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<stdio.h>

#define MAX 2000000

int select(int S[],int n,int max){
  int ans=0;
  int temp;
  for(int i = 0;i<n;i++){
    for(int j = i+1;j<n;j++){
      temp = S[i]+S[j];
      if(temp <= max && ans <= temp){
	ans = temp;
      }
    }
  }

  return ans;
}

int main(){
  int n;
  int a;
  int m;
  
  int S[MAX];

  scanf("%d",&n);
  scanf("%d",&m);

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

  int ans = select(S,n,m);

  if(ans==0){
    printf("NONE\n");
  }else{
    printf("%d\n",ans);
      }
  
      return 0;
}

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

int main() {
    int n, m, a;
    int item[1000];
    while (cin >> n >> m, n||m) {
        int sum  = -1;
        for (int i = 0; i < n; ++i) {
            cin >> a;
            item[i] = a;
        }

        for (int i = 0; i < n-1; ++i) {
            for (int j = i+1; j < n; ++j) {
                int tmp = item[i] + item[j];
                if (tmp <= m && tmp > sum) {
                    sum = tmp;
                }
            }
        }

        if (sum < 0) cout << "NONE" << endl;
        else cout << sum << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
    while(true){
        int n,m;
        int a[10000];
        cin>>n>>m;
        if(n==0)break;
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        int ans=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(a[i]+a[j]<=m){
                    if(i==j)continue;
                    ans = max(ans,a[i]+a[j]);
                }
            }
        }
        if(ans==0)cout<<"NONE"<<endl;
        else cout<<ans<<endl;
    }
    return 0;
}

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

int main() {
	int N, M;
	while (cin >> N >> M) {
		if (N == 0 && M == 0) return 0;
		vector<int> A(N);
		for (int i = 0; i < N; i++) cin >> A[i];
		int MAX = -1;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (i == j) continue;
				if (A[i] + A[j] <= M) MAX = max(MAX, A[i] + A[j]);
			}
		}
		if (MAX == -1) cout << "NONE" << endl;
		else cout << MAX << endl;
	}
}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, M;
  while ( cin >> N >> M, N ) {

    vector<int> a(N);
    for ( int i = 0; i < N; i++ ) {
      cin >> a[i];    
    }

    int ans = 0;
    for ( int i = 0; i < N; i++ ) {
      for ( int j = i+1; j < N; j++ ) {
	if ( i == j ) continue;	
	if ( a[i]+a[j] <= M ) ans = max(ans, a[i]+a[j]);
      }
    }

    if ( ans == 0 ) puts("NONE");
    else cout << ans << endl;
  }
  
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>

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

    while(n!=0 && m!=0){
        
        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--){
            if(p[i] + p[i-1] < m){
                ans = p[i] + p[i-1];
                break;
            }
            if(i==1){
                ans = -1;
            }
        }
        if(ans==-1){
            std::cout << "NONE\n";
        }else{
            std::cout << ans <<"\n";
        }
        std::cin >> n;
        std::cin >> m;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,a;
    while (cin>>n>>m) {
        if (n==0&&m==0) {
            break;
        } else {
            std::deque<int> deq;
            for (int i=0;i<n;i++) {
                cin>>a;
                deq.emplace_back(a);
            }
            int max=0;
            for (int j=0;j<n-1;j++) {
                for (int k=j+1;k<n;k++) {
                    if (deq[j]+deq[k]<=m) {
                        if (deq[j]+deq[k]>max) {
                            max=deq[j]+deq[k];
                        }
                    }
                }
            }
            if (max!=0) {
                cout<<max<<endl;
            } else {
                cout<<"NONE"<<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", &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 <bits/stdc++.h>
using namespace std;

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

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