Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#電球クラス
class Light:
    def __init__(self,name,switchs,whattype):
        self.name=name
        self.switchs=switchs
        self.whattype=whattype
    def reset(self):
        sumnum=0
        for switch in self.switchs:
            sumnum+=switch.onoff
        if sumnum%2==0:
            self.state="off"
        else:
            self.state="on"
            
#スイッチクラス            
class Switch:
    def __init__(self,name):
        self.name=name
        self.onoff=0
    def click(self,onoff):
        self.onoff=onoff
        
    
#整理用データ
n,m=[int(i) for i in input().split()]
allist=[]
for i in range(m+1):
    allist.append([int(j) for j in input().split()])
      

#全スイッチのリスト
switchlist=[]
for i in range(n):
    switchlist.append(Switch(i))


#全電球のリスト
lightlist=[]
for i in range(m):
    swlist=[]
    swnum=allist[i][1:]
    for j in swnum:
        swlist.append(switchlist[j-1])
    whattype=allist[-1][i]
    lightlist.append(Light(i,swlist,whattype))
    
#全部の付け方について
count=0
clicklist=[0 for i in range(n)]    
for i in range(2**n):
    onoffcheck=0
    j=0
    while i:
        clicklist[j]=i%2
        i=i//2
        j+=1
    for k in range(n):
        switchlist[k].click(clicklist[k])
    for light in lightlist:
        light.reset()
        if light.state=="off":
            onoffcheck+=1
    for i in lightlist:
#         print(i.state)
    if onoffcheck==0:
        count+=1
print(count)
    

Fixed submission:
#電球クラス
class Light:
    def __init__(self,name,switchs,whattype):
        self.name=name
        self.switchs=switchs
        self.whattype=whattype
    def reset(self):
        sumnum=0
        for switch in self.switchs:
            sumnum+=switch.onoff
        if sumnum%2==self.whattype:
            self.state="on"
        else:
            self.state="off"
            
#スイッチクラス            
class Switch:
    def __init__(self,name):
        self.name=name
        self.onoff=0
    def click(self,onoff):
        self.onoff=onoff
        
    
#整理用データ
n,m=[int(i) for i in input().split()]
allist=[]
for i in range(m+1):
    allist.append([int(j) for j in input().split()])
      

#全スイッチのリスト
switchlist=[]
for i in range(n):
    switchlist.append(Switch(i))


#全電球のリスト
lightlist=[]
for i in range(m):
    swlist=[]
    swnum=allist[i][1:]
    for j in swnum:
        swlist.append(switchlist[j-1])
    whattype=allist[-1][i]
    lightlist.append(Light(i,swlist,whattype))
    
#全部の付け方について
count=0
clicklist=[0 for i in range(n)]    
for i in range(2**n):
    onoffcheck=0
    j=0
    while i:
        clicklist[j]=i%2
        i=i//2
        j+=1
    for k in range(n):
        switchlist[k].click(clicklist[k])
    for light in lightlist:
        light.reset()
        if light.state=="off":
            onoffcheck+=1
    if onoffcheck==0:
        count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
n=int(input())

#ノードクラスの定義
class Node:
    def __init__(self,name):
        self.name=name
        self.near=[]
        self.length=[]
    def coloring(self,color):
        self.color=color


#ノードリストの作成
nodelist=[]
for i in range(n):
    nodelist.append(Node(i))
   
    
#辺の作成
for i in range(n-1):
    u,v,w=[int(i) for i in input().split()]
    w=w%2
    nodelist[u-1].near.append(nodelist[v-1])
    nodelist[u-1].length.append(w)
    nodelist[v-1].near.append(nodelist[u-1])
    nodelist[v-1].length.append(w)
    
#行ったかカラーでチェックリスト
color=[None for i in range(n)]
color[0]=0



def paint(node):
    nodecolor=node.color
    for j in range(len(node.near)):
        nearnode=node.near[j]
        if color[nearnode.name]!=None:
            continue
        if node.length[j]==0:
            nearnode.coloring(nodecolor)
        else:
            nearnode.coloring((nodecolor+1)%2)
        color[nearnode.name]=0
        paint(nearnode)

nodelist[0].coloring(0)
paint(nodelist[0])


for i in nodelist:
    print(i.color)
            
        
    

Fixed submission:
import sys

sys.setrecursionlimit(1000000)


n=int(input())

#ノードクラスの定義
class Node:
    def __init__(self,name):
        self.name=name
        self.near=[]
        self.length=[]
    def coloring(self,color):
        self.color=color


#ノードリストの作成
nodelist=[]
for i in range(n):
    nodelist.append(Node(i))
   
    
#辺の作成
for i in range(n-1):
    u,v,w=[int(i) for i in input().split()]
    w=w%2
    nodelist[u-1].near.append(nodelist[v-1])
    nodelist[u-1].length.append(w)
    nodelist[v-1].near.append(nodelist[u-1])
    nodelist[v-1].length.append(w)
    
#行ったかカラーでチェックリスト
color=[None for i in range(n)]
color[0]=0



def paint(node):
    nodecolor=node.color
    for j in range(len(node.near)):
        nearnode=node.near[j]
        if color[nearnode.name]!=None:
            continue
        if node.length[j]==0:
            nearnode.coloring(nodecolor)
        else:
            nearnode.coloring((nodecolor+1)%2)
        color[nearnode.name]=0
        paint(nearnode)

nodelist[0].coloring(0)
paint(nodelist[0])


for i in nodelist:
    print(i.color)
Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())
t=list(input())
n=len(s)
def get_count_list(s):
    alphabets="abcdefghijklmnopqrstuvwxyz"
    ans={}
    for alphabet in alphabets:
        ans[alphabet]=[]
    for i in range(n):
        ans[s[i]].append(i)
    return ans


def get_index2alpha(s):
    ans={}
    for i in range(n):
        ans[i]=s[i]
    return ans

s_count=get_count_list(s)
t_count=get_count_list(t)
s_index=get_index2alpha(s)
t_index=get_index2alpha(t)

ans=0
for i in range(len(s)):
    if not s_count[s_index[i]]==t_count[t_index[i]]:
        ans+=1

if ans==0:
    print("Yes")
else:
    print("No")

Fixed submission:
s=list(input())
t=list(input())
n=len(s)
def get_count_list(s):
    alphabets="abcdefghijklmnopqrstuvwxyz"
    ans={}
    for alphabet in alphabets:
        ans[alphabet]=[]
    for i in range(n):
        ans[s[i]].append(i)
    return ans


def get_index2alpha(s):
    ans={}
    for i in range(n):
        ans[i]=s[i]
    return ans

s_count=get_count_list(s)
t_count=get_count_list(t)
s_index=get_index2alpha(s)
t_index=get_index2alpha(t)

ans=0

s_set=set(s)


for i in range(n):
    s_alpha=s_index[i]
    t_alpha = t_index[i]
    if s_alpha in s_set:
        s_set.remove(s_alpha)
        if not s_count[s_alpha]==t_count[t_alpha]:
            ans+=1

if ans==0:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=input()

def get_count_list(s):
    alphabets="abcdefghijklmnopqrstuvwxyz"
    ans={}
    for alphabet in alphabets:
        ans[alphabet]=[]
    for j,i in enumerate(s):
        ans[i].append(j)
    return ans


def get_index2alpha(s):
    ans={}
    for i,c in enumerate(s):
        ans[i]=c
    return ans

s_count=get_count_list(s)
t_count=get_count_list(t)
s_index=get_index2alpha(s)
t_index=get_index2alpha(t)

ans=0
for i in range(len(s)):
    if not s_count[s_index[i]]==t_count[t_index[i]]:
        ans+=1

if ans==0:
    print("Yes")
else:
    print("No")

Fixed submission:
s=list(input())
t=list(input())
n=len(s)
def get_count_list(s):
    alphabets="abcdefghijklmnopqrstuvwxyz"
    ans={}
    for alphabet in alphabets:
        ans[alphabet]=[]
    for i in range(n):
        ans[s[i]].append(i)
    return ans


def get_index2alpha(s):
    ans={}
    for i in range(n):
        ans[i]=s[i]
    return ans

s_count=get_count_list(s)
t_count=get_count_list(t)
s_index=get_index2alpha(s)
t_index=get_index2alpha(t)

ans=0

s_set=set(s)


for i in range(n):
    s_alpha=s_index[i]
    t_alpha = t_index[i]
    if s_alpha in s_set:
        s_set.remove(s_alpha)
        if not s_count[s_alpha]==t_count[t_alpha]:
            ans+=1

if ans==0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import functools
def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)

def gcd(nums):
    return functools.reduce(euclid, nums)



n,k=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]

a.sort()

sa=[]

for i in range(1,n):
    sa.append(a[i]-a[i-1])



print(gcd(sa))



Fixed submission:
import functools
def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)

def gcd(nums):
    if len(nums)==1:
        return nums[0]
    return functools.reduce(euclid, nums)



n,k=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
a.append(k)
a.sort()

sa=[]

for i in range(1,n+1):
    sa.append(a[i]-a[i-1])



print(gcd(sa))
Buggy python submission (verdict: Runtime Error):
moji=input()

if moji.sort()=="abc":
    print("Yes")
else:
    print("No")

Fixed submission:
moji=list(input())
moji.sort()
a="".join(moji)

if a=="abc":
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=[int(i) for i in input().split()]
c=[]
for i in range(a,b+1):
    c.append(i)
head=c[:k]
tail=c[::-1][:k]
d=head+tail
e=list(set(d))
e.sort()
for i in e:
    print(i)

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

if b-a+1>=2*k:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)

Buggy python submission (verdict: Runtime Error):
a,b,k=[int(i) for i in input().split()]
c=list(range(a,b+1))

head=c[:k]
# tail=c[::-1][:k]
# d=head+tail
# e=list(set(d))
# e.sort()
# for i in e:
#     print(i)

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

if b-a+1>=2*k:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)

Buggy python submission (verdict: Runtime Error):
a,b,k=[int(i) for i in input().split()]
c=list(range(a,b+1))

head=c[:k]
tail=c[::-1][:k]
d=head+tail
# e=list(set(d))
# e.sort()
# for i in e:
#     print(i)

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

if b-a+1>=2*k:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)

Buggy python submission (verdict: Runtime Error):
a,b,k=[int(i) for i in input().split()]
c=list(range(a,b+1))

head=c[:k]
tail=c[::-1][:k]
d=head+tail
e=list(set(d))
e.sort()
for i in e:
    print(i)

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

if b-a+1>=2*k:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)

Buggy python submission (verdict: Runtime Error):
a,b,k=[int(i) for i in input().split()]
c=list(range(a,b+1))

d=c[:k]+c[::-1][:k]
e=list(set(d))
e.sort()
for i in e:
    print(i)

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

if b-a+1>=2*k:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)
Buggy python submission (verdict: Runtime Error):
n=int(input())

march=[0]*5

march_dic={"M":0,"A":1,"R":2,"C":3,"H":4}

for i in range(n):
    name=input()
    if name[0] in "MARCH":
        march[march_dic[name[0]]]+=1

def count_type(march):
    ans=[]
    for i in march:
        if i!=0:
            ans.append(i)
    ans.sort()
    return n-march.count(0),ans

type_num,each_num=count_type(march)
if type_num<3:
    print(0)
else:
    ans=0
    for i in range(type_num-2):
        for j in range(i+1,type_num-1):
            for k in range(j+1,type_num):
                ans+=each_num[i]*each_num[j]*each_num[k]

    print(ans)


Fixed submission:
n=int(input())

march=[0]*5

march_dic={"M":0,"A":1,"R":2,"C":3,"H":4}

for i in range(n):
    name=input()
    if name[0] in "MARCH":
        march[march_dic[name[0]]]+=1

def count_type(march):
    ans=[]
    for i in march:
        if i!=0:
            ans.append(i)
    ans.sort()
    return len(ans),ans

type_num,each_num=count_type(march)
if type_num<3:
    print(0)
else:
    ans=0
    for i in range(type_num-2):
        for j in range(i+1,type_num-1):
            for k in range(j+1,type_num):
                ans+=each_num[i]*each_num[j]*each_num[k]

    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]

a.sort()

times=[0]*(n+1)
for i in a:
    times[i]+=1
times.sort()

while True:
    if times[0]==0:
        del times[0]
    else:
        break
ans=0
if len(times)>k:
    for i in range(len(times)-k):
        ans+=times[i]
print(ans)

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

a.sort()

times=[0]*(n+1)
for i in a:
    times[i]+=1
times.sort()


for i in range(n+1):
    if times[i]!=0:
        j=i
        break

ans=0
if len(times)>k-j:
    for i in range(j,len(times)-k):
        ans+=times[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
a=input().split()
if a[0]==a[1] and a[1]==a[2] and a[2]!=a[3]:
    print("Yes")
elif a[3]==a[1] and a[1]==a[2] and a[1]!=a[0]:
    print("Yes")
else:
    print("No")
    

Fixed submission:
a=input()
if a[0]==a[1] and a[1]==a[2]:
    print("Yes")
elif a[3]==a[1] and a[1]==a[2]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
for i in a:
#     print(i)
    if pre<i-2:
        succession=0
        pre=i
        maxnum=max(maxnum,sum(check))
        check=[1,0,0]
    elif pre==i:
        check[succession]+=1
    elif pre==i-1 and succession==0:
        succession+=1
        check[1]+=1
        pre=i
    elif pre==i-1 and succession==1:
        succession+=1
        check[2]+=1
        pre=i
    elif pre==i-1 and succession==2:
        maxnum=max(maxnum,sum(check))
        check=[check[1],check[2],1]
        pre=i
    elif pre==i-2:
        maxnum=max(maxnum,sum(check))
        check=[check[succession],0,1]
        succession=2
        pre=i
#     print(check)
maxnum=max(maxnum,sum(check))

print(maxnum)

Fixed submission:
n=int(input())

a=[int(i) for i in input().split()]
a.sort()

succession=0
pre=-10000
maxnum=0
check=[0,0,0]

for i in a:
#     print(i)
    if pre<i-2:
        succession=0
        pre=i
        maxnum=max(maxnum,sum(check))
        check=[1,0,0]
    elif pre==i:
        check[succession]+=1
    elif pre==i-1 and succession==0:
        succession+=1
        check[1]+=1
        pre=i
    elif pre==i-1 and succession==1:
        succession+=1
        check[2]+=1
        pre=i
    elif pre==i-1 and succession==2:
        maxnum=max(maxnum,sum(check))
        check=[check[1],check[2],1]
        pre=i
    elif pre==i-2:
        maxnum=max(maxnum,sum(check))
        check=[check[succession],0,1]
        succession=2
        pre=i
#     print(check)
maxnum=max(maxnum,sum(check))

print(maxnum)
Buggy python submission (verdict: Runtime Error):
a,b=[int(i) for i in input().split()]

if a==b:
    print("H")
else:
    print("D")

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

if a==b:
    print("H")
else:
    print("D")
Buggy python submission (verdict: Runtime Error):
n, m = [int(i) for i in input().split()]

if n >= 2 * m:
    print(m // 2)
else:
    print(n + (m - 2 * n) // 2)
n, m = [int(i) for i in input().split()]

if n >= 2 * m:
    print(m // 2)
else:
    print(n + (m - 2 * n) // 4)

Fixed submission:
n, m = [int(i) for i in input().split()]

if 2*n >= m:
    print(m // 2)
else:
    print(n + (m - 2 * n) // 4)

Buggy python submission (verdict: Runtime Error):
n, m = [int(i) for i in input().split()]

if n >= 2 * m:
    print(m // 2)
else:
    print(n + (m - 2 * n) // 2)
n, m = [int(i) for i in input().split()]

if n >= 2 * m:
    print(m // 2)
else:
    print(n + (m - 2 * n) // 4)


Fixed submission:
n, m = [int(i) for i in input().split()]

if 2*n >= m:
    print(m // 2)
else:
    print(n + (m - 2 * n) // 4)
Buggy python submission (verdict: Runtime Error):
a=list(input()+"A")[::-1]
b=list(input()+"B")[::-1]
c=list(input()+"C")[::-1]

turn=a

def game(turn):
    card=turn.pop()
    if len(turn)==0:
        print(card)
    
    if card=="a":
        turn=a
    elif card=="b":
        turn=b
    else:
        turn=c
    
    game(turn)
    
game(turn)

Fixed submission:
a=list(input()+"A")[::-1]
b=list(input()+"B")[::-1]
c=list(input()+"C")[::-1]

turn=a

def game(turn):
    card=turn.pop()
    if len(turn)==0:
        print(card)
    else:
        
    
        if card=="a":
            turn=a
        elif card=="b":
            turn=b
        else:
            turn=c
    
        game(turn)
    
game(turn)
Buggy python submission (verdict: Runtime Error):
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p


MOD = 10**9 + 7
N = 10**6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)

ans = 0
for i in range(1, s // 3 + 1):
    rest = s - 3 * i
    ans += cmb(rest + i - 1, rest, MOD)

print(ans % MOD)

Fixed submission:
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p


MOD = 10**9 + 7
N = 10**6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)

s = int(input())

ans = 0
for i in range(1, s // 3 + 1):
    rest = s - 3 * i
    ans += cmb(rest + i - 1, rest, MOD)

print(ans % MOD)
Buggy python submission (verdict: Runtime Error):
n = int(input())
arr = list(map(int, input().split()))

ans = 0
sum_arr = sum(arr)

for x in arr:
    ans += x * (sum_arr - x) // 2
    ans %= MOD

print(ans)

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

MOD = 10**9 + 7

ans = 0
sum_arr = sum(arr)

for x in arr:
    sum_arr -= x
    ans += x * sum_arr
    ans %= MOD

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

MOD = 10**9 + 7

n = int(input())
arr = list(map(int, input().split()))

ans = 0
for x, y in combinations(arr, 2):
    ans += x * y
    ans %= MOD

print(ans)

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

MOD = 10**9 + 7

ans = 0
sum_arr = sum(arr)

for x in arr:
    sum_arr -= x
    ans += x * sum_arr
    ans %= MOD

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

h, w = map(int, input().split())
sx, sy = map(int, input().split())
gx, gy = map(int, input().split())
sx -= 1
sy -= 1
gx -= 1
gy -= 1

moves = [(1, 0), (-1, 0), (0, 1), (0, -1)]
ts = [(x, y) for x in range(-2, 3)
      for y in range(-2, 3) if not (x, y) in moves and (x, y) != (0, 0)]

grid = [list(map(str, input().rstrip())) for _ in range(h)]

q = deque([(sx, sy)])
qq = deque([(sx, sy)])

grid[sx][sy] = 0

while len(q) > 0 or len(qq) > 0:
    while q:
        (cx, cy) = q.popleft()
        for m in moves:
            nx, ny = cx + m[0], cy + m[1]
            if 0 <= nx < h and 0 <= ny < w:
                if grid[nx][ny] == ".":
                    grid[nx][ny] = grid[cx][cy]
                    q.append((nx, ny))
                elif grid[nx][ny] == "#":
                    qq.append((cx, cy))
    while qq:
        (cx, cy) = qq.popleft()
        for t in ts:
            nx, ny = cx + t[0], cy + t[1]
            if 0 <= nx < h and 0 <= ny < w:
                if grid[nx][ny] == ".":
                    grid[nx][ny] = grid[cx][cy] + 1
                    q.append((nx, ny))

print(grid[gx][gy] if grid[gx][gy] != "." else -1)

Fixed submission:
from collections import deque

h, w = map(int, input().split())
sx, sy = map(int, input().split())
gx, gy = map(int, input().split())
sx -= 1
sy -= 1
gx -= 1
gy -= 1

moves = [(1, 0), (-1, 0), (0, 1), (0, -1)]
ts = [(x, y) for x in range(-2, 3)
      for y in range(-2, 3) if not (x, y) in moves and (x, y) != (0, 0)]

grid = [list(map(str, input().rstrip())) for _ in range(h)]

q = deque([(sx, sy)])
qq = deque([(sx, sy)])

grid[sx][sy] = 0

while len(q) > 0 or len(qq) > 0:
    while q:
        (cx, cy) = q.popleft()
        for m in moves:
            nx, ny = cx + m[0], cy + m[1]
            if 0 <= nx < h and 0 <= ny < w:
                if grid[nx][ny] == ".":
                    grid[nx][ny] = grid[cx][cy]
                    q.append((nx, ny))
                elif grid[nx][ny] == "#":
                    qq.append((cx, cy))
    while qq:
        (cx, cy) = qq.popleft()
        for t in ts:
            nx, ny = cx + t[0], cy + t[1]
            if 0 <= nx < h and 0 <= ny < w:
                if grid[nx][ny] == ".":
                    grid[nx][ny] = grid[cx][cy] + 1
                    q.append((nx, ny))

print(grid[gx][gy] if grid[gx][gy] != "." else -1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = input()

ans = 0

while len(arr) > 1:
    left = -1
    right = -1

    if "W" in arr:
        left = arr.index("W")
    else:
        break
    if "R" in arr:
        right = len(arr) - arr[::-1].index("R") - 1
    else:
        break

    if left == -1 or right == -1 or left > right:
        break
    else:
        arr = arr[left + 1:right]
        ans += 1

print(ans)

Fixed submission:
import numpy as np
n = int(input())
arr = input()

dp = [[0] * (n + 1) for _ in range(2)]
dp[1][0] = arr.count("R")

for i in range(1, n + 1):
    if arr[i - 1] == "W":
        dp[0][i] = dp[0][i - 1] + 1
        dp[1][i] = dp[1][i - 1]
    if arr[i - 1] == "R":
        dp[0][i] = dp[0][i - 1]
        dp[1][i] = dp[1][i - 1] - 1


dp = np.array(dp)

print(dp.min(axis=0).max())

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

ans = 0

while "WR" in arr:
    left = arr.index("W")
    right = len(arr) - arr[::-1].index("R") - 1
    arr = arr[:left] + "R" + arr[left+1:right] + "W" + arr[right+1:]
    ans += 1

print(ans)

Fixed submission:
import numpy as np
n = int(input())
arr = input()

dp = [[0] * (n + 1) for _ in range(2)]
dp[1][0] = arr.count("R")

for i in range(1, n + 1):
    if arr[i - 1] == "W":
        dp[0][i] = dp[0][i - 1] + 1
        dp[1][i] = dp[1][i - 1]
    if arr[i - 1] == "R":
        dp[0][i] = dp[0][i - 1]
        dp[1][i] = dp[1][i - 1] - 1


dp = np.array(dp)

print(dp.min(axis=0).max())
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
arr = np.array(list(map(int, input().split())))

l = 1
r = max(arr)

while l + 1 < r:
    m = (l + r) // 2

    cut = 0
    for x in arr:
        cut += (x - 1) // m

    if cut > k:
        l = m
    else:
        r = m

print(r)

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

l = 0
r = max(arr)

while l + 1 < r:
    m = (l + r) // 2

    cut = 0
    for x in arr:
        cut += (x - 1) // m

    if cut > k:
        l = m
    else:
        r = m

print(r)
Buggy python submission (verdict: Time Limit Exceeded):
import math


def solve(n):
    cap = math.ceil(n**0.5) - 2
    return sum([((x + y + z)**2 - x * y - x * z - y * z) == n for x in range(1, cap + 1) for y in range(1, cap + 1) for z in range(1, cap + 1)])


n = int(input())

for i in range(1, n + 1):
    print(solve(i))

Fixed submission:
ans = [0] * 10**6

for x in range(1, 99):
    for y in range(1, 99):
        for z in range(1, 99):
            ans[(x + y + z)**2 - x * y - x * z - y * z] += 1

n = int(input())

for i in range(1, n + 1):
    print(ans[i])