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

Fixed submission:
import itertools
import sys
import math
import numpy as np
import fractions
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

def get_lcm(num):
    return reduce(lambda x,y:(x * y) // fractions.gcd(x, y), num, 1)

def main():
    K = int(input())
    if 0<=K<=10:
        print(K)
        exit()

    lunlun = [i for i in range(1,10)]
    m = 0

    while len(lunlun) < K:
        x = lunlun[m]
        btm = x % 10

        if btm - 1 >= 0:
            lunlun.append(10*x+btm-1)

        lunlun.append(10*x+btm)

        if btm + 1 < 10:
            lunlun.append(10*x+btm+1)

        m += 1

    print(lunlun[::-1][len(lunlun)-K])

if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
import itertools
import sys
import math
import numpy as np
import fractions
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

def main():
    K = int(input())
    if 0<=K<=10:
        print(K)
        exit()

    lunlun = [i for i in range(1,10)]
    m = 0

    while len(lunlun) < K:
        x = lunlun[m]
        btm = x % 10

        if btm - 1 >= 0:
            lunlun.append(10*x+btm-1)

        lunlun.append(10*x+btm)

        if btm + 1 < 10:
            lunlun.append(10*x+btm+1)

        m += 1

    print(lunlun[::-1][len(lunlun)-K])

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

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N,K,C=mi()
    S=list(input())
    ok,ng = "o","x"

    OK = []
    for i in range(N):
        if S[i] == ok:
            OK.append(i+1) # 1-index
    
    greeds = [OK[0]]
    for i in range(1,len(OK)):
        x = OK[i]
        if x - greeds[-1] > C:
            greeds.append(x)
            if len(greeds) > K:
                break

    inv_greeds = [OK[-1]]
    inv_OK = OK[::-1]
    for i in range(1,len(OK)):
        x = inv_OK[i]
        if -x + inv_greeds[-1] > C:
            inv_greeds.append(x)
            if len(inv_greeds) > K:
                break
    
    if len(greeds) < K or len(inv_greeds) < K:
        exit()

    greeds = greeds[:K]
    inv_greeds = inv_greeds[:K][::-1]

    # print(greeds,inv_greeds)
    for i in range(len(greeds)):
        if greeds[i] == inv_greeds[i]:
            print(greeds[i])



    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

class SuperArray:
    def __init__(self,init_array=[]):
        self.arr = init_array
        self.se = set(init_array)
    
    def __getitem__(self, item):
        return self.arr[item]

    def append(self,x):
        self.arr.append(x)
        self.se.add(x)
    
    def remove(self,x):
        self.arr.remove(x)
        self.se.remove(x)
    
    def array(self):
        return self.arr
    
    def set(self):
        return self.se


INF=10**20
def main():
    N,K,C=mi()
    S=list(input())
    ok,ng = "o","x"

    OK = []
    for i in range(N):
        if S[i] == ok:
            OK.append(i+1) # 1-index
    
    greeds = [OK[0]]
    G = {OK[0]:1}
    for i in range(1,len(OK)):
        x = OK[i]
        if x - greeds[-1] > C:
            greeds.append(x)
            G[x] = len(greeds)
        
        if len(greeds) == K: # ? 
            break
    
    # print(greeds)
    ans = []
    for i,x in enumerate(greeds): # xなしで成り立つかどうか調べる
        available = -1
        new_list = [0]
        is_last = i == len(greeds) - 1
        for j in range(1,len(OK)):  
            _x = OK[j]
            if _x != x and (new_list[-1] == 0 or  _x - new_list[-1] > C):
                new_list.append(_x)
                if _x in G and not is_last:
                    # print("_x",_x)
                    # print("G",G[_x])
                    new_list = new_list[1:]
                    available = (K - G[_x] + 1) + len(new_list) - 1
                    assert available >= 0
                    break
        
        if available == -1:
            new_list = new_list[1:]
            available = len(new_list)
        
        # print(x,available)
        if available < K:
            ans.append(x)

    print(*ans,sep='\n')





        




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

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

INF = 10**20
def main():
    H,N = map(int,input().split())
    A,B = [],[]
    for _ in range(N):
        a,b = map(int,input().split())
        A.append(a)
        B.append(b)

    tp = 3 * 10**4
    dp = [INF] * tp
    dp[0] = 0
    ans = INF
    for h in range(tp):
        minim = INF
        for i in range(N):
            dp_i = h-A[i]
            if dp_i >= 0 and dp[dp_i] != INF:
                minim = min(minim,dp[dp_i]+B[i])
                # print(dp[h-A[i]]+B[i])

        if minim != INF:
            dp[h] = minim
            if h >= H:
                ans = min(ans,dp[h])


    print(ans)


if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)

INF = 10**20
def main():
    H,N = map(int,input().split())
    A,B = [],[]
    for _ in range(N):
        a,b = map(int,input().split())
        A.append(a)
        B.append(b)

    tp = 10**4
    dp = [INF] * tp
    dp[0] = 0
    for h in range(tp):
        minim = INF
        for i in range(N):
            dp_i = h-A[i]
            if dp_i >= 0 and dp[dp_i] != INF:
                minim = min(minim,dp[dp_i]+B[i])
                # print(dp[h-A[i]]+B[i])

        if minim != INF:
            dp[h] = minim
            if h >= H:
                # print(dp[h],h,dp)
                print(dp[h])
                exit()


    assert False


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

Fixed submission:
import itertools
import sys
import math
import numpy as np
import fractions
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

def get_lcm(num):
    return reduce(lambda x,y:(x * y) // fractions.gcd(x, y), num, 1)

def main():
    N,M = map(int,input().split())
    half_A = list(map(lambda x:int(x)//2,input().split()))

    lcm = get_lcm(half_A)

    if lcm > M:
        print(0)
        exit()

    for a in half_A:
        if (lcm // a) % 2 == 0:
            print(0)
            exit()

    # print(math.ceil(M/(2*lcm)))
    print((M//lcm + 1) // 2)


if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
import itertools
import sys
import math
import numpy as np
import fractions
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

def get_lcm(num):
    return reduce(lambda x,y:(x * y) // fractions.gcd(x, y), num, 1)

def main():
    N,M = map(int,input().split())
    half_A = list(map(lambda x:int(x)//2,input().split()))

    lcm = get_lcm(half_A)

    if lcm <= M:
        if reduce(lambda x, y: (lcm // x) % 2 == 1 and (lcm // y) % 2 == 1, half_A):
            print(math.ceil(M/(2*lcm)))
            exit()

    print(0)


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

Fixed submission:
import fractions
import sys
sys.setrecursionlimit(10**9)


INF=10**20
def prime_factorize(n):
    P = []
    P_set = set()
    while n % 2 == 0:
        P.append(2)
        P_set.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            P.append(f)
            P_set.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        P.append(n)
        P_set.add(n)

    P_count = {p:0 for p in P_set}
    for p in P: P_count[p] += 1

    return P_count


def solve(A: int, B: int):
    gcd = fractions.gcd(A,B)
    P = prime_factorize(gcd).keys()
    print(len(list(P))+1)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)



if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import itertools
import sys
import math
import numpy as np
import fractions
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

def main():
    A, B= map(int,input().split())
    gcd = math.gcd(A,B)
    root = math.sqrt(gcd)

    ps = []
    ans = 1
    for p in range(2,math.floor(root)+2):
        is_prime = True
        for _p in ps:
            if p % _p == 0:
                is_prime = False
                break
        if is_prime:
            ps.append(p)
            if gcd % p == 0:
                ans += 1


    print(ans)


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

Fixed submission:
import bisect
import sys
sys.setrecursionlimit(10**9)

def main():
    S, T = list(input()),list(input())

    len_of_S = len(S)
    counter = {}
    seen = set()
    for i in range(len_of_S):
        if S[i] in seen:
            counter[S[i]].append(i) # 常に単調増加
        else:
            counter[S[i]] = [i]
            seen.add(S[i])

    len_of_T = len(T)

    if not T[0] in seen:
        print(-1)
        exit()

    counts = counter[T[0]]
    if len(counts) == 0:
        print(-1)
        exit()

    pre = counts[0]
    rep = 1

    for i in range(1,len_of_T):
        if not T[i] in seen:
            print(-1)
            exit()

        counts = counter[T[i]]
        if len(counts) == 0:
            print(-1)
            exit()

        j = bisect.bisect_left(counts,pre)
        mx = len(counts)

        while j < mx and not counts[j] > pre:
            j += 1

        # print(pre,rep)
        if j<mx:
            pre = counts[j]
        else:
            pre = counts[0]
            rep += 1
        # print(pre,rep)

    # print(counter[T[::-1][0]],len_of_S)
    rep -= 1
    ans = rep * len_of_S  + pre + 1
    print(ans)




if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
import bisect
import sys
sys.setrecursionlimit(10**9)

def main():
    S, T = list(input()),list(input())

    len_of_S = len(S)
    counter = {}
    seen = set()
    for i in range(len_of_S):
        if S[i] in seen:
            counter[S[i]].append(i) # 常に単調増加
        else:
            counter[S[i]] = [i]
            seen.add(S[i])

    len_of_T = len(T)

    if not T[0] in seen:
        print(-1)
        exit()

    counts = counter[T[0]]
    if len(counts) == 0:
        print(-1)
        exit()

    pre = counts[0]
    rep = 1

    for i in range(1,len_of_T):
        counts = counter[T[i]]
        if len(counts) == 0:
            print(-1)
            exit()

        j = bisect.bisect_left(counts,pre)
        mx = len(counts)

        while j < mx and not counts[j] > pre:
            j += 1

        # print(pre,ans)
        if j<mx:
            pre = counts[j]
        else:
            pre = counts[0]
            rep += 1
        # print(pre,ans)

    # print(counter[T[::-1][0]],len_of_S)
    rep -= 1
    ans = rep * len_of_S  + counter[T[::-1][0]][0] + 1
    print(ans)




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

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

def main():
    S = input()
    N = len(S)
    MOD = 10**9+7

    # S = [int(s) if s!="?" else -1 for s in S ]
    dp = [[0] * 13 for _ in range(N+1)]

    s = S[0]
    if s == "?":
        for j in range(10):
            dp[0][j] += 1
    else:
        dp[0][int(s)%13] += 1
    for i in range(1,N):
        s = S[i]
        if s == "?":
            for j in range(0,13):
                for x in range(10):
                    k = (j*10+x)%13
                    dp[i][k] += dp[i-1][j]
                    dp[i][k] %= MOD
        else:
            for j in range(0,13):
                k = (j*10+int(s))%13
                dp[i][k] += dp[i-1][j]
                dp[i][k] %= MOD


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


if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

def main():
    S = input()
    N = len(S)

    # S = [int(s) if s!="?" else -1 for s in S ]
    dp = [[0] * 13 for _ in range(N+1)]

    s = S[0]
    if s == "?":
        for j in range(10):
            dp[0][j] += 1
    else:
        dp[0][int(s)%13] += 1
    for i in range(1,N):
        s = S[i]
        if s == "?":
            X = range(10)
        else:
            X = [int(s)]

        for j in range(0,13):
            ten_j = j*10
            for x in X:
                k = (ten_j+x)%13
                dp[i][k] += dp[i-1][j]
                # print(i,j,k)

    # print(dp)
    print(dp[N-1][5] % (10**9+7))



if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

def main():
    S = input()
    N = len(S)

    # S = [int(s) if s!="?" else -1 for s in S ]
    dp = [[0] * 13 for _ in range(N+1)]

    s = S[0]
    if s == "?":
        for j in range(10):
            dp[0][j] += 1
    else:
        dp[0][int(s)%13] += 1
    for i in range(1,N):
        s = S[i]
        if s == "?":
            X = range(10)
        else:
            X = [int(s)]

        for j in range(0,13):
            ten_j = j*10
            for x in X:
                k = (ten_j+x)%13
                dp[i][k] += dp[i-1][j]
                # print(i,j,k)

    # print(dp)
    print(dp[-2][5] % (10**9+7))



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

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N,M=mi()
    A=list(mi())

    v = [0] * 2*10**5
    seen = set([0])
    for i in range(N):
        v[i+1] = A[i] + v[i]
        v[i+1] %= M
        seen.add(v[i+1])
    
    counts = {x:0 for x in seen}
    for i in range(N+1):
        counts[v[i]] += 1
    
    ans = 0
    for _,count in counts.items():
        ans += count * (count-1) // 2
    
    print(ans)
    





if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N,M=mi()
    A=list(mi())

    v = [0] * 2*10**5
    seen = set()
    for i in range(N):
        v[i+1] = A[i] + v[i]
        v[i+1] %= M
        seen.add(v[i+1])
    
    counts = {x:0 for x in seen}
    for i in range(N+1):
        counts[v[i]] += 1
    
    ans = 0
    for _,count in counts.items():
        ans += count * (count-1) // 2
    
    print(ans)
    





if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N,M=mi()
    A=list(mi())

    v = [0] * 2*10**5
    seen = set()
    for i in range(N):
        v[i+1] = A[i] + v[i]
        v[i+1] %= M
        seen.add(v[i+1])
    
    counts = {x:0 for x in seen}
    for i in range(N+1):
        counts[v[i]] += 1
    
    ans = 0
    for _,count in counts.items():
        ans += count * (count-1) // 2
    
    print(ans)
    





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

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

print("Odd" if (a*b)%2!=0 else "Even")

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

t,x,y=[],[],[]
for i in range(n):
    l=list(map(int,input().split()))
    t.append(l[0])
    x.append(l[1])
    y.append(l[2])

if n==1:
    if x+y>t or (x+y)%2!=t%2:
        print("No")
    else:
        print("Yes")
    exit()


for i in range(n-1):
    dx=abs(x[i+1]-x[i])
    dy=abs(y[i+1]-y[i])
    dt=t[i+1]-t[i]

    if dx+dy>dt or (dx+dy)%2!=dt%2:
        print("No")
        exit()


print("Yes")
Problem p03035 (python)

Fixed submission:
a,b=list(map(int,input().split(" ")))
if a>=13:
  pass
elif a>=6:
  b=b//2
else:
  b=0
  
print(b)

Buggy submission (verdict: Runtime Error):
a,b=list(map(int,input().split(" ")))
if a>=13:
  pass
elif a>=6:
  b=b//2
else
  b=0
  
print(b)

Buggy submission (verdict: Runtime Error):
a,b=list(map(int,input().split(" ")))
if b>=13:
  pass
elif b>=6:
  b=b//2
else
  b=0
  
print(b)
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000)

def func(num,pr):
  global l,ans

  if len(l[num])!=0:
    for z in l[num]:
      if z[0]==pr:
        continue

      if pr==-1:
        ans[z[0]]=z[1]
      else:
        ans[z[0]]=ans[num]+z[1]
      func(z[0],num)

N=int(input())
l=[ [] for z in range(N)]
ans=[0]*N


for z in range(N-1):
  u,v,w=list(map(int,input().split(" ")))
  l[u-1].append((v-1,w))
  l[v-1].append((u-1,w))

func(0,-1)

#print(l)
#print(ans)


for z in ans:
  if z%2==0:
    print(1)
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
def func(num,pr):
  global l,ans

  if len(l[num])!=0:
    for z in l[num]:
      if z[0]==pr:
        continue

      if pr==-1:
        ans[z[0]]=z[1]
      else:
        ans[z[0]]=ans[pr]+z[1]
      func(z[0],num)

N=int(input())
l=[ [] for z in range(N)]
ans=[0]*N


for z in range(N-1):
  u,v,w=list(map(int,input().split(" ")))
  l[u-1].append((v-1,w))
  l[v-1].append((u-1,w))

func(0,-1)

for z in ans:
  if z%2==0:
    print(1)
  else:
    print(0)
Problem p03048 (python)

Fixed submission:
import sys

sys.setrecursionlimit(100000)

def f(a):
  global R,G,B,N,ans,Rm,Gm,Bm

  for b in range(N-R*a+1):
    cmod=(N-R*a-G*b)%B
    c=(N-R*a-G*b)//B
    if cmod==0 and  c>=0:
      ans+=1
    elif c<0:
      break

  if a>0:
    f(a-1)


R,G,B,N=list(map(int,input().split(" ")))

ans=0

f(N//R+1)

print(ans)

Buggy submission (verdict: Runtime Error):
def f(a):
  global R,G,B,N,ans,Rm,Gm,Bm

  for b in range(N-R*a+1):
    cmod=(N-R*a-G*b)%B
    c=(N-R*a-G*b)//B
    if cmod==0 and  c>=0:
      ans+=1

  if a>0:
    f(a-1)


R,G,B,N=list(map(int,input().split(" ")))
Rm=N//R
Gm=N//G
Bm=N//B

ans=0

f(Rm)

print(ans)
Problem p03049 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

def f(a,b,ba):
  if a>0 and ba>0:
    return 1 + f(a,b,ba-1)
  elif a>0 and b>0:
    return 1+ f(a-1,b-1,ba)
  elif ba>1:
    return 1 + f(a+1,b,ba-2)
  elif ba>0 and b>0:
    return 1 + f(a,b-1,ba-1)

  return 0

N=int(input())
a=[]
b=[]

stA=0
stB=0
stBA=0

ans=0
for x in range(N):
  z=input()
  buf=z.count("AB")
  b.append((z[0],z[-1],buf))
  ans+=buf

for z in b:
  if z[0]=="B" and z[1]=="A":
    stBA+=1
  elif z[0]=="B":
    stB+=1
  elif z[1]=="A":
    stA+=1

ans=ans+f(stA,stB,stBA)
print(ans)

Buggy submission (verdict: Runtime Error):
def f(a,b,ba):
  if a>0 and b>0:
    return 1 + f(a-1,b-1,ba)
  elif a>0 and ba>0:
    return 1 + f(a-1,b+1,ba-1)
  elif ba>0 and b>0:
    return 1 + f(a,b-1,ba-1)

  return 0

N=int(input())
a=[]
b=[]

stA=0
stB=0
stBA=0

ans=0
for z in range(N):
  a.append(input())

for z in a:
  buf=z.count("AB")
  b.append((z[0],z[-1],buf))
  ans+=buf

for z in b:
  if z[0]=="B" and z[1]=="A":
    stBA+=1
  elif z[0]=="B":
    stB+=1
  elif z[1]=="A":
    stA+=1

ans=ans+f(stA,stB,stBA)
print(ans)
Problem p03147 (python)

Fixed submission:
import sys

def f(k):
  global N,h,update
  if k==N:
    return -1
  if h[k]==0:
    return k
  else:
    h[k]-=1
    update=True
    f(k+1)


update=False
N=int(input())
h=list(map(int,input().split(" ")))
r=0
s=0

try:
  while True:
    if h[s]!=0:
      break
    s+=1
except Exception:
  print(0)
  sys.exit(0)

while True:
  f(s)
  if update:
    r+=1
    while s!=N-1 and h[s]==0:
      s+=1
    update=False
  else:
    break

print(r)

Buggy submission (verdict: Runtime Error):
def f(k):
  global N,h,update
  if k==N:
    return -1
  if h[k]==0:
    return k
  else:
    h[k]-=1
    update=True
    f(k+1)


update=False
N=int(input())
h=list(map(int,input().split(" ")))
r=0
s=0
while True:
  if h[s]!=0:
    break
  s+=1

while True:
  f(s)
  if update:
    r+=1
    while s!=N-1 and h[s]==0:
      s+=1
    update=False
  else:
    break

print(r)
Problem p03523 (python)

Fixed submission:
import re
s=input()
m=re.match(r'A?KIHA?BA?RA?$',s)
if m!=None:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
rt re
s=input()
m=re.match(r'A*KIHA*BA*RA*',s)
if m!=None:
    print("YES")
else:
    print("NO")
Problem p02900 (python)

Fixed submission:
import fractions
a,b = map(int,input().split())
longer = max(a,b)
lcm = fractions.gcd(a,b)
i = 1
ans = 1
while True:
  i += 1
  if i * i >= longer:
    if lcm != 1:
      ans += 1
    break
  elif lcm == 1:
    break

  if lcm % i == 0:
    # print(i)
    ans += 1
    while lcm % i == 0:
      lcm //= i
# print(lcm)
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
a, b = map(int, input().split())
gc = fractions.gcd(a, b)

def prime_factorize(n):
    a = []
    if n % 2 == 0:
        a.append(2)
        while n % 2 == 0:
            n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            while n % f == 0:
                n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

print(len(prime_factorize(gc) + 1)

Buggy submission (verdict: Runtime Error):
import fractions
a, b = map(int, input().split())
gc = math.factorial(a, b)

def prime_factorize(n):
    a = []
    if n % 2 == 0:
        a.append(2)
        while n % 2 == 0:
            n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            while n % f == 0:
                n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

print(len(prime_factorize(gc) + 1)

Buggy submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())
longer = max(a,b)
lcm = math.gcd(a,b)
i = 1
ans = 1
while True:
  i += 1
  if i * i >= longer:
    break
  elif lcm == 1:
    break

  if lcm % i == 0:
    # print(i)
    ans += 1
    while lcm % i == 0:
      lcm //= i
print(ans)
Problem p02917 (python)

Fixed submission:
n = int(input())
b = list(map(int,input().split()))
ans = b[0]
for i in range(n - 2):
    
    ans += min(b[i],b[i + 1])

ans += b[-1]
print(ans)

Buggy submission (verdict: Runtime Error):
b = list(map(int,input().split()))
ans = b[0]
for i in range(n - 2):
    
    ans += min(b[i],b[i + 1])

ans += b[-1]
print(ans)
Problem p02927 (python)

Fixed submission:
N,M = map(int,input().split())
ans = 0
for n in range(1,N + 1):
        for m in range(1,M + 1):
                m = str(m)
                if len(m) == 1:
                        continue
                if int(m[1]) < 2 or int(m[0]) < 2:
                        continue
                if n == int(m[0]) * int(m[1]):
                        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
time_ans = 0
A_sort = sorted(A)
before = -1
b = -1
for i in range(N):
        a_sorti = A_sort[i]
        if a_sorti == before:
                time_ans += b
                continue
        b = A_sort.index(a_sorti)
        time_ans += b
        before = a_sorti

for i in range(N):
        for j in range(i + 1,N):
                if A[i] > A[j]:
                        ans += 1
ans1 = int((time_ans * K * (K - 1)) / 2) - K * (time_ans - ans)
print(ans1 % (10 ** 9 + 7))