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 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.



Sample input:
30


Sample output:
 3 6 9 12 13 15 18 21 23 24 27 30

Submission status: Accepted

Solution code:
import sys

n = int(input())
for i in range(1, n + 1):
  x = i
  if x % 3 == 0:
    sys.stdout.write(" %d" % i)
  else:
    while x > 1:
      if x % 10 == 3:
        sys.stdout.write(" %d" % i)
        break
      x //= 10
print()

Submission status: Accepted

Solution code:
def call(n):
    s = ""
    i = 1
    while i <= n:
        x = i
        if x%3 == 0:
            s += " {0}".format(i)
        else:
            while x > 0:
               if x%10 == 3:
                   s += " {0}".format(i)
                   break
               x = x // 10
        i += 1
    print(s)

m = int(input())
call(m)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Here your code !
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()

Submission status: Accepted

Solution code:
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('')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
'''
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
import sys

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

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

            checkVal = int(checkVal / 10)

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

    # EndChek
    if cntVal <= inputData:
        continue
    else:
        break

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

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
# i = 0
# 
# while i < n:
#     i = i + 1
#     if i % 3 == 0 or i % 10 == 3:
#         print(' ' + str(i),end='')
# 
# print()

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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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('')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3

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

Submission status: Accepted

Solution code:
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:
                #print (i/10)%10,"a"
                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 ""

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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("")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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("")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1, n+1): #(m,n)..start:m and number:n
	if i%3 == 0 or i%10 == 3 or '3' in str(i):
		print(" "+str(i), end='')
print()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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("")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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="")

Submission status: Accepted

Solution code:
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("")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Here your code !

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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("")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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("")

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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("")

Submission status: Accepted

Solution code:
#coding:utf-8
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))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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:])))

Submission status: Accepted

Solution code:
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('')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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)

Submission status: Accepted

Solution code:
#!/usr/bin/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("")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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('')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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('')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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("")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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("")

Submission status: Accepted

Solution code:
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("")

Submission status: Accepted

Solution code:
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('')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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,

Submission status: Accepted

Solution code:
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,

Submission status: Accepted

Solution code:
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("")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Aizu Problem ITP_1_5_D: Structured Programming
#
import sys, math, os

# read input:
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())
#n=1000
call(n)
print(' ' + ' '.join([str(r) for r in res]))

Submission status: Accepted

Solution code:
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('')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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