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):
import itertools
N = int(input())
count = 0
for i in range(3, len(str(N)) + 1):
    for j in itertools.product('753', repeat=i):
        if int(''.join(j)) =< N and '3' in str(j) and '5'in str(j) and '7' in str(j):
            count += 1

print(count)


N = int(f.input())
count = 0

for i in range(len(str(N))):
    for j in range(3 * (10**i), 4 * (10**i)):
        if j > N:
            break
        if '0' not in str(j) and '1' not in str(j) and '2' not in str(j) and '4' not in str(j) and '6' not in str(
                j) and '8' not in str(j) and '9' not in str(j) and('7' in str(j) and '5' in str(j) and '3' in str(j)):
            print(j)
            count += 1
    for j in range(5 * (10**i), 6 * (10**i)):
        if j > N:
            break

        if '0' not in str(j) and '1' not in str(j) and '2' not in str(j) and '4' not in str(j) and '6' not in str(
                j) and '8' not in str(j) and '9' not in str(j) and('7' in str(j) and '5' in str(j) and '3' in str(j)):
            print(j)
            count += 1

    for j in range(7 * (10**i), 8 * (10**i)):
        if j > N:
            break
        if '0' not in str(j) and '1' not in str(j) and '2' not in str(j) and '4' not in str(j) and '6' not in str(
                j) and '8' not in str(j) and '9' not in str(j) and('7' in str(j) and '5' in str(j) and '3' in str(j)):
            print(j)
            count += 1
    else:
        continue
    break

print(count)




import itertools
N = int(input())
count = 0
for i in range(3, len(str(N)) + 1):
    for j in itertools.product('753', repeat=i):
        if int(''.join(j)) <= N and '3' in str(j) and '5'in str(j) and '7' in str(j):
            count += 1

print(count)


Verdicts: Runtime Error

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):
ans = 0
n = int(input())
for i in range(n):
  s = str(i)
  if s.count('7')+s.count('5')+s.count('3') == int(s):
    ans += 1
print(ans)


ans = 0
n = int(input())
if n < 357:
  print(0)
else:
  for i in range(n):
    s = str(i)
    if s.count('7')+s.count('5')+s.count('3') == len(s):
    ans += 1
print(ans)


ans = 0
for i in range(n+1):
  s = str(input())
  if s.count('7')+s.count('5')+s.count('3') == int(s):
    ans += 1
print(ans)


ans = 0
for i in range(n+1):
  s = list(str(input()))
  if s.count('7')+s.count('5')+s.count('3') == int(s):
    ans += 1
print(ans)

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

ans = 0
for i in range(n+1):
  s = str(i)
  if s.count('7')+s.count('5')+s.count('3') == int(s):
    ans += 1
print(ans)


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: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

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 collections

n = int(input())
count = 0

for i in range(1, n + 1):
	c = collections.Counter(list(str(i)))
	if len(c.keys()) == 3:
		print(c)
		if (c['3'] != 0) and (c['5'] != 0) and (c['7'] != 0):
			count += 1
print(count)

n = int(input())
count = 0

def dfs(s):
	if int(s) > n:
		return 0
	if all(s.count(c) > 0 for c in '357'):
		count = 1
	else:
		count = 0
	count += dfs(s + '3')
	count += dfs(s + '5')
	count += dfs(s + '7')
	return count

print(dfs('0'))

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


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):
def to3(x,n):
  if (int(x/n)):
    return to3(int(x/n),n) + str(x%n)
  return str(x%n)
ch = ["3","5","7"]
ans = 0
for i in range(3 ** len(str(num))+1):
  s = to3(i,3)
  for u in range(len(str(num))-len(s)+2):
    if u > 0:
      s = "0" + s
    k1 = 0
    k2 = 0
    k3 = 0
    ss = ""
    for j in range(len(s)):
      if s[j] == "0":k1 = 1
      elif s[j] == "1":k2 = 1
      else: k3 = 1
      ss += ch[int(s[j])]
    if k1 and k2 and k3 and int(ss) <= num:ans += 1
print(ans)

num = int(input())
def to3(x,n):
  if (int(x/n)):
    return to3(int(x/n),n) + str(x%n)
  return str(x%n)
ch = ["3","5","7"]
ans = 0
for i in range(3 ** len(str(num))+1):
  s = to3(i,3)
  for u in range(len(str(num))-len(s)+2):
    if u > 0:
      s = "0" + s
    k1 = 0
    k2 = 0
    k3 = 0
    ss = ""
    for j in range(len(s)):
      if s[j] == "0":k1 = 1
      elif s[j] == "1":k2 = 1
      else: k3 = 1
      ss += ch[int(s[j])]
    if k1 and k2 and k3 and int(ss) <= num: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):
n = int(input())

count = 0
def dfs(x):
    global count
    if int(x) > n:
        return 0
    
    for i in ('753'):
        dfs(x+i)
    
    check =  True
    for j in ('753'):
        if x.find(j) == -1:
            check = False
    if check:
        count += 1
        
    return count
dfs('0')

n = int(input())

count = 0
def dfs(x):
    global count
    if int(x) > n:
        return 0
    
    for i in ('753'):
        dfs(x+i)
    
    check =  True
    for j in ('753'):
        if x.find(j) == -1:
            check = False
    if check:
        count += 1
        
    return count
print(dfs('0'))

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 f(x):
    if int(x) > N:
        return 0
    else:
        if all(x.count(j) >= 1 for j in [3, 5, 7]):
            ans = 1
        for i in [3, 5, 7]:
            ans += f(x+i)    
        return ans        

print(f("0"))

from itertools import product

N = int(input())
ans = 0
for i in product("357", repeat=N):
    x = "".join(i)
    if 357 <= int(x) <= N and len(set(x)) = 3:
        ans += 1
print(ans)

N = int(input())

def f(x):
    if int(x) > N:
        return 0
    else:
        if all(x.count(j) >= 1 for j in ["3", "5", "7"]):
            ans = 1
        else:
            ans = 0
        for i in ["3", "5", "7"]:
            ans += f(x+i)    
        return ans        

print(f("0"))

Verdicts: Runtime Error

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 sys

sys.setrecursionlimit(10 ** 9)
N = input()
N_len = len(N)
'''
75333
'''


# t = []


def dfs(a, depth):
    if depth == N_len:
        if int(a) <= int(N) and a.count('3') > 0 \
                and a.count('5') > 0 and a.count('7') > 0 and str(int(a)).count('0') == 0:
            t.append(a)
            return 1
        else:
            return 0

    ret1 = dfs(a + '0', depth + 1)
    ret2 = dfs(a + '3', depth + 1)
    ret3 = dfs(a + '5', depth + 1)
    ret4 = dfs(a + '7', depth + 1)
    return ret1 + ret2 + ret3 + ret4


ans = dfs('', 0)
print(ans)
# print(t)


S = input()



N = len(S)
list375 =['3','5','7']
if N <  3:
    print(0)
    exit(0)

for i in range(N + 1):
    if i ==0:
        continue
    else:
        targetList = list375[:]
        for l in targetList:
            print(l)
            list375.append(l + '3')
            list375.append(l + '5')
            list375.append(l + '7')

result = [i for i in list(set(list375)) if int(i) < int(S) and i.count('3') !=0 and i.count('5') !=0 and i.count('7') !=0]
#print(result)
print(len(result))


'''
def judge753():
    if keta[0] < 3:
        return 0
    if keta[0] < 5:
        if keta[1] < 3:
            return 0
        if keta[1] < 5:
            if keta[2] < 5:
                return 0
            if keta[2] < 7:
                return 1
            return 2
        if keta[1] < 7:
            
        return sum[len(S)-1]
    if keta[0] < 7:
        if keta[1] < 3:
            return sum[len(S)-1] + sum[len(S)-2]
        if keta[1] < 5:
            if keta[2] < 5:
        
        return sum[len(S)-1]
        
print(min(absList))
'''


import sys

sys.setrecursionlimit(10 ** 9)
N = input()
N_len = len(N)
'''
75333
'''


# t = []


def dfs(a, depth):
    if depth == N_len:
        if int(a) <= int(N) and a.count('3') > 0 \
                and a.count('5') > 0 and a.count('7') > 0 and str(int(a)).count('0') == 0:
            return 1
        else:
            return 0

    ret1 = dfs(a + '0', depth + 1)
    ret2 = dfs(a + '3', depth + 1)
    ret3 = dfs(a + '5', depth + 1)
    ret4 = dfs(a + '7', depth + 1)
    return ret1 + ret2 + ret3 + ret4


ans = dfs('', 0)
print(ans)
# print(t)


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):
from itertools import product

# 10 ** 9
l753 = []
for i in range(3, 10):
    l = ['753'] * i
    for s in product(*l):
        if '7' in s and '3' in s and '5' in s:
            l753.append(int("".join(s)))
sorted(l753)
N = int(input())
count = 0
for i in l753:
    if i > N:
        break
    count += 1
print(count)



from itertools import product

# 10 ** 9
l753 = []
for i in range(3, 10):
    l = ['753'] * i
    for s in product(*l):
        if '7' in s and '3' in s and '5' in s:
            l753.append(int("".join(s)))
l753 = sorted(l753)
N = int(input())
count = 0
for i in l753:
    if i > N:
        break
    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(now_s,digit,n,ans_sum):
    ans = 0
    if len(now_s)<digit:
        for i in ["3","5","7"]:
            now_s.append(i)
            if "3" in now_s and "5" in now_s and "7" in now_s and eval("".join(now_s)) <= n:
                ans = 1
                print(now_s)
            return(ans+dfs(now_s,digit,n,ans_sum))
    return ans_sum

now_s = []
ls_753 = [0,0,0]
digit = len(str(n))
ans = 0
print(dfs(now_s,digit,n,ans))


def dfs(n,a,s):
    global ans
    temp = int(s)
    if temp > n:
        return
    if "7" in s and "5" in s and "3" in s and n>=temp:
        ans += 1
    for i in a:
        dfs(n,a,s+i)
ans = 0
a = ["7","5","3"]
n = int(input())
s = "0"
dfs(n,a,s)
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):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
/* TLEだった orz 
int main() {
  ll N; cin >> N;
  ll val = 357, cnt = 0;
  while (N >= val) {
    string s = to_string(val);
    bool three=false,five=false,seven=false,ok=true;
    for(int i=0; i < s.size(); i++) {
      if(s[i]=='3')three=true;
      else if(s[i]=='5')five=true;
      else if(s[i]=='7')seven=true;
      else ok = false;
    }
    if(three&&five&&seven&&ok){
      cnt++;
      //cout<<"s = "<<s<<endl;
      //printf("cnt=%d\n",cnt);
    }
    val++;
  }
  cout << cnt << endl;
} 
*/
int N, ans;
void dfs(ll x,bool flag3,bool flag5,bool flag7) {
    if(x > N) {
        return ;
    }
    if(flag3 && flag5 && flag7) {
        ans++;
    }
    dfs(x*10+3, true, flag5, flag7);
    dfs(x*10+5, flag3, true, flag7);
    dfs(x*10+7, flag3, flag5, true);
}
int main() {
    cin >> N;
    dfs(0,0,0,0);
    cout << ans << endl;
}

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())
import bisect
import itertools
ans=[]
num=[]
for i in range(3,l+1):
    m=list(itertools.product(x, repeat=i))
    num.extend(m)
for i in range(len(num)):
    y=num[i]
    if '3' in y and '5' in y and '7' in y:
        number=''
        for j in range(len(y)):
            number+=y[j]
        ans.append(int(number))
ans.sort()
print(bisect.bisect_left(ans, n))

n=int(input())
import bisect
import itertools
l=len(str(n))
ans=[]
num=[]
for k in range(3,l+1):
    m=list(itertools.product(x, repeat=k))
    num.extend(m)
for i in range(len(num)):
    y=num[i]
    if '3' in y and '5' in y and '7' in y:
        number=''
        for j in range(len(y)):
            number+=y[j]
        ans.append(int(number))
ans.sort()
print(bisect.bisect_left(ans, n))

n=int(input())
import bisect
import itertools
l=len(str(n))
ans=[]
num=[]
x=['3', '5', '7']
for k in range(3,l+1):
    m=list(itertools.product(x, repeat=k))
    num.extend(m)
for i in range(len(num)):
    y=num[i]
    if '3' in y and '5' in y and '7' in y:
        number=''
        for j in range(len(y)):
            number+=y[j]
        ans.append(int(number))
ans.sort()
print(bisect.bisect_right(ans, n))

Verdicts: Runtime Error

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())
print([n for n in range(N) if(str(n) in "7" and str(n) in "5" and str(n) in "3")])

N = int(input())

def dfs(n, is3, is5, is7):
    if(n > N): 
        return 0
    ans = 0
    if(is3 and is5 and is7): ans += 1
    ans += dfs(n * 10 + 3, True, is5, is7)
    ans += dfs(n * 10 + 5, is3, True, is7)
    ans += dfs(n * 10 + 7, is3, is5, True)
    return ans

if __name__ == "__main__":
    print(dfs(0, False, False, False))



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

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

pritn(cnt('0'))

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

Verdicts: Wrong Answer

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

i = 357
count = 0
if 357 <= N:
    while(1):
        flag = 0
        flag7 = 0
        flag5 = 0
        flag3 = 0

        for j,s in enumerate(str(i)):
            if s != "7" and s != "5" and s != "3":
                flag = 1
                i += 10 ** (len(str(i)) - j - 1)
                break
            if s == "7":
                flag7 = 1
            elif s == "5":
                flag5 = 1
            elif s == "3":
                flag3 = 1
        if flag == 0 and flag7 == 1 and flag5 == 1 and flag3 == 1:
            count += 1
            print(str(i))
        if flag == 0:
            i += 1
        if N <= i:
            break

print(count)

N = int(input())

i = 357
count = 0
if 357 <= N:
    while(1):
        print(i)
        flag = 0
        flag7 = 0
        flag5 = 0
        flag3 = 0
        for j,s in enumerate(str(i)):
            if s != "7" and s != "5" and s != "3":
                flag = 1
                i += 10 ** (len(str(i)) - j - 1)
                break
            if s == "7":
                flag7 = 1
            elif s == "5":
                flag5 = 1
            elif s == "3":
                flag3 = 1
        if flag == 0 and flag7 == 1 and flag5 == 1 and flag3 == 1:
            count += 1
        if flag == 0:
            i += 1
        if N <= i:
            break

print(count)

N = int(input())

i = 357
count = 0
if 357 <= N:
    while(1):
        print(i)
        flag = 0
        flag7 = 0
        flag5 = 0
        flag3 = 0
        for j,s in enumerate(str(i)):
            if s != "7" and s != "5" and s != "3":
                flag = 1
                i += 10 ** (len(str(i)) - j - 1)
                break
            if s == "7":
                flag7 = 1
            elif s == "5":
                flag5 = 1
            elif s == "3":
                flag3 = 1
        if flag == 0 and flag7 == 1 and flag5 == 1 and flag3 == 1:
            count += 1
        if flag == 0:
            i += 1
        if N < i:
            break

print(count)

N = int(input())

i = 357
count = 0
if 357 <= N:
    while(1):
        flag = 0
        flag7 = 0
        flag5 = 0
        flag3 = 0
        for j,s in enumerate(str(i)):
            if s != "7" and s != "5" and s != "3":
                flag = 1
                i += 10 ** (len(str(i)) - j - 1)
                break
            if s == "7":
                flag7 = 1
            elif s == "5":
                flag5 = 1
            elif s == "3":
                flag3 = 1
        if flag == 0 and flag7 == 1 and flag5 == 1 and flag3 == 1:
            count += 1
        if flag == 0:
            i += 1
        if N < i:
            break

print(count)

Verdicts: 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 = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    r = 1 if all([i in s for i in '357']) else 0
    for c in '357':
        r += dfs(s+c)
    return r

return(dfs('0'))

N = int(input())
 
def dfs(s):
    if int(s) > N:
        return 0
    r = 1 if all([i in s for i in '357']) else 0
    for c in '357':
        r += dfs(s+c)
    return r

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):
from heapq import heappush, heappop, heapify
from itertools import product

N = int(input())

q = ["3", "5", "7"]
ans = 0
while q:
    now = q.pop(0)
    if int(now) <= N:
        for i in ("3", "5", "7"):
            q.append(i + now)
            q.append(now + i)
        if len(set(now)) == 3:
            ans += 1

print(ans)


from heapq import heapify, heappush, heappop

N = int(input())

queue = [3, 5, 7]
heapify(queue)

ans = 0
while (queue):
    now = heappop(queue)
    ans += 1
    for i in (3, 5, 7):
        if now*10 + i <= N:
            heappush(queue, now*10 + i)

print(ans)


from heapq import heappush, heappop
from itertools import permutations

N = int(input())

queue = []


for c in permutations([3, 5, 7]):
    heappush(queue, c[0]*100 + c[1]*10 + c[2])

ans = 0
while (queue):
    now = heappop(queue)
    if now <= N:
        print(now)
        ans += 1
        for i in (3, 5, 7):
            heappush(queue, now*10 + i)  # 357 -> 3573
            heappush(queue, now + i*pow(10, len(str(now))))  # 357 -> 3357

print(ans)


N = int(input())

q = ["3", "5", "7"]
ans = 0
while q:
    now = q.pop(0)
    if int(now) <= N:
        for c in ("3", "5", "7"):
            q.append(now + c)
        if len(set(now)) == 3:
            ans += 1

print(ans)


Verdicts: 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 = 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')) 


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())
A = set()
for x in product('753_', repeat=9):
    s = ''.join(x)
    s = s.replace('_', '')
    if '7' in s and '5' in s and '3' in s and int(s) <= n:
        A.add(s)
print(len(A))

n = int(input())
B = []
def dfs(A):
  x = int(''.join(A))
  if x <= n:
    if '7' in A and '5' in A and '3' in A:
      B.append(x)
    dfs(A + ['7'])
    dfs(A + ['5'])
    dfs(A + ['3'])

dfs(['0'])
print(len(B))

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

def calculate(n,length):
    count = 0
    for i in itertools.product([3,5,7],repeat=length):
        if isValid(i) == False:
            continue
        sum = 0
        print(i)
        for j in range(length):
            sum = sum + i[j] * 10 ** j
        if sum <= n:
            count = count + 1

    return count

def isValid(n):
    dict = {}
    for s in n:
        if dict.get(s) == None:
            dict.__setitem__(s,1)
        else:
            dict.__setitem__(s,dict.get(s) + 1)

    s1 = dict.get(3) != None and dict.get(3) > 0
    s2 = dict.get(5) != None and dict.get(5) > 0
    s3 = dict.get(7) != None and dict.get(7) > 0

    return s1 and s2 and s3

length = len(str(n))

result = 0
for i in range(3,length+1):
    result = result + calculate(n,i)

print(result)



import itertools


n = int(input())

def calculate(n,length):
    count = 0
    for i in itertools.product([3,5,7],repeat=length):
        if isValid(i) == False:
            continue
        sum = 0
        for j in range(length):
            sum = sum + i[j] * 10 ** j
        if sum <= n:
            count = count + 1

    return count

def isValid(n):
    dict = {}
    for s in n:
        if dict.get(s) == None:
            dict.__setitem__(s,1)
        else:
            dict.__setitem__(s,dict.get(s) + 1)

    s1 = dict.get(3) != None and dict.get(3) > 0
    s2 = dict.get(5) != None and dict.get(5) > 0
    s3 = dict.get(7) != None and dict.get(7) > 0

    return s1 and s2 and s3

length = len(str(n))

result = 0
for i in range(3,length+1):
    result = result + calculate(n,i)

print(result)



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 dsf(s):
  if int(s)>n:
    return0
  else:
    if all(s.count(c)>0 for c in "753"):
      x=1
    else:
      x=0
    for c in "753":
      x+=dsf(s+c)
    return x
print(dsf("0"))

n=int(input())
def dsf(s):
  if int(s)>n:
    return 0
  else:
    if all(s.count(c)>0 for c in "753"):
      x=1
    else:
      x=0
    for c in "753":
      x+=dsf(s+c)
    return x
print(dsf("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(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)

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

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 depth_first_search(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':
        #print(c)
        print(s + c)
        ret += depth_first_search(s + c)
        print(ret)
    return ret

print(depth_first_search('0'))


n = int(input())

def depth_first_search(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':
        #print(c)
        #print(s + c)
        ret += depth_first_search(s + c)
        #print(ret)
    return ret

print(depth_first_search('0'))

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())
ret = 0
a = ['3','5','7']
for i in range(357, N+1):
    t = list(set(str(i))).sort()
    if t == a:
        ret += 1
print(ret)

N = int(input())
ret = 0
a = ['3','5','7']
i = 357
while i < N+1:
	t = list(set(str(i)))
	t.sort()
	if t == a:
		ret += 1
	i += 2
	if str(i)[-1] == '7':
		i += 4
print(ret)


N = int(input())
ret = 0
a = ['3','5','7']
for i in range(357, N+1):
    t = list(set(str(i)))
    if t == a:
        ret += 1
print(ret)

N = int(input())
cnt = 0
def dfs(n, cnt):
    if int(n) > N:
        return cnt
    if n.count("3") >= 1 and n.count("5") >= 1 and n.count("7") >= 1:
        cnt += 1

    for i in ("3","5","7"):
        cnt = max(cnt, dfs(n+i, cnt))
    return cnt

print(dfs("0", 0))

Verdicts: 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):
S = input()
ans = 999

for i in range(len(S)-2):
    x = int(S[i:i+3])

    if abs(x-753) < ans:
        ans = abs(x-753)

print(ans)

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: 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())
l = [3,7,5]
c = 0
for i in range(3,10):
    for j in itertools.product(l, repeat=i):
        if set(j) == 3 and int(''.join(map(str,j))) <= n:
            c += 1
print(c)

import itertools
n = int(input())
l = [3,7,5]
c = 0
for i in range(3,10):
    for j in itertools.product(l, repeat=i):
        if len(set(j)) == 3 and int(''.join(map(str,j))) <= n:
            c += 1
print(c)

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, x = map(int,input().split())

def rec(lv,ls):
    if lv == 0:
        return [1]
    else:
        ret = rec(lv-1,ls)
        for i in range(0,len(ret) -1):
            if ret[i]>0 and ret[i+1]>0:
                ret[i+1] += ret[i]
                ret[i] = 0  #deleted tag

        while 0 != ret.count(0):
            ret.remove(0)
        return [-1,*ret,1,*ret,-1]

#print( rec(n, list()) )


count = 0
for e in rec(n, list() ):
    abs_e = abs(e)

    if x == 0:
        break

    if x>=abs_e:
        x -= abs_e
        count += e if e>0 else 0
    else:
        count += x if e>0 else 0
        x = 0
    #print(x," ",count)

print(count)



# post-placed for
# counter for counter in iterator
#  

#Shiti Go San
def sgs(s:str)->bool:
    return True if all( s.count(c)>0 for c in "753") else False





n = int( input() )


def recursive(s:str)->int:
    if n < int(s):
        return 0

    ret = 1 if sgs(s) else 0

    for x in "753":
       ret += recursive( s + x )
    
    return ret

print( recursive('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):
from itertools import permutations
target = [3,5,7]

clear_list = combinations(target, 4)
print(clear_list)

from itertools import product
target = ['3','5','7']

n=int(input())
tmp=n
keta=0
while tmp!=0:
  tmp//=10
  keta+=1
check_list = []
for i in range(1,keta+1):
  tmp=[]
  for _ in range(i):
    tmp.append(target.copy())
    tmp_product = list(product(*tmp))
  check_list+=[int(''.join(nums)) for nums in tmp_product]
check_list = sorted(check_list)

cnt=0
for i in check_list:
  if i <= n:
    tmp = set([w for w in str(i)])
    if len(tmp)==3:
      cnt+=1
  else:
    break
print(cnt)


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 '753':
    ret += dfs(s + c)
    return ret
print(dfs('0')) 


N = int(input())
def dfs(s): 
return 0
ret = 1 if all(s.count(c) > 0 for c in '753') else 0 
         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')) 


n=int(input())
 
def dfs(s):
  if int(s)>n:
    return 0
  cnt=1 if all(s.count(i)>0 for i in '753') else 0
  for j in '753':
    cnt+=dfs(s+j)
  return cnt
  
print(dfs('0'))

Verdicts: Wrong Answer

Runtime Error

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
  if all(s.count(c) > 0 for c in '753'):
    ret=1
  else:
    ret=0 
  for c in '753':
    ret += dfs(s + c)
  return ret
print(dfs('0'))

n=int(input())
ans=0
if n<10**8:
  if n%2==0:
    for i in range(1,n-1,2):
      sum3=0
      sum5=0
      sum7=0
      x=str(i)
      l=len(x)
      for j in range(l):
        if x[j]=='3':
          sum3 += 1
        elif x[j]=='5':
          sum5 += 1
        elif x[j]=='7':
          sum7 += 1
        if (sum3 + sum5 + sum7 == l) and (sum3>0) and(sum5>0) and (sum7>0):
          ans+=1
  else:
    for i in range(1,n,2):
      sum3=0
      sum5=0
      sum7=0
      x=str(i)
      l=len(x)
      for j in range(l):
        if x[j]=='3':
          sum3 += 1
        elif x[j]=='5':
          sum5 += 1
        elif x[j]=='7':
          sum7 += 1
        if (sum3+sum5+sum7==l) and (sum3>0) and(sum5>0) and (sum7>0):
          ans+=1
print(ans)
else:
print(0)


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

Verdicts: Runtime Error

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
def calc_num(S,S_len):
  	result = 0;
    l = [3,5,7];
    i = 3;
    while i <= S_len
    	for v in itertools.product(l,repeat=i):
        	if int("".join(map(str,v))) <= S and list(srt(v) & set(l)) == l;
          		result = result + 1;
        i = i + 1;
    return result
  
S = list(map(int,input()))
S_len = len(S)
S = int("".join(map(str, S)));
result = calc_num(S,S_len);
print(result)

import itertools
def calc_num(S,S_len):
  result = 0;
  l = [3,5,7];
  i = 3;
  while i <= S_len
  	for v in itertools.product(l,repeat=i):
   		if int("".join(map(str,v))) <= S and list(srt(v) & set(l)) == l;
        	result = result + 1;
    i = i + 1;
  return result
  
S = list(map(int,input()))
S_len = len(S)
S = int("".join(map(str, S)));
result = calc_num(S,S_len);
print(result)

import itertools
def calc_num(S,S_len):
  result = 0;
  l = [3,5,7];
  i = 3;
  while i <= S_len
  	for v in itertools.product(l,repeat=i):
      if int("".join(map(str,v))) <= S and list(srt(v) & set(l)) == l;
        result = result + 1;
    i = i + 1;
  return result
  
S = list(map(int,input()))
S_len = len(S)
S = int("".join(map(str, S)));
result = calc_num(S,S_len);
print(result)

import itertools
n = int(input())
target = ["7","5","3"]
c = 0
for i in range(1,len(str(n))+1):
  for p in list(itertools.product(target,repeat=i)):
    if int("".join(list(p))) <= n and len(set(p))==3: c += 1
print(c)
    

Verdicts: Runtime Error

Runtime Error

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 sys
sys.setrecursionlimit(10**6)

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

li = []


def rec(curr, use):
    if curr > N:
        return cnt
    if use == 0b111:
        li.append(curr)
    for i, b in enumerate(V):
        rec(curr * 10 + b, use | max(1, i * 2))


rec(0, 0)

print(len(li))

import sys
sys.setrecursionlimit(10**6)

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

li = []


def rec(curr, use):
    if curr > N:
        return
    if use == 0b111:
        li.append(curr)
    for i, b in enumerate(V):
        rec(curr * 10 + b, use | max(1, i * 2))


rec(0, 0)

print(len(li))

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) for c in '753']) else 0
  for c in '753':
    ret += dfs(s+c)
  return ret
print(ret('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(ret('0'))

s = set(['7', '5', '3'])
print(sum((1 for i in range(1, n+1) if set(str(i)) == s)))

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

Runtime Error

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):
S = input()
m = 999
for i in range(len(S)-2):
    a = int(S[i:i+3])-753
    if abs(a)<m:
        m = abs(a)
print(m)

N = int(input())

L = ["3","5","7"]
A = [L]
for i in range(8):
    B = []
    for a in A[i]:
        for l in L:
            B.append(a+l)
    A.append(B)
c = 0
for i in range(9):
    for a in A[i]:
        if "3" in a and "5" in a and "7" in a:
            if int(a) <= N:
                c += 1
            
print(c)


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())
ans = 0
for i in range(3,len(str(n))+1):
    for num in product(('3','5','7'),repeat=i):
        if len(set(num)) == 3 and int("".join(num)) <= 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()
N_ = len(N)
A = N_ * N_ - 1 * N_ - 2

if int(N) < 357:
  print(0)
elif int(N[0]) < 2:
  A = N_ - 1 * N_ - 2 * N_ - 3
elif int(N[0]) == 3 or int(N[0]) == 4:
  A = N_ - 1 * N_ - 2
elif int(N[0]) == 5 int(N[0]) == 6:
  A = 2 * N_ -1 * N_ -2
elif int(N[0]) >= 7:
  A = N_ * N_ - 1 * N_ - 2
  

print(A)


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

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

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

l = len(N)
ans = 0

for n in range(1, 4**l):
  n4 = ""
  while n > 0:
    mod = n % 4
    n4 = str(mod) + n4
    n //= 4
  
  if "0" in n4:
    continue
  
  if ("1" in n4) and ("2" in n4) and ("3" in n4):
    n4_10 = ""
    for i in range(len(n4)):
      if n4[i] == "1":
        n4_10 = n4_10 + "7"
      elif n4[i] == "2":
        n4_10 = n4_10 + "5"
      else:
        n4_10 = n4_10 + "3"
    if int(n4_10) =< int(N):
      ans += 1

print(ans)

N = input()

l = len(N)
ans = 0

for n in range(1, 4**l):
  n4 = ""
  while n > 0:
    mod = n % 4
    n4 = str(mod) + n4
    n //= 4
  
  if "0" in n4:
    continue
  
  if ("1" in n4) and ("2" in n4) and ("3" in n4):
    n4_10 = ""
    for i in range(len(n4)):
      if n4[i] == "1":
        n4_10 = n4_10 + "7"
      elif n4[i] == "2":
        n4_10 = n4_10 + "5"
      else:
        n4_10 = n4_10 + "3"
    if int(n4_10) <= int(N):
      ans += 1

print(ans)

Verdicts: Runtime Error

Accepted