TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
N = int(input())

base = ["3", "5", "7"]
nums = ["3", "5", "7"]
temp = []
x = 0

while 1:
    for num in nums[(3**x)-1:]:
        for b in base:
            temp.append(b + num)
    nums.extend(temp)
    
    x += 1
    if int(temp[-1]) > 10**9:
        break
    temp = []

target = []
for n in set(nums):
    if "7" in n and "5" in n and "3" in n:
        target.append(int(n))

count = 0
target.sort()
for n in target.:
    if int(n) < N:
        count += 1

print(count)

N = int(input())

base = ["3", "5", "7"]
nums = ["3", "5", "7"]
temp = []
x = 0

while 1:
    for num in nums[(3**x)-1:]:
        for b in base:
            temp.append(b + num)
    nums.extend(temp)
    
    x += 1
    if int(temp[-1]) > 10**9:
        break
    temp = []

target = []
for n in set(nums):
    if "7" in n and "5" in n and "3" in n:
        target.append(int(n))

count = 0
for n in target:
    if n <= N:
        count += 1

print(count)

Verdicts: Runtime Error

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
import itertools
N = int(input())
l = len(str(N))
ans = 0
if l < 3:
	pass
else:
	S = []
	for k in range(3,l+1):
		S += list(itertools.product(['3', '5', '7'], repeat=k))
	print(S)
	for i in range(len(S)):
		num = ''
		for t in range(len(S[i])):
			num = num + S[i][t]
		# print(num)
		if '3' in num:
			if '5' in num:
				if '7' in num:
					if int(num) <= N:
						print(num)
						ans += 1
print(ans)


import itertools
N = int(input())
l = len(str(N))
ans = 0
if l < 3:
	pass
else:
	S = []
	for k in range(3,l+1):
		S += list(itertools.product(['3', '5', '7'], repeat=k))
	# print(S)
	for i in range(len(S)):
		num = ''
		for t in range(len(S[i])):
			num = num + S[i][t]
		# print(num)
		if '3' in num:
			if '5' in num:
				if '7' in num:
					if int(num) <= N:
						# print(num)
						ans += 1
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
n = int(input())

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

n = int(input())

def dts(s):
  if int(s) > n:
    return 0
  ret = 1 if all(s.count(_) for _ in '753') else 0
  for i in '753':
    ret += dts(s+i)
  return ret
  
print(dts('0'))


Verdicts: Runtime Error

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
# coding: utf-8
import itertools
N = input()
ans = 0

for i in range(3, len(N)+1):
    for ptn in itertools.product((3,5,7), repeat=i):
        if (3 not in ptn) or (5 not in ptn) or (7 not in ptn):
            continue
        a = int("".join(list(map(str, ptn))))
        if a <= N:
            ans += 1
print(ans)

# coding: utf-8
import itertools
N = int(input())
ans = 0

for i in range(3, len(str(N))+1):
    for ptn in itertools.product((3,5,7), repeat=i):
        if (3 not in ptn) or (5 not in ptn) or (7 not in ptn):
            continue
        a = int("".join(list(map(str, ptn))))
        if a <= N:
            ans += 1
print(ans)

Verdicts: Runtime Error

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
# -*- coding: utf-8 -*-

import time

N = int(input())

all_num_list = []
nums = ["3", "5", "7"]

print(all_num_list)

for a in nums:
    for b in nums:
        for c in nums:
            all_num_list.append(a+b+c)
            for d in nums:
                all_num_list.append(a+b+c+d)
                for e in nums:
                    all_num_list.append(a+b+c+d+e)
                    for f in nums:
                        all_num_list.append(a+b+c+d+e+f)
                        for g in nums:
                            all_num_list.append(a + b + c + d + e + f+g)
                            for h in nums:
                                all_num_list.append(a + b + c + d + e + f + g+h)
                                for i in nums:
                                    all_num_list.append(a+b+c+d+e+f+g+h+i)

cnt = 0
for num in all_num_list:
    if int(num) <= N and "3" in num and "5" in num and "7" in num:
        print(num)
        cnt += 1

print(cnt)

# -*- coding: utf-8 -*-

import time

N = int(input())

all_num_list = []
nums = ["3", "5", "7"]

for a in nums:
    for b in nums:
        for c in nums:
            all_num_list.append(a+b+c)
            for d in nums:
                all_num_list.append(a+b+c+d)
                for e in nums:
                    all_num_list.append(a+b+c+d+e)
                    for f in nums:
                        all_num_list.append(a+b+c+d+e+f)
                        for g in nums:
                            all_num_list.append(a + b + c + d + e + f+g)
                            for h in nums:
                                all_num_list.append(a + b + c + d + e + f + g+h)
                                for i in nums:
                                    all_num_list.append(a+b+c+d+e+f+g+h+i)

cnt = 0
for num in all_num_list:
    if int(num) <= N and "3" in num and "5" in num and "7" in num:
        cnt += 1

print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
# ABC114C - 755
n = input()
digit = len(n)
ans = 0
for i in range(1, digit):
    ans += len([i for i in itertools.product("357", repeat=i) if len(set(i)) == 3])
tup = tuple(i for i in n)
lst = [i for i in itertools.product("357", repeat=digit) if len(set(i)) == 3] + [tup]
lst.sort()
ans += lst.index(tup)
print(ans)

# ABC114C - 755
def shichi_go_san(s="0"):
    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 += shichi_go_san(s + c)
    return ret


n = int(input())
print(shichi_go_san())

Verdicts: Runtime Error

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
n = input()
ans = 10000
for i in range (len(n)-2):
    if abs(int(n[i]+n[i+1]+n[i+2]))<ans:
        ans =abs(int(n[i]+n[i+1]+n[i+2]))
print(ans)
        

n = int(input())
dp = ["3"]
brk = False
for i in range(n):
    if brk == True:
        break
    for c in "357":
        if int(dp[i]+c)>n:
            brk = True
            break
        dp.append(dp[i]+c)
        
dp2 = ["5"]
brk = False
for i in range(n):
    if brk == True:
        break
    for c in "357":
        if int(dp2[i]+c)>n:
            brk = True
            break
        dp2.append(dp2[i]+c)

dp3 = ["7"]
brk = False
for i in range(n):
    if brk == True:
        break
    for c in "357":
        if int(dp3[i]+c)>n:
            brk = True
            break
        dp3.append(dp3[i]+c)

dp = dp+dp2+dp3
count = 0
for i in range(len(dp)):
    if all(dp[i].count(c) for c in "753"):
        count += 1
print(count)

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
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)
    
print(dfs('0'))

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'))


Verdicts: Runtime Error

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
Ns = input()
N = int(Ns)
Nl = len(Ns)
ret = 0
def doit(t, f , s, now):
    if t + f + s == 0:
        if int(now) <= N:
            ret += 1
        return
    if t > 0:
        doit(t - 1, f, s, now + str(3)) 
    if f > 0:
        doit(t, f - 1, s, now + str(5)) 
    if s > 0:
        doit(t, f, s - 1, now + str(7)) 
    
for seven in range(1, Nl - 1):
    for five in range(1, Nl - seven):
        least = Nl - seven - five
        for three in range(1, least + 1):
            doit(three, five, seven, '')

print(ret)


Ns = input()
N = int(Ns)
Nl = len(Ns)
ret = 0
def doit(t, f , s, now):
    global ret
    if t + f + s == 0:
        if int(now) <= N:
            ret += 1
        return
    if t > 0:
        doit(t - 1, f, s, now + str(3)) 
    if f > 0:
        doit(t, f - 1, s, now + str(5)) 
    if s > 0:
        doit(t, f, s - 1, now + str(7)) 
    
for seven in range(1, Nl - 1):
    for five in range(1, Nl - seven):
        least = Nl - seven - five
        for three in range(1, least + 1):
            doit(three, five, seven, '')

print(ret)


Verdicts: Runtime Error

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
def C3():
    tmp = []
    import  copy

    for i in range(9):
        tmp.append([])
        tmp[i].append(3 * pow(10, i))
        tmp[i].append(5 * pow(10, i))
        tmp[i].append(7 * pow(10, i))

    tmp2 = [copy.copy(tmp[0])]
    for i in range(1, 9):
        tmp2.append([])
        for j in range(3):
            k = 0
            while True:
                if len(tmp2[i - 1]) <= k:
                    break
                tmp2[i].append(tmp[i][j] + tmp2[i - 1][k])
                k += 1
    tmp3 = 

def C3():
    N = int(input())
    def make_list(s):
        S = [s]
        if int(s) <= N:
            S.extend(make_list(s + "3"))
            S.extend(make_list(s + "5"))
            S.extend(make_list(s + "7"))
        return S

    datalist = make_list("0")

    ans = 0
    for i in datalist:
        s = 0
        f = 0
        t = 0
        for j in list(i):
            print(j)
            if j == "7":
                s = 1
            if j == "5":
                f = 1
            if j == "3":
                t = 1
        if s + f + t == 3 and int(i) <= N:
            ans += 1
    print(ans)
C3()

def C3():
    N = int(input())
    def make_list(s):
        S = [s]
        if int(s) <= N:
            S.extend(make_list(s + "3"))
            S.extend(make_list(s + "5"))
            S.extend(make_list(s + "7"))
        return S

    datalist = make_list("0")

    ans = 0
    for i in datalist:
        s = 0
        f = 0
        t = 0
        for j in list(i):
            if j == "7":
                s = 1
            if j == "5":
                f = 1
            if j == "3":
                t = 1
        if s + f + t == 3 and int(i) <= N:
            ans += 1
    print(ans)
C3()


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
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)


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)



Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
n = input()
digit = len(n)
a753 = 0
a75 = 0
a73 = 0
a53 = 0
now = 0
i = digit - 1
# now + i = digit - 1
while now < digit:
  tmp = int(n[i])
  add = 3 ** now
  sun = (3 ** (now+1) - 3) // 2
  add2 = 2 ** now
  sun2 = 2 ** (now+1) - 2
  if tmp == 8 or tmp == 9:
    a753 = sun + 3 * add
    a75 = sun2 + 2 * add2
    a73 = sun2 + 2 * add2
    a53 = sun2 + 2 * add2
  elif tmp == 7:
    a753 += 3 * add
    a75 += 2 * add2
    a73 += 2 * add2
    a53 = sun2 + 2 * add2
  elif tmp == 6:
    a753 = sun + 2 * add
    a75 = sun2 + 1 * add2
    a73 = sun2 + 1 * add2
    a53 = sun2 + 2 * add2
  elif tmp == 5:
    a753 += 2 * add
    a75 += 1 * add2
    a73 = sun2 + 1 * add2
    a53 += 2 * add2
  elif tmp == 4:
    a753 = sun + 1 * add
    a75 = sun2 + 0 * add2
    a73 = sun2 + 1 * add2
    a53 = sun2 + 1 * add2
  elif tmp == 3:
    a753 += 1 * add
    a75 = sun2 + 0 * add2
    a73 += 1 * add2
    a53 += 1 * add2
  elif tmp == 2 or tmp == 1:
    a753 = sun + 0 * add
    a75 = sun2 + 0 * add2
    a73 = sun2 + 0 * add2
    a53 = sun2 + 0 * add2
    a = 3 * now - 3
  now += 1
  i -= 1
all1 = (10 ** digit - 1) // 9
a = 3 * digit
if int(n) < 7 * all1:
  a -= 1
if int(n) < 5 * all1:
  a -= 1
if int(n) < 3 * all1:
  a -= 1
print(a753,a75,a73,a53,a)
print(a753 - a75 - a73 - a53 +a)

n = input()
digit = len(n)
a753 = 0
a75 = 0
a73 = 0
a53 = 0
now = 0
i = digit - 1
# now + i = digit - 1
while now < digit:
  tmp = int(n[i])
  add = 3 ** now
  sun = (3 ** (now+1) - 3) // 2
  add2 = 2 ** now
  sun2 = 2 ** (now+1) - 2
  if tmp == 8 or tmp == 9:
    a753 = sun + 3 * add
    a75 = sun2 + 2 * add2
    a73 = sun2 + 2 * add2
    a53 = sun2 + 2 * add2
  elif tmp == 7:
    a753 += 3 * add
    a75 += 2 * add2
    a73 += 2 * add2
    a53 = sun2 + 2 * add2
  elif tmp == 6:
    a753 = sun + 2 * add
    a75 = sun2 + 1 * add2
    a73 = sun2 + 1 * add2
    a53 = sun2 + 2 * add2
  elif tmp == 5:
    a753 += 2 * add
    a75 += 1 * add2
    a73 = sun2 + 1 * add2
    a53 += 2 * add2
  elif tmp == 4:
    a753 = sun + 1 * add
    a75 = sun2 + 0 * add2
    a73 = sun2 + 1 * add2
    a53 = sun2 + 1 * add2
  elif tmp == 3:
    a753 += 1 * add
    a75 = sun2 + 0 * add2
    a73 += 1 * add2
    a53 += 1 * add2
  else:
    a753 = sun + 0 * add
    a75 = sun2 + 0 * add2
    a73 = sun2 + 0 * add2
    a53 = sun2 + 0 * add2
    a = 3 * now - 3
  now += 1
  i -= 1
all1 = (10 ** digit - 1) // 9
a = 3 * digit
if int(n) < 7 * all1:
  a -= 1
if int(n) < 5 * all1:
  a -= 1
if int(n) < 3 * all1:
  a -= 1
#print(a753,a75,a73,a53,a)
print(a753 - a75 - a73 - a53 +a)

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
n = int(input())
sft(n, "", "3")
sft(n, "", "5")
sft(n, "", "7")
le = []
for i in range(len(l)):
    c3 = str(l[i]).count("3")
    c5 = str(l[i]).count("5")
    c7 = str(l[i]).count("7")
    if c3 > 0 and c5 > 0 and c7 > 0:
        le.append(l[i])
print(len(list(set(le))))

def sft(n, num, add):
    int_sft = int(num+add)
    if int_sft > n:
        return True
    else:
        l.append(int_sft)
        sft(n, num+add, "3")
        sft(n, num+add, "5")
        sft(n, num+add, "7")

l=[]
n = int(input())
sft(n, "", "3")
sft(n, "", "5")
sft(n, "", "7")
le = []
for i in range(len(l)):
    c3 = str(l[i]).count("3")
    c5 = str(l[i]).count("5")
    c7 = str(l[i]).count("7")
    if c3 > 0 and c5 > 0 and c7 > 0:
        le.append(l[i])
print(len(list(set(le))))

Verdicts: Runtime Error

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
#include <bits/stdc++.h>
using namespace std;

int n;
int lim;
vector<string> A;

void f(int digitNum, string s){ 
    vector<bool> J(3, false);
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '3') J[0] = true;
        if(s[i] == '5') J[1] = true;
        if(s[i] == '7') J[2] = true;
    }
    int idx = find(J.begin(), J.end(), false) - J.begin();
    if(idx == 3){
        A.push_back(s);
    }
    if(digitNum == lim){
        return;
    }
    f(digitNum + 1, s + '3');
    f(digitNum + 1, s + '5');
    f(digitNum + 1, s + '7');
    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    
    lim = to_string(n).length();
    
    if(lim < 3){
        cout << 0 << endl;
        return 0;
    }

    f(0, "");

    vector<int> B(A.size());
    for(int i = 0; i < A.size(); i++){
        B[i] = stoi(A[i]);
    }

    sort(B.begin(), B.end());

    int idx = lower_bound(B.begin(), B.end(), n) - B.begin();

    cout << idx + (B[idx] == n) << endl;

    return 0;
}

A = []
str = "357"
lim = 11

def dfs(bef, sz):
    if sz + 1 == lim:
        return
    for i in str:
        t = bef + i
        A.append(t)
        dfs(t, sz + 1)

def main():
    n = int(input())

    dfs("", 0)

    ans = 0

    for a in A:
        q = False
        w = False
        e = False
        for i in a:
            if i == '3':
                q = True
            elif i == '5':
                w = True
            elif i == '7':
                e = True
        if q and w and e:      
            ai = int(a)
            if ai <= n:
                ans += 1

    print(ans)

main()

Verdicts: Runtime Error

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
n = input()
a = "357"
count357 = ["3", "5", "7"]
i = 0
while int(count357[-1]) <= int(n):
    for j in range(3):
        count357.append(str(int(count357[i])*10 + int(count357[j])))
        if int(count357[-1]) > int(n):
            break
    i += 1
count357.pop(-1)
count = 0
for i in range(len(count357)):
    for j in range(len(a)):
        if a[j] not in count357[i]:
            continue
    else:
        count += 1

print(count)

n = input()
count357 = ["3", "5", "7"]
i = 0
while int(count357[-1]) <= int(n):
    for j in range(3):
        count357.append(str(int(count357[i])*10 + int(count357[j])))
        if int(count357[-1]) > int(n):
            break
    i += 1
count357.pop(-1)
count = 0
for i in range(len(count357)):
    count += 1 if "3" in count357[i] and "5" in count357[i] and "7" in count357[i] else 0

print(count)

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
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 ])

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 = [i for i in can_l if i <= num]
print(count)

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)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
from collections import deque
n = int(input())
num753 = set()
q = deque([3,5,7])


while q:

    
    x = q.pop()

    
    if x <= 10**9:

        
        num753.add(x)

        
        q.append(x*10+3)
        q.append(x*10+5)
        q.append(x*10+7)
count = 0


for i in num753:
    if i <= n:
        lst = list(str(i))
        print(lst)
        if "3" in lst and "5" in lst and "7" in lst:
            count += 1
            
print(count)

from collections import deque
n = int(input())
num753 = set()
q = deque([3,5,7])


while q:

    
    x = q.pop()

    
    if x <= 10**9:

        
        num753.add(x)

        
        q.append(x*10+3)
        q.append(x*10+5)
        q.append(x*10+7)
count = 0


for i in num753:
    if i <= n:
        lst = list(str(i))
        if "3" in lst and "5" in lst and "7" in lst:
            count += 1

print(count)

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
N = int(input())
n = len(str(N))

def count_753(n):
    if n == 3:
        return (6, 18, 3)
    else:
        num_753 = count_753(n-1)[0] * 3 + count_753(n-1)[1]
        num_75 = count_753(n-1)[1] * 2 + count_753(n-1)[2] * 2
        return (num_753, num_75, 3)

if n <= 2:
    print(0)
else:
    count = 0
    for i in range(3, n+1):
        count += count_753(i)[0]
    #print('count :', count)

    for i in itertools.product(['7', '5', '3'], repeat=n):
        if len(set(i)) <= 2:
            continue
        s = 0
        for j,k in zip(range(n), reversed(range(n))):
            s += int(i[j]) * (10**k)
        if s > N:
            count -= 1
    
    print(count)

import itertools

N = int(input())
n = len(str(N))

def count_753(n):
    if n == 3:
        return (6, 18, 3)
    else:
        num_753 = count_753(n-1)[0] * 3 + count_753(n-1)[1]
        num_75 = count_753(n-1)[1] * 2 + count_753(n-1)[2] * 2
        return (num_753, num_75, 3)

if n <= 2:
    print(0)
else:
    count = 0
    for i in range(3, n+1):
        count += count_753(i)[0]
    #print('count :', count)

    for i in itertools.product(['7', '5', '3'], repeat=n):
        if len(set(i)) <= 2:
            continue
        s = 0
        for j,k in zip(range(n), reversed(range(n))):
            s += int(i[j]) * (10**k)
        if s > N:
            count -= 1
    
    print(count)

Verdicts: Runtime Error

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
n = int(input())
s = "0357"
ans = []
for a in s:
    for b in s:
        for c in s:
            for d in s:
                for e in s:
                    for f in s:
                        for g in s:
                            for h in s:
                                for i in s:
                                    for j in s:
                                        for k in s:
                                            o = int(a+b+c+d+e+f+g+h+i+j+k)
                                            if set(str(o)) == {"3","5","7"}:
                                                if o > n:
                                                    break
                                                else:
                                                    ans.append(o)
print(len(ans))
                                             

import itertools
n = input()
ans = 0
for i in range(3, len(n)+1):
    ans += len([f for f in itertools.product("357", repeat=i) if len(set(f)) == 3 and int("".join(f)) <= int(n)])

print(ans)


Verdicts: Time Limit Exceeded

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
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))

N = input()

def f(s):
    if int(s) > int(N):
        return 0
    for t in '3','5','7':
        if all(['3' in s,'5' in s,'7' in s]):
            ans.append(1)
        f(s+t)

ans=[]
f('0')
print(sum(ans)//3)

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
N = 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')) #

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')) #

Verdicts: Runtime Error

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
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 s:
    ret += dfs(s + c)
  return ret

print(dfs('0'))

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'))

Verdicts: Runtime Error

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
import math
print(math.factorial(5))

s = input()
n = int(s)
dg = len(s)

all_list = []

for i in '753':
    for j in '753':
        for k in '753':
            all_list.append(''.join([i,j,k]))

for i in range(4,dg+1):
    add_list = []
    for c in '753':
        add_list += [''.join(c+e) for e in all_list]
    all_list += add_list

all_list = set(all_list)
res = sum([True for _ in all_list if set(list(_))=={'7','5','3'} and int(_) <= n])
print(res)



Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
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'))

from collections import Counter
n = int(input())
ans = 0
def dfs(A):
    if A and int(A) > n:
        return
    if len(A) >= 3:
        c = Counter(A)
        is753 = True
        for i in ['7','5','3']:
            if c[i] < 1:
                is753 = False
        if is753:
            global ans 
            ans += 1
    for nex in ['7','5','3']:
        A += nex
        dfs(A)
        A = A[:-1]
dfs('')
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
import sys
sys.setrecursionlimit(10**5)
N = int(input())

def rec(num, use, cnt):
    if num > N:
        return cnt-1

    if (use == 0b111):
        cnt += 1

    return rec(num*10+7, use | 0b100, cnt)\
         + rec(num*10+5, use | 0b010, cnt)\
         + rec(num*10+3, use | 0b001, cnt)

print(rec(0,0,0))


import sys
sys.setrecursionlimit(10**5)
N = int(input())

def rec(num='0',cnt=0):
    if int(num) > N:
        return cnt

    if '7' in num and '5' in num and '3' in num:
        cnt += 1

    return rec('7'+num, cnt) + rec('5'+num, cnt) + rec('3'+num, cnt)

print(rec())


import sys
sys.setrecursionlimit(10**5)
N = int(input())

def rec(num, use, cnt):
    if num > N:
        return cnt

    if (use == 0b111):
        cnt += 1

    return rec(num*10+7, use | 0b100, cnt)\
         + rec(num*10+5, use | 0b010, cnt)\
         + rec(num*10+3, use | 0b001, cnt)

print(rec(0,0,0))


import sys
sys.setrecursionlimit(10**5)
N = int(input())

def rec(num ,cnt=0):
    if int(num) > N:
        return cnt

    if '7' in num and '5' in num and '3' in num:
        cnt += 1

    return rec('7'+num, cnt) + rec('5'+num, cnt) + rec('3'+num, cnt)

print(rec('7')+rec('5')+rec('3'))


import sys
sys.setrecursionlimit(10**5)
N = int(input())

def rec(num, use, cnt):
    if num > N:
        return cnt

    if (use == 0b111):
        cnt = 1

    return rec(num*10+7, use | 0b100, cnt)\
         + rec(num*10+5, use | 0b010, cnt)\
         + rec(num*10+3, use | 0b001, cnt)

print(rec(0,0,0))


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])


import sys
sys.setrecursionlimit(10**5)
N = int(input())

def rec(num, use, cnt):
    if num > N:
        return cnt

    if (use == 0b111):
        cnt += 1

    return rec(num*10+7, use | 0b100, cnt)\
        + rec(num*10+5, use | 0b100, cnt)\
        + rec(num*10+3, use | 0b100, cnt)

print(rec(0,0,0))


import sys
sys.setrecursionlimit(10**5)
N = int(input())

def rec(num, use):
    if num > N:
        return 0

    i = 0
    if (use == 0b111):
        i = 1

    return rec(num*10+7, use | 0b100)\
         + rec(num*10+5, use | 0b010)\
         + rec(num*10+3, use | 0b001)\
         + i

print(rec(0,0))


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
N = [0] + [int(x) for x in list(input())] 
print(N)

def dfs(L):
    global N
    if len(L) == len(N):
        if L.count(7) > 0 and L.count(5) > 0 and L.count(3) > 0:
            return 1
        else:
            return 0

    i = len(L) - 1  
    ans = 0
    if L[i] == N[i]:    
        next = []
        if i == 0:  
            for j in [0, 3, 5, 7]:
                if j <= N[i + 1]:
                    next.append(j)
        else:
            for j in [3, 5, 7]:
                if j <= N[i + 1]:
                    next.append(j)
    elif L[i] == 0:
        next = [0, 3, 5, 7]
    else:
        next = [3, 5, 7]

    for j in next:
        ans += dfs(L + [j])

    return ans

print(dfs([0]))

N = [int(x) for x in list(input())] 

def dfs(L):
    global N
    if len(L) == len(N):
        if L.count(7) > 0 and L.count(5) > 0 and L.count(3) > 0:
            return 1
        else:
            return 0

    ans = 0
    if len(L) == 0 or L[-1] == 0:
        ans += dfs(L + [0])
    for j in [3, 5, 7]:
        ans += dfs(L + [j])
    return ans

print(dfs([]))

def dfs(L):
    global N, ans
    ret = 0
    if all([L.count(i) for i in ["3", "5", "7"]]):
        ret += 1
    for j in ["3", "5", "7"]:
        if int(L + j) <= int(N):
            ret += dfs(L + j)
    return ret

N = input()
print(dfs(''))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
import itertools as itt

N = input()

def check(snum):
    three = snum.count("3")
    five = snum.count("5")
    seven = snum.count("7")
    if (three == 0 or five == 0 or seven == 0) or (int(snum) > int(N)): return False
    else: return True

C = ["3", "5", "7"] #choice
digit = len(N)
cnt = 0
for d in range(3, digit+1): 
    L = list(itt.product(C, repeat=d))
    for l in L:
        gen = "".join(l)
        if check(gen):
            print(gen)
            cnt += 1

print(cnt)

import sys
n = input()
cnt = 0
for i in range(int(n)):
    three = str(i).count("3")
    five = str(i).count("5")
    seven = str(i).count("7")
    if three == 0 or five == 0 or seven == 0:
        pass
    elif len(str(i)) != three + five + seven:
        pass
    else:
        print(i)
        cnt += 1

print(cnt)

import itertools as itt

N = input()

def check(snum):
    three = snum.count("3")
    five = snum.count("5")
    seven = snum.count("7")
    if (three == 0 or five == 0 or seven == 0) or (int(snum) > int(N)): return False
    else: return True

C = ["3", "5", "7"] #choice
digit = len(N)
cnt = 0
for d in range(3, digit+1): 
    L = list(itt.product(C, repeat=d))
    for l in L:
        gen = "".join(l)
        if check(gen):
            #print(gen)
            cnt += 1

print(cnt)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
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)


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)


Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
import itertools
N = int(input())
combi = []
l = []
count = 0

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
print(dfs('0'))


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'))

Verdicts: Runtime Error

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
N = int(input())
l = len(str(N))

def make753(num, l, list753):
    if l == 0:
        if '3' in num and '5' in num and '7' in num and int(num) <= N:
            print(int(num))
            list753.append(int(num))
    else:
        make753(num + '3', l-1, list753)
        make753(num + '5', l-1, list753)
        make753(num + '7', l-1, list753)
    return list753

L = []
for l in range(3, l+1):
    L += make753('', l, [])
print(len(L))

N = int(input())
l = len(str(N))

def make753(num, l, list753):
    if l == 0:
        if '3' in num and '5' in num and '7' in num and int(num) <= N:
            list753.append(int(num))
    else:
        make753(num + '3', l-1, list753)
        make753(num + '5', l-1, list753)
        make753(num + '7', l-1, list753)
    return list753

L = []
for l in range(3, l+1):
    L += make753('', l, [])
print(len(L))

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
N = int(input())
s=['0','3','5','7']
must = ['3','5','7']
count = 0
for i_9 in range (4):
    for i_8 in range (4):
        for i_7 in range (4):
            for i_6 in range (4):
                for i_5 in range (4):
                    for i_4 in range (4):
                        for i_3 in range (4):
                            for i_2 in range (4):
                                for i_1 in range (4):
                                    num =s[i_9]+s[i_8]+s[i_7]+s[i_6]+s[i_5]+s[i_4]+s[i_3]+s[i_2]+s[i_1]
                                    num = int(''.join(list(map(str,num))))
                                    if (num<=N) & ('0' not in list(str(num))) & ('3' in list(str(num))) & ('5' in list(str(num))) & ('7' in list(str(num))) :
                                        count +=1
                                        
count

N = int(input())
s=['0','3','5','7']
must = ['3','5','7']
count = 0
for i_9 in range (4):
    for i_8 in range (4):
        for i_7 in range (4):
            for i_6 in range (4):
                for i_5 in range (4):
                    for i_4 in range (4):
                        for i_3 in range (4):
                            for i_2 in range (4):
                                for i_1 in range (4):
                                    num =s[i_9]+s[i_8]+s[i_7]+s[i_6]+s[i_5]+s[i_4]+s[i_3]+s[i_2]+s[i_1]
                                    num = int(''.join(list(map(str,num))))
                                    if (num<=N) & ('0' not in list(str(num))) & ('3' in list(str(num))) & ('5' in list(str(num))) & ('7' in list(str(num))) :
                                        count +=1
                                        
print(count)


Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
from itertools import product

n = int(input())

tfs = set()
for i in range(1,10):
    tfs |= set(product(['3', '5', '7'], repeat=i))

cnt = 0
for l in tfs:
    if ('3' in l) and ('5' in l) and ('7' in l): 
        num = int(''.join(l))
        if num <= n:
            print(num)
            cnt += 1
print(cnt)


from itertools import product

n = int(input())

tfs = set()
for i in range(1,10):
    tfs |= set(product(['3', '5', '7'], repeat=i))

cnt = 0
for l in tfs:
    if ('3' in l) and ('5' in l) and ('7' in l):
        num = int(''.join(l))
        if num <= n:
            cnt += 1
print(cnt)


Verdicts: Wrong Answer

Accepted
Problem: You are given an integer N. Among the integers between 1 and N (inclusive), how many _Shichi-Go-San numbers_ (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:    * When the number is written in base ten, each of the digits `7`, `5` and `3` appears at least once, and the other digits never appear.

Submission attempts (in order):
cnt = 0

def main():
    n = int(input())
    m = len(str(n))
    nl = len(str(n))

    def cal(A):
        l = len(A) - 1
        ans = 0
        for idx, i in enumerate(A):
            ans += i*10**(l - idx)
        return ans

    def dfs(A):
        global cnt
        if len(A) == m:
            if len(list(set(A) & set([3, 5, 7]))) == 3:
                if (cal(A)) <= n:
                    print(cal(A))
                    cnt += 1
            return
        for i in (3, 5, 7):
            A.append(i)
            dfs(A)
            A.pop()
    for m in range(nl+1):
         dfs([])
    print(cnt)

if __name__ == '__main__':
    main()

cnt = 0

def main():
    n = int(input())
    m = len(str(n))
    nl = len(str(n))

    def cal(A):
        l = len(A) - 1
        ans = 0
        for idx, i in enumerate(A):
            ans += i*10**(l - idx)
        return ans

    def dfs(A):
        global cnt
        if len(A) == m:
            if len(list(set(A) & set([3, 5, 7]))) == 3:
                if (cal(A)) <= n:
                    # print(cal(A))
                    cnt += 1
            return
        for i in (3, 5, 7):
            A.append(i)
            dfs(A)
            A.pop()
    for m in range(nl+1):
         dfs([])
    print(cnt)

if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Accepted