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())
a = []
for i in range(1, n+1):
    if i % 3 == 0 or '3' in str(i):
        a.append(str(i))
print(' '+' '.join(a))

Solution (Python):






def check_num(n):
    
    return 1 if (n%10 == 3 or n%3 ==0) else 0

def include_3(n):
    
    return 1 if (n%10 == 3 ) else 0

str_n = input()
int_n = int(str_n)

for i in range(1,int_n+1):
    
    if check_num(i):
        print('',i, end="")
        continue
    else: 
        x = i
        while True:
            x = x//10
            if x == 0:
                break
            if include_3(x):
                print('',i, end="")
                break

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):
def call(n):
    for i in range(1,n+1):
        
        if i % 3 == 0:
            print(f' {i}',end='')
        else:
            
            tmp = i
            while tmp > 0:
                if tmp % 10 == 3:
                    print(f' {i}',end='')
                    break
                tmp //= 10
    
    print()


call(int(input()))

Solution (Python):
import sys
import itertools
import math



read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
lis=[]
for i in range(1,N+1):
    if i%3==0:
        lis.append(i)
    else:
        S=str(i)
        if '3' in S:
            lis.append(i)

ans=' '.join([str(i) for i in lis])
print(' '+ans)

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(f" {i}",end="")
 else:
  while x>0:
   if x%10==3:
    print(f" {i}",end="")
    break
   else:
    x = x//10
print()

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

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
            else:
                pass
            
            x = x // 10

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 = input()
inl = 3
while int(n) > int(inl) or int(n) == int(inl):
    if int(inl) % 3 == 0:
        print(' ' + str(inl),end='')
        inl += 1
    elif int(int(inl) / 10) == 3:
        print(' ' + str(inl),end='')
        inl += 1
    elif int(inl) % 10 == 3:
        print(' ' + str(inl),end='')
        inl += 1
    elif int((int(inl) / 10) % 10) == 3:
        print(' ' + str(inl),end='')
        inl += 1
    elif int((int(inl) / 100) % 10) == 3:
        print(' ' + str(inl),end='')
        inl += 1
    elif int((int(inl) / 1000) % 10) == 3:
        print(' ' + str(inl),end='')
        inl += 1
    else:
        inl += 1
print('')

Solution (Python):

def findthree(a):
    a = str(a)
    l = len(a)
    for i in range(l):
        if a[i]=="3":
            return True

a = int(input())
res = ""
for i in range(a):
    j = i + 1    
    if j%3==0 or findthree(j):
        res += " " + str(j)
print(res)

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(f" {i}", end="")

    else:
        num = i
        while num != 0:
            if num % 10 == 3:
                print(f" {i}", end="")
                break
            else:
                num /= 10
                num = int(num)
print()

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

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


if __name__ == '__main__':
    main()

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):
n=int(input())
L=""
for i in range(1,n+1):
    if i%3==0 or '3' in str(i):
        L +=' '+str(i)
print(L)

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

Solution (Python):

def call(n):
    result = ''
    for i in range(1, n + 1):
        x = i
        if x % 3 == 0:
            result += ' ' + str(i)
        else:
            while True:
                if int(x % 10) == 3:
                    result += ' ' + str(i)
                    break
    
                if int(x / 10) > 0:
                    x = int(x / 10)
                else:
                    break
    print(result)

call(int(input()))

Solution (Python):
n = int(input())
for i in range(3,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="")
        continue

    x = i
    while x > 0:
        if x % 10 == 3:
            print(" {}".format(i), end="")
            break
        else:
            x //= 10
print()

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

Solution (Python):
def call(n):
    i = 1
    
    while( i <= n ):
        x = i

        if( x % 3 == 0):
            print(" " + str(i), end = "")
            i = i + 1
            continue

        while True:

            if( x % 10 == 3):
                print(" " + str(i) , end = "")
                break
            x = int(x / 10)

            if x == 0 :
                break

        i = i + 1

    print("\n", end = "")

if __name__ == "__main__":

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

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

Solution (Python):
n=int(input())
for i in range(1,n+1):
    x=i
    if x%3==0:
        print(' {}'.format(i),end='')
    else:
        include3=False
        while x:
            if x%10==3:
                include3=True
            x//=10
        if include3:
            print(' {}'.format(i),end='')
print()

Solution (Python):
n = int(input())
for i in range(3, n+1):
    if i%3==0 or str(i).find('3')!=-1:
        print(' {0}'.format(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 > 0):
            if(x%10==3):
                print(" ",end="")
                print(i,end="")
                break
            x//=10

    i+=1
print()

Solution (Python):
import sys

n = int(input())

for i in range (1, n+1):
    if i % 3 == 0:
        print(" ", i, sep="", end="")
    else:
        x = i
        while x > 0:
            if x % 10 == 3:
                print(" ", i, sep="", 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 or '3' in str(i):
        print('',i,end='')
print()

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

Solution (Python):
n = int(input())
ans = ''
for i in range(1, n+1):
    if i % 3 == 0:
        ans += f' {i}'
    elif str(i).count('3') != 0:
        ans += f' {i}'
print(ans)

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

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

Solution (Python):
import sys

n = int(sys.stdin.readline())

for i in range(1, n+1):
    if i % 3 == 0:
        print(' ', i, sep='', end='')
    else:
        x = i
        while x > 0:
            if x % 10 == 3:
                print(' ', i, sep='', 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):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    
    n=int(input())
    ans=[]
    for x in range(1,n+1):
        if x%3==0 or str(x).count("3")>0:
            ans.append(x)
    print("",*ans)
main()

Solution (Python):
n = int(input())
i = 1
s = ""
while i <= n:
	if i % 3 == 0:
		s = s + " " + str(i)
	elif "3" in str(i):
	    s = s + " " + str(i)
	i = i + 1
print(s)

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

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

for i in range(len(mat)):
    print(" {}".format(mat[i]), end='')
print()

Solution (Python):
def call(n):
  CHECK_NUM     = 1
  INCLUDE3      = 2
  END_CHECK_NUM = 3
  i = 1
  goto = CHECK_NUM
  while True:
    if goto == CHECK_NUM:
      x = i
      if (x % 3 == 0):
        print(' ' + str(i), end='')
        goto = END_CHECK_NUM
    if goto <= INCLUDE3:
      if (x % 10 == 3):
        print(' ' + str(i), end='')
        goto = END_CHECK_NUM
      else:
        x = int(x / 10)
        if (x != 0):
          goto = INCLUDE3
          continue
    if goto <= END_CHECK_NUM:
      i += 1
      if (i <= n):
        goto = CHECK_NUM
      else:
        print('')
        break

call(int(input()))

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())
for i in range(n):
    i += 1
    if i % 3 == 0 or '3' in str(i):
        print(f" {i}", end ="")
print("")

Solution (Python):

def Call(n):
    s = ''
    for x in range(1,n+1):
        i = int(x)
        if i%3 == 0:
            temp = ' ' + str(x)
            s += temp
        elif i%10 == 3:
            temp = ' ' + str(x)
            s += temp
        else:
            i = int(i/10)
            while i:
                if i%10 == 3:
                    temp = ' ' + str(x)
                    s += temp
                    break
                i = int(i/10)
    return s


def main():
    n = int(input())
    print(Call(n))

if __name__ == "__main__":
    main()

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

Solution (Python):
n = int(input())
i = 1
s = ""
while i <= n:
    x = i
    if x % 3 == 0:
        s += " "+str(i)
        i += 1
        continue

    while x > 0:
        if x % 10 == 3:
            s += " " + str(i)
            break
        x = x//10
    i += 1
print(s)

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

Solution (Python):
x = int(input())
r = ''
for s in range(1, x + 1):
    if s % 3 == 0 or str(s).find('3') != -1:
        r += ' ' + str(s) 
print(r)

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

def include3(x):
    if x%10==3:
        return True
    if x//10>=1:
        if include3(x//10):
            return True


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

print(" ", end="")
print(" ".join(list3))

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

Solution (Python):
a = input()
for i in range(int(a)):
    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):
    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 or "3" in str(i):
        print(" {0}".format(i), end="")
print()

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

ans = [str(i) for i in range(1, n+1) if i % 3 == 0 or "3" in str(i)]

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

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

print()

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

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

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

Solution (Python):
l=int(input())
li=[]
for i in range(1,l+1):
    if i%3==0 or '3' in str(i):
        li.append(i)
lis=set(li)
s = " ".join(str(x) for x in lis)
print(" "+s)

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())

s = ''
for i in range(1, n+1):
    if i % 3 == 0:
        s += ' ' + str(i)
        continue
    
    dammy = i
    while dammy:
        if dammy % 10 == 3:
            s += ' ' + str(i)
            break
        else:
            dammy //= 10
print(s)

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):
def include3(x):
    if (x % 10 == 3):
        return True
    else:
        x //= 10
        if (x>0):
            return include3(x)
        else:
            return False

n = int(input())

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

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

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

Solution (Python):
import sys
i=int(input())
k=''
for j in range(1,i+1):
  if j%3==0 or '3' in str(j):
    k+=" "+str(j)
    
print(k)

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

Solution (Python):
x = int(input())
for i in range(1,x+1):
    if(i % 3 == 0):
        print(" {}".format(i),end="")
    elif("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())

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

print()

Solution (Python):
n = int(input())
tmp = ''
for x in range(3, n + 1):
    if x % 3 == 0 or str(x).find('3') >= 0:
        tmp += ' ' + str(x)
print(tmp)

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

for i in range(1, n + 1) :
    if i % 3 == 0 or "3" in str(i) :
        print(" ", i, end = "", sep = "")
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())
nlst =list()
for i in range(1,N+1):
    if i % 3 == 0:
        nlst.append(i)
    else:
        j = i
        while j > 1 :
            if j % 10 == 3 :
                nlst.append(i)
                break
            j = j//10
s = str()
for j in nlst:
    s += " " + str(j)
print(s)

Solution (Python):
def include3(x, i):
	if x % 10 == 3:
		print(' ' + str(i) , end='')
	else:
		x = int(x/10)
		if x:
			include3(x, i)

n = int(input())

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

print('')

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

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

        if(x % 10 == 3):
            print(" %d" %num, end ="")
            break
print()

Solution (Python):
def include3(x):
    while True:
        if x % 10 == 3:
            return True
        else:
            x = int(x / 10)
        if x == 0:
            return False

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

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

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

        check_num = str(i)
        if '3' in check_num:
            print(' '+check_num,end="")

print("")

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

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

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

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

Solution (Python):


n = int(input())

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

Solution (Python):

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

print(s)

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):
n=int(input())
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())


order = 0
for i in range(5):
    if 0 < num // 10**i <= 9:
        order = i


s = []
for j in range(1, num+1):
    if j % 3 == 0 or '3' in str(j):
        s.append(j)

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

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

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

print()

Solution (Python):
for i in range(1,int(input())+1):
    ky=False
    if i%3==0:
        ky=True
    else:
        j=i
        while j:
            if j%10==3:
                ky=True;break
            j//=10
    if ky:
        print(' ',i,sep='',end='')
print()

Solution (Python):
def call(n):
    i = 1

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


call(int(input()))

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):
import sys
if sys.platform=="ios":
	sys.stdin=open("input_file.txt")

n=int(input())
ans=""
print(end=" ")
for i in range(1,n+1):
	if i%3==0:
		ans+=str(i)+" "
		continue
	
	a=i//10000
	b=(i-10000*a)//1000
	c=(i-10000*a-1000*b)//100
	d=(i-10000*a-1000*b-100*c)//10
	e=(i-10000*a-1000*b-100*c-10*d)
	
	if a==3 or b==3 or c==3 or d==3 or e==3:
		ans+=str(i)+" "
		
print(ans[:-1])

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

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

while True:
    if i <= x:
        if i % 3 == 0:
            print(' {}'.format(i), end='')
        elif str(i).find('3') != -1:
            print(' {}'.format(i), end='')
    else:
        break
    i += 1
print()

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

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

print(''.join(ans))

Solution (Python):
n = int(input())
_ = list()
for i in range(1,n+1):
    if i % 3 == 0 or "3" in str(i):
        _.append(str(i))
        continue
print(" " + " ".join(_))

Solution (Python):
n = int(input())
for _ in range(3,n+1):
    flag = False
    if _ % 3 == 0:
        print(" ",_,end='',sep='')
        flag = True
    for i in list(str(_)):
        if i == '3' and flag == False:
            print(" ",_,end='',sep='')
            break
print()

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

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

print("")

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

Solution (Python):


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

Solution (Python):

def Check_Num(i):
    x = i
    if(x%3==0):
        print(" ",i,sep="",end="")
        return False
    return True

def Include_3(i,j):
    x = i
    y = j
    
    if(x%10==3):
        print(" ",j,sep="",end="")
        return True 
    x = (int)(x/10)       
    if(x!=0):
        Include_3(x,y)

s = input()
n = int(s)

for i in range(1,n+1):
    boolean = Check_Num(i)

    if boolean:
        Include_3(i,i)

print()

Solution (Python):
def test():

	n = int(input())

	for i in range(1,n+1):
		if i % 3 == 0:
			print(f" {i}",end='')
			continue
		elif i % 10 == 3:
			print(f" {i}",end='')
			continue
		elif (i // 10) % 10 == 3:
			print(f" {i}",end='')
			continue
		elif (i // 100) % 10 == 3:
			print(f" {i}",end='')
			continue
		elif (i // 1000) % 10 == 3:
			print(f" {i}",end='')
			continue
		elif (i // 10000) % 10 == 3:
			print(f" {i}",end='')
			continue


	print()

if __name__ == "__main__":
	test()

Solution (Python):
def call(n):
    i = x = 1
    mode = 0

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

        mode = 0
        i+=1

    print()

call(int(input()))

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

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

print(' ' + ' '.join([str(i) for i in range(1, 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):
print(" " + " ".join([str(i) for i in range(1, int(input()) + 1) if i%3 == 0 or '3' in str(i)]))

Solution (Python):
n=int(input())
l=[]
for i in range(1,n+1):
    x=i
    if (x%3)==0:
        l.append(str(i))
    else:
        while(1):
            if x==0:
                break
            elif (x%10)==3:
                l.append(str(i))
                break
            else:
                x=x//10    
l=' '.join(l)
print(' '+l)

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

Solution (Python):
n = int(input())
for i in range(1, n+1):
	if (i % 3 == 0) or ('3' in str(i)):
		print(' '+str(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(' ' + str(i) , end='')
    if i == a:
        print('')

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):
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())
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())
print_list = []
for i in range(1, n+1):
    tmp_val = i
    
    if tmp_val % 3 == 0:
        print_list.append(i)
    else:
        while tmp_val != 0:
            
            if tmp_val % 10 == 3:
                print_list.append(i)
                break
            else:
                tmp_val = tmp_val // 10

for i in range(len(print_list)):
    print(" ", print_list[i], sep="", 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())
for i in range(3, n + 1):
    if i % 3 == 0 or '3' in str(i):
        print('', i, end='')
print()

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

print(" " + " ".join([str(s) for s in ans]))

Solution (Python):
def CHECK_NUM(n):
    for d in range(len(n)):
        if n[d]=="3":
            return True
    return False
 
num = int(input())
str=""
for d in range(3,num+1):
    s = "%d"%(d)
    if d%3==0 or CHECK_NUM(s):
        str+=" %d"%(d)
print(str)

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(f" {i}",end='')
print()