Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = list(map(int,input().split()))
count = 0
for i in range(N):
  for j in range(i + 1,N):
    if s[i] == s[j]:
      print("NO")
      count += 1
      break
if count == 0:
  print("YES")

Fixed submission:
N = int(input())
s = list(map(int,input().split()))
count = 0
s.sort()

for i in range(N - 1):
  if s[i] == s[i + 1]:
    print("NO")
    count += 1
    break
    
if count == 0:
  print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
P = list(map(int,input().split()))
P = np.array(P)
ans = 0
for i in range(N):
  if P[i] == min(P[:i+1]):
    ans += 1
print(ans)

Fixed submission:
N = int(input())
P = list(map(int,input().split()))
m = N + 1
ans = 0
for i in P:
  if i <= m:
    ans += 1
    m = i
  else:
    continue
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(N):
  if P[i] == min(P[:i+1]):
    ans += 1
print(ans)

Fixed submission:
N = int(input())
P = list(map(int,input().split()))
m = N + 1
ans = 0
for i in P:
  if i <= m:
    ans += 1
    m = i
  else:
    continue
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(N):
  if P[i] == min(P[:i+1]):
    ans += 1
print(ans)

Fixed submission:
N = int(input())
P = list(map(int,input().split()))
m = N + 1
ans = 0
for i in P:
  if i <= m:
    ans += 1
    m = i
  else:
    continue
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = 0
w = 0
lis = [[] for _ in range(N)]
for i in range(M):
  p,s = map(int,input().split())
  p = int(p)
  lis[p - 1].append(s)
for j in range(N):
  if lis[j].count("AC") > 0:
    a += 1
    w += lis[j].index("AC")

    
print(a,w)



Fixed submission:
N,M = map(int,input().split())
a = 0
w = 0
lis = [[] for _ in range(N)]
for i in range(M):
  p,s = map(str,input().split())
  p = int(p)
  lis[p - 1].append(s)
for j in range(N):
  if lis[j].count("AC") > 0:
    a += 1
    w += lis[j].index("AC")

    
print(a,w)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = 0
w = 0
lis = [[] for i in range(N)]
for i in range(M):
  p,s = map(int,input().split())
  p = int(p)
  lis[p - 1].append(s)
for j in range(N):
  if lis[j].count("AC") > 0:
    a += 1
    w += lis[j].index("AC")

    
print(a,w)



Fixed submission:
N,M = map(int,input().split())
a = 0
w = 0
lis = [[] for _ in range(N)]
for i in range(M):
  p,s = map(str,input().split())
  p = int(p)
  lis[p - 1].append(s)
for j in range(N):
  if lis[j].count("AC") > 0:
    a += 1
    w += lis[j].index("AC")

    
print(a,w)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N,M = map(int,input().split())
a = 0
w = 0
lis = np.zeros(N + 1)
for i in range(M):
  p,s = map(str,input().split())
  p = int(p)
  if lis[p + 1] == 0 and s == "AC":
    a += 1
    lis[p] = 1
  elif lis[p + 1] > 0 and s == "AC":
    continue
  elif lis[p + 1] == 0 and s == "WA":
    w += 1
  elif lis[p + 1] > 0 and s == "WA":
    continue
    
print(a,w)



Fixed submission:
N,M = map(int,input().split())
a = 0
w = 0
lis = [[] for _ in range(N)]
for i in range(M):
  p,s = map(str,input().split())
  p = int(p)
  lis[p - 1].append(s)
for j in range(N):
  if lis[j].count("AC") > 0:
    a += 1
    w += lis[j].index("AC")

    
print(a,w)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N,M = map(int,input().split())
a = 0
w = 0
lis = np.zeros(N + 1)
for i in range(M):
  p,s = map(str,input().split())
  if lis[p] == 0 and s == "AC":
    a += 1
    lis[p] = 1
  elif lis[p] != 0 and s == "AC":
    continue
  elif lis[p] == 0 and s == "WA":
    w += 1
  elif lis[p] != 0 and s == "WA":
    continue
    
print(a,w)



Fixed submission:
N,M = map(int,input().split())
a = 0
w = 0
lis = [[] for _ in range(N)]
for i in range(M):
  p,s = map(str,input().split())
  p = int(p)
  lis[p - 1].append(s)
for j in range(N):
  if lis[j].count("AC") > 0:
    a += 1
    w += lis[j].index("AC")

    
print(a,w)
Buggy python submission (verdict: Runtime Error):
s = list(map(int, input().split()))
N = s[0]
A = s[1]
B = s[2]

if abs(A-B) % 2 == 0:
  print(int(abs(A-B) / 2))
elif abs(A-B) % 2 != 0:

Fixed submission:
s = list(map(int, input().split()))
N = s[0]
A = s[1]
B = s[2]

if (B - A) % 2 == 0:
  print((B - A) // 2)
else:
  print(min(A - 1,N - B) +  1 + (B - A - 1) // 2)
Buggy python submission (verdict: Runtime Error):
i = list(map(int, input().split()))
if 1 <= i[0] <= 9 and 1 <= i[1] <= 9:
  return i[0] * i[1]
else:
  return -1


Fixed submission:
i = list(map(int, input().split()))
if 1 <= i[0] <= 9 and 1 <= i[1] <= 9:
  print(i[0] * i[1])
else:
  print(-1)

Buggy python submission (verdict: Runtime Error):
i = list(map(int, input().split()))
if 0 <= i[0] <= 9 and 0 <= i[1] <= 9:
  return i[0] * i[1]
else:
  return -1


Fixed submission:
i = list(map(int, input().split()))
if 1 <= i[0] <= 9 and 1 <= i[1] <= 9:
  print(i[0] * i[1])
else:
  print(-1)

Buggy python submission (verdict: Runtime Error):
i = list(map(int, input().split()))
if 0 <= i[0] and i[0] <= 9 and 0 <= i[1] and i[1] <= 9:
  return i[0] * i[1]
else:
  return -1


Fixed submission:
i = list(map(int, input().split()))
if 1 <= i[0] <= 9 and 1 <= i[1] <= 9:
  print(i[0] * i[1])
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(9):
  if n % i == 0 and n / i < 10:
    print('Yes')
  else:
    print('No')

Fixed submission:
n = int(input())
for i in range(1,10):
    for j in range(1,10):
        if i * j == n:
            print('Yes')
            break
        else:
            continue
    if i * j == n:
        break
    elif i == 9 and i * j != n:
        print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map,int().split())
s = 0
for i in range(n):
  j = i + 1
  while j <= n - 1:
    s += l[i] * l[j]
  	j += 1
print(s)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
s = 0
for i in range(n):
  j = i + 1
  while j <= n - 1:
    s += l[i] * l[j]
    j += 1
print(s)

Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map,int().split())
s = 0
for i in range(n):
  j = i + 1
  while j <= n:
    s += l[i] * l[j]
  	j += 1
print(s)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
s = 0
for i in range(n):
  j = i + 1
  while j <= n - 1:
    s += l[i] * l[j]
    j += 1
print(s)

Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))
import numpy as np
ll = np.empty(int(n * (n - 1) / 2))

for i in range(N):
  for j in range(i + 1, N):
    ll[k] = l[i] * l[j]
    k += 1
print(np.sum(ll))

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
s = 0
for i in range(n):
  j = i + 1
  while j <= n - 1:
    s += l[i] * l[j]
    j += 1
print(s)
Buggy python submission (verdict: Runtime Error):
n = list(map(int, input().split()))
h = list(map(int, input().split()))
c = 0
for i in range(n[1]):
  if h[i] >= n[0]:
    c += 1
    
print(c)

Fixed submission:
n = list(map(int, input().split()))
h = list(map(int, input().split()))
c = 0
for i in range(n[0]):
  if h[i] >= n[1]:
    c += 1
    
print(c)

Buggy python submission (verdict: Runtime Error):
n = list(map(int, input().split()))
h = list(map(int, input().split()))
c = 0
for i in range(n[0]):
  if h[i] => n[1]:
    c += 1
    
print(c)

Fixed submission:
n = list(map(int, input().split()))
h = list(map(int, input().split()))
c = 0
for i in range(n[0]):
  if h[i] >= n[1]:
    c += 1
    
print(c)
Buggy python submission (verdict: Runtime Error):
import math
def c(x,y):
  if x < y or y < 0:
    return 0
  elif x == 0 or y == 0:
    return 1
  else:
    s = math.factorial(n)
    t = math.factorial(n-k)
    u = math.factorial(k)
    return s//(t*u)


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

for i in range(1,k+1):
  sol = c(n-k+1,i)*c(k-1,i-1)
  m = 10**9 +7
  ans = sol%m
  print(ans)

Fixed submission:
s = str(input())

if (s[0] == s[1]) and (s[2] == s[3]) and (s[1] == s[2]):
  print('No')
elif (s[0] == s[1]) and (s[2] == s[3]):
  print('Yes')
elif (s[0] == s[2]) and (s[1] == s[3]):
  print('Yes')
elif (s[0] == s[3]) and (s[2] == s[1]):
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
import math
def c(x,y):
  if x < y or y < 0:
    return 0
  elif x == 0 or y == 0:
    return 1
  else:
    s = math.factorial(n)
    t = math.factorial(n-k)
    u = math.factorial(k)
    return s//(t*u)

n,k = map(int,input().split())
m = 10**9 +7

for i in range(1,k+1):
  sol = c(n-k+1,i)*c(k-1,i-1)
  ans = sol%m
  print(ans)

Fixed submission:
s = str(input())

if (s[0] == s[1]) and (s[2] == s[3]) and (s[1] == s[2]):
  print('No')
elif (s[0] == s[1]) and (s[2] == s[3]):
  print('Yes')
elif (s[0] == s[2]) and (s[1] == s[3]):
  print('Yes')
elif (s[0] == s[3]) and (s[2] == s[1]):
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
s = str(input())

if (s[0] == s[1] and s[2] == s[3])or(s[0] == s[2] and s[1] == s[3])or(s[0] == s[3] and s[1] == s[2]):
  print(Yes)
elif s[0] == s[1] and s[0] == s[2] and s[0] == s[3]:
  print(No)
else:
   print(No)

Fixed submission:
s = str(input())

if (s[0] == s[1]) and (s[2] == s[3]) and (s[1] == s[2]):
  print('No')
elif (s[0] == s[1]) and (s[2] == s[3]):
  print('Yes')
elif (s[0] == s[2]) and (s[1] == s[3]):
  print('Yes')
elif (s[0] == s[3]) and (s[2] == s[1]):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
d = list(map(int,input().split()))

t = d.sort()

a = t[(n/2)-1]
b = t[(n/2)]

print(b-a)

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

d.sort()

a = d[int(n/2)-1]
b = d[int(n/2)]

print(b-a)
Buggy python submission (verdict: Runtime Error):
S = input()

if S[0] == S[1]:
  print(Bad)
  break
elif S[1] == S[2]:
  print(Bad)
  break
elif S[2] == S[3]:
  print(Bad)
  break
else:
  print(Good)
  
  

Fixed submission:
s =input()

if s[0] == s[1]:
  print('Bad')
elif s[1] == s[2]:
  print('Bad')
elif s[2] == s[3]:
  print('Bad')
else:
  print('Good')

Buggy python submission (verdict: Runtime Error):
S = input()

if S[0] == S[1]:
  print(Bad)
elif S[1] == S[2]:
  print(Bad)
elif S[2] == S[3]:
  print(Bad)
else:
  print(Good)
  
  

Fixed submission:
s =input()

if s[0] == s[1]:
  print('Bad')
elif s[1] == s[2]:
  print('Bad')
elif s[2] == s[3]:
  print('Bad')
else:
  print('Good')

Buggy python submission (verdict: Runtime Error):
S = input()

if S[0] == S[1]:
  print(Bad)
elif S[1] == S[2]:
  print(Bad)
elif S[2] == S[3]:
  print(Bad)
else:
 print(Good)
  
  

Fixed submission:
s =input()

if s[0] == s[1]:
  print('Bad')
elif s[1] == s[2]:
  print('Bad')
elif s[2] == s[3]:
  print('Bad')
else:
  print('Good')

Buggy python submission (verdict: Runtime Error):
S = input()

if S[0] == S[1]:
  print(Bad)
elif S[1] == S[2]:
  print(Bad)
elif S[2] == S[3]:
  print(Bad)
else
	print(Good)
  
  

Fixed submission:
s =input()

if s[0] == s[1]:
  print('Bad')
elif s[1] == s[2]:
  print('Bad')
elif s[2] == s[3]:
  print('Bad')
else:
  print('Good')
Buggy python submission (verdict: Runtime Error):
i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

m = min(c,d)
n = max(c,d)

while m != 0:
  n = m
  m = n % m
  
  
g = m
l = (c*d)/g

s = int((a-1)/c)
t = int((a-1)/d)
u = int((a-1)/l)
x = int(b/c)
y = int(b/d)
z = int(b/l)

B = b - x - y + z
A = a - 1 - s - t + u

print(B - A)



  

Fixed submission:
i  = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

def gcd(n,m):
    x = min(n,m)
    y = max(n,m)
    while x != 0:
        x1 = x
        x = y%x
        y = x1
    return y

l = (c*d)//gcd(c,d)

count = (b - b//c - b//d + b//l) - ((a-1) - (a-1)//c - (a-1)//d + (a-1)//l)
print(count)

Buggy python submission (verdict: Runtime Error):
i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

m = min(c,d)
n = max(c,d)

while m != 0:
  n = m
  m = n%m
  
  
g = n
l = (c*d)/g

s1 = (a-1)/c
t1 = (a-1)/d
u1 = (a-1)/l
x1 = b/c
y1 = b/d
z1 = b/l

A = (x1 + x2 - x3) - (s1 + t1 - u1)

print(A)



  

Fixed submission:
i  = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

def gcd(n,m):
    x = min(n,m)
    y = max(n,m)
    while x != 0:
        x1 = x
        x = y%x
        y = x1
    return y

l = (c*d)//gcd(c,d)

count = (b - b//c - b//d + b//l) - ((a-1) - (a-1)//c - (a-1)//d + (a-1)//l)
print(count)

Buggy python submission (verdict: Runtime Error):
i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

m = min(c,d)
n = max(c,d)

while m != 0:
  n = m
  m = n%m
  
  
g = n

s1 = (a-1)/c
t1 = (a-1)/d
u1 = (a-1)/g
x1 = b/c
y1 = b/d
z1 = b/g

A = (x1 + x2 - x3) - (s1 + t1 - u1)

print(A)



  

Fixed submission:
i  = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

def gcd(n,m):
    x = min(n,m)
    y = max(n,m)
    while x != 0:
        x1 = x
        x = y%x
        y = x1
    return y

l = (c*d)//gcd(c,d)

count = (b - b//c - b//d + b//l) - ((a-1) - (a-1)//c - (a-1)//d + (a-1)//l)
print(count)
Buggy python submission (verdict: Runtime Error):
X = int(input().strip())
A = int(input().strip())

if A > X:
	print(0)
else:
	print(10)

Fixed submission:
X, A = input().strip().split()
X, A = [int(X), int(A)]
if A > X:
	print(0)
else:
	print(10)

Buggy python submission (verdict: Runtime Error):
X = int(input())
A = int(input())

if A > X:
	print(0)
else:
	print(10)

Fixed submission:
X, A = input().strip().split()
X, A = [int(X), int(A)]
if A > X:
	print(0)
else:
	print(10)
Buggy python submission (verdict: Runtime Error):
i = list(map(int,input().split()))
w = i[0]
h = i[1]
x = i[2]
y = i[3]

m = (w*h)/2

if (2*x == w) and (2*y == h:)
  s = 1
else:
  s = 0
  

print("{:.9}".format(m));print(s)

Fixed submission:
i = list(map(int,input().split()))
w = i[0]
h = i[1]
x = i[2]
y = i[3]

m = (w*h)/2

if (2*x == w) and (2*y == h):
  s = 1
else:
  s = 0
  

print("{:.9}".format(m));print(s)

Buggy python submission (verdict: Runtime Error):
i = list(map(int,input().split()))
w = i[0]
h = i[1]
x = i[2]
y = i[3]

m = (w*h)/2

if (2*x == w) and (2*y == h:)
  s = 1
else:
  s = 0
  

print("{:.10}".format(m),end='');print(s)

Fixed submission:
i = list(map(int,input().split()))
w = i[0]
h = i[1]
x = i[2]
y = i[3]

m = (w*h)/2

if (2*x == w) and (2*y == h):
  s = 1
else:
  s = 0
  

print("{:.9}".format(m));print(s)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
for i in range(1,n+1):
	a = i
	p = 1/n
	while a < k:
    	a = a*2
    	p = p*0.5
  	pro[i] = p
  
print(sum(pro))
    

Fixed submission:
n,k = map(int,input().split())
pro = []
for i in range(1,n+1):
  a = i
  p = 1/n
  while a < k:
    a = a + a
    p = p * 0.5
  pro.append(p)
  
print(sum(pro))

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
for i in range(1,n+1):
  a = i
  p = 1/n
  while a < k:
    a = a*2
    p = p*0.5
  pro[i] = p
  
print(sum(pro))
    

Fixed submission:
n,k = map(int,input().split())
pro = []
for i in range(1,n+1):
  a = i
  p = 1/n
  while a < k:
    a = a + a
    p = p * 0.5
  pro.append(p)
  
print(sum(pro))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = map(input().split())
flag = 0
for i in range(N):
  if S[i] == "Y":
    flag += 1
if flag > 0:
  print("Four")
else:
  print("Three")

Fixed submission:
N = int(input())
S = list(input().split())
flag = 0
for i in range(N):
  if S[i] == "Y":
    flag += 1
if flag > 0:
  print("Four")
else:
  print("Three")

Buggy python submission (verdict: Runtime Error):
N = int(input())
flag = 0
for i in range(N):
  S = input()
  if S == "Y":
    flag += 1
if flag > 0:
  print("Four")
else:
  print("Three")

Fixed submission:
N = int(input())
S = list(input().split())
flag = 0
for i in range(N):
  if S[i] == "Y":
    flag += 1
if flag > 0:
  print("Four")
else:
  print("Three")
Buggy python submission (verdict: Runtime Error):
s = str(input())


print(0:len(s):2)

Fixed submission:
s = str(input())


print(s[0:len(s):2])

Buggy python submission (verdict: Runtime Error):
s = str(input())
print(0:len(s):2)

Fixed submission:
s = str(input())


print(s[0:len(s):2])
Buggy python submission (verdict: Runtime Error):
import numpy as np

class UnionFind:
    def __init__(self, sz: int):
        self._par: np.array = np.full(sz + 1, -1)

    def root(self, a: int):
        if self._par[a] < 0:
            return a
        self._par[a] = self.root(self._par[a])
        return self._par[a]
    
    def size(self, a: int):
        return -self._par[self.root(a)]
    
    def unite(self, a, b):
        a = self.root(a)
        b = self.root(b)
        if a != b:
            if self.size(a) < self.size(b):
                a, b = b, a
            self._par[a] += self._par[b]
            self._par[b] = a
    
if __name__ == '__main__':
    N, M = map(int, input().split())
    uf = UnionFind(N + 1)
    for i in range(M):
        a, b = map(int, input().split())
        uf.unite(a, b)
    ans = 1
    for i in range(1, N + 1):
        ans = max(ans, uf.size(i))
    print(ans)

Fixed submission:
class UnionFind:
    def __init__(self, sz: int):
        self._par: list[int] = [-1] * sz

    def root(self, a: int):
        if self._par[a] < 0:
            return a
        self._par[a] = self.root(self._par[a])
        return self._par[a]
    
    def size(self, a: int):
        return -self._par[self.root(a)]
    
    def unite(self, a, b):
        a = self.root(a)
        b = self.root(b)
        if a != b:
            if self.size(a) < self.size(b):
                a, b = b, a
            self._par[a] += self._par[b]
            self._par[b] = a
    
if __name__ == '__main__':
    N, M = map(int, input().split())
    uf = UnionFind(N + 1)
    for i in range(M):
        a, b = map(int, input().split())
        uf.unite(a, b)
    ans = 1
    for i in range(1, N + 1):
        ans = max(ans, uf.size(i))
    print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(intput())
stocks = list(map(int, input().split()))
curr = 1000
for i in range(N - 1):
    cnt = 0
    if stocks[i] < stocks[i + 1]:
      cnt = curr // stocks[i]
    curr += cnt * (stocks[i + 1] - stocks[i])
print(curr)

Fixed submission:
N = int(input())
stocks = list(map(int, input().split()))
curr = 1000
for i in range(N - 1):
  cnt = 0
  if stocks[i] < stocks[i + 1]:
    cnt = curr // stocks[i]
  curr += cnt * (stocks[i + 1] - stocks[i])
print(curr)

Buggy python submission (verdict: Runtime Error):
N = int(intput())
stocks = list(map(int, input().split()))
curr = 1000
for i in range(N - 1):
  cnt = 0
  if stocks[i] < stocks[i + 1]:
    cnt = curr // stocks[i]
  curr += cnt * (stocks[i + 1] - stocks[i])
print(curr)

Fixed submission:
N = int(input())
stocks = list(map(int, input().split()))
curr = 1000
for i in range(N - 1):
  cnt = 0
  if stocks[i] < stocks[i + 1]:
    cnt = curr // stocks[i]
  curr += cnt * (stocks[i + 1] - stocks[i])
print(curr)

Buggy python submission (verdict: Runtime Error):
N = int(intput())
stocks = list(map(int, input().split()))
for i in range(N - 1):
  cnt = 0
  if stocks[i] < stocks[i + 1]:
    pass

Fixed submission:
N = int(input())
stocks = list(map(int, input().split()))
curr = 1000
for i in range(N - 1):
  cnt = 0
  if stocks[i] < stocks[i + 1]:
    cnt = curr // stocks[i]
  curr += cnt * (stocks[i + 1] - stocks[i])
print(curr)
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 10 ** 9 + 7
K = int(input())
M = len(input())
N = M + K

pow25 = [1] * (N + 1)
fac = [1] * (N + 1)
inv = [1] * (N + 1)
for x in range(1, N + 1):
    fac[x] = fac[x - 1] * x % MOD
    pow25[x] = pow25[x - 1] * 25 % MOD
inv[N] = pow(fac[N], MOD-2, MOD)
for x in range(N - 1, -1, -1):
    inv[x] = inv[x + 1] * (x + 1) % MOD

def binom(n, k):
    return fac[n] * inv[n - k] % MOD * inv[k] % MOD

ans = 0
for k in range(M, N + 1):
    ans += binom(N, k) * pow25[N - k] % MOD
    ans %= MOD
print(ans)

Fixed submission:
MOD = 10 ** 9 + 7
K = int(input())
M = len(input())
N = M + K

pow25 = [1] * (N + 1)
fac = [1] * (N + 1)
inv = [1] * (N + 1)
for x in range(1, N + 1):
    fac[x] = fac[x - 1] * x % MOD
    pow25[x] = pow25[x - 1] * 25 % MOD
inv[N] = pow(fac[N], MOD-2, MOD)
for x in range(N - 1, -1, -1):
    inv[x] = inv[x + 1] * (x + 1) % MOD

def binom(n, k):
    return fac[n] * inv[n - k] % MOD * inv[k] % MOD

ans = 0
for k in range(M, N + 1):
    ans += binom(N, k) * pow25[N - k] % MOD
    ans %= MOD
print(ans)
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
typedef long long ll;

const int maxn = 110;

int N;

vector<unordered_map<string, ll>> memo(maxn);

bool check(string last4) {
    if (last4.find("AGC") != string::npos) {
        return false;
    }
    for (int i = 0; i < 4 - 1; ++i) {
        swap(last4[i], last4[i + 1]);
        if (last4.find("AGC") != string::npos) {
            return false;
        }
        swap(last4[i], last4[i + 1]);
    }
    return true;
}

ll dfs(int cur, const string& last3) {
    if (memo[cur].count(last3)) {
        return memo[cur][last3];
    }
    if (cur == N) {
        return 1;
    }
    ll ret = 0;
    for (char c : string("ACGT")) {
        if (check(last3 + c)) {
            ret = (ret % MOD + dfs(cur + 1, last3.substr(1) + c) % MOD) % MOD;
        }
    }
    return memo[cur][last3] = ret;
}

int main() {
    cin >> N;
    cout << dfs(0, "TTT") << endl;
    return 0;
}

Fixed submission:
N, MOD = int(input()), 10 ** 9 + 7
memo = [{} for i in range(N + 1)]

def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i - 1], t[i] = t[i], t[i - 1]
        if ''.join(t).count('AGC') >= 1:
            return False
    return True

def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in 'AGCT':
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret

print(dfs(0, 'TTT'))
Buggy python submission (verdict: Runtime Error):
x = int(input())
if x>=30:
  print("Yes")
  else:
    print("No")

Fixed submission:
x = int(input().strip())
if x>=30:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
N=int(input())
s = list(map(int, input().split()))
ans =1
for i in s:
    ans*=i
    
if ans>1e18:
    print(-1)
    sys.exit(0)

print(ans)


Fixed submission:
import sys
N=int(input())
s = list(map(int, input().split()))
ans =1
for i in s:
    if i==0:
        print(0)
        sys.exit()
    
for i in s:
    ans*=i
    if ans>1e18:
        print(-1)
        sys.exit()

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

s = input()
K = int(input())
subs=[]
for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        subs.append(s[i:j])

subset = set(subs)
subset = sorted(subset)
print(subset[K-1])


Fixed submission:
import sys

s = input()
K = int(input())
subs=[]
for i in range(len(s)):
    for j in range(i+1,min(len(s)+1,i+K+1)):
        subs.append(s[i:j])

subset = set(subs)
subset = sorted(subset)
print(subset[K-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(1, N):
    ans += A[i - 1] * sum(A[i:])
print(ans % (10**9 + 7))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
s = sum(A) % mod
ans = 0
for i in range(N):
    s -= A[i]
    if 0 > s:
        s += mod
    ans += A[i] * s
    ans %= mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(1, N):
    for j in range(i, N):
        ans += A[i - 1] * A[j]
print(ans % (10**9 + 7))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
s = sum(A) % mod
ans = 0
for i in range(N):
    s -= A[i]
    if 0 > s:
        s += mod
    ans += A[i] * s
    ans %= mod
print(ans)