Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
"""
方針
nは１<= n <= 200なので、
あらかじめ200まで全探索 O(n*2*√n)
"""
def countyakusu(n):
    cnt = 0
    for i in range(1,int(math.sqrt(n))+1):
        if n%i == 0:
            cnt += 1
            if i != n//i:
                cnt += 1
    return cnt
result = [0]*200
for i in range(1,201):
    if i%2 != 0:
        result[i-1] = countyakusu(i)

n = int(input())
cnt = 0
for i in range(n):
    if result[i] == 8:cnt += 1
print(cnt)

Fixed submission:
import math
"""
方針
nは１<= n <= 200なので、
あらかじめ200まで全探索 O(n*2*√n)
"""
def countyakusu(n):
    cnt = 0
    for i in range(1,int(math.sqrt(n))+1):
        if n%i == 0:
            cnt += 1
            if i != n//i:
                cnt += 1
    return cnt
result = [0]*200
for i in range(1,201):
    if i%2 != 0:
        result[i-1] = countyakusu(i)

n = int(input())
cnt = 0
for i in range(n):
    if result[i] == 8:cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

s = l()
alf = "abcdefghijklmnopqrstuvwxyz"
for i in range(len(s)):
	alf = alf.trplace(s[i],"")
print(alf)
if alf == "":
	print("None")
else:
	print(alf[0])


Fixed submission:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

s = l()
alf = "abcdefghijklmnopqrstuvwxyz"
for i in range(len(s)):
	alf = alf.replace(s[i],"")
if alf == "":
	print("None")
else:
	print(alf[0])

Buggy python submission (verdict: Runtime Error):
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    alpha = "abcdefghijklmnopqrstuvwxyz"
    inp = S()
    for i in inp:
        alpha = alpha.strip(i)
    print(alpha[0])

Fixed submission:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

s = l()
alf = "abcdefghijklmnopqrstuvwxyz"
for i in range(len(s)):
	alf = alf.replace(s[i],"")
if alf == "":
	print("None")
else:
	print(alf[0])
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a > b:
  print("GREATER")
elif a == b:
  print("EQUAL")
else:
  print("LESS")


Fixed submission:
a = int(input())
b = int(input())
if a > b:
  print("GREATER")
elif a == b:
  print("EQUAL")
else:
  print("LESS")

Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a > b:
  print("GREATER")
elif a == b:
  print("EQUAL")
else:
  print("LESS")

Fixed submission:
a = int(input())
b = int(input())
if a > b:
  print("GREATER")
elif a == b:
  print("EQUAL")
else:
  print("LESS")
Buggy python submission (verdict: Runtime Error):
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass

n = i()
a = intl()
if n == 1:print(0)
else:
    s = max(a)+min(a)
    k1 = s//2
    k2 = s//2 + s%2
    k3 = s//2 -1
    c1 = 0
    c2 = 0
    c3 = 0
    for i in range(n):
        c3 += (a[i]-k3)**2
        c2 += (a[i]-k2)**2
        c1 += (a[i]-k1)**2
    print(min(c1,c2,c3))

Fixed submission:
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass

n = i()
a = [i for i in range(1,n+1)]
print(sum(a))
Buggy python submission (verdict: Runtime Error):
n,l = map(int,input(),split())
s = [input() for _ in range(n)]
s.sort()
for k in s:
  print(k, end ="")

Fixed submission:
n,l = map(int,input().split())
s = [input() for i in range(n)]
s.sort()
for k in s:
  print(k, end ="")
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
snukes = [0] * n
for _ in range(k):
  d = int(input())
  a = map(int, input().split())
  for i in a:
    snukes[i] += 1

print(snukes.count(0))

Fixed submission:
n, k = map(int, input().split())
snukes = [0] * n
for _ in range(k):
  d = int(input())
  a = map(int, input().split())
  for i in a:
    snukes[i - 1] += 1
 
print(snukes.count(0))
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N,M=map(int,input().split())
    H=[int(_) for _ in input().split()]
    near=[[i] for i in range(N)]
    flag=[i for i in range(N)]
    AB=[]
    for m in range(M):
        ab=list(map(int,input().split()))
        if ab not in AB:
            AB.append(ab)
    for A,B in AB:
        near[A-1].append(B-1)
        near[B-1].append(A-1)
    ans=0
    for n in near:
        k=1
        for j in n[1:]:
            if H[n[0]] <= H[j]:
                k=0
        if k:
            ans+=1
    print(ans)

main()

Fixed submission:
def main():
    N,M=map(int,input().split())
    H=[int(_) for _ in input().split()]
    near=[[i] for i in range(N)]
    flag=[i for i in range(N)]
    for m in range(M):
        A,B=map(int,input().split())
        near[A-1].append(B-1)
        near[B-1].append(A-1)
    ans=0
    for n in near:
        k=1
        for j in n[1:]:
            if H[n[0]] <= H[j]:
                k=0
        if k:
            ans+=1
    print(ans)

main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    S=input()
    N=len(S)
    cnt=0
    for i in range(N-1):
        for j in range(i+1, N):
            if int(S[i:j+1])%2019==0:
                cnt+=1
    print(cnt)

main()


Fixed submission:
def main():
    MOD=2019
    S=input()[::-1]
    count=[1]+[0]*MOD
    r,tmp=0,1
    for i in S:
        r += int(i)*tmp
        r %= MOD
        tmp *= 10
        tmp %= MOD
        count[r] += 1

    print(sum([i*(i-1)//2 for i in count]))

main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    S=input()
    N=len(S)
    A=[0]+[int(s) for s in S]
    for i in range(N):
        A[i+1] += A[i]
    del A[0]
    cnt=0
    for i in range(N-1):
        for j in range(i+1, N):
            if int(S[i:j+1])%2019==0:
                cnt+=1
    print(cnt)

main()


Fixed submission:
def main():
    MOD=2019
    S=input()[::-1]
    count=[1]+[0]*MOD
    r,tmp=0,1
    for i in S:
        r += int(i)*tmp
        r %= MOD
        tmp *= 10
        tmp %= MOD
        count[r] += 1

    print(sum([i*(i-1)//2 for i in count]))

main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N=int(input())
    S=input()
    R=[]
    G=[]
    B=[]
    for s in range(N):
        if S[s]=='R':
            R.append(s)
        elif S[s]=='G':
            G.append(s)
        else:
            B.append(s)
    cnt=0
    for r in R:
        for g in G:
            for b in B:
                i=min(min(r,g),b)
                k=max(max(r,g),b)
                j=r+g+b-i-k
                if (j-i)!=(k-j):
                    cnt+=1
    print(cnt)
main()

Fixed submission:
def main():
    N=int(input())
    S=input()
    ans=S.count('R')*S.count('G')*S.count('B')
    for i in range(N):
        for d in range(N):
            j = i+d
            k = j+d
            if k >= N:
                break
            if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
                ans-=1
    print(ans)
main()
Buggy python submission (verdict: Runtime Error):
S=input()
N=len(S)

def kaibun_checker(s):
    rev_s = s[::-1]
    len_s = len(s)
    for i in range(len_s//2):
        if s[i]!=rev_s[i]:
            return False
    return True

if kaibun_checker(S[:]) and kaibun_checker(S[(N+3)//2]) and kaibun_checker(S[(N+3)//2-1:]):
    print('Yes')
else:
    print('No')

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

def kaibun_checker(s):
    rev_s = s[::-1]
    len_s = len(s)
    for i in range(len_s//2):
        if s[i]!=rev_s[i]:
            return False
    return True

if N==3:
    print('Yes' if S[0]==S[2] else 'No')
else:
    if kaibun_checker(S[:]) and kaibun_checker(S[(N+3)//2]) and kaibun_checker(S[(N+3)//2-1:]):
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
P=list(map(int,input().split()))
ans=sum(P[:K])/2+0.5*K
for i in range(N-K+1):
    _sum=sum(P[i:i+K])/2+0.5*K
    if ans<_sum:
        ans=_sum
print(ans)

Fixed submission:
N,K=map(int,input().split())
P=list(map(int,input().split()))
ans=sum(P[:K])/2+0.5*K
A,S=[0]*N,[0]*N
A[0]=S[0]=P[0]
for i in range(N-1):
    A[i+1]=P[i+1]
    S[i+1]=S[i]+A[i+1]

for i in range(N-K):
    tmp=(S[K+i]-S[i])/2+0.5*K
    if ans<tmp:
        ans=tmp
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N=int(input())
    P=[int(_) for _ in input().split()]
    ans = 0
    for i in range(N):
        if P[i] == min(P[:i+1]):
            ans += 1
    print(ans)
main()


Fixed submission:
INF=float('inf')

def main():
    N=int(input())
    P=[int(_) for _ in input().split()]
    tmp=INF
    ans = 0

    for i in range(N):
        if tmp > P[i]:
            ans += 1
        tmp = min(tmp, P[i])
    print(ans)

main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N=int(input())
    P=[int(_) for _ in input().split()]
    ans = 0

    for i in range(1,N+1):
        flag=0
        for j in range(1,i+1):
            if P[i-1] > P[j-1]:
                flag=1
            if flag:
                continue
        ans += abs(flag-1)
    print(ans)

main()


Fixed submission:
INF=float('inf')

def main():
    N=int(input())
    P=[int(_) for _ in input().split()]
    tmp=INF
    ans = 0

    for i in range(N):
        if tmp > P[i]:
            ans += 1
        tmp = min(tmp, P[i])
    print(ans)

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


Fixed submission:
A,B=map(int,input().split())
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)
print(lcm(A,B))
Buggy python submission (verdict: Runtime Error):
W = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
for j in range(7):
    if W[j] == input():
        print(7-j)

Fixed submission:
W = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

S = input()

for j in range(7):
    if W[j] == S:
        print(7-j)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N=int(input())
    A=[int(_) for _ in input().split()]
    ans = sum(A)-A[0]
    for i in range(N):
        ans = min(ans, abs(sum(A[:i]) - sum(A[i:])))
    print(ans)

main()

Fixed submission:
def main():
    N=int(input())
    A=[int(_) for _ in input().split()]
    left=0
    right=sum(A)
    ans=right
    for i in range(N):
        left+=A[i]
        right-=A[i]
        ans = min(ans, abs(left-right))
    print(ans)

main()
Buggy python submission (verdict: Time Limit Exceeded):
print(sum([_ for _ in range(int(input()))]))

Fixed submission:
N=int(input())
print(int((N-1)*N//2))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from itertools import combinations

N=int(input())
count=0
S=[Counter(sorted(input())) for i in range(N)]
for a,b in list(combinations(S, 2)):
    if a==b:
        count+=1
print(count)

Fixed submission:
N=int(input())
count=0
S=[input() for i in range(N)]
d={}

for i in S:
    a=''.join(sorted([c for c in i]))
    if a in d:
        count+=d[a]
        d[a]+=1
    else:
        d[a]=1
print(count)
Buggy python submission (verdict: Runtime Error):
from math import gcd

A,B,C,D=map(int,input().split())
Cdiv = B // C - (A-1) // C
Ddiv = B // D - (A-1) // D
cddiv = (C*D) // gcd(C, D)
CDdiv = B // (cddiv) - (A-1) // cddiv

print( (B-A+1) - Cdiv - Ddiv + CDdiv )

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

A,B,C,D=map(int,input().split())
Cdiv = B // C - (A-1) // C
Ddiv = B // D - (A-1) // D
cddiv = (C*D) // gcd(C, D)
CDdiv = B // (cddiv) - (A-1) // cddiv

print( (B-A+1) - Cdiv - Ddiv + CDdiv )
Buggy python submission (verdict: Runtime Error):
A,B,C=map(int,input().split())
print('NYoe s'[a==b==c::2])


Fixed submission:
A,B,C=map(int,input().split())
print('NYoe s'[A==B==C::2])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

def prime_decomposition(n):
	i=2
	table=[]
	while i*i <= n:
		while n%i == 0:
			n /= i
			table.append(i)
		i += 1
	if n > 1:
		table.append(n)
	return table

n=int(input())
a=list(map(int,input().split()))
ans_table = []
for i in a:
	ans_table.extend(prime_decomposition(i))
print(Counter(ans_table)[2])

Fixed submission:
N=input()
lst=map(int,input().split())
ans=0
for i in lst:
	while i%2 == 0:
		i //= 2
		ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = input()
if 1 <= N <= 999:
    print("ABC")
else:
    print("ABD")

Fixed submission:
N = int(input())
if 1 <= N <= 999:
    print("ABC")
else:
    print("ABD")
Buggy python submission (verdict: Time Limit Exceeded):
ans=[]
a,b,k=map(int,input().split())
if a+b<=2*k:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,b+1):
        if abs(a-i)<=k-1:
            print(i)
        elif abs(b-i)<=k-1:
            print(i)

Fixed submission:
a,b,k=map(int,input().split())
s=range(a,b+1)
for i in sorted(set(s[:k])|set(s[-k:])):
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split())
for i in range(a,b+1):
    if abs(a-i)<=k-1 or abs(b-i)<=k-1:
        print(i)

Fixed submission:
a,b,k=map(int,input().split())
s=range(a,b+1)
for i in sorted(set(s[:k])|set(s[-k:])):
    print(i)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=input()
if s[:a].isdigit() and s[a:b]=='-' and s[b:].isdigit():
    print("True")
else:
    print("No")

Fixed submission:
print(48-int(input()))
Buggy python submission (verdict: Time Limit Exceeded):
def get_prime_number_list(N):
    primes = [2]
    limit = int(N**0.5)
    data = [i+1 for i in range(2, N, 2)]
    while 1:
        p = data[0]
        if limit <= p:
            return primes + data
        primes.append(p)
        data = [e for e in data if e%p != 0]

def main():
    Q=int(input())
    primes = get_prime_number_list(10**5)
    prime_lst = [0] * (10**5+10)
    for prime in primes:
        prime_lst[prime] = 1

    ans = [0]*(10**5+10)

    for i in range(3, 10**5+10, 2):
        if prime_lst[i] and prime_lst[(i+1)//2]:
            ans[i] += 1

    for _ in range(Q):
        l,r=map(int,input().split())
        print(sum(ans[:r+1]) - sum(ans[:l]))

main()


Fixed submission:
from itertools import accumulate

def get_prime_number_list(N):
    # N以下の素数のリストを返す
    primes = [2]
    limit = int(N**0.5)
    data = [i+1 for i in range(2, N, 2)]
    while 1:
        p = data[0]
        if limit <= p:
            return primes + data
        primes.append(p)
        data = [e for e in data if e%p != 0]

def main():
    Q=int(input())
    primes = get_prime_number_list(10**5)
    prime_lst = [0]*(10**5+10)
    tmp = [0]*(10**5+10)
    for prime in primes:
        prime_lst[prime] = 1
    for i in range(3, 10**5+10, 2):
        if prime_lst[i] and prime_lst[(i+1)//2]:
            tmp[i] = 1
    ans = list(accumulate(tmp))
    l_r = []
    for _ in range(Q):
        l_r.append(map(int,input().split()))
    for l,r in l_r:
        print(ans[r] - ans[l-1])

main()

Buggy python submission (verdict: Time Limit Exceeded):
def check_similar_num_2017(N, prime_lst):
    return (N in prime_lst) and ((N+1)//2 in prime_lst)

def get_prime_number_list(N):
    prime_lst = [2]
    limit = int(N**0.5)
    data = [i+1 for i in range(2, N, 2)]
    while 1:
        p = data[0]
        if limit <= p:
            return prime_lst + data
        prime_lst.append(p)
        data = [e for e in data if e%p != 0]

def main():
    Q=int(input())
    prime_lst = get_prime_number_list(10**5)
    for _ in range(Q):
        cnt = 0
        l,r=map(int,input().split())
        for i in range(l, r+1, 2):
            cnt += check_similar_num_2017(i, prime_lst)
        print(cnt)

main()


Fixed submission:
from itertools import accumulate

def get_prime_number_list(N):
    # N以下の素数のリストを返す
    primes = [2]
    limit = int(N**0.5)
    data = [i+1 for i in range(2, N, 2)]
    while 1:
        p = data[0]
        if limit <= p:
            return primes + data
        primes.append(p)
        data = [e for e in data if e%p != 0]

def main():
    Q=int(input())
    primes = get_prime_number_list(10**5)
    prime_lst = [0]*(10**5+10)
    tmp = [0]*(10**5+10)
    for prime in primes:
        prime_lst[prime] = 1
    for i in range(3, 10**5+10, 2):
        if prime_lst[i] and prime_lst[(i+1)//2]:
            tmp[i] = 1
    ans = list(accumulate(tmp))
    l_r = []
    for _ in range(Q):
        l_r.append(map(int,input().split()))
    for l,r in l_r:
        print(ans[r] - ans[l-1])

main()
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
n=int(input())
lst=list(map(int,input().split()))
count=0
def gcd(*numbers):
    return reduce(math.gcd, numbers)
result = gcd(*lst)
while 1:
    if result%2 == 0:
        count += 1
        result //= 2
    else:
        break
print(count)

Fixed submission:
n=int(input())
lst=list(map(int,input().split()))
count=0
def check(lst):
    for i in lst:
        if i%2 != 0:
            return False
    return True
def two_devision(lst):
    new_lst=[]
    for i in lst:
        new_lst.append(i//2)
    return new_lst
while check(lst):
    lst=two_devision(lst)
    count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

n=int(input())
lst=list(map(int,input().split()))
count=0

def gcd(*numbers):
    return reduce(math.gcd, numbers)

result = gcd(*lst)

while 1:
    if result%2 == 0:
        count += 1
        result //= 2
    else:
        break
print(count)

Fixed submission:
n=int(input())
lst=list(map(int,input().split()))
count=0
def check(lst):
    for i in lst:
        if i%2 != 0:
            return False
    return True
def two_devision(lst):
    new_lst=[]
    for i in lst:
        new_lst.append(i//2)
    return new_lst
while check(lst):
    lst=two_devision(lst)
    count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
import math
print(math.floor(math.sqrt(int(input())))**2)

Fixed submission:
print("YES" if input()==input()[::-1] else "NO")
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
def gcd(a,b):
    if b==0:
        return a
    return gcd(b, a%b)
element=gcd(A[0], A[1])
if N!=2:
    for _ in range(2, N):
        element=gcd(element, A[_])

print("POSSIBLE" if K%element==0 and max(A)>=K else "IMPOSSIBLE")

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
def gcd(a,b):
    if b==0:
        return a
    return gcd(b, a%b)
if N==1:
    print("POSSIBLE" if K==A[0] else "IMPOSSIBLE")
    exit()
element=gcd(A[0], A[1])
if N!=2:
    for _ in range(2, N):
        element=gcd(element, A[_])

print("POSSIBLE" if K%element==0 and max(A)>=K else "IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
c = [map(int,input().split()) for i in range(M)]
result = [0]*N

for a,b in c:
    result[a-1] += 1
    result[b-1] += 1

for i in result:
    print(i)

Fixed submission:
A,B,C = map(int,input().split())
if A<=C<=B:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
print(n*800-adder*200)

Fixed submission:
n=int(input())
print(n*800-(n//15)*200)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
k,s=map(int,input().split())
count=0
ans=list(itertools.product(list(range(k+1)),repeat=3))
for i in ans:
    if sum(i)==s:
        count+=1
print(count)

Fixed submission:
k,s=map(int,input().split())
count=0
for x in range(k+1):
    for y in range(k+1):
        if 0<=s-x-y<=k:
            count+=1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N=int(input())
    a=[int(_) for _ in input().split()]
    pair = []
    ans = 0
    for i in range(N):
        fst = a[a[i]-1]
        snd = a[fst-1]
        pair.append((fst,snd))
    pair=list(set(pair))
    for i in range(len(pair)-1):
        for j in range(i+1,len(pair)):
            if pair[i][0]==pair[j][1] and pair[i][1]==pair[j][0]:
                ans += 1
    print(ans)

main()

Fixed submission:
def main():
    N=int(input())
    a=[int(_) for _ in input().split()]
    ans = 0
    for i,v in enumerate(a):
        if a[v-1] == i+1:
            ans += 1
    print(ans//2)

main()
Buggy python submission (verdict: Runtime Error):
sorted_lst=sorted(list(map(int,input().split())))
if so_lst[0]==5 and so_lst[1] == 5 and so_lst[2]==7:
    print("YES")
else:
    print("NO")

Fixed submission:
lst=list(map(int,input().split()))
so_lst=sorted(lst)
if so_lst[0]==5 and so_lst[1] == 5 and so_lst[2]==7:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
n = int(input())
c = [l for l in input()]
max_idx = len(c)-1

if 'W' not in c:
  print(0)
else:
  most_left_white = c.index('W')
  tmp = c[::-1]
  most_right_red = max_idx - tmp.index('R')

  cnt = 0
  while most_left_white<most_right_red:
    c[most_left_white] = 'R'
    c[most_right_red] = 'W'

    most_left_white = c.index('W')
    tmp = c[::-1]
    most_right_red = max_idx - tmp.index('R')
    cnt+=1
  print(cnt)

  

Fixed submission:
n = int(input())
c = [l for l in input()]
ideal = ['R']*(c.count('R')) + ['W']*(c.count('W'))

w_to_r=0
r_to_w=0
for i_, c_ in zip(ideal, c):
  if (i_=='R') and (c_=='W'):
    w_to_r+=1
  if (i_=='W') and (c_=='R'):
    r_to_w+=1

print(max(w_to_r, r_to_w))