Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

//Sliceconvtoi ...
func Sliceconvtoi() []int {
	strs := strings.Split(sc.Text(), " ")

	var ints []int
	var x int

	for _, s := range strs {
		x, _ = strconv.Atoi(s)
		ints = append(ints, x)
	}

	return ints
}

func isLeapYear(y int) bool {
	return (y%4 == 0 && y%100 > 0) || (y%4 == 0 && y%400 == 0)
}

func cntLeap(y []int) {
	cnt := 0

	for i := y[0]; i <= y[1]; i++ {
		if isLeapYear(i) {
			cnt++
			fmt.Println(i)
		}
	}

	if cnt == 0 {
		fmt.Println("NA")
	}
}

func main() {
	num := 0

	for sc.Scan() {
		y := Sliceconvtoi()

		if y[0] == 0 && y[1] == 0 {
			break
		}

		if num > 0 {
			fmt.Println()
		}

		cntLeap(y)
		num++
	}

}

C++: #include <iostream>
using namespace std;
int main(void){
    int a, b;
    for(int i=0; i < 55; i++){
      cin >> a >> b;
      if(a==0 && b==0){
          break;
      }
      if(i != 0){
          cout << endl;
      }
      if(a%4 == 0){
          if(a+4 == b && a%400 != 0 && a%100 == 0){
              cout << "NA" << endl;
          }else if(a+4 <= b){
              int c;
              c = b-a;
              for(int j=0; j <= c/4; j++){
                  if(a%400 != 0 && a%100 == 0){
                    a += 4;
                  }else{
                    cout << a << endl;
                    a+=4;
                  }
              }
          }else{
              cout << "NA" << endl;
          }
      }
      
      if(a%4 == 1){
          if(a+3 == b && a%400 != 0 && a%100 == 0){
              cout << "NA" << endl;
          }else if(a+3 <= b){
              a += 3;
              int c;
              c= b-a;
              for(int j=0; j <= c/4 ; j++){
                if(a%400 != 0 && a%100 == 0){
                a+=4;
                }else{
                  cout << a << endl;
                  a+=4;
                }
              }
          }else{
              cout << "NA" << endl;
          }
      }
      
      if(a%4 == 2){
          if(a+2 == b && a%400 != 0 && a%100 == 0){
              cout << "NA" << endl;
          }else if(a+2 <= b){
              a += 2;
              int c;
              c = b-a;
              for(int j=0; j <= c/4; j++){
                if(a%400 != 0 && a%100 == 0){
                  a+=4;
                }else{
                  cout << a << endl;
                  a+=4;
                }
              }
          }else{
              cout << "NA" << endl;
          }
      }
      
      if(a%4 == 3){
          if(a+1 == b && a%400 != 0 && a%100 == 0){
              cout << "NA" << endl;
          }else if(a+1 <= b){
              a += 1;
              int c;
              c = b-a;
              for(int j=0; j <= c/4; j++){
                if(a%400 != 0 && a%100 == 0){
                  a+=4;
                }else{
                  cout << a << endl;
                  a+=4;
                }
              }
          }else{
              cout << "NA" << endl;
          }
      }
    }
    
}

C++: #include <iostream>


int leap_year(int y) {
	if( y % 400 == 0) {
		return 1;/*???????????´*/
	} else if (y % 100 == 0 && y % 400 != 0) {
		return 0;/*???????????´??§??????*/
	} else if (y % 4 == 0 && y % 100 != 0) {
		return 1;
	} else {
		return 0;
	}
}
int main()
{
	int a;
	int b;
	while (true) {
		std::cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		} else {
			int sum = 0;
			for (int k = a; k <= b; k++) {
				sum = sum + leap_year(k);
			}
			if (sum == 0 /*????????????????????´?????????*/) {
				std::cout << "NA" << std::endl;
			} else {
			    for (int i =a; i <= b; i++) {
					if (leap_year(i) == 1) {
						std::cout << i << std::endl;
					}
				}
			}
			std::cout << std::endl;
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main()
{
	int a, b, i;
	bool f, g = false;
	while (cin >> a >> b)
	{
		if (a == 0 && b == 0) break;
		for (i = a, f = false; i <= b; i++)
		{
			if (i%4 == 0)
			{
				if (i%100 == 0 && i%400 != 0) continue;
				cout << i << endl;
				f = true;
			}
		}
		if (!f) cout << "NA" << endl;
		if (g) cout << endl;
		g = true;
	}
}

C++: #include <stdio.h>

int main(void)
{
    int start, finish;
    int exist = 0;
    while(1){
        scanf("%d %d", &start, &finish);
        if (start == 0 && finish == 0) {
            break;
        }
        for(; start <= finish; start++) {
            if((start % 4 == 0 && start % 100 != 0) || start % 400 == 0) {
            printf("%d\n", start);
            ++exist;
            }
        }
        if (exist == 0) {
            printf("NA\n");
        } else {
            exist = 0;
        }
    }
    return 0;
}

C++: #include <stdio.h>
#include <stdbool.h>

bool is_leap_year(int y);

int get_leap_years(int* a, int b, int c);

int main()
{
    int leap_years_list[1000]; //A.D. 0 - A.D. 3000 の間に閏年は高々1000個しかない

    bool first_set = true; //一つ目のセットの前にだけは改行を入れてはいけないので

    while (true) {
        int year_begin, year_end;

        //読み込み
        scanf("%d %d", &year_begin, &year_end);

        //終了判定
        if (year_begin == 0 && year_end == 0) {
            break;
        }

        //閏年を計算する
        int leap_years_count = get_leap_years(leap_years_list, year_begin, year_end);

        //セットとセットの間には空行を入れる
        if (first_set) {
            first_set = false;
        } else {
            putchar('\n'); //putcharは一文字だけ出力する関数です
        }

        //閏年を出力
        if (leap_years_count == 0) {
            puts("NA"); //putsは与えられた文字列を出力した後改行する関数です
        } else {
            for (int i = 0; i < leap_years_count; i++) {
                printf("%d\n", leap_years_list[i]);
            }
        }
        
    }
}

bool is_leap_year(int y)
{
    if (y % 400 == 0) {
        return true; 
    } else if (y % 100 == 0) {
        return false;
    } else {
        return y % 4 == 0;
    }
}

int get_leap_years(int* a, int b, int c)
{
    int s;
    for (int i = 0; b <= c; ++i) {        
        if (is_leap_year(b) == true) {
        a[i] = b;
        ++s;
        }
        ++b;
    }
    return s;
}

C++: #include<iostream>
using namespace std;

int main(){
	int year[3001];
	for(int i=0;i<3001;i++){
		if(i%4==0){
			year[i]=1;
		}else year[i]=0;
		if(i%100==0){
			year[i]=0;
		}
		if(i%400==0){
			year[i]=1;
		}
	}
	int a,b;
	while(1){
		cin>>a>>b;
		if(a==0 && b==0){
			break;
		}
		int cnt=0;
		for(int j=a;j<=b;j++){
			if(year[j]==1){
				cout<<j<<endl;
				cnt++;
			}
		}
		if(cnt==0)cout<<"NA"<<endl;
		cout<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;

#define ITER( c ) __typeof( c ).begin()
#define REP( i, m, n ) for ( int i = m; i < n; i++ )
#define UREP( i, m, n ) for ( unsigned int i = m; i < n; i++ )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) c.begin(), c.end()
#define PB( n ) push_back( n );
#define MP( a, b ) make_pair( a, b )
#define fst first
#define snd second

bool leap( int y )
{
	if ( !( y % 400 ) )
	{
		return true;
	}
	else if ( !( y % 100 ) )
	{
		return false;
	}
	else if ( !( y % 4 ) )
	{
		return true;
	}

	return false;
}

int main()
{
	int a, b;
	bool first = true;

	while ( cin >> a >> b )
	{
		if ( a == 0 && b == 0 )
		{
			break;
		}

		bool be = false;


		if ( !first )
		{
			cout << endl;
		}
		else
		{
			first = false;
		}

		for ( int i = a; i <= b; i++ )
		{
			if ( leap( i ) )
			{
				be = true;
				cout << i << endl;
			}
		}

		if ( !be )
		{
			cout << "NA" << endl;
		}
	}

	return 0;
}