Problem:


うるう年

 西暦 a 年から b 年までの間にあるすべてのうるう年を出力するプログラムを作成してください。

 うるう年の条件は、次のとおりとします。ただし、0 < a ≤ b < 3,000 とします。与えられた期間にうるう年がない場合には "NA"と出力してください。

 西暦年が 4 で割り切れる年であること。

 ただし、100 で割り切れる年はうるう年としない。

 しかし、400 で割り切れる年はうるう年である。

Input

複数のデータセットが与えられます。各データセットの形式は以下のとおりです：

a b

a, b がともに 0 のとき入力の終了とします。データセットの数は 50 を超えません。

Output

データセットごとに、西暦または NA を出力してください。

データセットの間に１つの空行を入れてください。

Sample Input

2001 2010
2005 2005
2001 2010
0 0

Output for the Sample Input

2004
2008

NA

2004
2008



Sample input:
2001 2010
2005 2005
2001 2010
0 0


Sample output:
2004
2008

NA

2004
2008

Submission status: Wrong Answer

Solution code:
def f(a, b):
    flg = False
    for x in range(a, b + 1):
        if x % 4 == 0 or x % 400 == 0:
            if not flg:
                flg = True
            print(x)
    if not flg:
        print('NA')


while True:
    _a, _b = map(int, input().split())
    if _a == _b == 0:
        break
    f(_a, _b)

Submission status: Wrong Answer

Solution code:
def isLeap(y):
    return y % 4 == 0 and (y != 100 or y == 400)

flag2 = False
while True:
    a,b = map(int,input().split())
    if a == 0: break
    if flag2:print()
    flag2 = True

    flag = True
    for y in range(a,b + 1):
        if isLeap(y):
            print(y)
            flag = False
    if(flag):print("NA")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
while True:
    a, b = map(int, input().split())

    if a == 0 and b == 0:
        break

    found = False
    for i, y in enumerate(range(a, b + 1)):
        if i != 0:
            print()
        if y % 4 == 0 and (y % 100 != 0 or y % 400 == 0):
            found = True
            print(y)
    if not found:
        print('NA')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
while True:
    a, b = map(int, input().split())

    if a == 0 and b == 0:
        break

    found = False
    for y in range(a, b + 1):
        if y != a:
            print()
        if y % 4 == 0 and (y % 100 != 0 or y % 400 == 0):
            found = True
            print(y)
    if not found:
        print('NA')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
while True:
    a, b = map(int, input().split())

    if a == 0 and b == 0:
        break

    found = False
    for y in range(a, b + 1):
        if y % 4 == 0 and (y % 100 != 0 or y % 400 == 0):
            if y != a:
                print()
            found = True
            print(y)
    if not found:
        print('NA')

Submission status: Wrong Answer

Solution code:
num = 0
while True:
    a,b = map(int,input().split())
    if a == 0 and b == 0:
        break
    for i in range(a,b + 1):
        if i % 400 == 0:
            print(i)
            num += 1
        elif i % 100 == 0:
            continue
        elif i % 4 == 0:
            print(i)
            num += 1
    if num == 0:
        print("NA")
    print()

Submission status: Wrong Answer

Solution code:
import calendar as C
while 1:
    a,b=map(int, input().split())
    if a==0:break
    if sum([1 for i in range(a,b+1) if C.isleap(i)])==0:
        print("NA")
    else:
        for i in range(a,b+1):
            if C.isleap(i)and i%100!=0:print(i)

Submission status: Wrong Answer

Solution code:
while True:
 a,b=map(int,input().split())
 if a==b==0: break
 else:
  for i in range(a,b+1):
   if i%4==0 or i%400==0:
     print(i)
   elif i%100==0 or i != 0 and i%4>0:
     print("NA")

Submission status: Wrong Answer

Solution code:
from calendar import isleap

while True:
    a, b = map(int, input().split())
    if a == 0:
        break
    print(sum(isleap(i) for i in range(a, b+1)))

Submission status: Wrong Answer

Solution code:
for e in iter(input,'0 0'):
 s,t=map(int,e.split())
 u=[y for y in range(s+1,t)if y%4==0 and y%100!=0 or y%400==0]
 if u:
  for y in u:print(y)
 else:print('NA')
 print()

Submission status: Wrong Answer

Solution code:
b=0
for e in iter(input,'0 0'):
 if b:print()
 b=u=1
 s,t=map(int,e.split())
 for y in range(s,t+1):y%4==0 and y%100!=0 or y%400==0 and print(y);u=0
 if u:print('NA')

Submission status: Wrong Answer

Solution code:
b=0
for e in iter(input,'0 0'):
 if b:print()
 b=u=1
 s,t=map(int,e.split())
 for y in range(s,t+1):((y%4==0)*(y%100!=0)or y%400==0)and print(y);u=0
 if u:print('NA')

Submission status: Wrong Answer

Solution code:
while True:
  a,b = map(int,raw_input().split())
  if a == 0 and b == 0: break
  count =0
  for i in range(a,b+1,1):
    if i%4 == 0:
      if i%100 == 0: continue
      else:
        print i
        count+=1
    elif i%400 == 0:
      print i
      count+=1
  if count == 0:
    print "NA"
    print ""
  else:
    print ""

Submission status: Wrong Answer

Solution code:
ans = []
while True:
	a, b = map(int, raw_input().split())
	if a + b == 0: break
	tmp = []
	for i in range(a, b+1):
		if i % 4 == 0:
			if i % 400 == 0:
				tmp.append(i)
			elif i % 100 == 0:
				continue
			else:
				tmp.append(i)
	if len(tmp) == 0: tmp.append("NA")
	ans.append(tmp)

print ans

for i in range(len(ans)):
	for s in ans[i]:
		print s
	if i != len(ans)-1:
		print

Submission status: Wrong Answer

Solution code:
ans = []
while True:
	a, b = map(int, raw_input().split())
	if a + b == 0: break
	tmp = []
	for i in range(a, b+1):
		if i % 4 == 0:
			if i % 400 == 0:
				tmp.append(i)
			elif i % 100 == 0:
				continue
			else:
				tmp.append(i)
	if len(tmp) == 0: tmp.append("NA")
	ans.append(tmp)

print ans

for i in range(len(ans)):
	for s in ans[i]:
		print s
	print

Submission status: Accepted

Solution code:
# from sys import exit
init = False
while(True):
    A, B = [int(n) for n in input().split()]
    if A == 0 and B == 0:
        exit()
    if init:
        print()

    # N = int(input())
    # a = [int(input()) for _ in range(N)]
    # S = str(input())
    # L = len(S)
    # T = str(input())
    # exit()
    aaa = False
    for a in range(A, B+1):
        if a % 4 == 0:
            if a % 100 == 0 and a % 400 != 0:
                continue
            print(a)
            aaa = True
    if (not aaa):
        print("NA")
    init = True

Submission status: Accepted

Solution code:
import sys

c=0
for s in sys.stdin:
  a,b = map(int,s.split())
  if a==b==0: break
  x=[]
  for i in range(a,b+1):
    if i%4==0:
      if i%100 ==0:
        if i%400==0: f=1
        else: f=0
      else: f=1
    else: f=0
    if f==1: x.append(i)
    
  if c: print
  if x==[]: print "NA"
  else:
    for e in x: print e
  c=1

Submission status: Accepted

Solution code:
import sys

c=0
for s in sys.stdin:
  a,b = map(int,s.split())
  if a==b==0: break
  x=[]
  for i in range(a,b+1):
    if i%4==0:
      if i%400==0: x.append(i)
      elif i%100!=0: x.append(i)
    
  if c: print
  if x==[]: print "NA"
  else:
    for e in x: print e
  c=1

Submission status: Accepted

Solution code:
c=0
while 1:
  a,b = map(int,raw_input().split())
  if a==b==0: break
  x=[i for i in range(a,b+1) if i%4==0 and (i%100!=0 or i%400==0)]
    
  if c: print
  if x==[]: print "NA"
  else:
    for e in x: print e
  c=1

Submission status: Accepted

Solution code:
c = 0
while 1:
  a, b = map(int, raw_input().split())
  if a == b == 0: break
  x = [i for i in range(a, b + 1) if (i % 4 == 0 and (i % 100 != 0 or i % 400 == 0))]
    
  if c: print
  if x == []: print "NA"
  else:
    for e in x: print e
  c = 1

Submission status: Accepted

Solution code:
f = 0
while 1:
  a, b = map(int, raw_input().split())
  if a == b == 0: break
  x = [i for i in range(a, b + 1) if (i % 4 == 0 and (i % 100 != 0 or i % 400 == 0))]
  if x == []: x = ["NA"]

  if f: print
  for e in x: print e
  f = 1

Submission status: Accepted

Solution code:
f=0
while 1:
  a, b = map(int, raw_input().split())
  if a==b==0: break
  x=[i for i in range(a,b+1) if (i%4==0 and (i%100!=0 or i%400==0))]
  if x==[]: x=["NA"]

  if f: print
  for e in x: print e
  f=1

Submission status: Accepted

Solution code:
import sys
f = sys.stdin

def is_leapyear(year):
    return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)
i = 0
while True:
    a, b = map(int, f.readline().split())
    if a == b == 0:
        break
    if i:
        print()
    leapyear = [year for year in range(a, b + 1) if is_leapyear(year)]
    print('\n'.join(map(str, leapyear)) if leapyear else 'NA')
    i += 1

Submission status: Accepted

Solution code:
count=0
while True:
    a,b=map(int,raw_input().split(" "))
    if a==0 and b==0:
        break
    if count!=0:
        print ""
    count+=1
    uruu=[]
    for i in [year for year in range(b+1) if year >=a]:
        if i%4==0 and i%100!=0 or i%400==0:
            uruu.append(str(i))
    if len(uruu)!=0:
        print '\n'.join(uruu)
    else:
        print "NA"

Submission status: Accepted

Solution code:
from calendar import isleap
s = []
while True:
    a, b = map(int, input().split())
    if not a:
        break
    s.append([])
    for i in range(a, b + 1):
        if isleap(i):
            s[-1].append(str(i))

print('\n\n'.join(['\n'.join(ss) if ss else 'NA' for ss in s]))

Submission status: Accepted

Solution code:
from calendar import isleap
f = lambda x: map(str, x) if x else ["NA"]
ans = []
while True:
    a, b = map(int, raw_input().split())
    if b == 0:
        break
    ans += f(filter(isleap, xrange(a, b+1))) + [""]
print "\n".join(ans).strip()

Submission status: Accepted

Solution code:
n=0
while True:
    a,b = map(int,raw_input().split())
    if (a,b)==(0,0): break
    if n>0: print ''
    ls=[i for i in range(a,b+1)]
    ans=[]
    for j in ls:
        if j%4==0 and j%100!=0:
            ans.append(j)
        elif j%400==0:
            ans.append(j)
    
    if ans==[]:
        print 'NA'
    else:
        for y in ans:
            print y
    n+=1

Submission status: Accepted

Solution code:
import calendar
c = 0
while 1:
	f = 0
	(n,m) = map(int,raw_input().split())
	if (n == 0 and m == 0):
		break;
	if c == 1:
		print ""
	for i in range(n,m+1):
		if calendar.isleap(i):
			f = 1
			print i
	if f == 0:
		print "NA"
	c = 1

Submission status: Accepted

Solution code:
import sys

i = 0
for line in sys.stdin:
    a,b = map(int, line.rstrip().split())
    if a != 0 and b != 0:
        if i != 0:
                print ''
        flag = False
        for y in range(a, b+1):
            if (y % 4 == 0 and y % 400 == 0) or (y % 4 == 0 and y % 100 != 0):
                flag = True
                print y
        else:
            if not flag:
                print 'NA'
            flag = False
    i += 1

Submission status: Accepted

Solution code:
k=0
while 1:
    a,b=map(int,raw_input().split())
    if a==0:
        break
    if k:
        print
    f=0
    k=1
    for i in range(a,b+1):
        if i%400==0 or (i%4==0 and i%100!=0):
            f=1
            print i
    if f==0:
        print "NA"

Submission status: Accepted

Solution code:
def get_data():
    while True:
        a, b = map(int, input().split())
        if a == b == 0:
            break
        yield a, b


input_data = list(get_data())
for i, data in enumerate(input_data):
    a, b = data
    flg = False
    for x in range(a, b + 1):
        if (x % 4 == 0 and x % 100 != 0) or x % 400 == 0:
            if not flg:
                flg = True
            print(x)
    if not flg:
        print('NA')
    if i != len(input_data) - 1:
        print()

Submission status: Accepted

Solution code:
line = False
while 1:
    a,b = map(int, raw_input().split())
    if a == b == 0: break
    if line: print
    line = True
    count = 0
    for i in range(a, b+1):
        if (i % 4 == 0 and i % 100 != 0) or (i % 400 == 0):
            print i
            count += 1
    if count == 0: print "NA"

Submission status: Accepted

Solution code:
def isLeap(y):
    return y % 4 == 0 and (y % 100 != 0 or y % 400 == 0)

flag2 = False
while True:
    a,b = map(int,input().split())
    if a == 0: break
    if flag2:print()
    flag2 = True

    flag = True
    for y in range(a,b + 1):
        if isLeap(y):
            print(y)
            flag = False
    if(flag):print("NA")

Submission status: Accepted

Solution code:
def isUruu(t):
    if t%4==0:
        if t%100==0:
            if t%400==0:return True
            return False
        return True
    return False
n=0
while 1:
    n+=1
    a,b=map(int,raw_input().split())
    if a!=0 and b!=0 and n!=1:print
    if a==b==0:break
    cnt=0
    for i in xrange(a,b+1):
        if isUruu(i):
            print(i)
            cnt+=1
    if cnt==0:
        print('NA')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
i = 0
while True:
    a, b = map(int, input().split())

    if a == 0 and b == 0:
        break
    elif i != 0:
        print()

    found = False
    for y in range(a, b + 1):
        if y % 4 == 0 and (y % 100 != 0 or y % 400 == 0):
            found = True
            print(y)
    if not found:
        print('NA')
        
    i += 1

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
while True:
    uru = [str(i) for i in range(a, b+1) if i % 400 == 0 or (i % 4 == 0 and i % 100 != 0)]
    result = '\n'.join(uru)

    if not result:
        result = 'NA'
    print(result)

    a, b = map(int, input().split())
    if a + b == 0: break
    print()

Submission status: Accepted

Solution code:
count = 0
while True:
  a,b = map(int,input().split())
  if (a,b) == (0,0):
    break
  if count:
    print()
  flag = 0
  for i in range(a,b+1):
    if (not (i % 400)) or ((i % 100) and (not (i % 4))):
      print(i)
      flag = 1
  if not flag:
    print("NA")
  count += 1

Submission status: Accepted

Solution code:
jun = 0
while True:
    num = 0
    a,b = map(int,input().split())
    if a == 0 and b == 0:
        break
    if jun > 0:
        print()
    for i in range(a,b + 1):
        if i % 400 == 0:
            print(i)
            num += 1
        elif i % 100 == 0:
            continue
        elif i % 4 == 0:
            print(i)
            num += 1
    if num == 0:
        print("NA")
    jun += 1

Submission status: Accepted

Solution code:
def isleap(a):return a%4==0 and a%100 or a%400==0
f=0
while 1:
    a,b=map(int,input().split())
    if not a: break
    if f:print()
    f,c=1,1
    for i in range(a,b+1):
        if isleap(i):
            print(i)
            c=0
    if c:print('NA')

Submission status: Accepted

Solution code:
import calendar as C
j=0
while 1:
    a,b=map(int, input().split())
    if a==0:break
    if j:print()
    j=1
    if sum([1 for i in range(a,b+1) if C.isleap(i)])==0:
        print("NA")
    else:
        for i in range(a,b+1):
            if C.isleap(i):print(i)

Submission status: Accepted

Solution code:
flag = False
while True:
    A,B = map(int,input().split())
    if A == 0:
        break
    ans = []
    for i in range(A,B + 1):
        if i % 400 == 0 or (i % 100 != 0 and i % 4 == 0):
            ans.append(i)
    if flag:
        print('')
    flag = True
    if len(ans) != 0:
        for i in ans:
            print(i)
    else:
        print('NA')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0093
???????????´
"""
import sys

def is_leap(year):
    ''' ?????????????????´??? ???????????´ ???????????????True/False??§?????? '''
    if year % 400 == 0:
        return True
    elif year % 100 == 0:
        return False
    elif year % 4 == 0:
        return True
    else:
        return False


def main(args):
    is_first__dataset = True
    leap_years = []  # ???????????´????????????
    # ??????????????\???
    while True:
        start_year, end_year = [int(x) for x in input().strip().split(' ')]
        if start_year == 0 and end_year == 0:
            break
        else:
            # ???????????????
            leap_years = []
            for year in range(start_year, end_year+1):
                if is_leap(year):
                    leap_years.append(year)

        # ???????????????
        if is_first__dataset == True:
            is_first__dataset = False
        else:
            print('')  # ????????????????????????1????????????

        if len(leap_years) == 0:
            print('NA')
        else:
            print('{0}'.format('\n'.join(map(str, leap_years))))

if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0093
???????????´
"""
import sys
from calendar import isleap

def is_leap(year):
    ''' ?????????????????´??? ???????????´ ???????????????True/False??§?????? (callendar.isleap(year) ??¨??????) '''
    if year % 400 == 0:
        return True
    elif year % 100 == 0:
        return False
    elif year % 4 == 0:
        return True
    else:
        return False


def main(args):
    is_first__dataset = True  # 2????????\?????????????????????????????´?????????????????????????????????????????\???????????????????????°
    leap_years = []  # ???????????´????????????
    # ??????????????\???
    while True:
        start_year, end_year = [int(x) for x in input().strip().split(' ')]
        if start_year == 0 and end_year == 0:
            break
        else:
            # ???????????????
            leap_years = []
            for year in range(start_year, end_year+1):
                if isleap(year):  # calendar.isleap()????????¨
                    leap_years.append(year)

        # ???????????????
        if is_first__dataset == True:
            is_first__dataset = False
        else:
            print('')  # 2????????\????????????????????????????????§??????????????????????????\??????

        if len(leap_years) == 0:
            print('NA')
        else:
            print('{0}'.format('\n'.join(map(str, leap_years))))

if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
def check(x) :
    if x % 4 == 0 :
        if   x % 100 != 0 : return x
        elif x % 400 == 0 : return x

def make(a, b):
    count = 0
    for _ in range(a, b+1) :
        if box[0] <= _ <= box[-1] :
            if _ in box :
                count = 1
                print(_)
        else :
            temp = check(_)
            if temp != None : 
                box.append(temp)
                count = 1
                print(_)
    if count == 0 : print('NA')
    
from sys import stdin
box = [2004]
a, b = map(int, input().split())
for _ in stdin.readlines() :
    make(a, b)
    a, b = map(int, _.split())
    if a == b == 0 : break
    print()

Submission status: Accepted

Solution code:
f = set(range(0,3000,4))
h = set(range(0,3000,100))
fh = set(range(0,3000,400))
lp = (f -h).union(fh)
 
a = False
while True:
  f,l = list(map(int, input().split()))
  if f == 0 and l == 0:
    break
  if a:
    print ('')
  t = set(range(f,l+1))
  it = sorted(list(lp.intersection(t)))
  for y in it:
    print(y)
  if len(it) == 0:
    print('NA')
  a = True

Submission status: Accepted

Solution code:
from calendar import isleap

flag = False
while True:
    a, b = map(int, input().split())
    if a == 0:
        break
    if flag:
        print()
    flag = True
    ans = [i for i in range(a, b+1) if isleap(i)]
    print("\n".join(map(str, ans)) if len(ans) else "NA")

Submission status: Accepted

Solution code:
# Aizu Problem 0093: Leap Yeark
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def is_leap_year(year):
    return year % 400 == 0 or (year % 4 == 0 and year % 100 != 0)


first = True
while True:
    y1, y2 = [int(_) for _ in input().split()]
    if y1 == y2 == 0:
        break
    if first:
        first = False
    else:
        print()
    leap_years = [year for year in range(y1, y2 + 1) if is_leap_year(year)]
    if len(leap_years) == 0:
        print("NA")
    else:
        for year in leap_years:
            print(year)

Submission status: Accepted

Solution code:
flag = 1
while True:
    a, b = map(int, input().split())
    if a == b == 0:
        quit()
    if flag == 0:
        print()
    else:
        flag = 0
    count = 0
    for i in range(a, b+1):
        if i % 400 == 0:
            print(i)
            count += 1
        elif i % 100 != 0 and i % 4 == 0:
            print(i)
            count += 1
    if count == 0:
        print('NA')

Submission status: Accepted

Solution code:
b=0
for e in iter(input,'0 0'):
 if b:print()
 b=1
 s,t=map(int,e.split())
 u=[y for y in range(s,t+1)if y%4==0 and y%100!=0 or y%400==0]
 if u:
  for y in u:print(y)
 else:print('NA')

Submission status: Accepted

Solution code:
b=0
for e in iter(input,'0 0'):
 if b:print()
 b=u=1
 s,t=map(int,e.split())
 for y in range(s,t+1):
  if y%4==0 and y%100!=0 or y%400==0:print(y);u=0
 if u:print('NA')

Submission status: Accepted

Solution code:
b=0
for e in iter(input,'0 0'):
 if b:print()
 b=u=1
 s,t=map(int,e.split())
 for y in range(s,t+1):
  if(y%4==0)*(y%100!=0)or y%400==0:print(y);u=0
 if u:print('NA')

Submission status: Accepted

Solution code:
p=print
b=0
for e in iter(input,'0 0'):
 if b:p()
 b=u=1
 s,t=map(int,e.split())
 for y in range(s,t+1):
  if((y%4==0)*(y%100!=0)or y%400==0):p(y);u=0
 if u:p('NA')

Submission status: Accepted

Solution code:
p=print
b=0
for e in iter(input,'0 0'):
 if b:p()
 b=u=1;s,t=e.split()
 for y in range(int(s),int(t)+1):
  if((y%4==0)*(y%100!=0)or y%400==0):p(y);u=0
 if u:p('NA')

Submission status: Accepted

Solution code:
p=print
b=0
for e in iter(input,'0 0'):
 if b:p()
 b=u=1;s,t=map(int,e.split())
 for y in range(s,t+1):
  if((y%4==0)*(y%100!=0)or y%400==0):p(y);u=0
 if u:p('NA')

Submission status: Accepted

Solution code:
p=print
b=0
for e in iter(input,'0 0'):
 if b:p()
 b=f=1;s,t=map(int,e.split())
 for y in range(s,t+1):
  if(y%4==0)*(y%100)or y%400==0:p(y);f=0
 if f:p('NA')

Submission status: Accepted

Solution code:
p=print
b=0
for e in iter(input,'0 0'):
 if b:p()
 b=f=1;s,t=map(int,e.split())
 for y in range(s,t+1):
  if(y%4==0)*(y%100)or y%400==0:p(y);f=0
 f and p('NA')

Submission status: Accepted

Solution code:
p=print
b=1
for e in iter(input,'0 0'):
 b or p()
 b=f=0;s,t=map(int,e.split())
 for y in range(s,t+1):
  if(y%4==0)*(y%100)or y%400==0:p(y);f=1
 f or p('NA')

Submission status: Accepted

Solution code:
flag2 = False
while True:
    a,b = map(int, input().split())
    flag = True
    if b == 0:
        break
    if flag2:
        print()
    for y in range(a, b + 1):
        if y%4 == 0:
            if y%100 == 0:
                if y%400 == 0:
                    print(y)
                    flag = False
                    continue
                continue
            print(y)
            flag = False
    if flag:
        print("NA")
    flag2 = True

Submission status: Accepted

Solution code:
is_not_first = 0
while True:
  a, b = map(int, input().split())
  if not a:
    break
  
  if is_not_first:
    print()
  is_not_first += 1

  print_flag = 0
  for year in range(a, b + 1):
    if (not year % 4) and ((not (not year % 100)) or (not year % 400)):
      print(year)
      print_flag = 1

  if not print_flag:
    print("NA")

Submission status: Accepted

Solution code:
def isUruu(y):
    if y % 4 == 0:
        if y % 100 == 0:
            if y % 400 == 0:
                return True
            else:
                return False
        else:
            return True
    else:
        return False

first = True
while True:
    a,b = [int(i) for i in input().split()]
    if a == 0 and b == 0:
        break

    if first:
        first = False
    else:
        print("")

    flag = False
    for i in range(a,b+1):
        if isUruu(i):
            flag = True
            print(i)

    if not flag:
        print("NA")

Submission status: Accepted

Solution code:
# AOJ 0093 Leap Year
# Python3 2018.6.11 bal4u

def leap_year(y):
    return y % 4 == 0 and (y % 100 != 0 or y % 400 == 0)

import sys
first = True
for line in sys.stdin:
    a, b = list(map(int, line.split()))
    if a == 0:
        break
    else:
        if first:
            first = False
        else:
            print()

        f = False
        for y in range(a, b+1):
            if leap_year(y):
                print(y)
                f = True
        if not f:
            print('NA')

Submission status: Accepted

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

import sys

def solve(pair):
    frm, to = pair[0], pair[1]
    ans = filter(is_uruu, range(frm, to + 1))
    if not ans:
        return "NA\n"
    else:
        return "\n".join(map(str, ans)) + "\n"
    
def is_uruu(n):
    return (n % 400 == 0) or ((not n % 100 == 0) and (n % 4 == 0))

if __name__ == "__main__":
    lst = []
    while True:
        line = sys.stdin.readline()
        frm, to = tuple(map(int, line.strip().split(" ")))
        if frm == 0 and to == 0:
            break
        lst.append((frm, to))
    print "\n".join(map(solve, lst)),

Submission status: Accepted

Solution code:
flg = True
while True:
	a, b = map(int, raw_input().split())
	if a == b == 0: break
	if flg:
		flg = False
	else:
		print ""
	pflg = False
	for i in xrange(a, b + 1):
		if i % 400 == 0 or (i % 4 == 0 and i % 100 != 0):
			print i
			pflg = True
	if not pflg:
		print "NA"

Submission status: Accepted

Solution code:
def solve(a, b):
	pflg = False
	for i in xrange(a, b + 1):
		if i % 400 == 0 or (i % 4 == 0 and i % 100 != 0):
			yield str(i)
			pflg = True
	if not pflg:
		yield "NA"
result = []
while True:
	a, b = map(int, raw_input().split())
	if a == b == 0: break
	result += ["\n".join(solve(a, b))]
print "\n\n".join(result)

Submission status: Accepted

Solution code:
flag=False
while True:
    a,b=map(int,raw_input().split())
    if (a,b)==(0,0):
        break
    if not flag:
        flag=True
    else:
        print
    ans=[y for y in xrange(a,b+1) if (y%4==0 and not y%100==0) or y%400==0]
    if not ans:
        print "NA"
    else:
        print "\n".join(map(str,ans))

Submission status: Accepted

Solution code:
ans=[]
while True:
    a,b=map(int,raw_input().split())
    if (a,b)==(0,0):
        break
    t=[y for y in xrange(a,b+1) if (y%4==0 and not y%100==0) or y%400==0]
    if not t:
        ans.append("NA")
    else:
        ans.append("\n".join(map(str,t)))
print "\n\n".join(ans).strip()

Submission status: Accepted

Solution code:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit


def main(readline=stdin.readline):
    leap_year = [not y % 4 and y % 100 or not y % 400 for y in range(3001)]
    separator = ''
    while 1:
        a, b = (int(s) for s in readline().split())
        if not a and not b:
            exit()

        print(separator, end='')

        result = 'NA\n'
        for year, leap in enumerate(leap_year[a:b+1], a):
            if leap:
                print(year)
                result = ''

        print(result, end='')
        separator = '\n'


main()

Submission status: Accepted

Solution code:
count = 0
while True:
    try:
        a, b = map(int, raw_input().split())
        if a + b == 0:
            break
        if count > 0:
            print ""
        flag = 0
        for i in range(a,b+1):
            if i%4 == 0 and (i%100 != 0 or i%400 == 0):
                print i
                flag = 1
        if flag == 0:
            print "NA"
        count += 1
    except:
        break

Submission status: Accepted

Solution code:
ans = []
while True:
	a, b = map(int, raw_input().split())
	if a + b == 0: break
	tmp = []
	for i in range(a, b+1):
		if i % 4 == 0:
			if i % 400 == 0:
				tmp.append(i)
			elif i % 100 == 0:
				continue
			else:
				tmp.append(i)
	if len(tmp) == 0: tmp.append("NA")
	ans.append(tmp)

for i in range(len(ans)):
	for s in ans[i]:
		print s
	if i != len(ans)-1:
		print

Submission status: Accepted

Solution code:
first = True
while True:
    a, b = map(int, input().split())
    if a == b == 0: break

    if not first: print()
    first = False

    count = 0
    for y in range(a, b + 1):
        if y % 400 == 0 or y % 4 == 0 and y % 100 != 0:
            count += 1
            print(y)
    if count == 0: print('NA')

Submission status: Accepted

Solution code:
csp = 0 
while True:
    a, b = map(int, input().split())

    if a == 0 and b == 0:
        break

    if csp:
        print()

    csp = 1

    a = (a+3)//4 *4

    lst = [i for i in range(a,b+1,4) if i %100 != 0 or i %400 == 0]

    if lst == []:
        print('NA')

    else:
        for i in lst:
            print(i)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def count(k):
    return k // 4 - k // 100 + k // 400
def solve(i):
    a, b = map(int, readline().split())
    if a == b == 0:
        return False
    if i:
        write("\n")
    ans = []
    for k in range((a+3)//4*4, b+1, 4):
        if k % 100 > 0 or k % 400 == 0:
            ans.append(k)
    if ans:
        for k in ans:
            write("%d\n" % k)
    else:
        write("NA\n")
    return True
i = 0
while solve(i):
    i += 1

Submission status: Accepted

Solution code:

def isLeap(y):
    if y % 400 == 0:
        return True
    if y % 100 == 0:
        return False
    if y % 4 == 0:
        return True
    else:
        return False
c = 0
while True:
    a, b = [int(x) for x in input().split()]
    if a  == 0 and b == 0:
        break
    if c > 0:
        print()
    c +=1
    f = 0
    for i in range(a,b+1):
        if isLeap(i):
            f += 1
            print(i)
    if f == 0:
        print("NA")

Submission status: Accepted

Solution code:
is_not_first = 0
while True:
  a, b = map(int, input().split())
  if not a:
    break
   
  if is_not_first:
    print()
  is_not_first += 1
 
  print_flag = 0
  for year in range(a, b + 1):
    if (not year % 4) and ((not (not year % 100)) or (not year % 400)):
      print(year)
      print_flag = 1
 
  if not print_flag:
    print("NA")

Submission status: Accepted

Solution code:
cnt = 0
while True:
  a, b = map(int, input().split())
  if a + b == 0:
    break
  flag = True
  if cnt != 0:
    print()
  for i in range(a, b + 1):
    if i % 4 == 0:
      if i % 100 == 0:
        if i % 400 == 0:
          flag = False
          print(i)
      else:
        flag = False
        print(i)
  if flag == True:
    print("NA")
  cnt += 1

Submission status: Accepted

Solution code:
first=1
while 1:
    a,b=map(int,input().split())
    if a==b==0:break
    if first==1:
        first=0
    else:
        print()
    count=0
    for i in range(a,b+1):
        if i%400==0:
            print(i)
            count+=1
        elif i%100==0:
            pass
        elif i%4==0:
            print(i)
            count+=1
    if count==0:print("NA")

Submission status: Accepted

Solution code:
first = True

while 1:
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        break

    if first:
        first = False
    else:
        print()

    anslist = []
    for i in range(a, b+1):
        if i % 400 == 0:
            anslist.append(i)
        elif i % 100 == 0:
            pass
        elif i % 4 == 0:
            anslist.append(i)

    if anslist == []:
        print("NA")
    else:
        for ans in anslist:
            print(ans)

Submission status: Accepted

Solution code:
from calendar import isleap

f = True
while True:
    a, b = map(int, input().split())
    if a == b == 0: break
    leap = [str(i) for i in range(a, b+1) if isleap(i)]
    if f:
        f = False
    else:
        print()
    if not leap:
        print('NA')
    else:
        print('\n'.join(leap))

Submission status: Accepted

Solution code:
import calendar
flag=False
while 1:
    a,b=map(int,input().split(" "))
    if a==b==0:break
    if flag:print()
    leaps=list(filter(calendar.isleap,range(a,b+1)))
    if not leaps:
        print("NA")
    else:
        for i in leaps:
            print(i)
    flag=True