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<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(false);

	ll n, m;
	while (true) {
		cin >> n >> m;
		if (n == 0 && m == 0) break;
		vi v(n);
		ll ans = 0;
		rep(i, n) cin >> v[i];
		rep(i, n) {
			rep(j, n) {
				if (i == j) break;
				if (v[i] + v[j] == m) {
					ans = m;
				}
				else {
					if (ans < v[i] + v[j] && v[i] + v[j] < m)
						ans = v[i] + v[j];
				}
			}
		}
		if (ans == 0) puts("NONE");
		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++: #include <iostream>
#define N 100000

int main(){
  int n,max;
  int A[N]={0},k=0;


  while(1){
    int p=0,sum=0,tmp;
    std::cin>>n;
    int a[n]={0};
    std::cin>>max;
    if(n==0){
      break;
    }
  for(int i=0;i<n;i++){
      std::cin>>a[i];
    }
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	tmp=a[i]+a[j];
	if(tmp>=sum&&tmp<=max){
	  sum=tmp;
	  p++; 
	}
      }
    }
    if(p!=0) {
      A[k]=sum;
      k++;
    }else {
      A[k]=0;
      k++;
    }
    //if(p!=0) std::cout<<sum<<"\n";
    //else std::cout<<"NONE\n";
  }
  for(int i=0;i<k;i++){
    if(A[i]!=0){
      std::cout<<A[i]<<"\n";
    }else{
      std::cout<<"NONE\n";
    }
  }



}

C++: #include <bits/stdc++.h>
using namespace std;

const int MAXN = 1005;
int n, m;
int a[MAXN];

bool input() {
    scanf("%d %d", &n, &m);
    if ( !n && !m ) return 0;
    for (int i = 0 ; i < n ; i++ ) {
        scanf("%d", &a[i]);
    }
    return 1;
}

void solve() {
    int mx = 0;
    for (int i = 0 ; i < n ; i++ ) {
        for (int j = i + 1 ; j < n ; j++ ) {
            if ( a[i] + a[j] <= m ) {
                mx = max(mx, a[i]+a[j]);
            }
        }
    }
    if (mx == 0) puts("NONE");
    else printf("%d\n", mx);
}

int main(){
    while(input()) {
        solve();
    }
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n,m;
  while(cin>>n>>m,n+m){
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(a[i]+a[j]<=m)
	ans=max(ans,a[i]+a[j]);
    }
  }
  if(ans==0)
    cout<<"NONE"<<endl;
  else
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n, m;
	while(cin>>n>>m, n!=0){
		ll ans=0;
		vll a(n);
		rep(i, n) cin>>a[i];
		for(int i=0; i<n; i++)
			for(int j=i+1; j<n; j++)
				if (a[i]+a[j] <= m)
					ans = max(ans, a[i]+a[j]);

		if (ans!=0)
			cout << ans << "\n";
		else
			cout << "NONE\n";
	}
	return 0;
}

C++: #include<stdio.h>

#define MAX 2000000

int select(int S[],int n,int max){
  int ans=0;
  int temp;
  for(int i = 0;i<n;i++){
    for(int j = i+1;j<n;j++){
      temp = S[i]+S[j];
      if(temp <= max && ans <= temp){
	ans = temp;
      }
    }
  }

  return ans;
}

int main(){

  int n;
  int a;
  int m;
  int k =0;
  int ans[100000];
  int S[MAX];

  while(1){
    scanf("%d",&n);
    scanf("%d",&m);
    if(n==0 && m == 0){
      break;
    }
    for(int i = 0;i<n;i++){
      scanf("%d",&a);
      S[i] = a;
    }

    ans[k] = select(S,n,m);
    k++;
  }


  for(int i = 0;i<k;i++){
    if(ans[i]==0){
      printf("NONE\n");
    }else{
      printf("%d\n",ans[i]);
    }
  }
  return 0;
}