Problem:


Structured Programming

In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.

Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.

Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout n is given in a line.

Output

Print the output result of the above program for given integer n.

Constraints

3 ≤ n ≤ 10000

Sample Input

30

Sample Output

 3 6 9 12 13 15 18 21 23 24 27 30

  Put a single space character before each element.



Sample input:
30


Sample output:
 3 6 9 12 13 15 18 21 23 24 27 30

Submission status: WA: Presentation Error

Solution code:
# -*- coding: utf-8 -*-

n = int(input())
i = 1

while True:
    if i % 3 == 0 or i % 10 == 3:
        print(' {0}'.format(i), end='')

    i += 1
    if i > n:
        break

Submission status: WA: Presentation Error

Solution code:
# -*- coding: utf-8 -*-
from functools import reduce

n = int(input())
i = 1

while True:

    a = [int(x) for x in list(str(i))]

    if 3 in a:
        print(" {0}".format(int(reduce(lambda x, y: x + y, [str(x) for x in a]))), end='')
    elif sum(a) % 3 == 0:
        print(" {0}".format(int(reduce(lambda x, y: x + y, [str(x) for x in a]))), end='')

    i += 1
    if i > n:
        break

Submission status: WA: Presentation Error

Solution code:
num = int(input().rstrip())

for i in range(1,num+1):
    if i % 3 == 0 or '3' in str(i):
        print(i,end=" ")

Submission status: WA: Presentation Error

Solution code:
num = int(input().rstrip())
L =[]
for i in range(1,num+1):
    if i % 3 == 0 or '3' in str(i):
        L.append(i)
print(" ".join(map(str,L)))

Submission status: WA: Presentation Error

Solution code:
num = int(input())
L =[]
for i in range(1,num+1):
    if i % 3 == 0 or '3' in str(i):
        L.append(i)
print(" ".join(map(str,L)))

Submission status: WA: Presentation Error

Solution code:
def include3(n):
	cond = 0
	while True:
		if n%10==3:
			cond = 1
			return cond
		elif n>9:
			n /= 10
		else:
			return cond

n = int(input())
print(' ',end='')
for i in range(1,n+1):
	if i%3==0 or include3(i)==1:
		print(i,end='')
		print(' ',end='')

Submission status: WA: Presentation Error

Solution code:
def include3(n):
	cond = 0
	while True:
		if n%10==3:
			cond = 1
			return cond
		elif n>9:
			n /= 10
		else:
			return cond

n = int(input())
print(' ',end='')
for i in range(1,n+1):
	if i%3==0 or include3(i)==1:
		print(i,end='')
		print(' ',end='')
print()

Submission status: WA: Presentation Error

Solution code:
n = int(input())
i = 1

while i <= n:
	if i % 3 == 0 or "3" in str(i):
		print(" ",end='')
		print(i,end='')
	i += 1

Submission status: WA: Presentation Error

Solution code:
def check(num):
    n = str(num)
    for i in range(len(n)):
        if n[i] == '3': return True
    return False

n = int(input())
print('3', end = '')
for i in range(4, n + 1):
    if i % 3 == 0: print(' ' + str(i), end = '')
    elif check(i):
        print(' ' + str(i), end = '')

Submission status: WA: Presentation Error

Solution code:
def check(num):
    n = str(num)
    for i in range(len(n)):
        if n[i] == '3': return True
    return False

n = int(input())
print('3', end = '')
for i in range(4, n + 1):
    if i % 3 == 0: print(' ' + str(i), end = '')
    elif check(i):
        print(' ' + str(i), end = '')
print()

Submission status: WA: Presentation Error

Solution code:
n = int(input())
print(*[i for i in range(1,1+n) if i%3==0 or'3' in str(i)])

Submission status: WA: Presentation Error

Solution code:
a = int(input())
b = []
for i in range(1, a+1, 1):
    if "3" in str(i):
        b.append(i)
    elif i % 3 == 0:
        b.append(i)
    else:
        pass
print(" ".join(map(str, b)))

Submission status: WA: Presentation Error

Solution code:
a = int(input())
b = []
for i in range(1, a+1, 1):
    if "3" in str(i):
        b.append(i)
    elif i % 3 == 0:
        b.append(i)
    else:
        pass

for i in b:
    print(i, end="")
    print(" ", end="")

Submission status: WA: Presentation Error

Solution code:
a = int(input())
b = []
for i in range(1, a+1, 1):
    if "3" in str(i):
        b.append(i)
    elif i % 3 == 0:
        b.append(i)
    else:
        pass

for i in b:
    print(i, end="")
    print(" ", end="")
print()

Submission status: WA: Presentation Error

Solution code:
a = int(input())
b = []
for i in range(1, a+1, 1):
    if "3" in str(i):
        b.append(i)
    elif i % 3 == 0:
        b.append(i)
    else:
        pass
count = 0
for i in b:
    count += 1
    if len(b) == count:
        print(i)
        break
    print(i, end="")
    print(" ", end="")

Submission status: WA: Presentation Error

Solution code:
#! python3
# structured_programming.py

n = int(input())

for i in range(1, n+1):
    if i%3 == 0:
        print(' ' + str(i), end='')
    elif i%10 == 3:
        print(' ' + str(i), end='')

Submission status: WA: Presentation Error

Solution code:
#x = [int(i) for i in input().split()]
n = int(input())
for i in range(1, n+1):
    if i % 3 == 0:
        print(" ",i,sep="",end="")
    if i % 3 != 0 and i % 10 == 3:
        print(" ",i,sep="",end="")

Submission status: WA: Presentation Error

Solution code:
n=int(input())
for i in range(1,n+1):
    if i%3==0:
        print(' '+str(i),end='')
    elif i%10==3:
        print(' '+str(i),end='')

Submission status: WA: Presentation Error

Solution code:
n=int(input())
for i in range(3,n+1):
    if i%3==0:
        print(' '+str(i),end='')
    elif i%10==3:
        print(' '+str(i),end='')

Submission status: WA: Presentation Error

Solution code:
a = int(input())
def three(x):
	if x%3==0:
		return True
	if "3" in str(x):
		return True
	return False
line =[]
for i in range(3,a+1,1):
	if three(i):
		line.append(i)

for i in range(len(line)-1):
	print(line[i],end=" ")
print(line[len(line)-1])

Submission status: WA: Presentation Error

Solution code:
n = int(input())
for i in range(1, n + 1):
    if i % 3 == 0:
        print(" {}".format(i), end="")
        continue
    ii = i
    while(ii  > 1):
        if ii % 10 == 3:
            print(" {}".format(i), end="")
            break
        ii //= 10

Submission status: WA: Presentation Error

Solution code:
a = []
n = int(input())
for i in range(1, n+1):
    if i % 3 == 0:
        a.append(i)
    elif i % 10 == 3:
        a.append(i)
for j in range(len(a)):
    print(' '+ str(a[j]), end='')

Submission status: WA: Presentation Error

Solution code:
a = []
n = int(input())
for i in range(1, n+1):
    if i % 3 == 0:
        a.append(i)
    elif i % 10 == 3:
        a.append(i)
for j in range(len(a)):
    print('', a[j], end='')

Submission status: WA: Presentation Error

Solution code:
a = []
n = int(input())
for i in range(2, n+1):
    if i % 3 == 0:
        a.append(i)
    elif i % 10 == 3:
        a.append(i)
for j in range(len(a)):
    print('', a[j], end='')

Submission status: WA: Presentation Error

Solution code:
import sys
n = int(input())

for i in range(3, n + 1):
	if i % 3 == 0 or i % 10 == 3:
		sys.stdout.write(str(i))
		sys.stdout.write(' ')

print()

Submission status: WA: Presentation Error

Solution code:
import sys
n = int(input())

for i in range(3, n + 1):
	if i % 3 == 0 or i % 10 == 3:
		sys.stdout.write(str(i))
		if i < n + 1:
			sys.stdout.write(' ')

print()

Submission status: WA: Presentation Error

Solution code:
import sys
n = int(input())

for i in range(3, n + 1):
	if i % 3 == 0 or i % 10 == 3:
		sys.stdout.write(str(i))
		if i < n + 1:
			sys.stdout.write(' ')

Submission status: WA: Presentation Error

Solution code:
import sys
n = int(input())

for i in range(3, n + 1):
	if i % 3 == 0 or i % 10 == 3:
		sys.stdout.write(str(i))
		if i < n:
			sys.stdout.write(' ')

Submission status: WA: Presentation Error

Solution code:
import sys
n = int(input())

for i in range(3, n + 1):
	if i % 3 == 0 or i % 10 == 3:
		if i != 3: sys.stdout.write(' ')
		sys.stdout.write(str(i))

Submission status: WA: Presentation Error

Solution code:
import sys
n = int(input())

for i in range(3, n + 1):
	if i % 3 == 0 or i % 10 == 3:
		if i != 3: sys.stdout.write(' ')
		sys.stdout.write(str(i))
print()

Submission status: WA: Presentation Error

Solution code:
n = int(input())
for i in range(1 , n+1):
	if i > n:
		break
	if i % 3 == 0:
		print(" ", i, end="")
	else:
		if i % 10 ==3:
			print(" ", i, end="")

Submission status: WA: Presentation Error

Solution code:
n = int(input())
for i in range(1 , n+1):
	if i > n:
		break
	if i % 3 == 0:
		print(" ", i, end="")
	else:
		if i % 10 == 3:
			print(" ", i, end="")
print()

Submission status: WA: Presentation Error

Solution code:
n = int(input())
for i in range(1 , n+1):
	if i > n:
		break
	if i % 3 == 0:
		print(" {}".format(i), end="")
	else:
		if i % 10 == 3:
			print("  {}".format(i), end="")
print()

Submission status: WA: Presentation Error

Solution code:
n = int(input())
for i in range(1 , n+1):
	if i > n:
		break
	if i % 3 == 0:
		print(" {}".format(i), end="")
	else:
		if (i % 10 == 3):
			print(" {}".format(i), end="")

Submission status: WA: Presentation Error

Solution code:
n = int(input())
for i in range(1 , n+1):
	if i > n:
		break
	if i % 3 == 0:
		print(" {}".format(i), end="")
	else:
		if i % 10 == 3:
			print(" {}".format(i), end="")

Submission status: WA: Presentation Error

Solution code:
def main():
    x = int(input())
    output = []
    for i in range(1,x+1):
        if i % 3 == 0 or i % 10 == 3:
            output.append(str(i))
    print(" ".join(output))
    
if __name__ == '__main__':
    main()

Submission status: WA: Presentation Error

Solution code:
def main():
    x = int(input())
    output = []
    for i in range(1,x+1):
        if i % 3 == 0 or i % 10 == 3 or i // 10 == 3:
            output.append(str(i))
    print(" ".join(output))
    
if __name__ == '__main__':
    main()

Submission status: WA: Presentation Error

Solution code:
def main():
    x = int(input())
    output = []
    for i in range(1,x+1):
        if i % 3 == 0 or i % 10 == 3 or i // 10 == 3:
            print(i, end="")
    print()
    
if __name__ == '__main__':
    main()

Submission status: WA: Presentation Error

Solution code:
def main():
    x = int(input())
    output = []
    for i in range(1,x+1):
        if i % 3 == 0 or i % 10 == 3 or i // 10 == 3:
            print(i, end="")
    
if __name__ == '__main__':
    main()

Submission status: WA: Presentation Error

Solution code:
def main():
    x = int(input())
    output = []
    for i in range(1,x+1):
        if i % 3 == 0 or i % 10 == 3 or i // 10 == 3:
            print(i, end=" ")
    
if __name__ == '__main__':
    main()

Submission status: WA: Presentation Error

Solution code:
def main():
    x = int(input())
    output = []
    for i in range(1,x+1):
        if i % 3 == 0 or i % 10 == 3 or i // 10 == 3:
            print(i, end=" ")
    print()
    
if __name__ == '__main__':
    main()

Submission status: WA: Presentation Error

Solution code:
def main():
    x = int(input())
    output = []
    for i in range(1,x+1):
        if i == 3:
            print(i, end="")
        elif i % 3 == 0 or i % 10 == 3 or i // 10 == 3:
            print(" "+str(i), sep=' ', end="")
    print()

if __name__ == '__main__':
    main()

Submission status: WA: Presentation Error

Solution code:
from sys import stdin

n = int(stdin.readline())

for i in range(1,n+1):
    x = i
    if x % 3 == 0 or x % 10 == 3:
        print('', x, end='')
        continue

    x //= 10
    while x != 0:
        if x % 10 == 3:
            print('', x, end='')

        x //= 10

Submission status: WA: Presentation Error

Solution code:
from sys import stdin

n = int(stdin.readline())

for i in range(1,n+1):
    x = i
    if x % 3 == 0 or x % 10 == 3:
        print('', i, end='')
        continue

    x //= 10
    while x != 0:
        if x % 10 == 3:
            print('', i, end='')

        x //= 10