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 <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

int testcase_ends() {
  size_t m;
  size_t nmin, nmax;
  scanf("%zu %zu %zu", &m, &nmin, &nmax);

  if (m == 0 && nmin == 0 && nmax == 0) return 1;

  std::vector<int> P(m);
  for (auto& pi: P) scanf("%d", &pi);

  std::sort(P.rbegin(), P.rend());
  size_t res = 0;
  int gap = 0;
  for (size_t i = m; i--;) {
    if (i > nmax) continue;
    if (i < nmin) break;
    if (gap < P[i-1]-P[i]) {
      gap = P[i-1]-P[i];
      res = i;
    }
  }
  printf("%zu\n", res);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b;
ll i,j,k;
ll x[100005];

bool solve(){
	cin >> n >> a >> b;
	if(n + a + b == 0){
		return false;
	}
	for(i=0;i<n;i++){
		cin >> x[i];
	}
	ll num = -100;;
	ll ansind = -1;
	for(i=a-1;i<b;i++){
		ll sa = x[i] - x[i+1];
		if(sa >= num){
			num = sa;
			ansind = i;
		}
	}
	cout << ansind + 1<< endl;
	return true;
}


int main(){
	while(solve());
	return 0;
	
}

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

using namespace std;

#define reps(i,f,n) for(int i=f; i<n; ++i)
#define rep(i,n) reps(i,0,n)

int main()
{
    int m, a, b;
    
    while(cin >> m >> a >> b, m){
        vector<int> pt(m);
        for(int i=0; i<m; ++i){
            cin >> pt[i];
        }
        
        pair<int, int> ans{-1, -1};
        
        rep(p, 10000){
            vector<int> ok, ng;
            
            rep(i, m){
                if(pt[i] < p) ng.push_back(pt[i]);
                else ok.push_back(pt[i]);
            }
            
            int n = ok.size();
            if(a <= n && n <= b){
                int gap = *min_element(ok.begin(), ok.end()) - *max_element(ng.begin(), ng.end());
                ans = max(ans, {gap, ok.size()});
            }
        }
        
        cout << ans.second << endl;
    }
}

C++: #include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template <typename T> inline
#define USE2(T, U) template <typename T, typename U> inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
 
template<typename T> using vec = std::vector<T>;
template<typename T> using withi = std::pair<T, int>;
using ll = long long;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE2(T,U=withi<T>)vec<U>zipi(const vec<T>&x,int s=0){int N=x.size();vec<U>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  int M, mi, ma;
  while (M = in(), mi = in(), ma = in(), M || mi || ma) {
    auto P = in(M);
    int gap = 0;
    int ans = 0;
    for (int border : P) {
      int lo = inf, hi = -inf;
      int pass = 0;
      for (int p : P) {
        if (border <= p) {
          pass++;
          chmin(lo, p);
        } else {
          chmax(hi, p);
        }
      }
      int g = lo - hi;
      if (mi <= pass && pass <= ma) {
        if (chmax(gap, g) || g == gap) chmax(ans, pass);
      }
    }
    pr(ans);
  }

  return 0;
}

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

int main () {
  int m, nmin, nmax, tempa, tempb, sa=0;
  while(cin >>m>>nmin>>nmax) {
    int temp = 0;
    sa = 0;
    if(m == 0 && nmin == 0 && nmax == 0)break;
  cin>> tempa;
  for (int i=1;i<m;i++) {
    cin>> tempb;
    if(nmin <= i&& i<= nmax&&sa <= tempa - tempb) {
      sa = tempa - tempb;
      temp = i;
    }
    tempa = tempb;
  }
  cout << temp<< endl;
}
  return 0;
}

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

int main(){
	while(1){
		int m,nmin,nmax;
		
		cin>> m>>nmin>>nmax;
		
		if(m==0 && nmin==0 && nmax == 0)
			break;
			
		int P[m];
		for(int i=0; i<m ;i++){
			cin>>P[i];
		}
		
		int maxgap=0;
		int chosen=0;
		for(int i=nmin-1; i<nmax; i++){
			
			if(maxgap <= (P[i]-P[i+1])){
				maxgap=P[i]-P[i+1];
				chosen=i+1;
			}
		}
		cout<<chosen<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps=1e-8;
int main() {
	int n, s, g;
	while (cin >> n >> s >> g, n) {
		int x[300];
		rep(i, n) {
			cin >> x[i];
		}
		sort(x, x + n,greater<int>());
		int ma = 0; int chk;
		Rep1(i,s,g) {
			if (ma <= x[i - 1]-x[i]) {
				ma = x[i - 1] - x[i]; chk = i;
			}
		}
		cout << chk << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int main()
{
    int m, min, max;
    cin >> m >> min >> max;
    vector<int> v;
    loop(m, i) {
        int j; cin >> j;
        v.push_back(i);
    }

    int gap = 0;
    int ans = 0;
    for (int i = min; i < max; i++) {
        if (gap < v[i-1] - v[1]) {
            gap = v[i-1] - v[1];
            ans = i;
        }
    }
    cout << ans << endl;
}