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;
int main(){
  int m,ni,na,i,j,k,ans,idx;
  while(cin>>m>>ni>>na,m||ni||na){
    int p[m];
    for(i=0;i<m;i++) cin>>p[i];
    sort(p,p+m);
    ans=0;
    idx=ni;
    for(i=ni;i<=na;i++){
      //cout<<p[m-i]-p[m-i-1]<<endl;
      if(p[m-i]-p[m-i-1]>=ans){
	ans=p[m-i]-p[m-i-1];
	idx=i;
      }
    }
    cout << idx << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  while calc();
}

bool calc(){
  int m, nMax, nMin;
  cin >> m >> nMax >> nMin;
  if(m == 0 && nMax == 0 && nMin == 0) return false;

  int p[m];
  for(int i = 0; i < m; i++) cin >> p[i];

  sort(p, p + m);

  int maxPoint = -1;
  int index = 0;
  for(int i = m - 1; i > 0; i--){
    int calc = p[i] - p[i - 1];
    if(maxPoint <= calc){
      maxPoint = calc;
      index = i;
    }
  }

  cout << m - index << endl;
  return true;
}

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

int main() {
        int m, nmin, nmax;
        while( cin >> m >> nmin >> nmax, m || nmin || nmax ) {
                vector<int>P( m );
                for( size_t i = 0; i < m; i++ ) {
                        cin >> P[i];
                }
                int ans = 0;
                int sub = 0;
                for( size_t i = nmin; i <= nmax; i++ ) {
                        if( sub <= P[i - 1] - P[i] ) {
                                sub = P[i - 1] - P[i];
                                ans = i;
                        }
                }
                cout << ans << endl;
        }
}

C++: #include<bits//stdc++.h>
using namespace std;
int main(){
	int m,minn,maxn;
	while(cin>>m>>minn>>maxn&&m!=0){
		int a[200];
		for(int i=0;i<m;i++){
			cin>>a[i];
		}
		sort(a,a+m);
		reverse(a,a+m);
		int go=-1;
		int n=0;
		for(int i=minn;i<=maxn;i++){
			if(go<a[i-1]-a[i]){
				go=a[i-1]-a[i];
				n=i;
			}
			else if(go==a[i-1]-a[i]){
				n=i;
			}
		}
		cout<<n<<endl;
	}
}

C++: #include <stdio.h>

int main()	{

	int m, nmin, nmax, curr, next, res, gap, gapmax;

	while (true)	{

		scanf("%d %d %d", &m, &nmin, &nmax);

		if (m == 0)	{ break; }

		gapmax = -1;
		gap = -1;

		// res番目の点数を入力したところで、
		// res-1番目が合格するかどうか明らかになる
		for (int i = 1; i <= m; i++)	{

			if (i == 1)	{
				scanf("%d", &next);
				///
				//printf("1banme\n");
				///
				continue;
			}

			curr = next;
			scanf("%d", &next);

			if (i <= nmin)	{
				///
				//printf("hidarisugi\n");
				///
				continue;
			} else if	(i > nmax + 1)	{
				///
				//printf("migisugi\n");
				///
				continue;
			}

			gap = curr - next;

			if (gap >= gapmax)	{
				///
				//printf("ギャップが大きい\n");
				///
				gapmax = gap;
				res = i - 1;
			}
		}

		printf("%d\n", res);
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
typedef long long ll;
ll n,a,b,s[201],t[201],ans,tmp;
int main(void){
    while(1){
    cin>>n>>a>>b;
    if(n==0)return 0;
    ans=0;
    tmp=0;
    
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=1;i<n;i++){
        t[i]=s[i-1]-s[i];
    }
    for(int i=a;i<=b;i++){
        if(tmp<=t[i]){tmp=t[i];ans=i;}
    }
    cout<<ans<<endl;
    }
}

C++: //#include <bits/stdc++.h>
#include <cstdio>
#include <vector>
#include <algorithm>
#define ll long long
#define all(a) (a).begin(),(a).end()

int main(int argc, char const *argv[]) {
  while(1){
    int m=0,nmin=0,nmax=0;
    scanf("%d%d%d",&m,&nmin,&nmax);
    if(m==0 && nmin==0 && nmax==0){
      break;
    }
    std::vector<int> p(m+1);
    for (int i = 1; i <= m; i++) {
      scanf("%d",&p[i]);
    }
    int temp=0,memo=0,memoid=0;
    for (int i = nmin; i <= nmax; i++) {
      temp=p[i]-p[i+1];
      memo=std::max(memo,temp);
      if(memo==temp) memoid=i;
    }
    p.erase(all(p));
    printf("%d\n",memoid);
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int m, nmin, nmax;

int main() {
    while(cin >> m >> nmin >> nmax, m&&nmin&&nmax){
        vector<int> v;
        int maxV=0;
        for(int i=0; i<m; ++i){
            int a; cin >> a; v.push_back(a);
        }
        int index=0;
        for(int i=nmin; i<=nmax; ++i){
            int temp = v[i-1]-v[i];
            if(maxV <= temp){
                index = i; maxV = temp;
            }
        }
        cout << index << endl;
    }
    return 0;
}

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

int main(void){
	int m, n_min, n_max, n;
	while(true){
		cin >> m >> n_min >> n_max;
		if(!m&&!n_min&&!n_max) break;
		vector<int> p(m);
		for(int i = 0; i < m; ++i){
			cin >> p[i];
		}
		sort(p.rbegin(), p.rend());
		int gap = 0, ans;
		for(n = n_min; n <= n_max; ++n){
			gap = max(gap, p[n-1] - p[n]);
			if(gap == p[n-1] - p[n]) ans = n;
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  while(true){
    int n,nmin,nmax;
    cin>>n>>nmin>>nmax;
    if(!n&&!nmin&&!nmax)return 0;
    vector<int> p(n);
    for(int i=0;i<n;i++)cin>>p[i];
    int diff=-1;
    int id;
    for(int i=nmin-1;i<nmax;i++){
      if(abs(p[i]-p[i+1])>=diff){
        diff=abs(p[i]-p[i+1]);
        id=i;
      }
    }
    cout<<id+1<<endl;
  }
}

C++: #include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <fstream>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
typedef long long ll;

#define INF 1000000000

int main(){
    int m,mi,mx;
    while(cin>>m>>mi>>mx, m){
        vector<int> p(m);
        rep(i,m) cin>>p[i];

        sort(all(p), greater<int>());

        int n, gap=0;

        for(int i=mi-1; i<mx; i++){
            if(p[i]-p[i+1] >= gap){
                n=i+1;
                gap = p[i]-p[i+1];
            }
        }
        cout<<n<<endl;
    }

  return 0;
}

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

int main(){
  int m,nmin,nmax,dmax,num;

  while(true){
    cin >> m >> nmin >> nmax;
    if(m == 0 && nmin == 0 && nmax == 0) break;

    int *score = new int[m];

    for(int i = 0; i<m; ++i)
      cin >> score[i];
    
    
    for(int i=nmin - 1; i<nmax; ++i){
      if(i == nmin - 1) dmax = score[i] - score[i+1];
      
      if(score[i] - score[i+1] >= dmax){
	dmax = score[i] - score[i+1];
	num = i + 1;
	
	cout << dmax << " *****" << endl;
      }
    }

    delete[] score;

    cout << num << endl;
    
  }
  return 0;
}