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>

using namespace std;

int main(){

  int n=1,kakaku=1,min1,min2=10000000,a,b,c,i,j,k=0;
  vector<int> min3(50000,10000000);
  while(n!=0&&kakaku!=0){
    min2=10000000;
    cin>>n;
    vector<int> s(n);
    cin>>kakaku;

    for(i=0;i<n;i++){
      cin>>s.at(i);
    }

    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	if(i!=j){
	  a=s.at(i);
	  b=s.at(j);
	  c=a+b;
	  min1=kakaku-c;
	  if(min2>min1&&min1>=0){
	    min2=min1;
	    min3[k]=c;
	  }
	}
      }
    }
    k++;
  }
  for(i=0;i<k-1;i++){
    if(min3.at(i)==10000000){
      cout<<"NONE"<<endl;
    }else{
      cout<<min3.at(i)<<endl;
    }
  }
  return 0;
}

C++: #include <stdio.h>
int max(int a, int b){
    if(a > b)
    return a;
    else
    return b;
}

int main(){
    while(true){
	int n, m, i, j, k, tmp;
	int result = 0;
	scanf("%d%d\n", &n, &m);
	if(n == 0 && m ==0)
	    break;
	int a[n];
	for (i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	for(int i = 0; i < n; i++){
	    for (j = i + 1; j < n; j++){
	        tmp = a[i] + a[j];
	        if(tmp <= m){
	            result = max(result, tmp);
	        }
	    }
	}
	if(result != 0)
	printf("%d\n", result);
	else
	printf("NONE");
    }
	return 0;	
}

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

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

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

using namespace std;
using LL = long long;

int main(){
    int n,m;
    while(cin >> n >> m){
        if(n == 0 && m == 0)continue;
        vector<int> vec;
        for(int i = 0;i < n;i++){
            int b;cin >> b;
            vec.push_back(b);
        }
        int ans = -1;
        for(int i = 0;i < n-1;i++){
            for(int j = i + 1; j < n;j++){
                if(vec.at(i) + vec.at(j) <= m)ans = max(ans, vec.at(i) + vec.at(j));
            }
        }
        if(ans == -1){
            cout<<"NONE"<<endl;
            continue;
        }
        cout<<ans<<endl;
    }
}

C++: #include <stdio.h>
int max(int a, int b){
    if(a > b)
    return a;
    else
    return b;
}

int main(){
    while(1 == 1){
	int n, m, i, j, k, tmp;
	int result = 0;
	scanf("%d%d", &n, &m);
	if(n == 0 && m ==0)
	    break;
	int a[n];
	for (i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	for(int i = 0; i < n; i++){
	    for (j = i + 1; j < n; j++){
	        tmp = a[i] + a[j];
	        if(tmp <= m){
	            result = max(result, tmp);
	        }
	    }
	}
	if(result != 0){
	    printf("%d\n", result);
	}else{
	printf("NONE");
    }
    }
	return 0;	
}

C++: #include <iostream>
#include <vector>
#include <stdlib.h> //for exit
#include <algorithm> //for sort...etc
#include <numeric> //for accumulate
using namespace std;

int main()
{
    while(1)
    {
        int n,m,sum=-100;
        vector<int> prices;
        cin >> n >> m;
        if(n == 0 && m == 0) exit(0);
        for(int i = 0 ; i < n; i++)
        {
            int tpprice;
            cin >> tpprice;
            prices.push_back(tpprice);
        }

        for(int i = 0; i < n; i++)
        {
            for(int k = 0; k < n; k++)
            {
                if(((prices[i] + prices[k]) > sum) && (prices[i] + prices[k]) <= m && (i!=k))
                {
                    sum = prices[i] + prices[k];
                }
            }
        }

        if(sum == -100){ cout << "NONE" << endl; }
        else{ cout << sum << endl; }   
    }
}

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

using namespace std;

#define INF 1e9

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    while(1){
        long long n,m;
        cin>>n>>m;

        if(n==0)break;

        vector<long long> a(n);

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

        long long ans=-1;

        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                long long sum=a[i]+a[j];

                if(sum<=m && sum>ans)ans=sum;
            }
        }

        if(ans==-1)cout<<"NONE"<<endl;
        else cout<<ans<<endl;

    }

}

C++: //#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
 
 
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

void solve(ll n,ll m){
    vector<ll> v(n);
    FOR(i,0,n)cin>>v[i];

    ll x = -1;
    FOR(i,0,n){
        FOR(j,i+1,n){
            if(m>=v[i]+v[j])x = max(x,v[i]+v[j]);
        }
    }
    if(x == -1) cout<<"NONE"<<endl;
    else cout<<x<<endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n,m;
    cin>>n>>m;
    while(n!=0){
        solve(n,m);
        cin>>n>>m;
    }
}