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

for i in range(0, N):
    number = i + 1
    if number % 3 == 0:
        print(f" {number}", end="")
    elif "3" in str(number):
        print(f" {number}", end="")
    else:
        continue
    
print()

Submission status: Accepted

Solution code:
import math

n = int(input())

for x in range(1, n + 1):
    if x % 3 == 0:
        print(f" {x}", end="")
    else:
        for y in range(int(math.log10(x)) + 1):
            if int(str(x)[y]) == 3:
                print(f" {x}", end="")
                break
print()

Submission status: Accepted

Solution code:
n = int(input())

i=1
res=[]
while i<=n:
  chk='3' in str(i)

  if chk==True:
    res.append(str(i))
    
  elif i%3==0:
    res.append(str(i))
    
  i+=1
  
print(' '+' '.join(res))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

outp = ""

for i in range(n):
    x = i + 1
    if x % 3 == 0:
        outp += " " + str(x)
        continue

    for num in range(10):
        if x % 10 == 3:
            outp += " " + str(i+1)
            break
        x = x // 10
        if x < 3:
            break

print(outp)

Submission status: Accepted

Solution code:
n = int(input())

def dividable3(x):
    if x % 3 == 0:
        return True
    return False

def include3(x):
    while x > 0:
        if x % 10 == 3:
            return True
        x = x // 10
    return False

def call(x):
    return dividable3(x) or include3(x)

line = ""
for i in range(1, n+1):
    if call(i):
        line += " " + str(i)
print(line)

Submission status: Accepted

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

Submission status: Accepted

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

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

def calc(x):
    if x % 3 == 0:
        return True
    for i in str(x):
        if i == '3':
            return True
    return False

ret = []
for i in range(1, N+ 1):
    if calc(i):
        ret.append(i)

ret2 = ''
for r in ret:
    ret2 = ret2 + ' ' + str(r)
print(ret2)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

def main():
    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("")

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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


op=[]
while i<=n:
	x=i
	if x%3==0:
		op.append(i)
	else:
		while x>1:
			if x%10==3:
				op.append(i)
				break
			else:
				x//=10
	i+=1

for i in op:
	print(f" {i}",end="")

print()

Submission status: Accepted

Solution code:

def call(n):
    i=1
    
    #終了条件
    #i==n
    for i in range(1,n+1):
        x=i
        #3の倍数なら表示して次のループ
        if x%3==0:
            print(f" {i}",end="")
            continue
        
        
        #0になるまで10割る
        while x!=0:
            #10で割ったあまりが3なら表示して次のループ
            if x%10==3:
                print(f" {i}",end="")
                break
                
            x=int(x/10)
            
    print("")
    

n=int(input())

call(n)

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

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>0: 
            if x%10==3:
                ans+=' '+str(i)
                break
            x = x//10
        
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
m = [i for i in range(3, n + 1, 3)]
s = [str(i) for i in range(1, n+1)]
s = [int(i) for i in s if '3' in i]
a = set(m + s)
b = ' '
for i in a:
    b += str(i) + ' '
print(b[:-1])

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1,n+1):
    if i % 3 == 0 :
        print(" {}".format(i),end="")
    elif "3" in str(i):
        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 e in range(1, N + 1):
    if e % 3 == 0 or str(e).find("3")!=-1:
        print(" {}".format(e), 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(" %d"%i,end="")
print()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = ""
for i in range(1, n + 1):
    tmp = str(i)
    if i % 3 == 0 or '3' in tmp:
        s += f' {i}'
        continue
print(s)

Submission status: Accepted

Solution code:
n = int(input())
arr = []
def do(n):
    i = 1
    # check num
    while i <= n:
        x = i
        if x%3==0:
            arr.append(x)
        else:
            while x:
                if x%10==3:
                    arr.append(i)
                    break
                x //= 10
        i+=1
do(n)
print(" " + " ".join(map(str,arr)))

Submission status: Accepted

Solution code:
i = 1
flag = True
n = int(input())
l = []

while flag:
    x = i
    if x % 3 == 0:
        l.append(i)

    else:
        flag2 = True
        while flag2:
            if x % 10 == 3:
                l.append(i)
                break

            else:
                x //= 10
                if x < 1:
                    flag2 = False

    i += 1
    if i > n:
        flag = False

m = map(str, l)
print(" ", end = "")
print(" ".join(m))

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1, n+1, 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())
print(' ' + ' '.join([str(i) for i in range(1, n + 1) if i % 3 == 0 or '3' in [j for j in str(i)]]))

Submission status: Accepted

Solution code:
def aho(x):
    if x % 3 == 0:
        return True
    while x:
        if x % 10 == 3:
            return True
        x //= 10
    return False

n = int(input())
for i in range(1, n + 1):
    if aho(i):
        print(' ', i, sep='', end='')
print()

Submission status: Accepted

Solution code:
"""
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;
}
"""
n = int(input())
i = 1
while True:
    x = i
    if x % 3 == 0:
        print (f' {i}', end='')
    else:
        while x:
            if x % 10 == 3:
                print(f' {i}', end='')
                break
            x //= 10
    i += 1
    if i > n:
        break
print()

Submission status: Accepted

Solution code:
num = int(input())
k = int(1)

for i in range(1,num+1):
    if i%3 == 0:
        print(" %d"%i, end="")

    else:
        k = i
        while (k):
            if k%10 == 3:
                print(" %d"%i, end="")
                break
            k //=10
print()

Submission status: Accepted

Solution code:
data = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
y = 0

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

    else:
        y = i
        while (y):
            if y % 10 == 3:
                print(" %d"%i, end='')
                break
            y //= 10
print()

Submission status: Accepted

Solution code:
#1から入力数までで3で割り切れる数と3が入ってるかずを出力する
for i in range(1,int(input()) + 1):
    if "3" in str(i) or i % 3 == 0: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 i % 10 == 3:
        a.append(i)
    elif int(int(i / 10) % 10) == 3:
        a.append(i)
    elif int(int(i / 100) % 10) == 3:
        a.append(i)
    elif int(int(i / 1000) % 10) == 3:
        a.append(i)

a = sorted(set(a))
print(" ",end="")
print(*a)

Submission status: Accepted

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

print('', *ans)

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())
print(' ' + ' '.join([str(i) for i in range(3, n+1) if i%3==0 or '3' in list(str(i))]))

Submission status: Accepted

Solution code:
def call(n):
    row = []
    for i in range(1, n + 1):
        
        # 3の倍数
        if i % 3 == 0 :
            row.append(str(i))
        
        # 3を含む数
        else:
            j = i
            while j != 0:
                if j % 10 == 3:
                    row.append(str(i))
                    break
                j //= 10
            
    return row
    
num = int(input())
print("", " ".join(call(num)))

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
N=int(input())
list_num=[]
for i in range(1,N+1):
    if i%3==0:
        list_num.append(i)
        
    else:
        s=str(i)
        if list(s).count('3')!=0:
            list_num.append(i)
            
list_num.sort()

[print(' ' + str(i),end='') for i in list_num]
print()

Submission status: Accepted

Solution code:
n = int(input())
i = 1
while i <= n:
    if i % 3 == 0 or "3" in str(i):
        print(f" {i}",end="")
    i+=1
print()

Submission status: Accepted

Solution code:
n = int(input())

b = []
for a in range(n):
    if (a+1) % 3 == 0:
        b.append(a+1)
    elif '3' in str(a+1):
        b.append(a+1)

for a in b:
    print(' ',end='')
    print(a,end='')
print('')

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:
num = int(input())
cnt = 1
s = []
while cnt <= num:
  x = cnt
  if x % 3 == 0:
    s.append(cnt)
    x = 0
  while x > 0:
    if x % 10 == 3:
      s.append(cnt)
      break
    x = x // 10
  cnt += 1
s = ' '.join(str(i) for i in s)
s = ' ' + s
print(s)

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

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:
        print('', i, end='')
    else:
        while x:
            if x % 10 == 3:
                print('', i, end='')
                break
            else:
                x //= 10
print() #最後の改行

Submission status: Accepted

Solution code:
n = int(input())

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

print("")

Submission status: Accepted

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


if __name__ == "__main__":
    main()

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

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 or i % 10 == 3 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 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(" {}".format(i),end="")
    elif "3" in str(i):
        print(" {}".format(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
            else:
                x=x//10
print('')

Submission status: Accepted

Solution code:
N = int(input())
res = []

for n in range(3,N+1):
    if n % 3 == 0:
        res.append(n)
    elif '3' in str(n):
        res.append(n)
for nn in res:
    print(' %d' % nn, 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 '3' in str(i):
        print(' {}'.format(i), end = '')
print()

Submission status: Accepted

Solution code:
n=int(input())

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

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

for i in range(1,n+1):
    if i%3 == 0:
        print(" ",end="")
        print(i, end="")
    else:
        i_str = str(i)
        for j in range(len(i_str)):
            if i_str[j] == "3":
                print(" ",end="")
                print(i, end="")
                break
print("")

Submission status: Accepted

Solution code:
N = int(input())

for i in range(1, N + 1, 1):
    if i % 3 == 0 or str(i).find('3') >= 0:
        print(f" {i}", end="")
print()

Submission status: Accepted

Solution code:
N = int(input())
l = ""
i = 1

while True:
    x = i
    # CHECK_NUM
    if x%3 == 0:
        l += " {}".format(i)

    # INCLUDE3
    else:
        while True:
            if x%10 == 3:
                l += " {}".format(i)
                break
            x //= 10
            if x < 1:
                break
    i += 1
    if i > N:
        print(l)
        break

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

Submission status: Accepted

Solution code:
n = int(input())
for i in range(n):
    x = i+1
    if (x%3==0):
        print(f" {i+1}",end="")
    else:
        while x:
            if x%10==3:
                print(f" {i+1}",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(" %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 include_3 (x):
#     print(" xは　%d" % x,end="")
    if x < 1:
        return False
    elif x % 10 == 3:
        return True
    else:
        return include_3(x // 10)

n = int(input())

for i in range (1,n+1):
    if i % 3 == 0:
        print(" %d" % i,end="")
    elif include_3(i) :
        print(" %d" % i,end="")
print()

Submission status: Accepted

Solution code:
n = int(input())
A = list()
for i in range(1,n+1):
    if i % 3 == 0:
        A.append(i)
    elif "3" in str(i):
        A.append(i)
print(" ", end="")
for i in range(len(A)-1):
    print(A[i], end=" ")
print(A[len(A)-1])

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):
    if i%3 == 0 or "3" in str(i):
        print(f" {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(' {}'.format(i), end='')
print()

Submission status: Accepted

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

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 True:
        if x % 10 == 3:
            print(" " + str(i) , end = "")
            break
        elif x == 0:
            break
        x //= 10
print()

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1, n + 1):
    if i % 3 == 0:
        print("", i, end = "")
        continue
    x = i
    while x != 0:
        if x % 10 == 3:
            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 str(i).find('3') != -1:
		print(' ', i, sep='', end = '')
print()

Submission status: Accepted

Solution code:
n = int(input())
number = []
for i in range(1, n + 1):
	if i % 3 == 0 or str(i).find("3") != -1:
		number.append(i)

answer = "".join(" "+str(j) for j in number)
print(answer)

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1, n+1):
    x = i

    if x%3 ==0 :
        print(" %d" %(i),end="")
        continue
    else :
        while(True):
            if x%10 ==3 :
                print(" %d" %(i),end="")
                break
            x//=10
            if x == 0:
                break
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="")

    elif '3' in str(i):
        print(" " , end="")
        print(i , end="")

print()

Submission status: Accepted

Solution code:
base = input()
a = int(base)

for i in range(1,a+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 calc(x):
    if x%10 == 3:
        return True
    
    else: return False
    

n = int(input())
res = []
i = 1

while True:
    x = i
    x1 = 0
    x2 = 0
    x3 = 0
    if x%3 == 0:
        res.append(i)
    
    elif x%10 == 3:
        res.append(i)
    
    else:
        if x > 10 and x < 100:
            x1 = x//10
            if calc(x1) == True:
                res.append(i)
        
        if x > 100 and x < 1000:
            x1 = x//10
            x2 = x1//10
            if calc(x1) == True or calc(x2) == True:
                res.append(i)
  
        if x > 1000 and x < 10000:
            x1 = x//10
            x2 = x1//10
            x3 = x2//10
            if calc(x1) == True or calc(x2) == True or calc(x3) == True:
                res.append(i)
     
    i += 1
    if i > n:
        break

print("", " ".join(map(str, res)))

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
            else:
                x = int(x / 10)
print("")

Submission status: Accepted

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

Submission status: Accepted

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

print(''.join(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
i = 1
while n >= i:
    c3 = i
    if i % 3 == 0:
        print(" {}".format(i), end = "")
    else:
        while c3 != 0:
            if c3 % 10 == 3:
                print(" {}".format(i), end = "")
                break
            c3 = int(c3 / 10)
    i += 1
print("")

Submission status: Accepted

Solution code:
n = int(input())
x = 1
while x <= n:
    a = [int(x % 10), int((x/10) % 10), int((x/100) % 10), int((x/1000) % 10)]
    if x % 3 == 0 or ("3" in (" ".join(map(str, a)))):
        print (f" {x}", end = "")
    x += 1
print ()

Submission status: Accepted

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

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:
        s=str(i)
        for sent in s:
            if sent=="3":
                print(" ",end="")
                print(s,end="")
                break

print()

Submission status: Accepted

Solution code:
N = int(input())

ans = []

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

    while n > 0:

        if n % 10 == 3:
            ans.append(i)

        n = n//10


print(" "+" ".join([str(i) for i in set(ans)]))

Submission status: Accepted

Solution code:
n=int(input())
for i in range(1,n+1):
    if 0 == i%3 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:
        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())
i = 1
while i <= n:
    # iが3で割り切れる場合、出力
    if i % 3 == 0:
        print(f" {i}", end="")
    else:
        x = i
        # xを10で割り余りが３になる場合、出力（再起的に10で割った商を返していく）
        while x != 0:
            if x % 10 == 3:
                print(f" {i}", end="")
                break
            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 '3' in str(i):
        print(f' {i}', end='')
print()

Submission status: Accepted

Solution code:
n = int(input())
l = [""]
i = 1
 
while i <= n:
    x = int(i)
    if x%3 == 0:
        l.append(str(i))
        i += 1
        continue
    while x != 0:
        if x%10 == 3:
            l.append(str(i))
            break
        else:
            x //= 10
    i += 1

print(" ".join(l))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
print("", *[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())
i = 1

while i < n:
    i += 1
    if i % 3 == 0:
        print(" {}".format(i), end="")
    elif "3" in str(i):
        print(" {}".format(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()