Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
time_list=[]

for _ in range(5):
    time_list.append(int(input()))
# print(1, time_list)

time_list2=[]
for x in time_list:
    m = x % 10
    if m!=0:
        time_list2.append(x+(10-m))
    else:
        time_list2.append(x)
# print("2", time_list2)
# print(round(102,-1))

mod_list = []
for x in time_list:
    m = x % 10
    if m!=0:
        mod_list.append(10-m)
min_ = max(mod_list)
# print(mod_list)



print(sum(time_list2)-min_)

Fixed submission:
import math
time_list=[]

for _ in range(5):
    time_list.append(int(input()))
# print(1, time_list)

time_list2=[]
for x in time_list:
    m = x % 10
    if m!=0:
        time_list2.append(x+(10-m))
    else:
        time_list2.append(x)
# print("2", time_list2)

mod_list = []
for x in time_list:
    m = x % 10
    if m!=0:
        mod_list.append(m)
    else:
        mod_list.append(10)
min_ = min(mod_list)
# print(mod_list)



print(sum(time_list2)-(10-min_))

Buggy python submission (verdict: Runtime Error):
import math
time_list=[]

for _ in range(5):
    time_list.append(int(input()))
# print(1, time_list)

time_list2=[]
for x in time_list:
    m = x % 10
    time_list2.append(x+(10-m))
# print("2", time_list2)
# print(round(102,-1))

mod_list = []
for x in time_list:
    m = x % 10
    if m!=0:
        mod_list.append(10-m)
min_ = max(mod_list)
# print(mod_list)



print(sum(time_list2)-min_)

Fixed submission:
import math
time_list=[]

for _ in range(5):
    time_list.append(int(input()))
# print(1, time_list)

time_list2=[]
for x in time_list:
    m = x % 10
    if m!=0:
        time_list2.append(x+(10-m))
    else:
        time_list2.append(x)
# print("2", time_list2)

mod_list = []
for x in time_list:
    m = x % 10
    if m!=0:
        mod_list.append(m)
    else:
        mod_list.append(10)
min_ = min(mod_list)
# print(mod_list)



print(sum(time_list2)-(10-min_))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

dish_list = []
for i in range(n):
    ai, bi = list(map(int, input().split()))
    dish_list.append([ai, bi, ai+bi])




a, b = 0, 0
def dfs(dish_list, turn):
    if dish_list==[]:
        return
    # print("=================")
    # print(dish_list)
    global a
    global b


    #評価値が最大の皿をみつける
    max_id = 0
    max_p = 0
    for i, dish in enumerate(dish_list):
        if dish[2] > max_p:
            max_p = dish[2]
            max_id = i

    #幸福度を加算
    # print(max_id, max_p)
    if turn == -1:
        a+=dish_list[max_id][0]
    elif turn == 1:
        b+=dish_list[max_id][1]

    #評価値最大のさらを削除した新しい皿のリストを作る
    new_list = [list for i, list in enumerate(dish_list) if i!=max_id]
    dfs(new_list, turn*(-1))

dfs(dish_list, -1)

# print(a, b, a-b)

print(a-b)

Fixed submission:
n = int(input())

dish_list = []
for i in range(n):
    ai, bi = list(map(int, input().split()))
    dish_list.append([ai, bi, ai+bi])


dish_list.sort(key = lambda x:x[2], reverse=True)


a, b =0, 0
turn = 1
for i in range(n):
    if turn ==1:
        a+=dish_list[i][0]
    else:
        b+=dish_list[i][1]
    turn*=-1

# print(a, b)
# a, b = 0, 0
# def dfs(dish_list, turn):
#     if dish_list==[]:
#         return
#     # print("=================")
#     # print(dish_list)
#     global a
#     global b
#
#
#     #評価値が最大の皿をみつける
#     max_id = 0
#     max_p = 0
#     for i, dish in enumerate(dish_list):
#         if dish[2] > max_p:
#             max_p = dish[2]
#             max_id = i
#
#     #幸福度を加算
#     # print(max_id, max_p)
#     if turn == -1:
#         a+=dish_list[max_id][0]
#     elif turn == 1:
#         b+=dish_list[max_id][1]
#
#     #評価値最大のさらを削除した新しい皿のリストを作る
#     new_list = [list for i, list in enumerate(dish_list) if i!=max_id]
#     dfs(new_list, turn*(-1))
#
# dfs(dish_list, -1)

# print(a, b, a-b)

print(a-b)
Buggy python submission (verdict: Runtime Error):
import sympy

n, p = map(int, input().split())

list = sympy.factorint(p)

# print(list)

ans = 1
for b, e in list.items():
    tmp = e // n
    if tmp!=0:
        ans*=b

print(ans)

Fixed submission:
n, p = map(int, input().split())

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


# print('(n, p) is ({}, {})'.format(n, p))
list = factorize(p)
# print(list)



ans = 1
for b, e in list:
    # print(b, e)
    tmp = e // n
    # print('b // n is', tmp )
    if tmp !=0:
        for i in range(tmp):
            ans*=b

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()

ans = 0
for i, c in enumerate(s):
    # print(i, c)
    if c == 'B':
        num_W=0
        for ac in s[i:]:
            # print(ac)
            if ac == 'W':
                num_W+=1
            # print('num = ', num_W)
        ans += num_W
    # print("ans = ", ans)

print(ans)


Fixed submission:
s = input()

ans = 0

num_B=0
num_W=0

for ele in s:
    # print(ele, num_W,num_B, ans)
    if ele == 'B':
        ans += num_B*num_W
        num_B+=1
        num_W=0
    else:
        num_W+=1
ans += num_B*num_W
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

def is_753(x):
    number = [ele for ele in str(x)]
    seven = False
    five = False
    three = False

    while '7' in number:
        seven = True
        number.remove('7')
    if not seven:
        return False

    while '5' in number:
        five = True
        number.remove('5')
    if not five:
        return False

    while '3' in number:
        three = True
        number.remove('3')
    if not three:
        return False

    if number:
        return False
    else:
        return True

count = 0

for i in range(100, n+1):
    if is_753(i):
        count+=1

print(count)

Fixed submission:
n = int(input())

count = 0

def dfs(s):
    # print(s)
    # 753数ですか？
    if int(s) > n:
        return
    if all(c in s for c in "753"):
        global count
        count += 1
    for c in "753":
        dfs(s+c)


dfs('0')

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

def is_753(x):
    number = [ele for ele in str(x)]
    if '7' in number and '5' in number and '3' in number:
        while '7' in number:
            number.remove('7')
        while '5' in number:
            number.remove('5')
        while '3' in number:
            number.remove('3')
    else:
        return False

    if number:
        return False
    else:
        return True

count = 0

for i in range(100, n+1):
    if is_753(i):
        count+=1

print(count)

Fixed submission:
n = int(input())

count = 0

def dfs(s):
    # print(s)
    # 753数ですか？
    if int(s) > n:
        return
    if all(c in s for c in "753"):
        global count
        count += 1
    for c in "753":
        dfs(s+c)


dfs('0')

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
hhh = list(map(int, input().split()))

dp = [0] * N
dp[0] = 0

for i in range(1, N):
    if i < K:
        dp[i] = min([abs(hhh[i] - hhh[i - k]) + dp[i - k]
                     for k in range(1, i + 1)])
    else:
        dp[i] = \
            min([abs(hhh[i] - hhh[i - k]) + dp[i - k]
                 for k in range(1, K + 1)])

print(dp[-1])


Fixed submission:
N, K = map(int, input().split())
hhh = list(map(int, input().split()))

dp = [0] * N
dp[0] = 0

for i in range(1, N):
    if i < K:
        dp[i] = min([abs(hhh[i] - hhh[i - k]) + dp[i - k]
                     for k in range(1, i + 1)])
    else:
        dp[i] = \
            min([abs(hhh[i] - hhh[i - k]) + dp[i - k]
                 for k in range(1, K + 1)])

print(dp[-1])
Buggy python submission (verdict: Runtime Error):
import functools
import math

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

# 最大公約数
ans = functools.reduce(math.gcd, a)
print(ans)

Fixed submission:
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

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

element = gcd(a[0], a[1])
if n==2:print(element)
else:
    for i in range(2,n):
        element=gcd(element,a[i])
    print(element)
Buggy python submission (verdict: Runtime Error):
n = int(input())

p = [None]*n

for i in range(n):
    p[i] = list(map(int,input().split()))

plan = [[0,0,0]]
plan.extend(p)

print('plan')
print(plan)

for i in range(n+1):
    diff = [plan[i+1][k] - plan[i][k] for k in range(len(plan[0]))]
    print(diff)
    if abs(diff[1])+abs(diff[2])>diff[0]:
        print('No')
        break
    elif (diff[0]-(abs(diff[1])+abs(diff[2])))%2==1:
        print('No')
        break
    elif i==n-1:
        print('YES')

Fixed submission:
n = int(input())

p = [None]*n

for i in range(n):
    p[i] = list(map(int,input().split()))

plan = [[0,0,0]]
plan.extend(p)

for i in range(n):
    diff = [plan[i+1][k] - plan[i][k] for k in range(len(plan[0]))]
    if (abs(diff[1])+abs(diff[2]))>diff[0] or (diff[0]-(abs(diff[1])+abs(diff[2])))%2==1:
        print('No')
        exit()

print('Yes')
Buggy python submission (verdict: Runtime Error):
n, y = map(int,input().split())

def f(n,y):
    for i in range(n):
        for j in range(n-i):
            s = 10000*i + 5000*j + 1000*(n-i-j)
            if s == y:
                return '{0} {1} {2}'.format(i,j,k)

    return '-1 -1 -1'

print(f(n,y))

Fixed submission:
n, y = map(int,input().split())

def f(n,y):
    for i in range(n+1):
        for j in range(n-i+1):
            s = 10000*i + 5000*j + 1000*(n-i-j)
            if s == y:
                return '{0} {1} {2}'.format(i,j,n-i-j)

    return '-1 -1 -1'

print(f(n,y))

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

def f(n,y):
    for i in range(n):
        for j in range(n-i):
            s = 10000*i + 5000*j + 1000*(n-i-j)
            if s == y:
                return [i, j, k]

    return [-1, -1, -1]

print(f(n,y))

Fixed submission:
n, y = map(int,input().split())

def f(n,y):
    for i in range(n+1):
        for j in range(n-i+1):
            s = 10000*i + 5000*j + 1000*(n-i-j)
            if s == y:
                return '{0} {1} {2}'.format(i,j,n-i-j)

    return '-1 -1 -1'

print(f(n,y))
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))

c = list()

for n in range(N):
    for i in range(1,31):
        if not a[n]%(2**i)==0:
            c.append(i-1)
            break
print(min(c))
        

Fixed submission:
a = list(input())
print(int(a[0])+int(a[1])+int(a[2]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))

c = list()

for n in range(N):
    for i in range(1,30):
        if not a[n]%(2**i)==0:
            c.append(i-1)
            break
print(min(c))

Fixed submission:
N = int(input())
a = list(map(int,input().split()))

c = list()

for n in range(N):
    for i in range(1,31):
        if not a[n]%(2**i)==0:
            c.append(i-1)
            break
print(min(c))
Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())
s = 0
for i in range(b-a+1): #aからbの中で最初にxで割り切れる数を探す
    if a % x == 0:
        break
    elif a % x != 0:
            a = a + 1
while (a+x*s) <= b:
    s = s + 1
print(s)

Fixed submission:
a, b, x = map(int, input().split())
#b以下で小さくかつbに最も近いxの倍数 x*i (x*i=0を含める)
i = b // x
#aより小さくかつaに最も近いxの倍数 x*j (x*j=0を含める)
j = (a-1) // x
print(i-j)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())
i = 0
s = 0
while a > x*i:
    i = i + 1 
while b - (x*i + x*s) >= 0:
    s = s + 1
print(s)

Fixed submission:
a, b, x = map(int, input().split())
#b以下で小さくかつbに最も近いxの倍数 x*i (x*i=0を含める)
i = b // x
#aより小さくかつaに最も近いxの倍数 x*j (x*j=0を含める)
j = (a-1) // x
print(i-j)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())
s = 0
for i in range(b-a+1): #aからbの中で最初にxで割り切れる数を探す
    if a % x == 0:
        break
    elif a % x != 0:
            a = a + 1
while (a+x*s) <= b:
    s = s + 1
print(s)

Fixed submission:
a, b, x = map(int, input().split())
#b以下で小さくかつbに最も近いxの倍数 x*i (x*i=0を含める)
i = b // x
#aより小さくかつaに最も近いxの倍数 x*j (x*j=0を含める)
j = (a-1) // x
print(i-j)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())
s = 0
for i in range(b-a+1): #aからbの中で最初にxで割り切れる数を探す
    if a % x == 0:
        s = (b-a)//x + 1 #初めて割り切れた数からbまでの割り切れる数の個数
        break
    elif a % x != 0:
        a = a + 1
print(s)

Fixed submission:
a, b, x = map(int, input().split())
#b以下で小さくかつbに最も近いxの倍数 x*i (x*i=0を含める)
i = b // x
#aより小さくかつaに最も近いxの倍数 x*j (x*j=0を含める)
j = (a-1) // x
print(i-j)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a == b:
    if a == c:
        print(1)
    else: print(2)
elif a == c:
	print(2)
    else: print(3)
elif b == c:
  print(2)
  else: print(3)

Fixed submission:
a, b, c = map(int, input().split())
if a == b:
    if a == c:
        print(1)
    else: print(2)
elif a == c:
	print(2)
elif b == c:
  print(2)
else: print(3)

Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a == b:
    if a == c:
        print(1)
    else: print(2)
elif a == c:
    print(2)
	else: print(3)

Fixed submission:
a, b, c = map(int, input().split())
if a == b:
    if a == c:
        print(1)
    else: print(2)
elif a == c:
	print(2)
elif b == c:
  print(2)
else: print(3)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = b * (b-1) ** (a-1)
print(c)

Fixed submission:
a, b = map(int, input().split())
c = b * (b-1) ** (a-1)
print(c)
Buggy python submission (verdict: Runtime Error):
# ６月６日
a = int(input())
b = int(input())
c = int(input())
d = (a+b)*c//2
print(d)


Fixed submission:
N = int(input())
candy_sum = int((1+N)*N/2)
print(candy_sum)

Buggy python submission (verdict: Runtime Error):
# ６月６日
a = int(input())
b = int(input())
c = int(input())
d = (a+b)*c//2
print(d)


Fixed submission:
N = int(input())
candy_sum = int((1+N)*N/2)
print(candy_sum)
Buggy python submission (verdict: Runtime Error):
nums = [int(input()) for _ in range(5)]


def orders(nums):
  r = [10 - (num % 10) for num in nums if (num % 10)]
  return sum(nums) + sum(r) - max(r)

print(orders(nums))

Fixed submission:
nums = [int(input()) for _ in range(5)]


def orders(nums):
  r = [10 - (num % 10) for num in nums if (num % 10)]
  if r:
  	return sum(nums) + sum(r) - max(r)
  return sum(nums)

print(orders(nums))
Buggy python submission (verdict: Runtime Error):
cnt = 0
for a in range(A+1):
#     _a = a*500
    for b in range(B+1):
#         _b = b*100 + _a
#         if _b > X: break
        for c in range(C+1):
#             _c = c*50 + _a + _b
#             if _c > X: break
#             if _c == X:
            if (a*500 + b*100 + c*50) == X:
                cnt+=1
print(cnt)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if (a*500 + b*100 + c*50) == X:
                cnt+=1
print(cnt)

Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for a in range(min([A,-(-X//500)])+1):
  _tmp = a*500
  if _tmp > x: break
  for b in range(min([B,-(-X//100)])+1):
	_tmp += b*100
	if _tmp > x: break
    for c in range(min([C,-(-X//50)])+1):
	  _tmp += c*50
	  if _tmp > x: break
	  if _tmp == X:
        cnt+=1
print(cnt)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if (a*500 + b*100 + c*50) == X:
                cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
D = sorted([int(input()) for _ in range(N)])
if len(D) == 1: print(1)
i,prev = 1,D[0]
while i != (len(D)-1):
    if D[i] == prev: 
        D.pop(i)
    else:
        i +=1
        prev = D[i]
print(len(D))

Fixed submission:
N = int(input())
D = sorted([int(input()) for _ in range(N)])
if len(D) > 1:
    i,prev = 0,None
    while i < (len(D)-1):
        if D[i] == D[i+1]: 
            D.pop(i+1)
        else:
            prev = D[i]
            i +=1
print(len(D))

Buggy python submission (verdict: Runtime Error):
N = int(input())
D = sorted([int(input()) for _ in range(N)])
i,prev = 1,D[0]
while i != (len(D)-1):
    if D[i] == prev: 
        D.pop(i)
    else:
        i +=1
        prev = D[i]
print(len(D))

Fixed submission:
N = int(input())
D = sorted([int(input()) for _ in range(N)])
if len(D) > 1:
    i,prev = 0,None
    while i < (len(D)-1):
        if D[i] == D[i+1]: 
            D.pop(i+1)
        else:
            prev = D[i]
            i +=1
print(len(D))
Buggy python submission (verdict: Runtime Error):
s = input()
print(count('1'))

Fixed submission:
s = input()
print(s.count('1'))
Buggy python submission (verdict: Runtime Error):
n = input()
l = input().split()
cnt = 0
while len([True for x in l if x%2==0]):
  l = [x/2 for x in l]
  cnt += 1
print(cnt)

Fixed submission:
n = input()
l = [int(x) for x in input().split()]
cnt = 0
while len([True for x in l if x%2==0]) == len(l):
  l = [x/2 for x in l]
  cnt += 1
print(cnt)

Buggy python submission (verdict: Runtime Error):
n = input()
l = input().split()
cnt = 0
while len([True for x in l if l%2==0]):
  l = [x/2 for x in l]
  cnt += 1
print(cnt)

Fixed submission:
n = input()
l = [int(x) for x in input().split()]
cnt = 0
while len([True for x in l if x%2==0]) == len(l):
  l = [x/2 for x in l]
  cnt += 1
print(cnt)

Buggy python submission (verdict: Runtime Error):
l = input().split()
cnt = 0
while len([True for x in l if l%2==0]):
  l = [x/2 for x in l]
  cnt += 1
print(cnt)

Fixed submission:
n = input()
l = [int(x) for x in input().split()]
cnt = 0
while len([True for x in l if x%2==0]) == len(l):
  l = [x/2 for x in l]
  cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left, bisect_right
a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
q = [int(input()) for _ in range(q)]
for qi in q:
    qans = 10**18
    ai = bisect_left(s, qi)
    bi = bisect_left(t, qi)
    ac = []
    bc = []
    for i in range(2):
        if (0 <= ai + i < a):
            ac.append(ai + i);
        if (0 <= ai - i < a):
            ac.append(ai - i);
    for i in range(2):
        if (0 <= bi + i < b):
            bc.append(bi + i);
        if (0 <= bi - i < b):
            bc.append(bi - i);
    for i in ac:
        for j in bc:
            aa = s[i];
            bb = t[j];
            if (max(aa, bb) <= qi):
                qans = min(qans, qi - min(aa, bb))
            elif (qi <= min(aa, bb)):
                qans = min(qans, max(aa, bb) - qi)
            else:
                qans = min(qans, min(abs(aa - qi), abs(bb - qi)) * 2 + max(abs(aa - qi), abs(bb - qi)))
    print(qans)


Fixed submission:
s = input()
b = s.split("/")
a = []
for i in b:
    a.append(int(i))
if (a[0] * 10000 + a[1] * 100 + a[2] <= 20190430):
    print("Heisei")
else:
    print("TBD")
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left, bisect_right
a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
q = [int(input()) for _ in range(q)]
for qi in q:
    qans = 10**18
    ai = bisect_left(s, qi)
    bi = bisect_left(t, qi)
    ac = []
    bc = []
    for i in range(3):
        if (0 <= ai + i < a):
            ac.append(ai + i);
        if (0 <= ai - i < a):
            ac.append(ai - i);
    for i in range(3):
        if (0 <= bi + i < b):
            bc.append(bi + i);
        if (0 <= bi - i < b):
            bc.append(bi - i);
    for i in ac:
        for j in bc:
            aa = s[i];
            bb = t[j];
            if (max(aa, bb) <= qi):
                qans = min(qans, qi - min(aa, bb))
            elif (qi <= min(aa, bb)):
                qans = min(qans, max(aa, bb) - qi)
            else:
                qans = min(qans, min(abs(aa - qi), abs(bb - qi)) * 2 + max(abs(aa - qi), abs(bb - qi)))
    print(qans)


Fixed submission:
from bisect import bisect_left, bisect_right
a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
q = [int(input()) for _ in range(q)]
for qi in q:
    qans = 10**18
    ai = bisect_left(s, qi)
    bi = bisect_left(t, qi)
    ac = []
    bc = []
    for i in range(2):
        if (0 <= ai + i < a):
            ac.append(ai + i);
        if (0 <= ai - i < a):
            ac.append(ai - i);
    for i in range(2):
        if (0 <= bi + i < b):
            bc.append(bi + i);
        if (0 <= bi - i < b):
            bc.append(bi - i);
    for i in ac:
        for j in bc:
            aa = s[i];
            bb = t[j];
            if (max(aa, bb) <= qi):
                qans = min(qans, qi - min(aa, bb))
            elif (qi <= min(aa, bb)):
                qans = min(qans, max(aa, bb) - qi)
            else:
                qans = min(qans, min(abs(aa - qi), abs(bb - qi)) * 2 + max(abs(aa - qi), abs(bb - qi)))
    print(qans)
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
d = sorted([int(input()) for _ in range(n)],reverse=True)
ret = 9999999999
#print(d)
for i in range(n-k+1):
    #print(i,i+k-1)
    ret = min(ret,d[i]-d[i+k-1])
print(ret)


Fixed submission:
print("Christmas "+("Eve "*(25-int(input()))))
Buggy python submission (verdict: Time Limit Exceeded):
cnt = 0
n = 357
l = int(input())+1
while n<l:
    #print(n)
    s = str(n)

    ok = False
    for i in "0124689":
        if i in s:
            ok = True
            break

    if ok:
        #print(s)
        if s[0] == '1':
            n += 2*(10**(len(s)-1))
        elif s[0] == '4' or s[0] == '6':
            n += 10**(len(s)-1)
        else:
            n+=2
        continue
        
    if '3' in s and '5' in s and '7' in s:
        #print(s)
        cnt += 1
        
    n+=2
print(cnt)


Fixed submission:
n = int(input())
def count(s):
    if len(s) == len(str(n)):
        if ('3' in s) and ('5' in s) and ('7' in s) and (int(s) <= n) and not ('0' in str(int(s))):
            #print(s)
            return 1
        else:
            return 0
    ret = 0
    for i in "0357":
        ret += count(s+i)
    return ret

print(count(""))