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

Fixed submission:
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y == 0:
      	return y
    else:
      	while x%y!=0:
      	    z =	x%y
      	    x =	y
      	    y =	z
      	else:
      	    return z

def lcm(m, n):
    return int(m * n/gcd(m, n))

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

print(lcm(AB[0],AB[1]))

Buggy submission (verdict: Runtime Error):
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y == 0:
      	return y
    else:
      	while x%y!=0:
      	    z =	x%y
      	    x =	y
      	    y =	z
	else:
      	    return z

def lcm(m, n):
    return int(m * n/gcd(m, n))

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

print(lcm(AB[0],AB[1]))

Buggy submission (verdict: Runtime Error):
import math

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

print((AB[0]*AB[1])//math.gcd(AB[0],AB[1]))
Problem p02552 (python)

Fixed submission:
x = int ( input() )
if x==1:
  print (0)
  
else :
  print (1)

Buggy submission (verdict: Runtime Error):
def(x)
 if x == 1
  return 0
return 1
Problem p02552 (python)

Fixed submission:
x=int(input())
if x==1:
  print("0")
if x==0:
  print("1")

Buggy submission (verdict: Runtime Error):
x=input()
if x==1:
  print("0")
elif x==0:
  print("1")
else:
  break

Buggy submission (verdict: Runtime Error):
x=include("xを入力してください")
if x==1:
  print("0")
else:
  print("1")

Buggy submission (verdict: Runtime Error):
x=input(xを入力してください)
if x==1:
  print("0")
 elif x==0:
  print("1")
Problem p02552 (python)

Fixed submission:
a = input()
if a == '0':
  print('1')
elif a == '1':
  print('0')

Buggy submission (verdict: Runtime Error):
input(a)
if a == '0':
  print('1')
elif a == '1':
  print('0')
Problem p02570 (python)

Fixed submission:
a,b,c = map(int, input().split())
if a <= b*c :
  print('Yes')
elif a > b*c :
   print('No')

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, input())
if a <= b*c :
  print('Yes')
elif a > b*c :
   print('No')

Buggy submission (verdict: Runtime Error):
a = input()
a = [int(a)]
b = a[1]*a[2]
if b >= a[0]:
  print('Yes')
elif b < a[0]:
  print('No')

Buggy submission (verdict: Runtime Error):
a = int([input()])
b = a[1]*a[2]
if b >= a[0]:
  print('Yes')
elif b < a[0]:
  print('No')

Buggy submission (verdict: Runtime Error):
a = int[input()]
b = a[1]*a[2]
if b >= a[0]:
  print('Yes')
elif b < a[0]:
  print('No')

Buggy submission (verdict: Runtime Error):
a = [input()]
b = a[1]*a[2]
if b >= a[0]:
  print('Yes')
elif b < a[0]:
  print('No')
Problem p02552 (python)

Fixed submission:
a=input()
if a=='1':
  print('0')
if a=='0':
  print('1')

Buggy submission (verdict: Runtime Error):
a=input()
if a=='1':
  print('0')
 else:
  print('1')
Problem p02557 (python)

Fixed submission:
#!/usr/bin/env python


def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    b = list(reversed(b))
    bad = next((x for x, y in zip(a, b) if x == y), None)
    if bad is None:
        print('Yes')
        print(' '.join(map(str, b)))
    else:
        l_1 = sum(1 for x, y in zip(a, b) if x < bad < y)
        l_2 = sum(1 for x, y in zip(a, b) if x < y and bad in (x, y))
        l_3 = sum(1 for x, y in zip(a, b) if x == y)
        l_4 = sum(1 for x, y in zip(a, b) if x > y and bad in (x, y))
        l_5 = sum(1 for x, y in zip(a, b) if x > bad > y and x != bad)
        if l_3 > l_1 + l_5:
            print('No')
        else:
            good_part = b[:l_1] + b[l_1 + l_2 + l_3 + l_4:]
            bad_part = b[l_1 + l_2:l_1 + l_2 + l_3]
            b[l_1 + l_2:l_1 + l_2 + l_3] = good_part[:l_3]
            good_part[:l_3] = bad_part
            b[:l_1] = good_part[:l_1]
            b[l_1 + l_2 + l_3 + l_4:] = good_part[l_1:]
            assert all(x != y for x, y in zip(a, b))
            print('Yes')
            print(' '.join(map(str, b)))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python


def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    b = list(reversed(b))
    bad = next((x for x, y in zip(a, b) if x == y), None)
    if bad is None:
        print(' '.join(map(str, b)))
    else:
        l_1 = sum(1 for x, y in zip(a, b) if x < y and y != bad)
        l_2 = sum(1 for x, y in zip(a, b) if x < y and y == bad)
        l_3 = sum(1 for x, y in zip(a, b) if x == y)
        l_4 = sum(1 for x, y in zip(a, b) if x > y and x == bad)
        l_5 = sum(1 for x, y in zip(a, b) if x > y and x != bad)
        if l_3 > l_1 + l_5:
            print('No')
        else:
            good_part = b[:l_1] + b[l_1 + l_2 + l_3 + l_4:]
            bad_part = b[l_1 + l_2:l_1 + l_2 + l_3]
            b[l_1 + l_2:l_1 + l_2 + l_3] = good_part[:l_3]
            good_part[:l_3] = bad_part
            b[:l_1] = good_part[:l_1]
            b[l_1 + l_2 + l_3 + l_4:] = good_part[l_1:]
            assert all(x != y for x, y in zip(a, b))
            print('Yes')
            print(' '.join(map(str, b)))


if __name__ == '__main__':
    main()
Problem p02570 (python)

Fixed submission:
d,t,s = map(int,input().split())
if d/s <=t:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
d,t,s = map(int,input().split())
if d/s <=t　:
  print('Yes')
else:
  print('No')
Problem p02622 (python)

Fixed submission:
S=input()
T=input()
aa=0
for s,t in zip(S,T):
  if s!=t:
    aa+=1
print(aa)

Buggy submission (verdict: Runtime Error):
S=input()
T=input()
aa=0
for s,t in zip(S,T):
  if s!=t:
    a+=1
print(a)
Problem p02629 (python)

Fixed submission:
n=int(input())
a=''
while n != 0:
  n-=1
  a=chr(int(97+n%26))+a
  n//=26
print(a)

Buggy submission (verdict: Runtime Error):
n=int(input())
i=0
while True:
    i+=1
    if (26**i-1)/25*26>=n:
        n-=(26**i-1)/25*26
        break
def sisu(n, b):
　if (int(n/b)):
　　return sisu(int(n/b), b) + chr(n%b+65)
　return chr(n%b+65)
aa=sisu(n,26)
aa="a"*(i-len(aa))+aa
print(aa)
Problem p02829 (python)

Fixed submission:
a=input()
b=input()
c=6-a-b
print(c)

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
c=6-a-b
print(c)

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
c=6-a-b
print(c)
Problem p02847 (python)

Fixed submission:
a=input()
if a=='SUN':
 b=7
if a=="MON":
 b=6
if a=="TUE":
 b=5
if a=="WED":
 b=4
if a=="THU":
 b=3
if a=="FRI":
 b=2
if a=="SAT":
 b=1
print(b)

Buggy submission (verdict: Runtime Error):
a=input()
if a=="SUN":
 b=7
if a=="MON":
 b=6
if a=="TUE":
 b=5
if a=="WED":
 b=4
if a=="THU":
 b=3
if a=="FRI":
 b=2
if a=="SET":
 b=1
print(b)
Problem p04005 (python)

Fixed submission:
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
abc=sorted([a,b,c])
if abc[2]%2==0:
    print(0)
else:
    print(abc[0]*abc[1])

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
a,b,c=[a,b,c].sort()
print(a*b)
Problem p02570 (python)

Fixed submission:
a,b,c = map(int, input().split())
print("Yes") if b * c >= a else print("No")

Buggy submission (verdict: Runtime Error):
def compare(a,b):
  res = 0
  for x,y in zip(a,b):
    if x == y:
      res += 1
  return res

s,t = map(int, input().split())
len_t = len(t)
ans = 0
for i in range(len(s)-len(t)+1):
  ans = max(ans,compare(s[i:i+len_t],t))
print(ans)
Problem p02580 (python)

Fixed submission:
h,w,m = map(int, input().split())
hw = [list(map(int, input().split())) for i in range(m)]
bomb = set()
h_list = [0] * (h+1)
w_list = [0] * (w+1)
for H,W in hw:
  h_list[H] += 1
  w_list[W] += 1
  bomb.add((H,W))
max_h = max(h_list)
max_w = max(w_list)
maxh_list = []
maxw_list = []
for k,v in enumerate(h_list):
  if v == max_h:
    maxh_list.append(k)
for k,v in enumerate(w_list):
  if v == max_w:
    maxw_list.append(k)
if len(maxh_list) * len(maxw_list) > m:
  ans = max_h + max_w
else:
  ans = max_h + max_w - 1
  for i in maxh_list:
    for j in maxw_list:
      if (i,j) not in bomb:
        ans = max_h + max_w
        break
print(ans)

Buggy submission (verdict: Runtime Error):
h,w,m = map(int, input().split())
hw = [list(map(int, input().split())) for i in range(m)]
bomb = set()
h_list = [0] * (h+1)
w_list = [0] * (w+1)
for H,W in hw:
  h_list[H] += 1
  w_list[W] += 1
  bomb.add((H,W))
max_h = max(h_list)
max_w = max(w_list)
maxh_list = []
maxw_list = []
for k,v in enumerate(h_list):
  if v == max_h:
    maxh_list.append(k)
for k,v in enumerate(w_list):
  if v == max_w:
    maxw_list.append(k)
if len(maxh_list) * len(maxv_list) > m:
  ans = max_h * max_w
else:
  ans = max_h * max_w - 1
  for i in maxh_list:
    for j in maxw_list:
      if (i,j) not in bomb:
        ans = max_h * max_w
        break
print(ans)
Problem p02759 (python)

Fixed submission:
n = int(input())
if n % 2:
  print(n//2+1)
else:
  print(n//2)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
keta = ["-1"] * n
if n == 1:
  ans = -1
  for s,c in sc:
    if ans == -1 or ans == c:
      ans = c
    else:
      print(-1)
      exit()
  if ans == -1:
    print(0)
  else:
    print(ans)
else:
  for s,c in sc:
    s-=1
    if keta[s] == "-1" or keta[s] == str(c):
      keta[s] = str(c)
    else:
      print(-1)
      exit()
  ans = ""
  for k,i in enumerate(keta):
    if i == "-1":
      if k == 0:
        ans += "1"
      else:
        ans += "0"
    else:
      ans += i   
  if ans[0] == "0":
    print(-1)
    exit()
  else:
    print(ans)
Problem p02863 (python)

Fixed submission:
from itertools import accumulate

n,t = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
dp1 = [[-(10 ** 18)] * t for i in range(n)]
dp2 = [[-(10 ** 18)] * t for i in range(n)]
dp1[0][0] = 0
dp2[0][0] = 0
for i,(a,b) in enumerate(ab[:-1]):
  for j in range(t):
    dp1[i+1][j] = max(dp1[i+1][j],dp1[i][j])
    if j < t-a:
      dp1[i+1][j+a] = max(dp1[i+1][j+a],dp1[i][j]+b)
for i,(a,b) in enumerate(ab[n-1:0:-1]):
  for j in range(t):
    dp2[i+1][j] = max(dp2[i+1][j],dp2[i][j])
    if j < t-a:
      dp2[i+1][j+a] = max(dp2[i+1][j+a],dp2[i][j]+b)
ans = 0
for key,(i,j,(a,b)) in enumerate(zip(dp1,dp2[::-1],ab)):
  nowi,nowj = 0,0
  I,J = [],[]
  for x,y in zip(i,j):
    nowi = max(nowi,x)
    nowj = max(nowj,y)
    I.append(nowi)
    J.append(nowj)
  J.reverse()
  tmp = 0
  for x,y in zip(I,J):
    tmp = max(tmp,x+y)
  tmp += b
  ans = max(ans,tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate

n,t = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
dp1 = [[-(10 ** 18)] * t for i in range(n)]
dp2 = [[-(10 ** 18)] * t for i in range(n)]
dp1[0][0] = 0
dp2[0][0] = 0
for i,(a,b) in enumerate(ab[:-1]):
  for j in range(t-a):
    dp1[i+1][j] = max(dp1[i+1][j],dp1[i][j])
    dp1[i+1][j+a] = max(dp1[i+1][j+a],dp1[i][j]+b)
  for j in range(t-a,t):
    dp1[i+1][j] = max(dp1[i+1][j],dp1[i][j])
for i,(a,b) in enumerate(ab[n-1:0:-1]):
  for j in range(t-a):
    dp2[i+1][j] = max(dp2[i+1][j],dp2[i][j])
    dp2[i+1][j+a] = max(dp2[i+1][j+a],dp2[i][j]+b)
  for j in range(t-a,t):
    dp2[i+1][j] = max(dp2[i+1][j],dp2[i][j])
ans = 0
for key,(i,j,(a,b)) in enumerate(zip(dp1,dp2[::-1],ab)):
  nowi,nowj = 0,0
  I,J = [],[]
  for x,y in zip(i,j):
    nowi = max(nowi,x)
    nowj = max(nowj,y)
    I.append(nowi)
    J.append(nowj)
  J.reverse()
  tmp = 0
  for x,y in zip(I,J):
    tmp = max(tmp,x+y)
  tmp += b
  ans = max(ans,tmp)
print(ans)
Problem p02897 (python)

Fixed submission:
n = int(input())
if n % 2:
  print((n+1) / (n * 2))
else:
  print(0.5)

Buggy submission (verdict: Runtime Error):
import fractions

def prime_divisor(n):
  prime_divisor_set = {1}
  end = int(n ** 0.5) + 1
  for i in range(2, 10 ** 5 + 1):
    if not (n % i):
      prime_divisor_set.add(i)
      while (n % i) == 0:
        n //= i
  return prime_divisor_set


a, b = map(int, input().split())
s1, s2 = prime_divisor(a), prime_divisor(b)
ans = len(s1 & s2)
print(len(prime_divisor(fractions.gcd(a, b))))

Buggy submission (verdict: Runtime Error):
def prime_divisor(n):
  prime_divisor_set = {1}
  end = int(n ** 0.5) + 1
  for i in range(2, 10 ** 5 + 1):
    if not (n % i):
      prime_divisor_set.add(i)
      while (n % i) == 0:
        n //= i
  return prime_divisor_set


a, b = map(int, input().split())
s1, s2 = prime_divisor(a), prime_divisor(b)
ans = len(s1 & s2)
print(ans)

Buggy submission (verdict: Runtime Error):
def prime_divisor(n):
  prime_divisor_set = {1}
  end = int(n ** 0.5) + 1
  for i in range(2, end):
    if not (n % i):
      prime_divisor_set.add(i)
      while (n % i) == 0:
        n //= i
  return prime_divisor_set


a, b = map(int, input().split())
s1, s2 = prime_divisor(a), prime_divisor(b)
ans = len(s1 & s2)
print(ans)
Problem p02990 (python)

Fixed submission:
from operator import mul
from functools import reduce

def cmb(n,r):
    if r > n: return 0
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n,k = map(int, input().split())
mod = 10 ** 9 + 7
for i in range(1,k+1):
  print((cmb(n-k+1,i) % mod * cmb(k-1, i-1) % mod) % mod)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n,k = map(int, input().split())
mod = 10 ** 9 + 7
for i in range(1,k+1):
  print((cmb(n-k+1,i) % mod * cmb(k-1, i-1) % mod) % mod)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n,k = map(int, input().split())
mod = 10 ** 9 + 7
for i in range(1,k+1):
  print((cmb(n-k+1,i) * cmb(k-1, i-1)) % mod)
Problem p03045 (python)

Fixed submission:
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]


n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(m)]
uf = UnionFind(n)
b = []
for i in a:
    uf.union(i[0]-1,i[1]-1)
for i in range(n):
  b.append(uf.find(i))
print(len(list(set(b))))

Buggy submission (verdict: Runtime Error):
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]


n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(m)]
uf = UnionFind(n)
for i in a:
    uf.union(i[0],i[1])

print(len(list(set(uf.par))))
Problem p03072 (python)

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

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

Fixed submission:
a = [int(input()) for i in range(5)]
k = int(input())
if max(a) - min(a) <= k:
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
a = [int(input()) for i in range(5)]
k = input()
if max(a) - min(a) <= k:
  print("Yay!")
else:
  print(":(")
Problem p03221 (python)

Fixed submission:
import math
n,m = map(int, input().split())
a = []
for i in range(m):
  pk,yk = map(int,input().split())
  b = [pk,yk,i]
  a.append(b)
a.sort(key=lambda x:(x[0],x[1]))
b = a[0][0]
c = 0
for i in range(len(a)):
  if a[i][0] != b:
    b = a[i][0]
    c = 1
  else:
    c += 1
  a[i].append(c)
a.sort(key=lambda x:x[2])
for i in range(len(a)):
  a[i].append(math.floor(math.log10(a[i][0])+1.0))
  a[i].append(math.floor(math.log10(a[i][3])+1.0))
  print(str("0"*(6-a[i][4]))+str(a[i][0])+str("0"*(6-a[i][5]))+str(a[i][3]))

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(m)]
c = [0]*n
for i in a:
  p,y = i[0],i[1]
  c[p-1] += 1
  num = c[p-1]
  print("0"*(6-len(p))+"0"*(6-len(num))+num)
Problem p03242 (python)

Fixed submission:
print(1110-int(input()))

Buggy submission (verdict: Runtime Error):
print(1100-int((input()))

Buggy submission (verdict: Runtime Error):
print(1100-int((input()))
Problem p03250 (python)

Fixed submission:
n = list(map(int,input().split()))
n.sort()
n.reverse()
print(n[0]*10+n[1]+n[2])

Buggy submission (verdict: Runtime Error):
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

  
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
  
  
N,M = map(int, input().split())
m_factorized = factorize(M)
mod = 10 ** 9 + 7
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
ans = 1
for i in range( 2, 2**N + 1 ):
  g1.append( ( g1[-1] * i ) % mod )
  inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
  g2.append( (g2[-1] * inverse[-1]) % mod )
    
    
for i in m_factorized:
  k = i[1] 
  ans *= cmb(N-1+k,k,mod)
  ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
for i in range(len(s)-2):
  if (s[i] == s[i+1]) != (t[i] == t[i+1]):
    print("No")
    exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
n = list(map(int,input().split())).sort()
print(n[2]*10+n[1]+n[0])

Buggy submission (verdict: Runtime Error):
n = list(map(int,input(),split()))
n.sort()
n.reverse()
print(n[0]*10+n[1]+n[2])
Problem p03253 (python)

Fixed submission:
from functools import reduce
from operator import mul

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

  
def cmb(n, r):
    """
    組み合わせの数 nCr
    :param n:
    :param r:
    :return:
    """
    r = min(n - r, r)
    if r == 0:
        return 1
    return reduce(mul, range(n, n - r, -1)) // reduce(mul, range(r, 0, -1))
  
  
N,M = map(int, input().split())
m_factorized = factorize(M)
mod = 10 ** 9 + 7

ans = 1

    
for i in m_factorized:
  k = i[1] 
  ans *= cmb(N-1+k,k)
  ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

  
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
  
  
N,M = map(int, input().split())
m_factorized = factorize(M)
mod = 10 ** 9 + 7
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
ans = 1
for i in range( 2, 2**N + 1 ):
  g1.append( ( g1[-1] * i ) % mod )
  inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
  g2.append( (g2[-1] * inverse[-1]) % mod )
    
    
for i in m_factorized:
  k = i[1] 
  ans *= cmb(N-1+k,k,mod)
  ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

  
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
  
  
N,M = map(int, input().split())
m_factorized = factorize(M)
mod = 10 ** 9 + 7
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
ans = 1
for i in range( 2, 2**N + 1 ):
  g1.append( ( g1[-1] * i ) % mod )
  inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
  g2.append( (g2[-1] * inverse[-1]) % mod )
    
    
for i in m_factorized:
  k = i[1] 
  ans *= cmb(N-1+k,k,mod)
  ans %= mod
print(ans)
Problem p03291 (python)

Fixed submission:
s = input()
mod = 10**9 + 7
abc = 0
bc = 0
c = 0
q = 0
for i in s[::-1]:
  if i == "A":
    abc = (abc + bc) % mod
  if i == "B":
    bc = (bc + c) % mod
  if i == "C":
    c = (pow(3,q,mod) + c) % mod
  if i == "?":
    abc = (abc*3 + bc) % mod
    bc = (bc*3 + c) % mod 
    c = (pow(3,q,mod) + c*3) % mod
    q += 1
print(int(abc))

Buggy submission (verdict: Runtime Error):
from math import pow

  
s = input()
mod = 10**9 + 7
abc = 0
bc = 0
c = 0
q = 0
for i in s[::-1]:
  if i == "A":
    abc = (abc + bc) % mod
  if i == "B":
    bc = (bc + c) % mod
  if i == "C":
    c = (pow(3,q)%mod+c) % mod
  if i == "?":
    abc = (abc*3 + bc) % mod
    bc = (bc*3 + c) % mod 
    c = (pow(3,q)%mod + c*3) % mod
    q += 1
print(int(abc))

Buggy submission (verdict: Runtime Error):
from math import pow

  
s = input()
mod = 10**9 + 7
abc = 0
bc = 0
c = 0
q = 0
for i in s[::-1]:
  if i == "A":
    abc = (abc + bc) % mod
  if i == "B":
    bc = (bc + c) % mod
  if i == "C":
    c = (pow(3,q)+c) % mod
  if i == "?":
    abc = (abc*3 + bc) % mod
    bc = (bc*3 + c) % mod 
    c = (pow(3,q) + c*3) % mod
    q += 1
print(int(abc))

Buggy submission (verdict: Runtime Error):
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

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

  
s = input()
mod = 10**9 + 7
abc = 0
bc = 0
c = 0
q = 0
for i in s[::-1]:
  if i == "A":
    abc = (abc + bc) % mod
  if i == "B":
    bc = (bc + c) % mod
  if i == "C":
    c = (power(3,q)+c) % mod
  if i == "?":
    abc = (abc*3 + bc) % mod
    bc = (bc*3 + c) % mod 
    c = (power(3,q) + c*3) % mod
    q += 1
print(abc)
Problem p03315 (python)

Fixed submission:
n = input()
a = 0
for i in n:
  if i == "+":
    a+=1
  else:
    a-=1
print(a)

Buggy submission (verdict: Runtime Error):
n = input().split()
a = 0
for i in n:
  if i = "+"
    a+=1
  else
    a-=1
print(a)
Problem p03327 (python)

Fixed submission:
n = int(input())
if n <=999:
  print("ABC")
else:
  print("ABD")

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

if n <=999:
  print("ABC")
else:
  print("ABD"))