Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
X = input()
while 1:
    if "ST" in X:
        X = X.replace("ST", "")
    else:
        break
##print(X)
print(len(X))

Fixed submission:
X = input()
ans = len(X)
N = len(X)
cnt_s = 0
cnt_t = 0
for i in range(N):
    if X[i] == "S":
        cnt_s += 1
    if X[i] == "T":
        cnt_t += 1
    
    if i < N -1:
        if X[i] == "T" and X[i + 1] == "S":
            ans -= 2 * min(cnt_s, cnt_t)
            cnt_s -= min(cnt_s, cnt_t)
            cnt_t = 0
    if i == N - 1:
        ans -= 2 * min(cnt_s, cnt_t)
    
print(ans)
Buggy python submission (verdict: Runtime Error):
#C問題
N, K = map(int, input().split())

D = []
D = list(map(int, input().split()))

num = []
for i in range(10):
    if i not in D:
        num.append(i)

N_num = []
while True:
    if N ==0:
        break
    N_num.append(N%10)
    N = N//10

N_num.sort(reverse = True)

ans = []
for i in N_num:
    for k in range(len(num)):
        if num[k] >= i:
            ans.append(num[k])
            break
        elif k == len(num):
            ans.append(k)
            ans[k-1] = num[k+1]
map(str, ans)
ans = int("".join(map(str, ans)))
print(ans)


Fixed submission:
#C問題
N, K = map(int, input().split())
D = list(map(str, input().split()))

def check(n, d):
    n = str(n)
    for nstr in n:
        if nstr in d:
            return False
    return True
while True:
    if check(N, D):
        print(N)
        break
    else:
        N += 1

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())

D = []
D = list(map(int, input().split()))

num = []
for i in range(10):
    if i not in D:
        num.append(i)

N_num = []
while True:
    if N ==0:
        break
    N_num.append(N%10)
    N = N//10

N_num.sort(reverse = True)

ans = []
for i in N_num:
    for k in num:
        if k >= i:
            ans.append(k)
            break
map(str, ans)
ans = int("".join(map(str, ans)))
print(ans)


Fixed submission:
#C問題
N, K = map(int, input().split())
D = list(map(str, input().split()))

def check(n, d):
    n = str(n)
    for nstr in n:
        if nstr in d:
            return False
    return True
while True:
    if check(N, D):
        print(N)
        break
    else:
        N += 1
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input())

if a**0.5 + b**0.5 < c**0.5:
    print('Yes')
else:
    print('No')


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

if c - a - b >= 0 and (c - a - b)**2 > 4 * a * b:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
s=str(input())
def isPalin(l,r):
  if l >= r:
    return True
  if s[l]!=s[r]:
    return False:
  return isPalin(l+1,r-1)
n = len(s)
if isPalin(0,n-1) and isPalin(0,n//2-1) and isPalin(n//2+1,n-1):
  print('Yes')
else:
  print('No')

Fixed submission:
s=str(input())
def isPalin(l,r):
  if l >= r:
    return True
  if s[l]!=s[r]:
    return False
  return isPalin(l+1,r-1)
n = len(s)
if isPalin(0,n-1) and isPalin(0,n//2-1) and isPalin(n//2+1,n-1):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
import math
a,b,c=map(int,input().split())
eps = 0.00000000000001
if 4*a*b<(c-a-b)**2 and (c-a-b) > 0:
	print('Yes')
else:
	print('No')

Fixed submission:
k = int(input())
x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(x[k-1])

Buggy python submission (verdict: Runtime Error):
import math
a,b,c=map(int,input().split())
eps = 0.0000001
if math.sqrt(a)+math.sqrt(b)+eps<math.sqrt(c):
	print('Yes')
else:
	print('No')

Fixed submission:
k = int(input())
x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(x[k-1])

Buggy python submission (verdict: Runtime Error):
import math
a,b,c=map(int,input().split())
if math.sqrt(a)+math.sqrt(b)+10**(-7)<math.sqrt(c):
	print('Yes')
else:
	print('No')  

Fixed submission:
k = int(input())
x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(x[k-1])
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
if(h==1||w==1):
  print(1)
else:
  print(((w+1)//2)*((h+1)//2)+(w//2)*(h//2))

Fixed submission:
h,w=map(int,input().split())
if(h==1 or w==1):
  print(1)
else:
  print(((w+1)//2)*((h+1)//2)+(w//2)*(h//2))
Buggy python submission (verdict: Runtime Error):
import math
a,b,c=map(int,input().split())
if a+b+2*math.sqrt(a)*math.sqrt(b)<c:
	print('Yes')
  else:
    print('No')  

Fixed submission:
import math
a,b,c=map(int,input().split())
eps = 0.00000000000001
if 4*a*b<(c-a-b)**2 and (c-a-b)>0:
	print('Yes')
else:
	print('No')
Buggy python submission (verdict: Runtime Error):
input()
a=map(int,input().split())
a.sort()
print(a[0]+a[1])

Fixed submission:
a=list(map(int,input().split()))
a.sort()
print(a[0]+a[1])

Buggy python submission (verdict: Runtime Error):
a=map(int,input().split())
a.sort()
print(a[0]+a[1])

Fixed submission:
a=list(map(int,input().split()))
a.sort()
print(a[0]+a[1])
Buggy python submission (verdict: Runtime Error):
def f(x):
    return len(x) % 2 == 0 and x[:len(x)/2] == x[len(x)/2:]

x=input()
while not f(x):
    x=x[:-1]

print(len(x))

Fixed submission:
def f(x):
    return len(x) % 2 == 0 and x[:len(x)//2] == x[len(x)//2:]
 
x=input()[:-1]
while not f(x):
    x=x[:-1]
 
print(len(x))

Buggy python submission (verdict: Runtime Error):
def f(x):
    return len(x) % 2 == 0 and x[:len(x)/2] == x[len(x)/2:]
x=input()
while f(x):
    x=x[:-1]
print(len(x))

Fixed submission:
def f(x):
    return len(x) % 2 == 0 and x[:len(x)//2] == x[len(x)//2:]
 
x=input()[:-1]
while not f(x):
    x=x[:-1]
 
print(len(x))
Buggy python submission (verdict: Runtime Error):
import math
a, b = map(int,input().split())
min = math.floor(a / 0.08)
max = math.ceil((a+1)/0.08)
ans = 0
for i in range(min, max):
    if math.floor(i * 0.08) == a and math.floor(i*0.1) == b:
        ans = i
        break
if ans == 0:
    print("-1")
else:
    print(ans)

Fixed submission:
my_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N = input()
N = int(N)
print(my_list[N-1])

Buggy python submission (verdict: Runtime Error):
import math

def A():
    a=int(input())
    b=int(input())
    c=int(input())
    A=math.sqrt(a)
    B=math.sqrt(b)
    C=math.sqrt(c)
    if A+B<C:
        print("Yes")
    else:
        print("No")

if __name__=='__main__':
    A()

Fixed submission:
my_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N = input()
N = int(N)
print(my_list[N-1])

Buggy python submission (verdict: Runtime Error):
import math

def A():
    a=int(input())
    b=int(input())
    c=int(input())
    A=math.sqrt(a)
    B=math.sqrt(b)
    C=math.sqrt(c)
    if A+B<C:
        print("Yes")
    else:
        print("No")

if __init__=='__main__':
    A()

Fixed submission:
my_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N = input()
N = int(N)
print(my_list[N-1])

Buggy python submission (verdict: Runtime Error):
my_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = input()
K = int(K)
print(my_list[K])

Fixed submission:
my_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N = input()
N = int(N)
print(my_list[N-1])

Buggy python submission (verdict: Runtime Error):
my_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N = input()
N = int(N)
print(my_list[N])

Fixed submission:
my_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N = input()
N = int(N)
print(my_list[N-1])

Buggy python submission (verdict: Runtime Error):
my_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N = input()
N = int(N)
print(my_list[N])

Fixed submission:
my_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N = input()
N = int(N)
print(my_list[N-1])

Buggy python submission (verdict: Runtime Error):
my_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N = input()
N = int(N)
print(my_list[N])

Fixed submission:
my_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N = input()
N = int(N)
print(my_list[N-1])
Buggy python submission (verdict: Runtime Error):
N = input().split(" ")
h = map(int,input().split())
h = list(h)

dp = [99999999 for i in range(100)]
dp[0]=0

for i in range(int(N[0])):
    for j in [i+1,i+N[1]]:
        if j<int(N) :
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]))

print(dp[int(N)-1])

Fixed submission:
import sys
n,k = map(int,input().split())
h = map(int,input().split())
h = list(h)

dp = [sys.maxsize]*n
dp[0]=0

for i in range(n):
    for j in range(i+1,i+k+1):
        if j<n:
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]))

print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
from collections import Counter

a,b,c = map(int,input())
if(abs(b-a)==abs(c-b)):
    print("Yes")
else:
    print("No")

Fixed submission:
#
from collections import Counter

a,b,c = map(int,input().split())
if(b-a ==  c-b):
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):

from collections import Counter
import sys
a,b,c = map(int,input())
if(abs(b-a)==abs(c-b)):
    print("Yes")
else:
    print("No")

Fixed submission:
#
from collections import Counter

a,b,c = map(int,input().split())
if(b-a ==  c-b):
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
# Hello World program in Python
from collections import Counter as cn

d = int(input())
l = []
for k in range(d):
  r = input()
   
  l.append(cn(r))

oi = l[0]

for g in range(1,d):
    oi = oi & l[g]
    
    
print("".join(sorted(oi.elements())))


Fixed submission:
#
from collections import Counter

a,b,c = map(int,input().split())
if(b-a ==  c-b):
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):

from collections import Counter

k = input()
p = input()
d = len(k)
f = len(p)
g=""
diff = abs(d-f)

if d>f :
     d = d-diff
     g = k[d:len(k)]
   
else:
    f = f-diff
    g=p[f:len(p)]


r=""a
i = 0
for i in range(d):
    r += "".join(k[i]+p[i])
    #print(r)
    
print(r+g)

Fixed submission:
#
from collections import Counter

k = input()
p = input()
d = len(k)
f = len(p)
g=""
diff = abs(d-f)

if d>f :
     d = d-diff
     g = k[d:len(k)]
   
else:
    f = f-diff
    g=p[f:len(p)]


r=""
i = 0
for i in range(d):
    r += "".join(k[i]+p[i])
    #print(r)
    
print(r+g)
Buggy python submission (verdict: Runtime Error):
#
from collections import Counter as cn

d = int(input())
l = []
for k in range(d):
  r = input()
   
  l.append(Counter(r))

oi = l[0]

for g in range(1,d):
    oi = oi & l[g]
    
    
print("".join(sorted(oi.elements())))



Fixed submission:
from collections import Counter
 
n = int(input())
l = []
 
for i in range(n):
    s = input()
    l.append(Counter(s))
    
cnt = l[0]
for i in range(1,n):
        cnt = cnt & l[i]
        
print("".join(sorted(cnt.elements())))

Buggy python submission (verdict: Runtime Error):
# Hello World program in Python
from collections import Counter as cn

d = int (input())
l = []
for k in range(d):
  r = input()
  p = cn(r)
  l.append(p)

oi = l[0]

for g in range(1,n):
    oi = oi & l[g]
    print(oi)
    
print("".join(sorted(oi.elements())))



Fixed submission:
from collections import Counter
 
n = int(input())
l = []
 
for i in range(n):
    s = input()
    l.append(Counter(s))
    
cnt = l[0]
for i in range(1,n):
        cnt = cnt & l[i]
        
print("".join(sorted(cnt.elements())))

Buggy python submission (verdict: Runtime Error):
# Hello World program in Python
from collections import Counter as cn

d = int (input())
l = []
for k in range(d):
  r = input()
  p = cn(r)
  l.append(p)

oi = l[0]

for g in range(n):
    oi = oi & l[g]
    print(oi)
    
print("".join(sorted(oi.elements())))



Fixed submission:
from collections import Counter
 
n = int(input())
l = []
 
for i in range(n):
    s = input()
    l.append(Counter(s))
    
cnt = l[0]
for i in range(1,n):
        cnt = cnt & l[i]
        
print("".join(sorted(cnt.elements())))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

for h in range(1, 3501):
    for n in range(1, 3501):
        a = N * h * n
        b = 4 * h * n - N * (h + n)
        if a > 0 and b > 0 and a % b == 0:
            print("{0} {1} {2}".format(h, n, a//b))
            exit()

Fixed submission:
N = int(input())

for h in range((N + 3) // 4, 3501):
    for n in range((N + 3) // 4, 3501):
        a = N * h * n
        b = 4 * h * n - N * (h + n)
        if a > 0 and b > 0 and a % b == 0:
            print("{0} {1} {2}".format(h, n, a//b))
            exit()
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]

A.sort()
left = A[0]
right = A[N - 1]
ans = right - left
for i in range((N - 2) // 2):
    if i % 2 == 0:
        ans += right - A[1 + i]
        ans += A[N - 2 - i] - left
        right = A[1 + i]
        left = A[N - 2 - i]
    else:
        ans += left - A[1 + i]
        ans += A[N - 2 - i] - right
        left = A[1 + i]
        right = A[N - 2 - i]

if N % 2 == 1:
    ans += max(abs(right - A[N // 2]), abs(left - A[N // 2]))

print(ans)


Fixed submission:
N = int(input())

for h in range((N + 3) // 4, 3501):
    for n in range((N + 3) // 4, 3501):
        a = N * h * n
        b = 4 * h * n - N * (h + n)
        if a > 0 and b > 0 and a % b == 0:
            print("{0} {1} {2}".format(h, n, a//b))
            exit()
Buggy python submission (verdict: Runtime Error):
n=int(input())
p=1
if 360//n == 0:
	print(360//n)
else:
  while true:
	if n*p%360 == 0:
		print(n)
      	break
    n+=1
	

Fixed submission:
p = int(input())
index = 1
while True:
    if p* index % 360 == 0:
        print(index)
        break
    index += 1

Buggy python submission (verdict: Runtime Error):
n=int(input())
p=1
if 360//n == 0:
	print(360//n)
else:
  while true:
	if n*p%360 == 0:
		print(n)
      	exit()
    n+=1
	

Fixed submission:
p = int(input())
index = 1
while True:
    if p* index % 360 == 0:
        print(index)
        break
    index += 1
Buggy python submission (verdict: Runtime Error):
def sackRace(p1, s1, p2, s2): 
      
    # Since starting points are always 
    # different, they will meet if following  
    # conditions are met. 
    # (1) Speeds are not same 
    # (2) Difference between speeds divide the 
    #     total distance between initial points.  
    return ( (s1 > s2 and (p2 - p1) % (s1 - s2) == 0)  
         or (s2 > s1 and (p1 - p2) % (s2 - s1) == 0)) 
p1 , s1=map(int , input().split()) 
p2 , s2=map(int , input().split())
t=int(input()) 
if sackRace(p1 , s1 , p2 , s2):
  print("NO")
else:
  print("YES)

Fixed submission:
p1 , s1=map(int , input().split()) 
p2 , s2=map(int , input().split())
t=int(input()) 
if abs(p1-p2) > t*(s1-s2):
  print("NO")
else:
  print("YES")
Buggy python submission (verdict: Runtime Error):
n = input()
print("No" if ((n//10) % 111 and (n%1000) % 111) else "Yes")

Fixed submission:
n = int(input())
print("No" if ((n//10) % 111 and (n%1000) % 111) else "Yes")

Buggy python submission (verdict: Runtime Error):
n = input()
print("No" if ((n//10) % 111 and (n%1000) % 111) else "Yes")

Fixed submission:
n = int(input())
print("No" if ((n//10) % 111 and (n%1000) % 111) else "Yes")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.readline

N, M, K = map(int, readline().split())
P = 998244353
def mod_prod(a,b):
    return a * b % P

def mod_fact(a):
    ret = 1
    for i in range(a):
        ret = ret * (i + 1) % P
    return ret

def mod_pow(a, n):
    ret = 1
    while n > 0:
        if n % 2 == 1:
            ret = ret * a % P
        a = a * a % P
        n = n // 2
    return ret

def mod_div(a, b):
    b_inv = mod_pow(b, P - 2)
    return a * b_inv % P

def mod_comb(a,b):
    ret = 1
    b = min(b, a - b)
    for i in range(b):
        ret *= a - i
        ret %= P
    ret = mod_div(ret, mod_fact(b))
    return ret

ans = 0
_n = N - 1
for k in range(K + 1):
    a = N - k
    # N-1 Comb k
    if k == 0:
        comb = 1
    elif k == 1:
        comb = _n
    else:
        comb = comb * mod_div((_n - k + 1), k) % P
    b = M * mod_pow(M-1, a-1) % P
    b = b * comb % P
    ans += b
    ans %= P


print(ans)

Fixed submission:
import sys
readline = sys.stdin.readline

N, M, K = map(int, readline().split())
P = 998244353
def mod_prod(a,b):
    return a * b % P

def mod_fact(a):
    ret = 1
    for i in range(a):
        ret = ret * (i + 1) % P
    return ret

def mod_pow(a, n):
    ret = 1
    while n > 0:
        if n % 2 == 1:
            ret = ret * a % P
        a = a * a % P
        n = n // 2
    return ret

def mod_div(a, b):
    b_inv = mod_pow(b, P - 2)
    return a * b_inv % P

def mod_comb(a,b):
    ret = 1
    b = min(b, a - b)
    for i in range(b):
        ret *= a - i
        ret %= P
    ret = mod_div(ret, mod_fact(b))
    return ret

ans = 0
_n = N - 1
for k in range(K + 1):
    a = N - k
    # N-1 Comb k
    if k == 0:
        comb = 1
    elif k == 1:
        comb = _n
    else:
        comb = comb * mod_div((_n - k + 1), k) % P
    b = M * mod_pow(M-1, a-1) % P
    b = b * comb % P
    ans += b
    ans %= P


print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
from collections import deque
readline = sys.stdin.readline

N, X, Y = map(int, readline().split())
X -= 1
Y -= 1

a = np.ones([N, N]) * 1e9

def test(n):
    b = np.ones([N]) * 1e9
    q = deque()

    q.append((n, 0))
    while len(q) > 0:
        n, d = q.popleft()
        if b[n] == 1e9:
            b[n] = d
            if n - 1 >= 0:
                q.append((n - 1, d + 1))
            
            if n + 1 < N:
                q.append((n + 1, d + 1))
            
            if n == X:
                q.append((Y, d + 1))
            elif n == Y:
                q.append((X, d + 1))
    
    return b

for n in range(N):
    a[n] = test(n)

ans = [0] * (N - 1)
for i in range(N):
    for j in range(i + 1, N):
        ans[int(a[i][j] - 1)] += 1

for x in ans:
    print(x)

Fixed submission:
import sys
from collections import deque
readline = sys.stdin.readline

N, X, Y = map(int, readline().split())
X -= 1
Y -= 1

a = [[1e9] * N for i in range(N)]

def test(n):
    b = [1e9] * N
    q = deque()

    q.append((n, 0))
    while len(q) > 0:
        n, d = q.popleft()
        if b[n] == 1e9:
            b[n] = d
            if n - 1 >= 0:
                q.append((n - 1, d + 1))
            
            if n + 1 < N:
                q.append((n + 1, d + 1))
            
            if n == X:
                q.append((Y, d + 1))
            elif n == Y:
                q.append((X, d + 1))
    
    return b

for n in range(N):
    a[n] = test(n)

ans = [0] * (N - 1)
for i in range(N):
    for j in range(i + 1, N):
        ans[int(a[i][j] - 1)] += 1

for x in ans:
    print(x)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.readline

n, k = map(int, readline().split())
P = 10**9 + 7

def mod_prod(a,b):
    return a * b % P

def mod_fact(a):
    ret = 1
    for i in range(a):
        ret = ret * (i + 1) % P
    return ret

def mod_pow(a, n):
    ret = 1
    while n > 0:
        if n % 2 == 1:
            ret = ret * a % P
        a = a * a % P
        n = n // 2
    return ret

def mod_div(a, b):
    b_inv = mod_pow(b, P - 2)
    return a * b_inv % P

def mod_comb(a,b):
    ret = 1
    b = min(b, a - b)
    for i in range(b):
        ret *= a - i
        ret %= P
    ret = mod_div(ret, mod_fact(b))
    return ret


if k >= n - 1:
    ans = mod_comb(n + n - 1, n - 1)
    print(ans)
else:
    ans = 0
    for i in range(k + 1):
        ans += mod_comb(n, i) * mod_comb(n - 1, i)
        ans %= P
    print(ans)

Fixed submission:
import sys
readline = sys.stdin.readline

n, k = map(int, readline().split())
P = 10**9 + 7

def mod_prod(a,b):
    return a * b % P

def mod_fact(a):
    ret = 1
    for i in range(a):
        ret = ret * (i + 1) % P
    return ret

def mod_pow(a, n):
    ret = 1
    while n > 0:
        if n % 2 == 1:
            ret = ret * a % P
        a = a * a % P
        n = n // 2
    return ret

def mod_div(a, b):
    b_inv = mod_pow(b, P - 2)
    return a * b_inv % P

def mod_comb(a,b):
    ret = 1
    b = min(b, a - b)
    for i in range(b):
        ret *= a - i
        ret %= P
    ret = mod_div(ret, mod_fact(b))
    return ret


if k >= n - 1:
    ans = mod_comb(n + n - 1, n - 1)
    print(ans)
else:
    ans = 0

    a = mod_comb(n, 0)
    b = mod_comb(n - 1, 0)
    ans = a * b % P
    for i in range(1, k + 1):
        a = mod_prod(a, (n - i + 1)) 
        a = mod_div(a, i)
        b = mod_prod(b, (n - 1 - i + 1))
        b = mod_div(b, i)
        ans += a * b % P
        ans %= P
    print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int, readline().split()))

for n in A:
    if n % 2 == 0:
        if not (n % 3 == 0 or n % 5 == 0):
            print('DENIED')
            exit(0)

print('APPROVED')


Fixed submission:
import sys
readline = sys.stdin.readline
from collections import Counter

N = int(readline())
S = [readline().rstrip() for i in range(N)]

c = Counter(S)

maxc = max(c.values())

a = []
for k, v in c.items():
    if v == maxc:
        a.append(k)

a.sort()

for s in a:
    print(s)
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
readline = sys.stdin.readline

N, K = map(int, readline().split())
p = list(map(int, readline().split()))

p = np.array(p)
a = [sum(p[i:i+K] + 1) / 2 for i in range(N - K)]
print(max(a))

Fixed submission:
import sys
readline = sys.stdin.readline

N, K = map(int, readline().split())
p = list(map(int, readline().split()))

t = sum(p[:K])
m = (t + K) / 2
for i in range(1, N - K + 1):
    t = t - p[i - 1] + p[i + K - 1]
    m = max(m, (t + K)/2)

print(m)

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
readline = sys.stdin.readline

N, K = map(int, readline().split())
p = list(map(int, readline().split()))

p = np.array(p)
a = [sum(p[i:i+K] + 1) / 2 for i in range(N - K)]
print(max(a))

Fixed submission:
import sys
readline = sys.stdin.readline

N, K = map(int, readline().split())
p = list(map(int, readline().split()))

t = sum(p[:K])
m = (t + K) / 2
for i in range(1, N - K + 1):
    t = t - p[i - 1] + p[i + K - 1]
    m = max(m, (t + K)/2)

print(m)
Buggy python submission (verdict: Runtime Error):
import sys; readline = sys.stdin.readline
from deque import deque

A = int(readline())
B = int(readline())

print(set([1,2,3]) - set([A, B]))

Fixed submission:
import sys; readline = sys.stdin.readline
from collections import deque

A = int(readline())
B = int(readline())

ans = list(set([1,2,3]) - set([A, B]))
print(ans[0])
Buggy python submission (verdict: Runtime Error):
import sys; readline = sys.stdin.readline
from collections import deque


N = int(readline())
A = list(map(int, readline().split()))
P = 10**9 + 7


a = 1
state = [0, 0, 0]

for i in range(N):
    c = state.count(A[i]) 
    a *= c
    a %= P
    state[state.index(A[i])] = A[i] + 1

print(a)

Fixed submission:
import sys; readline = sys.stdin.readline
from collections import deque


N = int(readline())
A = list(map(int, readline().split()))
P = 10**9 + 7


a = 1
state = [0, 0, 0]

for i in range(N):
    c = state.count(A[i]) 
    a *= c
    a %= P
    if c == 0:
        print(0)
        exit(0)
    state[state.index(A[i])] = A[i] + 1

print(a)