Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
ar = [0, 0, 0, 0]
for _ in range(int(input())):
  s = input()
  ar[{"AC": 0, "WA": 1, "TLE": 2, "RE": 3}[s]] += 1
print("AC x", arr[0])
print("WA x", arr[1])
print("TLE x", arr[2])
print("RE x", arr[3])

Fixed submission:
arr = [0, 0, 0, 0]
for _ in range(int(input())):
  s = input()
  arr[{"AC": 0, "WA": 1, "TLE": 2, "RE": 3}[s]] += 1
print("AC x", arr[0])
print("WA x", arr[1])
print("TLE x", arr[2])
print("RE x", arr[3])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = list(map(int, input().split()))
acc = arr[0]
for e in arr[1:]:
  acc *= e
if acc > 1e18:
  print(-1)
else:
  print(acc)

Fixed submission:
n = int(input())
arr = list(map(int, input().split()))
if 0 in arr:
    print(0)
    exit()

acc = arr[0]
for i in range(1, n):
    acc *= arr[i]
    if acc > 1e18:
        print(-1)
        exit()
print(acc)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

arr = [[False] * k for _ in range(n)] # person, snack

for i in range(k):
    m = int(input())
    for p in map(int, input().split()):
        arr[p-1][i] = True

total = 0
for i in range(n):
    if not any(arr[i]):
        total += 1

print(total)


Fixed submission:
if input() == "ABC":
  print("ARC")
else:
  print("ABC")
Buggy python submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
if b == 1:
	print(0)
else:
	x = min(b-1, n)
	print(floor(a*x/b) - a * floor(x/b))

Fixed submission:
from math import floor
a, b, n = map(int, input().split())
if b == 1:
	print(0)
else:
	x = min(b-1, n)
	print(floor(a*x/b) - a * floor(x/b))

Buggy python submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
if b == 1:
  print(0)
  exit()
x = min(b-1, n)
print(floor(a*x/b) - a * floor(x/b))

Fixed submission:
from math import floor
a, b, n = map(int, input().split())
if b == 1:
	print(0)
else:
	x = min(b-1, n)
	print(floor(a*x/b) - a * floor(x/b))

Buggy python submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
x = min(b-1, n)
print(floor(a*x/b) - a * floor(x/b))

Fixed submission:
from math import floor
a, b, n = map(int, input().split())
if b == 1:
	print(0)
else:
	x = min(b-1, n)
	print(floor(a*x/b) - a * floor(x/b))

Buggy python submission (verdict: Runtime Error):
a, b, n = map(int(input().split()))
x = min(b-1, n)
print(floor(a*x/b) - a * floor(x/b))

Fixed submission:
from math import floor
a, b, n = map(int, input().split())
if b == 1:
	print(0)
else:
	x = min(b-1, n)
	print(floor(a*x/b) - a * floor(x/b))
Buggy python submission (verdict: Runtime Error):
from math import gcd
lcm = lambda x, y: x*y//gcd(x, y)

n, m = map(int, input().split())
arr = list(map(int, input().split()))
arr = [e//2 for e in arr]

cm = arr[0]
for e in arr[1:]:
    cm = lcm(cm, e)

if any([cm//e % 2 == 0 for e in arr]):
    print(0)
    exit()
print((m//cm+1)//2)


Fixed submission:
def gcd(x, y):
    if x == 0: return y
    return gcd(y%x, x)
lcm = lambda x, y: x*y//gcd(x, y)

n, m = map(int, input().split())
arr = list(map(int, input().split()))
arr = [e//2 for e in arr]

cm = arr[0]
for e in arr[1:]:
    cm = lcm(cm, e)

if any([cm//e % 2 == 0 for e in arr]):
    print(0)
    exit()
print((m//cm+1)//2)
Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if a == 0: return b
    if b == 0: return a
    return gcd(a % b, b % a)

n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
    g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Fixed submission:
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
    g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if a == 0: return b
    if b == 0: return a
    return gcd(a % b, b % a)

n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
        g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
        print("POSSIBLE")
else:
        print("IMPOSSIBLE")

Fixed submission:
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
    g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
from math import gcd
n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
        g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
        print("POSSIBLE")
else:
        print("IMPOSSIBLE")

Fixed submission:
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
    g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
from math import gcd
n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
	g = gcd(g, e)
if k <= max(arr) and k//g*g == k:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

Fixed submission:
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
    g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
from math import gcd
n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
  g = gcd(g, e)
if k <= max(arr) and k//g*g == k:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Fixed submission:
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
    g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
 
####
from collections import deque
def solve(N, M):
    ans = []
    if N & 1:
        tops = deque(xrange(1, 2 * M + 1))
        while tops:
            ans.append([tops.popleft(), tops.pop()])
 
    else:
        unused = set(range(N))
        d = 0
        for done in range(M):
            while True:
                d += 1
                for i in unused:
                    if (i + d) % N in unused:
                        break
                else:
                    continue
                unused.discard(i)
                unused.discard((i+d)%N)
                ans.append([i+1, (i+d)%N+1])
 
    for row in ans:
        print "{} {}".format(*row)

solve(*rrm())


Fixed submission:
FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
 
####
from collections import deque
def solve(N, M):
    ans = []
    if N & 1:
        tops = deque(xrange(1, 2 * M + 1))
        while tops:
            ans.append([tops.popleft(), tops.pop()])
 
    else:
        # 1, 2, 3, 4, ..., M
        # there are (M+1)/2 odd numbers
        odds = (M + 1) // 2
        evens = M - odds
        i = odds
        d = 1
        for m in range(1, odds + 1):
            ans.append([i, i+d])
            i -= 1
            d += 2
        i = 2 * odds + evens
        d = 2
        for m in range(1, evens + 1):
            ans.append([i, i+d])
            i -= 1
            d += 2
            
 
    for row in ans:
        print "{} {}".format(*row)

solve(*rrm())
Buggy python submission (verdict: Runtime Error):
from sys import setrecursionlimit as srl; srl(10**7)
rr = lambda: int(raw_input())
rrm = lambda: map(raw_input().split())



A,B,C = rrm()
if A==B!=C or A==C!=B or B==C!=A:
    print "Yes"
else:
    print "No"

Fixed submission:
from sys import setrecursionlimit as srl; srl(10**7)
rr = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())
 
A,B,C = rrm()
if A==B!=C or A==C!=B or B==C!=A:
    print "Yes"
else:
    print "No"
Buggy python submission (verdict: Runtime Error):
from sys import setrecursionlimit as srl; srl(10**7)
rr = lambda: int(raw_input())
rrm = lambda: map(raw_input().split())

YES,NO = "APPROVED","DENIED"
def solve(N, A):
    for x in A:
        if x % 2 == 0:
            if x % 3 or x % 5:
                return NO
    return YES

    
print solve(int(rr()), rrm())


Fixed submission:
from sys import setrecursionlimit as srl; srl(10**7)
rr = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())

YES,NO = "APPROVED","DENIED"
def solve(N, A):
    for x in A:
        if x % 2 == 0:
            if x % 3 and x % 5:
                return NO
    return YES

    
print solve(int(rr()), rrm())
Buggy python submission (verdict: Runtime Error):
from sys import setrecursionlimit as srl; srl(10**7)
rr = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())

N =int(rr())
from collections import Counter
count = Counter()
for _ in xrange(N):
    count[rr()] += 1
M = max(count.values())
ans = []
for k in count:
    if count[k] == M:
        ans.append(k)
ans.sort()
for x in ans:
    print x


Fixed submission:
from sys import setrecursionlimit as srl; srl(10**7)
rr = raw_input
rrm = lambda: map(int, raw_input().split())

N =int(rr())
from collections import Counter
count = Counter()
for _ in xrange(N):
    count[rr()] += 1
M = max(count.values())
ans = []
for k in count:
    if count[k] == M:
        ans.append(k)
ans.sort()
for x in ans:
    print x
Buggy python submission (verdict: Runtime Error):
import heapq
readints = lambda: map(int, raw_input().split())

def solve(N, M, A):
    pq = [-x for x in A]
    heapq.heapify(pq)
 
    for _ in xrange(M):
        x = -heapq.heappop(pq)
        x /= 2
        heapq.heappush(pq, -x)
    return -sum(pq)

N, M = readints()
print solve(N, M, rrm())

Fixed submission:
rr = raw_input
rri = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())

import heapq
def solve(N, M, A):
    pq = [-x for x in A]
    heapq.heapify(pq)

    for _ in xrange(M):
        x = -heapq.heappop(pq)
        x /= 2
        heapq.heappush(pq, -x)
    return -sum(pq)


N, M = rrm()
print solve(N, M, rrm())
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict as ddic, deque
from itertools import combinations, permutations, product
import sys
sys.setrecursionlimit(10**6)
stdout = sys.stdout
rr = lambda: raw_input().strip()
rri = lambda: int(raw_input())
rrm = lambda: list(map(int, raw_input().strip().split()))


def solve(N, A):
    memo = {}
    def dp(i, color):
        if i == N: return 0
        if (i, color) in memo:
            return memo[i, color]
        if color == 1:  # black
            # no white
            ans = dp(i+1, 1) + (A[i] != color)
        else:
            ans = min(dp(i+1, 0), dp(i+1, 1)) + (A[i] != color)
        memo[i, color] = ans
        return ans

    return min(dp(0, 0), dp(0, 1))
###
N = rri()
S = rr()
A = [1 if c == '#' else 0 for c in S]
print solve(N, A)


Fixed submission:
from collections import defaultdict as ddic, deque
from itertools import combinations, permutations, product
import sys
sys.setrecursionlimit(10**6)
stdout = sys.stdout
rr = lambda: raw_input().strip()
rri = lambda: int(raw_input())
rrm = lambda: list(map(int, raw_input().strip().split()))


def solve(N, A):
    dp0 = [0] * (N+1)
    dp1 = [0] * (N+1)
    for i in xrange(N-1, -1, -1):
        for color in (0, 1):
            if color == 1:
                ans = dp1[i+1] + (A[i] != color)
            else:
                ans = min(dp0[i+1], dp1[i+1]) + (A[i] != color)

            if color == 0:
                dp0[i] = ans
            else:
                dp1[i] = ans

    return min(dp0[0], dp1[0])

###
N = rri()
S = rr()
A = [1 if c == '#' else 0 for c in S]
print solve(N, A)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
rr = lambda: stdin.readline().strip()

N = int(rr())
A = map(int, rr().split())
MOD = 10**9 + 7
ct, ans = 0, 1
for x in A:
    ct += 1
    while ct > (x + 1)/2:
        ans *= ct
        ans %= MOD
        ct -= 1
while ct:
    ans *= ct
    ans %= MOD
print ans


Fixed submission:
from sys import stdin
rr = lambda: stdin.readline().strip()

N = int(rr())
A = map(int, rr().split())
MOD = 10**9 + 7
ct, ans = 0, 1
for x in A:
    ct += 1
    while ct > (x + 1)/2:
        ans *= ct
        ans %= MOD
        ct -= 1
for k in xrange(1, ct+1):
    ans *= k
    ans %= MOD
print ans
Buggy python submission (verdict: Runtime Error):
L=input().split()
a=L[0]
b=L[1]
c=L[2]
d=L[3]
print(max(a*c,b*d,a*d,b*c))

Fixed submission:
L=list(map(int,input().split()))
a=L[0]
b=L[1]
c=L[2]
d=L[3]
print(max(a*c,b*d,a*d,b*c))
Buggy python submission (verdict: Runtime Error):
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 10 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

N = int(input())
A = list(map(int, input().split()))
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

# calc prime
MAX = 10 ** 3 + 5
is_prime = [True] * (MAX)
is_prime[0] = False
is_prime[1] = False
i = 2
primes = []
while i < MAX:
    if is_prime[i]:
        for j in range(i+i, MAX, i):
            is_prime[j] = False
        primes.append(i)
    i += 1

cnt = defaultdict(int)
for a in A:
    x = a
    for p in primes:
        if x % p == 0:
            cnt[p] += 1
        while x > 1 and x % p == 0:
            x //= p
        if x <= 1:
            break
    if x > 1:
        cnt[x] += 1
if max(cnt.values()) <= 1:
    print('pairwise coprime')
    exit()

setwise = False
g = A[0]
for a in A:
    g = gcd(g, a)
if g == 1:
    setwise = True

if setwise:
    print('setwise coprime')
if not setwise:
    print('not coprime')

Fixed submission:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 10 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

N = int(input())
A = list(map(int, input().split()))
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

# calc prime
MAX = 10 ** 6 + 2
is_prime = [True] * (MAX + 1)
is_prime[0] = False
is_prime[1] = False
i = 2
primes = []
cnt_a = Counter(A)
if cnt_a[1] == N:
    print('pairwise coprime')
    exit()
cnt_facts = defaultdict(int)
while i < MAX:
    if is_prime[i]:
        if cnt_a[i]:
            cnt_facts[i] += cnt_a[i]
        for j in range(i+i, MAX, i):
            is_prime[j] = False
            if cnt_a[j]:
                cnt_facts[i] += cnt_a[j]
        primes.append(i)
    i += 1
if cnt_facts and max(cnt_facts.values()) <= 1:
    print('pairwise coprime')
    exit()
setwise = False
g = A[0]
for a in A:
    g = gcd(g, a)
if g == 1:
    setwise = True

if setwise:
    print('setwise coprime')
if not setwise:
    print('not coprime')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

N, K = map(int, input().split())
P = list(map(lambda x: int(x) - 1, input().split()))
C = list(map(int, input().split()))


ans = -INF
for i in range(N):
    nx = i
    total = 0
    L = [] 
    while True:
        nx = P[nx]
        total += C[nx]
        L.append(C[nx])
        if nx == i:
            break
    l = len(L)
    now = 0
    for j in range(l):
        if j + 1 > K:
            break
        now += L[j]
        ans = max(ans, now)
    if total > 0:
        now = total * (K // l)
        ans = max(ans, now)
        r = K % l
        for j in range(r):
            now += L[j]
            ans = max(ans, now)
print(ans)




Fixed submission:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

N, K = map(int, input().split())
P = list(map(lambda x: int(x) - 1, input().split()))
C = list(map(int, input().split()))


ans = -INF
for i in range(N):
    nx = i
    total = 0
    L = [] 
    while True:
        nx = P[nx]
        total += C[nx]
        L.append(C[nx])
        if nx == i:
            break
    l = len(L)
    tmp = 0
    for j in range(l):
        if j + 1 > K:
            break
        tmp += L[j]
        now = tmp
        if total > 0:
            e = (K - j - 1) // l
            now += total * e
        ans = max(ans, now)
    # if total > 0:
    #     now = total * (K // l)
    #     ans = max(ans, now)
    #     r = K % l
    #     for j in range(r):
    #         now += L[j]
    #         ans = max(ans, now)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

K = int(input())
if K % 2 == 0:
    print(-1)
    exit()

ans = 1
seven = 7
mod = 7 % K
while True:
    if seven % K == 0:
        break
    ans += 1
    seven = (seven * 10) % K + mod
print(ans)

Fixed submission:
K = int(input())

x = 7
ans = 1
for i in range(K + 1):
    if x % K == 0:
        print(ans)
        exit()
    x = (x * 10 + 7) % K
    ans += 1
print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

K = int(input())
if K % 2 == 0:
    print(-1)
    exit()

ans = 1
seven = 7
mod = 7 % K
while True:
    if seven % K == 0:
        break
    ans += 1
    seven = (seven % K) * 10 + mod
print(ans)

Fixed submission:
K = int(input())

x = 7
ans = 1
for i in range(K + 1):
    if x % K == 0:
        print(ans)
        exit()
    x = (x * 10 + 7) % K
    ans += 1
print(-1)
Buggy python submission (verdict: Runtime Error):
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

N = int(input())
S = list(input())

left = 0
right = N - 1

ans = 0
while right > left:
    while left < N and S[left] == 'R':
        left += 1
    while right > left and S[right] == 'W':
        right -= 1
    S[left], S[right] = S[right], S[left]
    ans += 1
    left += 1
    right -= 1

for i in range(right):
    if S[i] == 'W':
        S[i] = 'R'
        ans += 1
print(ans)

Fixed submission:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

N = int(input())
S = list(input())

goal = sorted(S)

ans = 0
for i in range(N):
    if S[i] != goal[i]:
        ans += 1
print(ans // 2)

Buggy python submission (verdict: Runtime Error):
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

N = int(input())
S = list(input())

left = 0
right = N - 1

ans = 0
while right - left > 1:
    while left < N and S[left] == 'R':
        left += 1
    while right > left and S[right] == 'W':
        right -= 1
    S[left], S[right] = S[right], S[left]
    ans += 1
    left += 1
    right -= 1

for i in range(right):
    if S[i] == 'W':
        S[i] = 'R'
        ans += 1
print(ans)


Fixed submission:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

N = int(input())
S = list(input())

goal = sorted(S)

ans = 0
for i in range(N):
    if S[i] != goal[i]:
        ans += 1
print(ans // 2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = 1000 - N % 1000
if a == 1000:
    print(0)
else:
    print(a

Fixed submission:
N = int(input())
a = 1000 - N % 1000
if a == 1000:
    print(0)
else:
    print(a)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
# list(map(int, input().split()))

n, k = map(int, input().split())
P = list(map(int, input().split()))

from itertools import combinations

ans = 10 ** 12
for i in combinations(P, k):
    ans = min(ans, sum(i))
print(ans)


Fixed submission:
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
# list(map(int, input().split()))

n, k = map(int, input().split())
P = list(sorted(map(int, input().split())))

print(sum(P[:k]))