description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | n = int(input())
seq = input()
prev = -1
ans = 0
for e in seq:
if e != prev:
ans += 1
prev = e
print(min(n, ans + 2)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | n = map(int, input().split())
a = input()
prev, cur = "0", "0"
t = 1
flag = 0
x = 1
if len(a) > 1:
for i in range(len(a)):
cur = a[i]
if i > 0:
if prev == cur:
x = x + 1
else:
x = 1
t += 1
if x >= 2:
... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR STRING STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ... |
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.
However, all is not... | n = int(input())
x = input()
q = []
for y in x:
q.append(int(y))
def get_score(x, y):
score = 1
f = q[x]
for i in range(x + 1, y):
if q[i] != f:
score += 1
f = 1 - f
return score
flip = 1
for i in range(1, n):
if flip == 1:
if q[i] == q[i - 1]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR RETURN VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import permutations
s = input()
n = len(s)
s = int(s)
co = False
if n % 2 == 1:
co = True
if n % 2 == 0:
k = n // 2
ans = ""
for i in range(k):
ans += "4"
for i in range(k):
ans += "7"
co = True
n = n + 1
l = list(set(permutations(ans)))
l = sorted(l)
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR VAR STRING FOR VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR NUMBER ASSIGN... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | import sys
sys.setrecursionlimit(100000)
n = sys.stdin.readline().strip()
arr = []
def val(num_four, num_seven, s=""):
if num_four > 0:
arr.append(s + "4")
val(num_four - 1, num_seven, s + "4")
if num_seven > 0:
arr.append(s + "7")
val(num_four, num_seven - 1, s + "7")
def e... | IMPORT EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF STRING IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR STRING EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR STRING ... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def nextPermutation(nums):
i = j = len(nums) - 1
while i > 0 and nums[i] <= nums[i - 1]:
i -= 1
i -= 1
if i < 0:
nums.reverse()
return
while j > i and nums[j] <= nums[i]:
j -= 1
nums[i], nums[j] = nums[j], nums[i]
k, l = i + 1, len(nums) - 1
while k < l:
... | FUNC_DEF ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR RETURN WHILE VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR ... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def pnr(r, n):
res = float("inf")
p = 1 << r + 1
leaf = 1 << r
BT = ["0"] * p
for i in range(1, leaf):
BT[2 * i] = BT[i] + "4"
BT[2 * i + 1] = BT[i] + "7"
for i in range(leaf, p):
if BT[i].count("4") == BT[i].count("7"):
N = int(BT[i])
if N >= n:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP NUMBER VAR BIN_OP VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP VAR VAR STRING FOR VAR FUNC_CALL VAR VA... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import product
def same_amount_of_4_and_7(list_of_digits):
return list_of_digits.count(4) == list_of_digits.count(7)
numbers = []
for ln in range(1, 11):
numbers += list(product([4, 7], repeat=ln))
numbers = list(filter(same_amount_of_4_and_7, numbers))
for i in range(len(numbers)):
numbe... | FUNC_DEF RETURN FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR LIST NUMBER NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def next_permutation(a):
if len(a) < 2:
return False
i = len(a) - 2
while i >= 0 and a[i] >= a[i + 1]:
i -= 1
if i < 0:
return False
j = i + 1
k = len(a) - 1
while a[i] >= a[k]:
k -= 1
a[i], a[k] = a[k], a[i]
a[j:] = a[: j - 1 : -1]
return True
n... | FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR VAR ... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | b = input()
a = [int(i) for i in b]
l = len(a)
flag = 0
s = 0
f = 0
if l % 2 == 1:
flag = 1
else:
for i in range(l):
if a[i] > 7:
flag = 1
if s == l // 2 or s == i + 1:
break
for j in range(i, -1, -1):
if a[j] == 4:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VA... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def check(m):
if m >= n and str(m).count("4") == str(m).count("7"):
a.append(m)
if m < 10**12:
check(m * 10 + 4)
check(m * 10 + 7)
n = int(input())
a = []
check(0)
a.sort()
print(a[0]) | FUNC_DEF IF VAR VAR FUNC_CALL FUNC_CALL VAR VAR STRING FUNC_CALL FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR IF VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR NUM... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def good(n):
if n == 447777:
return 474477
if n == 4777:
return 7447
if n == 47474749:
return 47474774
l = len(str(n))
if l % 2 != 0:
return "4" * ((l + 1) // 2) + "7" * ((l + 1) // 2)
s = str(n)
if int(s[0]) > 7:
l = l + 2
return "4" * (l // 2... | FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP BIN_OP STRING BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP STRING BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR ... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | n = int(input())
a = set()
for i in range(1, 11):
for j in range(2**i):
c = j
cnt = 0
t = 0
b = 0
while c or cnt < i:
if c & 1:
t = t * 10 + 7
b += 1
else:
t = t * 10 + 4
b -= 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP ... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import permutations
s = str(input(""))
ma_rs = []
mi_rs = []
n = int((len(s) + 1) / 2)
for i in range(n):
ma_rs.append(4)
mi_rs.append(4)
for i in range(n):
ma_rs.append(7)
mi_rs.append(7)
mi_rs.sort(key=int)
i_mi_rs = int("".join(map(str, mi_rs)))
ma_rs.sort(key=int, reverse=True)
i_ma_... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL ... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def helper(binum, digit):
s = ""
count = 0
while binum > 0:
if binum & 1 == 1:
s = "7" + s
count += 1
else:
s = "4" + s
binum //= 2
if count != digit // 2:
return "-1"
if len(s) == digit:
return s
s = "4" * (digit - len(... | FUNC_DEF ASSIGN VAR STRING ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP STRING VAR VAR NUMBER ASSIGN VAR BIN_OP STRING VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER RETURN STRING IF FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR VAR RETURN VAR... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def gen(n):
return "4" * (n // 2) + "7" * (n // 2)
DS = 4, 7
def solve(n):
if len(n) % 2 == 0:
k = len(n) // 2
i = 0
c = [0] * 10
while i < len(n):
d = int(n[i])
if d not in DS or d in DS and c[d] == k:
break
c[d] += 1
... | FUNC_DEF RETURN BIN_OP BIN_OP STRING BIN_OP VAR NUMBER BIN_OP STRING BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FUNC_DEF IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VA... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | hi = input()
anslen = len(hi)
if anslen % 2 != 0:
anslen += 1
pos = []
def perms(curr, fours, sevens, total):
if total == 0 and curr >= int(hi):
print(curr)
exit()
elif total != 0:
if fours != 0:
perms(curr * 10 + 4, fours - 1, sevens, total - 1)
if sevens != 0:... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR LIST FUNC_DEF IF VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF VA... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import permutations as p
def ck(num, arr):
for i in arr:
if i >= num:
print(i)
return
x = input()
z = len(x)
if z == 1:
print(47)
elif z == 2:
if int(x) <= 74:
arr = [47, 74]
ck(int(x), arr)
else:
print(4477)
elif z == 3:
pri... | FUNC_DEF FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_C... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | n = int(input())
def search(c, d, l):
if d == 0:
if c >= n:
print(c)
exit()
return
if l:
search(10 * c + 4, d - 1, l - 1)
if l < d:
search(10 * c + 7, d - 1, l)
for i in range(2, 10, 2):
search(0, i, i // 2)
print(4444477777) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR RETURN IF VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VA... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | nums = []
for mask in range(1 << 10):
set = 0
count4 = 0
count7 = 0
for i in range(10):
if mask & 1 << i != 0:
set += 1
bound = -1
for i in range(10):
if mask & 1 << i == 0:
count7 += 1
else:
count4 += 1
if count7 == count4:
... | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VA... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def nextLuckyNumber(digits: str) -> str:
n = len(digits)
halfLen = n >> 1
if n & 1 or digits > f"{'7' * halfLen}{'4' * halfLen}":
halfLen += 1
return f"{'4' * halfLen}{'7' * halfLen}"
result = [(0) for i in range(n)]
remaining = [halfLen, halfLen]
for i in range(n):
add4 ... | FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER VAR BIN_OP STRING VAR BIN_OP STRING VAR VAR NUMBER RETURN BIN_OP STRING VAR BIN_OP STRING VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR VAR S... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import product
lucky = []
for i in range(10):
for p in product([4, 7], repeat=i + 1):
name = ""
fours = 0
sevens = 0
for j in range(len(p)):
name += str(p[j])
if p[j] == 4:
fours += 1
else:
sevens += ... | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR LIST NUMBER NUMBER BIN_OP VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN V... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | n = 0
s = ""
def check():
global n
global s
t = 0
for i in range(0, len(s) // 2):
t *= 10
t += 7
for i in range(0, len(s) // 2):
t *= 10
t += 4
if int(s) > t:
n += 2
def rec(i):
global n
global s
j = i * 10 + 4
k = i * 10 + 7
f1, f2... | ASSIGN VAR NUMBER ASSIGN VAR STRING FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASS... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | N = int(input())
queue = []
queue += [0]
queue[-1] = 0, 0
while len(queue) != 0:
val = queue[0][0]
C = queue[0][1]
if val >= N and C == 0:
print(val)
break
queue.pop(0)
queue.append((val * 10 + 4, C + 1))
queue.append((val * 10 + 7, C - 1)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR LIST NUMBER ASSIGN VAR NUMBER NUMBER NUMBER WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def num(n):
return "7" * (n // 2) + "4" * (n // 2)
def lucky(n):
c4 = 0
c7 = 0
for i in str(n):
if i == "4":
c4 += 1
elif i == "7":
c7 += 1
else:
return False
if c4 == c7:
return True
return False
s = input()
c4 = 0
c7 = 0
n... | FUNC_DEF RETURN BIN_OP BIN_OP STRING BIN_OP VAR NUMBER BIN_OP STRING BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER RETURN NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBE... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | import sys
from itertools import permutations
input = lambda: sys.stdin.readline().strip("\r\n")
n = int(input())
l = len(str(n))
if l % 2:
print("4" * ((l + 1) // 2) + "7" * ((l + 1) // 2))
else:
flag = False
p = permutations(list("4" * (l // 2) + "7" * (l // 2)))
for i in p:
ans = int("".join... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP STRING BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CA... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | n = input()
answer = ""
if len(n) % 2 == 0:
f = len(n) // 2
s = len(n) // 2
for x in n:
if x == "4":
if f > 0:
f -= 1
answer += "4"
else:
s -= 1
answer += "7"
break
elif x == "7" and s > 0... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR NUMBER VAR NUMBER VAR STRING VAR NUMBER VAR STRING IF VAR STRING VAR NUMBER VAR NUMBER VAR STRING IF VAR STRING STRI... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import permutations
number = input()
le = len(number)
l = le - int(le / 2)
n = int(number)
result = [x for x in "4" * l + "7" * l]
if le % 2 == 0:
f = sorted(list(int("".join(x)) for x in set(permutations(result))))
m = 0
for _ in f:
if _ >= n:
print(_)
m += 1... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL STRING VAR VAR FUNC_CALL VAR F... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | n = input()
c4 = n.count("4")
c7 = n.count("7")
def check(n):
for i in n:
if i in "01235689":
return False
return True
while c4 != c7 or check(n) == False:
for i in range(len(n)):
if n[i] not in "47":
break
if int(n[i]) < 4:
n = (
int(n)
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF FOR VAR VAR IF VAR STRING RETURN NUMBER RETURN NUMBER WHILE VAR VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR ... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | lucky = []
def findLucky(s):
if len(s) > 11:
return
ans1 = s + "4"
ans2 = s + "7"
if ans1.count("4") == ans1.count("7"):
lucky.append(int(ans1))
if ans2.count("4") == ans2.count("7"):
lucky.append(int(ans2))
findLucky(s + "4")
findLucky(s + "7")
findLucky("")
luck... | ASSIGN VAR LIST FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR STRING IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR STRING E... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def dfs(fo, se, cur):
if len(cur) == l:
if int(cur) >= num:
mn[0] = min(mn[0], int(cur))
return
if fo:
dfs(fo - 1, se, cur + "4")
if se:
dfs(fo, se - 1, cur + "7")
return
num = input()
l = len(num)
if l & 1:
print("4" * ((l + 1) // 2) + "7" * ((l + 1) //... | FUNC_DEF IF FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR RETURN IF VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR STRING IF VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR STRING RETURN ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import permutations
def check(n, giv):
if n % 2 == 0:
f = []
for i in range(n):
if i % 2 == 0:
f.append(4)
else:
f.append(7)
f = list(permutations(f))
ans = []
for i in f:
ans1 = ""
... | FUNC_DEF IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR STRING IF VAR NUMBER NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VA... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import permutations
ans = []
for i in range(2, 10, 2):
temp = [4, 7] * (i // 2)
x = list(permutations(temp))
for j in x:
t = ""
for k in j:
t += str(k)
ans.append(int(t))
ans.append(4444477777)
ans.sort()
n = int(input())
for i in ans:
if i >= n:
... | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR STRING FOR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_C... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | blanck = set()
def generator(n, seven, four):
if n > 10**12:
return blanck
if seven == four:
blanck.add(n)
generator(n * 10 + 4, seven, four + 1)
generator(n * 10 + 7, seven + 1, four)
generator(0, 0, 0)
a = sorted(list(blanck))
a.append(4444477777)
x = int(input())
for i in a:
i... | ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR BIN_OP NUMBER NUMBER RETURN VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FU... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | n = int(input())
v = []
def solve(cur, four, seven):
if cur > 20000000000.0:
return
if four == seven:
v.append(cur)
solve(cur * 10 + 4, four + 1, seven)
solve(cur * 10 + 7, four, seven + 1)
solve(0, 0, 0)
ans = 20000000000.0
for i in v:
if i >= n:
ans = min(ans, i)
print(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF IF VAR NUMBER RETURN IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMB... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | l = []
limit = 10000000000
def gen(number, four, seven):
if number > limit:
return
if number > 0 and four == seven:
l.append(number)
gen(number * 10 + 4, four + 1, seven)
gen(number * 10 + 7, four, seven + 1)
def main():
gen(0, 0, 0)
l.sort()
n = int(input())
ans = 0
... | ASSIGN VAR LIST ASSIGN VAR NUMBER FUNC_DEF IF VAR VAR RETURN IF VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER FUNC_DEF EXPR FUNC_CALL VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR ... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | d = input()
def correct(f):
c = 0
for i in f:
if int(i):
c -= 1
else:
c += 1
if c == 0:
return True
return False
if len(d) % 2:
k = (len(d) + 1) // 2
print("4" * k + "7" * k)
else:
k = len(d) // 2
if int(d) > int(k * "7" + k * "4"):
... | ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def check(num):
num = list(str(num))
if sorted(set(num)) != ["4", "7"]:
return False
if num.count("4") == num.count("7"):
return True
return False
num = int(input())
no = [0]
while 1:
if check(no[0]) and no[0] >= num:
print(no[0])
break
if no[0] < 10000000000.0:... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR LIST STRING STRING RETURN NUMBER IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER WHILE NUMBER IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR EXPR FUNC... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def gray(n):
if n == 1:
return [4, 7]
l1 = gray(n - 1)
l2 = reversed(l1)
l1 = [int(str(a) + "4") for a in l1]
l2 = [int(str(a) + "7") for a in l2]
return l1 + l2
n = int(input())
z = len(str(n))
l = gray(z) + gray(z + 1) + gray(z + 2)
l.sort()
l = [a for a in l if str(a).count("4") == ... | FUNC_DEF IF VAR NUMBER RETURN LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN V... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | n = input()
x = len(n)
if x % 2 == 0:
a = ["4"] * (x // 2) + ["7"] * (x // 2)
z = ""
if int(n) <= int("7" * (x // 2) + "4" * (x // 2)):
for i in range(x):
if int(n[i]) <= 4:
if "4" in a:
z += "4"
a.pop(a.index("4"))
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP LIST STRING BIN_OP VAR NUMBER BIN_OP LIST STRING BIN_OP VAR NUMBER ASSIGN VAR STRING IF FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP BIN_OP STRING BIN_OP VAR NUMBER BIN_OP STRING BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR ... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import permutations
strs = input()
n = len(strs)
def magic(numList):
s = "".join(map(str, numList))
return int(s)
if n & 1:
nn = n + 1
half = nn // 2
ans = "4" * half + "7" * half
print(ans)
else:
arr = []
for i in strs:
arr.append(int(i))
num = int(strs)
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VA... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | slucky = [4, 7]
i = 0
while slucky[-1] < 10**9:
slucky.append(slucky[i] * 10 + 4)
slucky.append(slucky[i] * 10 + 7)
i += 1
def superlucky(n):
four = 0
seven = 0
while n > 0:
if n % 10 == 4:
four += 1
else:
seven += 1
n = n // 10
if four == se... | ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER A... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | lucky = []
def func(number, fours, sevens):
if number > 10000000000.0:
return
elif fours == sevens:
lucky.append(number)
func(10 * number + 7, fours, sevens + 1)
func(10 * number + 4, fours + 1, sevens)
func(4, 1, 0)
func(7, 0, 1)
n = int(input())
lucky.sort()
for x in lucky:
if ... | ASSIGN VAR LIST FUNC_DEF IF VAR NUMBER RETURN IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR FUN... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | n = int(input())
possible = [0]
i = 0
while True:
k = possible[i]
if k >= n and str(k).count("4") == str(k).count("7"):
print(k)
exit(0)
possible += [10 * k + 4, 10 * k + 7]
i += 1 | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR VAR VAR IF VAR VAR FUNC_CALL FUNC_CALL VAR VAR STRING FUNC_CALL FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER VAR LIST BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER VAR N... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | import sys
from itertools import permutations
n = input()
x = len(n)
if len(n) % 2 == 0:
s = "4" * (x // 2) + "7" * (x // 2)
else:
s = "4" * (x // 2 + 1) + "7" * (x // 2 + 1)
if len(n) % 2 != 0:
sys.stdout.write(s + "\n")
else:
l1 = []
for l in permutations(s, len(s)):
a = int("".join(l))
... | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR NUMBER BIN_OP STRING BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP STRING BIN_OP BIN_OP VAR NUMBER NUMBER IF BIN_OP FUNC_CALL VAR V... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import permutations
n = int(input())
def next_value(x):
arr = ["4"] * x + ["7"] * x
for a in permutations(arr):
y = int("".join(a))
if y >= n:
return y
return -1
for i in range(1, 6):
sol = next_value(i)
if sol != -1:
print(sol)
break | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP LIST STRING VAR BIN_OP LIST STRING VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR IF VAR VAR RETURN VAR RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VA... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | ans = 100000000000.0
def lucky(a, x):
global ans
if a < ans:
if a >= n and x == 0:
ans = a
return
else:
lucky(a * 10 + 4, x + 1)
lucky(a * 10 + 7, x - 1)
n = int(input())
lucky(0, 0)
print(ans) | ASSIGN VAR NUMBER FUNC_DEF IF VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR RETURN EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | import itertools
n = int(input())
def very_happy(num):
banned = "01235689"
for c in banned:
if c in str(num):
return False
if not str(num).count("4") == str(num).count("7"):
return False
else:
return True
if very_happy(n):
print(n)
else:
candidats2 = []
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR STRING FOR VAR VAR IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF FUNC_CALL FUNC_CALL VAR VAR STRING FUNC_CALL FUNC_CALL VAR VAR STRING RETURN NUMBER RETURN NUMBER IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import product
n = int(input())
ans = 0
if len(str(n)) % 2 == 0:
for roll in product([4, 7], repeat=len(str(n))):
temp = [str(i) for i in roll]
if n <= int("".join(temp)) and temp.count("4") == temp.count("7"):
ans = int("".join(temp))
break
else:
for roll... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR LIST NUMBER NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR FUNC_CALL VAR FUNC_CALL STRING VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR FU... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import *
k = int(input())
n = len(str(k))
s = set()
if n % 2 != 0:
n = n + 1
c = ["4", "7"]
a = []
for i in range(n):
a.append(c)
for i in product(*a):
if i.count("7") == i.count("4"):
s.add(int("".join(i)))
ll = sorted(list(s))
if not k <= ll[-2] and k <= ll[-1]:
print(ll[-1])
e... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST STRING STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING FUNC_CALL V... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import permutations
n = input()
if len(n) % 2 == 0:
s = "4" * (len(n) // 2)
s += "7" * (len(n) // 2)
j = ""
for i in list(permutations(s)):
j = ""
for x in range(len(n)):
j += i[x]
if int(j) >= int(n):
print(j)
break
if int(... | ASSIGN VAR FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP STRING BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP STRING BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR IF FUNC_CALL VAR V... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | mx = 99999999999999999
def recur(val, c4, c7, n):
if c4 + c7 > 10:
return 2 * mx
if c4 == c7:
if val >= n:
return val
v4 = recur(val * 10 + 4, c4 + 1, c7, n)
v7 = recur(val * 10 + 7, c4, c7 + 1, n)
return min(v4, v7)
n = int(input())
print(recur(0, 0, 0, n)) | ASSIGN VAR NUMBER FUNC_DEF IF BIN_OP VAR VAR NUMBER RETURN BIN_OP NUMBER VAR IF VAR VAR IF VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER VAR RETURN FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import combinations
n = input()
t = len(n)
if t % 2:
print("4" * (t // 2 + 1) + "7" * (t // 2 + 1))
else:
for com in combinations(range(t), t // 2):
num = ["7"] * t
for s in com:
num[s] = "4"
num = int("".join(num))
if num >= int(n):
print(... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP STRING BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR VAR ASSIGN VAR VAR STRING A... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def check(a):
four = 0
seven = 0
while a > 0:
if a % 10 == 4:
four += 1
elif a % 10 == 7:
seven += 1
else:
return False
a = a // 10
if four == seven:
return True
else:
return False
lucky = []
lucky.append(0)
lucky.... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSI... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | import sys
def input():
return sys.stdin.readline().strip()
def iinput():
return int(input())
def rinput():
return map(int, sys.stdin.readline().strip().split())
def get_list():
return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
n = iinput()
Q = [0]
i = 0
w... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN V... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import permutations as pmt
string = input()
l = len(string)
if l % 2 != 0:
print("4" * ((l + 1) // 2) + "7" * ((l + 1) // 2))
exit()
n = l // 2
worst = "7" * n + "4" * n
if worst < string:
print("4" * (n + 1) + "7" * (n + 1))
exit()
newstr = "4" * n + "7" * n
List = pmt(newstr)
for x in ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP STRING BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR IF VAR VAR EXPR FU... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def uniform(line):
if line.count("1") == line.count("0"):
pass
elif line.count("1") > line.count("0"):
need = line.count("1") * 2 - len(line)
add = "0" * need
line = add + line
elif line.count("1") < line.count("0"):
need = line.count("0") * 2 - len(line)
add ... | FUNC_DEF IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP VAR VAR IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR STRING NUMB... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | n = int(input())
s = [0]
while True:
for i in s:
i = 10 * i
if i + 4 >= n and str(i + 4).count("4") == str(4 + i).count("7"):
print(i + 4)
exit()
elif i + 7 >= n and str(i + 7).count("4") == str(7 + i).count("7"):
print(i + 7)
exit()
el... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER WHILE NUMBER FOR VAR VAR ASSIGN VAR BIN_OP NUMBER VAR IF BIN_OP VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR BIN_OP VAR NUMBER STRING FUNC_CALL FUNC_CALL VAR BIN_OP NUMBER VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR ... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | l = ["4", "7"]
pre = 0
for k in range(7):
le = len(l)
while pre < le:
l += [l[pre] + "4", l[pre] + "7"]
pre += 1
n = int(input())
m = []
for p in l:
if p.count("4") == p.count("7"):
m += [int(p)]
m.sort()
m += [4444477777]
for ij in m:
if ij >= n:
print(ij)
break | ASSIGN VAR LIST STRING STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR LIST BIN_OP VAR VAR STRING BIN_OP VAR VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING VAR LIST FUNC_CALL VAR V... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | num = input()
def fun(temp, size4, size7):
if size4 == 0 and size7 == 0:
if int(temp) >= int(num):
return int(temp)
else:
return 999999999999999999999999
if size4 == 0:
for i in range(size7):
temp += "7"
if int(temp) >= int(num):
... | ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR RETURN NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR STRING IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR RETURN NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR STRING IF ... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | MAX = 10**10
def doit(cur, n4, n7):
if cur > MAX:
return
if n4 == n7:
a.append(cur)
doit(cur * 10 + 4, n4 + 1, n7)
doit(cur * 10 + 7, n4, n7 + 1)
a = []
doit(0, 0, 0)
a.sort()
n = int(input())
for v in a:
if v >= n:
print(v)
exit()
raise Exception | ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF IF VAR VAR RETURN IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | ans = 10000000000000
g = int(input())
s = int(0)
def vet(n, m):
global ans, s
if s < ans and s >= g and n == m:
ans = s
if n > 0:
s = s * 10 + 4
vet(n - 1, m)
s //= 10
if m > 0:
s = s * 10 + 7
vet(n, m - 1)
s //= 10
vet(5, 5)
print(ans) | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER FUNC_DEF IF VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | n = int(input())
ln = len(str(n))
lucky = [0]
if ln % 2 == 1:
cn = (ln + 1) // 2
res = cn * "4" + cn * "7"
else:
i = 0
while lucky[i] < 10**10:
lucky.append(lucky[i] * 10 + 4)
lucky.append(lucky[i] * 10 + 7)
i += 1
for j in range(len(lucky)):
if lucky[j] >= n and str(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR STRING BIN_OP VAR STRING ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR ... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | import itertools as it
s = input()
n = len(s)
if n & 1 == 0:
fc = n // 2
sc = n // 2
else:
fc = n // 2 + 1
sc = n // 2 + 1
l = []
for i in range(fc):
l.append("4")
for i in range(sc):
l.append("7")
pp = list(it.permutations(l))
res = ""
flag = 0
for i in range(len(pp)):
st = "".join(pp[i])
... | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL V... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def f(n, m):
k = 2 * m
for i in range(1 << k):
j = format(i, "b")
if j.count("1") == m:
j = j.replace("0", "4")
j = j.replace("1", "7")
j = "4" * (k - len(j)) + j
if int(j) >= n:
return j
t = input()
n, k = int(t), len(t)
m = (k +... | FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR STRING IF FUNC_CALL VAR STRING VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR VAR RETURN VAR... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | n = input()
length = len(n)
if length % 2 == 1:
result = "4" * ((length + 1) // 2) + "7" * ((length + 1) // 2)
else:
half = length // 2
if n > half * "7" + half * "4":
result = (half + 1) * "4" + (half + 1) * "7"
elif n < half * "4" + half * "7":
result = half * "4" + half * "7"
else... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP STRING BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP BIN_OP VAR STRING BIN_OP VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER STRING... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | a = []
def f(n, x):
if x <= 100000000000.0:
if x >= n and str(x).count("4") == str(x).count("7"):
a.append(x)
f(n, 10 * x + 4)
f(n, 10 * x + 7)
f(int(input()), 0)
a.sort()
print(a[0]) | ASSIGN VAR LIST FUNC_DEF IF VAR NUMBER IF VAR VAR FUNC_CALL FUNC_CALL VAR VAR STRING FUNC_CALL FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER EXPR FUNC_CAL... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | l = []
def rec(x):
if len(x) > 12:
return
if len(x) > 0 and x.count("4") == x.count("7"):
l.append(int(x))
rec(x + "4")
rec(x + "7")
rec("")
l = set(l)
l = sorted(list(l))
i = 0
N = int(input())
if N in l:
print(N)
else:
while l[i] < N:
i += 1
print(l[i]) | ASSIGN VAR LIST FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import permutations
numstr = input()
size = len(numstr) if len(numstr) % 2 == 0 else len(numstr) + 1
halfsize = size // 2
if len(numstr) <= 8:
premuts = [int("".join(p)) for p in permutations(["4", "7"] * halfsize)]
premuts.append(int("4" * (halfsize + 1) + "7" * (halfsize + 1)))
premuts.sor... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR VAR FUNC_CALL VAR BIN_OP LIST STRING STRING VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | z = []
for i in range(1, 11):
for j in range(1 << i):
s = bin(j)
s = s[2:]
if s.count("1") == s.count("0"):
z += [int(s.replace("1", "4").replace("0", "7"))] + [
int(s.replace("1", "7").replace("0", "4"))
]
z.sort()
a = int(input())
for i in z:
if ... | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING VAR BIN_OP LIST FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING STRING STRING STRING LIST FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def run(n):
l = len(n)
if l % 2 == 1:
result = "4" * (l // 2 + 1) + "7" * (l // 2 + 1)
print(result)
return result
if n > "7" * (l // 2) + "4" * (l // 2):
result = "4" * (l // 2 + 1) + "7" * (l // 2 + 1)
print(result)
return result
def set_range(p, start,... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP STRING BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR IF VAR BIN_OP BIN_OP STRING BIN_OP VAR NUMBER BIN_OP STRING BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING ... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | import sys
n = input()
A = [4, 7]
C = [0, 0]
m = 0
def permutation(c, result):
if len(result) == m:
t = int("".join(map(str, result)))
if t >= n:
print(t)
sys.exit()
else:
for i in range(2):
if c[i] > 0:
result.append(A[i])
... | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER FUNC_DEF IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CA... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | all = []
def solve(n, four, seven):
if four is seven and four != 0:
all.append(n)
if n >= 10000000000.0:
return True
solve(n * 10 + 4, four + 1, seven)
solve(n * 10 + 7, four, seven + 1)
return True
n = int(input())
solve(0, 0, 0)
all.sort()
for x in all:
if x >= n:
p... | ASSIGN VAR LIST FUNC_DEF IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER RETURN NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMB... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import permutations
n = input()
l = len(n)
r = "4" * (l // 2)
r += "7" * (l // 2)
if l % 2 == 1:
r = "4" + r + "7"
else:
for i in permutations(r):
i = "".join(i)
if n <= i:
r = i
break
if r < n:
r = "4" + r + "7"
print(r) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING BIN_OP VAR NUMBER VAR BIN_OP STRING BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP STRING VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING VAR IF VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | gh = set()
def rep(n, four, seven):
global gh
if n > 10000000000:
return
if four == seven:
gh |= {n}
rep(n * 10 + 4, four + 1, seven)
rep(n * 10 + 7, four, seven + 1)
rep(0, 0, 0)
gh = sorted(gh)
def bin_s(a):
lo = 0
hi = len(gh)
ans = 0
while lo <= hi:
... | ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN IF VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSI... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | arr = []
def lucky(n, curr):
if n <= 2 and n >= 0:
if str(curr).count("4") == str(curr).count("7"):
arr.append(curr)
if n < 0:
return
else:
lucky(n - 1, curr * 10 + 4)
lucky(n - 1, curr * 10 + 7)
n = int(input())
m = 0
if len(str(n)) % 2 == 1:
m = len(str(... | ASSIGN VAR LIST FUNC_DEF IF VAR NUMBER VAR NUMBER IF FUNC_CALL FUNC_CALL VAR VAR STRING FUNC_CALL FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR IF VAR NUMBER RETURN EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | n = input()
k = len(n) / 2
k1 = k
r1 = -1
r2 = -1
s1 = ""
p = False
g = -1
s = ""
def anis():
if g == -1:
print("4" * int((len(n) + 2) / 2) + "7" * int((len(n) + 2) / 2))
else:
print(s1 + "4" * int(r) + "7" * int(r1))
exit()
i = -1
if len(n) % 2 != 0:
anis()
while True:
i += 1
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING FUNC_DEF IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER BIN_OP... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | import sys
line = sys.stdin.readline().strip()
def run(i, nFour, nSeven, s, added):
n = len(line)
if i == n:
print(s)
return True
v = ord(line[i]) - ord("0")
if (added or v <= 4) and nFour > 0:
if run(i + 1, nFour - 1, nSeven, s + "4", added or v < 4):
return True
... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING IF VAR VAR NUMBER VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR STRING VAR VAR NUMBER RETURN NUMBE... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | x = input()
sz = (len(x) + 1) // 2
if len(x) % 2 == 1:
print("4" * sz + "7" * sz)
elif int(x) > int("7" * sz + "4" * sz):
print("4" * (sz + 1) + "7" * (sz + 1))
else:
ans = ""
left_4, left_7 = sz, sz
for i in range(len(x)):
if int(x) > int(ans + "4" + "7" * left_7 + "4" * (left_4 - 1)) or le... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING BIN_OP VAR NUMBE... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def luckynumwithequalnumberoffourandseven(x, n, a):
if x >= n and str(x).count("4") == str(x).count("7"):
a.append(x)
elif x < 1000000000000.0:
luckynumwithequalnumberoffourandseven(x * 10 + 4, n, a)
luckynumwithequalnumberoffourandseven(x * 10 + 7, n, a)
return a
def main():
n... | FUNC_DEF IF VAR VAR FUNC_CALL FUNC_CALL VAR VAR STRING FUNC_CALL FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | n = int(input())
t = 0
b = ["00", "01", "10", "11"]
a = ["00", "01", "10", "11"]
while t <= 7:
c = []
for i in a:
b.append("0" + i)
c.append("0" + i)
for i in a:
b.append("1" + i)
c.append("1" + i)
a = c
t += 1
k = []
for i in b:
if i.count("0") == i.count("1"):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST STRING STRING STRING STRING ASSIGN VAR LIST STRING STRING STRING STRING WHILE VAR NUMBER ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FU... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | import sys
def lucky(val, c4, c7, cnt):
if max(c4, c7) > int(cnt / 2):
return
if c4 + c7 == cnt:
if val >= n:
print(val)
sys.exit()
lucky(val * 10 + 4, c4 + 1, c7, cnt)
lucky(val * 10 + 7, c4, c7 + 1, cnt)
n = int(input())
i = 2
while True:
lucky(0, 0, 0, ... | IMPORT FUNC_DEF IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER RETURN IF BIN_OP VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR ... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | number = list(input())
new_number = []
if len(number) % 2 == 0:
already_bigger = False
for digit in number:
digit = int(digit)
if already_bigger:
new_number += [4]
elif digit == 4 or digit == 7:
new_number += [digit]
else:
already_bigger = True... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR LIST NUMBER IF VAR NUMBER VAR NUMBER VAR LIST VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR LIST NUMBER IF VAR NUMBER VAR LIST NUMBER IF NUMBER VAR EXPR FUNC_C... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import permutations as perm
from sys import stdin, stdout
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().split()))
isa = lambda: stdin.readline().strip().split()
mod = 1000000007
pos = []
n = 2
while n <= 8:
cur... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR NU... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | store = []
def getAns(n, a, b, s):
if n == 0:
store.append(int(s))
return
if a > 0 and b > 0:
getAns(n - 1, a - 1, b, s + "4")
getAns(n - 1, a, b - 1, s + "7")
elif a == 0:
getAns(n - 1, a, b - 1, s + "7")
else:
getAns(n - 1, a - 1, b, s + "4")
N = int... | ASSIGN VAR LIST FUNC_DEF IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def check(x):
a = b = 0
for i in str(x):
if i == "4":
a += 1
elif i == "7":
b += 1
return a == b
n = int(input())
q = [0]
while True:
if check(q[0]) and q[0] >= n:
print(q[0])
break
q.append(q[0] * 10 + 4)
q.append(q[0] * 10 + 7)
q.po... | FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER WHILE NUMBER IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import permutations
n = input()
nl = len(n)
if len(n) % 2 == 1:
print("4" * (nl // 2 + 1) + "7" * (nl // 2 + 1))
else:
psa = permutations(list("4" * (nl // 2) + "7" * (nl // 2)), nl)
for i in psa:
if int("".join(i)) >= int(n):
print(int("".join(i)))
break
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP STRING BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP STRING BIN_OP VAR NUMBER BIN_OP STRING BIN_OP VAR NUM... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def gen(k, number, bal):
if k == 11:
return
if bal == 0:
numbers.append(number)
gen(k + 1, number * 10 + 4, bal + 1)
gen(k + 1, number * 10 + 7, bal - 1)
n = int(input())
numbers = []
gen(0, 0, 0)
numbers.sort()
i = 0
while n > numbers[i]:
i += 1
print(numbers[i]) | FUNC_DEF IF VAR NUMBER RETURN IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBE... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import permutations
def solve(x):
for d in range(1, 6):
for p in permutations([4] * d + [7] * d):
y = 0
for e in p:
y = 10 * y + e
if y >= x:
return y
print(solve(int(input()))) | FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR IF VAR VAR RETURN VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import permutations
n = int(input())
k = len(str(n))
if k % 2 != 0:
print("4" * ((k + 1) // 2) + "7" * ((k + 1) // 2))
else:
flag = 0
z = list("4" * (k // 2) + "7" * (k // 2))
m = permutations(z)
ans = []
for i in m:
u = int("".join(i))
if u >= n:
prin... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP STRING BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP STRING BIN_OP VAR NUMBER BIN_OP STR... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def foo():
l = [4, 7]
while len(str(l[-1])) <= 12:
z = []
for i in range(0, len(l)):
for j in range(0, len(l)):
s = str(l[i]) + str(l[j])
if len(s) >= 12:
l = l + z
return l
z.append(int(s))
... | FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER WHILE FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR RET... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def main():
mode = "filee"
if mode == "file":
f = open("test.txt", "r")
get = lambda: [
int(x) for x in (f.readline() if mode == "file" else input()).split()
]
[n] = get()
h = ["4", "7"]
while int("".join(h)) < n:
g = list(h)
g.sort()
g.reverse()
... | FUNC_DEF ASSIGN VAR STRING IF VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR FUNC_CALL VAR ASSIGN LIST VAR FUNC_CALL VAR ASSIGN VAR LIST STRING STRING WHILE FUNC_CALL VAR FUNC_CALL STRING VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR ... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | Min = int(10**10)
n = input()
def next(x, a, f, s):
global Min
global n
if len(x) > 0:
if a == "" or int(a) >= int(n[0 : len(a)]):
if f + 1 <= len(n) / 2:
next(x[1:], a + "4", f + 1, s)
if s + 1 <= len(n) / 2:
next(x[1:], a + "7", f, s + 1)
... | ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF FUNC_CALL VAR VAR NUMBER IF VAR STRING FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER BIN_OP VAR STRING BIN_OP VAR NUMBER VAR IF BIN_OP VAR ... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | import itertools
num = input()
n = len(num)
if n % 2 == 1:
n += 1
print("4" * (n // 2) + "7" * (n // 2))
exit()
if int("7" * (n // 2) + "4" * (n // 2)) < int(num):
n += 2
print("4" * (n // 2) + "7" * (n // 2))
exit()
if int(num[0]) < 4:
print("4" * (n // 2) + "7" * (n // 2))
exit()
num ... | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING BIN_OP VAR NUMBER BIN_OP STRING BIN_OP VAR NUMBER EXPR FUNC_CALL VAR IF FUNC_CALL VAR BIN_OP BIN_OP STRING BIN_OP VAR NUMBER BIN_OP STRING BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR N... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | from itertools import permutations
s = input()
n = len(s)
if n & 1:
k = (n + 1) // 2
print("4" * k + "7" * k)
elif int(s) >= 99999999:
print("4444477777")
else:
k = n // 2
z = "4" * k + "7" * k
p = "4" * (k + 1) + "7" * (k + 1)
l = list(permutations(z))
l = ["".join(x) for x in l]
l... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR ASS... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | sa = int(input())
suplucky = [
47,
74,
4477,
4747,
4774,
7447,
7474,
7744,
747447,
744747,
744774,
477744,
444777,
777444,
447477,
747474,
774744,
474774,
474477,
447747,
774474,
447774,
744477,
774447,
747744,
47744... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMB... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | def check(x):
if x < n:
return
y = x
a = 0
b = 0
while x:
if x % 10 - 4:
a += 1
if x % 10 - 4 == 0:
b += 1
x = x // 10
if a == b:
print(y)
exit()
n = int(input())
q = [0] * 1000000
front = 1
rear = 1
while front <= rear:
... | FUNC_DEF IF VAR VAR RETURN ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR IF BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR B... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | a = []
def lucky(n):
if n > 10**10:
return
else:
h = str(n)
if h.count("4") == h.count("7"):
a.append(n)
lucky(10 * n + 4)
lucky(n * 10 + 7)
lucky(0)
a.sort()
n = int(input())
l = 0
r = len(a) - 1
ans = 0
while l <= r:
m = l + (r - l) // 2
if a[m] ... | ASSIGN VAR LIST FUNC_DEF IF VAR BIN_OP NUMBER NUMBER RETURN ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | n = int(input())
for i in range(1, 10 + 1):
for j in range(1 << i):
k = "".join([("7" if j & 1 << l else "4") for l in range(i)][::-1])
if k.count("4") == k.count("7") and int(k) >= n:
print(k)
exit() | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL STRING BIN_OP VAR BIN_OP NUMBER VAR STRING STRING VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR E... |
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. Fo... | while True:
try:
def solution(n):
i = 0
lnum = list()
lnum = [0]
while True:
if lnum[i] >= n and str(lnum[i]).count("7") == str(lnum[i]).count("4"):
print(str(lnum[i]))
break
t = 10 * lnu... | WHILE NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER WHILE NUMBER IF VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR STRING FUNC_CALL FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.