Go: // Entrance Examination(入学試験)
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1600&lang=jp
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for {
		m, nMin, nMax := nextInt(sc), nextInt(sc), nextInt(sc)
		if m == 0 && nMin == 0 && nMax == 0 {
			break
		}

		points := []int{}
		for i := 0; i < m; i++ {
			points = append(points, nextInt(sc))
		}

		gapMax, pass := 0, 0
		for n := nMin; n <= nMax; n++ {
			gap := points[n-1] - points[n]
			if gap >= gapMax {
				gapMax, pass = gap, n
			}
		}

		fmt.Println(pass)
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, ll> P;
#define MOD (1000000007ll)

int main(void){
	int m,l,r,p[222],ans,mx,i;
	cin >> m >> l >> r;
	while(m || l || r){
		mx = 0;
		for(i=0; i<m; ++i){
			cin >> p[i];
		}
		for(i=l; i<=r; ++i){
			if(mx <= p[i-1] - p[i]){
				mx = p[i-1] - p[i];
				ans = i;
			}
		}
		cout << ans << endl;
		cin >> m >> l >> r;
	}
}

C++: #include <iostream>
#include <vector>
#include <stdlib.h> //for exit
#include <algorithm> //for sort...etc
#include <numeric> //for accumulate
using namespace std;

int main()
{
    int m,nmin,nmax;
    while(1){
        int score_max=-10000, n_max=-1;
        
        vector<int> scores;
        cin >> m >> nmin >> nmax;
        if(m==0 && nmin==0 && nmax==0) exit(0);
        for(int i = 0 ; i < m; ++i)
        {
            int tpscore;
            cin >> tpscore;
            scores.push_back(tpscore);
        }

        sort(scores.rbegin(),scores.rend());

        for(int i = nmin-1; i < nmax; ++i)
        {
            //cout << "score is " << scores[i]-scores[i+1] << endl;
            if(scores[i]-scores[i+1] >= score_max) 
            {
                score_max = scores[i]-scores[i+1];
                n_max = i+1;
            }
            //cout << "I was compared " << scores[i] << " and " << scores[i+1] << endl;
            //cout << "i is " << i << ". nmax is " << n_max << ". scoremax is "<< score_max << endl;
        }
        if(n_max!=-10000) cout << n_max << endl;
    }

}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<=b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>=b){a=b;return true;}return false;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);
    while(true){
        int M,nl,nr; cin >> M >> nl >> nr;
        if(M==0) break;
        int A[M]; rep(i,M) cin >> A[i];
        int ans;
        int pos=-1;
        rng(i,nl-1,nr){
            if(chmax(pos,A[i]-A[i+1])) ans=i+1;
        }
        cout << ans << "\n";
    }
}

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

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	for(int m, n_min, n_max; cin >> m >> n_min >> n_max && m;) {
		vector<int> p(m);
		for(auto &e : p) cin >> e;

		int ans = -1;
		int mx = -1;
		for(int n = n_min; n <= n_max; ++n) {
			const int gap = p[n - 1] - p[n];
			if(mx <= gap) {
				ans = n;
				mx = gap;
			}
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main()
{
        int m,ni,na;
        while(cin>>m>>ni>>na,m)
        {
                vector<int> p(m);
                REP(i,m)
                {
                        cin>>p[i];
                }
                sort(p.begin(), p.end());
                int md=0,mp=ni;
                FOR(i, m-na, m-ni+1)
                {
                        if(p[i]-p[i-1]>md)
                        {
                                //cout<<md<<i<<endl;
                                md=p[i]-p[i-1];
                                mp=m-i;
                        }
                }
                cout<<mp<<endl;
        }
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1600&lang=jp>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int m,nmin,nmax;
ll solve(){
    ll res = 0;
    vector<ll> score(m); for(auto& in:score) cin >> in;
    ll min = -1;
    for(int i = nmin-1; i < nmax;i++){
        if(score[i]-score[i+1] >= min){
            min = score[i] - score[i+1];
            res = i+1;
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> m >> nmin >> nmax,m){
        cout << solve() << endl;
    }
    return 0;
}

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

int main(){
 while(true){
  int m, n_min, n_max;
  cin >> m >> n_min >> n_max;
  if(m==0 && n_min==0 && n_max==0) break;

  int P[m];
  for(int i=0; i<m; i++){
   cin >> P[i];
  }

  int gap = -1;
  int n = -1;
 
  for(int i=n_min; i<n_max; i++){
   int g = P[i-1]-P[i];
   if(gap<=g){
    gap = g;
    n = i;
   }
  }
  
  cout << n << endl;
 }

 return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)

using namespace std;

int main(void){
    
    int student = 0;
    int maxN,minN = 0;
    int gap = 0,gapMax = 0,gapnumber  = 0;
    int score[1020] = {0};
    
    while(cin >> student >>minN >>maxN,student+maxN+minN)
    {
        REP(i,student)
        cin >> score[i];
  
    
    FOR(j,minN-1,maxN+1)
        {
            gap = score[0] - score[j];
            if(gapMax <= gap)
            {
                gapnumber = j;
                gapMax = gap;
                
            }
        }
        cout << gapnumber << endl;
    
    }
    return 0;
}