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:
n=int(input())
l=""
for i in range(1,n+1):
    if i % 3==0 or i % 10 == 3 or (i % 100)//10 == 3 or (i % 1000)//100 == 3 or (i % 10000)//1000 == 3:
        l+=" "+str(i)
print(l)

Submission status: Accepted

Solution code:

N = int(input())

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

Submission status: Accepted

Solution code:
print("".join([" " + str(i) for i in range(1, int(input()) + 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, end = "")
		continue

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

		x //= 10

		if x != 0:
			continue

		break
print()

Submission status: Accepted

Solution code:
a = input()
i = 0
v = 0
for i in range(int(a)):
    if ((int(i)+1) % 3) == 0:
        print(' {}'.format(int(i)+1),end='')
    elif((int(i)+1) % 10) == 3:
        print(' {}'.format(int(i)+1),end='')
    else:
        x = int(i) + 1
        while v == 0:
            
            x = int(x) // 10
            if (int(x) > 10) and (not(int(x) % 10) == 3):
                pass
            elif (int(x) % 10) == 3:
                print(' {}'.format(int(i)+1),end='')
                v = 1
            else:
                v = 1
    v = 0
    
print('')

Submission status: Accepted

Solution code:
a = int(input())
b = []
for i in range(1,a+1):
    if i%3 == 0:
        b.append(i)
    elif i%10 == 3:
        b.append(i)
    elif (i//10)%10 == 3:
        b.append(i)
    elif((i//10)//10)%10 == 3:
        b.append(i)
    elif((i//10)//10)//10%10 == 3:
        b.append(i)
    elif((i//10)//10)//10//10%10 == 3:
        b.append(i)
    elif((i//10)//10)//10//10//10%10 == 3:
        b.append(i)
    else:
        continue
for i in b:
    print(" "+str(i),end="")
print("\n",end="")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k = int(input())


def call(m: int) -> str:
    result = ""
    for i in range(1, m + 1):
        if i % 3 == 0 or '3' in str(i): 
            result += " " + str(i)
    return result


print(call(k))

Submission status: Accepted

Solution code:
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]#3で割り切れる値
list_str = [s for s in map(str,num_list) if '3' in s]#3が含まれる場合
list_in = list(map(int,list_str))#list変換
list_uniq = list(set(num2_list+list_in))
list_uniq.sort()
print(' '+' '.join(str(i) for i in list_uniq))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdout
n = int(input())
i = 1

while True:
    x = i
    if x % 3 == 0:
        stdout.write(" " + str(i))
    else:
        while x:
            if x % 10 == 3:
                stdout.write(" " + str(i))
                break
            x //= 10
    i += 1
    if i > n: break
print()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
write = open(1, 'w').write
for i in range(1, int(open(0).read())+1):
    if i % 3:
        if "3" in str(i):
            write(" %d" % i)
    else:
        write(" %d" % i)
write("\n")

Submission status: Accepted

Solution code:
import math

x = int(input())
for i in range(1,x+1):
    if i%3==0:
        print(f" {i}",end="")
        continue
    r=i
    while True:
        if r<=0:
            break
        if r%10==3:
            print(f" {i}",end="")
            break
        r//=10
print("")

Submission status: Accepted

Solution code:
n = int(input())
x = 1
y = ""
z = 1
while True:
    z = 1
    x += 1
    if x % 3 == 0:
        y += " "
        y += str(x)
    else:
        while True:
            b = int(x % 10 ** (z - 1))
            a = int((x - b) / 10 ** z)
            c = a % 10 ** z
            d = a % 10 ** (z - 1)
            if a == 3 or b == 3 or c == 3 or d == 3:
                y += " "
                y += str(x)
                break
            z += 1
            if a < 3 and z > 3:
                break
    if x >= n:
        break
print(y)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
print(" ", end="")
print(*([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())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = int(input())
for i in range(1, num + 1):
    if i % 3 == 0:
        print(f' {i}', end='')
    else:
        x = i
        while x:
            if x % 10 == 3:
                print(f' {i}', end='')
                break
            x //= 10  # 切り捨て除算
print()

Submission status: Accepted

Solution code:
n = int(input())
a =[]
for i in range(1, n+1):
    if i % 3 == 0 or i % 10 == 3 or (i%100)//10 == 3 or (i%1000)//100 == 3 or (i%10000)//1000 == 3:
        a.append(i)
print(' ', end ='')
print(*a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
inData = int(input())

seqData = list(range(1,inData+1,1))
outData = [0] * inData
for thisData in seqData:
    if thisData == inData:
        if thisData%3 == 0 or thisData%10==3:
            print(" "+str(thisData))
        else:
            for i in range(5):
                i=i+1
                over =  10 ** i
                tmp = thisData/over
                if int(tmp % 10) == 3:
                    print(" "+str(thisData))
                    break
                else:
                    pass
            print("")
    else:
        if thisData%3 == 0 or thisData%10==3:
            print(" "+str(thisData), end = "")
        else:
            for i in range(5):
                i=i+1
                over =  10 ** i
                tmp = thisData/over
                if int(tmp % 10) == 3:
                    print(" "+str(thisData), end = "")
                    break
                else:
                    pass

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def nabeatsu(n):
    if(n % 3 == 0):
        return True
    temp = n
    while(temp > 0):
        if(temp % 10 == 3):
            return True
        temp = temp // 10
    return False

x = int(input())
for i in range(x):
    if(nabeatsu(i + 1)):
        print(' ', end = '')
        print(i + 1, end = '')
print()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
i = 1
ret = ""
while True:
    x = i
    if  x % 3 == 0:
        ret += " " + str(i)
    elif x % 10 == 3:
        ret += " " + str(i)
    else:
        x //= 10
        while x != 0:
            if x % 10 == 3:
                ret += " " + str(i)
                break
            x //= 10
    i+=1
    if i > n:
        break

print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
k = []
for i in range(1, x + 1):
    y = i
    if i % 3 == 0:
        k.append(i)
    else:
        while True:
            if y % 10 == 3:
                k.append(i)
                break
            else:
                if y <= 10:
                    break
                else:
                    y //= 10

print(' '+ ' '.join([str(x) for x in k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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:
def call(n):
    ans = []

    for i, x in enumerate(range(1, n + 1), 1):
        if x % 3 == 0:
            ans.append(i)
            continue

        while x:
            if x % 10 == 3:
                ans.append(i)
                break
            x //= 10

    print(" " + " ".join(map(str, ans)))


if __name__ == '__main__':
    from sys import stdin

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

    call(n)

Submission status: Accepted

Solution code:
n = int(input())
y = 1

while y <= n :
    if(y % 3 == 0):
        print(' %d'%y,end='')
    else:
        p = y
        while(p != 0):
            if(p % 10 == 3):
                print(' %d'%y,end='')
                break
            p //= 10
    y+=1
print()

Submission status: Accepted

Solution code:
a = int(input())
for x in range(1,a+1):    
    if x % 3 == 0 or "3" in str(x):
        print(" {}".format(x),end="")
print()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
write = sys.stdout.write
n = input()
i = 1
while i <= n:
	if i % 3 == 0:
		write(' ' + str(i))
	elif i % 10 == 3:
		write(' ' + str(i))
	else:
		j = i
		while j > 0:	
			j /= 10
			if j % 10 == 3:
				write(' ' + str(i))
				break;
	i += 1
print \

Submission status: Accepted

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

Submission status: Accepted

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

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

call(int(input()))

Submission status: Accepted

Solution code:
n = int(input())
i = 1
#end_check_num
while i <= n:
    #check_num
    x = i
    if x % 3 == 0:
        print(" %d" % i, end = "")
    else:
        #INCLUDE3
        while x != 0:
            if x % 10 == 3:
                print(" %d" % i, end = "")
                break
            x //= 10
    i += 1
print()

Submission status: Accepted

Solution code:
n=int(raw_input())
ans=''
for i in range(1,n+1):
    if i%3==0:ans+=" " + str(i)
    else :
        x=i
        while x:
            if x%10==3:
                ans+=' '+str(i)
                break
            x/=10
print ans

Submission status: Accepted

Solution code:
n = int(raw_input())

print "",

for i in xrange(3,n+1):
	x = i
	if x % 3 == 0:
		print i,
		continue
	while x:
		if x % 10 == 3:
			print i,
			break

		elif x / 10 != 0:
			x = x / 10
			continue
		else:
			break

Submission status: Accepted

Solution code:
import sys
def call(n):	
	for i in xrange(1, n+1):
		if (i % 3) == 0:
			sys.stdout.write(" " + str(i))
		elif (i % 10) == 3:
			sys.stdout.write(" " + str(i))
		else:
			x = i
			x = x / 10
			while x > 0:
				if (x % 10) == 3:
					sys.stdout.write(" " + str(i))
					break
				x = x / 10
				
	print ""
	

n = int(raw_input())
call(n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = input()
o = filter(lambda n: n%3 == 0 or '3' in str(n), range(1,x+1))

print " "+" ".join(map(str,o))

Submission status: Accepted

Solution code:
print " "+" ".join(map(str,filter(lambda n:n%3==0 or '3' in str(n),range(1,input()+1))))

Submission status: Accepted

Solution code:
import sys
def call(n):
    i = 1
    flg = 1
    while True:
        x = i
        if x % 3 == 0:
            sys.stdout.write(" "+str(i))
            flg = 0
        while flg == 1:
            if x % 10 == 3:
                sys.stdout.write(" "+str(i))
                flg = 0
            x /= 10
            if not x:
                flg = 0
        if i < n :
            i = i+1
            flg = 1
        else:
            sys.stdout.write("\n")
            break
n = input()
call(n)

Submission status: Accepted

Solution code:
print(' ' + ' '.join(str(i) for i in range(1, int(input()) + 1) if not i % 3 or '3' in str(i)))

Submission status: Accepted

Solution code:
n = int(input())

ans = []
i = 1

while True:
    """CHECK_NUM"""
    x = i
    if x % 3 == 0:
        ans.append(str(i))
    else:
        while True:
            """INCLUDE3"""
            if x % 10 == 3:
                ans.append(str(i))
                break

            x = int(x / 10)
            
            if x != 0: 
                continue
            else: 
                break
    i += 1
    if i <= n:
        continue
    else:
        break

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

Submission status: Accepted

Solution code:
n=input()
i=1
SP=[]
while i<=n:
  x=i
  if x%3==0:
    SP.append(str(i))
  else:
    while x:
      if x%10==3:
        SP.append(str(i))
        break
      x/=10
  i+=1
print "", " ".join(SP)

Submission status: Accepted

Solution code:
n=int(raw_input())
i=1
SP=[]
while i<=n:
  x=i
  if x%3==0:
    SP.append(str(i))
  else:
    while x:
      if x%10==3:
        SP.append(str(i))
        break
      x/=10
  i+=1
print "", " ".join(SP)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(raw_input())
i = 1
print "",
for i in range(1,n+1):
  if i%3==0 or str(i).count('3')>0: print i,

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
print "",
for i in range(1,int(raw_input())+1):
  if i%3==0 or str(i).count('3'): print i,

Submission status: Accepted

Solution code:
n = int(raw_input())
i=1
x=i
nums = []


def include3():
    global n
    global i
    global x
    global nums

    while True:
        if x % 10 == 3:
            nums.append(str(i))
            if end_check_num():
                return 0
            return 1

        x /= 10
        if x==0:
            if end_check_num():
                return 0
            return 1
    return 1

def end_check_num():
    global n
    global i
    global x

    i+=1
    if i <= n:
        return False
    return True


while True:
    x=i
    if x % 3==0:
        nums.append(str(i))
        if end_check_num():
            break
        continue
    if 0==include3():
        break

print " " + " ".join(nums)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(raw_input())
i = 1
print "",
while(i<=n):
    x=i
    if x%3 is 0:
        print i,
    elif x%10 is 3:
        print i,
    elif (x/10)%10 is 3:
        print i,
    elif (x/10**2)%10 is 3:
        print i,
    elif (x/10**3)%10 is 3:
        print i,
    elif (x/10**4)%10 is 3:
        print i,
    i = i+1

Submission status: Accepted

Solution code:
n=int(raw_input())
i = 1
print "",
while(i<=n):
    x=i
    if x%3 is 0:
        print i,
    elif x%10 is 3:
        print i,
    elif (x/10**1)%10 is 3:
        print i,
    elif (x/10**2)%10 is 3:
        print i,
    elif (x/10**3)%10 is 3:
        print i,
    elif (x/10**4)%10 is 3:
        print i,
    i = i+1

Submission status: Accepted

Solution code:
n=int(raw_input())
i = 1
print "",
while(i<=n):
    x=i
    if x%3 is 0:
        print i,
    else:
        for j in xrange(0,4):
            if (x/10**j)%10 is 3:
                print i,
                break
    i = i+1

Submission status: Accepted

Solution code:
import sys

n = input()

for i in range(1,n+1):
    x = i
    y = i
    flag = 0
    if(x % 3 == 0):
        flag = 1
        sys.stdout.write(" ")
        sys.stdout.write(str(x))
        if(i+1 > n):
            break

    while(1):
        if flag == 1:
            break
        if(y % 10 == 3):
            sys.stdout.write(" ")
            sys.stdout.write(str(x))
            break
            if(i+1 > n):
                break
        y = y/10
        if(y == 0):
            break
print

Submission status: Accepted

Solution code:
array = []
for i in range(3,int(input()) + 1):
  if i % 3 == 0 or i % 10 == 3 or '3' in str(i):
    array.append(i)
for i in array:
  print('',"{0}".format(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('',"{0}".format(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())
nums = []
for i in range(3, n + 1):
  if i % 3 == 0 or i % 10 == 3 or '3' in str(i):
      #print('',i,end='')
      nums.append(i)
for i in nums:
    print('',i,end='')
print()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
for i in range(3,n+1):
    x = i
    if x % 3 == 0:
        print(' {0}'.format(i), end='')
        continue

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

print()

Submission status: Accepted

Solution code:
n = int(input())
for i in range(3, n+1):
    x = i
    if x % 3 == 0:
        print(' {0}'.format(i), end='')
        continue

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

print()

Submission status: Accepted

Solution code:
n = int(input())
for i in range(3,n+1):
  x = i
  if x % 3 == 0:
    print(' {0}'.format(i), end='')
    continue

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

print()

Submission status: Accepted

Solution code:
n = input()
array = []
i = 1
while i <= n:
    x = i
    if x % 3 == 0:
        array.append(i)
    else:
        while x != 0:
            if x % 10 == 3:
                array.append(i)
                break
            x /= 10
    i += 1
print str(array).replace('[', ' ').replace(']', '').replace(',', '')

Submission status: Accepted

Solution code:
import sys

def call(n):
    nums = []
    for i in range(1, n + 1):
        if i % 3 == 0:
            nums.append(str(i))
            continue
        x = i
        while x > 0:
            if x % 10 == 3:
                nums.append(str(i))
                break
            x = int(x / 10)
    print('', ' '.join(nums))

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

Submission status: Accepted

Solution code:
from sys import stdin
n = int(stdin.readline())
for i in range(1,n+1):
        x = i
        if x % 3 == 0 or x % 10 == 3:
            print('', i, end='')
            continue

        x //= 10
        while x != 0:
            if x % 10 == 3:
                print('', i, end='')
                break

            x //= 10
print()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = input()
y= []
for i in range(x+1):
	if i == 0:
		continue
	if i % 3 == 0:
		y.append(str(i))
	else:
		z = i
		while 1:
			if z % 10 == 3:
				y.append(str(i))
				break
			z /= 10
			if z == 0:
				break
print " " + " ".join(y)

Submission status: Accepted

Solution code:
import itertools as itr

def call(n):
    def devided_3(x):
        return x % 3 == 0

    def has_3(x):
        return '3' in str(x)

    data = filter(lambda x: devided_3(x) or has_3(x), range(1, n+1))
    [print(' {0}'.format(i), end='') for i in data]
    print()

if __name__ == '__main__':
    n = int(input())
    call(n)

Submission status: Accepted

Solution code:
# Python 3

def PrintI(i):
	print(" ", i)
	return i + 1

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

Submission status: Accepted

Solution code:
#coding:utf-8
#1_5_D 2015.4.1
#This program outputs multiples of 3 or any numbers with 3 under n. In this program, n is int(input()).

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
n=int(input())
for i in range(1,n+1):
	if(i%3==0 or i%10==3 or '3' in str(i)):
		i=str(i)
		sys.stdout.write(' '+i)
		i=int(i)
print('')

Submission status: Accepted

Solution code:
import sys
n=int(input())
for i in range(1,n+1):
	if(i%3==0 or i%10==3 or '3' in str(i)):		
		sys.stdout.write(' '+str(i))		
print('')

Submission status: Accepted

Solution code:
import sys

n = int( sys.stdin.readline() )
output = []
for i in range( 1, n+1 ):
	x = i
	if x%3 == 0:
		output.append( " {:d}".format( i ) )
	else:
		while x != 0:
			if x%10 == 3:
				output.append( " {:d}".format( i ) )
				break
			x = x//10
print( "".join( output ) )

Submission status: Accepted

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

Submission status: Accepted

Solution code:
print '',
for i in range(3, int(raw_input())+1):
    if i%3 == 0 or str(i).count('3'): print i,

Submission status: Accepted

Solution code:
#coding:UTF-8

n = input()
ans='' #初期化
for i in range(3,n+1):
    if i%3 == 0 or '3' in str(i): #in演算子で3があるか判定
        ans +=' '+str(i)
print ans

Submission status: Accepted

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

def call(n):
	print '',
	for i in xrange(1, n+1):
		if check(i):
			print(i),
	print

def check(i):
	if i % 3 == 0:
		return True
	elif i % 10 == 3:
		return True
	elif i / 10 > 0:
		x = i
		x /= 10
		while (x > 0):
			if x % 10 == 3:
				return True
			else:
				x /= 10
	return False


n = int(raw_input())
call(n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def call(n):
    print "",
    i = 1
    while i <= n:
        x = i
        if x % 3 == 0:
            print str(i),
            i += 1
            continue

        while x:
            if x % 10 == 3:
                print str(i),
                break
            x /= 10
            
        i += 1
        
    print

n = int(raw_input())
call(n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def modz( x, n):
    a = x / n
    return x - a*n

if __name__ == "__main__":

    n = int(raw_input())

    s = ""
    i = 1

    while True:
        # print "i:{0}".format(i)
        x = i;
        if modz(x , 3) == 0:
            s += " " + str(i)
        else:
            ex = 0
            while True:
                if modz(x , 10) == 3:
                    s += " " + str(i)
                    ex = 1
                    break
                x /= 10
                if x == 0:
                    ex = 1
                    break

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

    print s