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 pb push_back
using namespace std;

void solve(int n, int k) {
    vector<int> v;
    for (int i = 0; i < n; i++) { 
        int x;
        cin >> x;
        v.pb(x);
    }
    sort(v.begin(), v.end());

    int ans = -1;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (k >= v[i] + v[j] && k - v[i] - v[j] < k - ans) ans = v[i] + v[j];
        }
    }
    if (ans == -1) cout << "NONE" << endl;
    else cout << ans << endl;
}

int main() {
    cin.tie(0);
    while (1) {
        int n, k;
        cin >> n >> k;
        if (n == 0 && k == 0) break;
        solve(n, k);
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
  vector<int> a;
  int n,m,b,max=0;
  while(n!=0 && m!=0){
    max=0;
    cin>>n>>m;
    for(int i=0;i<n;i++){
      cin>>b;
      a.push_back(b);
    }
  
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
	if(j!=k){
	  if(max<a[j]+a[k] && a[j]+a[k]<=m){
	    max=a[j]+a[k];
	    cout<<max<<"\n";
	  }
	}
      }
    }
    a.clear();
    if(max==0 && n!=0&&m!=0){
      cout<<"NONE"<<endl;
    }else if(n!=0&&m!=0){
      cout<<max<<endl;
    }
  }
}

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

int main(){
	int pay,n,m;
	while(true){
		n=0;
		m=0;
		pay=0;	
		cin>>n>>m;
		if(n==0&&m==0){
			break;
		}
		int a[n];
		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++){
					if(a[i]+a[j]<=m&&a[i]+a[j]>=pay){
						pay=a[i]+a[j];
					}
				}
		}
		cout<<pay<<endl;
	}
	return 0;
	
}

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

int main()
{
  int n, m, MAX = 0, SUM;
  int a, size;
  vector<int> v;

  while(cin >> n >> m, n) {

    for (int i = 0; i < n; i++) {
      cin >> a;
      v.push_back(a);
    }

    for (int i = 0; i < v.size(); i++) {
      for (int j = i+1; j < v.size(); j++) {
	SUM = v[i] + v[j];
	if (SUM <= m) {
	  MAX = max(MAX, SUM);
	  //cout << MAX << endl;
	}
      }
    }
    
    if (MAX==0) {
      cout << "NONE" << endl;
    }
    else {
      cout << MAX << endl;
    }
    
  }
  
  return 0;
}

C++: 
#include <cstdio>

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

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

    return 0;
}

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

int main(){
    int n,m;
    while(true){
        cin>>n>>m;
        if(n==0&&m==0)break;
        int goods[n];
        for(int i=0;i<n;i++)
            cin>>goods[i];
        int maximum=0;
        for(int i=0;i<n-1;i++){
            for(int j=i+1;j<n;j++){
                if(goods[i]+goods[j] <= m)
                    if(goods[i]+goods[j] > maximum)
                        maximum = goods[i]+goods[j];
            }
        }
        cout<<maximum<<endl;
    }
}

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

using namespace std;
const int MAX_N = 1024;

int kk[MAX_N*MAX_N + 1];

int n, m, Max;
int a[1024];


int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int solve(void) {


	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			if(Max < a[i] + a[j] && i != j && a[i] + a[j] < m)
			Max = a[i] + a[j];

	qsort(kk, n * n, sizeof(int), compare_int);

	cout << Max << endl;

}

int main(void) {
	while(1) {
	Max = 0;
	cin >> n >> m;
	for(int i = 0; i < n; ++i)
		cin >> a[i];
 
	solve();
	}
}

C++: #include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>

int main()
{
 
 int n,m;
 while(scanf("%d%d",&n,&m)==2){
     if(n==0 && m==0){
         break;
     }
     else
     {
         int a[1010];
        for(int i=0;i<n;i++){
            scanf("%d",&a[i]);
        }
        int max = 0;
        for(int i=0;i<n-1;i++){
            for(int j=i+1;j<n;j++){
                if(a[i]+a[j]>max && a[i]+a[j]<=m){
                    max = a[i]+a[j];
                }
            }
        }
        if (max==0){
            printf("NONE\n");
        } 
        else{
            printf("%d\n",max);
        }

     }
     
 }
    return 0;
}