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

Solution (Python):
def g(n):
    for i in range(1, n+1):
        if i % 3 == 0:
            yield " {}".format(i)
            continue
        x = i
        while x != 0:
            if x % 10 == 3:
                yield " {}".format(i)
                break
            x //= 10

n = int(input())
print("".join(g(n)))

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

for i in range(n + 1):
    if i != 0:
        if i % 3 == 0 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(' ' + str(i), end='')
    else:
        s = str(i)
        if '3' in s:
            print(' ' + str(i), end='')
print('')

Solution (Python):
data = int(input())
for i in range(1, data+1):
    if (i % 3 == 0) 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:
        print(' {}'.format(i), end='')
        continue
    if '3' in str(i):
        print(' {}'.format(i), end='')
        continue
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:
  ans += " " + str(i)
 else:
  div = i
  while div//10:
   div = div//10
   if div%10 == 3:
    ans += " " + str(i)
    div = 0
print(ans)

Solution (Python):

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

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

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

print()

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

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

print()

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

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

print()

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

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

print()

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

Solution (Python):
n = int(input())
result = []
def check(x, y, remnant):
    return x % y == remnant

for i in range(1, n + 1):
    x = i
    if check(x, 3, 0):
        result.append(i)
        continue
    for j in range(len(str(x))):
        if check(x, 10, 3):
            result.append(i)
            break
        x //= 10
print(' ' + ' '.join(map(str, result)))

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

Solution (Python):
import sys

n = int(input())
for i in range(1, n + 1):
    if i % 3 == 0:
        sys.stdout.write(' ')
        sys.stdout.write(str(i))
    else:
        x = i
        for j in range(0, 5):
            if x % 10 == 3:
                sys.stdout.write(' ')
                sys.stdout.write(str(i))
                break
            x //= 10

print('')

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

Solution (Python):
def main():
    n = int(input())
    ans = []
    i = 1
    while 1:
        if i <= n:
            if i % 3 == 0:
                ans.append(i)
            else:
                hoge = list(str(i))
                if "3" in hoge:
                    ans.append(i)
            i += 1
        else:
            break
    
    print(" ", end = "")
    for x in range(len(ans)):
        if x != len(ans) - 1:
            print(ans[x], end = " ")
        else:
            print(ans[x])

if __name__ == "__main__":
    main()

Solution (Python):
import sys

n = int(raw_input())



for i in range(1, n+1):
	if i % 3 == 0:
		sys.stdout.write(" {:}".format(i))
	elif str(i).find('3') > -1:
		sys.stdout.write(" {:}".format(i))
print("")

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

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

Solution (Python):
def main():
    n = int(input())
    _list = list(range(1,n+1))
    for x in _list:
        if x % 3 == 0 or any(list(map(lambda x: x == 3, list(map(int,list(str(x))))))):
            print(' %d' %  x, end = '')
    print()
    

main()

Solution (Python):
def main():
    n = int(input())
    _list = list(range(1,n+1))
    for x in _list:
        if x % 3 == 0 or any(list(map(lambda x: int(x) == 3, list(str(x))))):
            print(' %d' %  x, end = '')
    print()
    

main()

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

line = input()
n = int(line)

call(n)

Solution (Python):
import sys

def main():
    lines = sys.stdin.readlines()
    input_num = 0
    ans = []
    for line in lines:
        
        
        line = line.strip('\n')
        input_num = int(line)
        n = input_num
        
        print "",
        index_num = 1
        flag = 0
        while True:
            
            if index_num != 1 or flag == 1:
                if (index_num + 1) > n:
                    break
                else:
                    index_num += 1 
            else:
                flag = 1
            x = index_num
            if x % 3 == 0:
                print index_num,
                continue
            if x % 10 == 3:
                print index_num,
                continue
            else:
                while x > 0:
                    x /= 10
                    if x % 10 == 3:
                        print index_num,
                        break

        break


if __name__ == "__main__":
    main()

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

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

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

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

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

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

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

Solution (Python):



import math

def main():

    n = int(input())

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

    print('')

if __name__ == '__main__':
    main()

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









x = int(input())

    
i = 1
y = i
n = []


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

i = 0
while i < int(len(n))-1:
    print(n[i], end=" ")
    i += 1
    
print(n[i])

Solution (Python):
import sys
n=int(input())
a=[]
for i in range(1,n+1):
    if (i%3==0):
        a.append(i)
    else:
        j=str(i)
        for k in range(len(j)):
            if j[k]=="3":
                a.append(i)
                break
for i in a:
    sys.stdout.write(" {0}".format(i))
sys.stdout.write("\n")

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

Solution (Python):
def threeDivCheck(x):
  if x % 3 == 0: return x
  return 0

def threeIncludeCheck(x):
  y = x
  while y!=0:
    if y%10 == 3:
      return x
    y=int(y/10)
  return 0

def main():
  n = int(input())
  p = 0
  for i in range(n+1):
    p = threeDivCheck(i)
    if p:
      print(' {}'.format(p), end='')
    else:
      p=threeIncludeCheck(i)
      if p:
        print(' {}'.format(p), end='')
  print()

main()

Solution (Python):
def main():
    """
    n=30
     3 6 9 12 13 15 18 21 23 24 27 30
    """
    n = int(input())
    for i in range(1, n + 1):
        x = i
        if x % 3 == 0:
            print("", i, end="")
            continue

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

            x //= 10

    print("")

if __name__ == "__main__":
    main()

Solution (Python):
def CheckNum(n, x, i):
	x = i
	if x % 3 == 0:
		print(" %d"%(i), end="")
		return 2, i, x
	return 1, i, x

def Include3(n, x, i):
	if x % 10 == 3:
		print(" %d"%(i), end="")
		return 2, i, x
	x = int(x/10)
	if x != 0:
		return 1, i, x
	return 2, i, x

def EndCheckNum(n, x, i):
	i += 1
	if i <= n:
		return 0, i, x
	print("")
	return 3, i, x
	
def call(n):
	counter = 0
	i = 1
	x = 1
	func = [CheckNum, Include3, EndCheckNum]
	while counter != 3:
		counter, i, x = func[counter](n, x, i)

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

Solution (Python):
n=int(input())
m=[]
for i in range(1,n+1):
 a=i
 if a%3==0:
  m.append(i)
  continue
 while a>0:
  if a%10==3:
   m.append(i)
   break
  a//=10
print(' ',end='')
print(*m)

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

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

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

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

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

Solution (Python):
def check(st):
    for d in range(len(st)):
        if st[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(s):
        str+=" %d"%(d)
print(str)

Solution (Python):
num = int(input())
for i in range(1,num+1):
    if i % 3 == 0 or '3' in str(i):
        print(' {}'.format(i),end="")
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):
def call(a):
    if a % 3 == 0:
        return True

    while a != 0:
        if a % 10 == 3:
            return True

        a //= 10

    return False

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

    for i in range(1, n + 1):
        if call(i):
            print(" {0}".format(i), end="")

    print("")

if __name__ == "__main__":
    main()

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

import sys
def call(n):
    i = 1
    sys.stdout.write(' ')
    while i <= n:
        x = i
        if x % 3 == 0:
            print i, 
            if i <= n:
                i += 1
                continue
        while x != 0:
            if x % 10 == 3:
                print i,
                if i <= n:
                    break
            x = int(x / 10)
        i += 1
    else:
        print
n = input()
call(n)

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

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

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

res = ''

i = 1
while True:
    x = i
    if x % 3 == 0:
        res += " " + str(i)
    else:
        while True:
            if x % 10 == 3:
                res += " " + str(i)
                break
            x = x // 10
            if x == 0:
                break
    i += 1
    if i > a:
        break

print(res)

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

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

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

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):
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):
def call(n):
    ret = ""
    for i in range(1, int(n)+1):
        if 0 == i % 3:
            ret += " " + str(i)
        elif -1 != str(i).find("3"):
            ret += " " + str(i)

    return ret

if __name__ == "__main__":
    n = input()
    ret = call(n)
    print (ret)

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

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

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

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

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

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

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

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

    for j in range(6):
        if int(x / (10**j)) % 10 == 3:
            print(" " + str(x), end = '')
            break
print("")

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

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

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

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

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

Solution (Python):
num = int(input())
for i in range(num):
    i += 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) :
    x = i
    if (x%3 == 0) :
        print(' %d' % i, end = '')
    else :
        while (x) :
            if (x%10 == 3) :
                print(' %d' % i, end = '')
                break
            x //= 10
print('')

Solution (Python):


def multiple_3(num):
    if num % 3 == 0:
        print(" {}".format(num), end="")
    else:
        included_3(num)

def included_3(num):
    if "3" in str(num):
        print(" {}".format(num), end="")
        
n = int(input())
for num in range(3, n+1):
    multiple_3(num)
print()

Solution (Python):


import sys

def main():
    n = int(raw_input())
    for i in range(3, n+1):
        if three(i):
            sys.stdout.write(' {}'.format(i))
    print

def three(i):
    if i%3 == 0:
        return True

    while i > 0:
        if i%10 == 3:
            return True
        i /= 10

    return False

if __name__ == '__main__':
    main()

Solution (Python):
def Check_Num(n):

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

Solution (Python):
def Check_Num(n):

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

Solution (Python):
def Check_Num(n):

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

Solution (Python):
def Check_Num(n):

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

Solution (Python):
def Check_Num(n):

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

Solution (Python):
def Check_Num(n):

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

Solution (Python):
def Check_Num(n):

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

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

for i in range(1, n+1):
    if i % 3 == 0:
        l.append(i)
    else:
        j = i
        while j > 0:
            if j % 10 == 3:
                l.append(i)
                break
            else:
                j //= 10

for p in l:
    print(" " + str(p), end="")
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())

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

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

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

Solution (Python):
n = int(input())
num_list = [i for i in range(1,n+1)]
num2_list = [i for i in num_list if i%3==0]
list_str = [s for s in map(str,num_list) if '3' in s]
list_in = list(map(int,list_str))
list_uniq = list(set(num2_list+list_in))
list_uniq.sort()
print(' '+' '.join(str(i) for i in list_uniq))

Solution (Python):

from functools import reduce

n = int(input())
i = 1

while True:

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

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

    i += 1
    if i > n:
        print()
        break

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

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

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())
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):
def include3(n):
	cond = 0
	while True:
		if n%10==3:
			cond = 1
			return cond
		elif n>9:
			n //= 10
		else:
			return cond

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

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

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

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

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

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

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

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

Solution (Python):
import sys
import math
 
n = input()
 
for x in xrange(1, n+1) :
    if x % 3 == 0 or str(x).find("3") != -1 :
        sys.stdout.write(" " + str(x))
print

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

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

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

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

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

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

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