Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

s = input()

def fact(n):
  ans = 1
  for i in range(2,n+1):
    ans*=i
  return ans

m = max(s.count("B"),s.count("W"))
print(fact(m))

Fixed submission:
from collections import defaultdict

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

s = input()

ans = 0
bCount = 0
for i in s:
  if i=="B":
    bCount += 1
  else:
    ans+=bCount
print(ans)
Buggy python submission (verdict: Runtime Error):
N, K, *h = map(int, open(0).read().split())
h = sorted(h)
ans=float("inf")
for i in range(len(h)-k+1):
	ma = h[i+k-1]
	mi = h[i]
	ans = min(ans,ma-mi)

print(ans)

Fixed submission:
n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h.sort()
ans=float("inf")
for i in range(len(h)-k+1):
	ma = h[i+k-1]
	mi = h[i]
	ans = min(ans,ma-mi)

print(ans)

Buggy python submission (verdict: Runtime Error):
N, K, *h = map(int, open(0).read().split())
h.sort()
ans=float("inf")
for i in range(len(h)-k+1):
	ma = h[i+k-1]
	mi = h[i]
	ans = min(ans,ma-mi)

print(ans)

Fixed submission:
n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h.sort()
ans=float("inf")
for i in range(len(h)-k+1):
	ma = h[i+k-1]
	mi = h[i]
	ans = min(ans,ma-mi)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h.sort()
ans=float("inf")
for i in range(len(h)-k+1):
	ma = max(h[i:i+k])
	mi = min(h[i:i+k])
	ans = min(ans,ma-mi)

print(ans)

Fixed submission:
n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h.sort()
ans=float("inf")
for i in range(len(h)-k+1):
	ma = h[i+k-1]
	mi = h[i]
	ans = min(ans,ma-mi)

print(ans)
Buggy python submission (verdict: Runtime Error):
x = int(input())

print(x)

print("Hello World!")

Fixed submission:
x = list(map(lambda y: int(y),input().split(" ")))

if x[0]<9 and x[1]<9:
	print("Yay!")
else:
	print(":(")

Buggy python submission (verdict: Runtime Error):
print('Hello World!'')

Fixed submission:
x = list(map(lambda y: int(y),input().split(" ")))

if x[0]<9 and x[1]<9:
	print("Yay!")
else:
	print(":(")

Buggy python submission (verdict: Runtime Error):
4444
1111
aaaa
a
a
a
a
a
a
print('Hello World!'')

Fixed submission:
x = list(map(lambda y: int(y),input().split(" ")))

if x[0]<9 and x[1]<9:
	print("Yay!")
else:
	print(":(")

Buggy python submission (verdict: Runtime Error):
4444
1111
aaaa
a
a
a
a
a
a


Fixed submission:
x = list(map(lambda y: int(y),input().split(" ")))

if x[0]<9 and x[1]<9:
	print("Yay!")
else:
	print(":(")

Buggy python submission (verdict: Runtime Error):
4545454
5455454
4
4545
44444444444444444444444444440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

0000000000044444

Fixed submission:
x = list(map(lambda y: int(y),input().split(" ")))

if x[0]<9 and x[1]<9:
	print("Yay!")
else:
	print(":(")

Buggy python submission (verdict: Runtime Error):
ｈｈｈ

Fixed submission:
x = list(map(lambda y: int(y),input().split(" ")))

if x[0]<9 and x[1]<9:
	print("Yay!")
else:
	print(":(")
Buggy python submission (verdict: Runtime Error):
x = int(input())

print(x)

print("Hello World!")

Fixed submission:
from collections import defaultdict
def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

d,n = readInts()

if d==0:
  if n==100:
    print(101)
  else:
    print(n)
elif d==1:
  if n==100:
    print(10100)
  else:
    print(n*100)
else:
  if n==100:
    print(1010000)
  else:
    print(n*10000)
Buggy python submission (verdict: Runtime Error):
a,b,c,x,y=readInts()
for i in range(max(x,y)*2+1,2):
	ans=min(ans,max(x-i//2,0)*a+max(y-i//2,0)*b+i*c)
print(ans)



Fixed submission:
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		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 -1*self.parents[self.find(x)]

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

	def members(self,x): # much time
		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()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1

a,b,c,x,y = readInts()

ans = 1000000000000000000
for i in range(0,x+1):
	B = max(y-(x-i),0)
	AB = max(2*(x-i),0)
	money = i*a+B*b+AB*c
	ans = min(ans,money)

for i in range(0,y+1):
	A = max(x-(y-i),0)
	AB = max(2*(y-i),0)
	money = A*a+b*i+AB*c
	ans = min(ans,money)

for i in range(0,max(x,y)*2+1,2):
	A = max(x - i//2,0)
	B = max(y - i//2,0)
	money = A*a+B*b+i*c
	ans = min(ans,money)

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

def readInt():
	return int(input())
 
def readInts():
	return list(map(int, input().split()))
 
def readChars():
	return input().split()

N,Y = readInts()
o = Y



for x in range(Y//10000+1):
	o=Y-x*10000
	#print(Y,x,o)
	for y in range(o//5000+1):
		#print(y)
		o=Y-x*10000-y*5000
		for z in range(o//1000+1):
			if x+y+z>N:
				break
			res = x*10000+y*5000+z*1000
			if res==Y and sum([x,y,z])==N:
				print(str(x)+" "+str(y)+" "+str(z))
				exit()

print("-1 -1 -1")

Fixed submission:
import math

def readInt():
	return int(input())
 
def readInts():
	return list(map(int, input().split()))
 
def readChars():
	return input().split()

N,Y = readInts()
o = Y



for x in range(Y//10000,-1,-1):
	o=Y-x*10000
	#print(Y,x,o)
	for y in range(o//5000,-1,-1):
		#print(y)
		o=Y-x*10000-y*5000
		z=o//1000
		res = x*10000+y*5000+z*1000
		if x+y+z>N or res>Y:
			break
		if res==Y and x+y+z==N:
			print(str(x)+" "+str(y)+" "+str(z))
			exit()

print("-1 -1 -1")

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

def readInt():
	return int(input())
 
def readInts():
	return list(map(int, input().split()))
 
def readChars():
	return input().split()

N,Y = readInts()
o = Y



for x in range(Y//10000,-1,-1):
	o=Y-x*10000
	#print(Y,x,o)
	for y in range(o//5000,-1,-1):
		#print(y)
		o=Y-x*10000-y*5000
		for z in range(o//1000,-1,-1):
			if x+y+z>N:
				break
			res = x*10000+y*5000+z*1000
			if res==Y and sum([x,y,z])==N:
				print(str(x)+" "+str(y)+" "+str(z))
				exit()

print("-1 -1 -1")

Fixed submission:
import math

def readInt():
	return int(input())
 
def readInts():
	return list(map(int, input().split()))
 
def readChars():
	return input().split()

N,Y = readInts()
o = Y



for x in range(Y//10000,-1,-1):
	o=Y-x*10000
	#print(Y,x,o)
	for y in range(o//5000,-1,-1):
		#print(y)
		o=Y-x*10000-y*5000
		z=o//1000
		res = x*10000+y*5000+z*1000
		if x+y+z>N or res>Y:
			break
		if res==Y and x+y+z==N:
			print(str(x)+" "+str(y)+" "+str(z))
			exit()

print("-1 -1 -1")

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

def readInt():
	return int(input())
 
def readInts():
	return list(map(int, input().split()))
 
def readChars():
	return input().split()

N,Y = readInts()
o = Y

for x in range(Y//10000,-1,-1):
	o=Y-x*10000
	#print(Y,x,o)
	for y in range(o//5000,-1,-1):
		#print(y)
		o=Y-x*10000-y*5000
		for z in range(o//1000,-1,-1):
			#print(x,y,z)
			res = x*10000+y*5000+z*1000
			if res==Y and sum([x,y,z])==N:
				print(str(x)+" "+str(y)+" "+str(z))
				exit()

print("-1 -1 -1")

Fixed submission:
import math

def readInt():
	return int(input())
 
def readInts():
	return list(map(int, input().split()))
 
def readChars():
	return input().split()

N,Y = readInts()
o = Y



for x in range(Y//10000,-1,-1):
	o=Y-x*10000
	#print(Y,x,o)
	for y in range(o//5000,-1,-1):
		#print(y)
		o=Y-x*10000-y*5000
		z=o//1000
		res = x*10000+y*5000+z*1000
		if x+y+z>N or res>Y:
			break
		if res==Y and x+y+z==N:
			print(str(x)+" "+str(y)+" "+str(z))
			exit()

print("-1 -1 -1")
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

d = defaultdict(int)
n = readInt()
for i in readChars():
	d[i]+=1

d = [i for i in sorted(d.items(), reverse=True) if i[1]>=2]

if len(d)==0:
	print(0)
	exit()
elif len(d)==1:
	if d[0][1]>=4:
		pass
	else:
		print(0)
		exit()
if d[0][1]>=4:
	print(int(d[0][0])**2)
else:
	print(int(d[0][0])*int(d[1][0]))
	raise Exception


Fixed submission:
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()

d = Counter(readInts())

d = [i for i in sorted(d.items(), reverse=True) if i[1]>=2]

if len(d)==0:
	print(0)
	exit()
elif len(d)==1:
	if d[0][1]>=4:
		pass
	else:
		print(0)
		exit()
if d[0][1]>=4:
	print(int(d[0][0])**2)
else:
	print(int(d[0][0])*int(d[1][0]))

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

d = defaultdict(int)
n = readInt()
for i in readChars():
	d[i]+=1

d = [i for i in sorted(d.items(), reverse=True) if i[1]>1]

if len(d)==0:
	print(0)
	exit()
elif len(d)==1:
	if d[0][1]>=4:
		continue
	else:
		print(0)
		exit()

if d[0][1]>=4:
	print(int(d[0][0])**2)
else:
	print(int(d[0][0])*int(d[1][0]))


Fixed submission:
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()

d = Counter(readInts())

d = [i for i in sorted(d.items(), reverse=True) if i[1]>=2]

if len(d)==0:
	print(0)
	exit()
elif len(d)==1:
	if d[0][1]>=4:
		pass
	else:
		print(0)
		exit()
if d[0][1]>=4:
	print(int(d[0][0])**2)
else:
	print(int(d[0][0])*int(d[1][0]))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,m = readInts()
ab = [readInts() for i in range(m)]
go1 = []
for i in range(m):
	if ab[i][0]==1:
		go1.append(ab[i][1])
for i in range(m):
	if ab[i][0] in go1 and ab[i][1]==n:
		print("POSSIBLE")
		exit()

print("IMPOSSIBLE")

Fixed submission:
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

import bisect
def isin(arr,x):
	#print(bisect.bisect_left(arr,x))
	return arr[min(bisect.bisect_left(arr,x),len(arr)-1)]==x

n,m = readInts()
ab = [readInts() for i in range(m)]
go1 = []
for i in range(m):
	if ab[i][0]==1:
		go1.append(ab[i][1])
go1.sort()
for i in range(m):
	if isin(go1,ab[i][0]) and ab[i][1]==n:
		print("POSSIBLE")
		exit()

print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,m = readInts()
ab = [readInts() for i in range(m)]
go1 = []
for i in range(m):
	if ab[i][0]==1:
		go1.append(ab[i][1])
for i in range(m):
	if ab[i][0] in go1 and ab[i][1]==n:
		print("POSSIBLE")
		exit()

print("IMPOSSIBLE")

Fixed submission:
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

import bisect
def isin(arr,x):
	#print(bisect.bisect_left(arr,x))
	return arr[min(bisect.bisect_left(arr,x),len(arr)-1)]==x

n,m = readInts()
ab = [readInts() for i in range(m)]
go1 = []
for i in range(m):
	if ab[i][0]==1:
		go1.append(ab[i][1])
go1.sort()
for i in range(m):
	if isin(go1,ab[i][0]) and ab[i][1]==n:
		print("POSSIBLE")
		exit()

print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

rate = [0]*9
n = readInt()
a = readInts()

for i in a:
	rate[i//400]+=1

print(8-rate[:-1].count(0),end=" ")
print(min(9,(8-rate[:-1].count(0))+rate[-1]))

Fixed submission:
from collections import defaultdict

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n = readInt()
a = readInts()
rate = [0]*9


for i in a:
  rate[min(i//400,8)]+=1
base = 8-rate[:-1].count(0)
ma = base+rate[-1]
print(max(base,1),ma)
Buggy python submission (verdict: Runtime Error):
# https://note.nkmk.me/python-union-find/
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())
uf = UnionFind(N)
ans = 0
for i in range(M):
    A, B = map(int, input().split())
    if not uf.same(A,B):
        ans += 1
    else:
        uf.union(A-1,B-1)
print(ans)

Fixed submission:
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())
uf = UnionFind(N)
ans = 0
for i in range(M):
    A, B = map(int, input().split())
    uf.union(A-1,B-1)
print(uf.group_count()-1)
Buggy python submission (verdict: Runtime Error):
MOD = 10**9 + 7
S = int(input())
dp = [0]*(S+1)
dp[0] = 1
dp[3] = 1
for i in range(4,S+1):
    for k in range(i-2):
        dp[i] += dp[k]
print(dp[S]%MOD)

Fixed submission:
MOD = 10**9 + 7
def comb(n, k):
    if n < k or n < 0 or k < 0:
        return 0
    if k == 0:
        return 1
    iinv = [1] * (k + 1)
    ans = n
    for i in range(2, k + 1):
        iinv[i] = MOD - iinv[MOD % i] * (MOD // i) % MOD
        ans *= (n + 1 - i) * iinv[i] % MOD
        ans %= MOD
    return ans
S = int(input())
ans = 0
for i in range(1,S+1):
    tmp = S
    tmp -= i*3
    if tmp < 0:
        continue
    ans += comb(i+tmp-1,tmp)
    ans %= MOD
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# https://note.nkmk.me/python-union-find/
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())
uf = UnionFind(N)
for i in range(M):
    A, B = map(int, input().split())
    uf.union(A-1,B-1)
ans = 0
for i in uf.all_group_members().values():
    ans = max(ans,len(i))
print(ans)

Fixed submission:
# https://note.nkmk.me/python-union-find/
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())
uf = UnionFind(N)
ans = 0
if M == 0:
    print(1)
    exit()
for i in range(M):
    A, B = map(int, input().split())
    uf.union(A-1,B-1)
    ans = max(ans,uf.size(A-1))
print(ans)