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>

int main(){
    int n,m;
    int tmp;
    int ans;
    bool flag;
    std::vector<int> p;
    std::cin >> n;
    std::cin >> m;

    while(n!=0 && m!=0){
        ans =-1;
        flag = false;
        for(int i=0;i<n;i++){
            std::cin >> tmp;
            p.push_back(tmp);
        }
        std::sort(p.begin(),p.end());
        for(int i=n-1;i>0;i--){
            for(int j=i-1;j>=0;j--){
                if(p[i]+p[j] <= m){
                    if(p[i] + p[j] > ans){
                        ans = p[i] + p[j];
                        flag = true;
                        break;
                    }
                }
            }
            if(flag){
                break;
            }
        }
        if(ans==-1){
            std::cout << "NONE\n";
        }else{
            std::cout << ans <<"\n";
        }
        std::cin >> n;
        std::cin >> m;
    }
    return 0;
}

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

int main(){
	int n,m,a[1000],dp[1001],b=0;
	dp[0]=0;
	while(1){
		cin>>n>>m;
		if(n==0&&m==0)break;
		for(int i=0;i<n;i++)cin>>a[i];
		for(int i=1;i<=n;i++){
			dp[i]=max(dp[i-1],b+a[i-1]);
			b=max(b,a[i-1]);
		}
		cout<<dp[n]<<endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
using pii = pair<int, int>;
using vi = vector<int>;
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
int di[] = {0, 0, -1, 1, -1, 1, -1, 1}; //右、左、マイナス、プラス
int dj[] = {1, -1, 0, 0, -1, 1, 1, -1};
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
//manip
template<class T> bool chmax(T &a, T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, T &b) {if (a > b) {a = b; return 1;} return 0;}
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power(T a, T b)
{return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0






int main() {
    //cast caution
    //look constraints always
    cin.tie(0); ios::sync_with_stdio(false);
    
    
    
    
    
    
    
    int n, m;
    while (cin >> n >> m && n) {
        int a[n];
        rep(i, n) cin >> a[i];
        int ans = 0;
        rep(i, n) {
            int tmp = a[i];
            rep(j, n) {
                
                if (i == j) continue;
                
                if (tmp + a[j] >  m) continue;
                ans = max(ans, tmp + a[j]);
            }
        }
        if (ans == 0) cout << "NONE" << endl;
        else cout << ans << endl;
    }
    
    
    
    
    
    
    
}
//cast caution

C++: int a[1000];

int main(void)
{
  while (1) {
    int n, m, max = -1;
    cin >> n >> m;
    if (n == 0) {
      break;
    }
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }

    for (int i = 0; i < n - 1; ++i) {
      for (int j = i + 1; j < n; ++j) {
	if (max < a[i] + a[j] && a[i] + a[j] <= m) {
	  max = a[i] + a[j];
	}
      }
    }
    if (max == -1) {
      cout << "NONE" << endl;
      continue;
    }
    cout << max << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long ll;
int main()
{
	int n,m;
	while(scanf("%d%d",&n,&m)!=EOF&&n!=0)
	{
		int  f[1500]={0};
		bool flag=false;
		for(int i=0;i<n;i++)
		scanf("%d",&f[i]);
		sort(f,f+n);
		int l=0,r,ans=0;
		for(int i=0;i<n;i++)
		{
			int s=m-f[i];
			int j=upper_bound(f,f+n,s)-f;
			j--;
			if(j==i)
			j--;
			if(j>=0&&j<n&&(f[i]+f[j]<=m))
			{
				flag=true;
				ans=max(ans,f[i]+f[j]);
			}
		} 
		if(flag)
		printf("%d\n",ans);
		else
		printf("NONE\n");
	}
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9+7;

#define sx(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a),end(a)

int main(void) {
    ll n,m;
    while(cin >> n >> m,n) {
        vector<ll> a(n);
        REP(i,n) cin >> a[i];
        sort(ALL(a),greater<ll>());
        ll ans = -1;
        REP(i,n) REP(j,n) {
            if (a[i]+a[j] <= m) {
                if (i == j) continue;
                ans = max(a[i]+a[j],ans);
            }
        }
        if (ans == -1) {
            cout << "NONE" << endl;
            continue;
        }
        cout << ans << endl;
    }
    return 0;
}