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++: /*

  1????????????cin >> ????????????????????¢????????????????????????????????????????????????????????????????????????
???2????????\?????????cin >> ??????????????????????????????????????£????????????????????¨??????????????????????????????????§?

#include <iostream>

bool judgeUruyear(int year)
{

    if (year % 400 == 0) {
        return true;
    } else if (year % 100 == 0) {
        return false;
    } else if (year % 4 == 0) {
        return true;
    } else {
        return false;
    }

}

int flag = 0;

void printUruyear(int year_begin, int year_end)
{

    if(flag == 1){
        std::cout << std::endl;
    }
    flag = 1;

    int count_year = 0;

    // kono for loop no jyouken-siki ha "=" hituyou
    for (int i = year_begin; i <= year_end; i++) {
        
        if (judgeUruyear(i)) {

            count_year += 1;
            std::cout << i << std::endl;
        }    
    }

    if (count_year == 0) { 
        std::cout << "NA" << std::endl;
    }
    
}

int main()
{
    int year_begin, year_end;

    while (true) {

        std::cin >> year_begin >> year_end;

        if (year_begin == 0 && year_end == 0) {
            break;
        }

        printUruyear(year_begin, year_end);
    }
    
    return 0;
}

// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1877346#1

*/

#include <iostream>

bool judgeUruyear(int year)
{

    if (year % 400 == 0) {
        return true;
    } else if (year % 100 == 0) {
        return false;
    } else if (year % 4 == 0) {
        return true;
    } else {
        return false;
    }

}

int flag = 0;

void printUruyear(int year_begin, int year_end)
{

    if(flag == 1){
        std::cout << std::endl;
    }
    flag = 1;

    int count_year = 0;

    // kono for loop no jyouken-siki ha "=" hituyou
    for (int i = year_begin; i <= year_end; i++) {
        
        if (judgeUruyear(i)) {

            count_year += 1;
            std::cout << i << std::endl;
        }    
    }

    if (count_year == 0) { 
        std::cout << "NA" << std::endl;
    }
    
}

int main()
{
    int year_begin, year_end;

    while (true) {

        std::cin >> year_begin >> year_end;

        if (year_begin == 0 && year_end == 0) {
            break;
        }

        printUruyear(year_begin, year_end);
    }
    
    return 0;
}

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

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

void leapyear (int year1, int year2)
{
    int i;
    int j = 0; 
    for (i = year1; i <= year2; ++i) {
        if (i % 4 == 0) {
            if (i % 100 != 0) {
                printf("%d\n", i);
                ++j;
            } else if (i % 400 == 0) {
                printf("%d\n", i);
                ++j;
            } 
        }
    }
    if (j == 0) {
        printf("NA\n");
    }
}

int main(void)
{
    while (true) {
        int year1, year2;
        scanf("%d %d", &year1, &year2);
        if (year1 == 0 && year2 == 0) {
            break;
        }
        leapyear(year1, year2);
    }
    return 0;
}

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

int main(){
	int a, b;

	while( cin >> a >> b && !( a == 0 && b == 0 ) ){
		bool exist = false;
		for( int i = a + ( 4 - a%4 ) % 4; i <= b; i += 4 ){
			exist = true;
			if( i % 400 != 0 && i % 100 == 0 ){
				continue;
			}
			cout << i << endl;
		}
		if( !exist ){
			cout << "NA" << endl;
		}
	}

	return 0;
}

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

int main(void)
{
  int a, b;
  int flag;
  
  while(1)
    {
      cin >> a >> b;
      if(a == 0 && b == 0) break;
      flag = 0;
      cout << endl;

      for(int i = a ; i <= b ; i++)
	{
	  if(i % 4 == 0 && i % 100 != 0 || i % 400 == 0) 
	    {
	      cout << i << endl;
	      flag = 1;
	    }
	}
      if(flag == 0) cout << "NA" << endl;
      cout << endl;
    }
  return 0;
}

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

void leapyear (int year1, int year2)
{
    int i;
    int j = 0; 
    for (i = year1; i <= year2; ++i) {
        if (i % 4 == 0) {
            if (i % 100 != 0) {
                printf("%d\n", i);
                ++j;
            } else if (i % 400 == 0) {
                printf("%d\n", i);
                ++j;
            } 
        }
    }
    if (j == 0) {
        printf("NA\n");
    }
    printf("\n");
}

int main(void)
{
    while (true) {
        int year1, year2;
        scanf("%d %d", &year1, &year2);
        if (year1 == 0 && year2 == 0) {
            break;
        }
        leapyear(year1, year2);
    }
    return 0;
}

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

int isLeap(int y){
  return y%400==0||(y%4==0&&y%100!=0);
}

int main(void){
  int a,b, isNA;
  bool firstLineFlg=1;
  
  while (cin >> a >> b){
    if (a==0 && b==0) break;
    isNA=1;
    if (firstLineFlg) firstLineFlg = 0;
    else cout << endl;
    for (int i=a; i<=b; i++){
      if (isLeap(i)){
        isNA = 0;
        cout << i << endl;
      }
    }
    if (isNA){
      cout << "NA" << endl;
    }
  }
  
  return 0;
}

C++: #include <stdio.h>
#include <stdbool.h>
   
int lpyrJudge(int x, int y);
   
int main(void)
{
    int sta, fin;
    int judgecount = 0;
    while (true) {
        scanf("%d %d", &sta, &fin);
        if (sta == 0 && fin == 0) {
            break;
        } else {
            if (judgecount != 0) {
                printf("\n");
            }
            lpyrJudge(sta, fin);
        }
        judgecount++;
    }
    return 0;
}
   
int lpyrJudge(int x, int y)
{
    int minmod4x;   //x??\?????????????°????4???????????°
    if (x % 4 == 0){
        minmod4x = x;
    } else {
        minmod4x = x - x % 4 + 4;
    }
    if (y - minmod4x < 0) {
        printf("NA\n");
    } else {
        for (int i = minmod4x; i <= y; i = i + 4) {
            if (i % 100 == 0) {
                if(i % 400 == 0) {
                    printf("%d\n", i);
                } else {    //??????????????????????????????
                }
            } else {
                printf("%d\n", i);
            }
        }
    }
    return 0;
}

C++: #include <iostream>

int main()
{
    int a = 0,b = 0;
    bool flag1,flag2;
    flag2 = false;
    while (true){
        flag1 = false;
        std::cin >> a >> b;
        if (a == 0 && b == 0){
            break;
}       if (flag2 == true){
            std::cout << std::endl;
}       flag2 = true;
        for (int i = a;i <= b;i++){
            if (i % 4 == 0 && i % 100 != 0){
                std::cout << i << std::endl;
                flag1 = true;
}
}
        if (flag1 == false){
            std::cout << "NA" << std::endl;
}
}
    return 0;
}