ZhenlongDai/ACPR huggingface dataset:
Problem: p03967
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
ans = 0
for i in range(len(S)):
  if i%2 == 0 and S[i] == "g":
    ans += 1
  elif i%2 == 1 and S[i] == "p":
    ans -= 1
print(ans)

Failing test case input:
gpg

Expected output:
0

Actual output:
1


Fixed submission (verdict: Accepted):
S = input()
ans = 0
for i in range(len(S)):
  if i%2 == 0 and S[i] == "p":
    ans -= 1
  elif i%2 == 1 and S[i] == "g":
    ans += 1
print(ans)

Problem: p03967
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
print(s)

Failing test case input:
gpg

Expected output:
0

Actual output:
gpg


Fixed submission (verdict: Accepted):
s=input()
print(len(s)

Problem: p03967
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
dif=0
for i in range(len(s)):
    if s[i]=='g':
        dif+=1
    else:
        dif-=1
print(dif/2)


Failing test case input:
gpg

Expected output:
0

Actual output:
0.5


Fixed submission (verdict: Accepted):
s=input()
dif=0
for i in range(len(s)):
    if s[i]=='g':
        dif+=1
    else:
        dif-=1
print(dif

Problem: p03967
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
g_cnt, p_cnt = 0, 0
ans = 0
for si in s:
    if si == "g":
        if p_cnt < g_cnt:
            p_cnt += 1
            ans += 1
        else:
            g_cnt += 1
            ans -= 1
    else:
        g_cnt += 1
        ans += 1
print(ans)


Failing test case input:
gpg

Expected output:
0

Actual output:
1


Fixed submission (verdict: Accepted):
s = input()
g_cnt, p_cnt = 0, 0
ans = 0
for si in s:
    if si == "g":
        if p_cnt < g_cnt:
            p_cnt += 1
            ans += 1
        else:
            g_cnt += 1
    else:
        if p_cnt < g_cnt:
            p_cnt += 1
        else:
            g_cnt += 1
            ans -= 1
print(ans)

Problem: p03967
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s=input()
ans=0
for index,i in enumerate(s):
  if index%2==1:
    if i=="p":
      ans-=1
  else:
    if i=="g":
      ans+=1
print(ans)

Failing test case input:
gpg

Expected output:
0

Actual output:
1


Fixed submission (verdict: Accepted):
s=input()
ans=0
for index,i in enumerate(s):
  if index%2==0:
    if i=="p":
      ans-=1
  else:
    if i=="g":
      ans+=1
print(ans)

Problem: p03967
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()

ans = 0
for i, x in enumerate(s):
    if i % 2 == 1 and x == 'p':
        ans -= 1
    elif i % 2 == 0 and x == 'g':
        ans += 1

print(ans)

Failing test case input:
gpg

Expected output:
0

Actual output:
1


Fixed submission (verdict: Accepted):
s = input()

ans = 0
for i, x in enumerate(s):
    if i % 2 == 0 and x == 'p':
        ans -= 1
    elif i % 2 == 1 and x == 'g':
        ans += 1

print(ans)
Problem: p03967
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
cnt=0
for i in range(len(s)):
    if i%2==0 and s[i]=='g':
        cnt+=1
    elif i%2==0 and s[i]=='p':
        pass
    elif i%2==1 and s[i]=='g':
        pass
    else:
        cnt-=1
print(cnt)


Failing test case input:
gpg

Expected output:
0

Actual output:
1


Fixed submission (verdict: Accepted):
s=input()
cnt=0
for i in range(len(s)):
    if i%2==1 and s[i]=='g':
        cnt+=1
    elif i%2==1 and s[i]=='p':
        pass
    elif i%2==0 and s[i]=='g':
        pass
    else:
        cnt-=1
print(cnt)
Problem: p02305
Buggy submission (Python3, verdict: Wrong Answer):
import math

c1x,c1y,c1r = [int(i) for i in input().split()]
c2x,c2y,c2r = [int(i) for i in input().split()]

d = math.sqrt(pow(c1x-c2x, 2) +  pow(c1y-c2y, 2))

if d > c1r + c2r:
    print(4)
elif d == c1r + c2r:
    print(3)
elif d + c1r > c2r or d + c2r > c1r:
    print(2)
elif d + c1r == c2r or d + c2r == c1r:
    print(1)
else:
    print(0)



Failing test case input:
1 2 0
0 2 2

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):
import math

c1x,c1y,c1r = [int(i) for i in input().split()]
c2x,c2y,c2r = [int(i) for i in input().split()]

d = math.sqrt(pow(c1x-c2x, 2) +  pow(c1y-c2y, 2))

s = c1r + c2r

if d > s:
    print(4)
elif d == s:
    print(3)
else:
    if c1r > c2r:
        if d + c2r > c1r:
            print(2)
        elif d + c2r == c1r:
            print(1)
        else:
            print(0)
    else:
        if d + c1r > c2r:
            print(2)
        elif d + c1r == c2r:
            print(1)
        else:
            print(0)
Problem: p03464
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
K = int(input())
A = [int(i) for i in input().split()]

def solve() :
    if A[-1] != 2 :
        return [-1]
    for i in range(K - 1) :
        if A[i] >= 2 * A[i+1] :
            return [-1]
            
    cM = 2
    for a in A[::-1] :
        nM = cM 
        cM = nM
    
    return [cM - cM % A[0], cM]
    
print(*solve())

Failing test case input:
4
3 4 3 2

Expected output:
6 8

Actual output:
0 2


Fixed submission (verdict: Accepted):
K = int(input())
A = [int(i) for i in input().split()]

def solve() :            
    m, M = 2, 2
    for a in A[::-1] :
        if (m - 1) 
            return [-1]
            
        M = M 
        x = (m + a - 1) 
        m = a * x
        
    return [m, M]
    
print(*solve())

Problem: p03464
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))[::-1]
mn,mx=2,2
for j in a:
  mn=(mn+j-1)
  mx=mx
  if mx==0:
    print(-1)
    exit()
print(mn,mx)

Failing test case input:
5
2 32 100 7 4

Expected output:
-1


Actual output:
142 2


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))[::-1]
if a[0]!=2:
  print(-1)
  exit()
mn,mx=2,2
for j in a:
  if (mn+j-1)
    print(-1)
    exit()
  mn=(mn+j-1)
  mx=mx
print(mn,mx)

Problem: p03464
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

K = int(input())
L = list(map(int, input().split()))

ma = 2
mi = 2
L = reversed(L)

for l in L:
    if l > ma:
        print(-1)
        exit()
    else:
        mi = ma
        ma = mi+l-1
print(mi, ma)


Failing test case input:
4
3 3 2 2

Expected output:
3 5


Actual output:
6 8


Fixed submission (verdict: Accepted):
from math import ceil

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

K = int(input())
L = list(map(int, input().split()))

maxr = 2
minr = 2
r = 0
for n in reversed(L):
    
    if ceil(maxr
        
        
        minr = ceil(minr/n)*n
        maxr = (maxr)
    else:
        n = -1
        break

if n == -1:
    print(n)
else:
    print(int(minr), maxr)

Problem: p03464
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
K = int(input())
A = [int(i) for i in input().split()]

def solve() :
    for i in range(K - 1) :
        if A[i] >= 2 * A[i+1] :
            return [-1]
            
    cM = 2
    for a in A[::-1] :
        nM = cM 
        cM = nM
    
    return [cM - cM % A[0], cM]
    
print(*solve())

Failing test case input:
10
2 3 2 2 2 2 2 2 2 2

Expected output:
4 5


Actual output:
2 2


Fixed submission (verdict: Accepted):
K = int(input())
A = [int(i) for i in input().split()]

def solve() :            
    m, M = 2, 2
    for a in A[::-1] :
        if (m - 1) 
            return [-1]
            
        M = M 
        x = (m + a - 1) 
        m = a * x
        
    return [m, M]
    
print(*solve())
Problem: p03464
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))[::-1]
if a[0]!=2:
  print(-1)
  exit()
mn,mx=2,2
for j in a:
  mn=(mn+j-1)
  mx=mx
  if mx==0:
    print(-1)
    exit()
print(mn,mx)

Failing test case input:
5
3 47 110 9 2

Expected output:
-1


Actual output:
168 2


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))[::-1]
if a[0]!=2:
  print(-1)
  exit()
mn,mx=2,2
for j in a:
  if (mn+j-1)
    print(-1)
    exit()
  mn=(mn+j-1)
  mx=mx
print(mn,mx)

Problem: p03464
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K=int(input())
A=input().split(' ')
min=2
max=2
flag=0
while K>0:
  K=K-1
  i=int(A[K])
  if max<i:
    print('aa1')
    flag=1
    break
  elif i<min:
    min=min+i-(min%i)
    max=max+i-(max%i)-1
  else:
    min=i
    max=max+i-(max%i)-1
if flag==0:
  print('{0} {1}'.format(min,max))

Failing test case input:
5
3 12 100 3 3

Expected output:
-1


Actual output:
aa1


Fixed submission (verdict: Accepted):
K=int(input())
A=input().split(' ')
min=2
max=2
flag=0
while K>0:
  K=K-1
  i=int(A[K])
  if max<i:
    print('-1')
    flag=1
    break
  elif i<min:
    if min%i!=0:min=min+i-(min%i)
    else:min=min+(min%i)
    max=max+i-(max%i)-1
    if min>max:
      print('-1')
      flag=1
      break
  else:
    min=i
    max=max+i-(max%i)-1
if flag==0:
  print('{0} {1}'.format(min,max))

Problem: p03464
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
K = int(input())
A = [int(i) for i in input().split()]

def solve() :
    m, M = 2, 2
    for a in A[::-1] :
        x = (2 * M - 1) 
        if a * x < M :
            return [-1]
        M = a * x
      
    return [M, M + A[0] - 1]
    
print(*solve())

Failing test case input:
5
6 7 100 1 2

Expected output:
-1


Actual output:
352710 352715


Fixed submission (verdict: Accepted):
K = int(input())
A = [int(i) for i in input().split()]

def solve() :            
    m, M = 2, 2
    for a in A[::-1] :
        if (m - 1) 
            return [-1]
            
        M = M 
        x = (m + a - 1) 
        m = a * x
        
    return [m, M]
    
print(*solve())

Problem: p03464
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

k = int(input())
a = list( map(int, input().split()))

if a[-1]!=2:
    print(-1)
    exit()

ma = 2

for i in reversed(range(k)):
    ma = ma

    if a[i] > ma:
        print(-1)
        exit()

mi = ma

print(mi,ma)




Failing test case input:
10
2 3 2 2 2 2 2 2 2 2

Expected output:
4 5


Actual output:
-1


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

k = int(input())
a = list( map(int, input().split()))

if a[-1]!=2:
    print(-1)
    exit()

ma = 2

for i in reversed(range(k)):
    ma = ma

    if a[i] > ma:
        print(-1)
        exit()

mi = 2

for i in reversed(range(k)):

    mi = -(-mi

if mi > ma:
    print(-1)
    exit()

print(mi,ma)
Problem: p03464
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
k = int(input())
A = list(map(int,input().split()))

ans = [2,2]
for a in A[::-1]:
  print(ans)
  if a > ans[1]:
    print(-1)
    exit()
  ans[1] = ans[1]
  if ans[0] <= a:
    ans[0] = a
  else:
    i = 1
    while 1:
      if i*a > ans[0]:
        ans[0] = i*a
        break
      else:
        i+= 1
print(*ans)

Failing test case input:
5
3 4 100 3 12

Expected output:
-1


Actual output:
[2, 2]
-1


Fixed submission (verdict: Accepted):
k = int(input())
A = list(map(int,input().split()))

ans = [2,2]
for a in A[::-1]:

  if a > ans[1]:
    print(-1)
    exit()
  ans[1] = (ans[1]
  if ans[0] <= a:
    ans[0] = a
  else:
    if ans[0]%a != 0:
      ans[0] = (ans[0]
  if ans[0] >ans[1]:
    print(-1)
    exit()
print(*ans)

Problem: p03464
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
a=list(reversed(list(map(int,input().split()))))
if a[0]>2:
	print("-1")
	exit()
ans=2
for i in range(1,n):
	pre=ans
	ans+=(a[i]-ans%a[i])%a[i]
	if ans-ans%a[i-1]!=pre:
		print("-1")
		exit()
print(ans,ans+a[n-1]-1)

Failing test case input:
4
3 5 3 2

Expected output:
6 11


Actual output:
6 8


Fixed submission (verdict: Accepted):
n=int(input())
a=list(reversed(list(map(int,input().split()))))
if a[0]>2:
	print("-1")
	exit()
a1,a2=2,2
for i in range(1,n):
	a1+=(a[i]-a1%a[i])%a[i]
	pre=a2
	a2+=a[i-1]-1
	a2-=a2%a[i]
	if a1>a2:
		print("-1")
		exit()	
print(a1,a2+a[n-1]-1)

Problem: p03464
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(a) for a in input().split()]

Possible = A[-1]
for i in reversed(range(N-1)):
    if Possible % A[i] == 0: Possible = A[i]
    elif A[i] - Possible % A[i] < A[i+1]:
        Possible += A[i] - Possible % A[i]
    else:
        print(-1)
        break
else:
    print(Possible, Possible + A[0] - 1)

Failing test case input:
4
3 5 3 2

Expected output:
6 11


Actual output:
6 8


Fixed submission (verdict: Accepted):
from math import ceil
N = int(input())
A = [int(a) for a in input().split()]

if A[-1] != 2: print(-1)
else:
    PossibleMin, PossibleMax = A[-1], A[-1] + 1
    for i in reversed(range(N-1)):
        PossibleMin = ceil(PossibleMin/A[i]) * A[i]
        PossibleMax = (PossibleMax
    if PossibleMax >= PossibleMin: print(PossibleMin, PossibleMax)
    else: print(-1)
Problem: p03464
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
K = int(input())
A = [int(i) for i in input().split()][::-1]

ans_low = 2
ans_high = 2

for i in range(1, K):
    if A[i]/A[i-1] >= 2:
        print(-1)
        exit()

    ans_high = math.ceil(ans_low/A[i])*A[i]+A[i]-1
    ans_low = math.ceil(ans_low/A[i])*A[i]

    

print(ans_low, ans_high)


Failing test case input:
4
3 5 3 2

Expected output:
6 11


Actual output:
6 8


Fixed submission (verdict: Accepted):
import math
K = int(input())
A = [int(i) for i in input().split()][::-1]

if A[0] != 2:
    print(-1)
    exit()

ans_low = 2
ans_high = 3

for i in range(1, K):
    next_ans_high = ((ans_high
    next_ans_low = math.ceil(ans_low/A[i])*A[i]

    if (next_ans_high 
        print(-1)
        exit()

    ans_high = next_ans_high
    ans_low = next_ans_low

    

print(ans_low, ans_high)

Problem: p03464
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
k = int(input())
A = list(map(int,input().split()))

ans = [2,2]
for a in A[::-1]:

  if a > ans[1]:
    print(-1)
    exit()
  ans[1] = ans[1]
  if ans[0] <= a:
    ans[0] = a
  else:
    i = 1
    while 1:
      if i*a > ans[0]:
        ans[0] = i*a
        break
      else:
        i+= 1
print(*ans)


Failing test case input:
4
3 4 3 2

Expected output:
6 8

Actual output:
-1


Fixed submission (verdict: Accepted):
k = int(input())
A = list(map(int,input().split()))

ans = [2,2]
for a in A[::-1]:

  if a > ans[1]:
    print(-1)
    exit()
  ans[1] = (ans[1]
  if ans[0] <= a:
    ans[0] = a
  else:
    if ans[0]%a != 0:
      ans[0] = (ans[0]
  if ans[0] >ans[1]:
    print(-1)
    exit()
print(*ans)

Problem: p03464
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))[::-1]
if a[0]!=2:
  print(-1)
  exit()
mn,mx=2,2
for i,j in enumerate(a[1:],1):
  mn=(mn+j-1)
  mx=(mx+a[i-1]-1)
  if mx==0:
    print(-1)
    exit()
print(mn,mx+a[-1]-1)

Failing test case input:
5
5 1 100 1 2

Expected output:
-1


Actual output:
105 106


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))[::-1]
if a[0]!=2:
  print(-1)
  exit()
mn,mx=2,2
for j in a:
  if (mn+j-1)
    print(-1)
    exit()
  mn=(mn+j-1)
  mx=mx
print(mn,mx)

Problem: p03464
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K=int(input())
A=input().split(' ')
min=2
max=2
flag=0
while K>0:
  K=K-1
  i=int(A[K])
  if max<i:
    print('-1')
    flag=1
    break
  else:
    min=min+i-(min%i)
    max=max+i-(max%i)-1
if flag==0:
  print('{0} {1}'.format(min,max))

Failing test case input:
4
3 3 2 2

Expected output:
3 5


Actual output:
12 5


Fixed submission (verdict: Accepted):
K=int(input())
A=input().split(' ')
min=2
max=2
flag=0
while K>0:
  K=K-1
  i=int(A[K])
  if max<i:
    print('-1')
    flag=1
    break
  elif i<min:
    if min%i!=0:min=min+i-(min%i)
    else:min=min+(min%i)
    max=max+i-(max%i)-1
    if min>max:
      print('-1')
      flag=1
      break
  else:
    min=i
    max=max+i-(max%i)-1
if flag==0:
  print('{0} {1}'.format(min,max))
Problem: p03464
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from math import ceil
k = int(input())
A = list(map(int,input().split()))[::-1]
if A[0] != 2:
    print(-1)
    exit()
flg = True
tmp = [2,3]
for i in range(1, k):
    a = A[i]
    if a>tmp[1]:
        flg = False
        break
    else:
        l = ceil(tmp[0]/a)*a
        tmp = [l, l+a-1]

if flg:
    print(*tmp)
else:
    print(-1)

Failing test case input:
4
3 5 3 2

Expected output:
6 11


Actual output:
6 8


Fixed submission (verdict: Accepted):
from math import ceil
k = int(input())
A = list(map(int,input().split()))[::-1]
if A[0]!=2:
    print(-1)
    exit()
flg = True
ans = [2,3]
for i in range(1, k):
    a = A[i]
    m = a*ceil(ans[0]/a)
    if m>ans[1]:
        flg = False
        break
    else:
        ans = [m,a*(ans[1]
if flg:
    print(*ans)
else:
    print(-1)

Problem: p03464
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from math import floor, ceil
k = int(input())
a = [int(i) for i in input().split()]
l,r = 2,2
for ai in a[::-1]:
    l = ceil(l/ai)*ai
    r = floor(r/ai) * ai + ai - 1
print(l,r)

Failing test case input:
5
2 12 111 10 7

Expected output:
-1


Actual output:
120 119


Fixed submission (verdict: Accepted):
from math import floor, ceil
k = int(input())
a = [int(i) for i in input().split()]
l,r = 2,2
for ai in a[::-1]:
    xi = ceil(l/ai)
    yi = floor(r/ai)
    if xi > yi:
        print(-1)
        exit()
    l = xi * ai
    r = yi * ai + ai - 1
print(l, r)

Problem: p03464
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
a=list(reversed(list(map(int,input().split()))))
if a[0]>2:
	print("-1")
	exit()
ans=2
for i in range(1,n):
	pre=ans
	ans+=(a[i]-ans%a[i])%a[i-1]
	if ans-ans%a[i-1]!=pre:
		print("-1")
		exit()
print(ans,ans+a[n-1]-1)

Failing test case input:
4
3 5 3 2

Expected output:
6 11


Actual output:
6 8


Fixed submission (verdict: Accepted):
n=int(input())
a=list(reversed(list(map(int,input().split()))))
if a[0]>2:
	print("-1")
	exit()
a1,a2=2,2
for i in range(1,n):
	a1+=(a[i]-a1%a[i])%a[i]
	pre=a2
	a2+=a[i-1]-1
	a2-=a2%a[i]
	if a1>a2:
		print("-1")
		exit()	
print(a1,a2+a[n-1]-1)
Problem: p03128
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int, input().split())
mt=[0,2,5,5,4,5,6,3,7,6]
a=sorted(map(int, input().split()))
dp=['']*(n+1)
dp[0]='*'
for i in range(n+1):
    if not dp[i]:continue
    for j in a:
        if i+mt[j]<n+1:
            dp[i+mt[j]]=str(j)+dp[i]
print(''.join(sorted(dp[-1][:-1])[::-1]))


Failing test case input:
43 4
3 3 8 9

Expected output:
99933333


Actual output:
98333333


Fixed submission (verdict: Accepted):
n,m=map(int, input().split())
mt=[0,2,5,5,4,5,6,3,7,6]
a=sorted(map(int, input().split()))[::-1]
dp=[-1]*(n+1)
dp[0]=0
for i in range(n+1):
    if dp[i]==-1:continue
    for j in a:
        if i+mt[j]<n+1:
            dp[i+mt[j]]=max(dp[i]*10+j,dp[i+mt[j]])
print(dp[-1])

Problem: p03128
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N,M=map(int,input().split())
l=list(map(int,input().split()))
w=[2,5,5,4,5,6,3,7,6]
dp=[0]*(N+1)
for i in range(N):
   for j in l:
      if w[j-1]+i<=N:
         dp[i+w[j-1]]=max(dp[i+w[j-1]],dp[i]*10+j)
print(dp[N])

Failing test case input:
23 6
4 2 6

Expected output:
64442


Actual output:
64444


Fixed submission (verdict: Accepted):
N,M=map(int,input().split())
l=list(map(int,input().split()))
w=[2,5,5,4,5,6,3,7,6]
l.sort()
dp=[0]*(max(N+1,8))
for j in l:
   dp[w[j-1]]=j
for i in range(N):
   if dp[i]!=0:
      for j in l:
         if w[j-1]+i<=N:
            dp[i+w[j-1]]=max(dp[i+w[j-1]],dp[i]*10+j)
print(dp[N])

Problem: p03128
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [0]*(N+1)  
for i in range(N+1):
    for j in A:
        if i + B[j] <= N:
            dp[i+B[j]]= max(dp[i]*10+j, dp[i+B[j]])
print(dp[N])

Failing test case input:
23 10
1 3 5

Expected output:
5111111111


Actual output:
11111111111


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [-1]*(N+1)
dp[0]=0  
for i in range(N+1):
    for j in A:
        if i + B[j] <= N:
            dp[i+B[j]]= max(dp[i]*10+j, dp[i+B[j]])
print(dp[N])

Problem: p03128
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[0,2,5,5,4,5,6,3,7,6]
wv=[]
for i in a:
  wv.append((b[i],i))
wv.sort()
dp=[-1 for i in range(n+1)]
dp[0]=0
for w,v in wv:
  for i in range(w,max(w,n+1)):
    if dp[i-w]==-1:
      continue
    dp[i]=max(dp[i],dp[i-w]*10+v)
print(dp[n])

Failing test case input:
13 2
7 1 1

Expected output:
711111


Actual output:
111117


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[0,2,5,5,4,5,6,3,7,6]
wv=[]
for i in a:
  wv.append((b[i],i))
wv.sort()
dp=[-1 for i in range(n+1)]
dp[0]=0
for i in range(1,n+1):
  for w,v in wv:
    if i-w<0:
      continue
    if dp[i-w]==-1:
      continue
    dp[i]=max(dp[i],dp[i-w]*10+v)
print(dp[n])
Problem: p03128
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int,input().split())
l=list(map(int,input().split()))
x=[0,2,5,5,4,5,6,3,7,6]
d=dict()
for j in l:
    d[x[j]]=j
INF=float('inf')
dp=[-INF for i in range(n+1)]
dp[0]=0
for i in range(2,n+1):
    for j in d.keys():
        if j<=i:
            dp[i]=max(dp[i],dp[i-j]*10+d[j])
print(dp[n])

Failing test case input:
5 7
5 3 6

Expected output:
5


Actual output:
3


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
x=[0,2,5,5,4,5,6,3,7,6]
d=dict()
for j in l:
    d[x[j]]=j
INF=float('inf')
dp=[-INF for i in range(n+1)]
dp[0]=0
l=d.keys()
for i in range(2,n+1):
    for j in d.keys():
        if j<=i:
            dp[i]=max(dp[i],dp[i-j]*10+d[j])
print(dp[n])

Problem: p03128
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int,input().split())
a=list(map(int,input().split()))
dp=[0]*(n+1)
ans=[0]*(n+1)
num=[0,2,5,5,4,5,6,3,7,6]
INF=10**18
for i in range(1,n+1):
  stack=[]
  for j in a:
    if i-num[j]>=0:
      stack.append(dp[i-num[j]])
    else:
      stack.append(-INF)
  dp[i]=max(stack)+1
  if dp[i]>0:
    ans[i] += ans[i-num[stack.index(max(stack))]]+num[stack.index(max(stack))]*10**(dp[i]-1)
print(ans[n])

Failing test case input:
20 4
6 4 8 5

Expected output:
44444


Actual output:
20000


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
a.reverse()
dp=[0]*(n+1)
ans=[0]*(n+1)
num=[0,2,5,5,4,5,6,3,7,6]
INF=10**18
for i in range(1,n+1):
  stack=[]
  chance=[]
  for j in a:
    if i-num[j]>=0:
      stack.append(dp[i-num[j]])
      chance.append([dp[i-num[j]],ans[i-num[j]]])
    else:
      stack.append(-INF)
      chance.append([-1,-1])
  dp[i]=max(stack)+1
  if dp[i]>0:
    for v in range(len(stack)):
      if stack[v]==max(stack):
        ans[i] += chance[v][1]+a[v]*10**(dp[i]-1)
        break
print(ans[n])

Problem: p03128
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
INF = 10**10
arr = [10,2,5,5,4,5,6,3,7,6]
N,M = map(int,input().split())
src = sorted(list(map(int,input().split())))

dp = [-INF]*(N+1)
dp[0] = 0
for i in range(N):
    for j in src:
        if i + arr[j] <= N:
            dp[i+arr[j]] = max(dp[i+arr[j]],dp[i] + 1)
dim = dp[N]
ans  = '0'

print(ans)

Failing test case input:
10 2
7 1 1

Expected output:
11111


Actual output:
0


Fixed submission (verdict: Accepted):
INF = 10**10
arr = [INF,2,5,5,4,5,6,3,7,6]
N,M = map(int,input().split())
src = sorted(list(map(int,input().split())))

dp = [-INF]*(N+1)
dp[0] = 0
for i in range(N):
    for j in src:
        if i + arr[j] <= N:
            dp[i+arr[j]] = max(dp[i+arr[j]],dp[i] + 1)
dim = dp[N]
ans  = ''
while(dim > 0):
    for i in src[::-1]:
        if N >= arr[i] and dp[N-arr[i]] + 1 == dp[N]:
            ans += str(i)
            N -= arr[i]
            dim -= 1
            break
print(ans)
Problem: p03128
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m = map(int,input().split())
A = list(map(int,input().split()))

su = [0,2,5,5,4,5,6,3,7,6]

dp = [0]*(n+1)

for i in range(1,n+1):
  for j in A:
    if i >= su[j]:
      dp[i] = max(dp[i],dp[i-su[j]]*10+j)
      
print(dp[-1])
  





Failing test case input:
4 7
4 4 7

Expected output:
4


Actual output:
7


Fixed submission (verdict: Accepted):
n,m = map(int,input().split())
A = list(map(int,input().split()))

su = [0,2,5,5,4,5,6,3,7,6]

dp = [-1]*(n+1)
dp[0] = 0

for i in range(1,n+1):
  for j in A:
    if i >= su[j]:
      dp[i] = max(dp[i],dp[i-su[j]]*10+j)
      
print(dp[-1])

Problem: p03128
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())
A = [int(a) for a in input().split()]
L = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
A.sort(reverse = True)
print(A)
dp = [0] + ([-1]*N)
print(dp)
for i in range(1, N+1):
    for a in A:
        if L[a] <= i:
            dp[i] = max(dp[i], dp[i-L[a]] * 10 + a)
print(dp)
print(dp[-1])

Failing test case input:
8 18
1 5 5

Expected output:
1111


Actual output:
[5, 5, 1]
[0, -1, -1, -1, -1, -1, -1, -1, -1]
[0, -1, 1, -1, 11, 5, 111, 51, 1111]
1111


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
A = [int(a) for a in input().split()]
L = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
A.sort(reverse = True)

dp = [0] + ([-1]*N)

for i in range(1, N+1):
    for a in A:
        if L[a] <= i:
            dp[i] = max(dp[i], dp[i-L[a]] * 10 + a)

print(dp[-1])

Problem: p03128
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
costs = [2, 5, 5, 4, 5, 6, 3, 7, 6]


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    dp = [-1 for _ in range(N + 1)]
    dp[0] = 0
    for i in range(1, N + 1):
        for a in A:
            if i < costs[a - 1]:
                continue
            dp[i] = max(dp[i], dp[i - costs[a - 1]] * 10 + a)
    print(dp)


main()


Failing test case input:
32 7
1 3 2

Expected output:
1111111111111111


Actual output:
[0, -1, 1, -1, 11, 3, 111, 31, 1111, 311, 11111, 3111, 111111, 31111, 1111111, 311111, 11111111, 3111111, 111111111, 31111111, 1111111111, 311111111, 11111111111, 3111111111, 111111111111, 31111111111, 1111111111111, 311111111111, 11111111111111, 3111111111111, 111111111111111, 31111111111111, 1111111111111111]


Fixed submission (verdict: Accepted):
costs = [2, 5, 5, 4, 5, 6, 3, 7, 6]


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    dp = [-1 for _ in range(N + 1)]
    dp[0] = 0
    for i in range(1, N + 1):
        for a in A:
            if i < costs[a - 1]:
                continue
            dp[i] = max(dp[i], dp[i - costs[a - 1]] * 10 + a)
    print(dp[N])


main()
Problem: p03128
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
NUM = (None, 2, 5, 5, 4, 5, 6, 3, 7, 6)

nSticks, n = map(int, input().split())
a = list(map(int, input().split()))


dp = [0] * (nSticks + 1)
for digit in a:
    if NUM[digit] <= nSticks:
        dp[NUM[digit]] = digit
for sticks in range(2, nSticks + 1):
    for digit in a:
        if sticks - NUM[digit] >= 0 and dp[sticks - NUM[digit]] > 0:
            dp[sticks] = max(dp[sticks], dp[sticks - NUM[digit]] * 10 + digit)
print(dp[-1])



Failing test case input:
5 7
5 3 6

Expected output:
5


Actual output:
3


Fixed submission (verdict: Accepted):
NUM = (None, 2, 5, 5, 4, 5, 6, 3, 7, 6)

nSticks, n = map(int, input().split())
a = list(map(int, input().split()))


dp = [0] * (nSticks + 1)
for digit in a:
    if NUM[digit] <= nSticks:
        dp[NUM[digit]] = max(dp[NUM[digit]], digit)
for sticks in range(2, nSticks + 1):
    for digit in a:
        if sticks - NUM[digit] >= 0 and dp[sticks - NUM[digit]] > 0:
            dp[sticks] = max(dp[sticks], dp[sticks - NUM[digit]] * 10 + digit)
print(dp[-1])

Problem: p03128
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int, input().split())
mt=[0,2,5,5,4,5,6,3,7,6]
a=sorted(map(int, input().split()))
dp=['']*(n+1)
dp[0]='*'
for i in range(n+1):
    if not dp[i]:continue
    for j in a:
        if i+mt[j]<n+1:
            dp[i+mt[j]]=dp[i]+str(j)
print(dp[-1][1:])

Failing test case input:
23 1
4 3 6

Expected output:
64443


Actual output:
63444


Fixed submission (verdict: Accepted):
n,m=map(int, input().split())
mt=[0,2,5,5,4,5,6,3,7,6]
a=sorted(map(int, input().split()))[::-1]
dp=[-1]*(n+1)
dp[0]=0
for i in range(n+1):
    if dp[i]==-1:continue
    for j in a:
        if i+mt[j]<n+1:
            dp[i+mt[j]]=max(dp[i]*10+j,dp[i+mt[j]])
print(dp[-1])

Problem: p03128
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
a = list(map(int, input().split()))

maxnum = [-1] * (n+1)
cost = [0,2,5,5,4,5,6,3,7,6]
maxnum[0] = 0
for i in range(n+1):
    for num in a:
        if ( i+cost[num] < n+1 ):
            maxnum[i+cost[num]] = max(maxnum[i+cost[num]], num + maxnum[i]*10)

print(maxnum)

Failing test case input:
28 7
4 3 5

Expected output:
4444444


Actual output:
[0, -1, -1, -1, 4, 5, -1, -1, 44, 54, 55, -1, 444, 544, 554, 555, 4444, 5444, 5544, 5554, 44444, 54444, 55444, 55544, 444444, 544444, 554444, 555444, 4444444]


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
a = list(map(int, input().split()))

maxnum = [-1] * (n+1)
cost = [0,2,5,5,4,5,6,3,7,6]
maxnum[0] = 0
for i in range(n+1):
    for num in a:
        if ( i+cost[num] < n+1 ):
            maxnum[i+cost[num]] = max(maxnum[i+cost[num]], num + maxnum[i]*10)

print(maxnum[n])
Problem: p03128
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    C = [2, 5, 5, 4, 5, 6, 3, 7, 6]
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    dp = [0] * (N + 1)
    K = {a: C[a - 1] for a in A}
    for i in range(1, min(K)):
        dp[i] = -1

    for i in range(min(K), N + 1):
        try:
            dp[i] = max(dp[i - v] * 10 + k for k, v in K.items() if i - v >= 0 and dp[i - v] >= 0)
        except ValueError:
            dp[i] = -1
    print(dp[N])
main()


Failing test case input:
23 2
7 4 9

Expected output:
7777744


Actual output:
4777774


Fixed submission (verdict: Accepted):
def main():
    C = [2, 5, 5, 4, 5, 6, 3, 7, 6]
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    dp = [0] + [-1] * N
    K = {a: C[a - 1] for a in A}

    for i in range(min(K.values()), N + 1):
        try:
            dp[i] = max(dp[i - v] * 10 + k for k, v in K.items() if i - v >= 0 and dp[i - v] >= 0)
        except ValueError:
            dp[i] = -1
    print(dp[N])
main()

Problem: p03128
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n, m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

dp = [(0, 0)] * (n+1)
ma = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

for i in range(n):
    for j in a:
        t = dp[i]
        k = i + ma[j]
        if k <= n:
            dp[k] = max(dp[k], (t[0] + j * 10 ** t[1], t[1] + 1))
            dp[k] = max(dp[k], (t[0]*10 + j, t[1] + 1))

print(dp[-1][0])


Failing test case input:
20 4
3 7 8 5

Expected output:
777775


Actual output:
777777


Fixed submission (verdict: Accepted):
n, m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

dp = [(0, 0)] * (n+1)
ma = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

for i in range(n):
    if i!=0 and dp[i] == (0, 0):
        continue
    for j in a:
        t = dp[i]
        k = i + ma[j]
        if k <= n:
            dp[k] = max(dp[k], (t[0] + j * 10 ** t[1], t[1] + 1))
            dp[k] = max(dp[k], (t[0]*10 + j, t[1] + 1))

print(dp[-1][0])

Problem: p03128
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N,M=map(int,input().split())
l=list(map(int,input().split()))
w=[2,5,5,4,5,6,3,7,6]
dp=[0]*(max(N+1,8))
for j in l:
   dp[w[j-1]]=j
for i in range(N):
   if dp[i]!=0:
      for j in l:
         if w[j-1]+i<=N:
            dp[i+w[j-1]]=max(dp[i+w[j-1]],dp[i]*10+j)
print(dp[N])

Failing test case input:
29 4
5 4 2

Expected output:
5444444


Actual output:
4544444


Fixed submission (verdict: Accepted):
N,M=map(int,input().split())
l=list(map(int,input().split()))
w=[2,5,5,4,5,6,3,7,6]
l.sort()
dp=[0]*(max(N+1,8))
for j in l:
   dp[w[j-1]]=j
for i in range(N):
   if dp[i]!=0:
      for j in l:
         if w[j-1]+i<=N:
            dp[i+w[j-1]]=max(dp[i+w[j-1]],dp[i]*10+j)
print(dp[N])
Problem: p03128
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())
A = list(map(int, input().split()))

numbers = [None, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [0] * (N+1)
dp[0] = 0
for i in range(N+1):
    for a in A:
        j = i + numbers[a]
        if j <= N:
            dp[j] = max(dp[j], dp[i]*10 + a)
print(dp[N])

Failing test case input:
20 4
3 7 8 5

Expected output:
777775


Actual output:
777777


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
A = list(map(int, input().split()))

numbers = [None, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [-1] * (N+1)
dp[0] = 0
for i in range(N+1):
    for a in A:
        j = i + numbers[a]
        if j <= N:
            dp[j] = max(dp[j], dp[i]*10 + a)
print(dp[N])

Problem: p03128
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
sys.setrecursionlimit(1000000)

n, m = map(int, input().split())
a = list(map(int, input().split()))
cost = [None, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [None] * (n + 1)
def dfs(at):
    if dp[at] is not None:
        return dp[at]
    r = max([0] + [dfs(at - cost[v]) * 10 + v for v in a if at - cost[v] >= 0])
    dp[at] = r
    return r


print(dfs(n))


Failing test case input:
23 6
4 2 6

Expected output:
64442


Actual output:
64444


Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(1000000)

n, m = map(int, input().split())
a = list(map(int, input().split()))
cost = [float("inf"), 2, 5, 5, 4, 5, 6, 3, 7, 6]
mincost = min(cost)

dp = [None] * (n + 1)
def dfs(at):
    if at < 0:
        return -1
    if at == 0:
        return 0
    if dp[at] is not None:
        return dp[at]
    r = max(dfs(at - cost[v]) * 10 + v for v in a)
    dp[at] = r
    return r


print(dfs(n))

Problem: p03128
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
a = [int(m) for m in input().split()]
a.sort(reverse=True)
dp = []
for i in range(10 * n):
    dp.append(0)

b = [0,2,5,5,4,5,6,3,7,6]
for i in range(1, n + 1):
    for j in range(len(a)):
        if i - b[a[j]] >= 0:
            dp[i] = max(dp[i], dp[i - b[a[j]]] + a[j])
        else:
            pass
    if i != n:
        dp[i] *= 10

print(dp[n])

Failing test case input:
23 7
1 3 2

Expected output:
3111111111


Actual output:
11111111111


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
a = [int(m) for m in input().split()]
a.sort(reverse=True)
dp = []
for i in range(10 * n):
    dp.append(0)

b = [0,2,5,5,4,5,6,3,7,6]
for i in range(1, n + 1):
    for j in range(len(a)):
        if i - b[a[j]] >= 0:
            if (dp[i - b[a[j]]] == 0 and i - b[a[j]] == 0) or dp[i - b[a[j]]] != 0:
                dp[i] = max(dp[i], dp[i - b[a[j]]] + a[j])
        else:
            pass
    if i != n:
        dp[i] *= 10

print(dp[n])
Problem: p03128
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int, input().split())
mt=[0,2,5,5,4,5,6,3,7,6]
a=sorted(map(int, input().split()))
dp=['']*(n+1)
dp[0]='*'
for i in range(n+1):
    if not dp[i]:continue
    for j in a:
        if i+mt[j]<n+1:
            dp[i+mt[j]]=str(j)+dp[i]
print(*sorted(dp[-1][:-1])[::-1],sep='')

Failing test case input:
33 4
3 3 8 9

Expected output:
999333


Actual output:
983333


Fixed submission (verdict: Accepted):
n,m=map(int, input().split())
mt=[0,2,5,5,4,5,6,3,7,6]
a=sorted(map(int, input().split()))[::-1]
dp=[-1]*(n+1)
dp[0]=0
for i in range(n+1):
    if dp[i]==-1:continue
    for j in a:
        if i+mt[j]<n+1:
            dp[i+mt[j]]=max(dp[i]*10+j,dp[i+mt[j]])
print(dp[-1])
Problem: p02900
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def getlist(x):
    l = []
    
    for i in range(1,int(x**0.5)+1):
        if x % i == 0:
            l.append(i)
      
    return l
  
def isprime(x):
    count = 0
    for i in range(1,int(x**0.5)+1):
        if x % i == 0:
            count += 1
      
    if count == 1:
        return True
    else:
        return False

a,b = map(int,input().split())

la = getlist(a)
lb = getlist(b)
l = []
for i in la:
    if i in lb:
        l.append(i)

ans=0
for i in l:
    if isprime(i):
        ans+=1
       

print(ans)
  

  

  

  

  


Failing test case input:
3 2019

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
def gcd(x, y):
    a, b = x, y
    r = a % b
    while r != 0:
        a, b = b, r
        r = a % b
    return b

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

def isprime(x):
    t = 1
    for i in range(2, int(x**0.5) + 1):
        if x % i == 0:
            t = 0
            break
    if t == 1 and x != 1:
        return True
    else:
        return False


a, b = map(int, input().split())

CD = divisors(gcd(a, b))

ans = 1
for cd in CD:
    if isprime(cd):
        ans += 1

print(ans)

Problem: p02900
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import copy
A,B = map(int, input().split())

num = min(A,B)
tmps = {}
p = 2
while p * p <= num:
    if A % p == 0 and B % p == 0:
        tmps[p] = True
    p += 1

if num != 1 and  A % num == 0 and B % num == 0:
    tmps[num] = True


d = copy.deepcopy(tmps)
for k in tmps.keys():
    if d.get(k, False):
        aaa = copy.deepcopy(d)
        for n in d.keys():
            if k == n:
                continue
            if n > k and n % k == 0:
                aaa.pop(n)
        d = aaa

print(len(d.keys())+1)


Failing test case input:
10 6430

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):

import copy
import math
A,B = map(int, input().split())

num = min(A,B)
tmps = {}
p = 2
for p in range(2, math.ceil(num**0.5)+1):

    if A % p == 0 and B % p == 0:
        tmps[p] = True

    if A % (num
        tmps[num

    p += 1

if num != 1 and  A % num == 0 and B % num == 0:
    tmps[num] = True


d = copy.deepcopy(tmps)
for k in tmps.keys():

    if d.get(k, False):
        aaa = copy.deepcopy(d)
        for n in d.keys():
            if k == n:
                continue
            if n > k and n % k == 0:
                aaa.pop(n)
        d = aaa

print(len(d.keys())+1)
Problem: p02900
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import copy
A,B = map(int, input().split())


tmp_list = [1]

num = min(A,B)

tmps = {}
p = 2
while p * p <= num:
    if A % p == 0 and B % p == 0:
        
        tmps[p] = True
    p += 1

ans_list = []
d = copy.deepcopy(tmps)
for k in tmps.keys():
    if d.get(k, False):
        aaa = copy.deepcopy(d)
        for n in d.keys():
            if k == n:
                continue
            if n > k and n % k == 0:
                aaa.pop(n)
        d = aaa

print(len(d.keys())+1)


Failing test case input:
442 17

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):

import copy
import math
A,B = map(int, input().split())

num = min(A,B)
tmps = {}
p = 2
for p in range(2, math.ceil(num**0.5)+1):

    if A % p == 0 and B % p == 0:
        tmps[p] = True

    if A % (num
        tmps[num

    p += 1

if num != 1 and  A % num == 0 and B % num == 0:
    tmps[num] = True


d = copy.deepcopy(tmps)
for k in tmps.keys():

    if d.get(k, False):
        aaa = copy.deepcopy(d)
        for n in d.keys():
            if k == n:
                continue
            if n > k and n % k == 0:
                aaa.pop(n)
        d = aaa

print(len(d.keys())+1)

Problem: p02900
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

A, B = map(int, input().split())

def is_prime(n):
    rn = int(n**0.5) + 1 
    for i in range(2, rn):
        if n % i == 0:
            return False
    return True

def divisor(a, b):
    res = []
    ra = int(a**0.5) + 1 
    for i in range(1, ra):
        if a % i == 0:
            if b % i == 0:
                res.append(i)
    return sorted(res)

Y = divisor(A, B)
ans = 0
for i in range(len(Y)):
    if is_prime(Y[i]):
        ans += 1

print(ans)

Failing test case input:
6 2019

Expected output:
2


Actual output:
1


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

A, B = map(int, input().split())

def is_prime(n):
    rn = int(n**0.5) + 1 
    for i in range(2, rn):
        if n % i == 0:
            return False
    return True

def divisor(a, b):
    if a < b:
        b, a = a, b
    res = []
    ra = int(a**0.5) + 1 
    for i in range(1, ra):
        if a % i == 0:
            if b % i == 0:
                res.append(i)
                if i != a / i and b % (a/i) == 0:
                    res.append(int(a / i))
            else:
                if i != a / i and b % (a/i) == 0:
                    res.append(int(a / i))
    return sorted(res)

Y = divisor(A, B)

ans = 0
for i in range(len(Y)):
    if is_prime(Y[i]):
        ans += 1

print(ans)
Problem: p02900
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def is_prime(num):
    if num==2 or num==3:
        return True
    for i in range(2,int(num**0.5)+1):
        if num%i==0:
            return False
    return True

def main():
    a,b=map(int,input().split())
    s,l=min(a,b),max(a,b)
    
    s_sub=s
    s_prime=[1]
    i=2
    while i<=s_sub:
        print(i,s%i==0,is_prime(i))
        if s%i==0:
            if is_prime(i):
                s_prime.append(i)
                s_sub=s
        i+=1
    ans=0
    for i in s_prime:
        if l%i==0:
            ans+=1
    print(ans)
    
main()

Failing test case input:
5 4794

Expected output:
1


Actual output:
2 False True
3 False True
4 False False
5 True True
1


Fixed submission (verdict: Accepted):
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def is_prime(num):
    if num<1:
        return False
    if num==1 or num==2 or num==3:
        return True
    for i in range(2,int(num**0.5)+1):
        if num%i==0:
            return False
    return True
 
def main():
    a,b=map(int,input().split())
    GCD=gcd(a,b)
    ans=0
    for i in range(1,int(GCD**0.5)+1):
        if GCD%i==0:
            if is_prime(i):
                ans+=1
            if i!=GCD and is_prime(GCD
                ans+=1
    print(ans)
    
main()

Problem: p02900
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

def kouyaku(a,b):
    if a<b:
        temp = a
        a = b
        b = temp
    if b == 0:
        return a
    r = a%b
    if r == 0:
        return b
    else:
        return kouyaku(b,r)

if __name__ == "__main__":
    a,b = (int(i) for i in input().split())
    s = kouyaku(a,b)
    if s == 1:
        print(1)
        exit()
    ans = 1
    for i in range(2, s):
        if s == 1: break
        if s%i == 0:
            ans += 1
            while s%i == 0:
                s = s/i
    print(ans)

Failing test case input:
6 1324

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):

def kouyaku(a,b):
    if a<b:
        temp = a
        a = b
        b = temp
    if b == 0:
        return a
    r = a%b
    if r == 0:
        return b
    else:
        return kouyaku(b,r)

if __name__ == "__main__":
    a,b = (int(i) for i in input().split())
    s = kouyaku(a,b)
    if s == 1:
        print(1)
        exit()
    ans = 1
    for i in range(2, int(s**0.5)+1):
        if s == 1: 
            break
        if s%i == 0:
            ans += 1
            while s%i == 0:
                s = s/i
    if s>int(s**0.5):
        ans += 1
    print(ans)
Problem: p02900
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a,b=mi()
while a!=0:
  c=a
  a=b%a
  b=c
ans=0
for i in range(2,int(math.sqrt(b)+2)):
  if b%i==0:
    ans+=1
    while b%i==0:
      b=int(b/i)
  if b!=1:
    ans+=1
print(ans+1)

Failing test case input:
420 456

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a,b=mi()
while a!=0:
  c=a
  a=b%a
  b=c
ans=1
for i in range(2,int(math.sqrt(b)+2)):
  if b%i==0:
    ans+=1
    while b%i==0:
      b=int(b/i)
if b!=1:
    ans+=1
print(ans)

Problem: p02900
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

def pf(n):
    ans=[1]
    i=2
    if(n%i==0):
        while(n%2==0):
            n = n/i
        ans.append(i)
    i+=1
    while(i<math.sqrt(n) and n!=1):
        if (n%i==0):
            while(n%i==0):
                n=n/i
            ans.append(i)
        i+=2
    if(n!=1):
        ans.append(n)
    return set(ans)

a,b = map(int,input().split())
pfa=pf(a)
pfb=pf(b)
a=0
for i in pfa:
    if(i in pfb):
        a+=1
print(a)


Failing test case input:
66 9

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
import math

def pf(n):
    ans=[1]
    i=2
    if(n%i==0):
        while(n%2==0):
            n = n/i
        ans.append(i)
    i+=1
    while(i<math.sqrt(n) and n!=1):
        if (n%i==0):
            while(n%i==0):
                n=n/i
            ans.append(i)
        i+=2
    if(n!=1):
        ans.append(n)
    return set(ans)

a,b = map(int,input().split())
pfa=pf(a)
a=0
for i in pfa:
    if(b%i==0):
        a+=1
print(a)
Problem: p02900
Buggy submission (Python (3.4.3), verdict: Wrong Answer):




import math

a, b = map(int, input().split())


def ff(x):
    if x == 1 or x == 2:
        return True
    for i in range(2, math.floor(x ** 0.5) + 1):
        if x % i == 0:
            return False
    return True


def f(x):
    ret = []
    for i in range(1, math.floor(x ** 0.5) + 1):
        if x % i == 0 and ff(i):
            
            ret.append(i)
    return set(ret)


a_lis, b_lis = f(a), f(b)
common_lis = a_lis & b_lis
print(len(common_lis))


Failing test case input:
3 2019

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):




a, b = map(int, input().split())


def ff(x):
    if x == 1 or x == 2:
        return True
    for i in range(2, int(x ** 0.5) + 1):
        if x % i == 0:
            return False
    return True


def f(x):
    ret = []
    i = 1
    while i * i <= x:
        if x % i == 0:
            if ff(i):
                ret.append(i)
            
            if i != 1 and i * i != x:
                if ff(x 
                    ret.append(x 
        i += 1
    if ff(x):
        ret.append(x)
    return set(ret)


a_lis, b_lis = f(a), f(b)
common_lis = a_lis & b_lis
print(len(common_lis))

Problem: p02900
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=[int(i) for i in input().split()]

def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

A=prime_decomposition(a)
B=prime_decomposition(b)
ans=0
for i in A:
    if i in B:
        ans+=1

print(ans)



Failing test case input:
42 9

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
a,b=[int(i) for i in input().split()]

def prime_decomposition(n):
    i = 2
    table = [1]
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(int(n))
    return table

A=list(set(prime_decomposition(a)))
B=list(set(prime_decomposition(b)))


ans=0
for i in A:
    if i in B:
        ans+=1

print(ans)