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 << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
} Input An integer 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.

Solution (Python):
n = int(input())
i = 1
while i <= n:
    
    if i % 3 == 0:
        print(f" {i}", end="")
    else:
        x = i
        
        while x != 0:
            if x % 10 == 3:
                print(f" {i}", end="")
                break
            x //= 10
    i += 1
print()

Solution (Python):
n = int(input())
for i in range(1, n+1):
    if i % 3 == 0 or '3' in str(i):
        print(f' {i}', end='')
print()

Solution (Python):
n = int(input())
l = [""]
i = 1
 
while i <= n:
    x = int(i)
    if x%3 == 0:
        l.append(str(i))
        i += 1
        continue
    while x != 0:
        if x%10 == 3:
            l.append(str(i))
            break
        else:
            x //= 10
    i += 1

print(" ".join(l))

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

Solution (Python):

N = int(input())
x = 0

for i in range(1,N+1):

    if i%3 == 0:
            print(" %d"%i,end = "");
    else:
        x = i
        while (x):
            if x%10 == 3:
                print(" %d"%i,end = "")
                break
            x //= 10
print()

Solution (Python):
N = int(input())
for i in range(1, N+1):
    if i%3 == 0 or "3" in str(i):
        print("", i, end = "")
print()

Solution (Python):
N = int(input())
x = 0

for i in range(1,N+1):

    if i%3 == 0:
            print(" %d"%i,end = "");
    else:
        x = i
        while (x):
            if x%10 == 3:
                print(" %d"%i,end = "")
                break
            x //= 10
print()

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

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

while i < n:
    i += 1
    if i % 3 == 0:
        print(" {}".format(i), end="")
    elif "3" in str(i):
        print(" {}".format(i), end="")
print()

Solution (Python):
N=int(input())
for i in range(1,N+1):
    if i%3==0 or "3" in str(i):
        print(" {}".format(i),end="")
print()

Solution (Python):
BIG_NUM = 2000000000


N = int(input())
x = 0

for i in range(1,N+1):

    if i%3 == 0:
            print(" %d"%i,end = "");
    else:
        x = i
        while (x):
            if x%10 == 3:
                print(" %d"%i,end = "")
                break
            x //= 10
print()

Solution (Python):
n=int(input())
a=[]
for i in range(1,n+1):
    if (i%3==0):
        a.append(i)
        continue
    x=i
    while x>0:
        if (x%10==3):
            a.append(i)
            break
        x=x//10
result=" ".join([str(n) for n in a])
print("",result)

Solution (Python):
n = int(input())
l = [""]
for i in range(1, n + 1):
    if i % 3 == 0:
        l.append(i)
    elif "3" in list(str(i)):
        l.append(i)
print(*l)

Solution (Python):
n = int(input())

lis = ['']
for i in range(1, n+1):
    if i%3==0 or '3' in list(str(i)):
        lis.append(i)
        
print(*lis)

Solution (Python):
n = int(input())
for i in range(1, n + 1):
  if i % 3 == 0:
    print(f" {i}", end = "")
  else:
    x = i
    while x:
      if x % 10 == 3:
        print(f" {i}", end = "")
        break
      x //= 10
print()

Solution (Python):
n = int(input())

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

Solution (Python):
x = int(input())
for i in range(1, x+1):
    j = i
    if j % 3 == 0:
        print(f" {i}", end = "")
        continue
    while j > 1:
        if j % 10 == 3:
            print(f" {i}", end = "")
            break
        j = j // 10
print()

Solution (Python):
def call(n):
    i = 1
    while True:
        x = i
        if x%3 == 0:
            print(f' {i}', end = '')
        else:
            while True:
                if x%10 == 3:
                    print(f' {i}', end = '')
                    break
                x //= 10
                if x == 0:
                    break
        i = i + 1
        if i > n:
            break
    print()

call(int(input()))

Solution (Python):
n = int(input())
ans = []
for i in range(1,n+1):
    if i%3 == 0 or "3" in str(i):
        ans.append(i)
print("",*ans)

Solution (Python):
n = int(input())
for i in range(1, n+1):
    if i % 3 == 0:
        print(f" {i}", end="")
    else:
        x = i
        while x:
            if x % 10 == 3:
                print(f" {i}", end="")
                break
            x = x // 10
print()

Solution (Python):
n = int(input())
r = ''
for i in range(1, n+1):
	if i % 3 == 0:
		r = r + ' ' + str(i)
		continue
	x = i
	while x != 0:
		if x % 10 == 3:
			r = r + ' ' + str(i)
			break
		x = x // 10
print(r)

Solution (Python):
n = int(input())

ans = []
while True:
    if n % 3 == 0:
        ans.append(n)
    elif str(n).find('3') != -1:
        ans.append(n)
    n -= 1
    if n < 3:
        break

print('',*ans[::-1])

Solution (Python):
n = int(input())
ans = ''
i = 1
while i <= n:
    x = i
    if (x % 3) == 0:
        ans += ' ' + str(i)
        i += 1
    elif (x % 10) == 3:
        ans += ' ' + str(i)
        i += 1
    else:
        while True:
            x = (x // 10)
            if x == 0:
                i += 1
                break
            elif (x % 10) == 3:
                ans += ' ' + str(i)
                i += 1
                break
print(ans)

Solution (Python):
a = int(input())

num =[]

for i in range(1, a + 1):
    if i % 3 == 0:
        num.append(i)
        
    x = str(i)
    x = list(x)

    if ("3" in x) and (i not in num):
        num.append(i)

for i in num:    
    print(f" {i}", end = "")
    
print("")

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

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

Solution (Python):
s = int(input())
for i in range(1, s+1):
    if i%3 == 0 or "3" in str(i):print(f" {i}",end="")
print()

Solution (Python):
n = int(input())

i = 1

while i <= n:
    x = i
    if x%3 == 0:
        print(" "+ str(i), end="")
        i += 1
        continue
    while x:
        if x%10 == 3:
            print(" "+ str(i), end="")
            break
        x //= 10
    
    i += 1
print()

Solution (Python):
n = int(input())
x = 0

for i in range(1, n+1):
    if   i % 3  == 0:
        print("", i,end="")
    else:
        x = i
        while (x):
            if x % 10 == 3:
                print("", i,end="")
                break
            x //= 10
print()

Solution (Python):
n = int(input())

out = ""

for i in range(1, n+1):
    x = i
    if i%3 == 0:
        out += " " + str(x)
        continue
    while True:
        if i%10 == 3:
            out += " " + str(x)
            break
        i //= 10 
        if i == 0:
            break

print(out)

Solution (Python):
a = [i for i in range(3, int(input()) + 1) if i%3 == 0 or '3' in str(i)]
print(' ' + ' '.join(map(str, a)))

Solution (Python):
n = int(input())
table = []

for i in range(1,n+1):
    if i % 3 == 0:
        table.append(i)
    else:
        tmp = i
        while tmp != 0:
            if tmp % 10 == 3:
                table.append(i)
                break
            else:
                tmp //= 10

print(' ', end="")
print(' '.join(map(str, table)))

Solution (Python):

n = int(input())
for i in range(1,n+1):
    if i%3==0:
        print(" %d"%(i),end='')
    elif str(i).count('3'):
        print(" %d"%(i),end='')
print ()

Solution (Python):
n = int(input())

int_list = []
for i in range(1, n+1):
    x = i
    if x % 3 == 0:
        int_list.append(i)
    else:
        while x != 0:
            if x % 10 == 3:
                int_list.append(i)
                break
            x //= 10

print(' '+' '.join(list(map(str, int_list))))

Solution (Python):
import math
import copy
from copy import deepcopy
import sys
import fractions

from functools import reduce

import decimal
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)






def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList




def checker(n):
    n = str(n)
    n_list = list(n)
    for i in n_list:
        if i == "3":
            return True

n = int(input())
ans =[]
for i in range(1, n+1, 1):
    if i%3==0 or checker(i):
        ans.append(i)

print("", *ans, sep=" ")

Solution (Python):
n = int(input())
for i in range(1,n+1):
    if i % 3 == 0 or str(i).find("3") != -1:
        print (" {}".format(i), end='')
print()

Solution (Python):
num = int(input())
lst = []
ans = " "
for i in range(1, num+1):
  if i % 3 == 0:
    lst.append(i)
  else:
    nume = []
    k = i
    while k > 0:
      if k % 10 == 3:
        lst.append(i)
        break;
      else:
        k //= 10 
length = len(lst)
for j in range(length-1):
  ans += str(lst[j]) + " "
ans += str(lst[length-1])
print(ans)

Solution (Python):
n = int(input())
for i in range(1,n+1):
    if i % 3 == 0:
        print(" {0}".format(i), end="")
    else:
        x = i
        while x != 0:
            if x % 10 == 3:
                print(" {0}".format(i), end="")
                break;
            x //= 10;
print("")

Solution (Python):
N = int(input())
x = 0

for i in range(1,N+1):

    if i%3 == 0:
            print(" %d"%i,end = "");
    else:
        x = i
        while (x):
            if x%10 == 3:
                print(" %d"%i,end = "")
                break
            x //= 10
print()

Solution (Python):
n = int(input())

for i in range(1,n+1):
    
    if i % 3 == 0:
        print(" {}".format(i), end="")
        continue
    
    if "3" in list(str(i)):
        print(" {}".format(i), end="")

print()

Solution (Python):

num = int(input())
for i in range(1,num+1):
    if i % 3 == 0 or  "3" in str(i):
        print(f" {i}",end="")
print()

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



while True:
    x = i
    if (x%3) == 0:
        print(" ",end="")
        print(i,end="")
    else:
        while True:
            
            if int(x%10) == 3:
                print(" ",end="")
                print(i,end="")
                break 
            x = x/ 10
            if x < 1:
                break
             
    
    i+=1
    if i > n:
        break
            
        
print("")

Solution (Python):
num = int(input())

for i in range(1, num + 1):
    if i % 3 == 0 or i % 10 == 3 or '3' in str(i):
        print(' {}'.format(i), end='')
print()

Solution (Python):
n = int(input())
def divn(x, i, d, m):
    if x % d == m:
        print("", i, end="")
        return True
    return False

def call(i):
    x = i
    if divn(x, i, 3, 0):return
    if divn(x, i, 10, 3):return
    tmp = 1
    while tmp:
        x = x // 10
        tmp = x
        if not tmp:return
        if divn(x, i, 10, 3):return
    return

for i in range(n):
    call(i+1)
print("")

Solution (Python):
N = int(input())
x = 0

for i in range(1,N+1):

    if i%3 == 0:
            print("",i,end = "")
    else:
        x = i
        while (x):
            if x%10 == 3:
                print( "",i,end = "")
                break
            x //= 10
print()

Solution (Python):
N= int(input())
x = 0

for i in range(1, N+1):
    if i%3 == 0:
        print("% d"%i, end="")
    else:
        x = i
        while x:
            if x%10 == 3:
                print("% d" % i, end="")
                break
            x //= 10
print()

Solution (Python):
num=int(input())

for i in range(1,num+1):
    if i%3==0:
        print(' %d'%i,end='');
    else:
        x=i
        while (x):
            if x%10==3:
                print(' %d'%i,end='')
                break
            x//=10
print()

Solution (Python):
n = int(input())
for i in range(1, n+1):
    if i%3 == 0 or '3' in str(i):
        print(f" {i}", end='')

print()

Solution (Python):
n = int(input())

for i in range(1, n+1):
    if i%3 == 0:
        print(" %d"%(i), end = "")
        continue
    elif i%10 == 3:
        print(" %d" % (i), end="")
        continue
    else:
        x = i
        while x > 0:
            x //= 10
            if x%10 == 3:
                print(" %d"%(i), end="")
                break

print()

Solution (Python):
n = int(input())

for i in range(3, n + 1):
    if i % 3 == 0:
        print(" {}".format(i), end="")
    else:
        x = i
        while x != 0:
            if x % 10 == 3:
                print(" {}".format(i), end="")
                break
            else:
                x = x // 10
print()

Solution (Python):
n = int(input())
ans = ' '
for i in range(1, n+1):
    x = i
    if x%3 == 0:
        ans += str(i) + ' '
    elif "3" in str(x):
        ans += str(i) + ' '
print(ans[0:-1])

Solution (Python):
x=int(input())
n=[]
for i in range(3,x+1):
	if i%3==0:
		n.append(i)
	elif '3' in str(i):
		n.append(i)
c=0
for j in n:
	n[c]=str(j)
	c+=1
print(' '+' '.join(n))

Solution (Python):
n=int(input())
x=0
for i in range(1,n+1):
    if i%3 == 0:
        print(' %d'%i,end='')
    else:
        x=i
        while(x):
            if x%10 == 3:
                print(' %d'%i,end='')
                break
            x//=10
print()

Solution (Python):
n = int(input())
for i in  range(1, n + 1):
    x = i
    if x % 3 == 0:
        print(" " + str(i), end = "")
    else:
        while True:
            if x % 10 == 3:
                print(" " + str(i), end = "")
                break
            x //= 10
            if x <= 0:
                break
print()

Solution (Python):


n = int(input())

i = 1
while i<=n:
    x = i
    if x%3==0:
        print(" %d"%(i), end="")
        i = i + 1
        continue
    while True:
        if x%10==3:
            print(" %d"%(i), end="")
            break
        x = x // 10
        if x==0:
            break
    i = i + 1
print()

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

while i <= n:
    x = i
    if x % 3 == 0:
        print("", i, end = "")
    else:
        while x % 10 != 3:
            if x == 0:
                break
            else:
                x //= 10
        else:
            print("", i, end = "")
    i += 1

print()

Solution (Python):
n = int(input())
ans = ""
for i in range(1, (n+1)):
  if i % 3 == 0:
    ans += " " + str(i)
  elif i % 10 == 3 or "3" in str(i // 10):
    ans += " " + str(i)
print(ans)

Solution (Python):
input_value = input()

n = int(input_value)

numbers = range(1, n + 1)

multiples_of_three = [i for i in numbers if i % 3 == 0]

numbers_with_three = [i for i in numbers if '3' in str(i)]

related_three = multiples_of_three + numbers_with_three

related_three.sort()

sorted_related_three = sorted(set(related_three), key=related_three.index)

multiples_and_with_three_strings = list(map(str, sorted_related_three))

print(' ' + ' '.join(multiples_and_with_three_strings))

Solution (Python):
x=[]
for i in range (1,int(input())+1):
  if i%3==0:
    x.append(str(i))
  elif i%10==3:
    x.append(str(i))
  elif 30<=i%100<40:
    x.append(str(i))
  elif 300<=i%1000<400:
    x.append(str(i))
  elif 3000<=i%10000<4000:
    x.append(str(i))
print(""," ".join(list(map(str,x))))

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

Solution (Python):
n = int(input())

ans = []
i = 1

while True:
    """CHECK_NUM"""
    x = i
    if x % 3 == 0:
        ans.append(str(i))
    else:
        while True:
            """INCLUDE3"""
            if x % 10 == 3:
                ans.append(str(i))
                break

            x = int(x / 10)
            
            if x != 0: 
                continue
            else: 
                break
    i += 1
    if i <= n:
        continue
    else:
        break

print(" " + " ".join(ans))

Solution (Python):
n = int(input())
s = ""
for i in range(n):
    i += 1
    if i % 3 == 0:
        s += " " + str(i)
    else:
        x = i
        while True:
            if x % 10 == 3:
                s += " " + str(i)
                break
            elif x == 0:
                break
            x //= 10
print(s)

Solution (Python):
n = int(input())
i = 1
k = ""
while i <= n:
    if i%3 == 0:
        print(k, end=" ")
        k = i
    else:
        m = i
        while m//10 > 0:
            if m%10 == 3 or m//10 == 3:
                print(k, end=" ")
                k = i
                m = 0
            else:
                m = m//10
    i += 1
    
print(k)

Solution (Python):
n = int(input())
for i in range(1, n + 1):
    if i % 3 == 0:
        print(" {}".format(i), end="")
    elif "3" in str(i):
        print(" {}".format(i), end="")
print()

Solution (Python):
n = int(input())
x = 0

for i in range(1,n+1):

    if i%3 == 0:
            print(" %d"%i,end = "")

    else:
        x = i
        while (x):
          if x%10 == 3:
              print(" %d"%i,end = "")
              break
          x //= 10

print()

Solution (Python):
n = int(input())

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


    elif "3" in str(i+1):
        print(" " + str(i+1),end='')
        
print()

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

print(" "+" ".join(ans))

Solution (Python):
def call(n):
    for i in range(1, n + 1):
        x = i
        if x % 3 == 0:
            print(" %d" % (i), end="")
            continue
        while x:
            if x % 10 == 3:
                print(" %d" % (i), end="")
                break
            x //= 10
    print()


n = int(input())
call(n)

Solution (Python):
n = int(input())
print("", end="")
for i in range(1, n+1):
    x = i
    if x % 3 == 0:
        print("", i, end="")
        continue
    while x > 1:
        if x % 10 == 3:
            print("", i, end="")
            break
        x //= 10
print()

Solution (Python):
def inc3(i):
    if i - (i // 10)*10 == 3:
        return(True)
    elif i//10==0:
        return(False)
    else:    
        return(inc3(i//10))

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

Solution (Python):
def main():
  n = int(input())
  for i in range(3, n + 1):
      if i % 3 == 0 or '3' in str(i):
          print('', i, end='')
  print()
  
if __name__ == "__main__":
  main()

Solution (Python):
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 = '')
    else:
        x = i
        while x != 0:
            x = x // 10
            if x % 10 == 3:
                print(' '+str(i), end = '')
                break
print('')

Solution (Python):
N = int(input())
x = 0

for i in range(1,N+1):

    if i%3 == 0:
            print(" %d"%i,end = "");
    else:
        x = i
        while (x):
            if x%10 == 3:
                print(" %d"%i,end = "")
                break
            x //= 10
print()

Solution (Python):
n = int(input())
ans_list = list()

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

print('', ' '.join(ans_list))

Solution (Python):
n = int(input())

for i in range(1, n + 1):
    x = i
    if(x % 3 == 0):
        print(' {}'.format(i), end = '')
        continue
    while x:
        if x % 10 == 3:
            print(' {}'.format(i), end = '')
            x = 0
            break
        x //= 10
print('')

Solution (Python):
n = int(input())

for i in range(1, n + 1):
    if i % 3 == 0:
        print(" {}".format(i), end="")
    else:
        x = i
        while x:
            if x % 10 == 3:
                print(" {}".format(i), end="")
                break
            x //= 10
print()

Solution (Python):
n = int(input())
for i in range(1,n+1):
  if i%3==0 or "3" in str(i):
    print(" {}".format(i), end="")
print()

Solution (Python):
n = int(input())
for i in range(1, n+1):
    if i % 3 == 0 or str(i).find("3") != -1:
        print(" {}".format(i), end='')
print()

Solution (Python):
n = int(input())
for i in range(1, n + 1):
    if i % 3 == 0:
        print(" {}".format(i), end="")
    elif "3" in str(i):
        print(" {}".format(i), end="")
print("")

Solution (Python):
a = int(input())
for i in range(1,a+1):
    if i%3 ==0 or "3" in str(i):print(f" {i}",end="")
print()

Solution (Python):

import sys

n= int(input())




hoge=""
for i in range(1,n+1):
    if(i%3==0):
        hoge+=" "+str(i)
    else:
        x=i
        while(x>=1):
            if(x%10==3):
                hoge+=" "+str(i)
                break;
            x=x//10
print(hoge)

Solution (Python):
n = int(input())
for i in range(1, n + 1):
	if i % 3 == 0 or str(i).find("3") != -1:
		print(" {}".format(i), end = '')
print()

Solution (Python):
n = int(input())
x = 0
for i in range(1, n+1):
    if(i%3 == 0):
        print(" %d" %i, end = "")
    else:
        x = i
        while(x):
            if x % 10 == 3:
                print(" %d" %i, end = "")
                break
            x //= 10
print()

Solution (Python):
n= int(input())
Alist = []
for i in range(1,n+1):
  if i%3==0:
    Alist.append(i)
  else:
    if '3' in str(i):
      Alist.append(i)
print(" ",end="")
print(*Alist)

Solution (Python):
n = int(input())
ans = []
for i in range(1,n+1):
    if i % 3 == 0 or i % 10 == 3:
        ans.append(i)
    else:
        tmp =  i // 10
        while True:
            if tmp == 0:
                break
            if tmp % 10 == 3:
                ans.append(i)
                break
            tmp //= 10


print(' ',end='')
print(*ans)

Solution (Python):
import math
n = int(input())
i = x = 1
ans = ""
inc = True
while True:
    if (x % 3) == 0 and inc:
        ans = " " + str(i)
        print(ans, end='')
    elif (x % 10) == 3:
        ans = " " + str(i)
        print(ans, end='')
    else:
        x //= 10
        if x != 0:
            inc = False
            continue
    i += 1
    if i <= n:
        x = i
        inc = True
        continue
    break
print()

Solution (Python):
n = int(input())

for i in range(1, n+1):
    if i % 3 == 0:
        print(' ' + str(i), end='')
    else:
        x = i
        while x:
          if x % 10 == 3:
            print(" {}".format(i), end = "")
            break
          x //= 10
print()

Solution (Python):
def main():
    num = int(input())
    
    origin2(num)

def origin2(n):
    i = 1
    while i <= n:
        x = i
        if x % 3 == 0:
            print(' %d' % i, end='')
            i += 1
            continue
        else:
            while x != 0:
                if x % 10 == 3:
                    print(' %d' % i, end='')
                    break
                else:
                    x //= 10
            
        i += 1
    

if __name__ == '__main__':
    main()
    print()

Solution (Python):
def call(n:int):
    out_c = ''
    for i in range(1,n+1):
        if (i%3 == 0):
            out_c = '{} {}'.format(out_c,i)
        else:
            x = i
            while(x>0):
                if (x%10 == 3):
                    out_c = '{} {}'.format(out_c,i)
                    break
                x = int(x/10)
    else:
        print(out_c)

s = input()
call(int(s))

Solution (Python):
n = int(input())
for i in range(1,n+1):
         j = list(str(i))
         if i % 3 == 0:
                  print(" "+str(i),end="")
         elif "3" in j:
                  print(" "+str(i),end="")
print()

Solution (Python):
n = int(input())
for i in range(1, n+1):
    if i%3 == 0:
        print(" " + str(i), end='')
    elif str(i).count('3') > 0:
        print(" " + str(i), end='')
print("")

Solution (Python):
n = int(input())
lst = []
for i in range(1, n + 1):
    if i % 3 == 0:
        lst.append(i)
    if '3' in str(i):
        lst.append(i)

lst = set(lst)
lst = [str(i) for i in lst]
print(' ' + ' '.join(lst))

Solution (Python):
num = int(input())
x = 0
for i in range(1,num+1):
    if i % 3 == 0:
        print(end=" ")
        print(i, end="")
    elif "3" in str(i):
        print(end=" ")
        print(i, end="")
print()

Solution (Python):
n = int(input())
x = n//10
for i in range(1, n+1, 1):
    
    if i % 3 == 0 or '3' in str(i):
        print(" {0}".format(i), end='')
print()

Solution (Python):
n = int(input())
A = []
for i in range(1,n+1):
    fixi = i
    if i % 3 == 0:
        A.append(i)
    else:
        for j in range(1, len(str(fixi)) + 1):
            if i % 10 == 3:
                A.append(fixi)
                break
            else:
                i = int(i / 10)

print("", *A)

Solution (Python):
n = int(input())
list = []
for i in range(3, n + 1):
    if i % 3 == 0:
        list.append(i)
    else:
        x = i
        while x:
            if x % 10 == 3:
                list.append(i)
                break
            else:
                x = x // 10
print("", *list)

Solution (Python):
n = int(input())
for i in range (1,n + 1):
    if i % 3 == 0:
        print(" " + str(i),end = "")
    else:
        i = str(i)
        l = len(i)
        for j in range (l):
            if int(i[j]) == 3:
                print(" " + i,end = "" )
                break
print()

Solution (Python):
n = int(input())
m = []
for i in range(n+1):
    if i != 0:
        if i % 3 == 0 or str(i).find("3") != -1:
            m.append(str(i))
print(' '+' '.join(map(str, m)))

Solution (Python):
import sys
input = sys.stdin.readline
n = int(input())
i = 1
while i <= n:
  if not i % 3 or '3' in str(i):
    print(' {}'.format(i), end='')
  i += 1
print()

Solution (Python):
def call(n: int) -> list:
    ret = []
    for i in range(1, n+1):
        if i%3 == 0:
            ret.append(i)
            continue

        x = i
        while x:
            if x%10 == 3:
                ret.append(i)
                break

            x //= 10

    return ret

n = int(input())
print(" ", end="")
print(*call(n))

Solution (Python):
n = int(input())
num = []
for i in range(1, n+1):
    if i % 3 == 0:
        num.append(str(i))
    elif list(str(i)).count('3') > 0:
        num.append(str(i))

ans = ' '.join(num)
print(' {}'.format(ans))

Solution (Python):
n = int(input())
ans = ""
for i in range(1, n + 1) :
    if i % 3 == 0 or "3" in str(i) :
        ans += " " + str(i)

print(ans)

Solution (Python):
x = int(input())
for i in range(x):
    if((i+1)%3 ==0):
        print(" ",end="")
        print(i+1, end="")
        continue
    q = i+1
    while(q != 0):
        if(q%10==3):
            print(" ", end="")
            print(i + 1, end="")
            break
        q=q//10
print()

Solution (Python):
a=int(input())
for i in range(a+1):
    if (i%3==0 or "3" in str(i)) and i!=0:
        print(" %d" %(i), end="")
print("")

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

while i<=n:
    x = i
    if  x % 3 == 0:
        print(" ", end="")
        print(i, end="")
    else:
        while x:
            if  x % 10 == 3 :
                print(" ", end="")
                print(i, end="")
                break
            x = x//10
    i+=1
print()

Solution (Python):
n=int(input())
i=1
while i<=n:
    if i%3==0:
        print(" " + str(i),end='')
    else:
        x=i
        while x>0:
            if x%10==3:
                print(" " + str(i),end='')
                break
            x//=10
    i+=1
print()

Solution (Python):
n = int(input())

def aaa(a, b):
    if a % 10 == 3:
        print(f' {b}', end='')
    
    elif (a // 10 > 0):
        aaa(a // 10, b)

for i in range(1, n + 1):
    if i % 3 == 0:
        print(f' {i}', end='')
    
    else:
        aaa(i, i)
        
print()

Solution (Python):
n = int(input())
for i in range(1, n + 1):
	if i % 3 == 0 or str(i).find("3") != -1:
		print(" {}".format(i), end = '')
print()

Solution (Python):
N = int(input())
for i in range(1,N+1):
    if i%3 == 0 or str(i).find("3") != -1:
        print(' {}'.format(i), end='')
print()

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

Solution (Python):
def main():
    call(int(input()))


def call(n):
    i = 1
    while True:
        x = i
        
        if int(x % 3) == 0:
            print(" {}".format(i), end="")
        else:
            
            while True:
                if (x % 10) == 3:
                    print(" {}".format(i), end="")
                    break
                else:
                    x = int(x / 10)
                    if not(x):
                        break
        
        i += 1
        if n < i:
            break

    print("")

main()

Solution (Python):
x = int(input())
for i in range(1, x):
    if (i+1)%3==0 or "3" in str(i+1):
        print(" "+str(i+1), end="")
print()

Solution (Python):
n=int(input())
for i in range(1,n+1):
    flag=0
    j=i
    while j>=1:
        j,a=divmod(j,10)
        if a==3:
            flag=1
            break
    if i%3==0 or flag==1:
        print(" %d"%i,end="")
print("")

Solution (Python):
n = int(input())
for i in range(1, n + 1):
	if i % 3 == 0 or str(i).find("3") != -1:
		print(" %d"%i, end = '')
print()

Solution (Python):
x = int(input())
for n in range(3,x+1):
    if n % 3 == 0 or str(3) in str(n):
        print(f' {n}',end ='')
print()

Solution (Python):
n = int(input())
op = ""
for i in range(1,n+1):
	if (i % 3 == 0):
		op += " " + str(i)
	else:
		x = i
		while True:
			if (x % 10 == 3):
				op += " " + str(i)
				break
			x = int(x / 10)
			if x < 1:
				break
print(op)

Solution (Python):
count = int(input())
result = ""

for i in range(1, count + 1):
    if i % 3 == 0 or ("3" in str(i)) == True:
        result += f" {i}"

print(result)

Solution (Python):
n = int(input())

for i in range(3, n+1):
    x = i
    if x % 3 == 0:
        print(' {0}' .format(i), end='')
    else:
        while x :
            if x % 10 == 3:
                print(' {0}' .format(i), end='')
                break
            x //= 10
print()