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

def three(n):
    result = ""
    counter = 3
    while counter < n+1:
        if "3" in str(counter) or counter % 3 == 0:
            result += " {}".format(counter)
        counter += 1
    return(result)


print(three(n))

Submission status: Accepted

Solution code:
def divisible(n):
    if n % 3 == 0:
        print(' {0}'.format(n), end='')


def include(n):
    if '3' in str(n):
        print(' {0}'.format(n), end='')


n = int(input())
for n in range(3, n+1):
    divisible(n)
    if n % 3:
        include(n)
print()

Submission status: Accepted

Solution code:
n=int(input())
d=[]
for i in range(1,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())
d=[]
for i in range(1,n+1):
    if i%3==0 or "3" in str(i):
        d.append(i)
print(" ",end="")
print(*d)

Submission status: Accepted

Solution code:
number = int(input())
data = []
for i in range(3,number+1):
    if i%3 == 0 or "3" in str(i):
        data.append(i)
print(' ',end="")
print(*data)#文字列->数列

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

Submission status: Accepted

Solution code:
import sys
n = int(input())

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

Submission status: Accepted

Solution code:
import sys
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

i = 1

while i <= n:
    if i % 3 == 0 or str(i).count('3') > 0:
        print(f" {i}", end='')
    i += 1

print()

Submission status: Accepted

Solution code:
n = int(input())

ans_str = " 3"
for i in range(4, n+1):
    if (i % 3) == 0:
        ans_str += " " + str(i)
    else:
        tho = i // 1000
        cto = (i % 1000) // 100
        ten = ((i % 1000) % 100) // 10
        one = ((i % 1000) % 100) % 10
        if tho == 3 or cto == 3 or ten == 3 or one == 3:
            ans_str += " " + str(i)

print(ans_str)

Submission status: Accepted

Solution code:
# Structured Programming
# if 入力: 30, output is " 3 6 9 12 13 15 18 21 23 24 27 30"

integer = int(input())
cout = []

i = 1
while i <= integer:
    x = i
    if x % 3 == 0:
        cout.append(i)
    else:
        while x > 0:
            if x % 10 == 3:
                cout.append(i)
                x = 0
            else:
                x //= 10
    i += 1

for n in cout:
    print(' ' + str(n), end = '')
print()

Submission status: Accepted

Solution code:
i = int(input())
for n in range(1,i+1):
    if (n%3==0):
        print(' {}'.format(n),end="") # 개행하면 안되기 때문
    else:
        x = n
        while(x>0):
            if (x%10 == 3):
                print(' {}'.format(n),end="")
                break
            else:
                x = x//10
print()

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def call_filter(x):
    if x % 3 == 0: return True

    while x > 0:
        if x % 10 == 3: return True
        x = int(x/10)

    return False

def call(n):
    for i in [x for x in range(1, n+1) if call_filter(x)]:
        print(' {}'.format(i), end='')
    print()

n = int(input())
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:
n = int(input())
i = 1
for i in range(1,n + 1):
    if i%3==0:
        print(f" {i}", end="")
        continue
    else:
        x = i
        while x!=0:
            if x%10==3:
                print(f" {i}", end="")
                break
            else:
                x = x//10
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:
def CHECK_NUM(i):
    x = i
    if x % 3 == 0:
        print(' ', x, sep='', end='')
    else:
        INCLUDE3(x)


def INCLUDE3(i):
    x = i
    while x:
        if x % 10 == 3:
            print(' ', i, sep='', end='')
            return ()
        x //= 10


n = int(input())
for i in range(1, n + 1):
    CHECK_NUM(i)
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 += (' '+str(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(" {}".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(" {0}".format(i),end="")
print()

Submission status: Accepted

Solution code:
x = int(input())

for i  in range( x ):
    j = i + 1
    if j % 3 == 0:
        print(f" {j}", end = "" )
    else:
        for k in range(4):
            if ( (j//10**k) %10) == 3:
                print(f" {j}", end = "")
                break
print(sep = "\n")

Submission status: Accepted

Solution code:
n=input()
n=(int(n))
for i in range(1,n+1):
    if i%3==0:
        print(" {}".format(i),end='')
    elif i%10==3:
        print(" {}".format(i),end='')
    elif (i//10)%10==3:
        print(" {}".format(i),end='')
    elif (i//100)%10==3:
        print(" {}".format(i),end='')
    elif (i//1000)%10==3:
        print(" {}".format(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(" {}".format(i), end = "")
print()

Submission status: Accepted

Solution code:
print("",*[i for i in range(3,-~int(input()))if 0==i%3or"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(f' {i}',end='')
        continue
    while x>0:
        if x%10 == 3:
            print(f' {i}',end='')
            break
        x = int(x/10)
print()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
data = [""]
for i in range(3,x+1):
  flag = 0

  for j in str(i):
    if int(j) == 3:
      flag = 1
  if i % 3 == 0:
    flag = 1
  if flag == 1:
    data.append(i)
ans = ' '.join(map(str, data))
print(ans)

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

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, end='')
print()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input())
s=""
for i in range(1,N+1):
    x=i
    if x%3==0:
        s+=" {}".format(i)
        continue
    while x!=0:
        if x%10==3:
            s+=" {}".format(i)
            break
        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:
n = int(input())
n_list = []
counter = 0
for i in range(3, n+1):
    if i%3 == 0:
      n_list.append(i)
      counter += 1
    else:
      x = i
      while x > 0:
        if x%10 == 3:
          n_list.append(i)
          counter += 1
          break
        x //= 10
for i in range(counter):
    print(' %d'%n_list[i], end='')
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(f" {i}",end="")

print()

Submission status: Accepted

Solution code:
n = int(input())

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())
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(input())
i = 1
while i <= n:
    if i % 3 == 0:
        print(' ', end='')
        print(i, end='')
    else:
        x = i
        while x:
            if x % 10 == 3:
                print(' ', end='')
                print(i, end='')
                break
            x = x // 10
    i += 1
print('')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#
# 5d
#

def main():
    n = int(input())
    s = ""
    for i in range(1, n+1):
        x = i
        if x % 3 == 0 or x % 10 == 3:
            s += " " + str(i)
        else:
            x //= 10
            while x:
                if x % 10 == 3:
                    s += " " + str(i)
                    break
                x //= 10
    print(s)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
for i in range(3,N+1):
    if i%3 == 0 or str(i).count("3") > 0:
        print("", end = " ")
        print(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:
        print('', i, end='')
    else:
        j = i
        while True:
            j = j // 10
            if j == 0:
                break
            if j % 10 == 3:
                print('', i, end='')
                break
print()

Submission status: Accepted

Solution code:
def Nabeatsu(num):
    ans=[]
    for i in range(1,num+1):
        if i%3==0 or ("3" in str(i)):
            ans.append(str(i))
    ans=" "+" ".join(ans)
    return ans

print(Nabeatsu(int(input())))

Submission status: Accepted

Solution code:
n=int(input())
a=1
for i in range(n):
    if a%3==0:
        print(" "+str(a),end="")
        a=a+1
    elif a%10==3:
        print(" "+str(a),end="")
        a=a+1
    elif 30<=a%100<=39:
        print(" "+str(a),end="")
        a=a+1
    elif 300<=a%1000<=399:
        print(" "+str(a),end="")
        a=a+1
    elif 3000<=a<=3999:
        print(" "+str(a),end="")
        a=a+1
    else:
        a=a+1
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:
print("", *[n for n in range(1,int(input())+1) if "3" in str(n) or n%3==0])

Submission status: Accepted

Solution code:
n=int(input())

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

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

print("")

Submission status: Accepted

Solution code:
n = int(input())

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

        continue

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

            break
        x //= 10
        if(x == 0):

            break


print("")

Submission status: Accepted

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

for i in lis:
    if i%3==0 or "3" in str(i):
        print(" {}".format(i),end="")
print()

Submission status: Accepted

Solution code:
n = int(input())
i = 1
ans = ['']
while True :
    x = i
    if x > n :
        break
    if x % 3 == 0 :
        ans.append(i)
    else :
        while x != 0 :
            if x % 10 == 3 :
                ans.append(i)
                break
            else :
                x = x // 10 
    i += 1
print(*ans)

Submission status: Accepted

Solution code:
n = int(open(0).read())

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

Submission status: Accepted

Solution code:
n=int(input())
out=""

for i in range(1,n+1):
    if i%3==0 : out+=" {}".format(i)
    elif "3" in str(i) : out+=" {}".format(i)

print(out)

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

Submission status: Accepted

Solution code:
n = int(input())
flg = True
count = 0
while count < n:
    flg = True
    count += 1
    x = count
    if x % 3 == 0:
        print(" {}".format(count), end="")
        continue
    while x != 0 and flg:
        if x % 10 == 3:
            print(" {}".format(count), end="")
            flg = False
        x = x // 10
print("")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


resolve()

Submission status: Accepted

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

if __name__ == "__main__":
    call(int(input()))

Submission status: Accepted

Solution code:
n = int(input())
result = ''
for j in range(1, n + 1):
    i = j
    if i % 3 == 0:
        result += f' {i}'
    elif i % 10 == 3:
        result += f' {i}'
    else:
        while True:
            i = i // 10
            if i == 0:
                break
            elif i % 10 == 3:
                result += f' {j}'
                break
print(result)

Submission status: Accepted

Solution code:
n = int(input())
list = list()
def call(num) :
	for i in range(1,num+1) :
		if i%3 == 0 or str(i).count("3") :
			print(" ", end="")
			print(i, end="")
			continue
call(n)
print("")

Submission status: Accepted

Solution code:
n = int(input())

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

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

print()

Submission status: Accepted

Solution code:
n = int(input())
lst1 = []
for i in range(1, n+1):
    if i % 3 == 0:
        lst1.append(i)
    else:
        j = 0
        lst2 = []
        while i >= 1:
            if i % 10 == 3:
                lst1.append(i*(10**j) + sum(lst2))
                break
            else:
                lst2.append((i%10)*(10**j))
                j += 1
                i = i // 10
print(' ', end='')
print(*lst1)

Submission status: Accepted

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


def f(x):
    if not x:
        return

    x //= 10
    if x % 10 == 3:
        print(" {}".format(i), end="")
        return

    return f(x)


for i in range(1, n + 1):
    x = i
    if x % 3 == 0 or x % 10 == 3:
        print(" {}".format(i), end="")
        continue
    f(x)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
i = 1
l = []
while i <= n:
  x = i
  if x % 3 == 0:
    l.append(i)
  else:
    while x:
      if int(x) % 10 == 3:
        l.append(i)
        break
      x /= 10
  i += 1
for n in l:
  print(" {0}".format(n), end='')
print('', sep='\n')

Submission status: Accepted

Solution code:
# coding: utf-8

n = int(input())

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

Submission status: Accepted

Solution code:
number = int(input())

index = 1
while index <= number:
    current = index
    if current % 3 == 0:
        print(f" {index}", end="")
    else:
        while current != 0:
            if current % 10 == 3:
                print(f" {index}", end="")
                break
            current //= 10
    index += 1 
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:
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):
    if i%3 == 0 or "3" in str(i):
        print(" {}".format(i),end="")
print()

Submission status: Accepted

Solution code:
n = int(input())

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

print("")

Submission status: Accepted

Solution code:

i = 1
x = i
n = int(input())

while i <= n:
    x = i
    check = False

    while True:
        if x % 3 == 0 and check == False:
            print(" %s" % i,end="")
            break
        elif x % 10 == 3:
            print(" %s" % i,end="")
            break
        else:
            x /= 10
            x = int(x)
            check = True
            if x <= 0:
                break

    i += 1
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:
a = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input().strip())
i = 1
while i <= N:
    x = i
    if x % 3 == 0:
        print(" "+str(i),end="")
    else:
        while x > 0:
            if x%10 == 3:
                print(" "+str(i),end="")
                break
            x = x//10
    i += 1
print("")

Submission status: Accepted

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

def cal(x,i,answer):
    if x >0:
        x//=10
        if x%10==3:
            answer.append(i)
        else:
            cal(x,i,answer)

def main():
    number = int(input())
    answer=[""]
    for i in range(1,number+1):
        x=i
        if x%3 ==0:
            answer.append(i)
        elif x%10==3:
            answer.append(i)
        else:
            cal(x,i,answer)
    print(*answer)

if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

s = ""

for i in range(n):
  if ((i+1)%3 == 0) or ("3" in str(i+1)):
    s +=  " " + str(i+1)

print(s)

Submission status: Accepted

Solution code:
n = int(input())
list_three =[]
for i in range(1, n+1):
  if i % 3 == 0:
    list_three.append(str(i))
  else:
    i2 = i
    while i2 > 1:
      amari = i2 % 10
      if amari == 3:
        list_three.append(str(i))
        break
      else:
        i2 //= 10
        continue
print(" " + " ".join(list_three))

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

Submission status: Accepted

Solution code:
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    n = Z()
    output = []
    for i in range(1, n+1):
        if i%3 == 0: output.append(i)
        elif '3' in str(i): output.append(i)
    for i in output: print(' ' + str(i), end='')
    print('')

    return

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

def aho(i):
    ans = ""
    if i % 3 == 0:
        ans += (" " + str(i))
    elif "3" in str(i):
        ans += (" " + str(i))
    return ans

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

Submission status: Accepted

Solution code:
n = int(input())
nums = []
for i in range(n + 1):
    if i != 0:
        # .find()は見つからなかったら-1を返す。for文で回してるので見つかった場合は0が出る
        if i % 3 == 0 or str(i).find("3") != -1:
            nums.append(i)
print("", " ".join(map(str, sorted(nums))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def call(n):
	for i in range(1, n+1):
		if i%3 == 0:
			print(' {}'.format(i),end='')
		elif str(i).count('3') > 0:
			print(' {}'.format(i),end='')
	print()

a = int(input())
call(a)

Submission status: Accepted

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