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
def check(x): if x % 8 == 0: print("YES") print(x) exit(0) s = input() for i in range(len(s)): curi = int(s[i]) check(curi) for j in range(len(s)): if j <= i: continue curj = curi * 10 + int(s[j]) check(curj) for k in range(len(s)): if k <= j: continue curk = curj * 10 + int(s[k]) check(curk) print("NO")
FUNC_DEF IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR 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
dp = dict() st = input() def solve(index, qty, valor): t = index, qty, valor if t in dp: return dp[t] if index >= len(st) or qty >= 3: if valor % 8 == 0 and qty >= 1: dp[t] = valor else: dp[t] = -1 return dp[t] L = solve(index + 1, qty + 1, 10 * valor + int(st[index])) R = solve(index + 1, qty, valor) if L == R == -1: dp[t] = -1 elif L != -1: dp[t] = L else: dp[t] = R return dp[t] ans = solve(0, 0, 0) if ans == -1: print("NO") else: print("YES") print(ans)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR VAR IF VAR VAR RETURN VAR VAR IF VAR FUNC_CALL VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER NUMBER 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
nstr = input() def solve(nstr): for n8 in range(0, 1000, 8): if has_subseq(nstr, str(n8)): print("YES") print(n8) return print("NO") def has_subseq(nstr, n8str): pos = 0 limit = len(nstr) for n in n8str: while pos < limit and nstr[pos] != n: pos += 1 if pos == limit: return False pos += 1 return True solve(nstr)
ASSIGN VAR FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR RETURN EXPR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR WHILE VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR RETURN NUMBER VAR NUMBER RETURN NUMBER 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
n = int(input()) if n % 8 == 0: print("YES") print(n) else: results = "NO" n = str(n) a = len(n) for x in range(a): b = int(n[x]) if b % 8 == 0: results = "YES" break for y in range(x + 1, a): b = int(n[x] + n[y]) if b % 8 == 0: results = "YES" break for z in range(y + 1, a): b = int(n[x] + n[y] + n[z]) if b % 8 == 0: results = "YES" break if results == "YES": break if results == "YES": break print(results) if results == "YES": print(b)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR STRING 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 STRING 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 STRING IF VAR STRING IF VAR STRING 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
n = input() x = len(n) flag = 0 for _ in range(0, 100001, 8): s = str(_) a = "" __ = 0 S = len(s) for ___ in range(x): if __ < S: if s[__] == n[___]: a += s[__] __ += 1 if a == s: print("YES") print(a) flag = 1 break if flag == 0: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF 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
from itertools import combinations from sys import stdin string = list(stdin.readline().strip()) if len(string) >= 3: for i in range(len(string) - 2): for j in range(i + 1, len(string) - 1): for k in range(j + 1, len(string)): num = int(string[i] + string[j] + string[k]) if num % 8 == 0: print("YES") print(num) exit() else: continue if len(string) >= 2: for i in range(len(string) - 1): for j in range(i + 1, len(string)): num = int(string[i] + string[j]) if num % 8 == 0: print("YES") print(num) exit() else: continue if len(string) >= 1: for i in range(len(string)): num = int(string[i]) if num % 8 == 0: print("YES") print(string[i]) exit() else: continue print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR 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 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 IF FUNC_CALL VAR 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 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 IF FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL 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 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 sys k = input() k = "00" + k n = len(k) flag = True for i in range(n - 2): for j in range(i + 1, n - 1): for t in range(j + 1, n): f = int(k[i] + k[j] + k[t]) if f % 8 == 0 and flag: print("YES") print(f) flag = False if flag: print("NO")
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN 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 VAR 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
n = input() length = len(n) found = False n = n[::-1] if "8" in n: val = 8 found = True elif "0" in n: val = 0 found = True else: for i in range(1, length): if not found: for j in range(i): if not found: val = int(n[i] + n[j]) if not val % 8: found = True for i in range(2, length): if not found: for j in range(1, i): for z in range(j): if not found: val = int(n[i] + n[j] + n[z]) if not val % 8: found = True if not found: print("NO") else: print("YES") print(val)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER IF STRING VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR FOR VAR FUNC_CALL VAR VAR IF VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER 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
a = input() z = len(a) for i in range(0, 993, 8): s = str(i) s1 = len(s) o = 0 for k in a: if k == s[o]: o += 1 if o == s1: print("YES") print(i) exit() print("NO")
ASSIGN VAR FUNC_CALL VAR 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 ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER IF 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 = input() f = 0 for i in range(len(n)): if int(n[i]) % 8 == 0: print("YES") print(n[i]) f = 1 break if f == 0: for i in range(len(n)): if f == 1: break for j in range(i + 1, len(n)): if int(n[i] + n[j]) % 8 == 0: print("YES") print(n[i] + n[j]) f = 1 break if f == 0: for k in range(len(n)): if f == 1: break for i in range(k + 1, len(n)): if f == 1: break for j in range(i + 1, len(n)): if int(n[k] + n[i] + n[j]) % 8 == 0: print("YES") print(n[k] + n[i] + n[j]) f = 1 break if f == 0: 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 EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF 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 EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF 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 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 = str(input()) flag = 0 ans = 0 for i in range(len(s)): v1 = int(s[i]) if v1 % 8 == 0: flag = 1 ans = v1 break for j in range(i + 1, len(s)): if i != j: s1 = s[i] + s[j] v2 = int(s1) if v2 % 8 == 0: flag = 1 ans = v2 break for k in range(j + 1, len(s)): if i != j and j != k and k != i: ss = s[i] + s[j] + s[k] val = int(ss) if val % 8 == 0: flag = 1 ans = val break if flag == 1: break if flag == 1: break check = 0 for i in s: if i == "0": check = 1 break if flag == 1: print("YES") print(ans) elif check == 1: print("YES") print(0) else: print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR 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 ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR 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 NUMBER ASSIGN VAR VAR IF VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING 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 = int(input()) if N % 8 == 0: print("YES") print(N) else: ok = 0 N = str(N) for i in range(len(str(N))): for j in range(i + 1, len(str(N))): for k in range(j + 1, len(str(N))): if (100 * int(N[i]) + 10 * int(N[j]) + int(N[k])) % 8 == 0 and ok == 0: print("YES") print(100 * int(N[i]) + 10 * int(N[j]) + int(N[k])) ok = 1 for i in range(len(str(N))): for j in range(i + 1, len(str(N))): if (10 * int(N[i]) + int(N[j])) % 8 == 0 and ok == 0: print("YES") print(10 * int(N[i]) + int(N[j])) ok = 1 for i in range(len(str(N))): if int(N[i]) % 8 == 0 and ok == 0: print("YES") print(N[i]) ok = 1 if ok == 0: print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP 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 NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL 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
from itertools import combinations def prog(): s = "00" + input().strip() worked = False for combo in combinations(s, 3): combo = int("".join(combo)) if combo % 8 == 0: print("YES") print(combo) worked = True break if not worked: print("NO") prog()
FUNC_DEF ASSIGN VAR BIN_OP STRING FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF 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 = [int(x) for x in input()][::-1] def f(x): if x % 8 == 0: print("YES") print(x) exit() for i, x in enumerate(n): f(x) for j, y in enumerate(n[i + 1 :], i + 1): f(x + 10 * y) for z in n[j + 1 :]: f(x + 10 * y + 100 * z) print("NO")
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER FUNC_DEF IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VAR FOR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR BIN_OP NUMBER 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
numero = input() NiUnoNiOtro = False for cifra in range(0, 1000, 8): x = -1 encontrado = False for digito in str(cifra): x = numero.find(digito, x + 1) if x < 0: encontrado = True break if not encontrado: print("YES") print(cifra) NiUnoNiOtro = True break if not NiUnoNiOtro: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR 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
n = input().strip() till_1000 = [str(8 * num) for num in range(0, 125)] def is_subseq(sub): it = iter(n) return all(c in it for c in sub) for x in till_1000: if is_subseq(x): print("YES\n", x, sep="") break else: print("NO\n")
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR VAR VAR VAR FOR VAR VAR IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING VAR STRING 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") exit(0) if "8" in n: print("YES") print("8") exit(0) num = int(n) x = int(num / 8) def SinN(s, n): i = 0 for c in s: i = n.find(c, i) + 1 if i == 0: return False return True while x > 0: for i in range(-80, +80, 8): s = str(x * 8 + i) if SinN(s, n): print("YES") print(s) exit(0) x = int(x / 10) 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 IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER WHILE VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP 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
mas = (str(x) for x in range(0, 1000, 8)) s = input() q = False for x in mas: cnt = 0 if q: break for ch in s: if ch == x[cnt]: cnt += 1 if cnt == len(x): print("YES\n" + x) q = True break if not q: print("NO")
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER IF VAR FOR VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP 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
def check(S, x): if str(x) in S: return x K = list(str(x)) for i in S: if not K: return x if i == K[0]: K.pop(0) if not K: return x else: return -1 A = [] a = 0 while a < 1000: A.append(a) a += 8 S = input() for i in A: ans = check(S, i) if ans >= 0: print("YES") print(ans) break else: print("NO")
FUNC_DEF IF FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR RETURN VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR RETURN VAR RETURN NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR FUNC_CALL 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
def solve(): n = input() for i in range(0, 1000, 8): s = str(i) k = 0 for j in n: if s[k] == j: k += 1 if k == len(s): print("YES") print(s) return print("NO") for i in range(1): solve()
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR RETURN EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL 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 = input() a = 0 m = [int(l[x]) for x in range(len(l))] for x in range(len(m)): if m[x] in [0, 8]: a = 1 b = m[x] break else: pass if a != 1: for x in range(len(m)): for y in range(x + 1, len(m)): if (10 * m[x] + m[y]) % 8 == 0: a = 1 b = 10 * m[x] + m[y] break else: pass else: pass if a != 1: for x in range(len(m)): for y in range(x + 1, len(m)): for z in range(y + 1, len(m)): if (4 * m[x] + 2 * m[y] + m[z]) % 8 == 0: a = 1 b = 100 * m[x] + 10 * m[y] + m[z] break else: pass else: pass if a == 1: print("YES") print(b) else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR IF 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 BIN_OP BIN_OP NUMBER VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR VAR VAR IF 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 BIN_OP BIN_OP BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR BIN_OP NUMBER 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 = list(map(int, list(input()))) found = False sol = 0 L = len(n) for i in range(L): if n[i] % 8 == 0: sol = n[i] found = True if not found: for i in range(L): for j in range(i + 1, L): if (10 * n[i] + n[j]) % 8 == 0: sol = 10 * n[i] + n[j] found = True if not found: for i in range(L): for j in range(i + 1, L): for k in range(j + 1, L): if (100 * n[i] + 10 * n[j] + n[k]) % 8 == 0: sol = 100 * n[i] + 10 * n[j] + n[k] found = True if not found: print("NO") else: print("YES") print(sol)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER IF VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP BIN_OP BIN_OP NUMBER VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR VAR VAR ASSIGN VAR NUMBER IF 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 NUMBER VAR VAR BIN_OP NUMBER VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR VAR VAR VAR ASSIGN VAR NUMBER 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
n = input() def f(n): for i in reversed(range(len(n))): ni = int(n[i]) if ni % 8 == 0: return True, "%d" % ni if ni % 2 == 0: for j in reversed(range(i)): nj = int(n[j]) if (10 * nj + ni) % 8 == 0: return True, "%d%d" % (nj, ni) if (10 * nj + ni) % 4 == 0: for k in reversed(range(j)): nk = int(n[k]) if (100 * nk + 10 * nj + ni) % 8 == 0: return True, "%d%d%d" % (nk, nj, ni) return False, "" res = f(n) if res[0]: print("YES") print(res[1]) else: print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN NUMBER BIN_OP STRING VAR IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER NUMBER RETURN NUMBER BIN_OP STRING VAR VAR IF BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR VAR NUMBER NUMBER RETURN NUMBER BIN_OP STRING VAR VAR VAR RETURN NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR 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 f(x): for i, t in enumerate(x, 1): if t in "13579": return g(t, x[i:]) def g(t, x): for u, v in ["12", "36", "44", "52", "76", "92"]: i = x.find(u) if i != -1: j = x.find(v, i + 1) if j != -1: return t + u + v def h(x): for u, v in ["16", "24", "32", "56", "64", "72", "96"]: i = x.find(u) if i != -1: j = x.find(v, i + 1) if j != -1: return u + v t, x = "", input() if "0" in x: t = "0" elif "8" in x: t = "8" else: t = h(x) if not t: t = f(x) print("YES\n" + t if t else "NO")
FUNC_DEF FOR VAR VAR FUNC_CALL VAR VAR NUMBER IF VAR STRING RETURN FUNC_CALL VAR VAR VAR VAR FUNC_DEF FOR VAR VAR LIST STRING STRING STRING STRING STRING STRING ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN BIN_OP BIN_OP VAR VAR VAR FUNC_DEF FOR VAR VAR LIST STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN BIN_OP VAR VAR ASSIGN VAR VAR STRING FUNC_CALL VAR IF STRING VAR ASSIGN VAR STRING IF STRING VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR IF VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP STRING 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() l = len(n) flag = 0 for i in n: if int(i) % 8 == 0: print("YES") print(i) flag = 1 break if flag == 0: for i in range(l): for j in range(i + 1, l): if int(n[i] + n[j]) % 8 == 0: flag = 1 print("YES") print(n[i] + n[j]) break if flag == 1: break if flag == 0: 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: ans = n[i] + n[j] + n[k] print("YES") print(ans) 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 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 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 NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF VAR NUMBER 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 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 EXPR FUNC_CALL VAR STRING EXPR 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 = input() if int(n) % 8 == 0: print("YES") print(n) elif "0" in n: print("YES") print(0) elif "8" in n: print("YES") print(8) else: flag = 0 k = 0 while not flag and k < 100: d = "0" * (2 - len(str(k))) + str(k) k += 8 t = n p1 = t.find(d[0]) if p1 != -1: t = t[p1 + 1 :] p2 = t.find(d[1]) if p2 != -1: flag = 1 print("YES") print(d) k = 0 while not flag and k < 1000: d = "0" * (3 - len(str(k))) + str(k) k += 8 t = n p1 = t.find(d[0]) if p1 != -1: t = t[p1 + 1 :] p2 = t.find(d[1]) if p2 != -1: t = t[p2 + 1 :] p3 = t.find(d[2]) if p3 != -1: flag = 1 print("YES") if p1 != 0: print(n[0] + d) else: print(d) if flag == 0: 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 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 NUMBER ASSIGN VAR NUMBER WHILE VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR 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
s = input("") x = int(s) s = list(s) n = len(s) for i in range(n): s[i] = int(s[i]) if x % 8 == 0: print("YES") print(x) elif s.count(8) != 0: print("YES") print(8) elif s.count(0) != 0: print("YES") print(0) else: sol = -1 flag = 0 for i in range(n): for j in range(i + 1, n): num = int(str(s[i]) + str(s[j])) if num % 8 == 0: sol = num flag = 1 break if flag: break if sol != -1: print("YES") print(sol) else: for i in range(n): for j in range(i + 1, n): for k in range(j + 1, n): num = int(str(s[i]) + str(s[j]) + str(s[k])) if num % 8 == 0: sol = num flag = 1 break if flag: break if flag: break if sol != -1: print("YES") print(sol) else: print("NO")
ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL 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 ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR IF 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 diveight(n): for i in range(len(n) - 1, -1, -1): x1 = int(n[i]) if x1 % 8 == 0: return x1 for j in range(i - 1, -1, -1): x2 = x1 + int(n[j]) * 10 if x2 % 8 == 0: return x2 for k in range(j - 1, -1, -1): x3 = x2 + int(n[k]) * 100 if x3 % 8 == 0: return x3 return -1 n = input() x = diveight(n) if x >= 0: print("YES") print(x) else: print("NO")
FUNC_DEF 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 RETURN VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER 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 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
a = list(input()) a = list(map(int, a)) b = [] for i in range(len(a)): b.append(a[i] % 8) for i in range(len(a)): if b[i] in (0, 8): print("YES") print(a[i]) quit() for i in range(len(a)): for j in range(i, len(a)): if i != j: if (10 * b[i] + b[j]) % 8 == 0: print("YES") print(str(a[i]) + str(a[j])) quit() for i in range(len(a)): for j in range(i, len(a)): for k in range(j, len(a)): if not (i == j or j == k or k == i): if (100 * b[i] + 10 * b[j] + b[k]) % 8 == 0: print("YES") print(str(a[i]) + str(a[j]) + str(a[k])) quit() print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR IF BIN_OP BIN_OP BIN_OP NUMBER VAR 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 EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR IF BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR 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 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() for i in range(0, 1000, 8): x = 0 for j in str(i): x = s.find(j, x) if x == -1: break x += 1 if x != -1: print("YES") print(str(i)) exit() print("NO")
ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR 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() flag = 0 ans = 0 if "8" in s: flag = 1 ans = 8 if "0" in s: flag = 1 ans = 0 for i in range(len(s)): for j in range(i + 1, len(s)): if int(s[i] + s[j]) % 8 == 0: flag = 1 ans = int(s[i] + s[j]) for i in range(len(s)): for j in range(i + 1, len(s)): for k in range(j + 1, len(s)): if int(s[i] + s[j] + s[k]) % 8 == 0: flag = 1 ans = int(s[i] + s[j] + s[k]) if flag == 1: print("YES\n" + str(ans)) else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR ASSIGN 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 IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR 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 IF BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF VAR NUMBER 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
n = input() have = False ans = 0 for i in range(len(n)): if int(n[i]) % 8 == 0: have = True ans = int(n[i]) for i in range(len(n)): for j in range(i + 1, len(n)): if (int(n[i]) * 10 + int(n[j])) % 8 == 0: have = True ans = int(n[i]) * 10 + int(n[j]) 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]) * 100 + int(n[j]) * 10 + int(n[k])) % 8 == 0: have = True ans = int(n[i]) * 100 + int(n[j]) * 10 + int(n[k]) if not have: print("NO") else: print("YES") print(ans)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER 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 FUNC_CALL 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 IF BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL 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 IF BIN_OP 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 NUMBER NUMBER ASSIGN VAR NUMBER 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 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
ans = -1 n = input() def dfs(start, end, count, temp): global ans if count <= 3 and temp & 7 == 0: ans = temp return if count > 3: return for i in range(end + 1, len(n)): dfs(start, i, count + 1, temp * 10 + int(n[i])) for i in range(len(n)): count = 1 dfs(i, i, count, int(n[i])) if ans != -1: break if ans == -1: print("NO") else: print("YES") print(ans)
ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR RETURN IF VAR NUMBER RETURN FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR FUNC_CALL 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
def solve(): n = int(input()) if n < 100: if n % 8 == 0: print("YES") print(n) elif n % 10 == 0: print("YES") print(0) else: print("NO") else: s = str(n) if "0" in s: print("YES") print(0) elif "8" in s: print("YES") print(8) else: f = 0 for i in range(len(s) - 2): for j in range(i + 1, len(s) - 1): for k in range(j + 1, len(s)): t = int(s[i]) * 100 + int(s[j]) * 10 + int(s[k]) ij = int(s[i]) * 10 + int(s[j]) jk = int(s[j]) * 10 + int(s[k]) ik = int(s[i]) * 10 + int(s[k]) if t % 8 == 0: print("YES") print(t) f = 1 break elif ij % 8 == 0: print("YES") print(ij) f = 1 break elif jk % 8 == 0: print("YES") print(jk) f = 1 break elif ik % 8 == 0: print("YES") print(ik) f = 1 break else: f = 0 continue if f == 1: break if f == 1: break if f == 0: print("NO") solve()
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING 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 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 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 ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL 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 VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER 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 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
num = input() length = len(num) done = False result = 0 for i in range(0, length): result = int(num[i]) if result % 8 == 0: print("YES") print(result) done = True break if not done: result = 0 for i in range(0, length - 1): if done: break result += int(num[i]) * 10 for j in range(i + 1, length): if done: break result += int(num[j]) if result % 8 == 0: print("YES") print(result) done = True break result -= int(num[j]) result -= int(num[i]) * 10 if not done: result = 0 for i in range(0, length - 2): if done: break result += int(num[i]) * 100 for j in range(i + 1, length - 1): if done: break result += int(num[j]) * 10 for k in range(j + 1, length): result += int(num[k]) if result % 8 == 0: print("YES") print(result) done = True break result -= int(num[k]) result -= int(num[j]) * 10 result -= int(num[i]) * 100 if not done: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR BIN_OP FUNC_CALL 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
def sub(a, b): d = {} for l in range(len(b)): d[l] = b[l] for x in range(len(b)): if a and d[x] == a[0]: a = a[1:] if a == "": return True return False n = input() if "8" in n: print("YES", 8, sep="\n") else: e = [str(8 * x) for x in range(126) if "8" not in str(8 * x)] for x in e: if sub(x, n): print("YES") print(x) break else: print("NO")
FUNC_DEF ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR STRING RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR STRING NUMBER STRING ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER STRING FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR VAR IF FUNC_CALL VAR VAR 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
num_str = input() permutations = [""] i = 0 while i < len(num_str): new = [] for p in [x for x in permutations if len(x) < 3]: new.append(p + num_str[i]) permutations += new i += 1 found = None for x in set(permutations[1:]): if int(x) % 8 == 0: found = x break if found: print("YES") print(str(int(x))) else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST STRING ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NONE FOR VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR 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 = str(input()) n = [i for i in n] flag = False for i in range(len(n)): if int(n[i]) % 8 == 0: flag = True ans = n[i] break for j in range(i + 1, len(n)): if int(n[i] + n[j]) % 8 == 0: flag = True ans = n[i] + n[j] break for k in range(j + 1, len(n)): if int(n[i] + n[j] + n[k]) % 8 == 0: flag = True ans = n[i] + n[j] + n[k] break if flag: break if flag: print("YES") print(ans) else: print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR 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 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 ASSIGN VAR 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 ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR 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
a = input() if "0" in a: print("YES") print(0) else: x = 0 l = len(a) sol = False while x < l: if sol: break if int(a[x]) == 8: sol = True toprint = a[x] break for y in range(x, l): if int(a[x] + a[y]) % 8 == 0: sol = True toprint = a[x] + a[y] break for y in range(x + 1, l): for k in range(y + 1, l): if int(a[x] + a[y] + a[k]) % 8 == 0: sol = True toprint = a[x] + a[y] + a[k] break x += 1 if sol: print("YES") print(toprint) else: print("NO")
ASSIGN VAR FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR IF FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR 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 NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR 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
from itertools import combinations n = input() l = len(n) if n == "8" or n == "0": print("YES") print(n) elif n in ["1", "2", "3", "4", "5", "6", "7", "9"]: print("NO") elif l == 2 or l == 3: word = list(map(str, n)) for i in range(1, l + 1): x = list(combinations(word, i)) for j in x: cur = "".join(str(x) for x in j) cur = int(cur) if cur % 8 == 0: print("YES") print(cur) exit() print("NO") else: for i in range(l): if int(n[i]) % 8 == 0: print("YES") print(n[i]) exit() for i in range(l): for j in range(i + 1, l): if int(n[i] + n[j]) % 8 == 0: print("YES") print(n[i] + n[j]) exit() 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: print("YES") print(n[i] + n[j] + n[k]) exit() print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR IF VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR 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 STRING 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 EXPR FUNC_CALL 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
def is_possible(n, pat): i = 0 for c in n: if c == pat[i]: i += 1 if i == len(pat): return True return False def func(): n = input() if n.find("0") != -1: return print("YES\n0") if n.find("8") != -1: return print("YES\n8") pats = [ str(i) for i in range(0, 1000, 8) if str(i).find("0") == -1 and str(i).find("8") == -1 ] for pat in pats: if is_possible(n, pat): return print("YES\n" + pat) return print("NO") func()
FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING NUMBER RETURN FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING NUMBER RETURN FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER FUNC_CALL FUNC_CALL VAR VAR STRING NUMBER FUNC_CALL FUNC_CALL VAR VAR STRING NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR BIN_OP 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
from itertools import combinations def main(): n = input() if "0" in n: print("YES\n0") else: for i in range(1, min(3, len(n)) + 1): for r in combinations(n, i): m = int("".join(r)) if m % 8 == 0: print(f"YES\n{m}") exit() print("NO") main()
FUNC_DEF ASSIGN VAR FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR 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 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() i = 0 while i < 1000: t = str(i) j = 0 for k in s: if k == t[j]: j += 1 if j == len(t): break if j == len(t): print("YES") print(t) exit() i += 8 print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR 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 CanDo(num): num = num[::-1] for i in range(0, len(num)): if int(num[i]) % 2 != 0: continue a = int(num[i]) if a % 8 == 0: return a for j in range(i + 1, len(num)): b = int(num[j]) * 10 + a if b % 8 == 0: return b elif b % 4 == 0: for k in range(j + 1, len(num)): c = int(num[k]) * 100 + b if c % 8 == 0: return c return -1 num = str(input()) ans = CanDo(num) if ans == -1: print("NO") else: print("YES") print(ans)
FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER RETURN VAR IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER RETURN VAR RETURN NUMBER ASSIGN VAR FUNC_CALL 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
n = int(input()) x = n _len = 0 if n == 0: _len = 1 while x != 0: _len += 1 x = x // 10 flag = 0 ans = -1 l = list(map(int, list(str(n)))) for i in range(_len): if l[i] % 8 == 0: flag = 1 ans = l[i] if flag == 0: for j in range(i + 1, _len): if (l[i] * 10 + l[j]) % 8 == 0: flag = 1 ans = l[i] * 10 + l[j] if flag == 0: for k in range(j + 1, _len): if (l[i] * 100 + l[j] * 10 + l[k]) % 8 == 0: flag = 1 ans = l[i] * 100 + l[j] * 10 + l[k] if flag == 1: print("YES") print(ans) else: print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR IF VAR NUMBER 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 ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER 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
lectura = input() conclusion = "NO" for multiplos8 in [str(i) for i in range(1000) if i % 8 == 0]: marcador = -1 for intento2 in multiplos8: marcador = lectura.find(intento2, marcador + 1) if marcador == -1: break if marcador != -1: conclusion = "YES" + "\n" + str(multiplos8) print(conclusion)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING STRING 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
n = input() l = list(n) n = len(l) for i in range(len(l)): l[i] = int(l[i]) ans = 0 if 8 in l: print("YES") print(8) elif 0 in l: print("YES") print(0) elif n < 3: if n == 2: if (l[0] * 10 + l[1]) % 8 == 0: print("YES") print(l[0] * 10 + l[1]) elif l[1] == 0: print("YES") print(0) else: print("NO") if n == 1: if l[0] % 8 == 0: print("YES") print(l[0]) else: print("NO") else: for i in range(n - 2): for j in range(i + 1, n - 1): for k in range(j + 1, n): if (l[i] * 10**2 + l[j] * (10 * 1) + l[k] * 1) % 8 == 0: ans += 1 dig = l[i] * 10**2 + l[j] * (10 * 1) + l[k] * 1 break if (l[i] * 10 + l[j]) % 8 == 0: ans += 1 dig = l[i] * 10 + l[j] break if (l[j] * 10 + l[k]) % 8 == 0: ans += 1 dig = l[j] * 10 + l[k] break if (l[i] * 10 + l[k]) % 8 == 0: ans += 1 dig = l[i] * 10 + l[k] break if ans > 0: print("YES") print(dig) else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER 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 IF VAR NUMBER IF 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 BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING IF 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 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 IF BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP NUMBER NUMBER BIN_OP VAR VAR BIN_OP NUMBER NUMBER BIN_OP VAR VAR NUMBER NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP NUMBER NUMBER BIN_OP VAR VAR BIN_OP NUMBER NUMBER BIN_OP VAR VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER 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
__author__ = "victormion" def function(): for word in array: last = -1 flag = True for i in range(0, len(word)): last = n.find(word[i], last + 1) if last == -1: flag = False if flag: return word return -1 n = input() temp = 0 array = [] array.append(str(0)) while temp + 8 <= 999: temp += 8 array.append(str(temp)) res = function() if res == -1: print("NO") else: print("YES") print(res)
ASSIGN VAR STRING FUNC_DEF FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR RETURN VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER WHILE BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN 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
n = input().strip() ll = [] for i in range(16, 1001, 8): ll.append(str(i)) if "0" in n: print("YES\n0") elif "8" in n: print("YES\n8") else: f = False p = n for i in ll: n = p q = "" for j in range(len(i)): l = n.find(i[j]) if l != -1: q += i[j] n = n[l + 1 :] else: break if len(q) == len(i): f = True print("YES\n" + q) break print("NO" if f == False else "")
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF STRING VAR EXPR FUNC_CALL VAR STRING IF STRING VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR VAR ASSIGN VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR VAR NUMBER STRING 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 uni_c(): for c in n: v = int(c) if v % 8 == 0: return v return -1 def two_c(): for i in range(len(n)): for j in range(i + 1, len(n)): num = int(n[i]) * 10 + int(n[j]) if num % 8 == 0: return num return -1 def three_c(): for i in range(len(n)): for j in range(i + 1, len(n)): for k in range(j + 1, len(n)): num = int(n[i]) * 100 + int(n[j]) * 10 + int(n[k]) if num % 8 == 0: return num return -1 n = input() count = [(0) for i in range(10)] for digit in n: count[ord(digit) - ord("0")] += 1 ans = uni_c() if ans != -1: print("YES") print(ans) else: ans = two_c() if ans != -1: print("YES") print(ans) else: ans = three_c() if ans != -1: print("YES") print(ans) else: print("NO")
FUNC_DEF FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN VAR RETURN NUMBER FUNC_DEF 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 FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN VAR RETURN NUMBER FUNC_DEF 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 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 RETURN VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL 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 divisibili(a): m = len(a) k = 0 for i in range(m - 1, -1, -1): if int(a[i]) % 8 == 0: print("YES") print(a[i]) k = 1 return for j in range(i - 1, -1, -1): if (int(a[j]) * 2 + int(a[i])) % 8 == 0: print("YES") print(a[j] + a[i]) k = 1 return for k in range(j - 1, -1, -1): if (int(a[k]) * 4 + int(a[j]) * 2 + int(a[i])) % 8 == 0: print("YES") print(a[k] + a[j] + a[i]) k = 1 return if k == 0: print("NO") a = input() divisibili(a)
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER RETURN FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER RETURN FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP 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 NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER RETURN IF VAR NUMBER EXPR FUNC_CALL VAR 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
lis = list(input()) n = len(lis) ans = 0 aa = [2, 4, 8] c = 0 for i in range(n - 1, -1, -1): tmp = ans + int(lis[i]) * 10**c if tmp % aa[c] == 0: ans = tmp c += 1 if c == 3: break if c == 0 or ans % 8 != 0: print("NO") else: print("YES") print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP FUNC_CALL VAR VAR VAR BIN_OP NUMBER VAR IF BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER 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
i = input() def sub_is_8_divisible(number): possible = set() i = 1 while i <= len(number): possible.add(int(number[-i])) i += 1 i = 1 while i <= len(number): e = i + 1 while e <= len(number): possible.add(int(number[-e] + number[-i])) e += 1 i += 1 i = 1 while i <= len(number): e = i + 1 while e <= len(number): o = e + 1 while o <= len(number): possible.add(int(number[-o] + number[-e] + number[-i])) o += 1 e += 1 i += 1 for i in possible: if int(i) % 8 == 0: return ["YES", i] return ["NO"] for i in sub_is_8_divisible(i): print(i)
ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER RETURN LIST STRING VAR RETURN LIST STRING FOR VAR 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
from sys import stdin, stdout for _ in range(1): s = input() n = len(s) ans = -1 if "8" in s: print("YES") print("8") continue if "0" in s: print("YES") print("0") continue 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: ans = s[i] + s[j] + s[k] break for j in range(n): for k in range(j + 1, n): if int(s[j] + s[k]) % 8 == 0: ans = s[j] + s[k] break if ans == -1: print("NO") else: print("YES") print(ans)
FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER 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 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 BIN_OP BIN_OP VAR VAR VAR VAR 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 ASSIGN VAR BIN_OP VAR 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
def possible(A): rems = [False] * 8 prev = {} digitFor = {} for x in A: digit = int(x) nxtRems = [False] * 8 if digit % 8 not in digitFor: digitFor[digit % 8] = str(digit) nxtRems[digit % 8] = True for rem in range(len(rems)): nxtRems[rem] |= rems[rem] nxt = (rem * 10 + digit) % 8 nxtRems[nxt] |= rems[rem] if nxtRems[nxt] and nxt not in digitFor: prev[nxt] = rem digitFor[nxt] = str(digit) if nxtRems[0]: print("YES") p = 0 s = "" while p in prev: s = digitFor[p] + s p = prev[p] print(digitFor[p] + s) return rems = nxtRems print("NO") possible(input())
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR VAR VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR STRING WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR RETURN ASSIGN VAR VAR EXPR FUNC_CALL VAR STRING 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
from itertools import * from sys import * s = input() com, com2 = list(combinations(s, 3)), list(combinations(s, 2)) l, eight, zero = len(s), s.find("8"), s.find("0") if l == 1: if int(s) % 8: exit(print("NO")) else: exit(print("YES", s, sep="\n")) if eight != -1: exit(print("YES", "8", sep="\n")) elif zero != -1: exit(print("YES", "0", sep="\n")) elif l == 2: if int(s) % 8 == 0: exit(print("YES", s, sep="\n")) else: exit(print("NO")) for i in com: num = int("".join(i)) if num % 8 == 0: exit(print("YES", num, sep="\n")) for i in com2: num = int("".join(i)) if num % 8 == 0: exit(print("YES", num, sep="\n")) print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING IF VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR STRING VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR STRING STRING STRING IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR STRING STRING STRING IF VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR STRING VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR STRING FOR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR STRING VAR STRING FOR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR STRING VAR STRING 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 sub_2(num_list, n): for i in range(n): for j in range(i + 1, n): sub_num = num_list[i] * 10 + num_list[j] if sub_num % 8 == 0: print("YES") return sub_num return -1 def sub_3(num_list, n): for i in range(n): for j in range(i + 1, n): for k in range(j + 1, n): sub_num = num_list[i] * 100 + num_list[j] * 10 + num_list[k] if sub_num % 8 == 0: print("YES") return sub_num return -1 num_list = list(map(int, input())) n = len(num_list) if 8 in num_list: print("YES") print("8") elif 0 in num_list: print("YES") print("0") else: result = sub_2(num_list, n) if result == -1: r3 = sub_3(num_list, n) if r3 == -1: print("NO") else: print(r3) else: print(result)
FUNC_DEF FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING RETURN VAR RETURN NUMBER FUNC_DEF 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 VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING RETURN VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER 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
n = str(input()) k = 0 l = int(n) + 1 for i in range(len(n)): m = n[i] if int(m) % 8 == 0: k = k + 1 l = m break for i in range(len(n) - 1): for j in range(i + 1, len(n)): m = n[i] + n[j] if int(m) % 8 == 0: k = k + 1 l = m break for i in range(len(n) - 2): for j in range(i + 1, len(n) - 1): for t in range(j + 1, len(n)): m = n[i] + n[j] + n[t] if int(m) % 8 == 0: k = k + 1 l = m break if k > 0: print("YES") print(int(l)) else: print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN 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 VAR VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR 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 VAR VAR VAR VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR 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
a = list(map(int, list(input()))) n = len(a) dp = [(0) for i in range(n)] flag = 0 ans = 0 for i in range(n): if a[i] == 0 or a[i] == 8: flag = 1 ans = a[i] break if flag == 0: for i in range(1, n): for j in range(i): if (a[j] * 10 + a[i]) % 8 == 0: ans = a[j] * 10 + a[i] flag = 1 break if flag == 1: break if flag == 0: for i in range(2, n): for j in range(1, i): for k in range(j): if (a[k] * 100 + a[j] * 10 + a[i]) % 8 == 0: ans = a[k] * 100 + a[j] * 10 + a[i] flag = 1 break if flag == 1: break if flag == 1: break if flag == 1: print("YES") print(ans) else: print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF 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
a = input() n = len(a) was = False for i4 in range(n - 1, -1, -1): if was: break p = int(a[i4]) if p % 8 == 0: print("YES") print(p) was = True if p % 2 != 0: continue for i3 in range(i4 - 1, -1, -1): if was: break p += int(a[i3]) * 10 if p % 8 == 0: print("YES") print(p) was = True for i2 in range(i3 - 1, -1, -1): if was: break p += int(a[i2]) * 100 if p % 8 == 0: print("YES") print(p) was = True else: p -= int(a[i2]) * 100 p -= int(a[i3]) * 10 p -= int(a[i4]) if not was: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR ASSIGN VAR FUNC_CALL 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 VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF 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 NUMBER NUMBER IF VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR 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
A = input() list(A) A = [int(i) for i in A] if A[0] == 0: print("YES") print(0) else: result = "NO" for i in range(0, len(A)): for j in range(i + 1, len(A)): for k in range(j + 1, len(A)): if (100 * A[i] + 10 * A[j] + A[k]) % 8 == 0: result = 100 * A[i] + 10 * A[j] + A[k] for i in range(0, len(A)): for j in range(i + 1, len(A)): if (10 * A[i] + A[j]) % 8 == 0: result = 10 * A[i] + A[j] for i in range(0, len(A)): if A[i] == 0 or A[i] == 8: result = A[i] if result != "NO": print("YES") print(result)
ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR STRING 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 BIN_OP BIN_OP BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR BIN_OP NUMBER 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 IF BIN_OP BIN_OP BIN_OP NUMBER VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR IF 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 itertools C = list(map(int, input().strip())) if 8 in C: print("YES") print(8) elif 0 in C: print("YES") print(0) else: combi = [] for i in range(1, 4): tmp = [list(x) for x in itertools.combinations(C, i)] combi.extend(tmp) flag = True for tmp in combi: num = int("".join(map(str, tmp))) if num % 8 == 0: print("YES") print(num) flag = False break if flag: print("NO")
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL 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 LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR IF BIN_OP 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
ASCII_0 = ord("0") def can_remove_digits(number_string): i = len(number_string) - 1 while i >= 0: third_digit = ord(number_string[i]) - ASCII_0 if third_digit % 8 == 0: return third_digit j = i - 1 while j >= 0: second_digit = ord(number_string[j]) - ASCII_0 last_two_digits = second_digit * 10 + third_digit if last_two_digits % 8 == 0: return last_two_digits k = j - 1 while k >= 0: first_digit = ord(number_string[k]) - ASCII_0 last_three_digits = first_digit * 100 + last_two_digits if last_three_digits % 8 == 0: return last_three_digits k -= 1 j -= 1 i -= 1 return -1 def run_alg(): result = can_remove_digits(input()) if result == -1: print("NO") else: print("YES\n%d" % result) run_alg()
ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER RETURN VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER RETURN VAR VAR NUMBER VAR NUMBER VAR NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING 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
m = [] flag = False for i in range(100, 999): if i % 8 == 0: m.append(str(i)) s = input() for i in m: posa = 1000 posb = 1000 posc = 1000 a = i[0] b = i[1] c = i[2] for j in range(len(s)): if s[j] == a: posa = j break for j in range(posa + 1, len(s)): if s[j] == b: posb = j break for j in range(posb + 1, len(s)): if s[j] == c: posc = j if posa != 1000 and posb != 1000 and posc != 1000 and posa < posb < posc: flag = True ans = i m = [] for i in range(10, 99): if i % 8 == 0: m.append(str(i)) for i in m: a = i[0] b = i[1] posa = 1000 posb = 1000 for j in range(len(s)): if s[j] == a: posa = j break for j in range(posa + 1, len(s)): if s[j] == b: posb = j break if posa != 1000 and posb != 1000 and posa < posb: flag = True ans = i if s.find("8") != -1: flag = True ans = 8 if s.find("0") != -1: flag = True ans = 0 if flag: print("YES") print(ans) else: print("NO")
ASSIGN VAR LIST ASSIGN VAR NUMBER 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 FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR NUMBER 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
a = input() def ans(i, a): b = str(i) j = 0 for i in a: if i == b[j]: j += 1 if j == len(b): return 1 return 0 q = 0 for i in range(0, 1000, 8): if ans(i, a): q = 1 break if q: print("YES") print(i) else: print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF FUNC_CALL VAR 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
arr = list(map(int, list(input()))) found = False i = len(arr) - 1 while i >= 0 and not found: if arr[i] == 0 or arr[i] == 8: print("YES") print(0 if arr[i] == 0 else 8) found = True i -= 1 i = len(arr) - 1 while not found and i >= 0: if arr[i] % 2 == 0: for j in range(i): if (10 * arr[j] + arr[i]) % 8 == 0: print("YES") print(10 * arr[j] + arr[i]) found = True break for k in range(j): if (100 * arr[k] + 10 * arr[j] + arr[i]) % 8 == 0: print("YES") print(100 * arr[k] + 10 * arr[j] + arr[i]) found = True break if found == True: break i -= 1 if found == False: print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER VAR IF VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP BIN_OP NUMBER VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER 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 verify(x): return x != -1 d = dict() def solve(index, cur): if index == len(n): if cur % 8 == 0 and cur: return cur return -1 if (index, cur) in d: return d[index, cur] x = solve(index + 1, cur) y = solve(index + 1, (cur * 10 + int(n[index])) % 1000) if verify(x): d[index, cur] = x return x if verify(y): d[index, cur] = y return y d[index, cur] = -1 return -1 n = input() if "0" in n: print("YES\n0") exit() x = solve(0, 0) if x != -1: print("YES") print(x) else: print("NO")
FUNC_DEF RETURN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR RETURN VAR RETURN NUMBER IF VAR VAR VAR RETURN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR RETURN VAR IF FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR RETURN VAR ASSIGN VAR VAR VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER 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
n = input() a = [] for i in n: a.append(i) if "0" in a: print("YES") print(0) elif "8" in a: print("YES") print(8) elif len(a) == 1: print("NO") elif len(a) == 2: if int(n) % 8 == 0: print("YES") print(n) else: print("NO") elif len(a) >= 3: for j in range(len(a) - 1): for k in range(j + 1, len(a)): y = int(a[j] + a[k]) if y % 8 == 0 and str(y)[0] != 0: print("YES") print(y) break else: for m in range(k + 1, len(a)): x = int(a[j] + a[k] + a[m]) if x % 8 == 0 and str(x)[0] != 0: print("YES") print(x) break else: continue break else: continue break else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR 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 FUNC_CALL VAR VAR NUMBER 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 EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR 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 ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR 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 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
import sys input = [] input_index = 0 def next(type, number=None): def next(): global input, input_index while input_index == len(input): if sys.stdin: input = sys.stdin.readline().split() input_index = 0 else: raise Exception() input_index += 1 return input[input_index - 1] if number is None: result = type(next()) else: result = [type(next()) for _ in range(number)] return result s = next(str) ns = {str(n) for n in range(0, 1000, 8)} res = None for i1 in range(len(s)): n1 = s[i1] if n1 in ns: res = n1 else: for i2 in range(i1 + 1, len(s)): n2 = n1 + s[i2] if n2 in ns: res = n2 else: for i3 in range(i2 + 1, len(s)): n3 = n2 + s[i3] if n3 in ns: res = n3 break if res is not None: break if res is not None: break if res is not None: print("YES") print(res) else: print("NO")
IMPORT ASSIGN VAR LIST ASSIGN VAR NUMBER FUNC_DEF NONE FUNC_DEF WHILE VAR FUNC_CALL VAR VAR IF VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER RETURN VAR BIN_OP VAR NUMBER IF VAR NONE ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NONE FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR NONE IF VAR NONE 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
ans = -1 num = input() temp = 0 for x in range(0, 1000, 8): for sym in str(x): if sym in num[temp:]: temp = num[temp:].index(sym) + 1 + temp else: temp = 0 break else: ans = x break if ans == -1: print("NO") else: print("YES", ans, sep="\n")
ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING 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(s): for i in range(0, len(s)): if int(s[i]) % 8 == 0: print("YES") print(s[i]) return for i in range(0, len(s) - 1): for j in range(i + 1, len(s)): if int(s[i] + s[j]) % 8 == 0: print("YES") print(s[i] + s[j]) return for i in range(0, 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: print("YES") print(s[i] + s[j] + s[k]) return print("NO") s = input() solve(s)
FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER 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 RETURN FOR VAR FUNC_CALL 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 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 NUMBER 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 RETURN EXPR FUNC_CALL VAR 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
digits = input()[::-1] val = None for i in range(0, 1000, 8): first = 0 for j in reversed(str(i)): c = digits.find(j, first) if c == -1: break else: first = c + 1 else: val = i break print("YES" + "\n" + str(val) if val != None else "NO")
ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR NONE 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 ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR NONE BIN_OP BIN_OP STRING STRING FUNC_CALL 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
s = input() a = [int(x) for x in s] n = len(s) for i in range(n): if a[i] % 8 == 0: print("YES") print(a[i]) exit() ans = [] for i in range(n): for j in range(i + 1, n): if (a[i] * 10 + a[j]) % 8 == 0: print("YES") print(a[i] * 10 + a[j]) exit() for k in range(j + 1, n): if (a[i] * 100 + a[j] * 10 + a[k]) % 8 == 0: print("YES") print(a[i] * 100 + a[j] * 10 + a[k]) exit() print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR 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 ASSIGN VAR LIST 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 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 VAR NUMBER VAR IF BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER 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 as it n = list(input()) flag = 0 for i in range(1, 4): temp = it.combinations(n, i) for j in temp: temp1 = int("".join(j)) if temp1 % 8 == 0: print("YES") print(temp1) flag = 1 break else: continue if flag == 1: break if flag != 1: print("NO")
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN 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
eg = list(str(input())) for i in range(len(eg)): eg[i] = int(eg[i]) for i in range(0, len(eg) - 2): for j in range(i + 1, len(eg) - 1): for m in range(j + 1, len(eg)): if (eg[i] * 100 + eg[j] * 10 + eg[m]) % 8 == 0: print("YES") print(eg[i] * 100 + eg[j] * 10 + eg[m]) exit(0) for i in range(0, len(eg)): for j in range(i + 1, len(eg)): if (eg[i] * 10 + eg[j]) % 8 == 0: print("YES") print(eg[i] * 10 + eg[j]) exit(0) for i in range(0, len(eg)): if eg[i] % 8 == 0: print("YES") print(eg[i]) exit(0) print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER 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 BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER 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 BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR EXPR FUNC_CALL 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 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
ch = str(input()) T = "NO" if len(ch) >= 3: T = "NO" res = 0 BIG = list() for i in range(100, 1000): if i % 8 == 0: BIG.append(i) for n in BIG: a = str(n)[0] b = str(n)[1] c = str(n)[2] m = len(ch) n = len(ch) p = len(ch) for i in range(len(ch)): if ch[i] == a: m = i break for i in range(len(ch)): if ch[i] == b and i > m: n = i break for i in range(len(ch)): if ch[i] == c and i > n: p = i break if max(p, m, n) < len(ch): if m < n and n < p: T = "YES" res = int(ch[m]) * 100 + int(ch[n]) * 10 + int(ch[p]) break if "0" in ch: T = "YES" res = 0 if "8" in ch: T = "YES" res = 8 BIG = list() for i in range(10, 100): if i % 8 == 0: BIG.append(i) for n in BIG: a = str(n)[0] b = str(n)[1] m = len(ch) n = len(ch) for i in range(len(ch)): if ch[i] == a: m = i break for i in range(len(ch)): if ch[i] == b and i > m: n = i break if max(m, n) < len(ch): if m < n: T = "YES" res = int(ch[m]) * 10 + int(ch[n]) break elif len(ch) == 2: if ch[1] in "80": T = "YES" res = int(ch[1]) if int(ch) % 8 == 0: T = "YES" res = int(ch) elif len(ch) == 1: if ch[0] in "80": T = "YES" res = int(ch[0]) if T == "NO": print("NO") if T == "YES": print(T) print(res)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR VAR IF FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR STRING 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 STRING VAR ASSIGN VAR STRING ASSIGN VAR NUMBER IF STRING VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR VAR IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR STRING ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR STRING IF 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
def readint(): return int(input()) def readfloat(): return float(input()) def readarray(n, f=input): return [f() for i in range(n)] def readlinearray(f=int): return list(map(f, input().split())) def euclide(a, b): if a < 0: g, x, y = euclide(-a, b) return g, -x, y if b < 0: g, x, y = euclide(a, -b) return g, x, -y if b == 0: return a, 1, 0 g, x, y = euclide(b, a % b) return g, y, x - a // b * y def gen_primes(max): primes = [1] * (max + 1) for i in range(2, max + 1): if primes[i]: for j in range(i + i, max + 1, i): primes[j] = 0 primes[0] = 0 return [x for x in range(max + 1) if primes[x]] def is_prime(N): if N % 2 == 0: return N == 2 i = 3 while i * i <= N: if N % i == 0: return False i += 2 return True n = input() for i in range(0, 1000, 8): i = str(i) can = 0 j = 0 while j < len(n) and can < len(i): if i[can] == n[j]: can += 1 j += 1 if can == len(i): print("YES") print(i) exit() print("NO")
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF VAR RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR VAR IF VAR NUMBER RETURN VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR RETURN VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER RETURN VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR FUNC_DEF IF BIN_OP VAR NUMBER NUMBER RETURN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER RETURN NUMBER VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF 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
def solve(): n = int(input()) arr = [int(i) for i in str(n)] unique = [i for i in arr if i % 2 == 0] if 0 in arr: print("YES") print(0) return elif n % 8 == 0: print("YES") print(n) return elif len(unique) == 0: print("NO") return numbers = [i for i in range(8, 1001) if i % 8 == 0] for i in numbers: num = [int(j) for j in str(i)] counter = len(num) - 1 index = len(arr) - 1 while index >= 0: if num[counter] == arr[index]: counter -= 1 if counter < 0: print("YES") print(i) return index -= 1 print("NO") solve()
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER IF NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER RETURN IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR RETURN IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR RETURN 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
v = [] for i in input(): v.append(int(i)) n = len(v) succ = False for i in range(0, n): for j in range(i, n): for k in range(j, n): if succ: continue s = set() s.add(i) s.add(j) s.add(k) r = 0 z = [] for x in s: z.append(x) z.sort() s = z for x in s: r *= 10 r += v[x] if r % 8 == 0: succ = True print("YES") print(r) if not succ: print("NO")
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR IF VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR FOR VAR VAR VAR NUMBER VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER 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
n = "00" + input() while len(n) >= 3 and int(n[-1]) % 2 == 1: n = n[:-1] while len(n) >= 3 and int(n[-2] + n[-1]) % 4 != 0: n = n[:-2] + n[-1] while len(n) >= 3 and int(n[-3] + n[-2] + n[-1]) % 8 != 0: n = n[:-3] + n[-2] + n[-1] n = n[2:] if n: print("YES") print(n) else: print("NO")
ASSIGN VAR BIN_OP STRING 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 BIN_OP VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR 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 preveritabelo(list): preverjenec = list[0] if preverjenec % 8 != 0: resitu = True for element in range(len(list)): if list[element] == preverjenec: continue else: resitu = False break return resitu else: return preverjenec def main(): a = int(input()) t = [] for i in str(a): t.append(int(i)) if preveritabelo(t) == True: print("NO") quit() elif preveritabelo(t) == t[0]: print("YES") print(preveritabelo(t)) quit() dolzina = 0 while dolzina <= len(t): for e in range(len(t) - dolzina + 1): for f in range(e + 1, len(t) - dolzina + 1): b = "" stevec = 0 for i in range(dolzina): b += str(t[f + stevec]) stevec += 1 if int(str(t[e]) + b) % 8 == 0: print("YES") print(str(t[e]) + b) quit() dolzina += 1 dolzina = 0 while dolzina < len(t): for e in range(len(t) - dolzina): b = "" stevec = e for i in range(dolzina): b += str(t[stevec]) stevec += 1 for f in range(stevec, len(t)): if int(b + str(t[f])) % 8 == 0: print("YES") print(b + str(t[f])) quit() dolzina += 1 print("NO") main()
FUNC_DEF ASSIGN VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR NUMBER RETURN VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL 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() N = len(S) flag = 0 if S.count("0") > 0: print("YES") print(0) exit() if S.count("8") > 0: print("YES") print(8) exit() if N < 3: 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: print("NO") exit() for i in range(N - 2): if int(S[i]) % 8 == 0: print("YES") print(S[i]) flag = 1 break for j in range(i + 1, N - 1): if int(S[i] + S[j]) % 8 == 0: print("YES") print(S[i] + S[j]) flag = 1 break 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]) flag = 1 break elif int(S[j] + S[k]) % 8 == 0: print("YES") print(S[j] + S[k]) flag = 1 break elif int(S[i] + S[k]) % 8 == 0: print("YES") print(S[i] + S[k]) flag = 1 break if flag: break if flag: break if not flag: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER 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 NUMBER IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR VAR 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 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 ASSIGN VAR NUMBER 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 ASSIGN VAR 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 ASSIGN VAR 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 ASSIGN VAR NUMBER 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
s = input() n = len(s) g = 0 for i in range(n): if s[i] == "0" or s[i] == "8": print("YES") print(s[i]) g = 1 break for j in range(i + 1, n): if int(s[i] + s[j]) % 8 == 0: print("YES") print(s[i] + s[j]) g = 1 break 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]) g = 1 break if g: break if g: break if not g: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING 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 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 ASSIGN VAR NUMBER 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 ASSIGN VAR NUMBER 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
s = input() a = int(s) if a % 8 == 0: print("YES") print(a) else: n = len(s) if n == 1: if a % 8 == 0: print("YES") print(a) else: print("NO") elif n == 2: if "0" in s: print("YES") print(0) elif "8" in s: print("YES") print(8) else: print("NO") elif "0" in s: print("YES") print(0) elif "8" in s: print("YES") print(8) else: f = 0 for i in range(n - 2): for j in range(i + 1, n - 1): for k in range(j + 1, n): temp = int(s[i]) * 100 + int(s[j]) * 10 + int(s[k]) if temp % 8 == 0: f = 1 break if f == 1: break if f == 1: break if f == 1: print("YES") print(temp) else: for i in range(n - 1): for j in range(i + 1, n): temp = int(s[i]) * 10 + int(s[j]) if temp % 8 == 0: f = 1 break if f == 1: break if f == 1: print("YES") print(temp) else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING IF 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 EXPR 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 ASSIGN 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 BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR 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 BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF 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
d = input() n = len(d) if d.find("8") != -1: print("YES") print("8") elif d.find("0") != -1: print("YES") print("0") else: for i in range(n - 1): if d[i] != "0": for j in range(i + 1, n): t = d[i] + d[j] if int(t) % 8 == 0: print("YES") print(t) exit() for i in range(n - 2): if d[i] != "0": for j in range(i + 1, n - 1): for k in range(j + 1, n): t = d[i] + d[j] + d[k] if int(t) % 8 == 0: print("YES") print(t) exit() print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR 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 FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING 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 BIN_OP VAR NUMBER IF VAR VAR STRING 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 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
def solve(n): for q in (8 * i for i in range(125)): nums = list(str(q)) for c in reversed(n): if c == nums[-1]: nums.pop() if not nums: return q def main(): n = input() ans = solve(n) ans = "YES\n{}".format(ans) if ans is not None else "NO" print(ans) main()
FUNC_DEF FOR VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR IF VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NONE FUNC_CALL STRING 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
def solve(nstr): if "8" in nstr: print("YES") print("8") return elif "0" in nstr: print("YES") print("0") return ind2 = nstr.rfind("2") ind4 = nstr.rfind("4") ind6 = nstr.rfind("6") if ind2 > 0: for ch in ["1", "5", "9"]: if ch in nstr[1:ind2]: indch = nstr.rfind(ch, 1, ind2) for c in ["1", "3", "5", "7", "9"]: if c in nstr[0:indch]: print("YES") print(c + ch + "2") return for ch in ["3", "7"]: if ch in nstr[0:ind2]: print("YES") print(ch + "2") return if ind4 > 0: for ch in ["4"]: if ch in nstr[1:ind4]: indch = nstr.rfind(ch, 1, ind4) for c in ["1", "3", "5", "7", "9"]: if c in nstr[0:indch]: print("YES") print(c + ch + "4") return for ch in ["2", "6"]: if ch in nstr[0:ind4]: print("YES") print(ch + "4") return if ind6 > 0: for ch in ["1", "5", "9"]: if ch in nstr[0:ind6]: print("YES") print(ch + "6") return for ch in ["3", "7"]: if ch in nstr[1:ind6]: indch = nstr.rfind(ch, 1, ind6) for c in ["1", "3", "5", "7", "9"]: if c in nstr[0:indch]: print("YES") print(c + ch + "6") return print("NO") return inp = input() solve(inp)
FUNC_DEF IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING RETURN IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER FOR VAR LIST STRING STRING STRING IF VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR FOR VAR LIST STRING STRING STRING STRING STRING IF VAR VAR NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR STRING RETURN FOR VAR LIST STRING STRING IF VAR VAR NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR STRING RETURN IF VAR NUMBER FOR VAR LIST STRING IF VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR FOR VAR LIST STRING STRING STRING STRING STRING IF VAR VAR NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR STRING RETURN FOR VAR LIST STRING STRING IF VAR VAR NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR STRING RETURN IF VAR NUMBER FOR VAR LIST STRING STRING STRING IF VAR VAR NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR STRING RETURN FOR VAR LIST STRING STRING IF VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR FOR VAR LIST STRING STRING STRING STRING STRING IF VAR VAR NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR STRING RETURN EXPR FUNC_CALL VAR STRING RETURN 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
num = list(input()) if "8" in num: print("YES") print(8) elif "0" in num: print("YES") print(0) else: for a in range(len(num)): for b in range(a + 1, len(num)): if int(num[a] + num[b]) % 8 == 0: print("YES") print(num[a] + num[b]) exit() for a in range(len(num)): for b in range(a + 1, len(num)): for c in range(b + 1, len(num)): if int(num[a] + num[b] + num[c]) % 8 == 0: print("YES") print(num[a] + num[b] + num[c]) exit() print("NO")
ASSIGN VAR FUNC_CALL 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 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 BIN_OP VAR VAR VAR VAR 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() lgn = len(n) eights = [str(8 * x) for x in range(125)] def match(eight): j = 0 lge = len(eight) ok = 0 for i in range(lgn): if j < lge and eight[j] == n[i]: ok += 1 j += 1 if ok == lge: return 1 else: return 0 ok = 0 for i in range(125): if ok == 0 and match(eights[i]) == 1: ok = 1 print("YES") print(eights[i]) if ok == 0: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR 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
s = input() s = s[::-1] l = len(s) y = 0 for x in range(l): if s[x] == "0" or s[x] == "8": y = 1 print("YES") print(s[x]) elif x != l - 1: for i in range(x + 1, l): if int(s[i] + s[x]) % 8 == 0: print("YES") print(s[i] + s[x]) y = 1 elif i != l - 1: for j in range(x + 2, l): k = s[j] + s[i] + s[x] if int(k) % 8 == 0: print("YES") print(k) y = 1 break if y: break if y: break else: print("NO")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR IF 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 EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER 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 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
def success(n): print("YES") print(n) exit(0) def check_div(a, b, c): if a == 8 or b == 8 or c == 8: success(8) if (10 * a + b) % 8 == 0: success(10 * a + b) if (10 * a + c) % 8 == 0: success(10 * a + c) if (10 * b + c) % 8 == 0: success(10 * b + c) if (4 * a + 2 * b + c) % 8 == 0: success(100 * a + 10 * b + c) num = input() if num.count("0") > 0: success(0) if len(num) < 3: if int(num) % 8 == 0: success(num) if len(num) == 2: if num[0] == "8": success(8) if num[1] == "8": success(8) for a in range(len(num) - 2): for b in range(a + 1, len(num) - 1): for c in range(b + 1, len(num)): check_div(int(num[a]), int(num[b]), int(num[c])) print("NO")
FUNC_DEF EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR IF BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR IF BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR IF BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER STRING EXPR FUNC_CALL 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 EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR 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 n = str(input()) length = len(n) divis = False for i in itertools.combinations(n, 1): if int("".join(i)) % 8 == 0: print("YES") print("".join(i)) divis = True break if divis == False and length >= 2: for i in itertools.combinations(n, 2): if int("".join(i)) % 8 == 0: print("YES") print("".join(i)) divis = True break if divis == False and length >= 3: for i in itertools.combinations(n, 3): if int("".join(i)) % 8 == 0: print("YES") print("".join(i)) divis = True break if divis == False: print("NO")
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR 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 ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR 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 ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR 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 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 = list(input()) length = len(s) if s.count("0") > 0: print("YES", 0, sep="\n") elif s.count("8") > 0: print("YES", 8, sep="\n") elif length < 3: s = "".join(s) if int(s) % 8 == 0: print("YES", s, sep="\n") else: print("NO") else: for i in range(length - 2): for j in range(i + 1, length - 1): for k in range(j + 1, length): if int(s[i] + s[j] + s[k]) % 8 == 0: print("YES", s[i] + s[j] + s[k], sep="\n") exit() for l in range(length - 1): for p in range(l + 1, length): if int(s[l] + s[p]) % 8 == 0: print("YES", s[l] + s[p], sep="\n") exit() if l == length - 2 and p == length - 1: print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING NUMBER STRING IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING NUMBER STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING VAR STRING EXPR FUNC_CALL VAR STRING 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 IF BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR STRING EXPR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR STRING BIN_OP VAR VAR VAR VAR STRING EXPR FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER VAR BIN_OP 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() ans = 0 YES = "YES" NO = "NO" for i in range(0, len(n)): x = int(n[i]) if x % 8 == 0: ans = 1 print(YES) print(x) break if ans != 1: for i in range(len(n) - 1, -1, -1): if ans == 1: break if int(n[i]) % 2 == 0: for j in range(i - 1, -1, -1): if ans == 1: break m = int(n[i]) + 10 * int(n[j]) if m % 8 == 0: ans = 1 print(YES) print(m) break elif m % 4 == 0: if ans == 1: break for k in range(j - 1, -1, -1): l = 100 * int(n[k]) + m if l % 8 == 0: ans = 1 print(YES) print(l) break if ans != 1: print(NO)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER IF 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 VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER 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
t = input() if "0" in t: print("YES") print(0) elif len(t) == 1: if t == "8": print("YES") print(8) else: print("NO") elif len(t) == 2: if "8" in t: print("YES") print(8) elif int(t) % 8 == 0: print("YES") print(t) else: print("NO") elif "8" in t: print("YES") print(8) else: h = 0 for j in range(8, 10000000, 8): a = str(j) u = "" s = 0 for k in t: if s < len(a): if k == a[s]: u += k s += 1 if u == a: print("YES") print(a) h += 1 break if h == 0: print("NO")
ASSIGN VAR FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR 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 check(n): return n % 8 == 0 s = input() if "8" in s: print("YES") print("8") exit() if "0" in s: print("YES") print("0") exit() s = "00" + 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 check(int("{}{}{}".format(s[i], s[j], s[k]))): print("YES") print("{}{}{}".format(s[i], s[j], s[k]).lstrip("0")) exit() print("NO")
FUNC_DEF RETURN BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN 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 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 FUNC_CALL STRING VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL STRING VAR VAR VAR 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
n = list(input()) l = len(n) for i in range(l): n[i] = int(n[i]) flag = 0 for i in range(l): if n[i] == 8 or n[i] == 0: print("YES") print(n[i]) flag = 1 break if flag == 0: for i in range(l - 1): for j in range(i + 1, l): k = int(str(n[i]) + str(n[j])) if k % 8 == 0: print("YES") print(k) flag = 1 break if flag == 1: break if flag == 0: for i in range(l - 2): for j in range(i + 1, l - 1): for k in range(j + 1, l): ki = int(str(n[i]) + str(n[j]) + str(n[k])) if ki % 8 == 0: print("YES") print(ki) flag = 1 break if flag == 1: break if flag == 1: break if flag == 0: print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR 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 VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP 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 ASSIGN VAR NUMBER IF 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 FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR 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 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 check(a): if len(a) < 3: return int(a) % 8 == 0 code = lambda x: ord(x) - ord("0") val = 4 * code(a[-3]) + 2 * code(a[-2]) + code(a[-1]) return val % 8 == 0 def main(): s = input() m = len(s) r = "" if s.find("8") >= 0: print("YES\n8") return 0 if s.find("0") >= 0: print("YES\n0") return 0 if len(s) < 3: print("YES\n" + s if int(s) % 8 == 0 else "NO") return 0 for i in range(m): for j in range(i + 1, m): r = s[i] + s[j] if check(r): print("YES\n" + r) return 0 for i in range(m): for j in range(i + 1, m): for k in range(j + 1, m): r = s[i] + s[j] + s[k] if check(r): print("YES\n" + r) return 0 print("NO") main()
FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER RETURN BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING RETURN NUMBER IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING RETURN NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER BIN_OP STRING VAR STRING RETURN NUMBER 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 FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR RETURN 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 FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR RETURN 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 "8" in s: print("YES") print(8) elif "0" in s: print("YES") print(0) else: l = len(s) f = False for i in range(l - 1): if f: break for j in range(i + 1, l): if int(s[i] + s[j]) % 8 == 0: f = int(s[i] + s[j]) if f: break for k in range(j + 1, l): if int(s[i] + s[j] + s[k]) % 8 == 0: f = s[i] + s[j] + s[k] break if f: print("YES") print(f) else: print("NO")
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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF 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 FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF 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 BIN_OP BIN_OP VAR VAR VAR VAR VAR 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
s = "00" + input() ans = False num = 0 for k in range(len(s) - 2): for i in range(k + 1, len(s) - 1): for j in range(i + 1, len(s)): if int(s[k] + s[i] + s[j]) % 8 == 0: ans = True num = int(s[k] + s[i] + s[j]) if ans: print("YES") print(num) else: print("NO")
ASSIGN VAR BIN_OP STRING FUNC_CALL VAR 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 NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING