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

call2(int(input()))

Solution (Python):


n = int(input().rstrip())

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

print()

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

Solution (Python):
import sys
x=[]
n=input()
for i in range(3,n+1):
    if i%3==0:
        x.append(i)
    else:
        j=i
        while j!=0:
            if j%10==3:
                x.append(i)
                break
            j=j/10

X=iter(x)
for i in X:
    sys.stdout.write(' ')
    sys.stdout.write('%d'%i)
print('')

Solution (Python):

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

Solution (Python):
n = int(input())
result = []
for i in range(1,n+1):
    si = str(i)
    if (not i % 3) or "3" in si:
        result.append(si)
print(" " + " ".join(result))

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

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

print()

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

Solution (Python):
'''
ITP-1_5-D
 ?§???????????????°???????????°
goto ?????????C/C++?¨????????????§???????????¨?????§???????????§????????????????????¨????????¶????????????????????????????????????????£?????????????????????° goto CHECK_NUM; ??¨?????????????????????????????¨???????????°??????????????§ CHECK_NUM: ??¨????????????????????????????§?????????????????????????????????£????????°?????????????????????????????????????????¨?????§????????????
?????????goto ???????????±??????????????????????????°?????????????????§?????±??????????????????????????????????????????????????¨?????¨?\¨?????????????????????
?¬????C++?¨???????????????°????????¨?????????????????????????????°????????????????????????????????????????????????goto ????????????????????§????£?????????????????????????
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
???????????´??° nn ?????????????????????????????????
???Output
????¨?????????°???????????\????????´??° nn ????????????????????????????????????????????????
'''

import sys

inputData = int(input())
 
outputData = []
cntVal = 1

while True:
    
    checkVal = cntVal
    if checkVal % 3 == 0:
        outputData.append(str(cntVal))
    else:
        while True:
            
            if checkVal % 10 == 3:
                outputData.append(str(cntVal))
                break

            checkVal = int(checkVal / 10)

            
            if checkVal != 0: 
                continue
            else: 
                break
    
    cntVal += 1

    
    if cntVal <= inputData:
        continue
    else:
        break


print(" " + " ".join(outputData))

Solution (Python):


n = int(input())

for i in range(2,n+1):
    a = i // 10
    a = a % 10
    b = i // 100
    b = b % 10
    if i % 3 == 0:
        print(' ',i,sep='',end='')
    elif i % 10 == 3:
        print(' ',i,sep='',end='')
    elif a == 3:
        print(' ',i,sep='',end='')
    elif i // 100 == 3:
        print(' ',i,sep='',end='')
    elif i // 1000 == 3:
        print(' ',i,sep='',end='')
    elif i // 10000 == 3:
        print(' ',i,sep='',end='')
    elif b == 3:
        print(' ',i,sep='',end='')
print('')

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

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

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

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









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

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

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

print()

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

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

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

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

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())
result = ""
for i in range(1,n+1):
    if i % 3 == 0 or i % 10 == 3:
        result += " " + str(i)
        continue
    x = i
    while(x):
        if x % 10 == 3:
            result += " " + str(i)
            break
        x //= 10

print(result)

Solution (Python):


import sys


def int_fetcher():
    num = int(sys.stdin.readline())
    return num


def call(num):
    res = ''
    for i in range(1, num+1):
        x = i
        if x % 3 == 0 or x % 10 == 3:
            res += ' ' + str(i)
            continue
        while x:
            if x % 10 == 3:
                res += ' ' + str(i)
                break
            x //= 10
    return res


def main():
    print(call(int_fetcher()))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
N=input()
i = 1
for i in range(1,N+1):
    if (i % 3) == 0 :
        sys.stdout.write(" ")
        sys.stdout.write("%d" % i)
    else:
        if (i % 10 ) == 3 :
            sys.stdout.write(' ')
            sys.stdout.write("%d" % i)
        else:
            if (i/10)%10 == 3:
                
                sys.stdout.write(' ')
                sys.stdout.write("%d" % i)
            else:
                if (i/100)%10 == 3:
                    sys.stdout.write(' ')
                    sys.stdout.write("%d" % i)
                else:
                    if (i/100)%10 == 3:
                        sys.stdout.write(' ')
                        sys.stdout.write("%d" % i)
                    else:
                        if(i/1000)%10 == 3:
                            sys.stdout.write(' ')
                            sys.stdout.write("%d" % i)
print ""

Solution (Python):
def call(n):
    """
    n: int
    output numbers that is multiple of 3 or include '3' (1 <= number <= n)
    
    >>> call(30)
     3 6 9 12 13 15 18 21 23 24 27 30
    """

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

    print(line)

if __name__ == '__main__':

    i = int(input())
    call(i)

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

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

print("")

Solution (Python):
n = int(input())
list_a = [i for i in range(1,n+1) if i % 3 ==0]
list_b = []
for i in range (1,n+1):
    j = i
    while True:
        if j == 0:
            break
        elif j % 10 == 3:
            list_b.append(i)
            break
        j = j // 10
    
a = set(list_a)
b = set(list_b)
c =list(a | b)
c.sort()
print(" " + " ".join(map(str,c)))

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):
num = int(input())
result = ""
for i in range(1, num + 1):
    if i % 3 == 0:
        result += " " + str(i)
    else:
        j = i 
        while(j):
            if j % 10 ==3:
                result += " " + str(i)
                break
            else:
                j  = j // 10
            
print(result)

Solution (Python):
num = int(input())
res = " ".join([str(x) for x in range(1, num+1) if x % 3 == 0 or str(x).find("3") != -1])
print(" {}".format(res))

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(" "+str(i), end='')
print()

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

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

Solution (Python):
a=input()
num=[]
for x in range(int(a)+1):
    if x!=0 and x%3==0 or x%10==3 or "3" in str(x):
        num.append(x)

str_list=map(str,num)
print(" "+" ".join(str_list))

Solution (Python):
n = int(input())
for i in range(1,n+1):
    if i%3 == 0:
        if i == n or i == n-1 or i == n-2:
            print(" "+str(i))
        else:
            print(" "+str(i),end="")
    elif i%10 == 3:
        if i == n or i == n-1 or i == n-2:
            print(" "+str(i))
        else:
            print(" "+str(i),end="")
    elif str(i).find("3") > -1:
        if i == n or i == n-1 or i == n-2:
            print(" "+str(i))
        else:
            print(" "+str(i),end="")

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

Solution (Python):


import sys
import os



"""
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;
}
"""

def include3(v):
    s = str(v)
    if '3' in s:
        return True
    else:
        return False

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

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

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):
    x = i
    if x%3 == 0:
        print('', i, end='')
        continue
    while x:
        if x%10 == 3:
            print('', i, end='')
            break
        x = 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(" {0}".format(i), end='')
print()

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

print(' ' + ' '.join(l))

Solution (Python):
def call(n):
    s = ""
    for i in range(1,n+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)
 
m = int(input())
call(m)

Solution (Python):
a = int(input())
x=0
y=[]
while x<a:
    x+=1
    if "3" in str(x) or x%3==0:
        y.append(str(x))
print(" "+" ".join(y))

Solution (Python):



def func():
    result=""
    try:
        line = input().rstrip()
        num = int(line)
    except:
        print("input error")
        return -1
        
    for i in range(1,num+1):
        if(i % 3 ==0):
            result += " "+str(i)
        else:
            devided=i
            while(True):
                if(devided % 10 == 3):
                    result += " "+str(i)
                    break
                elif(devided > 9):
                    devided = devided // 10
                else:
                    break
                
    print(result)

func()

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

Solution (Python):
def func(n):
    x = []
    for i in range(1,n+1):
        num = i
        if i % 3 == 0:
            x.append(i)
        else:
            while num:
                if int(num % 10) == 3:
                    x.append(i)
                    break
                num = int(num / 10)
    return x

if __name__ == '__main__':
    N = int(input())
    rlt = func(N)
    print(" ", end='')
    for i in range(len(rlt)):
        if rlt[i] == rlt[-1]:
            print(rlt[i], end='')
        else:
            print(rlt[i], end=' ')
print()

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

print(ans)

Solution (Python):
def check3(m):
    m = str(m)
    if '3' in m:
        return True
    else:
        return False

n = int(input())

i = 1


while i <= n:
    x = i
    if x%3 == 0 or x%10 == 3:
        print(" %d" % i, end = '')
        i += 1
    else:
        isThree = check3(x)
        if isThree:
            print(" %d" % i, end = '')
        i += 1
print("")

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

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

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

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

    x = i

    while x >= 1:
        if x % 10 == 3:
            print('', i, end='')
            break

        x = int(x/10)

print()

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

def num(i):
 num = []
 n = i
 while n != 0:
  num.append(n % 10)
  n = n // 10
 return 3 in num

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

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

out = ""
for i in range(1, n + 1):
    if (i % 3 == 0) or (i % 10 == 3):
        out += " " + str(i)
        continue
    if "3" in str(i):
        out += " " + str(i)

print out

Solution (Python):
n = int(input())
out = ''
for i in range(3,n+1):
    if i % 3 == 0:
        out += ' {0}'.format(i)
        continue
    elif i % 10 == 3:
        out += ' {0}'.format(i)
        continue
    n = i
    while n // 10:
        n = n // 10
        if n % 10 == 3:
            out += ' {0}'.format(i)
            n = 0
print(out)

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

Solution (Python):
def check_num(n):
    if n % 3 == 0\
    or n % 10 == 3\
    or str(n).find("3") != -1:
        print(" {0}".format(n), end="")

n = int(input())
for i in range(3, n+1):
    check_num(i)
print()

Solution (Python):
def hitoketame3(num):
    if num % 10 == 3:
        return True
    else:
        return False

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

Solution (Python):

def jyu_waru(a):
    x = a
    b = 0
    while x>10:
        x = x//10
        if x%10 ==3:
            b = a
            break
    return b

n = int(input().rstrip())
kazu =[]
x = 0
for i in range(1,n+1):
    if i%3==0:
        kazu.append(i)
        
    elif i%10 ==3:
        kazu.append(i)

    else:
        x = jyu_waru(i)
        if x != 0:
            kazu.append(i)

print(" " +" ".join(list(map(str,kazu))))

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

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

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

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

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

Solution (Python):

def call(n):
    for i in (range(1,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 = int(x / 10)
    print()

input = int(input().strip())
call(input)

Solution (Python):


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

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

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

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

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

r = ''
for i in range(1, n+1):
    x = i
    if x % 3 == 0:
        r += ' '+str(x)
        continue
    while x > 0 and x % 10 != 3:
        x = x // 10
    if x % 10 == 3:
        r += ' '+str(i)
print(r)

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

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

result = ' '.join([str(c) for c in range(1, N + 1) 
  if c % 3 == 0 or '3' in str(c)])

print(' ' + result)

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

print(' {}'.format(' '.join([str(c) for c in range(1, N + 1) 
  if c % 3 == 0 or '3' in str(c)])))

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

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

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

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

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

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

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

print("")

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

Solution (Python):
n=int(input())
 
result=[]
for i in range(1,n+1):
    if i %3==0:
        result.append(i)
    else:
        k=i
        for j in range(1,5):
            if k%10==3:
                result.append(i)
                break
            else:
                k=k//10
        else:
            continue
 
print("",*result)

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

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

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

Solution (Python):
def has_three(a):
    while a != 0:
        if a % 10 == 3:
            return True
        else:
            a /= 10
    return False


result = list()
n = int(raw_input())
for i in range(1, n + 1):
    if i % 3 == 0:
        result.append(i)
    elif has_three(i):
        result.append(i)
print(" " + " ".join(str(i) for i in result))

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

Solution (Python):
def func(n):
    i = 1
    dst = ""

    def include3(x, i):
        local_dst = ""

        if x % 10 == 3:
            local_dst += " " + str(i)
        else:
            if x // 10:
                local_dst += include3(x // 10, i)

        return local_dst

    while i <= n:
        x = i
        if x % 3 == 0:
            dst += " " + str(i)
        else:
            dst += include3(x, i)
        i += 1

    return dst

print(func(int(input())))

Solution (Python):
n = int(raw_input())
print '',
for i in range(1, n+1):
    if i % 3 == 0:
        print '%s' % i,
    elif i % 10 == 3:
        print '%s' % i,
    elif '3' in str(i):
        print '%s' % i,

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

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

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

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

Solution (Python):

n=int(input())
s=''

for i in range(1,n+1):
 
    if i%3==0:
        s+=' '+str(i)
    else:
        x=i
  
        while x>0 and x%10!=3:
      
            x//=10
        if x%10==3:
            s+=' '+str(i)
print(s)

Solution (Python):


import sys, math, os


PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

res = []


def CHECK_NUM2(n, i):
    x = i
    if x % 3 == 0:
        res.append(i)
    else:
        while True:
            if x % 10 == 3:
                res.append(i)
                break
            x //= 10
            if x == 0:
                break
    i += 1
    if i <= n:
        CHECK_NUM(n, i)
        
def CHECK_NUM(n, i):
    while True:
        x = i
        if x % 3 == 0:
            res.append(i)
        else:
            while True:
                if x % 10 == 3:
                    res.append(i)
                    break
                x //= 10
                if x == 0:
                    break
        i += 1
        if i > n:
            break
        
def call(n):
    CHECK_NUM(n, 1)
    

n = int(input())

call(n)
print(' ' + ' '.join([str(r) for r in res]))

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

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(end = " ")
print(*l)

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
			else:
				x = int(x / 10)
			
	i += 1
print()

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

for i in range(1,num+1):
	if str(i).find("3") != -1:
		x += (" " + str(i))
	elif i % 3 == 0:
		x += (" " + str(i))
print(x)

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

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

def call(n):
    i = 0
    while True:
        i += 1
        if i > n:
            break
        x = i
        if x % 3 == 0:
            print(' ' + str(i), end = '')
            continue

        while True:
            if int(x) % 10 == 3:
                print(' ' + str(i), end = '')
                break
            x /= 10
            if x == 0:
                break
            
    print()
    
call(n)

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

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

Solution (Python):
a=[]
n=int(input())
i=1
c=0
while i <= n:
    if c==0:
        x=i
        if x%3==0:
            a.append(i)
            i+=1
            continue
    c=0
    if x%10==3:
        a.append(i)
        i+=1
        continue
    x//=10
    if x == 0:
        i+=1
        continue
    else:
        c=1
print(' ', end='')
print(*a)

Solution (Python):
n=int(input())
a,c,i=[],0,1
while i <= n:
    if c==0:
        x=i
        if x%3==0:
            a.append(i)
            i+=1
            continue
    c=0
    if x%10==3:
        a.append(i)
        i+=1
        continue
    x//=10
    if x == 0:
        i+=1
        continue
    else:
        c=1
print(' ', end='')
print(*a)

Solution (Python):
n=int(input())
a,c,i=[],0,1
while i <= n:
    if c==0:
        x=i
        if x%3==0:
            print(' '+str(i), end='')
            i+=1
            continue
    c=0
    if x%10==3:
        print(' '+str(i), end='')
        i+=1
        continue
    x//=10
    if x == 0:
        i+=1
        continue
    else:
        c=1
print()

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

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