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:
# coding=utf-8


def main():
    def sub():
        n = input()
        i = 1
        s = ''
        # ---------------------------------------------------------------------
        # CHECK_NUM
        while True:
            x = i
            if x % 3 == 0:
                s += ' '+str(i)
                # -----------------------
                # END_CHECK_NUM
                i += 1
                if i <= n:
                    # goto CHECK_NUM
                    continue
                else:
                    # END!!
                    break
                # -----------------------
            # -----------------------------------------------------
            # INCLUDE3
            while True:
                if x % 10 == 3:
                    s += ' '+str(i)
                    # -----------------------
                    # END_CHECK_NUM
                    i += 1
                    if i <= n:
                        # goto INCLUDE3
                        break
                    else:
                        # END!!
                        return s
                    # -----------------------
                else:
                    x /= 10
                    if x:
                        # goto INCLUDE3
                        continue
                    else:
                        # -----------------------
                        # END_CHECK_NUM
                        i += 1
                        if i <= n:
                            # goto CHECK_NUM
                            break
                        else:
                            # END!!
                            return s
                        # -----------------------
            # -----------------------------------------------------
        # ---------------------------------------------------------------------
        return s
    print sub()

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding=utf-8


def main():
    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
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

  while True:
    if x % 10 == 3:
      output += " "
      output += str(i)
      break
    else:
      x /= 10
      if x == 0:
        break
print output

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import accumulate, repeat, takewhile
(lambda n:
    (lambda include3:
        print('',
              *filter(None,
                      map(lambda i: i if i % 3 == 0 else include3(i),
                          range(1, n+1)))))(
        (lambda x:
            next(map(lambda _: x,
                     filter(lambda d: d % 10 == 3,
                            takewhile(bool,
                                      accumulate(repeat(x),
                                                 lambda a, _: a // 10)))),
                 None))))(int(input()))

Submission status: Accepted

Solution code:
i = int(input())

for j in range(1, i + 1) :
    tmpJ = int(j // 10)
    isFinish = False

    if j % 3 == 0 :
        print(' {}'.format(j), end = '')
    elif (j % 10 == 3) :
        print(' {}'.format(j), end = '')
    elif tmpJ % 10 == 3 :
        print(' {}'.format(j), end = '')
    elif tmpJ != 0 :
        tmpJ //= 10
        while tmpJ != 0 and (not isFinish) :
            if tmpJ % 10 == 3 :
                print(' {}'.format(j), end = '')
                isFinish = True
            tmpJ //= 10
print()

Submission status: Accepted

Solution code:
n = int(input())

numbers = ""

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

print(numbers)

Submission status: Accepted

Solution code:
n = input()
x = 1
print '',
while True:
    if x > n:
        break
    if (x % 3 == 0) or ('3' in str(x)):
        print x,
    x += 1

Submission status: Accepted

Solution code:
import sys

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

Submission status: Accepted

Solution code:
num = input()
print "",
for x in xrange(1,num+1):
    if x%3==0:
        print x,
    elif "3" in str(x):
        print x,
    else:
        pass

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

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

i = 0
while i < n:
    i = i+1
    x = i
    if x%3 == 0 or str(x).find( "3" ) > -1:
        sys.stdout.write( " " + str(i) )
        continue
print

sys.exit(0)

Submission status: Accepted

Solution code:
l = int(raw_input())
print "",
for i in range(l+1):
	if i//3 != 0:
		if i%3 ==0:
			print i,
		elif "3" in str(i):
			print i,

Submission status: Accepted

Solution code:
# coding:utf-8

import sys

# ??\???
n = int(input())

display = []
for i in range(n):
    num = i + 1
    # 3??§?????????????????´???
    if (num % 3 == 0):
        display.append(num)
        continue

    # ????????????????????????3????????????????????´???
    original = num
    while (num != 0):
        last_digit = int(num % 10)
        if (last_digit == 3):
            display.append(original)
            num = 0
        num = int(num / 10)

for x in display:
    
    sys.stdout.write(' ' + str(x))
print('')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
s = ''
i = 1
while True:
    x = i
    if (x % 3 == 0):
        s = s + ' ' + str(i)
    else:
        while True:
            if (x % 10 == 3):
                s = s + ' ' + str(i)
                break
            x = int(x / 10)
            if x == 0:
                break
    i = i + 1
    if (i > n):
        break
print s

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

tmp1 = 3

while tmp1 <= n:
    if tmp1 % 3 == 0:
        string =  ' ' + str(tmp1)
        sys.stdout.write(string )
    else:
        tmp2 = tmp1
        while tmp2 > 0:
            if tmp2 % 10 == 3:
                string = ' ' + str(tmp1)
                sys.stdout.write(string)
                break
            tmp2 /= 10
    tmp1 += 1
    
print ""

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def check(a,x):
    if x == 3 :
        print a,
    elif x % 10 == 3:
        print a,
    elif x :
        check(a,x/10)
        
        
n = input()
print"",

for i in range(3,n+1) :
    if i % 3 == 0 :
        print i ,
    elif i%10 == 3 :
        print i,
    else :
        check(i,i/10)

Submission status: Accepted

Solution code:
def check(a,x):
    if x == 3 :
        print a,
    elif x % 10 == 3:
        print a,
    elif x :
        check(a,x/10)
        
        
n = input()
print"",

for i in range(3,n+1) :
    if i % 3 == 0 :
        print i ,
    elif i%10 == 3 :
        print i,
    else :
        check(i,i/10)

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:
n = 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(raw_input())
s = ''

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

Submission status: Accepted

Solution code:
import sys
n = input()
for i in range(1,n+1):
  x = i
  if x%3==0:
    sys.stdout.write(' %d' % i)
    continue
  while x<=n:
    if x%10==3:
      sys.stdout.write(' %d' % i)
      break
    else:
      x /= 10
      if x==0:
        break
sys.stdout.write('\n')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(raw_input())

print "",

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

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

Submission status: Accepted

Solution code:


m = []
a = 0
for i in range(input()+1):
    if i == 0:
        continue
    if i % 3 == 0:
        m.append(str(i))
    else:
        a = i
        while True:
            if a % 10 == 3:
                m.append(str(i))
                break
            a /= 10
            if a == 0:
                break
print " " + " ".join(m)

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()
result = ""
for x in xrange(1,n+1):
    if x % 3 == 0:
        result = result + " " + str(x)

    elif x % 10 == 3:
        result = result + " " + str(x)

    else :
        i = x
        while i :
            i /= 10
            if i % 10 == 3:
                result = result + " " + str(x)
                break
print result

Submission status: Accepted

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

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

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:
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:
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:
class StructuredProgramming:
    def call(self, n):
        s = ""
        i = 1
        while i <= n:
            x = i
            if x % 3 == 0:
                s += " %d" % (i)
            else:
                while x:
                    if x % 10 == 3:
                        s += " %d" % (i)
                        break
                    x /= 10
            i += 1
        print s

if __name__ == "__main__":
    sp = StructuredProgramming()
    n = int(raw_input())
    sp.call(n)

Submission status: Accepted

Solution code:
n = input()
print(""),

for i in range(1, n+1):
    k = 1
    a = 0
    x = i
    if x%3 == 0:
        print i,
    else:
        while x != 0 and a == 0:
            if x%10 == 3:
                print i,
                a = 1
                k = 2
            else:
                x = x/10

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:
# -*- coding:utf-8 -*-
n = int(input())
s=''

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

Submission status: Accepted

Solution code:
n = int(raw_input())
cout = ""

for i in range(1,n+1):
	x = i

	if (x%3) == 0:
		cout = cout + " " + str(i)
		continue

	while x > 0:
		if (x%10) == 3:
			cout = cout + " " + str(i)
			break
		x /= 10

print cout

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1,n+1):
    if i % 3 == 0:
        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:
import sys
import math

n = input()

for x in xrange(1, n+1) :
    if x % 3 == 0 or str(x).find("3") != -1 :
        sys.stdout.write(" " + str(x))
print

Submission status: Accepted

Solution code:
n = int(input())
out = ''
for i in range(3,n+1):
    if i % 3 == 0:
        out += ' {0}'.format(i)
        continue
    elif i % 10 == 3:
        out += ' {0}'.format(i)
        continue
    n = i
    while n // 10:
        n = n // 10
        if n % 10 == 3:
            out += ' {0}'.format(i)
            n = 0
print(out)

Submission status: Accepted

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

Submission status: Accepted

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

print(end = " ")
print(*l)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

print("")

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def call(n):
	i = 1
	while True:
		through_flag = False
		x = i
		if x % 3 == 0:
			print(" {}".format(i), end="")
			through_flag = True
		if not through_flag:
			while True:
				if x % 10 == 3:
					print(" {}".format(i), end="")
					through_flag = True
				if not through_flag:
					x //= 10
					if x == 0: break
				if through_flag: break
		i += 1
		if i > n: break
	print("")



call(int(input()))

Submission status: Accepted

Solution code:
def call(n):
    s = ""
    for x in range(1, n + 1):
        y = x
        if y % 3 == 0:
            s = s + " " + str(x)
        else:
            while y != 0:
                if y % 10 == 3:
                    s = s + " " + str(x)
                    break
                y = int(y / 10)
    return s

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
x = 1
print "",
while x <= n:
	if x%3==0:
		print str(x),
	else:
		t = x
		while t:
			if t%10==3:
				print str(x),
				t = 0
			else:
				t /= 10
	x += 1
print

Submission status: Accepted

Solution code:
n = int(input())
L = []

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

print "",

while L != []:
    print L.pop(0),

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(raw_input())
i = 1
print "",

while i <= n:
  if i%3 == 0:
      print i,
  else:
      I = str(i)
      for j in range(len(I)):
          if I[j] == '3':
              print I,
              break
  i += 1

Submission status: Accepted

Solution code:
n = int(input())
result = ['']

for i in range(3, n + 1):
    if i % 3 == 0:
        result.append(i)
    elif '3' in list(str(i)):
        result.append(i)

print(*result)

Submission status: Accepted

Solution code:
N = int(input())
Plist = []
i=1
print(" ",end="")
while i <= N:
    k=1
    if i%3 == 0:
        Plist.append(i)
    elif i%10 == 3:
        Plist.append(i)
    else:
        while i//k>1 and k>=0:
            if i//k%10 == 3:
                Plist.append(i)
                break
            else:
                k = k*10
    i=i+1
print(' '.join(map(str,Plist)))

Submission status: Accepted

Solution code:
#coding:utf-8
#3????????°???????????????

n = input()

print "",
for i in xrange(1, n+1):
    if i % 3 == 0:
        print i,
    elif "3" in str(i):
        print i,

Submission status: Accepted

Solution code:
n = input()
x = 1
print '',

while True:
    if x > n:
        break
    if (x % 3 == 0) or ('3' in str(x)):
        print x,
    x += 1

Submission status: Accepted

Solution code:
import sys

def call(n):
    i = 1
    while i <= n:
        x = i
        if x % 3 == 0:
            print(' ', i, sep='', end='')
        else:
            while x:
                if x % 10 == 3:
                    print(' ', i, sep='', end='')
                    break

                x //= 10
            
        i += 1
        
    print('')
    
if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    call(n)

Submission status: Accepted

Solution code:
def include3(n):
    while n!=0:
        if n%10 == 3:
            return True
        n //= 10
    return False
n = int(input())
d = [x for x in range(1 ,n+1) if (x % 3 == 0)|(x % 10 == 3)|(include3(x))]
s = ''
for i in d:
    s += ' {}'.format(i)
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = [int(x) for x in input().split()]

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
i = 1
for i in range(1, n + 1):
 if i % 3 == 0:
  print(' {0}'.format(i), end = '')
 else:
  st = str(i)
  for x in range(0, len(st)):
   if st[x] == '3':
    print(' {0}'.format(i), end = '')
    break
print()

Submission status: Accepted

Solution code:
# get line input split by space
def getLnInput():
    return input().split()


# ceil(a / b) for a > b
def ceilDivision(a, b):
    return (a - 1) // b + 1


def call(n):
    i = 1
    while i < n:
        i += 1
        x = i
        if not x % 3:
            print(" " + str(i), end="")
        else:
            while True:
                if x % 10 == 3:
                    print(" " + str(i), end="")
                    break
                x //= 10
                if not x:
                    break
    print()


def main():
    n = int(getLnInput()[0])
    call(n)
    return


main()

Submission status: Accepted

Solution code:
n = input()
i = 1
num = []
while i <= n:
    if i % 3 == 0:
        num.append(i)
        i +=1
    else:
        x = i
        while x > 0:
            if x % 10 == 3:
                num.append(i)
                break
            elif x / 10 == 3:
                num.append(i)
                break
            else:
                x /=  10                
        i += 1
print("{}".format(str(num)).replace("["," ").replace("]","").replace(",",""))

Submission status: Accepted

Solution code:
n = input()
i = 1
num = []
while i <= n:
    if i % 3 == 0:
        num.append(i)
        i +=1
    else:
        x = i
        while x > 0:
            if x % 10 == 3:
                num.append(i)
                break
            else:
                x /=  10                
        i += 1
print("{}".format(str(num)).replace("["," ").replace("]","").replace(",",""))

Submission status: Accepted

Solution code:
def contains3(n):
    x = n
    while x > 0:
        if x % 10 == 3:
            return True
        else:
            x //= 10
    return False

x = int(input())
out = ""
for i in range(x):
    n = i + 1
    if n % 3 == 0 or contains3(n):
        out += (" %d" % n)
print(out)

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
#coding:utf-8

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

n = int(raw_input())
i = 1
while i <= n:
    x = i
    if x%3 == 0:
        sys.stdout.write(' '+str(i))
        i += 1
        continue
    while x != 0:
        if x%10 == 3:
            sys.stdout.write(' '+str(i))
            break
        x /= 10
    i += 1
print

Submission status: Accepted

Solution code:
import sys

input_num = int(sys.stdin.readline())

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

Submission status: Accepted

Solution code:
from __future__ import print_function
n = int(raw_input())

for i in range(n+1):
    if i != 0 and i % 3 == 0:
        print (" %i" % i, end="")
    elif i != 0 and i % 10 == 3:
        print (" %i" % i, end="")
    else:
        if str(i).find('3') >= 0:
            print (" %i" % i, end="")
print("")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    limit = int(input())

    data = []
    for i in range(3, limit+1):
        if (i % 3) == 0 or (i % 10 == 3) or '3' in str(i):
            data.append(str(i))

    txt = ' '.join(data)
    print(' {0}'.format(txt))

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    limit = int(input())

    data = []
    for i in range(3, limit+1):
        if (i % 3) == 0 or '3' in str(i):
            data.append(str(i))

    txt = ' '.join(data)
    print(' {0}'.format(txt))

Submission status: Accepted

Solution code:
n = int(input())

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