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;

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

int main(){
    int a, b;
    bool first = true;
    while( cin >> a >> b, a||b ){
        if( !first ) cout << '\n';
        bool exist = false;
        for(int i = a; i <= b; i++){
            if( leap(i) ){
                cout << i << endl;
                exist = true;
            }
        }
        if( !exist ) cout << "NA" << endl;
        first = false;
    }
    return 0;
}

C++: #include <stdio.h>

void Leap_Year(int start_year, int end_year)
{
    while ((start_year != 0) || (end_year != 0)) {
        if ((end_year - start_year > 0) && (end_year - start_year < 3)) {
            if (((start_year % 4) < (end_year % 4)) || ((start_year % 100) > (end_year % 100))) { 
                if ((start_year % 400) < (end_year % 400)) {
                    printf("NA\n");
                } else {
                    printf("%d\n", start_year + 4 - start_year % 4);
                }
            }
        } else if(start_year == end_year) {
            if (((start_year % 4 == 0) && (start_year % 100 != 0)) || (start_year % 400 == 0)) {
                printf("%d\n", start_year);
            } else {
                printf("NA\n");
            } 
        } else {
            for (int i = start_year; i <= end_year; ++i) {
                if (i % 400 != 0) {
                    if ((i % 100 != 0) && (i % 4 == 0)) {
                        printf("%d\n", i);
                    }
                } else {
                    printf("%d\n", i);
                }
            }
        }
        scanf("%d %d", &start_year, &end_year);
        if ((start_year != 0) || (end_year != 0)) {
            printf("\n");
        }
    }
}

int main(void)
{
    
    int start_year, end_year;
    scanf("%d %d", &start_year, &end_year);
    Leap_Year(start_year, end_year);
    return 0;
}

C++: #include <stdio.h>

void Leap_Year(int start_year, int end_year)
{
    while ((start_year != 0) || (end_year != 0)) {
        if ((end_year - start_year > 0) && (end_year - start_year < 3)) {
            if (((0 < start_year % 4) && ((start_year % 4) < (end_year % 4))) || (((start_year % 100) > (end_year % 100)) && (end_year % 100 > 0))) { 
                if ((0 < start_year % 400) && ((start_year % 400) < (end_year % 400))) {
                    printf("NA\n");
                } else {
                    printf("%d\n", start_year + 4 - start_year % 4);
                }
            }
        } else if(start_year == end_year) {
            if (((start_year % 4 == 0) && (start_year % 100 != 0)) || (start_year % 400 == 0)) {
                printf("%d\n", start_year);
            } else {
                printf("NA\n");
            } 
        } else {
            for (int i = start_year; i <= end_year; ++i) {
                if (i % 400 != 0) {
                    if ((i % 100 != 0) && (i % 4 == 0)) {
                        printf("%d\n", i);
                    }
                } else {
                    printf("%d\n", i);
                }
            }
        }
        scanf("%d %d", &start_year, &end_year);
        if ((start_year != 0) || (end_year != 0)) {
            printf("\n");
        }
    }
}

int main(void)
{
    
    int start_year, end_year;
    scanf("%d %d", &start_year, &end_year);
    Leap_Year(start_year, end_year);
    return 0;
}

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

int main(){
	int a,b,count=0;
	while(1){
		cin>>a>>b;
		if(a==0 && b==0){
			break;
		}
		while(a<=b){
			if(a%4==0){
				if(a%100==0){
					if(a%400==0){
						cout<<a<<endl;
						count++;
					}
				}else{
					cout<<a<<endl;
					count++;
				}
			}
			a++;
		}
		if(count==0){
			cout<<"NA"<<"\n"<<endl;
		}else{
			cout<<endl;
		}
		count=0;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int a, b;
V vi;

int main(){
	while (cin >> a >> b&&a+b){
		for (int i = a; i <= b; i++){
			if (i % 4 == 0){
				if (i % 100 == 0){
					if (i % 400 == 0){
						vi.push_back(i);
						continue;
					}
				}
				vi.push_back(i);
			}
		}
		if (vi.empty())cout << "NA" << endl;
		REP(i, vi.size()){
			cout << vi[i] << endl;
		}
		vi.clear();
	}
}

C++: #include <stdio.h>


const int year[4] = {1868, 1912, 1926, 1989};
const int month[4] = {9, 7, 12, 1};
const int day[4] = {8, 30, 25, 8};
const char gengou[5] = {'p', 'm', 't', 's', 'h'};//??????pre-meiji, meiji, taisyou, syowa, heisei??¨??????

char gengouka (int inputyear, int inputmonth, int inputday)
{
    int i;
    char y;//y?????????????????????????????????
    for (i = 0; i < 3; ++i) {
        if (inputyear == year[i]) {//?¢?????????´?????¨????????????
            if (inputmonth == month[i]) {
                if (inputday < day[i]) {
                    y = gengou[i];
                    break;
                } else {
                    y = gengou[i + 1];
                    break;
                } 
            } else if (inputmonth < month[i]) {
                y = gengou[i];
                break;
            } else {
                y = gengou[i + 1];
                break;
            }
            break;
        } else if (inputyear < year[i]) {
            y = gengou[i]; 
            break;
        } 
        if (inputyear > year[3]) {//???????????????????????§??????
            y = gengou[4];
            break;
        }
    }
    return y;
}

int main(void) 
{
    int inputyear, inputmonth, inputday, outputyear;
??????while (scanf("%d %d %d", &inputyear, &inputmonth, &inputday) != EOF) {
        char y = gengouka(inputyear, inputmonth, inputday);
        if (y == 'p') {
            printf("pre-meiji\n");
        } else if (y == 'm') {
            outputyear = inputyear - year[0] + 1;
            printf("meiji %d %d %d\n", outputyear, inputmonth, inputday);
        } else if (y == 't') {
            outputyear = inputyear - year[1] + 1;
            printf("taisho %d %d %d\n", outputyear, inputmonth, inputday); 
        } else if (y == 's') {
            outputyear = inputyear - year[2] + 1;
            printf("syowa %d %d %d\n", outputyear, inputmonth, inputday);
        } else {
            outputyear = inputyear - year[3] + 1;
            printf("heisei %d %d %d\n", outputyear, inputmonth, inputday);
        }
    } 
    return 0;
}