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

Fixed submission:
p = sum(map(int, input().split()))
if p < 10:
    print(p)
else:
    print("error")

Buggy submission (verdict: Runtime Error):
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        int a = inp.nextInt();
        int b = inp.nextInt();
        inp.close();
        System.out.println((a + b) < 10 ? a + b : "error");
    }
}

Buggy submission (verdict: Runtime Error):
s=eval(input()).replace(" ","+");print(s if s < 10 else"10")
Problem p03860 (python)

Fixed submission:
a,b,c=input().split();print(a[0]+b[0]+c[0])

Buggy submission (verdict: Runtime Error):
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        inp.next();
        char s = inp.next().toCharArray()[0];
        System.out.println("A" + s + "C");
    }
}
Problem p03943 (python)

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

Buggy submission (verdict: Runtime Error):
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        int a = inp.nextInt();
        int b = inp.nextInt();
        int c = inp.nextInt();
        boolean flag = false;
        if ((a + b) == c) flag = true;
        if ((a + c) == b) flag = true;
        if ((b + c) == a) flag = true;
        System.out.println(flag ? "Yes" : "No");
    }
}
Problem p02588 (python)

Fixed submission:
def divide(n, p):
    c = 0
    while n%p == 0 and c < 18:
        c += 1
        n //= p
    return c

n = int(input())
table = [[0]*19 for _ in range(19)]
for i in range(n):
    sub = input()
    key = float(sub)
    if "." in sub:
        a, b = map(str, sub.split("."))
        s = int(a)*1000000000+10**(9-len(b))*int(b)
    else:
        s = int(sub)
        s *= 1000000000
    if key != s/1000000000:
        while True:
            pass
    c2, c5 = divide(s, 2), divide(s, 5)
    table[c2][c5] += 1

ans = 0
for i in range(19):
    for j in range(19):
        for k in range(19):
            for l in range(19):
                if i+k < 18 or j+l < 18:
                    continue;
                if i == k and j == l:
                    ans += table[i][j]*(table[k][l]-1)
                else:
                    ans += table[i][j]*table[k][l]

ans //= 2
print(ans)

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


def divide(n):
    c1, c2 = 0, 0
    while (n%2 == 0):
        c1 += 1
        n //= 2
    while (n%5 == 0):
        c2 += 1
        n //= 5
    c1, c2 = min(18, c1), min(18, c2)
    return (c1, c2)
    

def main():
    n = int(input())
    a = [divide(int(Decimal(float(input()))*1e9)) for _ in range(n)]

    dp = [[0]*20 for _ in range(20)]
    for i in range(n):
        c1, c2 = a[i]
        dp[c1][c2] += 1
    
    for i in range(18, -1, -1):
        for j in range(18, -1, -1):
            dp[i][j] += dp[i+1][j]+dp[i][j+1]-dp[i+1][j+1]

    ans = 0
    for i in range(n):
        c1, c2 = a[i]
        if (c1 >= 9 and c2 >= 9):
            ans -= 1
        ans += dp[18-c1][18-c2]
        
    print(ans//2)
    

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

Fixed submission:
s = input()
print(s[:3])

Buggy submission (verdict: Runtime Error):
import sys

def main():
    input = sys.stdin.readline
    n, k = map(int, input().split())
    a = [int(x) for x in input().split()]
    key = 1
    nn = n
    while nn > 0:
        key += 1
        nn //= 2
    
    for _ in range(min([key*2, k])):
        b = [0]*n
        for i in range(n):
            l, r = max([i-a[i], 0]), min([i+a[i], n-1])
            b[l] += 1
            if r != n-1:
                b[r+1] -= 1
        for i in range(n):
            a[i] = 0
            a[i] += b[i]
            if i != 0:
                 a[i] += a[i-1]
    print(*a)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

def main():
    input = sys.stdin.readline
    n, k = map(int, input().split())
    a = [int(x) for x in input().split()]
    key = 30
    nn = n
    while nn > 0:
        key += 1
        nn //= 2
    
    for _ in range(min([key, k])):
        b = [0]*n
        for i in range(n):
            l, r = max([i-a[i], 0]), min([i+a[i], n-1])
            b[l] += 1
            if r != n-1:
                b[r+1] -= 1
        for i in range(n):
            a[i] = 0
            a[i] += b[i]
            if i != 0:
                 a[i] += a[i-1]
    print(*a)

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

Fixed submission:
n, m, x = map(int, input().split())
books = [0]*n
for i in range(n):
  books[i] = [int(x) for x in input().split()]

ans = 10**9
for i in range(2**n):
  cost = 0
  point = [0]*m
  for j in range(n):
    if (i>>j)&1:
      cost += books[j][0]
      for k in range(1, m+1):
        point[k-1] += books[j][k]
  flag = True
  for j in range(m):
    if point[j] < x:
      flag = False
  if flag and ans > cost:
    ans = cost

print(ans if ans != 10**9 else -1)

Buggy submission (verdict: Runtime Error):
n, m, x = map(int, input().split())
books = [0]*n
for i in range(n):
  books[i] = [int(x) for x in input().split()]

ans = 10**9
for i in range(2**n):
  cost = 0
  point = [0]*m
  for j in range(n):
    if (i>>j)&1:
      for k in range(1, m+1):
        point[k-1] += books[j][k]
  flag = True
  for j in range(m):n, m, x = map(int, input().split())
books = [0]*n
for i in range(n):
  books[i] = [int(x) for x in input().split()]

ans = 10**9
for i in range(2**n):
  cost = 0
  point = [0]*m
  for j in range(n):
    if (i>>j)&1:
      cost += books[j][0]
      for k in range(1, m+1):
        point[k-1] += books[j][k]
  flag = True
  for j in range(m):
    if point[j] < x:
      flag = False
  if flag and ans > cost:
    ans = cost

print(ans if ans != 10**9 else -1)
    if point[j] < x:
      flag = False
  if flag and ans > cost:
    ans = cost

print(ans if ans != 10**9 else -1)
Problem p02713 (python)

Fixed submission:
from math import gcd
k = int(input())
ans = 0
for i in range(1, k+1):
  for j in range(1, k+1):
    key = gcd(i, j)
    for n in range(1, k+1):
      ans += gcd(key, n)
print(ans)

Buggy submission (verdict: Runtime Error):
k = int(input())
ans = 0
for i in range(1, k+1):
  for j in range(1, k+1):
    key = gcd(i, j)
    for n in range(1, k+1):
      ans += gcd(key, n)
print(ans)
Problem p02761 (python)

Fixed submission:
import sys

n, m = map(int, input().split())
key = [-1 for i in range(n)]
for i in range(m):
  s, c = map(int, input().split())
  if key[s-1] == -1:
    key[s-1] = c
  else:
    if key[s-1] == c:
      continue
    else:
      print(-1)
      sys.exit()

for i in range(n):
  if key[i] == -1:
    if i != 0:
      key[i] = 0
    elif n == 1:
      key[i] = 0
    else:
      key[i] = 1
  key[i] = str(key[i])

ans = int("".join(key))
if 10**(n-1) <= ans < 10**n:
  print(ans)
elif n == 1 and ans == 0:
  print(0)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
ans = 10**(n-1)

judge = [0]*m
for i in range(m):
  judge[i] = [int(x) for x in input().split()]

flag = False
whlie ans < 10**n:
  ans = str(ans)
  for i in range(m):
    if ans[judge[i][0]-1] != judge[i][1]:
      break
    if i == m-1:
      print(int(ans))
      flag = True
      break
  if flag:
    break
  ans = int(ans)+1

if ans == 10**n:
  print(-1)

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

num = [str(x) for x in range(10**(n-1), 10**n)]
judge = [True]*len(num)

for i in range(m):
  s, c = map(int, input().split())
  for j in range(len(num)):
    if num[j][s] != c:
      judge[j] = False
      
ans = -1
for i in range(len(num)):
  if judge[i] == True:
    ans = num[i]
    break

print(ans)
Problem p02768 (python)

Fixed submission:
n, a, b = map(int, input().split())
mod = 10**9+7
def comb(n, r, mod):
    if r == 0 or r == n:
        return 1
    r = min([r, n-r])
    x, y = 1, 1
    for i in range(1, r+1):
        x *= n+1-i
        x %= mod
        y *= i
        y %= mod
    return x*pow(y, mod-2, mod)%mod

ans = (pow(2, n, mod)+3*mod-1-comb(n, a, mod)-comb(n, b, mod))%mod
print(ans)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
mod = 10**9+7

def nCr(n, r):
    r = min(r, n - r)
    if r == 0: return 1;
    if r == 1: return n;
    numerator = [n - r + i + 1 for i in range(r)]
    denominator  = [i + 1 for i in range(r)]
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1: 
            result *= numerator[k]
            result %= mod
    return int(result)

ans = (pow(2, n, mod)-1-(mod-nCr(n, a))-(mod_nCr(n, b)))%mod
print(ans)
Problem p02806 (python)

Fixed submission:
n = int(input())
s = [0]*n
t = [0]*n
for i in range(n):
    a, b = map(str, input().split())
    b = int(b)
    s[i], t[i] = a, b
k = input()

for i in range(n):
    if s[i] == k:
        key = i+1
        
ans = sum(t[key:])
print(ans)

Buggy submission (verdict: Runtime Error):

n = int(input())
x = [int(x) for x in input().split()]
inf = 10**9+7
a = 1
for i in range(n-1, 0, -1):
    a *= i
    a %= inf
key = 0
ans = 0
for i in range(n-1):
    key += a//(i+1)
    key %= inf
    ans += key*(x[i+1]-x[i])
    ans %= inf
    

print(ans)
Problem p02821 (python)

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


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    
    l, r = -1, 10**6
    while r-l > 1:
        k = (r+l)//2
        count = 0
        for i in range(n):
            count += n-bisect.bisect_left(a, k-a[i])
        
        if count > m:
            l = k
        else:
            r = k
    ans = 0
    count = 0
    b = [0]*(n+1)
    for i in range(n):
        b[i+1] += b[i]+a[i]
    for i in range(n):
        index = bisect.bisect_left(a, r-a[i])
        ans += b[n]-b[index]+a[i]*(n-index)
        count += n-index
    
    if count < m:
        ans += (m-count)*l
    
    print(ans)
    
    
    
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import heapq

n, m = map(int, input().split())
a = [int(x) for x in input().split()]
a = list(set(a))
a.sort(reverse=True)
key = []
judge = [[False]*n for i in range(n)]

heapq.heappush(key, [-(a[0]+a[0]), 0, 0])
judge[0][0] = True

ans = 0
for i in range(m):
    p = heapq.heappop(key)
    p1, p2, p3 = p[0], p[1], p[2]
    ans += (-p1)
    if p2 < n-1 and judge[p2+1][p3] == False:
        heapq.heappush(key, [-(a[p2+1]+a[p3]), p2+1, p3])
        judge[p2+1][p3] = True
    if p3 < n-1 and judge[p2][p3+1] == False:
        heapq.heappush(key, [-(a[p2]+a[p3+1]), p2, p3+1])
        judge[p2][p3+1] = True

print(ans)
Problem p02838 (python)

Fixed submission:
import numpy as np

n = int(input())
a = np.array([int(x) for x in input().split()])
inf = 10**9+7

ans = 0
p = 1
for i in range(61):
    a, b = a//2, a%2
    key = int(b.sum())
    ans += p*(n-key)*key
    ans = ans%inf
    p *= 2
    p %= inf
print(ans)

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

n = int(input())
a = [int(x) for x in input().split()]
a.sort()

inf = pow(10, 9)+7
key = max(a)

k = 1
while key > 1:
  k += 1
  key //= 2
sub = [0]*k

ans = 0
for i in range(n):
  value = a[i]
  value_bin = [0]*k
  q = 0
  p = 0
  while value > 0:
    if value%2 == 1:
      value_bin[p] += 1
    p += 1
    value //= 2
  if p > q:
    q = p
  if i == 0:
    for j in range(q):
      if value_bin[p] == 1:
        sub[p] = 1
  r = 1
  for j in range(q):
    if value_bin[j] == 1:
      ans += (r*(i-sub[j]))%inf
      sub[j] += 1
    else:
      ans += (r*sub[j])%inf
    r *= 2
    ans %= inf

print(ans)
Problem p02842 (python)

Fixed submission:
import sys
n = int(input())
for i in range(1, n+1):
    if n*100 <= i*108 <(n+1)*100:
        print(i)
        sys.exit()
print(":(")

Buggy submission (verdict: Runtime Error):
import sys
n = int(input())
for i in range(n):
    if n <= i*1.08 <n+1:
        print(i)
        sys.exit()
print(:()
Problem p02843 (python)

Fixed submission:
import sys
x = int(input())
for i in range(1000):
    if 100*i <= x <= 105*i:
        print(1)
        sys.exit()
print(0)

Buggy submission (verdict: Runtime Error):
x = int(input())
key = [True] + [False]*99 + [True]*6 + [0]*(x+1)
def dp(x):
    if x <= 105:
        return key[x]
    if key[x] == 0:
        key[x] = any([dp(x-100), dp(x-101), dp(x-102), dp(x-103), dp(x-104), dp(x-105)])
    return key[x]
if dp(x):
    print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
x = int(input())
key = [True] + [False]*99 + [True]*6 + [0]*(x+1)
def dp(x):
    if key[x] == 0:
        key[x] = any([dp(x-100), dp(x-101), dp(x-102), dp(x-103), dp(x-104), dp(x-105)])
    return key[x]
if dp(x):
    print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
x = int(input())
key = [0]*(x+1)
def dp(x):
    if x == 0:
        key[x] = 0
        return True
    if x < 100:
        key[x] = False
        return False
    if key[x] == 0:
        key[x] = any([dp(x-100), dp(x-101), dp(x-102), dp(x-103), dp(x-104), dp(x-105)])
        return key[x]
if dp(x):
    print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
x = int(input())
def dp(x):
    if x == 0:
        return True
    if x < 100:
        return False
    return any([dp(x-100), dp(x-101), dp(x-102), dp(x-103), dp(x-104), dp(x-105)])

if dp(x):
    print(1)
else:
    print(0)
Problem p02848 (python)

Fixed submission:
n = int(input())
s = input()
alphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]

ans = [0]*len(s)
for i in range(len(s)):
    S = s[i]
    key = (alphabet.index(S))
    ans[i] = alphabet[(key+n)%26]
print("".join(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
alphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]*2

ans = [0]*n
for i in range(s):
    S = s[i]
    key = alphabet.index(S)
    ans[i] = alphabet[key+n]
print("".join(ans))
Problem p02850 (python)

Fixed submission:
from collections import deque
import sys

def main():
    input = sys.stdin.readline
    n = int(input())
    
    node = [0]*(n-1)
    next_node = [[] for _ in range(n)]
    for i in range(n-1):
        a, b = map(int, input().split())
        node[i] = (a-1, b-1)
        next_node[a-1].append(b-1)
        next_node[b-1].append(a-1)
    
    ans = 0
    for i in range(n):
        if ans < len(next_node[i]):
            ans = len(next_node[i])
    print(ans)
    
    not_yet = deque([])
    already = [False]*n
    parent = [0]*n
    ans_list = dict()
    k = 1
    
    already[0] = True
    for value in next_node[0]:
        not_yet.append(value)
        ans_list[(0, value)] = k
        parent[value] = k
        already[value] = True
        k += 1
    
    
    while not_yet:
        k = 1
        key = not_yet.popleft()
        for value in next_node[key]:
            if already[value]:
                continue
            already[value] = True
            not_yet.append(value)
            if k == parent[key]:
                k += 1
            parent[value] = k
            p, q = min([key, value]), max([key, value])
            ans_list[(p, q)] = k
            k += 1
            
    
    for value in node:
        print(ans_list[value])


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
n = int(input())
tree = [0]*n
input_list = [0]*n

for i in range(n-1):
    a, b = map(int, input().split())
    input_list[i] = [a, b]
    tree[a-1] = tree[a-1] + 1
    tree[b-1] = tree[b-1] + 1

ans = max(tree)
print(ans)

key = [int(i) for i in range(1, ans+1)]
keyofkey = [[] for i in range(n)]
key = set(key)

for i in range(n-1):
    a, b = input_list[i][0], input_list[i][1]
    key_list = list(key - (set(keyofkey[a-1]) | set(keyofkey[b-1])))
    p = key_list[0]
    keyofkey[a-1].append(p)
    keyofkey[b-1].append(p)
    print(p)

Buggy submission (verdict: Runtime Error):
import heapq
n = int(input())
tree = [0]*n
input_list = [0]*n
 
for i in range(n-1):
    a, b = map(int, input().split())
    input_list[i] = [a, b]
    tree[a-1] = tree[a-1] + 1
    tree[b-1] = tree[b-1] + 1

ans = max(tree)
print(ans)

keyofkey = [[int(i) for i in range(1, ans+1)] for i in range(n)]

for i in range(n-1):
    a, b = input_list[i][0], input_list[i][1]
    key_list = list(set(keyofkey[a-1]) & set(keyofkey[b-1]))
    p = key_list[0]
    keyofkey[a-1].remove(p)
    keyofkey[b-1].remove(p)
    print(p)
Problem p02852 (python)

Fixed submission:
import sys
import heapq

def main():
  input = sys.stdin.readline
  n, m = map(int, input().split())
  s = input()
  
  inf = pow(10, 6)
  ans = [inf]*(n+1)
  key = []
  heapq.heapify(key)
  heapq.heappush(key, (0, n))
  ans[n] = 0
  index = n-1
  count = 0
  while key:
    sub = heapq.heappop(key)
    s1, s2 = sub[0], sub[1]
    if s1 < count:
      continue
    count = s1+1
    subindex = index
    for i in range(min([index, s2-1]), max([-1, s2-m-1]), -1):
      if ans[i] != inf:
        continue
      if s[i] == "1":
        continue
      heapq.heappush(key, (count, i))
      ans[i] = s2
      subindex = i
    index = subindex
      
  if ans[0] == inf:
    print(-1)
  else:
    index = 0
    answer = []
    while True:
      subindex = ans[index]
      answer.append(subindex-index)
      if subindex == n:
        break
      index = subindex
  
    print(*answer)
  
if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
import sys
import heapq

def main():
  input = sys.stdin.readline
  n, m = map(int, input().split())
  s = input()
  
  inf = pow(10, 6)
  ans = [inf]*(n+1)
  key = []
  heapq.heapify(key)
  heapq.heappush(key, (0, n))
  ans[n] = 0
  index = n-1
  count = 0
  while key:
    sub = heapq.heappop(key)
    s1, s2 = sub[0], sub[1]
    if s1 < count:
      continue
    count = s1+1
    for i in range(min([index, s2-1]), max([-1, s2-m-1]), -1):
      if ans[i] != inf:
        continue
      if s[i] == "1":
        continue
      heapq.heappush(key, (count, i))
      ans[i] = s2
      subindex = i
    index = subindex
      
  
  if ans[0] == inf:
    print(-1)
  else:
    index = 0
    answer = []
    while True:
      subindex = ans[index]
      answer.append(subindex-index)
      if subindex == n:
        break
      index = subindex
  
    print(*answer)
  
if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
import sys
import heapq

def main():
  input = sys.stdin.readline
  n, m = map(int, input().split())
  s = input()
  
  inf = pow(10, 6)
  ans = [inf]*(n+1)
  key = []
  heapq.heapify(key)
  heapq.heappush(key, (0, n))
  ans[n] = 0
  index = n-1
  count = 0
  while key:
    sub = heapq.heappop(key)
    s1, s2 = sub[0], sub[1]
    if s1 < count:
      continue
    count = s1+1
    for i in range(min([index, s2-1]), max([-1, s2-m-1]), -1):
      if ans[i] != inf:
        continue
      if s[i] == "1":
        continue
      heapq.heappush(key, (s1+1, i))
      ans[i] = s2
      subindex = i
    index = subindex
      
  
  if ans[0] == inf:
    print(-1)
  else:
    index = 0
    answer = []
    while True:
      subindex = ans[index]
      answer.append(subindex-index)
      if subindex == n:
        break
      index = subindex
  
    print(*answer)
  
if __name__ == "__main__":
  main()
Problem p02899 (python)

Fixed submission:
n = int(input())
a = list([int(x), int(y)+1] for x, y in zip(input().split(), range(n)))
a.sort()
for i in range(n):
    print(a[i][1], end=" ")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list([int(x), int(y)+1] for x, y in zip(input()split(), range(n)))
a.sort()
for i in range(n):
    print(a[i], end=" ")
Problem p02900 (python)

Fixed submission:
a, b = map(int, input().split())
def gcd(p, q):
    if p < q:
        p, q = q, p
    while q > 0:
        p, q = q, p%q
    return p

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

divisors = make_divisors(gcd(a, b))
ans = []
while divisors:
    key = divisors[0]
    ans.append(key)
    divisors.remove(key)
    notans = []
    for value in divisors:
        if gcd(key, value) != 1:
            notans.append(value)
    for i in notans:
        divisors.remove(i)
            
print(len(ans))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
def gcd(p, q):
    if p < q:
        p, q = q, p
    while q > 0:
        p, q = q, p%q
    return p
  
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

divisors = make_divisors(gcd(a, b))

def prime(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for j in range(4, n+1, 2):
        is_prime[j] = False
    for i in range(3, int(n**0.5) + 1, 2):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

prime = [1] + prime(divisors[-1])
ans = set(divisors) & set(prime)
print(len(ans))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
def gcd(p, q):
    if p < q:
        p, q = q, p
    while q > 0:
        p, q = q, p%q
    return p
  
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

divisors = make_divisors(gcd(a, b))

def prime(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for j in range(4, n+1, 2):
        is_prime[j] = False
    for i in range(3, int(n**0.5) + 1, 2):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

prime = [1] + prime(divisors[-1])
print(divisors, prime)
ans = set(divisors) & set(prime)
print(ans)
print(len(ans))