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

try:
     (n)  =  int(input())
except:
    exit

i = 1
end_check = False
while True:
    x = i
    if ( x % 3 == 0):
        print(' {}'.format(i),end="")
        end_check = True

    while end_check == False:
        if ( x % 10 == 3):
            print(' {}'.format(i),end="")
            end_check = True
        x = x // 10
        if (x == 0):
            end_check =True

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

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

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

print()

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

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

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

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

print(''.join(ans_list))

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

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

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

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 = x//10
print()

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

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

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

    print()

call(int(input()))

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

for i in range(3, n+1):
    if i % 3 == 0:
        List.append(i)
    elif '3' in str(i):
        List.append(i)
        
print(' ', end = '') 
print(' '.join(map(str, List)))

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

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

Solution (Python):















import math


def judge(i):
    if i%3==0:
        return str(i)
        
    newi=i
    
    while(newi>10):
        if newi%10==3:
            
            
            return str(i)
        elif newi//10==3:
            
            
            return str(i)
        newi=math.floor(newi/10)
        
    return False


x=int(input())
result=[]
for num in range(1,x+1):
    if(judge(num)):
        result.append(judge(num))

print(" "+" ".join(result))

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

x = 0

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

print()

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

Solution (Python):
def include_3(n) :
    ans = False
    if n >= 10 :
        if n % 10 == 3 :
            ans = True
            return ans
        if n // 10 == 3 :
            ans = True
            return ans
        ans = include_3(n // 10)
    return ans

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

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

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

Solution (Python):
n = int(input())
i=1
while True:
    if i % 3 == 0 or "3" in str(i):
        print(" "+str(i), end="")
    if i == n:
        break
    i+=1
print()

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

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

Solution (Python):
n = int(input())
x = 1
i = 0
while x <= n:
    if x % 3 == 0:
        print(" %d"%x,end="")
    elif x % 10 == 3:
        print(" %d"%x,end="")
    else:
        i = x
        while i:
            i //= 10
            if i % 10 == 3:
                print(" %d"%x,end="")
                break
    x += 1
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())
s = ""
for i in range(1, n+1):
    x = i
    if (x % 3 == 0):
        s = s + " " + str(i)
    else:
        while x % 10 != 3 and x > 0:
            x = x // 10
        if x % 10 == 3:
            s = s + " " + str(i)
print(s)

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

word = ""
for i in range(len(L)):
    word =  word + " "+str(L[i])

print(word)

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

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

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

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

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

Solution (Python):
def doSame(n):
	i = 0
	while i <= n:
		i += 1
		cn(i, n)
	print()

def cn(i, n):
	x = i
	if x % 3 == 0:
		if i <= n:
			print(' %d' % (i), end='')
		return
	i3(x, i, n)

def i3(x, i, n):
	if x % 10 == 3:
		if i <= n:
			print(' %d' % (i), end='')
		return
	x = int(x / 10)
	if x > 0:
		i3(x, i, n)

doSame(int(input()))

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

Solution (Python):



num = int(input())
ans = ""
for num in range(3, num + 1):
    if num % 3 == 0 or num % 10 == 3 or '3' in list(str(num)):
        ans += ' ' + str(num)
print(ans)

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

Solution (Python):
s = int(input())
numbers = []
for i in range(s+1):
    if (i % 3 == 0 or "3" in str(i)) and i != 0:
        numbers.append(i)

for p in numbers:
    if len(numbers) == 1:
        print("",p)
    else:
        if p == numbers[0]:
            print("",p,end=" ")
        elif p == numbers[-1]:
            print(p)
        else:
            print(p,end=" ")

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

Solution (Python):


def main():

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

if __name__ == "__main__":

	main()

Solution (Python):
arg = int(input())
data = []
for x in range(3,arg+1):
    if x % 3 == 0 or '3' in str(x):
        print('',x,end='')
    else:
        pass
print("")