Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02578 (python)

Fixed submission:
import sys
def main(lines):
  n = int(lines[0])
  a = []
  hei = lines[1].split()
  for i in range(n):
    a.append(int(hei[i]))
  tmp = a[0]
  ans = 0
  for i in range(1,n):
    if tmp < a[i]:
      tmp = a[i]
    else:
      ans += tmp-a[i]
  print(ans)

if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)

Buggy submission (verdict: Runtime Error):
def main(lines):
	line = lines  

if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)
Problem p03208 (python)

Fixed submission:
N, K = map(int, input().split())
h = [int(input()) for i in range(N)]
h.sort()
print(min(h[i+K-1] - h[i] for i in range(N-K+1)))

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
list = [int(input()) for i in range(N)]
max(list())
list.sort()
print(min(list[i+K-1] - list[i] for i in range(N-K+1)))
Problem p02623 (python)

Fixed submission:
from bisect import *
n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# Aの累積和を保存しておく
# 各Aの要素について、Bが何冊読めるか二分探索する。
# 計算量: AlogB
A.insert(0, 0)

for i in range(1,len(A)):
  A[i] += A[i-1]
for i in range(1, len(B)):
  B[i] += B[i-1]

ans = 0
for i in range(len(A)):
  rest_time = k - A[i]
  if rest_time >= 0:
    numb = bisect_right(B, rest_time)
    anstmp = i + numb 
    ans = max(ans, anstmp)
print(ans)

Buggy submission (verdict: Runtime Error):
from bisect import *
n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# Aの累積和を保存しておく
# 各Aの要素について、Bが何冊読めるか二分探索する。
# 計算量: AlogB

for i in range(1,len(A)):
  A[i] += A[i-1]
  B[i] += B[i-1]

ans = 0
for i in range(len(A)):
  rest_time = k - A[i]
  if rest_time < 0:
    break
  numb = bisect_left(B, rest_time)
  anstmp = i + 1 + numb 
  ans = max(ans, anstmp)
print(ans)
Problem p03252 (python)

Fixed submission:
S = input()
T = input()
sdic = {}
tdic = {}
flag = True
for s, t in zip(S, T):
  if s not in sdic:
    sdic[s] = t
  if t not in tdic:
    tdic[t] = s
  if sdic[s] != t or tdic[t] != s:
    flag = False
    break
if flag:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
X = list(map(int, input().split()))

ans = 10**6
for i in range(n-k):
  d1 = abs(X[i]) + abs(X[i] - X[i+k-1])
  d2 = abs(X[i+k-1]) + abs(X[i] - X[i+k-1])
  if ans > min(d1, d2):
    ans = min(d1,d2)
if ans == 10**6:
  print(0)
else:
  print(ans)
Problem p02970 (python)

Fixed submission:
N, D = (int(x) for x in input().split())
X = N / (2 * D + 1)
#print(X)
if (X.is_integer()):
  print(int(X))
else:
  print(int(X) + 1)

Buggy submission (verdict: Runtime Error):
N, D = [int (x) for x in input().split()]
X = N / (2 * D + 1)
if (X.is_integer()) print(X)
else print(X + 1)
Problem p02771 (python)

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

if a==b:
  if b==c:
    print("No")
  else:
    print("Yes")
    
else:
  if a==c or b==c:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
a,b,c = input().strip().split()

if a==b:
  if b==c:
    print("No")
  else:
    printf("Yes")
    
else:
  if a==c or b==c:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
list=[]
for i in range 3:
  list.append(int(input()))
if list[0]==list[1]:
  if list[1]==list[2]:
    print("No")
  else:
    printf("Yes")
    
else:
  if list[0]==list[2] or list[1]==list[2]:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())

if a==b:
  if b==c:
    print("No")
  if b!=c:
    printf("Yes")
    
if a!=b:
  if a==c or b==c:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())

if a==b:
  if b==c:
    print("No")
  else:
    printf("Yes")
    
if a!=b:
  if a==c or b==c:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())

if a==b:
  if b==c:
    print("No")
  else:
    printf("Yes")
    
else:
  if a==c or b==c:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
s=[input() for i in range 3]

if s[0]==s[1]:
  if s[1]==s[2]:
    print("No")
  else:
    printf("Yes")
    
else:
  if s[0]==s[2] or s[1]==s[2]:
    print("Yes")
  else:
    print("No")
Problem p02773 (python)

Fixed submission:
N=int(input())
s=[input() for i in range (N)]

s.sort()
count=1
maximum=0

for j in range (N-1):
  if s[j]==s[j+1]:
    count+=1
    if j==N-2:
      if count>maximum:
        a=[]
        a.clear()
        a.append(s[j])
        maximum=count
        number=1
      elif count==maximum:
        a.append(s[j])
        number+=1
  else:
    if count>maximum:
      a=[]
      a.clear()
      a.append(s[j])
      maximum=count
      number=1
    elif count==maximum:
      a.append(s[j])
      number+=1
    count=1   
  if maximum==1 and j==N-2:
    a.append(s[N-1])
    number+=1
for p in range (number):
  print(a[p])

Buggy submission (verdict: Runtime Error):
N=int(input())
s=[input() for i in range (N)]

for q in range N:
  for i in range N-1:
    if s[i]>s[i+1]:
      s0=s[i]
      s[i]=s[i+1]
      s[i+1]=s0

count=1
maximum=0

for j in range N-1:
  if s[j]=s[j+1]:
    count+=1
  else:
    if count>maximum:
      a=[]
      a.append(s[j])
      maximum=count
      number=1
    elif count=maximum:
      a.append(s[j])
      number+=1
    count=0
    
for p in range number:
  print(a[p])

Buggy submission (verdict: Runtime Error):
N=int(input())
s=[input() for i in range (N)]

for q in range N:
  for i in range N-1:
    if s[i]>s[i+1]:
      s0=s[i]
      s[i]=s[i+1]
      s[i+1]=s0

count=1
maximum=0

for j in range N-1:
  if s[j]=s[j+1]:
    count+=1
  else:
    if count>maximum:
      a=[]
      a.append(s[j])
      maximum=count
      number=1
    elif count=maximum:
      a.append(s[j])
      number+=1
    count=0
    
for p in range number:
  print(a[p])
Problem p03745 (python)

Fixed submission:
N=int(input())
count=1
size=1
p=list(map(int,input().split()))
q=[p[0]]
for i in range (1,N):
  if p[i]!=p[i-1]:
    q.append(p[i])
    size+=1
j=0
while True:
  if j>=size-2:
    break
  while (q[j]-q[j+1])*(q[j+1]-q[j+2])>=0:
    if j>=size-3:
      count-=1
      break
    j+=1    
  count+=1
  j+=2
print(count)

Buggy submission (verdict: Runtime Error):
N=int(input())
count=1
size=1
p=list(map(int,input().split()))
q=[p[0]]
for i in range (1,N):
  if p[i]!=p[i-1]:
    q.append(p[i])
    size+=1
j=0
while True:
  if j>=size-2:
    break
  while (q[j]-q[j+1])*(q[j+1]-q[j+2])>=0:
    if j>=size-2:
      break
    j+=1    
  count+=1
  j+=2
print(count)

Buggy submission (verdict: Runtime Error):
N=int(input())
count=1
size=1
p=list(map(int,input().split()))
q=[p[0]]
for i in range (1,N):
  if p[i]!=p[i-1]:
    q.append(p[i])
    size+=1
j=0
while True:
  if j>=size-3:
    break
  while (q[j]-q[j+1])*(q[j+1]-q[j+2])>=0:
    j+=1
  count+=1
  j+=2
print(count)

Buggy submission (verdict: Runtime Error):
N=int(input())
count=1
size=1
p=list(map(int,input().split()))
q=[p[0]]

j=0
while True:
  if j>=N-2:
    break
  while (q[j]-q[j+1])*(q[j+1]-q[j+2])>=0:
    j+=1
  count+=1
  j+=2
print(count)

Buggy submission (verdict: Runtime Error):
N=int(input())
count=1
size=1
p=list(map(int,input().split()))
q=[p[0]]
for i in range (1,N):
  if p[i]!=p[i-1]:
    q.append(p[i])
    size+=1
j=0
while True:
  if j>=size-2:
    break
  while (q[j]-q[j+1])*(q[j+1]-q[j+2])>=0:
    j+=1
  count+=1
  j+=2
print(count)
Problem p02763 (python)

Fixed submission:
import sys
#input = sys.stdin.buffer.readline
import bisect

def main():
    N = int(input())
    S = list(str(input()))
    
    pos = [[] for _ in range(26)]
    for x,s in enumerate(S):
        num = ord(s)-ord("a")
        pos[num].append(x)
    
    q = int(input())
    for _ in range(q):
        m,a,b = map(str,input().split())
        if m == "1":
            a = int(a)-1
            if S[a] == b:
                continue
            else:
                popind = bisect.bisect_left(pos[ord(S[a])-ord("a")],a)
                pos[ord(S[a])-ord("a")].pop(popind)
                bisect.insort(pos[ord(b)-ord("a")],a)
                S[a] = b
        else:
            a,b = int(a)-1,int(b)-1
            count = 0
            for i in range(26):
                l = bisect.bisect_left(pos[i],a)
                if l >= len(pos[i]):
                    continue
                if pos[i][l] <= b:
                    count += 1
            print(count)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
#input = sys.stdin.buffer.readline
import bisect

def main():
    N = int(input())
    S = list(str(input()))
    
    pos = [[] for _ in range(26)]
    for x,s in enumerate(S):
        num = ord(s)-ord("a")
        pos[num].append(x)
    
    q = int(input())
    for _ in range(q):
        m,a,b = map(str,input().split())
        if m == "1":
            a = int(a)-1
            if S[a] == b:
                continue
            else:
                popind = bisect.bisect_left(pos[ord(S[a])-ord("a")],a)
                pos[ord(S[a])-ord("a")].pop(popind)
                bisect.insort(pos[ord(b)-ord("a")],a)
        else:
            a,b = int(a)-1,int(b)
            count = 0
            for i in range(26):
                aind = bisect.bisect_left(pos[i],a)
                bind = bisect.bisect_left(pos[i],b)
                if bind-aind > 0:
                    count += 1
            print(count)

if __name__ == "__main__":
    main()
Problem p02833 (python)

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

def main():
    N = int(input())
    if N % 2 == 1:
        print(0)
    else:
        N //= 2
        count = 0
        while N > 1:
            N //= 5
            count += N
        print(count)
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    if N % 2 == 1:
        print(0)
    else:
        N //= 2
        count = 0
        while N > 1:
            N //= 5
            count += N
            
    print(count)
    
if __name__ == "__main__":
    main()
Problem p02925 (python)

Fixed submission:
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)

def main():
    N = int(input())
    memo = []
    base = 0
    for i in range(N-1):
        memo.append(base)
        base += N-i-1
    edge = [[] for _ in range((N*(N-1))//2)]
    
    for i in range(N):
        a = list(map(int,input().split()))
        b = []
        for j in a:
            j -= 1
            if i < j:
                b.append(memo[i]+j-i-1)
            else:
                b.append(memo[j]+i-j-1)
        for i in range(N-2):
            edge[b[i+1]].append(b[i])

    go = [False]*((N*(N-1))//2)
    cul = [False]*((N*(N-1))//2)
    dp = [0]*((N*(N-1))//2)
    
    def dfs(v):
        if go[v]:
            if not cul[v]:
                return -1
            return dp[v]
        go[v] = True
        dp[v] = 1
        for u in edge[v]:
            ret = dfs(u)
            if ret == -1:
                return -1
            dp[v] = max(dp[v],ret+1)
        cul[v] = True
        return dp[v]
    
    ans = 0
    for i in range((N*(N-1))//2):
        ret = dfs(i)
        if ret == -1:
            print(-1)
            exit()
        ans = max(ans,ret)
        
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline
from collections import deque

def main():
    N = int(input())
    memo = []
    base = 0
    for i in range(N-1):
        memo.append(base)
        base += N-i-1
    edge = [[] for _ in range((N*(N-1))//2)]
    
    for i in range(N):
        a = list(map(int,input().split()))
        b = []
        for j in a:
            j -= 1
            if i < j:
                b.append(memo[i]+j-i-1)
            else:
                b.append(memo[j]+i-j-1)
        for i in range(N-2):
            edge[b[i+1]].append(b[i])

    go = [False]*((N*(N-1))//2)
    cul = [False]*((N*(N-1))//2)
    dp = [0]*((N*(N-1))//2)
    
    def dfs(v):
        if go[v]:
            if not cul[v]:
                return -1
            return dp[v]
        go[v] = True
        dp[v] = 1
        for u in edge[v]:
            ret = dfs(u)
            if ret == -1:
                return -1
            dp[v] = max(dp[v],ret+1)
        cul[v] = True
        return dp[v]
    
    ans = 0
    for i in range((N*(N-1))//2):
        ret = dfs(i)
        if ret == -1:
            print(-1)
            exit()
        ans = max(ans,ret)
        
    print(ans)

if __name__ == "__main__":
    main()
Problem p02987 (python)

Fixed submission:
S = list(input())
 
S = sorted(S)
 
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
S = list(input())
 
s = sorted(s)
 
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
four = input()
 
four = sorted(four)
if four[1] == four[2] and four[3] == four[4] and four[2] != four[3]:
	print ("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
four = input()

four = sorted(four)
if four[1] = four[2] and four[3] = four[4] and four[2] != four[3]:
	print ("Yes")
else:
	print("No")
Problem p03011 (python)

Fixed submission:
P,Q,R = map(int,input().split())
 
print(min(P+Q,Q+R,R+P))

Buggy submission (verdict: Runtime Error):
P,Q,R = map(int.input().split())
 
print(min(P+Q,Q+R,R+P))
Problem p03012 (python)

Fixed submission:
N = int(input())

W = list(map(int,input().split()))

sumw = sum(W)
for i in range(N):
	ans = abs(sum(W[:i+1])-sum(W[i+1:]))
	if ans < sumw:
		sumw = ans

print(sumw)

Buggy submission (verdict: Runtime Error):
N = int(input())

W = list(map(int,input().split()))

sumw = sum(W)
for i in range(N):
	ans = abs(sum(W[:,i+1])-sum(W[i+1:]))
	if ans < sumw:
		sumw = ans

print(sumw)
Problem p03042 (python)

Fixed submission:
n = input()

a = int(n[0]+n[1])
b = int(n[2]+n[3])
if b == 0 or b > 12:
	if 1 <= a <= 12:
		print("MMYY")
	else:
		print("NA")
elif 1 <= a <= 12:
	print("AMBIGUOUS")
else:
	print("YYMM")

Buggy submission (verdict: Runtime Error):
n = input()

a = int(n[0]+n[1])
b = int(n[2]+n[3])
if b = 0 or b > 12:
	if 1 <= a <= 12:
		print("MMYY")
	else:
		print("NA")
elif 1 <= a <= 12:
	print("AMBIGUOUS")
else:
	print("YYMM")
Problem p03053 (python)

Fixed submission:
import numpy
H,W = map(int,input().split())
a_list = []
INF = 10**10
for i in range(H):
    str = input()
    a_list.append([0 if i == "#" else INF for i in list(str)])

a_list = numpy.array(a_list)
for x in range(W-1):
    a_list[:,x+1] = numpy.minimum(a_list[:,x]+1,a_list[:,x+1])
    a_list[:,-x-2] = numpy.minimum(a_list[:,-x-1]+1,a_list[:,-x-2])

for y in range(H-1):
    a_list[y+1,:] = numpy.minimum(a_list[y,:]+1,a_list[y+1,:])
    a_list[-y-2,:] = numpy.minimum(a_list[-y-1,:]+1,a_list[-y-2,:])

print(a_list.max())

Buggy submission (verdict: Runtime Error):
from collections import deque
def main():
    H, W = map(int,input().split())
    s = [list(map(str,input())) for _ in range(W)]
    dist = [[-1]*W for _ in range(H)]
    
    q = deque([])
    for i in range(H):
        for j in range(W):
            if s[i][j] == "#":
                dist[i][j] = 0
                q.append((i, j))
    
    ans = 0
    while q:
        x, y = q.popleft()
        dx = [1, -1, 0, 0]
        dy = [0, 0, 1, -1]
        for i in range(4):
            nx = x+dx[i]
            ny = y+dy[i]
            if (0 <= nx < H and 0 <= ny < W and dist[nx][ny] == -1 and s[nx][ny] == '.'):
                dist[nx][ny] = dist[x][y] + 1
                q.append((nx, ny))
                ans = max(ans, dist[nx][ny])
                
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
a_list = []
for i in range(H):
    str = input()
    a_list.append(list(str))

def clear(A):
    
    INF = 100000000

    distance = [[INF for i in range(W)] for j in range(H)]

    def bfs():
        queue = []
        already = []

        for i in range(W):
            for j in range(H):
                if A[i][j] == "#":
                    queue.insert(0,(i,j))
                    already.insert(0,(i,j))
                    distance[i][j] = 0

        while len(queue):
            x, y = queue.pop()

            for i in range(0, 4):
                nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]

                if (0 <= nx and nx < W and 0 <= ny and ny < H and \
                    A[nx][ny] == '.' and distance[nx][ny] == INF):
                    queue.insert(0, (nx, ny))
                    already.insert(0, (nx,ny))
                    distance[nx][ny] = distance[x][y] + 1

        max_dis = 0
        for i in range(H):
            max_dis = max(max_dis,max(distance[i]))

        return max_dis

    return bfs()

print (clear(a_list))
Problem p03055 (python)

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

def main():
    N = int(input())
    if N == 1:
        print("First")
        exit()
    edge = [[] for _ in range(N)]
    
    for _ in range(N-1):
        a,b = map(int,input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)
        
    dep = [-1 for _ in range(N)]
    dep[0] = 0
    q = deque([0])
    while q:
        now = q.popleft()
        for fol in edge[now]:
            if dep[fol] == -1:
                dep[fol] = dep[now]+1
                q.append(fol)
    
    st = dep.index(max(dep))
    dep = [-1 for _ in range(N)]
    dep[st] = 0
    q = deque([st])
    while q:
        now = q.popleft()
        for fol in edge[now]:
            if dep[fol] == -1:
                dep[fol] = dep[now]+1
                q.append(fol)
                
    if max(dep)%3 == 1:
        print("Second")
    else:
        print("First")

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline
from collections import deque

def main():
    N = int(input())
    edge = [[] for _ in range(N)]
    
    for _ in range(N-1):
        a,b = map(int,input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)
        
    for i in range(N):
        if len(edge[i]) == 1:
            st = i
            break
    dep = [-1 for _ in range(N)]
    dep[st] = 0
    
    q = deque([st])
    while q:
        now = q.pop()
        for fol in edge[now]:
            if dep[fol] == -1:
                dep[fol] = dep[now]+1
                q.append(fol)
    
    if max(dep)%3 == 1:
        print("second")
    else:
        print("first")

if __name__ == "__main__":
    main()
Problem p03075 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if e - a > k:
	print(":(")
else:
	print("Yay!")

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,k = map(int,input().split())
 
if e - a > k:
	print(":(")
else:
	print("Yay!")

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,k = map(int,input().split())

if e - a > k:
	print(":(")
else:
    print("Yay!")
Problem p03242 (python)

Fixed submission:
s = input()
 
ss = ""
for i in s:
  if i == "1":
  	ss += "9"	
  else:
    ss += "1"
    
print(ss)

Buggy submission (verdict: Runtime Error):
from corections import Counter 
n = int(input())
v = list(map(int,input().split()))
 
odd = []
even = []
for i in range(n//2):
	odd.append(v[2*i+1])
	even.append(v[2*i])
 
odd = sorted(odd)
even = sorted(even)
ac = Counter(odd).most_common(2)
bc = Counter(even).most_common(2)
def cnt(X):
	count = 0
	ans = 0
	for i in range(len(X)-1):
		if X[i+1] == X[i]:
			count += 1
			ans = max(ans,count)
		else:
			count = 0
	return ans+1
            
if ac[0][0] != bc[0][0]:
  print(len(v)-cnt(odd)-cnt(even))
elif len(ac) == 1 and len(bc) == 1:
	print(n//2)
else:
	print(n-max(ac[0][1]+bc[1][1],ac[1][1]+bc[0][1]))

Buggy submission (verdict: Runtime Error):
s = input()
 
ss = ""
for i in s:
  if s[i] == "1":
  	ss += "9"	
  else:
    ss += "1"
    
print(ss)

Buggy submission (verdict: Runtime Error):
s = input()
 
ss = ""
for i in s:
  if s == "1"
  		ss += "9"	
  else:
    	ss += "1"
    
print(ss)

Buggy submission (verdict: Runtime Error):
s = input()
 
ss = ""
for i in s:
  if s == "1"
  	ss += "9"	
  else:
    ss += "1"
    
print(ss)

Buggy submission (verdict: Runtime Error):
s = input()
 
ss = ""
for i in range(len(s)):
  if s[i] == "1"
  	ss += "9"	
  else:
    ss += "1"
    
print(ss)

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

ss = ""
for i in range(len(S)):
  if s[i] == "1"
  	ss += "9"	
  else:
    ss += "1"
    
print(ss)
Problem p03253 (python)

Fixed submission:
import sys
input = sys.stdin.buffer.readline
from collections import defaultdict
import copy

def main():
    N,M = map(int,input().split())
    d = defaultdict(int)
    MOD = 10**9+7
    R = 10**5+100
    fac = [0 for _ in range(R+1)]
    fac[0],fac[1] = 1,1
    inv = copy.deepcopy(fac)
    invfac = copy.deepcopy(fac)
    
    for i in range(2,R+1):
        fac[i] = (fac[i-1]*i)%MOD
        inv[i] = MOD-(MOD//i)*inv[MOD%i]%MOD
        invfac[i] = (invfac[i-1]*inv[i])%MOD
        
    def coef(x,y):
        num = (((fac[x+y]*invfac[y])%MOD)*invfac[x]%MOD)
        return num

    while M%2 == 0:
        d[2] += 1
        M //= 2
    f = 3
    while f ** 2 <= M:
        if M % f == 0:
            d[f] += 1
            M //= f
        else:
            f += 2
    if M != 1:
        d[M] += 1
    
    l = list(d.values())
    ans = 1
    for num in l:
        ans *= coef(num,N-1)
        ans %= MOD
        
    print(ans)
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math
import sys
input = sys.stdin.readline

def main():
    N,M = map(int,input().split())
    div_list = []
    d = 2
    ans = 1
    MOD = 10**9+7
    while M != 1:
        count = 0
        while M%d == 0:
            count += 1
            M //= d
        div_list.append(count)
        d += 1
    _m = max(div_list)
    fac = [1]
    for i in range(1,_m+N):
        fac.append(fac[-1]*i%MOD)
    use = max(N-1,_m)
    
    def power(x,y):
        if y == 0:return 1
        elif y == 1:return x%MOD
        elif y%2 == 0:return power(x,y//2)**2%MOD
        else:return power(x,y//2)**2*x%MOD
        
    invfac = [0 for _ in range(use+1)]
    invfac[-1] = power(fac[use],MOD-2)
    for i in range(use-1,-1,-1):
        invfac[i] = invfac[i+1]*(i+1)%MOD
        
    for i in div_list:
        a = fac[i+N-1]
        b = invfac[i]
        c = invfac[N-1]
        ans *= (a*b*c)%MOD
        
    print(ans%MOD)

if __name__ == "__main__":
    main()