ZhenlongDai/ACPR huggingface dataset:
Problem: p02729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = list(map(int,input().split()))
b = a[0]+a[1]

c = ((a[0]*(a[0]-1))+(a[1]*(a[1]-1)))/2
print(c)

Failing test case input:
6 -8

Expected output:
51


Actual output:
51.0


Fixed submission (verdict: Accepted):
a = list(map(int,input().split()))
b = a[0]+a[1]

c = ((a[0]*(a[0]-1))+(a[1]*(a[1]-1)))/2
print(int(c))

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

print((n*(n-1)+m*(m-1))/2)

Failing test case input:
335 1

Expected output:
55945


Actual output:
55945.0


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

print(round((n*(n-1)+m*(m-1))

Problem: p02729
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N,M=map(int,input().split())

c = (N+M)*(N+M-1)/2 - N*M

print(c)

Failing test case input:
-1 -90

Expected output:
4096


Actual output:
4096.0


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

c = (N+M)*(N+M-1)/2 - N*M

print(int(c))

Problem: p02729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())

print(N*(N-1)+M*(M-1))

Failing test case input:
-19 -1

Expected output:
191


Actual output:
382


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
 
print((N*(N-1)+M*(M-1))

Problem: p02729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())

k = 0

if a%2 == 0:
  k = k + a*(a-1)/2
else:
  k = k
  
if b%2 == 0:
  k = k + b*(b-1)/2
else:
  k = k
  
print(k)


Failing test case input:
0 -14

Expected output:
105


Actual output:
105.0


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())
 
k = 0
 
if a != 1:
  k = k + a*(a-1)/2
else:
  k = k
  
if b != 1:
  k = k + b*(b-1)/2
else:
  k = k
  
print(int(k))

Problem: p02729
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,m=map(int,input().split())

a=n*(n-1)/2
b=m*(m-1)/2

print(a+b)

Failing test case input:
-99 1

Expected output:
4950


Actual output:
4950.0


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

a=n*(n-1)/2
b=m*(m-1)/2

print(int(a+b))

Problem: p02729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())

ans = N*(N-1)/2 + M*(M-1)/2

print(ans)

Failing test case input:
-1 -39

Expected output:
781


Actual output:
781.0


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

ans = int(N*(N-1)/2 + M*(M-1)/2)

print(ans)

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

print(n*(n-1)/2+m*(m-1)/2)

Failing test case input:
-60 0

Expected output:
1830


Actual output:
1830.0


Fixed submission (verdict: Accepted):
n,m = map(int, input().split())
 
print(int(n*(n-1)/2+m*(m-1)/2))

Problem: p02729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
a=(n*(n-1))/2+(m*(m-1))/2
print(m)

Failing test case input:
560 1

Expected output:
156520


Actual output:
1


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
a=(n*(n-1))/2+(m*(m-1))/2
a=int(a)
print(a)
Problem: p02729
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n, m = map(int, input().split())
print(n*(n-1)/2+m*(m-1)/2)

Failing test case input:
11 -13

Expected output:
146


Actual output:
146.0


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
print(n*(n-1)

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

print(n*(n-1) + m*(m-1))


Failing test case input:
-19 1

Expected output:
190


Actual output:
380


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

print(int(n*(n-1)/2 + m*(m-1)/2))

Problem: p02729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = (int(x) for x in input().split())
A = N * (N - 1) / 2
B = M * (M - 1) / 2
print(A+B)

Failing test case input:
10 -6

Expected output:
66


Actual output:
66.0


Fixed submission (verdict: Accepted):
N, M = (int(x) for x in input().split())
A = N * (N - 1) / 2
B = M * (M - 1) / 2
print(int(A+B))

Problem: p02729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = map(int,input().split())
print(N*(N-1)/2+M*(M-1)/2)

Failing test case input:
-19 -1

Expected output:
191


Actual output:
191.0


Fixed submission (verdict: Accepted):
N,M = map(int,input().split())
print(int((N*(N-1)+M*(M-1))/2))

Problem: p02729
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = map(int,input().split())
print((N*(N-1))/2+(M*(M-1))/2)

Failing test case input:
-60 0

Expected output:
1830


Actual output:
1830.0


Fixed submission (verdict: Accepted):
N,M = map(int,input().split())
a = int((N*(N-1))/2+(M*(M-1))/2)
print(a)
Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

def dfs(s):
    if int(s) > n:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    for c in '753':
        ret = dfs(s+c)
    return ret

print(dfs('0'))

Failing test case input:
5689978

Expected output:
1725


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())

def dfs(s):
    if int(s) > n:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    for c in '753':
        ret += dfs(s+c)
    return ret

print(dfs('0'))

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
i=1
j=0
k=0
s=["3","5","7"]
d=["3","5","7"]
g=[]
k2=0
while i!=10:
    f=len(d)
    while j!=3:
        k = k2
        while k!=f:
            d.append(d[k]+s[j])
            k+=1


        j+=1
    k2 = f
    j=0
    i+=1
i=0
while i!=len(d):
    if ("3" in d[i])==True and ("5" in d[i])==True and ("7" in d[i])==True:
        i+=1
    else:
        del d[i]

d=list(map(int,d))
d.sort()
ans=0
i=0
x=0
while x<n:
    ans+=1
    i+=1
    x=d[i]


print(ans)

Failing test case input:
283

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
n=int(input())
i=1
j=0
k=0
s=["3","5","7"]
d=["3","5","7"]
g=[]
k2=0
while i!=10:
    f=len(d)
    while j!=3:
        k = k2
        while k!=f:
            d.append(d[k]+s[j])
            k+=1


        j+=1
    k2 = f
    j=0
    i+=1
i=0
while i!=len(d):
    if ("3" in d[i])==True and ("5" in d[i])==True and ("7" in d[i])==True:
        i+=1
    else:
        del d[i]

d=list(map(int,d))
d.sort()
ans=0
i=0
x=d[i]
while x<=n:
    ans+=1
    i+=1
    x=d[i]


print(ans)

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
N = int(input())

def f(i,ans):
    if int(i) > N:
        return ans
    i = str(i)
    for a in A:
        ans += f(i+a,ans)-ans
    return ans

ans = 0
A = '357'
print(f(0,0))

Failing test case input:
18056810

Expected output:
2538


Actual output:
0


Fixed submission (verdict: Accepted):
def f(i,ans):
    if int(i) > N:
        return ans
    i = str(i)
    ans += 1 if all([i[1:].count(a) for a in A]) else 0
    for a in A:
        ans += f(i+a,ans)-ans
    return ans
  
N = int(input())
ans = 0
A = '357'
print(f(0,0))
Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin
import sys
sys.setrecursionlimit(10**6) 
import bisect

n = int(stdin.readline().rstrip())

li = [7,5,3]

if n < 357:
    print(0)
    exit()

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

kazu = 0
point = 0
k = "0"
while int(k) <= n:
    k = Base_10_to_n(kazu,4)
    k = k.replace("3","7").replace("1","3").replace("2","5")
    if all(k.count(c)>0 for c in "753")and k.count("0") == 0:
        point += 1
    kazu += 1
print(point)

Failing test case input:
3750

Expected output:
14


Actual output:
15


Fixed submission (verdict: Accepted):
from sys import stdin
import sys
sys.setrecursionlimit(10**6) 
import bisect

n = int(stdin.readline().rstrip())

li = [7,5,3]

if n < 357:
    print(0)
    exit()

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

kazu = 0
point = 0
k = "0"
while int(k) <= n:
    k = Base_10_to_n(kazu,4)
    k = k.replace("3","7").replace("1","3").replace("2","5")
    if all(k.count(c)>0 for c in "753")and k.count("0") == 0:
        if int(k) <= n:
            point += 1
    kazu += 1
print(point)

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

ans = 0
def dfs(s):
    global ans
    if int(s) > N:
        return
    if all(s.count(i) for i in '753'):
        ans += 1
        return
    for c in '753':
        dfs(s+c)
        
dfs('0')
print(ans)

Failing test case input:
585456

Expected output:
552


Actual output:
126


Fixed submission (verdict: Accepted):
N = int(input())

ans = 0
def dfs(s):
    global ans
    if int(s) > N:
        return
    if all(s.count(i) for i in '753'):
        ans += 1
    for c in '753':
        dfs(s+c)
        
dfs('0')
print(ans)

Problem: p03212
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import itertools

n = int(input())

count = 0
for i in range(3, 11):
    for itr in itertools.product('357', repeat=i):
        value = 0
        for j in range(i):
            value += int(itr[j])*10**j
        if value <= n:
            count += 1
print(count)

Failing test case input:
5422200

Expected output:
1545


Actual output:
2052


Fixed submission (verdict: Accepted):
import itertools

n = int(input())

count = 0
for i in range(3, 11):
    for itr in itertools.product('357', repeat=i):
        if '3' not in itr or '5' not in itr or '7' not in itr:
            continue
        value = 0
        for j in range(i):
            value += int(itr[j])*10**j
        if value <= n:
            count += 1
print(count)
Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def search(s, n):
  if int(s) > n:
    return 0
  ans = 0 if s == '0' else 1
  for c in '753':
    ans += search(s+c,n)
  return ans

N = int(input())
print(search('0',N))
    

Failing test case input:
11571688

Expected output:
2538


Actual output:
3279


Fixed submission (verdict: Accepted):
def search(s, n):
  if int(s) > n:
    return 0
  ans = 1 if (s.count('7') > 0 and s.count('5') > 0 and s.count('3') > 0) else 0
  for c in '753':
    ans += search(s+c,n)
  return ans

N = int(input())
print(search('0',N))

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def gen_753(l,li=["7","5","3"]):
    if l == 1:
        return li
    new_li = []
    for cand in li:
        new_li.extend([cand + "7",cand + "5",cand + "3"])
    return gen_753(l-1,new_li)

num_str = input()
l = len(num_str)
num = int(num_str)
can_l = [int(num) for num in gen_753(l)]
count = sum([num >= i for i in can_l ])

Failing test case input:
371598

Expected output:
307


Actual output:

Fixed submission (verdict: Accepted):
def gen_753(l,li=["7","5","3"]):
    if l == 1:
        return li
    new_li = []
    for cand in li:
        new_li.extend([cand + "7",cand + "5",cand + "3"])
    return gen_753(l-1,new_li)

num_str = input()
l = len(num_str)
num_ = int(num_str)
temp = []
for num in range(3,l+1):
    temp.extend(gen_753(num))
can_l = [int(num) for num in temp if len(set(list(num))) == 3]
count = sum([i <= num_ for i in can_l])
print(count)

Problem: p03212
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import deque
N = int(input())
nums = ['3', '5', '7']
now = ''
q = deque(nums)
ans = 0
flag = True
while flag:
    n = q.popleft()
    for num in nums:
        tmp = n
        tmp += num
        if '3' in tmp and '5' in tmp and '7' in tmp:
            ans += 1
        if int(tmp) >= N:
            flag = False
            break
        q.append(tmp)

print(ans)

Failing test case input:
57418340

Expected output:
5980


Actual output:
5981


Fixed submission (verdict: Accepted):
from collections import deque
N = int(input())
nums = ['3', '5', '7']
now = ''
q = deque(nums)
ans = 0
flag = True
while flag:
    n = q.popleft()
    for num in nums:
        tmp = n
        tmp += num
        if int(tmp) > N:
            flag = False
            break
        if '3' in tmp and '5' in tmp and '7' in tmp:
            ans += 1
        q.append(tmp)

print(ans)
Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = input().strip()

base = set(['375', '357', '537', '573', '735', '753'])

if int(N) < 357:
  print(0)
else:
  for n in range(len(N) - 3):
    newb = set()
    for b in base:
      new3b = set([b[:i] + '3' + b[i:] for i in range(len(b) + 1)])
      new5b = set([b[:i] + '5' + b[i:] for i in range(len(b) + 1)])
      new7b = set([b[:i] + '7' + b[i:] for i in range(len(b) + 1)])
      newb |= new3b | new5b | new7b
    base |= newb

print(len([i for i in base if int(i) <= int(N)]))


Failing test case input:
283

Expected output:
0


Actual output:
0
0


Fixed submission (verdict: Accepted):
N = input().strip()

maxn = ()
base = set(['357', '375', '537', '573', '735', '753'])

if int(N) < 357:
  print(0)
else:
  for n in range(len(N) - 3):
    newb = set()
    for b in base:
      new3b = set([b[:i] + '3' + b[i:] for i in range(len(b) + 1)])
      new5b = set([b[:i] + '5' + b[i:] for i in range(len(b) + 1)])
      new7b = set([b[:i] + '7' + b[i:] for i in range(len(b) + 1)])
      newb |= new3b | new5b | new7b
    base |= newb
  print(len([i for i in base if int(i) <= int(N)]))

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import deque
n=int(input())

que=deque([3,5,7])
x=0
ans=0
while x<=n:
    x=que.popleft()
    s=str(x)
    if s.count('3')>0 and s.count('5')>0 and s.count('7')>0:
        ans+=1
    que.append(10*x+3)
    que.append(10*x+5)
    que.append(10*x+7)

print(ans)

Failing test case input:
536671710

Expected output:
15714


Actual output:
15715


Fixed submission (verdict: Accepted):
from collections import deque
n=int(input())

que=deque([3,5,7])
x=0
ans=0
while True:
    x=que.popleft()
    if x>n:
        break
    s=str(x)
    if s.count('3')>0 and s.count('5')>0 and s.count('7')>0:
        ans+=1
    que.append(10*x+3)
    que.append(10*x+5)
    que.append(10*x+7)
print(ans)

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import deque
n=int(input())
ans=0
start=["357","375","537","573","735","753"]
start=deque(start)
while start:
  s=start.popleft()
  if int(s)<=n:ans+=1
  else:continue
  for i in ["3","5","7"]:
    start.append(s+i)
print(ans)

Failing test case input:
5825

Expected output:
30


Actual output:
18


Fixed submission (verdict: Accepted):
from collections import deque
n=int(input())
ans=0
start=["0"]
start=deque(start)
while start:
  s=start.popleft()
  if int(s)<=n and "3" in s and "5" in s and "7" in s:ans+=1
  elif int(s)>n:continue
  for i in ["3","5","7"]:
    start.append(s+i)
print(ans)
Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
n = int(s)
l = len(s)

dp = [[] for _ in range(l+1)]
dp[0].append('')

for i in range(l):
  for e in dp[i]:
    dp[i+1].append(e+'3')
    dp[i+1].append(e+'5')
    dp[i+1].append(e+'7')
ans = 0
for i in range(min(3,l),l):
  for e in dp[i]:
    if '3' in e and '5' in e and '7' in e and int(e) <= n:
      ans += 1
print(ans)


Failing test case input:
3600

Expected output:
13

Actual output:
6


Fixed submission (verdict: Accepted):
s = input()
n = int(s)
l = len(s)

dp = [[] for _ in range(l+1)]
dp[0].append('')

for i in range(l):
  for e in dp[i]:
    dp[i+1].append(e+'3')
    dp[i+1].append(e+'5')
    dp[i+1].append(e+'7')
ans = 0

for i in range(min(3,l+1),l+1):
  for e in dp[i]:
    if '3' in e and '5' in e and '7' in e and int(e) <= n:
      ans += 1
      
print(ans)

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
n = ["3", "5", "7"]
l = 0
r = 3
x = 1
flag = True
while flag:
    for m in (3, 5, 7):
        if not flag:
            break
        for i in range(l, r):
            y = int(n[i])+m*10**x
            if y > N:
                flag = False
                break
            n.append(str(y))

    l = r + 1
    r = len(n)   
    x += 1

res = 0
for s in n:
    if "3" in s and "5" in s and "7" in s:
        res += 1

print(res)

Failing test case input:
5422200

Expected output:
1545


Actual output:
1347


Fixed submission (verdict: Accepted):
N = int(input())
n = ["3", "5", "7"]
l = 0
r = 3
x = 1
flag = True
while flag:
    for m in (3, 5, 7):
        if not flag:
            break
        for i in range(l, r):
            y = int(n[i])+m*10**x
            if y > N:
                flag = False
                break
            n.append(str(y))

    l = r
    r = len(n)   
    x += 1

res = 0
for s in n:
    if "3" in s and "5" in s and "7" in s:
        res += 1

print(res)

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin
import sys
sys.setrecursionlimit(10**6) 
import bisect

n = int(stdin.readline().rstrip())

li = [7,5,3]

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

kazu = 0
point = 0
k = "0"
while int(k) <= n:
    k = Base_10_to_n(kazu,4)
    k = k.replace("3","7").replace("1","3").replace("2","5")
    if all(k.count(c)>0 for c in "753")and k.count("0") == 0:
        point += 1
    kazu += 1
print(point)

Failing test case input:
3750

Expected output:
14


Actual output:
15


Fixed submission (verdict: Accepted):
from sys import stdin
import sys
sys.setrecursionlimit(10**6) 
import bisect

n = int(stdin.readline().rstrip())

li = [7,5,3]

if n < 357:
    print(0)
    exit()

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

kazu = 0
point = 0
k = "0"
while int(k) <= n:
    k = Base_10_to_n(kazu,4)
    k = k.replace("3","7").replace("1","3").replace("2","5")
    if all(k.count(c)>0 for c in "753")and k.count("0") == 0:
        if int(k) <= n:
            point += 1
    kazu += 1
print(point)
Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = 10
cnt = 0

def rec(pref):
	global cnt
	if pref <= n:
		cnt += 1
		for d in {3, 5, 7}:
			rec(pref * 10 + d)


rec(0)
print(cnt - 1)


Failing test case input:
2718

Expected output:
6


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
cnt = 0

def rec(pref):
	global cnt
	if pref <= n:
		s = str(pref)
		if '3' in s and '5' in s and '7' in s:
			
			cnt += 1
		for d in {3, 5, 7}:
			rec(pref * 10 + d)


rec(0)
print(cnt)

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

def search(keta, num):
  if keta == 0:
    if int(num) <= N:
      return 1
    else:
      return 0
  else:
    return search(keta-1, num + '0') + search(keta-1, num + '3') + search(keta-1, num + '5') + search(keta-1, num + '7')

keta = len(str(N))

ans = search(keta, '')
print(ans)

Failing test case input:
12197586

Expected output:
2538


Actual output:
16384


Fixed submission (verdict: Accepted):
N = int(input())

def search(keta, num):
  if keta == 0:
    if '0' in str(int(num)):
      return 0
    elif '3' in num and '5' in num and '7' in num:
      if int(num) <= N:
        return 1
      else:
        return 0
    else:
      return 0
  else:
    return search(keta-1, num + '0') + search(keta-1, num + '3') + search(keta-1, num + '5') + search(keta-1, num + '7')

keta = len(str(N))

ans = search(keta, '')
print(ans)

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

def search(keta, num):
  if keta == 0:
    if '0' in str(int(num)):
      return 0
    elif int(num) <= N:
      return 1
    else:
      return 0
  else:
    return search(keta-1, num + '0') + search(keta-1, num + '3') + search(keta-1, num + '5') + search(keta-1, num + '7')

keta = len(str(N))

ans = search(keta, '')
print(ans)


Failing test case input:
635

Expected output:
4


Actual output:
30


Fixed submission (verdict: Accepted):
N = int(input())

def search(keta, num):
  if keta == 0:
    if '0' in str(int(num)):
      return 0
    elif '3' in num and '5' in num and '7' in num:
      if int(num) <= N:
        return 1
      else:
        return 0
    else:
      return 0
  else:
    return search(keta-1, num + '0') + search(keta-1, num + '3') + search(keta-1, num + '5') + search(keta-1, num + '7')

keta = len(str(N))

ans = search(keta, '')
print(ans)

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools
n=str(input())
ans=0
for i in range(3,len(n)+1):
    for j in itertools.product([3,5,7], repeat=i):
        if (3 not in j) or (5 not in j) or (7 not in j):
            continue
        a=''.join(list(map(str,j)))
        if a<=n:
            ans+=1
print(ans)

    

Failing test case input:
1992

Expected output:
6


Actual output:
0


Fixed submission (verdict: Accepted):
import itertools
n=str(input())
ans=0
for i in range(3,len(n)+1):
    for j in itertools.product([3,5,7], repeat=i):
        if (3 not in j) or (5 not in j) or (7 not in j):
            continue
        a=''.join(list(map(str,j)))
        if int(a)<=int(n):
            ans+=1
print(ans)
Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    for c in '753':
        ret = dfs(s + c)
    return ret

print(dfs('0'))


Failing test case input:
5825

Expected output:
30


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0'))

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools
n = int(input())
l = []
l.extend(list(itertools.product([3,5,7], repeat=i)) for i in range(3,9))
l = [int("".join(map(str,j))) for i in l for j in i if 7 in j and 5 in j and 3 in j]
print(sum([1 for i in l if n>=i]))

Failing test case input:
1450760047

Expected output:
26484


Actual output:
8334


Fixed submission (verdict: Accepted):
import itertools
n = int(input())
l = []
l.extend(list(itertools.product([3,5,7], repeat=i)) for i in range(3,10))
l = [int("".join(map(str,j))) for i in l for j in i if 7 in j and 5 in j and 3 in j]
print(sum([1 for i in l if n>=i]))

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools

N = int(input())
d753 = ["3", "5", "7"]

c = 0
for i in range(1, 9):
	for d in itertools.product(d753, repeat = i):
		if d.count("3") >= 1 and d.count("5") >= 1 and d.count("7") >= 1:
			x = int("".join(d))
			if x <= N:
				c += 1

print(c)

Failing test case input:
1260308870

Expected output:
26484


Actual output:
8334


Fixed submission (verdict: Accepted):
import itertools

N = int(input())
d753 = ["3", "5", "7"]

c = 0
for i in range(1, 10):
	for d in itertools.product(d753, repeat = i):
		if d.count("3") >= 1 and d.count("5") >= 1 and d.count("7") >= 1:
			x = int("".join(d))
			if x <= N:
				c += 1

print(c)

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = input()
t = ["3","5","7"]
for i in range(8):
    s = []
    for j in t:
        s.append(j+"3")
        s.append(j+"5")
        s.append(j+"7")
    t += s
t = set(t)
t = list(t)
t.sort()
count = 0
for i in range(len(t)):
    if len(t[i]) > len(n):
        break
    if int(t[i]) > int(n):
        continue
    if '3' in t[i] and '5' in t[i] and '7' in t[i]:
        count+=1
print(count)

Failing test case input:
5689978

Expected output:
1725


Actual output:
0


Fixed submission (verdict: Accepted):
n = input()
t = ["3","5","7"]
for i in range(8):
    s = []
    for j in t:
        s.append(j+"3")
        s.append(j+"5")
        s.append(j+"7")
    t += s
t = set(t)
t = list(t)
t.sort()
count = 0
for i in range(len(t)):
    if len(t[i]) > len(n):
        continue
    if int(t[i]) > int(n):
        continue
    if '3' in t[i] and '5' in t[i] and '7' in t[i]:
        count+=1
print(count)
Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = input().strip()

base = set(['375', '357', '537', '573', '735', '753'])

if int(N) < 375:
  print(0)
else:
  for n in range(len(N) - 3):
    newb = set()
    for b in base:
      new3b = set([b[:i] + '3' + b[i:] for i in range(len(b) + 1)])
      new5b = set([b[:i] + '5' + b[i:] for i in range(len(b) + 1)])
      new7b = set([b[:i] + '7' + b[i:] for i in range(len(b) + 1)])
      newb |= new3b | new5b | new7b
    base |= newb
    
  
print(len([i for i in base if int(i) <= int(N)]))


Failing test case input:
283

Expected output:
0


Actual output:
0
0


Fixed submission (verdict: Accepted):
N = input().strip()

maxn = ()
base = set(['357', '375', '537', '573', '735', '753'])

if int(N) < 357:
  print(0)
else:
  for n in range(len(N) - 3):
    newb = set()
    for b in base:
      new3b = set([b[:i] + '3' + b[i:] for i in range(len(b) + 1)])
      new5b = set([b[:i] + '5' + b[i:] for i in range(len(b) + 1)])
      new7b = set([b[:i] + '7' + b[i:] for i in range(len(b) + 1)])
      newb |= new3b | new5b | new7b
    base |= newb
  print(len([i for i in base if int(i) <= int(N)]))

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())

def dfs(s):
    if int(s)>n:
        return 0
    ret=1 if all(s.count(c)>0 for c in "753") else 0
    for c in "753":
        ret+=dfs(s+c)
    return ret

print("0")


Failing test case input:
268445916

Expected output:
8334


Actual output:
0


Fixed submission (verdict: Accepted):
n=int(input())
def dfs(x):
    if int(x)>n:
        return 0
    c=1 if all(x.count(l)>0 for l in "753") else 0
    for i in "753":
        c+=dfs(x+i)
    return c
print(dfs("0"))

Problem: p03212
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import itertools
from collections import Counter
import bisect
N = int(input())

lst = ['3','5','7']
anslst = set()
for i in range(1,10):
    for v in itertools.product(lst,repeat=i):
        x = Counter(str(v))
        if x['7'] >= 1 and x['5'] >= 1 and x['3'] >= 1:
            anslst.add(int(''.join(v)))

index = bisect.bisect_left(list(anslst), N)
print(index)


Failing test case input:
539422341

Expected output:
16443


Actual output:
13221


Fixed submission (verdict: Accepted):
import itertools
from collections import Counter
import bisect
N = int(input())

lst = ['3','5','7']
anslst = []
for i in range(1,10):
    for v in itertools.product(lst,repeat=i):
        x = Counter(str(v))
        if x['7'] >= 1 and x['5'] >= 1 and x['3'] >= 1:
            anslst.append(int(''.join(v)))
anslst.sort()
index = bisect.bisect_right(list(anslst), N)
print(index)
Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
cnt = 0

def rec(pref):
	global cnt
	if pref <= n:
		cnt += 1
		for d in {3, 5, 7}:
			rec(pref * 10 + d)


rec(0)
print(cnt - 1)


Failing test case input:
2751855

Expected output:
732


Actual output:
1092


Fixed submission (verdict: Accepted):
n = int(input())
cnt = 0

def rec(pref):
	global cnt
	if pref <= n:
		s = str(pref)
		if '3' in s and '5' in s and '7' in s:
			
			cnt += 1
		for d in {3, 5, 7}:
			rec(pref * 10 + d)


rec(0)
print(cnt)

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

def cnt(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '357') else 0
    for c in '357':
        ret += cnt(s+c)
    return ret

cnt('0')

Failing test case input:
3412

Expected output:
8


Actual output:

Fixed submission (verdict: Accepted):
N = int(input())

def cnt(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '357') else 0
    for c in '357':
        ret += cnt(s+c)
    return ret

print(cnt('0'))

Problem: p03212
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N=int(input())
def next_357(num_arr,i=-1):
    if len(num_arr) < -i:
        num_arr.insert(0,3)
        return num_arr
    if num_arr[i] == 3:
        num_arr[i] = 5
        return num_arr
    elif num_arr[i] == 5:
        num_arr[i] = 7
        return num_arr
    elif num_arr[i] == 7:
        num_arr[i] = 3
        i -= 1
        return next_357(num_arr,i)
ans = 1
a357 = [3,5,7]
while True:
    if N < 357:
        ans = 0
        break
    elif N == 357:
        break
    else:
        a357 = next_357(a357)
        if int("".join(map(str, a357))) <= N:
            ans += 1
        else:
            break
print(ans)

Failing test case input:
923

Expected output:
6


Actual output:
22


Fixed submission (verdict: Accepted):
N=int(input())
def next_357(num_arr,i=-1):
    if len(num_arr) < -i:
        num_arr.insert(0,3)
        return num_arr
    if num_arr[i] == 3:
        num_arr[i] = 5
        return num_arr
    elif num_arr[i] == 5:
        num_arr[i] = 7
        return num_arr
    elif num_arr[i] == 7:
        num_arr[i] = 3
        i -= 1
        return next_357(num_arr,i)
ans = 1
a357 = [3,5,7]
while True:
    if N < 357:
        ans = 0
        break
    elif N == 357:
        break
    else:
        a357 = next_357(a357)
        if int("".join(map(str, a357))) <= N:
            if a357.count(3) >= 1 and a357.count(5) >= 1 and a357.count(7) >= 1:
                ans += 1
        else:
            break
print(ans)
Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools as it
N=int(input())
d=0
for i in range(3,10):
    for c in sorted(list(it.product('753',repeat=i))):
        if int(''.join(c))>N:exit(0)
        if len(set(c))==3:d+=1
print(d)

Failing test case input:
17251712

Expected output:
2538


Actual output:

Fixed submission (verdict: Accepted):
import itertools as it
N=int(input())
d=0
for i in range(3,10):
    for c in sorted(list(it.product('753',repeat=i))):
        if int(''.join(c))>N:
            print(d)
            exit(0)
        if len(set(c))==3:d+=1
print(d)

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools
n = tuple(map(int,input()))
l = []
l.extend(list(itertools.product([3,5,7], repeat=i)) for i in range(3,9))
l = [j for i in l for j in i if 7 in j and 5 in j and 3 in j]
print(sum([1 for i in l if len(n) > len(i)  or (n >= i and len(n) == len(i))]))

Failing test case input:
656396080

Expected output:
20434


Actual output:
8334


Fixed submission (verdict: Accepted):
import itertools
n = int(input())
l = []
l.extend(list(itertools.product([3,5,7], repeat=i)) for i in range(3,10))
l = [int("".join(map(str,j))) for i in l for j in i if 7 in j and 5 in j and 3 in j]
print(sum([1 for i in l if n>=i]))

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import copy

N=int(input())

tmp0=[]
tmp1=[3,5,7]
res=[3,5,7]
for i in range(1,8):
  for j in tmp1:
    for k in [3,5,7]:
      res.append(j*10+k)
      tmp0.append(j*10+k)
  tmp1=copy.deepcopy(tmp0)
  tmp0=[]

res2=[]
for i in res:
  if len(set(str(i)))==3:
    res2.append(i)


ans=0
for i in res2:
  if i<=N:
    ans+=1
print(ans)

Failing test case input:
539422341

Expected output:
16443


Actual output:
8334


Fixed submission (verdict: Accepted):
import copy

N=int(input())

tmp0=[]
tmp1=[3,5,7]
res=[3,5,7]
for i in range(1,9):
  for j in tmp1:
    for k in [3,5,7]:
      res.append(j*10+k)
      tmp0.append(j*10+k)
  tmp1=copy.deepcopy(tmp0)
  tmp0=[]

res2=[]
for i in res:
  if len(set(str(i)))==3:
    res2.append(i)


ans=0
for i in res2:
  if i<=N:
    ans+=1
print(ans)

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())

def dfs(i,count):
    if i!="":
        if int(i)>=N:
            return count
    if "3" in i and "5" in i and "7" in i:
        count+=1
    count=dfs("3"+i,count)
    count=dfs("5"+i,count)
    count=dfs("7"+i,count)
    return count
  
dfs("",0)

Failing test case input:
2751855

Expected output:
732


Actual output:

Fixed submission (verdict: Accepted):
N=int(input())

def dfs(i,count):
    if i!="":
        if int(i)>N:
            return count
    if "3" in i and "5" in i and "7" in i:
        count+=1
    count=dfs("3"+i,count)
    count=dfs("5"+i,count)
    count=dfs("7"+i,count)
    return count
  
print(dfs("",0))
Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
def dfs(s): 
  if int(s) > N:
    return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0 
    for c in '753':
      ret += dfs(s + c)
      return ret
print(dfs('0'))

Failing test case input:
26435227

Expected output:
2538


Actual output:
None


Fixed submission (verdict: Accepted):
N = int(input())
def shichi(n):
    if int(n) > N:
        return 0
    ret=1 if all(n.count(c)>0 for c in "753") else 0
    for c in "753":
        ret += shichi(n+c)
    return ret
print(shichi("0"))

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = input().strip()

base = set(['375', '357', '537', '573', '735', '753'])

if int(N) < 375:
  print(0)
else:
  for n in range(len(N) - 3):
    newb = set()
    for b in base:
      new3b = set([b[:i] + '3' + b[i:] for i in range(len(b) + 1)])
      new5b = set([b[:i] + '5' + b[i:] for i in range(len(b) + 1)])
      new7b = set([b[:i] + '7' + b[i:] for i in range(len(b) + 1)])
      newb |= new3b | new5b | new7b
    base |= newb
    
  
print(len([i for i in base if int(i) < int(N)]))

Failing test case input:
330

Expected output:
0


Actual output:
0
0


Fixed submission (verdict: Accepted):
N = input().strip()

maxn = ()
base = set(['357', '375', '537', '573', '735', '753'])

if int(N) < 357:
  print(0)
else:
  for n in range(len(N) - 3):
    newb = set()
    for b in base:
      new3b = set([b[:i] + '3' + b[i:] for i in range(len(b) + 1)])
      new5b = set([b[:i] + '5' + b[i:] for i in range(len(b) + 1)])
      new7b = set([b[:i] + '7' + b[i:] for i in range(len(b) + 1)])
      newb |= new3b | new5b | new7b
    base |= newb
  print(len([i for i in base if int(i) <= int(N)]))

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from itertools import product
N = int(input())
strN = str(N)
lenN = len(strN)
num = ['7','5','3']
count = 0
if N < 357:
    print(0)
else:
    for i in range(3,lenN+1):
        for j in product(num,repeat = i):
            num2 = [str(i) for i in j]
            num2 = ''.join(num2)
            if ('7' in num2) and  ('5' in num2) and  ('3' in num2) and int(num2) <= N:
                count += 1
print(count)

Failing test case input:
330

Expected output:
0


Actual output:
0
0


Fixed submission (verdict: Accepted):
from itertools import product
N = int(input())
strN = str(N)
lenN = len(strN)
num = ['7','5','3']
count = 0
if N < 357:
    print(0)
else:
    for i in range(3,lenN+1):
        for j in product(num,repeat = i):
            num2 = [str(i) for i in j]
            num2 = ''.join(num2)
            if ('7' in num2) and  ('5' in num2) and  ('3' in num2) and int(num2) <= N:
                count += 1
    print(count)
Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools as t;N=input();X=[]
for i in range(9):X+=list(t.product('357',repeat=i))
print(sum(len(set(i))>2and int(''.join(i))<=int(N)for i in X))

Failing test case input:
536671710

Expected output:
15714


Actual output:
8334


Fixed submission (verdict: Accepted):
import itertools as t;N=input();X=[]
for i in range(10):X+=list(t.product('357',repeat=i))
print(sum(len(set(i))>2and int(''.join(i))<=int(N)for i in X))

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools
n = int(input())
nagoya = [3,5,7]
i = 3
if n < 357:
    print(0)
    exit()
ans = 0
while(i < 10):
    current = list(itertools.product(nagoya,repeat=i))
    for j in range(len(current)):
        h = int("".join(map(str,(list(current[j])))))
        if len(set(str(h))) == 3:
            if n <= h:
                print(ans)
                exit()
            ans += 1
    i += 1

Failing test case input:
1450760047

Expected output:
26484


Actual output:

Fixed submission (verdict: Accepted):
import itertools
n = int(input())
nagoya = [3,5,7]
i = 1
if n < 357:
    print(0)
    exit()
ans = 0
while(i < 99):
    current = list(itertools.product(nagoya,repeat=i))
    for j in range(len(current)):
        h = int("".join(map(str,(list(current[j])))))
        if len(set(str(h))) == 3:
            if n < h:
                print(ans)
                exit()
            else:
                ans += 1
    i += 1

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def gen_753(l,li=["7","5","3"]):
    if l == 1:
        return li
    new_li = []
    for cand in li:
        new_li.extend([cand + "7",cand + "5",cand + "3"])
    return gen_753(l-1,new_li)

num_str = input()
l = len(num_str)
num = int(num_str)
can_l = [int(num) for num in gen_753(l) if len(set(list(num))) == 3]
count = sum([i <= num for i in can_l])
print(count)

Failing test case input:
268571838

Expected output:
8334


Actual output:
0


Fixed submission (verdict: Accepted):
def gen_753(l,li=["7","5","3"]):
    if l == 1:
        return li
    new_li = []
    for cand in li:
        new_li.extend([cand + "7",cand + "5",cand + "3"])
    return gen_753(l-1,new_li)

num_str = input()
l = len(num_str)
num_ = int(num_str)
temp = []
for num in range(3,l+1):
    temp.extend(gen_753(num))
can_l = [int(num) for num in temp if len(set(list(num))) == 3]
count = sum([i <= num_ for i in can_l])
print(count)
Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools
import collections
n=int(input())
l=len(str(n))
cnt=0
if l<3:
  print(0)
  exit()
for i in range(3,l+1):
  for k in itertools.product(['7','5','3'],repeat=i):
    j=int(''.join(k))
    c=collections.Counter(k)
    cv=c.values()
    if all(vv!=0 for vv in cv) and j<=n:
      cnt+=1
print(cnt)

Failing test case input:
251112438

Expected output:
8334


Actual output:
9828


Fixed submission (verdict: Accepted):
import itertools
import collections
n=int(input())
l=len(str(n))
cnt=0
if l<3:
  print(0)
  exit()
for i in range(3,l+1):
  for k in itertools.product(['7','5','3'],repeat=i):
    j=int(''.join(k))
    k=list(k)
    x=k.count('7')
    y=k.count('5')
    z=k.count('3')
    if all(vv!=0 for vv in [x,y,z]) and j<=n:
      cnt+=1
print(cnt)

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

def search(i,j,k,val) :
    ret = 0 
    if val > N :
        return 0
    elif i > 0 and j > 0 and k > 0 and val<=N:
        return 1 
    else :
        ret += search(i+1,j,k,val*10+3)
        ret += search(i,j+1,k,val*10+5)
        ret += search(i,j,k+1,val*10+7)
    return ret
print(search(0,0,0,0))

Failing test case input:
12197586

Expected output:
2538


Actual output:
342


Fixed submission (verdict: Accepted):
N = int(input())
 
def search(i,j,k,val) :
    ret = 0 
    if val > N :
        return 0
    elif i > 0 and j > 0 and k > 0 and val<=N:
        ret = 1 
    else :
        ret = 0 
    ret += search(i+1,j,k,val*10+3)
    ret += search(i,j+1,k,val*10+5)
    ret += search(i,j,k+1,val*10+7)
    return ret
print(search(0,0,0,0))

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N= int(input())
def f(x):
    if int(x) >N:
        return 0
    if x.count('3')>0 and x.count('5')>0 and x.count('7')>0:
        z = 1
    z=0
    z +=f(x+'3')
    z +=f(x+'5')
    z +=f(x+'7')
    return z
print(f('0'))


Failing test case input:
3750

Expected output:
14


Actual output:
0


Fixed submission (verdict: Accepted):
N= int(input())
def f(x):
    z=0
    if int(x) >N:
        return 0
    if x.count('3')>0 and x.count('5')>0 and x.count('7')>0:
        z = 1
    z +=f(x+'3')
    z +=f(x+'5')
    z +=f(x+'7')
    return z
print(f('0'))
Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin
import sys
sys.setrecursionlimit(10**6) 
import bisect

n = int(stdin.readline().rstrip())

li = [7,5,3]

if n < 357:
    print(0)

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

kazu = 0
point = 0
k = "0"
while int(k) <= n:
    k = Base_10_to_n(kazu,4)
    k = k.replace("3","7").replace("1","3").replace("2","5")
    if all(k.count(c)>0 for c in "753")and k.count("0") == 0:
        point += 1
    kazu += 1
print(point)

Failing test case input:
283

Expected output:
0


Actual output:
0
0


Fixed submission (verdict: Accepted):
from sys import stdin
import sys
sys.setrecursionlimit(10**6) 
import bisect

n = int(stdin.readline().rstrip())

li = [7,5,3]

if n < 357:
    print(0)
    exit()

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

kazu = 0
point = 0
k = "0"
while int(k) <= n:
    k = Base_10_to_n(kazu,4)
    k = k.replace("3","7").replace("1","3").replace("2","5")
    if all(k.count(c)>0 for c in "753")and k.count("0") == 0:
        if int(k) <= n:
            point += 1
    kazu += 1
print(point)

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools

def main():
    n = int(input())
    c = 0
    for m in gen():
        if is_753(m):
            c += 1

        if m > n:
            break
    print(c)

def is_753(n):
    s = str(n)
    if '3' in s and '5' in s and '7' in s:
        return True
    else:
        return False

def gen():
    for i in itertools.count(1):
        for x in gen_1(i):
            yield x

def gen_1(num_digits):
    if num_digits == 1:
        yield 3
        yield 5
        yield 7
    else:
        for sub in gen_1(num_digits - 1):
            yield sub * 10 + 3
            yield sub * 10 + 5
            yield sub * 10 + 7

main()


Failing test case input:
563

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
import itertools

def main():
    n = int(input())
    c = 0
    for m in gen():
        if m > n:
            break

        if is_753(m):
            c += 1

    print(c)

def is_753(n):
    s = str(n)
    if '3' in s and '5' in s and '7' in s:
        return True
    else:
        return False

def gen():
    for i in itertools.count(1):
        for x in gen_1(i):
            yield x

def gen_1(num_digits):
    if num_digits == 1:
        yield 3
        yield 5
        yield 7
    else:
        for sub in gen_1(num_digits - 1):
            yield sub * 10 + 3
            yield sub * 10 + 5
            yield sub * 10 + 7

main()
Problem: p03212
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import itertools

N=int(input())
num=[3,5,7]
dig=10
p=[1]*dig
for i in range(dig-1):
    p[i+1]=p[i]*10
    
ans=0

def check(n):
    strn=str(n)
    for i in range(len(num)):
        if not (str(num[i]) in strn):
            return False
    return True
        
ans=0
flag=1
for d in range(3,dig):
    if flag==0:
        break
    for pro in itertools.product(num, repeat=d):
        temp=0
        for j in range(d):
            temp+=pro[-1-j]*p[j]
        if check(temp):
            ans+=1
        if temp>=N:
            flag=0
            break
        
print(ans)

Failing test case input:
57418340

Expected output:
5980


Actual output:
5981


Fixed submission (verdict: Accepted):
import itertools

N=int(input())
num=[3,5,7]
dig=10
p=[1]*dig
for i in range(dig-1):
    p[i+1]=p[i]*10
    
ans=0

def check(n):
    strn=str(n)
    for i in range(len(num)):
        if not (str(num[i]) in strn):
            return False
    return True
        
ans=0
flag=1
for d in range(3,dig):
    if flag==0:
        break
    for pro in itertools.product(num, repeat=d):
        temp=0
        for j in range(d):
            temp+=pro[-1-j]*p[j]
        if temp>N:
            flag=0
            break
        if check(temp):
            ans+=1
        
print(ans)

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=999999999
l=len(str(N))

def calc(st):
    st=str(st)
    if(len(st)>l):return 0
    t=calc(st+"3")
    f=calc(st+"5")
    s=calc(st+"7")
    o=0
    if(st.find("7")>=0 and st.find("5")>=0 and st.find("3")>=0 and int(st)<=N):
        o=1
    return (t+f+s+o)

print(calc(str()))







Failing test case input:
3412

Expected output:
8


Actual output:
26484


Fixed submission (verdict: Accepted):
N=int(input())
l=len(str(N))

def calc(st):
    st=str(st)
    if(len(st)>l):return 0
    t=calc(st+"3")
    f=calc(st+"5")
    s=calc(st+"7")
    o=0
    if(st.find("7")>=0 and st.find("5")>=0 and st.find("3")>=0 and int(st)<=N):
        o=1
    return (t+f+s+o)

print(calc(str()))

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

ans = 0
p = [0]
while p:
    k = p.pop()
    if k > N:
        continue
    if '7' in str(k) and '5' in str(k) and '3' in str(k):
        ans += 1
    p.extend([k*10+3, k*10+5, k*10+7])


Failing test case input:
179898217

Expected output:
8334


Actual output:

Fixed submission (verdict: Accepted):
N = int(input())

ans = 0
p = [0]
while p:
    k = p.pop()
    if k > N:
        continue
    if '7' in str(k) and '5' in str(k) and '3' in str(k):
        ans += 1
    p.extend([k*10+3, k*10+5, k*10+7])
print(ans)
Problem: p03212
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
def dfs(s):
    if int(s)>n:
        return 0
    res = 1 if all(s.count(c) > 0 for c in '753') else 0
    for i in '753':
        res += dfs(s+i)
    return res
dfs('0')


Failing test case input:
80751

Expected output:
192


Actual output:

Fixed submission (verdict: Accepted):
n = int(input())
def dfs(s):
    if int(s)>n:
        return 0
    res = 1 if all(s.count(c) > 0 for c in '753') else 0
    for i in '753':
        res += dfs(s+i)
    return res
print(dfs('0'))

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import deque

n = int(input())
q = deque(['3','5','7'])
ans = 0
while True:
    v = q.popleft()
    if '3' in v and '5' in v and '7' in v:
        ans += 1
    if int(v) >= n:
        print(ans)
        exit() 
    q.append(v+'3')
    q.append(v+'5')
    q.append(v+'7')

Failing test case input:
3738092

Expected output:
1188


Actual output:
1189


Fixed submission (verdict: Accepted):
from collections import deque

n = int(input())
q = deque(['3','5','7'])
ans = 0
l = []
while True:
    v = q.popleft()
    if int(v) >= n:
        if int(v) == n and ('3' in v and '5' in v and '7' in v):
            ans += 1
        print(ans)
        exit() 
    if '3' in v and '5' in v and '7' in v:
        ans += 1
        l.append(int(v))
    q.append(v+'3')
    q.append(v+'5')
    q.append(v+'7')

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


N = int(input())

def dfs(s):
    if int(s) > 0:
        return 0
    ret =1 if all (s.count(c) > 0 for c in '753') else 0
    for c in '753':
        ret += dfs (s+c)
    return ret

print(dfs('0'))




Failing test case input:
9468117

Expected output:
2538


Actual output:
0


Fixed submission (verdict: Accepted):


N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    ret =1 if all (s.count(c) > 0 for c in '753') else 0
    for c in '753':
        ret += dfs (s+c)
    return ret

print(dfs('0'))

Problem: p03212
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools
n = input()
ans = 0

if int(n) < 357:
  print(ans)
else:
  num = "753"
  for x in range(3,len(n)+1):
    for y in itertools.product(num, repeat=x):
      if "7" in y and "5" in y and "3" in y:
        if int("".join(y)) <= int(n):
          ans += 1
print(ans)

Failing test case input:
330

Expected output:
0


Actual output:
0
0


Fixed submission (verdict: Accepted):
import itertools
n = input()
ans = 0

if len(n) < 3 or int(n) <= 356:
  pass
else:
  num = "753"
  for x in range(3,len(n)+1):
    for y in itertools.product(num, repeat=x):
      if "7" in y and "5" in y and "3" in y:
        if int("".join(y)) <= int(n):
          ans += 1
print(ans)