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 <bits/stdc++.h>

#define MOD 1000000007
#define INF (0x7fffffff)
#define NINF (1<<31)
#define INFL (0x7fffffffffffffff)
#define NINFL (1LL<<63)
#define MAX 100000000

#define pe(str) return cout<<(str)<<endl,0
#define px(str) cout<<(str)<<endl,exit(0)
#define accu(ac,v) cout<<setprecision(ac)<<v<<endl
#define bpc(a) __builtin_popcount(a)
#define pr(str) cout<<(str)<<endl
#define prpr(str) cout<<str<<endl
#define db(str) cerr<<"debug:"<<(str)<<endl
#define dbdb(str) cerr<<"debugs:"<<str<<endl
#define re(i,n) for(int i=0;i<(n);i++)
#define rre(i,n) for(int i=(n);i>=0;i--)
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b);i>=(a);i--)
#define bw(a,b,c) (((a)<=(b))&&((b)<=(c)))
#define hello cout<<"hello"<<endl
#define spre(a) setprecision(a)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define IF(C,T,F) ((C)?(T):(F))
#define max3(a,b,c) max((a),max((b),(c)))
#define min3(a,b,c) min((a),min((b),(c)))
#define max4(a,b,c,d) max((a),max((b),max((c),(d))))
#define min4(a,b,c,d) min((a),min((b),min((c),(d))))
#define enl cout<<endl
#define declare(t,n) t n;cin>>n
#define EPS 1e-6
#define EPSIN(a,b) ((b)-EPS<=(a)&&(a)<=(b)+EPS)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef complex<int> point;

template<class InputIterator>
void dump(InputIterator first,InputIterator last,char delim=' '){
	for(InputIterator it=first;it!=last;it++){
		if(it!=first)cout<<delim;
		cout<<*it;
	}
}

ull p(ull x,ull y){
	if(y==0) return 1;
	ull A=p(x,y/2)%MOD;
	// return (y&1?((A*A)%MOD*x)%MOD: (A*A)%MOD);
	return (y&1?((A*A)*x):(A*A));
}

template<class T>
void swp(T &a,T &b){
	T t=a; a=b; b=t;
}

template<class T>
int h(T first,string t){
	T it=first;
	int c=0;
	for(int i=0;i<t.size();i++){
		if(*it!=t[i]) c++;
		it++;
	}
	return c;
}

ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

int main(void){
	int n,m;
	while(cin>>n>>m,n||m){
	int a[n];
	int ans=0;
	re(i,n)cin>>a[i];
	re(i,n){
		rep(j,i+1,n){
			if(a[i]+a[j]<=m)ans=max(a[i]+a[j],ans);
		}
	}
	if(ans!=0)cout<<(ans)<<endl;
	else cout<<("NONE")<<endl;
	}
	return 0;
}

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

int main() 
{
    int num = 1,max = 1;
    int max_pri = 0;
    int i,j,k;
    int n=0,m,l;
    std::vector<int> res;
    while(1){
        cin >> num >> max;
        if(num==0&&max==0){
            break;
        }
        std::vector<int> vec(num);
        for(i=0;i<num;i++){
            cin >> vec[i]; 
        }
        for(i=0;i<num;i++){
            for(j=i+1;j<num;j++){
                if(max_pri<vec[i]+vec[j] && vec[i]+vec[j]<= max){
                    max_pri =  vec[i]+vec[j];
                }
            }
        }
        if(max_pri==0){
            res.push_back(-100);
        }else{
            res.push_back(max_pri);
        }
        max_pri = 0;
        n++;
    }
    for(i=0;i<n;i++){
        if(res[i]==-100){
            cout << "NONE" << endl;
        }else{
            cout << res[i] << endl;
        }
        
    }
    return 0;
}

C++: #include <iostream>
#define N 100000

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


  while(n!=0){
    int p=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-1;i++){
      for(int j=i+1;j<n;j++){
	tmp=a[i]+a[j];
	if(tmp>=A[k]&&tmp<=max){
	  A[k]=tmp;
	  p++; 
	}
      }
    }
    if(p==0) A[k]=0;

    if(A[k]!=0){
      std::cout<<A[k]<<"\n";
    }else{
      std::cout<<"NONE\n";

      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<cstdio>

int main(){
  int n,m;
  int A[10000];
  int max;
  bool flag = 1;

  std::scanf("%d %d",&n,&m);
  
  for(int i = 0;i < n;i++){
    std::scanf("%d",&A[i]);
  }
  
  max = A[0] + A[1];

  if(max > m){
    flag = 0;
  }
  
  for(int i = 0;i < n;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];
	flag = 0;
      }
    }
  }
  if(!(flag)){
    std::printf("%d\n",max);
  }else{
    std::printf("NONE\n");
  }

  return 0;
}

C++: #include<iostream>
#include<string>
#include<queue>
#include<utility>

using namespace std;

int main(){

  int n,m,l=0,ans[25000]={0};
  int a[1000]={0};

  while(n!=0 && m!=0){
    cin>>n>>m;
    //  cout<<n<<" "<<m<<endl;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }

  /* for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
  }
  */
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){

      if(i!=j && a[i]+a[j]<=m && a[i]+a[j]>ans[l]){
	  ans[l]=a[i]+a[j];
	}     
      
    }
  }

 
 
 
  l++;
  }
     

  for(int i=0;i<l-1;i++){
  if(ans[i]!=0){
    cout<<ans[i]<<endl;
  }else{
    cout<<"NONE"<<endl;
  }
  }


return 0;
}

C++: #include<iostream>
#include<string>
#include<queue>
#include<utility>

using namespace std;

int main(){

  int n,m,l=0,ans[25000]={0};
  int a[1000]={0};

  while(n!=0 && m!=0){
    cin>>n>>m;
    //  cout<<n<<" "<<m<<endl;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }

  /* for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
  }
  */
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){

      if(i!=j && a[i]+a[j]<=m && a[i]+a[j]>ans[l]){
	  ans[l]=a[i]+a[j];
	}     
      
    }
  }

 
 
 
  l++;
  }
     

  for(int i=0;i<l-1;i++){
  if(ans[i]!=0){
    cout<<ans[i]<<endl;
  }else{
    cout<<"NONE"<<endl;
  }
  }


return 0;
}