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 <stdio.h>

int leap_year(int, int);

int main(void)
{
	int a, b;
	while (1) {
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0) 
			break;
		leap_year(a, b);
	}
	return 0;
}

int leap_year(int a, int b)
{
	int leap_year_number = 0;
	for (int i = a; i <= b; i++) {
		if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0) {
			printf("%d\n", i);
			leap_year_number += 1;
		}
	}
	if (leap_year_number == 0) {
		printf("NA\n");
	}
	return 0;
	printf("\n");
}

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

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define DBL(x) ((x)*(x))
#define EPS 1e-10

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  int a,b;
  int c = 0;
  while(scanf("%d%d",&a,&b), a+b){
    bool flag = false;
    if(c++ != 0) puts("");
    do{
      if( (a%4 == 0 && a%100 != 0) || (a%400 == 0) ){
	flag = true;
	printf("%d\n",a);
      }
    }while(++a <= b);
    if(!flag) puts("NA");
  }
}

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; ++b) {        
        if (is_leap_year(b) == true) {
        a[i] = b;
        ++s;
        ++i;
        }
    }
    return s;
}

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;
		}
		cout << endl;
		vi.clear();
	}
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int a,b;
  while( cin >> a >> b , a+b){
    int f = 1;
    for(int i = a ; i <= b ; i++){
      if(i%4 == 0){
	if(i%100 != 0 || i%400 == 0){
	  cout << i << endl << endl; 

	  f = 0;
	}
      }
    }
    if(f) cout << "NA" << endl;
  }
  return 0;
}

C++: #include <stdio.h>

int main(void) {

  int a,b;
  int i,flag;

  while(1) {

    scanf("%d %d",&a,&b);

    if(a==0 && b==0) {
      printf("");
      break;
    }

    flag=0;

    for(i=a;i<=b;i++) {
      
      if((i%4==0 && i%100!=0) || i%400==0) {
	printf("%d\n",i);
	flag=1;
      }

    }

    if(flag==0) printf("NA\n");

    //printf("\n");
  }

  return 0;

}

C++: #include <iostream>

int LeapYear (int x);
int main()
{
    int a,b;
    std::cin >> a >> b;
    while (true) {
        int n = 0;
        if (a == 0 && b == 0) {
	        break;
        } else {
            for (int i = a; i <= b; i++) {
                if (LeapYear (i) == 1) {
                    std::cout << i << std::endl;
                    n++; 
            }				
        }
        if (n == 0) {
            std::cout << "NA" << std::endl;
        }
        std::cin >> a >> b;
        }
    }
    return 0;
}

int LeapYear (int x)
{
    if (x % 400 == 0) {
    return 1;
    } else if (x % 100 == 0) {
    return 0;
    } else if (x % 4 == 0) {
    return 1;
    }else {
    return 0;
    }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <map>
#include <functional>
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
  int a, b;
  int c = 0;
  while(cin >> a >> b, a, b){
    int cnt = 0;
    for(int i = a; i <= b; i++){
      if(i % 4 == 0){
        if(i % 100 != 0 || i % 400 == 0){
          cout << i << endl;
          cnt++;
        }
      }
    }
    if(cnt == 0){
      cout << "NA" << endl;
    }
    cout << endl;
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    int fiyear,finyear,co=0;
    while(cin>>fiyear>>finyear&&fiyear!=0&&finyear!=0){
        for(int i=0;(fiyear+i)<finyear;i++){
            if((fiyear+i)%4==0){
                co=1;
                if((fiyear+i)%100!=0||(fiyear+i)%400==0)cout<<fiyear+i<<endl;
            }
        }
        if(co==0)cout<<"NA"<<endl<<endl;
    }
}

C++: #include<stdio.h>
/*与えられた期間の間のうるう年をすべて出力*/
void leap_year(int year1, int year2);

int main(void)
{
    while(1){
        int a, b; /*a は year1　, b は year2*/
        scanf("%d %d", &a, &b);
        if (a == 0 && b == 0){
            break;
        }else if (a == b){
            printf("NA\n");
            printf("\n");
        }else {
            leap_year(a, b);
        }
    }
    return 0;
}

void leap_year(int year1, int year2)
{   
    int limit = 0; /*もしも、うるう年がなかった時に使う*/
    for (int i = year1; i <= year2; ++i){ /*i は年を表す*/
        if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0){
            printf("%d\n", i);
        }else{
            ++limit;
        }
    }
    if (limit == (year2 - year1 + 1)){/*うるう年がない場合*/
        printf("NA\n");
        printf("\n");
    }else{    /*うるう年がある場合*/
        printf("\n");
    }
}