description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | n = input()
def valid(x):
i = 0
for ch in n:
if ch == x[i]:
i += 1
if i == len(x):
return True
return False
for i in range(0, 1000, 8):
if valid(str(i)):
print("YES")
print(i)
exit()
print("NO") | ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | from itertools import combinations
def is_divisible(s, k):
best = [-1] * min(len(s), k)
mx = 0
for x in combinations(list(range(0, len(s))), min(len(s), k)):
if int("".join(s[i] for i in x)) % 8 == 0:
length = len(s) - (x[-1] - x[0]) - (len(s) - x[-1] - 1) + len(x) - 1
if length > mx:
mx = length
best = x
if best[0] != -1 or k == 1:
return best
return is_divisible(s, min(len(s), k) - 1)
def solve():
s = input()
if len(s) == 1 and int(s) % 8 != 0:
print("NO")
return
res = is_divisible(s, 3)
if res[0] != -1:
print("YES")
if s[res[0]] == "0":
print(s[res[0]])
elif len(res) < 3:
print("".join(s[i] for i in res))
else:
print(s[0 : res[0] + 1] + "".join(s[i] for i in res[1:]))
else:
print("NO")
solve() | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF BIN_OP FUNC_CALL VAR FUNC_CALL STRING VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER NUMBER VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING IF VAR VAR NUMBER STRING EXPR FUNC_CALL VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER FUNC_CALL STRING VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = input()
if "0" in s:
print("YES")
print("0")
exit(0)
s = "00" + s
for i in range(len(s)):
for j in range(i + 1, len(s)):
for k in range(j + 1, len(s)):
a = ord(s[i]) - ord("0")
b = ord(s[j]) - ord("0")
c = ord(s[k]) - ord("0")
ss = s[i] + s[j] + s[k]
if (100 * a + 10 * b + c) % 8 == 0:
print("YES")
ss = ss.replace("0", "", ss.count("0"))
print(ss)
exit(0)
print("NO") | ASSIGN VAR FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP STRING VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | in_x = input()
n = list(in_x)
length = len(n)
counter = 0
counter_2 = 0
for _ in range(length):
temp = n[:]
if counter > 0:
temp.pop(counter)
counter += 1
for j in range(0, len(temp)):
if j > 0:
temp.pop(length - 1 - j)
num = int("".join(temp))
if num % 8 == 0:
print(f"YES\n{num}")
exit()
temp = n[:]
if counter_2 > 0:
temp.pop(counter_2)
counter_2 += 1
for j in range(len(temp), 1, -1):
temp.pop(j - len(temp))
num = int("".join(temp))
if num % 8 == 0:
print(f"YES\n{num}")
exit()
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | import itertools
s = list(input())
b = 1
r = 1
e = 1
for x in range(1, len(s)):
if int("".join(s[:x])) % 8 == 0:
r = x + 1
print("YES")
print("".join(s[: r - 1]))
b = 0
break
for x in range(len(s) - 1, 0, -1):
if int(s[x]) % 2 == 0:
r = x + 1
break
s = s[:r]
if not b == 0:
z = False
for y in range(1, int(len(s) / 2) + 1):
e = 1
for x in range(0, len(s) - y, y):
if s[x : x + y] != s[x + y : x + 2 * y]:
e = 0
break
z = True
if z:
break
if e == 1 and not b == 0:
b = 0
if int("".join(s)) % 8 != 0:
print("NO")
else:
print("YES")
print("".join(s))
def pro(s, f):
for x in range(len(s)):
for y in list(itertools.combinations(s, x + 1)):
t = int("".join(y))
if t % f == 0:
print("YES")
print(t)
return t
print("NO")
return -1
z = 4
for y in range(len(s)):
x = int(s[y])
if x % 2 != 0 or b == 0:
break
if x != z and x == 6 and x % 2 == 0:
z = x
if x != z and x == 2 and x % 2 == 0 and y == len(s) - 1:
b = 0
print("NO")
break
if not b == 0:
pro(s, 8) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR FUNC_CALL STRING VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR VAR IF VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP FUNC_CALL VAR FUNC_CALL STRING VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR RETURN VAR EXPR FUNC_CALL VAR STRING RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR IF VAR VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | def solve(s):
s = list(map(int, s))
n = len(s)
for i1 in range(n):
if s[i1] % 8 == 0:
return s[i1]
for i1 in range(n):
for i2 in range(i1 + 1, n):
if (s[i1] * 10 + s[i2]) % 8 == 0:
return s[i1] * 10 + s[i2]
for i1 in range(n):
for i2 in range(i1 + 1, n):
for i3 in range(i2 + 1, n):
if (s[i1] * 100 + s[i2] * 10 + s[i3]) % 8 == 0:
return s[i1] * 100 + s[i2] * 10 + s[i3]
return -1
def solve_str(s):
if solve(s) == -1:
return "NO"
else:
return "YES\n" + str(solve(s))
s = input()
print(solve_str(s)) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER RETURN VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER NUMBER RETURN BIN_OP BIN_OP VAR VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR VAR NUMBER NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR VAR RETURN NUMBER FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN STRING RETURN BIN_OP STRING FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | def isSubSequence(subString, string, m=-1, n=-1):
if m == -1:
m = len(subString)
if n == -1:
n = len(string)
if m == 0:
return True
if n == 0:
return False
if subString[m - 1] == string[n - 1]:
return isSubSequence(subString, string, m - 1, n - 1)
return isSubSequence(subString, string, m, n - 1)
line = input()
possibilities = [str(8 * k) for k in range(125)]
for e in possibilities:
if isSubSequence(e, line):
print("YES\n" + e)
exit()
print("NO") | FUNC_DEF NUMBER NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
lst = [
16,
24,
32,
56,
64,
72,
96,
112,
136,
144,
152,
176,
192,
216,
224,
232,
256,
264,
272,
296,
312,
336,
344,
352,
376,
392,
416,
424,
432,
456,
464,
472,
496,
512,
536,
544,
552,
576,
592,
616,
624,
632,
656,
664,
672,
696,
712,
736,
744,
752,
776,
792,
912,
936,
944,
952,
976,
992,
]
n = cin()[:-1]
if "0" in n:
cout("YES\n0")
exit(0)
if "8" in n:
cout("YES\n8")
exit(0)
for s in lst:
k = 0
for ch in str(s):
f = 1
for i in range(k, len(n)):
if n[i] == ch:
k = i + 1
f = 0
break
if f:
break
else:
cout("YES\n" + str(s))
break
else:
cout("NO\n") | ASSIGN VAR VAR ASSIGN VAR 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 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 NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | flag = "NO"
ans = ""
def mai():
n = input()
l = len(n)
global flag, ans
if "0" in n:
flag = "YES"
ans = "0"
return
if "8" in n:
flag = "YES"
ans = "8"
return
for i in range(l):
for j in range(i + 1, l):
for k in range(j + 1, l):
if int(n[i] + n[j] + n[k]) % 8 == 0:
flag = "YES"
ans = n[i] + n[j] + n[k]
return
elif int(n[i] + n[j]) % 8 == 0:
flag = "YES"
ans = n[i] + n[j]
return
elif int(n[i] + n[k]) % 8 == 0:
flag = "YES"
ans = n[i] + n[k]
return
elif int(n[j] + n[k]) % 8 == 0:
flag = "YES"
ans = n[j] + n[k]
return
mai()
print(flag)
print(ans) | ASSIGN VAR STRING ASSIGN VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF STRING VAR ASSIGN VAR STRING ASSIGN VAR STRING RETURN IF STRING VAR ASSIGN VAR STRING ASSIGN VAR STRING RETURN FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR RETURN IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR VAR VAR VAR RETURN IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR VAR VAR VAR RETURN IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR VAR VAR VAR RETURN EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | def printans(i, j):
if prev[i][j] == -1:
print(arr[i], end="")
return
k = prev[i][j]
printans(i - 1, k)
if (k * 10 + arr[i]) % 8 == j:
print(arr[i], end="")
arr = [int(x) for x in input()]
n = len(arr)
dp = [([0] * 8) for i in range(n)]
prev = [([-1] * 8) for i in range(n)]
dp[0][arr[0] % 8] = 1
for i in range(1, n):
dp[i][arr[i] % 8] = 1
for j in range(8):
if dp[i - 1][j] and dp[i][(j * 10 + arr[i]) % 8] == 0:
dp[i][(j * 10 + arr[i]) % 8] = 1
prev[i][(j * 10 + arr[i]) % 8] = j
if dp[i - 1][j] and not dp[i][j]:
dp[i][j] = 1
prev[i][j] = j
ans = "NO"
for i in range(n):
if dp[i][0]:
ans = "YES"
break
print(ans)
if ans == "YES":
printans(i, 0)
print() | FUNC_DEF IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR STRING RETURN ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR STRING EXPR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | l = list(map(int, input()))
o = 0
e = 0
for i in range(len(l)):
if l[i] % 2 == 0:
e = e + 1
else:
o = o + 1
n = len(l)
if o == len(l):
print("NO")
else:
t = 0
for i in range(len(l)):
if t == 1:
break
elif int(str(l[i])) % 8 == 0:
print("yes")
print(str(l[i]))
t = 1
break
for j in range(i + 1, len(l)):
if t == 1:
break
elif int(str(l[i]) + str(l[j])) % 8 == 0:
print("yes")
print(str(l[i]) + str(l[j]))
t = 1
break
for k in range(j + 1, len(l)):
if int(str(l[i]) + str(l[j]) + str(l[k])) % 8 == 0:
print("yes")
print(str(l[i]) + str(l[j]) + str(l[k]))
t = 1
break
if t == 0:
print("NO") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER IF BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER IF BIN_OP FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = input()
if int(s) % 8 == 0:
print("YES")
print(s)
elif s.count("0") != 0:
print("YES")
print("0")
elif s.count("8") != 0:
print("YES")
print("8")
else:
bdr = 0
res = ""
for k in range(2, 125):
j = 8 * k
t = s
i = str(j)
p = ""
if len(i) == 2 and int(i) < int(s):
i0 = i[0]
i1 = i[1]
x1 = s.find(i0)
if x1 != -1 and x1 != len(s) - 1:
t = s[x1 + 1 : len(s)]
if t.find(i1) != -1:
bdr = 1
res = i
break
if len(i) == 3 and int(i) < int(s):
i0 = i[0]
i1 = i[1]
i2 = i[2]
x1 = s.find(i0)
if x1 != -1 and x1 != len(s) - 1:
t = s[x1 + 1 : len(s)]
x2 = t.find(i1)
if x2 != len(s) - 1 and x2 != -1:
p = t[x2 + 1 : len(s)]
if p.find(i2) != -1:
bdr = 1
res = i
break
if bdr == 1:
print("YES")
print(res)
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | def check(s, a):
if s in a:
print("YES")
print(int(s))
return 1
else:
return 0
a = input()
l = len(a)
flag = 0
s = ["8", "16", "24", "32", "40", "48", "56", "64", "72", "80", "88", "96", "0"]
i = 0
while flag != 1 and i != 13:
flag = check(s[i], a)
i += 1
if flag == 0:
for i in range(l - 2):
for j in range(i + 1, l - 1):
for k in range(j + 1, l):
temp = int(a[i]) * 100 + int(a[j]) * 10 + int(a[k])
if divmod(temp, 8)[1] == 0:
flag = 1
print("YES")
print(temp)
break
else:
continue
else:
continue
break
else:
continue
break
if flag == 0:
for i in range(l - 1):
for j in range(i + 1, l):
temp = int(a[i]) * 10 + int(a[j])
if divmod(temp, 8)[1] == 0:
print("YES")
print(temp)
flag = 1
break
if flag == 0:
print("NO") | FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | n = input()
if int(n) % 8 == 0:
print("YES")
print(n)
exit()
elif "0" in n:
print("YES")
print(0)
exit()
elif "8" in n:
print("YES")
print(8)
exit()
elif n.find("1") < n.rfind("6") and "1" in n and "6" in n:
print("YES")
print(16)
exit()
elif n.find("2") < n.rfind("4") and "2" in n and "4" in n:
print("YES")
print(24)
exit()
elif n.find("3") < n.rfind("2") and "3" in n and "2" in n:
print("YES")
print(32)
exit()
elif n.find("5") < n.rfind("6") and "5" in n and "6" in n:
print("YES")
print(56)
exit()
elif n.find("6") < n.rfind("4") and "6" in n and "4" in n:
print("YES")
print(64)
exit()
elif n.find("7") < n.rfind("2") and "7" in n and "2" in n:
print("YES")
print(72)
exit()
elif n.find("9") < n.rfind("6") and "9" in n and "6" in n:
print("YES")
print(92)
exit()
if len(n) <= 2:
print("NO")
exit()
for i in range(len(n)):
for j in range(i + 1, len(n)):
for k in range(j + 1, len(n)):
if int(n[i] + n[j] + n[k]) % 8 == 0:
print("YES")
print(n[i] + n[j] + n[k])
exit()
print("NO") | ASSIGN VAR FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING STRING VAR STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | n = input()
sts = []
progs = []
res = False
for num in range(0, 1000, 8):
st = str(num)
sts.append(st)
progs.append(0)
for ch in n:
for i in range(0, 125):
if sts[i][progs[i]] == ch:
progs[i] += 1
if progs[i] == len(sts[i]):
res = True
print("YES")
print(sts[i])
break
else:
continue
break
if not res:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR IF VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | n = input()
n = "00" + n
for i in range(len(n)):
for j in range(i + 1, len(n)):
for k in range(j + 1, len(n)):
a = (ord(n[i]) - 48) * 100 + (ord(n[j]) - 48) * 10 + (ord(n[k]) - 48)
if a % 8 == 0:
print("YES")
print(a)
exit(0)
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP STRING VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = input()
s1 = len(s)
flag = 0
if s.count("0") > 0:
r = 0
flag = 1
if flag == 0:
for i in range(s1):
r = int(s[i])
if r % 8 == 0:
flag = 1
break
if flag == 0:
for i in range(s1 - 1):
for j in range(i + 1, s1):
r = int(s[i] + s[j])
if r % 8 == 0:
flag = 1
break
if flag:
break
if flag == 0:
for i in range(s1 - 2):
for j in range(i + 1, s1 - 1):
for k in range(j + 1, s1):
r = int(s[i] + s[j] + s[k])
if r % 8 == 0:
flag = 1
break
if flag:
break
if flag:
break
if flag:
print("YES")
print(r)
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR IF VAR IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | def check(s):
for i in range(len(s) - 2):
for j in range(i + 1, len(s) - 1):
for k in range(j + 1, len(s)):
if int(s[i] + s[j] + s[k]) % 8 == 0:
return int(s[i] + s[j] + s[k])
for i in range(len(s) - 1):
for j in range(i + 1, len(s)):
if int(s[i] + s[j]) % 8 == 0:
return int(s[i] + s[j])
return -1
s = input()
if "0" in s:
print("YES")
print(0)
elif "8" in s:
print("YES")
print(8)
else:
answ = check(s)
if answ >= 0:
print("YES")
print(answ)
else:
print("NO") | FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR NUMBER NUMBER RETURN FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | def main():
s = input()[::-1]
for i in range(0, 1000, 8):
start = 0
for c in reversed(str(i)):
stop = s.find(c, start)
if stop == -1:
break
else:
start = stop + 1
else:
print("YES")
print(i)
return
print("NO")
main() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR RETURN EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | def main():
S = input()
for i in range(len(S)):
if int(S[i]) % 8 == 0:
print("YES")
print(int(S[i]))
return
for i in range(len(S)):
for j in range(i + 1, len(S)):
if int(S[i] + S[j]) % 8 == 0:
print("YES")
print(int(S[i] + S[j]))
return
for i in range(len(S)):
for j in range(i + 1, len(S)):
for k in range(j + 1, len(S)):
a = S[i] + S[j] + S[k]
if int(a) % 8 == 0:
print("YES")
print(int(a))
return
print("NO")
main() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR RETURN FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | a = list(input())
l = len(a)
check = 0
ans = ""
for i in range(l):
if check:
break
if int(a[i]) % 8 == 0:
ans = a[i]
check = 1
break
for j in range(i + 1, l):
if check:
break
next = a[i] + a[j]
if int(next) % 8 == 0:
ans = next
check = 1
break
for k in range(j + 1, l):
next2 = next + a[k]
if int(next2) % 8 == 0:
ans = next2
check = 1
break
if check:
print("YES")
print(ans)
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | import sys
s = sys.stdin.readline().strip()
f = {(0): "0", (1): "", (2): "", (3): "", (4): "", (5): "", (6): "", (7): ""}
empty = {
(0): False,
(1): True,
(2): True,
(3): True,
(4): True,
(5): True,
(6): True,
(7): True,
}
for i in range(len(s)):
if len(f[0]) > 1:
break
for j in f.keys():
if len(f[j]) >= 1 and empty[j] == False:
if (
len(f[(j * 10 + int(s[i])) % 8]) == 0 == 0
or (j * 10 + int(s[i])) % 8 == 0
):
f[(j * 10 + int(s[i])) % 8] = f[j] + s[i]
for j in empty.keys():
if f[j] != "":
empty[j] = False
if len(f[0]) > 1:
print("YES")
print(f[0][1:])
else:
print("NO") | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR NUMBER VAR VAR NUMBER IF FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR IF VAR VAR STRING ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | import sys
def get_is_div8(n):
for i in range(0, len(n)):
if int(n[i]) % 8 == 0:
return int(n[i])
for i in range(0, len(n)):
for j in range(i + 1, len(n)):
if int(n[i] + n[j]) % 8 == 0:
return int(n[i] + n[j])
for i in range(0, len(n)):
for j in range(i + 1, len(n)):
for k in range(j + 1, len(n)):
if int(n[i] + n[j] + n[k]) % 8 == 0:
return int(n[i] + n[j] + n[k])
return -1
for line in sys.stdin:
result = get_is_div8(line.strip())
if result == -1:
print("NO")
else:
print("YES")
print(result) | IMPORT FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER RETURN FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR NUMBER NUMBER RETURN FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR RETURN NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | import sys
n = str(sys.stdin.readline())
nums = []
for num in n:
if num == "0":
print("YES")
print("0")
exit()
elif num == "8":
print("YES")
print("8")
exit()
else:
nums.append(num)
l = len(n)
for i1 in range(l):
for i2 in range(i1 + 1, l):
ret = n[i1] + n[i2]
if int(ret) % 8 == 0:
print("YES")
print(ret)
exit()
for i1 in range(l):
for i2 in range(i1 + 1, l):
for i3 in range(i2 + 1, l):
ret = n[i1] + n[i2] + n[i3]
if int(ret) % 8 == 0:
print("YES")
print(ret)
exit()
print("NO") | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = input()
b = 0
for i in range(len(s) + 1):
for j in range(len(s) + 1):
for k in range(len(s) + 1):
if i < len(s) and (i == j or i == k):
continue
if j < len(s) and j == k:
continue
if not i <= j <= k:
continue
t = (
(s[i] if i < len(s) else "")
+ (s[j] if j < len(s) else "")
+ (s[k] if k < len(s) else "")
)
if len(t) > 0 and int(t) % 8 == 0:
print("YES\n" + str(int(t)))
b = 1
break
if b == 1:
break
if b == 1:
break
if b == 0:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR VAR VAR VAR VAR IF VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR VAR VAR STRING VAR FUNC_CALL VAR VAR VAR VAR STRING VAR FUNC_CALL VAR VAR VAR VAR STRING IF FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | n = list(input())
ans = False
ne = 1
for i in range(len(n) - 1, -1, -1):
for j in range(i - 1, -1, -1):
s = int(n[j] + n[i])
if s % 8 == 0:
ans = True
ne = s
break
for k in range(j - 1, -1, -1):
s = int(n[k] + n[j] + n[i])
if s % 8 == 0:
ans = True
ne = s
break
if ans == True:
print("YES")
print(ne)
elif "0" in n:
print("YES")
print(0)
elif "8" in n:
print("YES")
print(8)
elif int("".join(n)) % 8 == 0:
print("YES")
print("".join(n))
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF BIN_OP FUNC_CALL VAR FUNC_CALL STRING VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | n = input()
isBreak = 0
while True:
for i in n:
if int(i) % 8 == 0:
print("YES")
print(i)
isBreak = 1
break
if isBreak == 1:
break
breakInner2 = 0
for i in range(len(n)):
for j in range(i + 1, len(n)):
values = int(n[i] + n[j])
if values % 8 == 0:
print("YES")
print(values)
isBreak = 1
breakInner2 = 1
break
if breakInner2 == 1:
break
if isBreak == 1:
break
breakInner3 = 0
for i in range(len(n)):
for j in range(i + 1, len(n)):
for k in range(j + 1, len(n)):
values = int(n[i] + n[j] + n[k])
if values % 8 == 0:
print("YES")
print(values)
breakInner3 = 1
isBreak = 1
break
if breakInner3 == 1:
break
if breakInner3 == 1:
break
if isBreak == 1:
break
print("NO")
break | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = input()
candidate = [str(x) for x in range(0, 1000, 8)]
def isContain(str, substr):
d = {i: ss for i, ss in enumerate(substr)}
ptr = 0
for ss in str:
if d[ptr] == ss:
ptr += 1
if ptr == len(substr):
return True
return False
for ss in candidate:
if isContain(s, ss):
print("YES")
print(ss)
exit()
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | n = int(input())
c1 = 0
if n % 8 == 0:
print("YES")
print(n)
else:
s = str(n)
for i in range(len(s)):
if int(s[i]) != 0:
s1 = s[i]
if int(s[i]) % 8 == 0:
print("YES")
print(s[i])
c1 = -1
break
else:
print("YES")
print("0")
c1 = -1
break
for j in range(i + 1, len(s)):
s1 = s[i] + s[j]
if int(s1) % 8 == 0:
print("YES")
if int(s[i]) == 0:
print(s[j])
else:
print(s[i] + s[j])
c1 = -1
break
for r in range(j + 1, len(s)):
s1 = s[i] + s[j] + s[r]
if int(s1) % 8 == 0:
print("YES")
if int(s[i]) == 0:
if int(s[j]) == 0:
print(s[r])
else:
print(s[j] + s[r])
else:
print(s[i] + s[j] + s[r])
c1 = -1
break
if c1 == -1:
break
if c1 == -1:
break
if c1 != -1:
print("NO") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | def getInts():
return [int(s) for s in input().split()]
def getInt():
return int(input())
def getStrs():
return [s for s in input().split()]
def getStr():
return input()
def listStr():
return list(input())
def solve():
A = [int(s) for s in input()]
if 8 in A:
print("YES")
return 8
if 0 in A:
print("YES")
return 0
mults = []
for j in range(2, 13):
mults.append(8 * j)
for i in range(len(A)):
for j in range(i + 1, len(A)):
x = 10 * A[i] + A[j]
if x in mults:
print("YES")
return x
mults = dict()
for j in range(13, 125):
mults[8 * j] = j
for i in range(len(A)):
for j in range(i + 1, len(A)):
for k in range(j + 1, len(A)):
x = 100 * A[i] + 10 * A[j] + A[k]
if x in mults:
print("YES")
return x
return "NO"
ans = solve()
print(ans) | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR IF NUMBER VAR EXPR FUNC_CALL VAR STRING RETURN NUMBER IF NUMBER VAR EXPR FUNC_CALL VAR STRING RETURN NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING RETURN VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING RETURN VAR RETURN STRING ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = input()
a = [int(x) for x in s]
a.reverse()
bhul = False
for i in range(len(a)):
if a[i] % 8 == 0:
print("YES")
print(a[i])
bhul = True
break
if bhul == False:
for i in range(len(a) - 1):
for j in range(i + 1, len(a)):
if int(str(a[j]) + str(a[i])) % 8 == 0:
print("YES")
print(int(str(a[j]) + str(a[i])))
bhul = True
break
if bhul:
break
if bhul == False:
for i in range(len(a) - 2):
for j in range(i + 1, len(a) - 1):
for k in range(j + 1, len(a)):
if int(str(a[k]) + str(a[j]) + str(a[i])) % 8 == 0:
print("YES")
print(int(str(a[k]) + str(a[j]) + str(a[i])))
bhul = True
break
if bhul:
break
if bhul:
break
if bhul == False:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER IF VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER IF VAR IF VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = input()
while len(s) > 0 and int(s[-1]) % 2 == 1:
s = s[:-1]
while len(s) > 1 and int(s[-2:]) % 4 != 0:
s = s[: len(s) - 2] + s[len(s) - 1 :]
while len(s) > 2 and int(s[-3:]) % 8 != 0:
s = s[: len(s) - 3] + s[len(s) - 2 :]
if len(s) > 0 and int(s[-3:]) % 8 == 0:
print("YES")
print(s)
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR WHILE FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | n = input()
lenN = len(n)
candiv8s = [str(x) for x in range(0, 1000, 8)]
def isPart(s1, s2):
i = 0
lenS2 = len(s2)
for s in s1:
while i < lenS2:
if s2[i] == s:
i += 1
break
i += 1
else:
return False
return True
for candiv8 in candiv8s:
if isPart(candiv8, n):
print("YES")
print(candiv8)
exit(0)
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR WHILE VAR VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = input()
n = int(len(s))
dp = [(-1) for i in range(n)]
if int(s[0]) % 8 == 0:
dp[0] = s[0]
if int(s[:2]) % 8 == 0 and n >= 2:
dp[1] = s[:2]
for i in range(2, n):
for j in range(i - 1, -1, -1):
for k in range(j - 1, -1, -1):
if int(s[k] + s[j] + s[i]) % 8 == 0:
dp[i] = s[: k + 1] + s[j] + s[i]
break
for i in range(2, n):
for j in range(i - 1, -1, -1):
if int(s[j] + s[i]) % 8 == 0 and dp[i] == -1:
dp[i] = s[j] + s[i]
break
ind = -1
l = 0
for i in range(0, n):
if dp[i] != -1:
if len(dp[i]) > l:
l = len(dp[i])
ind = i
if l == 0:
for i in range(0, n):
if s[i] == "0":
print("YES")
print("0")
raise SystemExit(0)
if l == 0:
print("NO")
else:
print("YES")
l = 0
ind = -1
for i in range(0, n):
if len(str(dp[i])) > l and dp[i] != -1:
l = len(str(dp[i]))
ind = i
print(dp[ind]) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | n = input()
res = -1
for k in range(0, 1000, 8):
temp = str(k)
p1 = n.find(temp[0])
p2 = -1
p3 = -1
if len(temp) > 1:
p2 = n.find(temp[1], max(0, p1) + 1)
if len(temp) > 2:
p3 = n.find(temp[2], max(0, p2) + 1)
if len(temp) == 1 and p1 != -1:
res = n[p1]
break
if len(temp) == 2 and p1 != -1 and p2 != -1:
res = n[p1] + n[p2]
break
if len(temp) == 3 and p1 != -1 and p2 != -1 and p3 != -1:
res = n[p1] + n[p2] + n[p3]
break
if res != -1:
print("YES")
print(res)
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | n = int(input())
n = str(n)
n = n.rstrip("13579")
if "0" in n:
print("YES")
print(0)
elif "8" in n:
print("YES")
print(8)
else:
while True:
if n == "":
print("NO")
break
elif n[-1] == "4":
if "2" in n:
print("YES")
print(24)
elif "6" in n:
print("YES")
print(64)
else:
q = n.rfind("4", 0, -1)
if q != -1 and n.rfind("1", 0, q) != -1:
print("YES")
print(144)
elif q != -1 and n.rfind("3", 0, q) != -1:
print("YES")
print(344)
elif q != -1 and n.rfind("5", 0, q) != -1:
print("YES")
print(544)
elif q != -1 and n.rfind("7", 0, q) != -1:
print("YES")
print(744)
elif q != -1 and n.rfind("9", 0, q) != -1:
print("YES")
print(944)
else:
print("NO")
break
elif n[-1] == "2":
if "3" in n:
print("YES")
print(32)
break
elif "7" in n:
print("YES")
print(72)
break
else:
a = n.find("1")
b = n.find("5")
c = n.find("9")
s = {a, b, c}
s.discard(-1)
if s == set():
n = n.rstrip("26")
else:
d = min(s)
a = n.find("1", d + 1)
b = n.find("5", d + 1)
c = n.find("9", d + 1)
s = {a, b, c}
s.discard(-1)
if s == set():
n = n.rstrip("1592")
else:
e = min(s)
print("YES")
print(n[d] + n[e] + "2")
break
elif n[-1] == "6":
if "1" in n:
print("YES")
print(16)
break
elif "5" in n:
print("YES")
print(56)
break
elif "9" in n:
print("YES")
print(96)
break
else:
a = n.find("3")
b = n.find("7")
s = {a, b}
s.discard(-1)
if s == set():
n = n.rstrip("26")
else:
d = min(s)
a = n.find("3", d + 1)
b = n.find("7", d + 1)
s = {a, b}
s.discard(-1)
if s == set():
n = n.rstrip("376")
else:
e = min(s)
print("YES")
print(n[d] + n[e] + "6")
break | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER WHILE NUMBER IF VAR STRING EXPR FUNC_CALL VAR STRING IF VAR NUMBER STRING IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING NUMBER NUMBER IF VAR NUMBER FUNC_CALL VAR STRING NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER FUNC_CALL VAR STRING NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER FUNC_CALL VAR STRING NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER FUNC_CALL VAR STRING NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER FUNC_CALL VAR STRING NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER STRING IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR STRING IF VAR NUMBER STRING IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | from itertools import combinations
num = input()
l = len(num)
done = False
for k in range(1, min(l + 1, 4)):
for e in combinations(list(range(l)), k):
s = "".join([num[i] for i in e])
if int(s) % 8 == 0:
print("YES")
print(s)
done = True
break
if done:
break
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING VAR VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = []
for i in range(999):
if i % 8 == 0:
s.append(i)
a = list(input())
f = 0
def check(p):
j = 0
flag = 0
for i in p:
while j < len(a):
if a[j] == i:
flag += 1
j += 1
break
j += 1
if flag == len(p):
return True
return False
for i in s:
if check(str(i)):
f = 1
print("YES")
print(i)
break
if f == 0:
print("NO") | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER FOR VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | n = input()
if int(n[-3:]) % 8 == 0:
print("YES")
print(n)
else:
l = len(n)
op = "ud"
no = -1
for i in n:
if int(i) % 8 == 0:
op = "YES"
no = int(i)
if op == "ud":
for i in range(l):
for j in range(i + 1, l):
if int(n[i] + n[j]) % 8 == 0:
op = "YES"
no = int(n[i] + n[j])
if op == "ud":
for i in range(l):
for j in range(i + 1, l):
for k in range(j + 1, l):
if int(n[i] + n[j] + n[k]) % 8 == 0:
op = "YES"
no = int(n[i] + n[j] + n[k])
if op == "ud":
print("NO")
else:
print(op)
print(no) | ASSIGN VAR FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF VAR STRING FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | a = input()
answer = -1
flag = 0
if "0" in a:
print("YES")
print(0)
else:
for i in range(0, len(a)):
if int(a[i]) % 8 == 0:
answer = a[i]
flag = 1
break
for j in range(i + 1, len(a)):
if int(a[i] + a[j]) % 8 == 0:
answer = a[i] + a[j]
flag = 1
break
for k in range(j + 1, len(a)):
if int(a[i] + a[j] + a[k]) % 8 == 0:
answer = a[i] + a[j] + a[k]
flag = 1
break
if flag == 1:
break
if flag == 1:
break
if answer == -1:
print("NO")
else:
print("YES")
print(answer) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | a = list(input())
for i in range(0, len(a)):
a[i] = int(a[i])
if len(a) == 1:
if a[0] % 8 == 0:
print("YES")
print(a[0])
exit()
else:
print("NO")
exit()
if len(a) == 2:
if (a[1] * 10 + a[0]) % 8 == 0:
print("YES")
print(a)
elif a[0] % 8 == 0:
print("YES")
print(a[0])
elif a[1] % 8 == 0:
print("YES")
print(a[1])
else:
print("NO")
else:
for i in range(len(a) - 1, 1, -1):
for j in range(i - 1, 0, -1):
for k in range(j - 1, -1, -1):
if (a[i] + a[j] * 10 + a[k] * 100) % 8 == 0:
print("YES")
for t in range(0, k + 1):
print(a[t], end="")
print(a[j], end="")
print(a[i], end="")
exit()
for i in range(len(a) - 1, 0, -1):
for j in range(i - 1, -1, -1):
if (a[i] + a[j] * 10) % 8 == 0:
print("YES")
print(a[j] * 10 + a[i])
exit()
for i in range(len(a) - 1, -1, -1):
if a[i] % 8 == 0:
print("YES")
print(a[i], end="")
exit()
print("NO") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = input()
t, f = "00" + s, 1
for i in range(len(t) - 2):
for j in range(i + 1, len(t) - 1):
for y in range(j + 1, len(t)):
if int(t[i] + t[j] + t[y]) % 8 == 0 and f:
print("YES")
print(int(t[i] + t[j] + t[y]))
f = 0
if f:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP STRING VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | import sys
number = input()
a = {str(x * 8) for x in range(0, 125)}
for num in a:
if num in number:
print("YES")
print(num)
sys.exit()
for f in range(len(number) - 1):
for s in range(1, len(number)):
if int(number[f] + number[s]) % 8 == 0 and f < s:
print("YES")
print(int(number[f] + number[s]))
sys.exit()
for t in range(2, len(number)):
if int(number[s] + number[t]) % 8 == 0 and s < t:
print("YES")
print(int(number[s] + number[t]))
sys.exit()
if int(number[f] + number[s] + number[t]) % 8 == 0 and f < s < t:
print("YES")
print(int(number[f] + number[s] + number[t]))
sys.exit()
print("NO") | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR NUMBER NUMBER VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = input()
found = False
if "0" in s:
sol = 0
found = True
elif "8" in s:
sol = 8
found = True
if not found:
d = {}
for i in range(len(s)):
c = int(s[i])
if c not in d:
d[c] = []
d[c].append(i)
for i in range(16, 100, 8):
uni = i % 10
dec = i // 10
if uni in d and dec in d:
if d[uni][-1] > d[dec][0]:
sol = i
found = True
break
if not found:
s_list = list(map(int, s))
for i in range(len(s) - 1, 1, -1):
if s_list[i] % 2 == 1:
continue
if found:
break
for j in range(i - 1, 0, -1):
if found:
break
for k in range(j - 1, -1, -1):
temp = s_list[k] * 100 + s_list[j] * 10 + s_list[i]
if temp % 8 == 0:
sol = temp
found = True
break
if found:
print("YES")
print(sol)
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR VAR LIST EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR NUMBER NUMBER IF VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | def get_result(n):
mult_of_8 = {}
for i in range(0, 1000):
if i % 8 == 0:
mult_of_8[i] = 1
size = len(n)
for i in range(size - 1, -1, -1):
if n[i] == "0" or n[i] == "2" or n[i] == "4" or n[i] == "6" or n[i] == "8":
if size - (size - i) - 1 < 0:
v = int(n[i])
if v in mult_of_8:
print("YES")
return v
for j in range(size - (size - i) - 1, -1, -1):
if size - (size - j) - 1 < 0:
v = int(n[j]) * 10 + int(n[i]) * 1
if v in mult_of_8:
print("YES")
return v
for k in range(size - (size - j) - 1, -1, -1):
v = int(n[k]) * 100 + int(n[j]) * 10 + int(n[i]) * 1
if v in mult_of_8:
print("YES")
return v
v = int(n[j]) * 10 + int(n[i]) * 1
if v in mult_of_8:
print("YES")
return v
v = int(n[i])
if v in mult_of_8:
print("YES")
return v
return "NO"
n = input()
print(get_result(n)) | FUNC_DEF ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR STRING VAR VAR STRING VAR VAR STRING VAR VAR STRING VAR VAR STRING IF BIN_OP BIN_OP VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING RETURN VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING RETURN VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING RETURN VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING RETURN VAR RETURN STRING ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | a = list(input())
if len(a) <= 2:
if len(a) == 1:
if int(a[0]) % 8 == 0:
print("YES")
print(a[0])
else:
print("NO")
elif int("".join(a)) % 8 == 0:
print("YES")
print("".join(a))
elif int(a[0]) % 8 == 0:
print("YES")
print(a[0])
elif int(a[1]) % 8 == 0:
print("YES")
print(a[1])
else:
print("NO")
else:
ans = None
def recur(a, i, dp):
global ans
if i >= len(a) or len(a) == 0:
return False
if "".join(a) in dp:
return dp["".join(a)]
temp = a.copy()
if len(dp) > 10000:
return False
del temp[i]
ind = len(temp) - 3
tval = "".join(temp)
if tval in dp:
return dp[tval]
elif (
len(temp) > 0 and ind >= 0 and int("".join(temp[ind : len(temp)])) % 8 == 0
):
ans = tval
return True
elif len(temp) > 0 and ind < 0 and int(tval) % 8 == 0:
ans = tval
return True
else:
an = recur(temp, i, dp) or recur(a, i + 1, dp)
dp[tval] = an
return an
dp = {}
if int("".join(a[len(a) - 3 : len(a)])) % 8 == 0:
print("YES")
print("".join(a))
elif recur(a, 0, dp):
print("YES")
print(ans)
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP FUNC_CALL VAR FUNC_CALL STRING VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NONE FUNC_DEF IF VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF FUNC_CALL STRING VAR VAR RETURN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR IF VAR VAR RETURN VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL STRING VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR RETURN NUMBER IF FUNC_CALL VAR VAR NUMBER VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR RETURN VAR ASSIGN VAR DICT IF BIN_OP FUNC_CALL VAR FUNC_CALL STRING VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING VAR IF FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = input()
n = len(s)
for i in range(n):
si = s[i]
if int(si) % 8 == 0:
print("YES\n" + si)
exit()
for j in range(i + 1, n):
sj = si + s[j]
if int(sj) % 8 == 0:
print("YES\n" + sj)
exit()
for k in range(j + 1, n):
sk = sj + s[k]
if int(sk) % 8 == 0:
print("YES\n" + sk)
exit()
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = input()
n = len(s)
flag = 0
if n == 1:
if (ord(s[0]) - 48) % 8 == 0:
flag = 1
print("YES")
print(s[0])
if n == 2:
if (ord(s[0]) - 48) % 8 == 0:
flag = 1
print("YES")
print(s[0])
elif (ord(s[1]) - 48) % 8 == 0:
flag = 1
print("YES")
print(s[1])
elif ((ord(s[0]) - 48) * 10 + (ord(s[1]) - 48)) % 8 == 0:
print("YES")
print(s[0] + s[1])
flag = 1
for i in range(n - 2):
if (ord(s[i]) - 48) % 8 == 0:
print("YES")
print(s[i])
flag = 1
break
for j in range(i + 1, n - 1):
if (ord(s[j]) - 48) % 8 == 0:
print("YES")
print(s[j])
flag = 1
break
if ((ord(s[i]) - 48) * 10 + (ord(s[j]) - 48)) % 8 == 0:
print("YES")
print(s[i] + s[j])
flag = 1
break
for k in range(j + 1, n):
if (ord(s[k]) - 48) % 8 == 0:
print("YES")
print(s[k])
flag = 1
break
if ((ord(s[i]) - 48) * 10 + (ord(s[k]) - 48)) % 8 == 0:
print("YES")
print(s[i] + s[k])
flag = 1
break
if ((ord(s[j]) - 48) * 10 + (ord(s[k]) - 48)) % 8 == 0:
print("YES")
print(s[j] + s[k])
flag = 1
break
if (
(ord(s[i]) - 48) * 100 + (ord(s[j]) - 48) * 10 + (ord(s[k]) - 48)
) % 8 == 0:
print("YES")
print(s[i] + s[j] + s[k])
flag = 1
break
if flag == 1:
break
if flag == 1:
break
if flag == 0:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER IF BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER IF BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER IF BIN_OP BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER IF BIN_OP BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER IF BIN_OP BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER IF BIN_OP BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER IF BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | def isSubSequence(str1, str2):
m = len(str1)
n = len(str2)
j = 0
i = 0
while j < m and i < n:
if str1[j] == str2[i]:
j = j + 1
i = i + 1
return j == m
divBy8 = ["0"]
for i in range(8, 1000):
if i % 8 == 0:
divBy8.append(str(i))
n = input()
f = 0
for i in divBy8:
if isSubSequence(i, n):
print("YES")
print(i)
f = 1
break
if f == 0:
print("NO") | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR VAR ASSIGN VAR LIST STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | __author__ = "Andrey"
n = int(input())
s_n = str(n)
l_n = len(s_n)
done = False
for x in range(l_n):
n_1 = int(s_n[x])
if n_1 % 8 == 0:
print("YES")
print(n_1)
break
for y in range(x + 1, l_n):
n_2 = int(s_n[y])
n_12 = int(str(n_1) + str(n_2))
if n_1 != 0 and n_12 % 8 == 0:
print("YES")
print(n_12)
done = True
break
for z in range(y + 1, l_n):
n_3 = int(s_n[z])
n_123 = int(str(n_12) + str(n_3))
if n_1 != 0 and n_123 % 8 == 0:
print("YES")
print(n_123)
done = True
break
if done:
break
if done:
break
else:
print("NO") | ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR IF VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | D = [[str(i * 8), 0, len(str(i * 8))] for i in range(200)]
s = input()
div = False
for c in s:
if div:
break
for d in D:
if c == d[0][d[1]]:
d[1] += 1
if d[1] == d[2]:
print("YES")
print(d[0])
div = True
break
if not div:
print("NO") | ASSIGN VAR LIST FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR FOR VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = input()
s = list(s)
n = len(s)
if "0" in s:
print("YES")
print(0)
exit()
if "8" in s:
print("YES")
print(8)
exit()
s.insert(0, "0")
n = n + 1
for i in range(n - 2):
for j in range(i + 1, n - 1):
for k in range(j + 1, n):
x = int(s[i] + s[j] + s[k])
if x % 8 == 0:
print("YES")
print(x)
exit()
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | n = input()
if int(n) % 8 == 0:
print("YES")
print(n)
else:
ok = 0
x = len(n)
res = ""
for i in range(x):
if ok == 1:
break
add = n[i]
if int(add) % 8 == 0:
ok = 1
res = add
break
for j in range(i + 1, x):
if ok == 1:
break
add += n[j]
if int(add) % 8 == 0:
ok = 1
res = add
break
for z in range(j + 1, x):
add += n[z]
if int(add) % 8 == 0:
ok = 1
res = add
break
add = n[i] + n[j]
add = n[i]
if ok == 1:
print("YES")
print(res)
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR NUMBER VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = list(map(int, input()))
if 0 in s:
print("YES")
print(0)
exit(0)
if 8 in s:
print("YES")
print(8)
exit(0)
for n in range(len(s)):
for k in range(n + 1, len(s)):
if s[k] % 2 == 0:
nm = s[n] * 10 + s[k]
if nm % 8 == 0:
print("YES")
print(nm)
exit(0)
for n in range(len(s)):
for k in range(n + 1, len(s)):
for j in range(k + 1, len(s)):
if s[j] % 2 == 0:
nm = s[n] * 100 + s[k] * 10 + s[j]
if nm % 8 == 0:
print("YES")
print(nm)
exit(0)
print("NO") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR IF NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | import itertools
def con(e):
try:
return int(e)
except:
return int("".join(list(e)))
mainnum = input()
candidates = set()
for e in itertools.chain(
mainnum, itertools.combinations(mainnum, 2), itertools.combinations(mainnum, 3)
):
e = con(e)
candidates.add(e)
found = False
for c in candidates:
if c % 8 == 0:
print("YES\n{}".format(c))
found = True
break
if not found:
print("NO") | IMPORT FUNC_DEF RETURN FUNC_CALL VAR VAR RETURN FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | lst = input()
def f(lst):
b2, b4, b6, b12, b52, b92, b44, b36, b76 = (
False,
False,
False,
False,
False,
False,
False,
False,
False,
)
for k in range(len(lst) - 1, -1, -1):
a = int(lst[k])
if a in [0, 8]:
return "YES\n" + str(a)
elif a == 2:
b2 = True
if b4:
return "YES\n24"
elif a == 4:
if b4:
b44 = True
b4 = True
elif a == 6:
b6 = True
if b4 == True:
return "YES\n64"
elif a == 1:
if b12:
return "YES\n112"
if b44:
return "YES\n144"
if b6:
return "YES\n16"
if b52:
return "YES\n152"
if b92:
return "YES\n192"
if b2:
b12 = True
elif a == 5:
if b6:
return "YES\n56"
if b52:
return "YES\n552"
if b92:
return "YES\n592"
if b44:
return "YES\n544"
if b12:
return "YES\n512"
if b2:
b52 = True
elif a == 9:
if b6:
return "YES\n96"
if b52:
return "YES\n952"
if b92:
return "YES\n992"
if b44:
return "YES\n944"
if b12:
return "YES\n912"
if b2:
b92 = True
elif a == 3:
if b2:
return "YES\n32"
if b44:
return "YES\n344"
if b76:
return "YES\n376"
if b36:
return "YES\n336"
if b6:
b36 = True
elif a == 7:
if b2:
return "YES\n72"
if b44:
return "YES\n744"
if b76:
return "YES\n776"
if b36:
return "YES\n736"
if b6:
b76 = True
return "NO"
print(f(lst)) | ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR LIST NUMBER NUMBER RETURN BIN_OP STRING FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER IF VAR RETURN STRING IF VAR NUMBER IF VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER RETURN STRING IF VAR NUMBER IF VAR RETURN STRING IF VAR RETURN STRING IF VAR RETURN STRING IF VAR RETURN STRING IF VAR RETURN STRING IF VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR RETURN STRING IF VAR RETURN STRING IF VAR RETURN STRING IF VAR RETURN STRING IF VAR RETURN STRING IF VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR RETURN STRING IF VAR RETURN STRING IF VAR RETURN STRING IF VAR RETURN STRING IF VAR RETURN STRING IF VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR RETURN STRING IF VAR RETURN STRING IF VAR RETURN STRING IF VAR RETURN STRING IF VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR RETURN STRING IF VAR RETURN STRING IF VAR RETURN STRING IF VAR RETURN STRING IF VAR ASSIGN VAR NUMBER RETURN STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = [j for j in input()]
n = len(s)
if "0" in s:
print("YES")
print(0)
elif int("".join(s)) % 8 == 0:
print("YES")
print("".join(s))
elif "8" in s:
print("YES")
print(8)
else:
ans = []
for i in range(n):
for j in range(i + 1, n):
if int(s[i] + s[j]) % 8 == 0:
ans.append(int(s[i] + s[j]))
for k in range(j + 1, n):
if int(s[i] + s[j] + s[k]) % 8 == 0:
ans.append(int(s[i] + s[j] + s[k]))
if int(s[j] + s[k]) % 8 == 0:
ans.append(int(s[j] + s[k]))
if int(s[i] + s[k]) % 8 == 0:
ans.append(int(s[i] + s[k]))
if len(ans) == 0:
print("NO")
else:
print("YES")
print(ans[0]) | ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF BIN_OP FUNC_CALL VAR FUNC_CALL STRING VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | n = input()
st = 0
nd = 1000
ic = 8
for x in range(st, nd, ic):
i = -1
for y in str(x):
i = n.find(y, i + 1)
if i < 0:
break
else:
print("YES")
print(x)
break
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | def buildNumber(n, mask):
strN = str(n)
newN = 0
for i in range(len(strN)):
if mask & 1 << i:
newN *= 10
newN += int(strN[i])
return newN
def is8k(n):
return n % 1000 % 8 == 0
def solve(n):
if n % 8 == 0:
print("YES")
print(n)
return
strN = str(n)
for i in range(len(strN)):
if strN[i] == "0":
print("YES")
print(0)
return
if strN[i] == "8":
print("YES")
print(8)
return
if len(str(n)) <= 6:
mask = 1
limit = pow(2, len(strN)) - 1
while mask <= limit:
newN = buildNumber(n, mask)
if is8k(newN):
print("YES")
print(newN)
return
mask += 1
for i in range(len(strN)):
for j in range(i + 1, len(strN)):
newN = 10 * int(strN[i]) + int(strN[j])
if newN % 8 == 0:
print("YES")
print(newN)
return
for k in range(j + 1, len(strN)):
newN = 100 * int(strN[i]) + 10 * int(strN[j]) + int(strN[k])
if newN % 8 == 0:
print("YES")
print(newN)
return
print("NO")
n = int(input())
solve(n) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER FUNC_DEF IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR RETURN ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER RETURN IF VAR VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER RETURN IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR RETURN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR RETURN FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR RETURN EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = input().strip()
n = len(s)
ans = None
for i in range(n):
x = s[i]
x = int(x)
if x % 8 == 0:
ans = x
for j in range(i + 1, n):
x = s[i] + s[j]
x = int(x)
if x % 8 == 0:
ans = x
for k in range(j + 1, n):
x = s[i] + s[j] + s[k]
x = int(x)
if x % 8 == 0:
ans = x
if ans is not None:
print("YES")
print(ans)
else:
print("NO") | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NONE FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR IF VAR NONE EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | n = input()
x = len(n)
f = 0
if "8" in n:
f = 1
s = "8"
elif "0" in n:
f = 1
s = "0"
else:
for i in range(x):
for j in range(i + 1, x):
s = n[i] + n[j]
if int(s) % 8 == 0:
f = 1
break
if f:
break
if f == 0 and x >= 3:
for i in range(x):
for j in range(i + 1, x):
for k in range(j + 1, x):
s = n[i] + n[j] + n[k]
if int(s) % 8 == 0:
f = 1
break
if f:
break
if f:
break
if f:
print("YES")
print(s)
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR NUMBER ASSIGN VAR STRING IF STRING VAR ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR IF VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR IF VAR IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | n = input()
flag = 0
for i in range(len(n)):
if flag == 1:
break
if i + 1 < len(n):
for j in range(i + 1, len(n)):
if flag == 1:
break
if j + 1 < len(n):
for k in range(j + 1, len(n)):
s = int(n[i] + n[j] + n[k])
if s % 8 == 0:
print("YES")
print(s)
flag = 1
break
if int(n[i] + n[j]) % 8 == 0 and flag != 1:
flag = 1
print("YES")
print(n[i] + n[j])
break
if int(n[i]) % 8 == 0 and flag != 1:
print("YES")
print(n[i])
flag = 1
break
if flag == 0:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | n = input()
if "0" in n:
print("YES")
print("0")
elif "8" in n:
print("YES")
print("8")
else:
ans = "NO"
asdf = ""
t1 = ["16", "24", "32", "56", "64", "72", "96"]
t2 = [
"112",
"136",
"144",
"152",
"176",
"192",
"216",
"224",
"232",
"256",
"264",
"272",
"296",
"312",
"336",
"344",
"352",
"376",
"392",
"416",
"424",
"432",
"456",
"464",
"472",
"496",
"512",
"536",
"544",
"552",
"576",
"592",
"616",
"624",
"632",
"656",
"664",
"672",
"696",
"712",
"736",
"744",
"752",
"776",
"792",
"912",
"936",
"944",
"952",
"976",
"992",
]
for i in t1:
i0 = n.find(i[0])
i1 = n.find(i[1], i0 + 1)
if min(i0, i1) > -1:
ans = "YES"
asdf = i
for i in t2:
i0 = n.find(i[0])
i1 = n.find(i[1], i0 + 1)
i2 = n.find(i[2], i1 + 1)
if min(i0, i1, i2) > -1:
ans = "YES"
asdf = i
print(ans)
if ans == "YES":
print(asdf) | ASSIGN VAR FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | def solve(n):
for i in range(len(n)):
if int(n[i]) % 8 is 0:
return int(n[i])
for i in range(len(n) - 1):
for j in range(i + 1, len(n)):
m = 10 * int(n[i]) + int(n[j])
if m % 8 is 0:
return m
for i in range(len(n) - 2):
for j in range(i + 1, len(n) - 1):
for k in range(j + 1, len(n)):
m = 100 * int(n[i]) + 10 * int(n[j]) + int(n[k])
if m % 8 is 0:
return m
return -1
n = input()
sol = solve(n)
if sol is -1:
print("NO")
else:
print("YES")
print(sol) | FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER RETURN FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | a = [[0, 8], [6], [4], [2]]
s = "00" + input()
f = 0
for i in range(len(s)):
for j in range(i + 1, len(s)):
b, c = int(s[i]), int(s[j])
x = a[(b % 2 * 2 + c % 4) % 4]
for k in x:
if str(k) in s[j + 1 :]:
f = 1
print("YES")
print(int(str(b) + str(c) + str(k)))
break
if f:
break
if f:
break
if not f:
print("NO") | ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER LIST NUMBER LIST NUMBER ASSIGN VAR BIN_OP STRING FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR IF VAR IF VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | from sys import exit
s = input()
s = s[::-1]
n = len(s)
for i in range(0, 1000, 8):
item = str(i)
length = len(item)
for j in range(3 - length + 1):
x = "0" * j + item
le = length + j - 1
a = x[le]
le -= 1
for z, b in enumerate(s):
if a == b:
if le == -1:
print("YES", x, sep="\n")
exit()
a = x[le]
le -= 1
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | import sys
s = sys.stdin.readline().strip()
n = len(s)
e = 0
for i in range(n):
if (ord(s[i]) - ord("0")) % 8 == 0 and e == 0:
print("YES")
print(s[i])
e = 1
break
for j in range(i + 1, n):
if ((ord(s[i]) - ord("0")) * 10 + (ord(s[j]) - ord("0"))) % 8 == 0 and e == 0:
print("YES")
print(s[i] + s[j])
e = 1
break
for k in range(j + 1, n):
if (
(ord(s[i]) - ord("0")) * 100
+ (ord(s[j]) - ord("0")) * 10
+ (ord(s[k]) - ord("0"))
) % 8 == 0 and e == 0:
print("YES")
print(s[i] + s[j] + s[k])
e = 1
break
if e == 0:
print("NO") | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING NUMBER BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING NUMBER BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = input()
le = len(s)
if "0" in s:
print("YES")
print(0)
elif "8" in s:
print("YES")
print(8)
else:
for i in range(0, le):
for j in range(i + 1, le):
val = int(s[i] + s[j])
if val % 8 == 0:
print("YES")
print(val)
exit(0)
for k in range(j + 1, le):
val = int(s[i] + s[j] + s[k])
if val % 8 == 0:
print("YES")
print(val)
exit(0)
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | l = []
for i in range(1, 126):
l.append(i * 8)
f = 0
s = input().strip()
if "0" in s:
print("Yes")
print(0)
else:
for i in range(len(l)):
n = l[i]
div = ""
for j in range(len(s) - 1, -1, -1):
if int(s[j]) == n % 10:
n //= 10
div += s[j]
if n == 0:
f = 1
break
if f == 1:
print("Yes")
print(div[::-1])
else:
print("No") | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | from itertools import combinations
s = list(input())
p = list(combinations(s, 3)) + list(combinations(s, 1)) + list(combinations(s, 2))
for i in range(len(p)):
p[i] = int("".join(p[i]))
for i in range(len(p)):
if p[i] % 8 == 0:
print("YES")
print(p[i])
exit()
print("NO") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL STRING VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | def solve(n):
if "8" in n:
print("YES")
return 8
elif "0" in n:
print("YES")
return 0
for i in range(len(n)):
for j in range(i + 1, len(n)):
val = int(n[i] + n[j])
if val % 8 == 0:
print("YES")
return n[i] + n[j]
for i in range(len(n)):
for j in range(i + 1, len(n)):
for k in range(j + 1, len(n)):
val = int(n[i] + n[j] + n[k])
if val % 8 == 0:
print("YES")
return n[i] + n[j] + n[k]
return "NO"
n = input()
print(solve(n)) | FUNC_DEF IF STRING VAR EXPR FUNC_CALL VAR STRING RETURN NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING RETURN NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING RETURN BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING RETURN BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR RETURN STRING ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | a = input()
answer = 1
for i in range(len(a) - 1, 1, -1):
if answer == 0:
break
for j in range(i - 1, 0, -1):
if answer == 0:
break
for k in range(j - 1, -1, -1):
if (int(a[i]) + 10 * int(a[j]) + 100 * int(a[k])) % 8 == 0:
print("YES")
print(int(a[i]) + 10 * int(a[j]) + 100 * int(a[k]))
answer = 0
break
if answer == 1:
for i in a:
if int(i) % 8 == 0:
print("YES")
print(i)
answer = 0
break
if answer == 1:
for j in range(len(a) - 1, 0, -1):
if answer == 0:
break
for k in range(j - 1, -1, -1):
if (int(a[j]) + 10 * int(a[k])) % 8 == 0:
print("YES")
print(int(a[j]) + 10 * int(a[k]))
answer = 0
break
if answer == 1:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP FUNC_CALL VAR VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = input()
flag = 0
for i in range(len(s) - 1, -1, -1):
tmp = int(s[i])
if tmp % 8 == 0:
print("YES")
print(int(tmp))
flag = 1
break
for j in range(i - 1, -1, -1):
tmp = 10 * int(s[j]) + int(s[i])
if tmp % 8 == 0:
print("YES")
print(int(tmp))
flag = 1
break
for k in range(j - 1, -1, -1):
if s[k] == "0":
continue
tmp = 100 * int(s[k]) + 10 * int(s[j]) + int(s[i])
if tmp % 8 == 0:
print("YES")
print(int(tmp))
flag = 1
break
if flag == 1:
break
if flag == 1:
break
if flag == 0:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | import time
s = input()
flag = False
ans = ""
start = time.time()
for i in s:
if i == "8" or i == "0":
ans = i
break
if len(s) >= 2 and ans == "":
for i in range(len(s) - 1):
for j in range(i + 1, len(s)):
if divmod(int(s[i] + s[j]), 8)[1] == 0:
ans = s[i] + s[j]
break
if ans != "":
break
if len(s) >= 3 and ans == "":
for i in range(len(s) - 2):
for j in range(i + 1, len(s) - 1):
for k in range(j + 1, len(s)):
if divmod(int(s[i] + s[j] + s[k]), 8)[1] == 0:
ans = s[i] + s[j] + s[k]
break
if ans != "":
break
if ans != "":
break
if ans == "":
print("NO")
else:
print("YES")
print(ans)
finish = time.time() | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR STRING VAR STRING ASSIGN VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR STRING FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR IF VAR STRING IF FUNC_CALL VAR VAR NUMBER VAR STRING FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF VAR STRING IF VAR STRING IF VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | a = list(input()[::-1])
m = [False, 0]
if "0" in a:
m[0] = True
m[1] = 0
if "8" in a:
m[0] = True
m[1] = 8
for x in range(len(a)):
if m[0]:
break
if int(a[x]) % 2 == 0:
if a[x] == "0" or a[x] == "8":
m[0] = True
break
for y in range(x + 1, len(a)):
if m[0]:
break
s = a[y] + a[x]
if int(s) % 8 == 0:
m[1] = s
m[0] = True
break
if int(s) % 4 == 0:
for z in range(y + 1, len(a)):
t = int(a[z] + s)
if t % 8 == 0:
m[1] = t
m[0] = True
break
if m[0]:
print("YES")
print(m[1])
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER IF STRING VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER IF STRING VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER IF VAR VAR STRING VAR VAR STRING ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR ASSIGN VAR NUMBER NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR ASSIGN VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | def isSubseq(s, x):
i, j = 0, 0
while True:
if j == len(x):
return True
if i == len(s):
return False
if s[i] == x[j]:
j += 1
i += 1
n = input().strip()
if len(n) == 1:
if n == "8" or n == "0":
print("YES")
print(n)
else:
print("NO")
elif len(n) == 2:
if int(n) % 8 == 0:
print("YES")
print(n)
elif "8" in n:
print("YES")
print(8)
elif "0" in n:
print("YES")
print(0)
else:
print("NO")
else:
poss = [str(i) for i in range(0, 1000, 8)]
found = False
for x in poss:
if len(x) > len(n):
break
if isSubseq(n, x):
found = True
print("YES")
print(x)
break
if not found:
print("NO") | FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER WHILE NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER IF VAR STRING VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR IF VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | number = input()
flag = False
for i1 in range(len(number)):
if int(number[i1]) % 8 == 0:
flag = True
print(f"YES\n{number[i1]}")
break
for i2 in range(i1 + 1, len(number)):
if int(number[i1] + number[i2]) % 8 == 0:
flag = True
print(f"YES\n{number[i1] + number[i2]}")
break
for i3 in range(i2 + 1, len(number)):
if int(number[i1] + number[i2] + number[i3]) % 8 == 0:
flag = True
print(f"YES\n{number[i1] + number[i2] + number[i3]}")
break
if flag:
break
if flag:
break
if not flag:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF VAR IF VAR IF VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | n = input()
def check(d):
dp = 0
for i in n:
if dp == len(d):
return True
if i == d[dp]:
dp += 1
return dp == len(d)
if int(n) % 8 == 0:
print("YES")
print(n)
exit(0)
if "0" in n:
print("YES")
print(0)
exit(0)
if "8" in n:
print("YES")
print(8)
exit(0)
divs = [str(i * 8) for i in range(1, 125)]
for d in divs:
if check(d):
print("YES")
print(d)
exit(0)
print("NO") | ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR VAR VAR VAR NUMBER RETURN VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | n = input()
found = False
for i in range(len(n)):
if int(n[i]) % 8 == 0:
found = True
print("YES")
print(n[i])
break
if not found:
for i in range(len(n)):
if found:
break
for j in range(i + 1, len(n)):
if int(n[i] + n[j]) % 8 == 0:
found = True
print("YES")
print(n[i] + n[j])
break
if not found:
for i in range(len(n)):
if found:
break
for j in range(i + 1, len(n)):
if found:
break
for k in range(j + 1, len(n)):
if int(n[i] + n[j] + n[k]) % 8 == 0:
found = True
print("YES")
if i == 0:
print(n[i] + n[j] + n[k])
else:
print(n[i - 1] + n[i] + n[j] + n[k])
break
if not found:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR IF VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR VAR IF VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | n = input()
n = n[::-1]
sol = 0
found = False
for i in range(len(n) - 2):
for j in range(i + 1, len(n) - 1):
for k in range(j + 1, len(n)):
if int(n[k] + n[j] + n[i]) % 8 == 0:
sol = str(int(n[k] + n[j] + n[i]))
found = True
break
if found:
break
if found:
break
if found:
print("YES\n" + sol)
else:
for i in range(len(n) - 1):
for j in range(i + 1, len(n)):
if int(n[j] + n[i]) % 8 == 0:
sol = str(int(n[j] + n[i]))
found = True
break
if found:
break
if found:
print("YES\n" + sol)
else:
for i in n:
if int(i) == 8 or int(i) == 0:
sol = i
found = True
break
if found:
print("YES\n" + sol)
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR IF VAR IF VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR IF VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | str = input()
x = []
for i in range(len(str)):
x.append(str[i])
y = "".join(x)
raw = int(y)
if raw % 8 == 0:
print("YES")
print(raw)
exit()
for j in range(i + 1, len(str)):
x.append(str[j])
y = "".join(x)
raw = int(y)
if raw % 8 == 0:
print("YES")
print(raw)
exit()
for k in range(j + 1, len(str)):
x.append(str[k])
y = "".join(x)
raw = int(y)
if raw % 8 == 0:
print("YES")
print(raw)
exit()
x.pop()
x.pop()
x.pop()
print("NO")
exit() | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | n = input()
z = False
while int(n[len(n) - 1]) % 2 == 1:
n = n[: len(n) - 1]
if n == "":
break
if n.count("8") > 0:
print("YES")
print("8")
elif n.count("0") > 0:
print("YES")
print("0")
elif n.count("6") == 0 and n.count("4") == 0 and n.count("2") == 0:
print("NO")
elif n.count("1") > 0 and n.count("6") > 0 and n.find("6") > n.find("1"):
print("YES")
print("16")
elif n.count("2") > 0 and n.count("4") > 0 and n.find("4") > n.find("2"):
print("YES")
print("24")
elif n.count("3") > 0 and n.count("2") > 0 and n.find("2") > n.find("3"):
print("YES")
print("32")
elif n.count("5") > 0 and n.count("6") > 0 and n.find("6") > n.find("5"):
print("YES")
print("56")
elif n.count("6") > 0 and n.count("4") > 0 and n.find("4") > n.find("6"):
print("YES")
print("64")
elif n.count("7") > 0 and n.count("2") > 0 and n.find("2") > n.find("7"):
print("YES")
print("72")
elif n.count("9") > 0 and n.count("6") > 0 and n.find("6") > n.find("9"):
print("YES")
print("96")
else:
for i in range(len(n) - 2):
for j in range(i + 1, len(n) - 1):
for k in range(j + 1, len(n)):
if int(n[i] + n[j] + n[k]) % 8 == 0:
print("YES")
print(n[i] + n[j] + n[k])
z = True
break
if z == True:
break
if z == True:
break
if z == False:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR STRING IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | from sys import *
l = list(input())
for i in range(len(l)):
if int(l[i]) % 8 == 0:
print("YES")
print(int(l[i]))
exit()
for j in range(i + 1, len(l)):
if int(l[i] + l[j]) % 8 == 0:
print("YES")
print(int(l[i] + l[j]))
exit()
for k in range(j + 1, len(l)):
if int(l[i] + l[j] + l[k]) % 8 == 0:
print("YES")
print(int(l[i] + l[j] + l[k]))
exit()
print("NO") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | import itertools
def soln(n):
nStr = str(n)
if n % 8 == 0:
return n
for ch in nStr:
num = int(ch)
if num % 8 == 0:
return num
if len(nStr) >= 2:
for i in range(len(nStr)):
for j in range(i + 1, len(nStr)):
num = int("".join(nStr[index] for index in (i, j)))
if num % 8 == 0:
return num
if len(nStr) >= 3:
for i in range(len(nStr)):
for j in range(i + 1, len(nStr)):
for k in range(j + 1, len(nStr)):
num = int("".join(nStr[index] for index in (i, j, k)))
if num % 8 == 0:
return num
return None
def main():
n = int(input())
result = soln(n)
if result is None:
print("NO")
else:
print("YES")
print(result)
main() | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN VAR IF FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN VAR IF FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR VAR VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN VAR RETURN NONE FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NONE EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | from sys import stdin, stdout
n = str(input())
flag = False
for i in range(len(n)):
if int(n[i]) % 8 == 0:
flag = True
s = n[i]
break
if not flag:
for i in range(len(n) - 1):
for j in range(i + 1, len(n)):
if int(n[i] + n[j]) % 8 == 0:
s = n[i] + n[j]
flag = True
break
if flag:
break
if not flag:
s = ""
for i in range(len(n) - 2):
for j in range(i + 1, len(n) - 1):
for z in range(j + 1, len(n)):
s = n[i] + n[j] + n[z]
if int(s) % 8 == 0:
flag = True
break
if flag:
break
if flag:
break
if flag:
print("YES")
print(s)
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR IF VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR IF VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR IF VAR IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | import itertools
num = list(map(int, list(input())))
if 0 in num or 8 in num:
if 0 in num:
print("YES")
print(0)
elif 8 in num:
print("YES")
print(8)
else:
threes = list(itertools.combinations(num, 3))
twos = list(itertools.combinations(num, 2))
done = False
for i in twos:
v = i[0] * 10 + i[1]
if v % 8 == 0:
print("YES")
print(v)
done = True
break
if done == False:
for i in threes:
v = i[0] * 100 + i[1] * 10 + i[2]
if v % 8 == 0:
print("YES")
print(v)
done = True
break
if done == False:
print("NO") | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF NUMBER VAR NUMBER VAR IF NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | def main():
s = "00" + input()
l = len(s)
for i in range(l - 2):
for j in range(i + 1, l - 1):
for k in range(j + 1, l):
rezwan = int(s[i] + s[j] + s[k])
if rezwan % 8 == 0:
return print("YES\n", rezwan)
return print("NO\n")
main() | FUNC_DEF ASSIGN VAR BIN_OP STRING FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN FUNC_CALL VAR STRING VAR RETURN FUNC_CALL VAR STRING EXPR FUNC_CALL VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = [
0,
8,
16,
24,
32,
40,
48,
56,
64,
72,
80,
88,
96,
104,
112,
120,
128,
136,
144,
152,
160,
168,
176,
184,
192,
200,
208,
216,
224,
232,
240,
248,
256,
264,
272,
280,
288,
296,
304,
312,
320,
328,
336,
344,
352,
360,
368,
376,
384,
392,
400,
408,
416,
424,
432,
440,
448,
456,
464,
472,
480,
488,
496,
504,
512,
520,
528,
536,
544,
552,
560,
568,
576,
584,
592,
600,
608,
616,
624,
632,
640,
648,
656,
664,
672,
680,
688,
696,
704,
712,
720,
728,
736,
744,
752,
760,
768,
776,
784,
792,
800,
808,
816,
824,
832,
840,
848,
856,
864,
872,
880,
888,
896,
904,
912,
920,
928,
936,
944,
952,
960,
968,
976,
984,
992,
]
t = [c for c in input()]
n = len(t)
f = True
ans = True
i = 0
while i < 125 and f:
l = 0
r = [x for x in str(s[i])]
k = 0
while k < n and l < len(r):
if t[k] == r[l]:
l += 1
k += 1
if l == len(r):
f = False
ans = False
print("YES")
print(s[i])
i += 1
if ans:
print("NO") | 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 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 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 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 NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | import itertools
n = str(input())
x = ""
d = -1
z = []
y = []
if int(n) % 8 == 0:
print("YES")
print(n)
else:
for j in range(1, 4):
y += list(itertools.combinations(n, j))
for i in y:
x = "".join(i)
z.append(int(x))
for i in range(len(z)):
if z[i] / 8 == int(z[i] / 8):
d = z[i]
break
if d == -1:
print("NO")
else:
print("YES")
print(d) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = input()
if len(s) == 1:
if s == "0" or s == "8":
print("YES")
print(s)
else:
print("NO")
exit()
if len(s) == 2:
if int(s) % 8 == 0:
print("YES")
print(s)
elif s[0] in "08":
print("YES")
print(s[0])
elif s[1] in "08":
print("YES")
print(s[1])
else:
print("NO")
exit()
for i in s:
if i in "08":
print("YES")
print(i)
exit()
n = len(s)
for i in range(n):
for j in range(i + 1, n):
if int(s[i] + s[j]) % 8 == 0:
print("YES")
print(s[i] + s[j])
exit()
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
if int(s[i] + s[j] + s[k]) % 8 == 0:
print("YES")
print(s[i] + s[j] + s[k])
exit()
print("NO") | ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER IF VAR STRING VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | n1 = input()
n = []
for i in n1:
n.append(int(i))
k = len(n)
for i in range(k):
if n[i] % 8 == 0:
print("YES")
print(n[i])
exit()
if k > 1:
for i in range(k):
t = n[i] * 10
for j in range(i + 1, k):
if (t + n[j]) % 8 == 0:
print("YES")
print(t + n[j])
exit()
if k > 2:
for i in range(k):
t = n[i] * 100
for j in range(i + 1, k):
l = n[j] * 10
for e in range(j + 1, k):
if (t + l + n[e]) % 8 == 0:
print("YES")
print(t + l + n[e])
exit()
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP BIN_OP VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = input()
n = len(s)
if "0" in s:
print("YES")
print(0)
exit()
if n == 1:
if s == "8":
print("YES")
print(s)
else:
print("NO")
exit()
elif n == 2:
k = int(s)
o = -1
if int(s[0]) % 8 == 0 or int(s[1]) % 8 == 0:
o = 8
if k % 8 == 0:
print("YES")
print(k)
elif o == -1:
print("NO")
else:
print("YES")
print(o)
exit()
elif n == 3:
k = int(s)
o = -1
if int(s[-1]) % 8 == 0 or int(s[-2]) % 8 == 0 or int(s[-3]) % 8 == 0:
o = 8
if int(s[-2] + s[-1]) % 8 == 0:
o = int(s[-2] + s[-1])
if int(s[-3] + s[-1]) % 8 == 0:
o = int(s[-3] + s[-1])
if int(s[-3] + s[-2]) % 8 == 0:
o = int(s[-3] + s[-2])
if k % 8 == 0:
print("YES")
print(k)
elif o == -1:
print("NO")
else:
print("YES")
print(o)
exit()
h = {}
for i in range(n - 1, -1, -1):
if int(s[i]) not in h:
h[int(s[i])] = i
f = {(0): 0, (1): 6, (2): 4, (3): 2, (4): [0, 8], (5): 6, (6): 4, (7): 2}
o = -1
for i in range(n - 2):
if s[i] == "0":
o = 0
break
if s[i] == "8":
o = 8
break
for j in range(i + 1, n - 1):
m = int(s[i] + s[j]) % 8
if m == 0:
o = int(s[i] + s[j])
break
if m == 4:
for k in f[m]:
if k in h and h[k] > j:
o = int(s[i] + s[j] + str(k))
break
if o != -1:
break
elif f[m] in h and h[f[m]] > j:
o = int(s[i] + s[j] + str(f[m]))
break
if o != -1:
break
if int(s[-1]) % 8 == 0 or int(s[-2]) % 8 == 0 or int(s[-3]) % 8 == 0:
o = 8
if int(s[-2] + s[-1]) % 8 == 0:
o = int(s[-2] + s[-1])
if int(s[-3] + s[-1]) % 8 == 0:
o = int(s[-3] + s[-1])
if int(s[-3] + s[-2]) % 8 == 0:
o = int(s[-3] + s[-2])
if o == -1:
for i in range(n - 1):
for j in range(i + 1, n):
if int(s[i] + s[j]) % 8 == 0:
o = int(s[i] + s[j])
break
if o != -1:
break
if o == -1:
print("NO")
else:
print("YES")
print(o) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER IF BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR NUMBER IF VAR VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF VAR NUMBER FOR VAR VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER IF BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = "00" + input()
n = len(s)
flag = 0
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
number = int(s[i] + s[j] + s[k])
if number % 8 == 0:
print("YES")
print(number)
exit()
print("NO") | ASSIGN VAR BIN_OP STRING FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | from itertools import combinations
def check(n):
for item in n:
if int(item) % 2 == 0 or int(item) == "8":
return True
return False
n = input()
result = "NO"
if "8" in n:
result = "YES"
n = "8"
elif not check(n):
pass
elif len(n) <= 10:
for i in range(len(n)):
for item in combinations(n, i + 1):
item = "".join(item)
if int(item) % 8 == 0:
result = "YES"
n = item
break
else:
for item in combinations(n, 3):
item = "".join(item)
if int(item) % 8 == 0:
result = "YES"
n = item
break
print(result)
if result == "YES":
print(str(int(n))) | FUNC_DEF FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FUNC_CALL VAR VAR STRING RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING IF STRING VAR ASSIGN VAR STRING ASSIGN VAR STRING IF FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | from itertools import combinations as comb
s = input()
n = len(s)
res = 0
found = False
if n <= 2:
if int(s) % 8 == 0:
res = s
found = True
elif n == 2:
if int(s[0]) % 8 == 0:
res = s[0]
found = True
elif int(s[1]) % 8 == 0:
res = s[1]
found = True
else:
arr = [i for i in range(n)]
for index in arr:
num = int(s[index])
if num % 8 == 0:
found = True
res = num
break
if not found:
for index in comb(arr, 2):
a, b = index
num = int(s[a] + s[b])
if num % 8 == 0:
found = True
res = num
break
if not found:
for index in comb(arr, 3):
a, b, c = index
num = int(s[a] + s[b] + s[c])
if num % 8 == 0:
found = True
res = num
break
if not found:
print("NO")
else:
print("YES")
print(res) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR FOR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR FOR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | class Trie:
def __repr__(self):
return {k: v.__repr__() for k, v in self.table.items()}
def __str__(self):
return str(self.__repr__())
def __init__(self):
self.table = dict()
def makeTrie(self, key, node):
if key == "":
self.table["isleaf"] = node
return
fst = key[0]
if fst not in self.table.keys():
self.table[fst] = Trie()
self.table[fst].makeTrie(key[1:], node)
def insert(self, s):
self.makeTrie(s, s)
def solve(trie, n):
pointers = set([trie])
for ch in n:
news = set([p.table[ch] for p in pointers if ch in p.table.keys()])
check = list(filter(lambda p: "isleaf" in p.table.keys(), news))
if len(check) > 0:
return check[0].table["isleaf"]
pointers = pointers | news
return "-1"
res = [str(x) for x in range(1001) if x % 8 == 0]
root = Trie()
for x in res:
root.insert(x)
n = input()
ans = solve(root, n)
flag = ans != "-1"
print("YES" if flag else "NO")
if flag:
print(ans) | CLASS_DEF FUNC_DEF RETURN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR STRING ASSIGN VAR STRING VAR RETURN ASSIGN VAR VAR NUMBER IF VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_DEF EXPR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR LIST VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN VAR NUMBER STRING ASSIGN VAR BIN_OP VAR VAR RETURN STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR STRING EXPR FUNC_CALL VAR VAR STRING STRING IF VAR EXPR FUNC_CALL VAR VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | def checker(text):
n = text
if any(n[i] == "0" for i in range(len(n))):
print("YES")
print("0")
return
elif any(n[i] == "8" for i in range(len(n))):
print("YES")
print("8")
return
else:
for i in range(len(n) - 1, 0, -1):
if int(n[i]) % 2 == 0:
for j in range(i - 1, -1, -1):
if int(n[j] + n[i]) % 8 == 0:
print("YES")
print(n[j] + n[i])
return
for k in range(j - 1, -1, -1):
if int(n[k] + n[j] + n[i]) % 8 == 0:
print("YES")
print(n[k] + n[j] + n[i])
return
print("NO")
return
checker(input()) | FUNC_DEF ASSIGN VAR VAR IF FUNC_CALL VAR VAR VAR STRING VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING RETURN IF FUNC_CALL VAR VAR VAR STRING VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING RETURN FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR RETURN FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR RETURN EXPR FUNC_CALL VAR STRING RETURN EXPR FUNC_CALL VAR FUNC_CALL VAR |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | import sys
k = input()
l = [int(i) for i in str(k)]
div = False
for x in range(0, len(l)):
if l[x] % 8 == 0:
print("YES")
print(l[x])
sys.exit()
pivote = 0
q = pivote + 1
aux = ""
while pivote < len(l) - 1 and div == False:
if q + 1 <= len(l):
aux = ""
aux = str(l[pivote])
aux += str(l[q])
q = q + 1
if int(aux) % 8 == 0:
print("Yes")
print(aux)
div = True
sys.exit
else:
pivote = pivote + 1
q = pivote + 1
if div == False:
pivote = 0
pivote2 = 1
q = pivote2 + 1
aux = ""
while pivote2 < len(l) - 1 and div == False:
if q + 1 <= len(l) and pivote2 + 1 <= len(l) - 1:
aux = ""
aux = str(l[pivote])
aux += str(l[pivote2])
aux += str(l[q])
q = q + 1
if int(aux) % 8 == 0:
print("Yes")
div = True
print(aux)
sys.exit
elif pivote2 + 1 < len(l) - 1:
pivote2 = pivote2 + 1
q = pivote2 + 1
elif pivote + 1 <= len(l) - 2:
pivote = pivote + 1
pivote2 = pivote + 1
q = pivote2 + 1
if div == False:
print("No") | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR STRING WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR STRING WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR VAR IF BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = input()
n = len(s)
if n > 2:
for x in range(n):
if int(s[x]) % 8 == 0:
print("YES")
print(s[x])
break
else:
pass
if int(s[x]) % 8 == 0:
pass
else:
for x in range(n - 1):
for y in range(x + 1, n):
m = int(s[x] + s[y])
if m % 8 == 0:
print("YES")
print(m)
break
else:
pass
if m % 8 == 0:
break
else:
pass
if m % 8 == 0:
pass
else:
for x in range(n - 2):
for y in range(x + 1, n - 1):
for z in range(y + 1, n):
m = int(s[x] + s[y] + s[z])
if m % 8 == 0:
print("YES")
print(s[x] + s[y] + s[z])
break
elif m % 8 != 0 and x != n - 3:
pass
else:
print("NO")
if m % 8 == 0:
break
else:
pass
if m % 8 == 0:
break
else:
pass
elif n == 2:
if int(s) % 8 == 0:
print("YES")
print(s)
elif int(s[0]) % 8 == 0:
print("YES")
print(s[0])
elif int(s[1]) % 8 == 0:
print("YES")
print(s[1])
else:
print("NO")
elif int(s) % 8 == 0:
print("YES")
print(s)
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER IF VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING |
You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
-----Input-----
The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.
-----Output-----
Print "NO" (without quotes), if there is no such way to remove some digits from number n.
Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.
If there are multiple possible answers, you may print any of them.
-----Examples-----
Input
3454
Output
YES
344
Input
10
Output
YES
0
Input
111111
Output
NO | s = input()
n = len(s)
flag = 0
res = ""
for x in s:
if int(x) % 8 == 0:
flag = 1
res = x
break
if flag == 0:
for i in range(n):
for j in range(i + 1, n):
num = int(s[i]) * 10 + int(s[j])
if num % 8 == 0:
res = num
flag = 1
break
if flag:
break
if flag == 0:
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
num = int(s[i]) * 100 + int(s[j]) * 10 + int(s[k])
if num % 8 == 0:
res = num
flag = 1
break
if flag:
break
if flag:
break
if flag:
print("YES")
print(res)
else:
print("NO") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR IF VAR IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.