Go: package main

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

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		n, m := io.NextInt(), io.NextInt()
		if n == 0 {
			break
		}
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = io.NextInt()
		}
		ans := 0
		for i := 0; i < n; i++ {
			for j := i + 1; j < n; j++ {
				if a[i]+a[j] <= m {
					ans = intMax(a[i]+a[j], ans)
				}
			}
		}
		if ans == 0 {
			io.Println("NONE")
		} else {
			io.Println(ans)
		}
	}
}

func intMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
  int N,M;
  int A[1000];
  while(1){
    int N,M;
    cin>>N>>M;
    if(N==0&&M==0){
      break;
    }
    FOR(i,0,N){
      cin>>A[i];
    }
    VE S;
    FOR(i,0,N){
      FOR(j,i+1,N){
        S.PB(A[i]+A[j]);
      }
    }
    sort(S.begin(),S.end());
    int ans=0,now=0;
    while(1){
      if(S[now]<=M){
        ans=S[now];
        now++;
      }else{
        break;
      }
    }
    if(now==0){
      cout<<"NONE"<<endl;
    }else{
      cout<<ans<<endl;
    }
  }
  return 0;
}

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

int main(){
  while(true){
    int n,m;
    cin>>n>>m;
    if(n==0&&m==0){
      break;
    }
    int a[1000];
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    int sum=-1;
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
        int p = a[i]+a[j];
        if(p<=m&&p>sum){
          sum=p;
        }
      }
    }
    if(sum!=-1){
      cout<<sum<<endl;
    }else{
      cout<<"NONE"<<endl;
    }
  }
  return 0;
}

C++: #define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	while (true) {
		int n, m;
		cin >> n >> m;
		if (n == 0) return 0;
		vector<int> geko;
		REP(i, n) {
			int tmp;
			cin >> tmp;
			geko.push_back(tmp);
		}
		int ans = -1;
		for (int i = 0; i < n; ++i) {
			for (int q = i + 1; q < n; ++q) {
				if (geko[i] + geko[q] <= m) {
					ans = max(ans, geko[i] + geko[q]);
				}
			}
		}
		if (ans == -1) {
			cout << "NONE" << endl;
		}
		else cout << ans << endl;
	}
}

C++: #include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int goods[1010];

int main(){
	while(1){
		int n,m;
		cin >> n >> m;
		if(n + m == 0) break;
		for(int i = 0;i < n;i++){
			cin >> goods[i];
		}
		int ans = -1;
		for(int i = 0;i < n;i++){
			for(int j = i + 1;j < n;j++){
				if(goods[i] + goods[j] <= m){
					ans = max(ans,goods[i] + goods[j]);
				}
			}
		}
		if(ans == -1){
			cout << "NONE" << endl;
		}else{
			cout << ans << endl;
		}
	}

}

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

int main(){
 int max=0;
 int n, m;

while(true){
 cin >> n >> m;
 if(n==0&&m==0) break;

 int a[n];
 for(int i=0; i<n; i++){
  cin >> a[i];
 }

 for(int h=0; h<n-1; h++){
  for(int i=h+1; i<n; i++){
   if(a[h]+a[i]<=m && a[h]+a[i]>=max){
    max = a[h]+a[i];
   }
  }
 }

 if(max==0){
  cout << "NONE" << endl;
 }else{
  cout << max << endl;
 }
}
 
 return 0;
}