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 REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	while (cin >> n >> m, n) {
		vi v(n);
		REP(i, n)cin >> v[i];
		int ans = -INF;
		REP(i, n)FOR(j, i + 1, n) {
			if (v[i] + v[j] <= m)ans = max(ans, v[i] + v[j]);
		}
		if (ans != -INF)cout << ans << endl;
		else cout << "NONE" << endl;
	}
}

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<<"NOME"<<endl;
		}
	}

			
	
return 0;
}

C++: #include <iostream>

#include <vector>

#include <cassert>

#include <algorithm>

#include <functional>

#include <cmath>

#include <iomanip>

#include <limits>
#include <bits/stdc++.h>
#include<queue>
#include<type_traits>
#include<cstdint>
using namespace std;
using ll=long long;
int main(){
    
    while(1){
        int count=0;
    int n,m;
    cin >> n >> m;
    if(n==0){
        break;
    }
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        vec[i]=x;
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(vec[i]+vec[j]<=m){
                count = max(count,vec[i]+vec[j]);
            }
        }
    }
    if(count==0){
        cout << "NONE"<<endl;
    }else{
    cout << count <<endl;
    }
    }
}

C++: #include <iostream>
#define MAX 1000
using namespace std;
int a[MAX];

int main(){
    while(true){
        int n,m,maxsum = 0;
        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 -1;i++){
            for(int j = i + 1;j < n;j++){
                if((a[i] + a[j] <= m))
                    maxsum = max(maxsum,a[i] + a[j]);
            }
        }

        if(maxsum == 0)
            cout << "NONE" << endl;
        else
            cout << maxsum << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
  int i,n,m,j;
  vector<int> ans;
  while(1){
    cin>>n>>m;
    if(n==0 && m==0) break;
    vector<int> item(n);
    for(i=0; i<n; i++){
      cin>>item[i];
    }
    int max=0;
    int sum;
    for(i=0; i<n-1; i++){
      for(j=i; j<n; j++){
	sum=0;
	sum=item[i]+item[j];
	if(sum>max && sum<m+1){
	  max=sum;
	}
      }
    }
    if(max==0){
      ans.push_back(-1);
    }else{
    ans.push_back(max);
    }
  }
  for(i=0; i<ans.size(); i++){
    if(ans[i]==-1){
      cout<<"NONE";
    }else{
      cout<<ans[i];
    }
    cout<<endl;
  }
  cout<<endl;
  return 0;
}

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

using namespace std;

int main(){

  int n,m;
  vector<int> a(1000);
  int sum=0;
  int max=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=0;i<n-1;++i){
	  for(int j=i+1;j<n;++j){
	   
		sum=a[i]+a[j];
		
		if(sum>max && sum<=m)
		  max = sum;
			
	  }
	}

	cout<<max<<endl;
	
  }

  return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]){
	int i, j,p,q,r, n, m,max = -1;
	int *a;
    for(i=0;; i++){
		scanf("%d %d",&n,&m);
		if (n == 0 && m == 0) break;
		a = (int *)malloc(n * sizeof(int));
		for (j = 0; j < n; j++) {
			scanf("%d", &a[j]);
		}
		for (p = 0; p < n - 1; p++) {
			for (q = p + 1; q < n; q++) {
				if (a[p] + a[q] <= m && a[p] + a[q] > max) {
					max = a[p] + a[q];
				}
			}
		}
		if (max == -1) printf("NONE\n");
		else printf("%d\n", max);
		max = -1;
		/*
        fgets(a, 203, stdin);
		//if (i != 0) printf("\n");
        fgets(b, 203, stdin);
		if (a[0] == '0' && a[1] == '0') break;
        cmpr1(a,b);
		printf("\n");*/
		free(a);
    }
}
/*
void cmpr1(char *a, char *b){
	int i = 0, j = 0;
    int q=0, f=0, g=0;
	for (int i = 0; i < 203;) {
        if(a[i] == '\n' || b[j] == '\n') {
			if (a[i] == b[j]){
				if (!f) {
					printf("IDENTICAL");
				}
				else {
					printf("CLOSE");
				}
				return;
			}
			printf("DIFFERENT");
            return;
        }
		if (!f && a[i] == '"' && b[j] == '"') {
			i++;
			j++;
			while (1) {
				if (a[i] == '"') {
					if (a[i] == b[j]) {
						break;
					}
					else {
						while (b[j] != '"') j++;
						f = 1;
						break;
					}
				}
				if (b[j] == '"') {
					while (a[i] != '"') i++;
					f = 1;
					break;
				}
				if (a[i] != b[j]) f = 1;
				i++;
				j++;
			}
		}
        if(a[i] != b[j]) {
            if(q){
                f = 1;
            }
            else{
                printf("DIFFERENT");
                return;
            }
        }
		i++;
		j++;
    }
    printf("ERROR");
}*/