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 <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;


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

  int M, min, max;

  while(1){
    cin >> M >> min >> max;

    if(M == 0 && min == 0 && max == 0) break;

    int P[M];
    REP(i, M) cin >> P[i];

    int gomi = 0;
    int cnt = 0;
    REPS(i, min-1, max){
      if(gomi <= P[i]-P[i+1]){
      gomi = P[i]-P[i+1];
      cnt = i+1;
    }
  }
    cout << cnt << endl;
  }

  return 0;
}

C++: #include <bits/stdc++.h>
#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);
    for (size_t i = 1; i <= m; i++) {
      scanf("%d",&p[i]);
    }
    int temp=0,memo=0,memoid=0;
    for (size_t i = nmin; i <= nmax; i++) {
      temp=p[i]-p[i+1];
      memo=std::max(memo,temp);
      if(memo==temp) memoid=i;
    }
    printf("%d\n",memoid);
  }


  return 0;
}

C++: #include <iostream>

using namespace std;

int main(void) {
	int m, n_min, n_max;
	int score[10001] = { 0 }, gap, ans, tmp;

	while (1) {
		cin >> m; cin >> n_min; cin >> n_max;
		if (m == 0 && n_min == 0 && n_max == 0) break;

		gap = 0;
		ans = 0;
		for (int i = 1; i <= m; i++) {
			cin >> score[i];
		}
		for (int j = n_min; j <= n_max; j++) {
			if ((tmp = score[j] - score[j + 1]) >= gap) {
				gap = tmp;
				ans = j;
			}
		}
		cout << ans <<endl;
	}

	return 0;
}

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

using namespace std;

int main(){
	int m, mn, mx;
	while(cin>>m>>mn>>mx, m|mn|mx){
		int P[205], diff=0, ans=0;
		rep(i,m) cin >> P[i+1];
		for(int i=mn; i<=mx; i++){
			if( P[i] - P[i+1] >= diff ){
				ans = i;
				diff = P[i] - P[i+1];
			}
		}
		cout << ans << endl;
	}
	return 0;
}

C++: 5 2 4
100
90
82
70
65
5 2 4
100
90
80
75
65
3 1 2
5000
4000
3000
4 2 3
10000
10000
8000
8000
4 2 3
10000
10000
10000
8000
5 2 3
100
80
68
60
45
0 0 0

C++: #include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<map>
using namespace std;

int main() {
	int a, b, c;
	while (cin>>a>>b>>c, a | b | c) {
		map<int, int>e;
		for (int d = 0; d < a; d++) {
			int f;
			cin >> f;
			e[20000-f]++;
		}
		auto i = e.end();
		i--;
		int g = 0;
		int p = 0, q = 0;
		for (auto h = e.begin();h!=i; h++) {
			g += (*h).second;
			if (g < b)continue;
			else if (g > c)break;
			auto j = h;
			j++;
			if ((*j).first - (*h).first >= p) { p = (*j).first - (*h).first; q = g; }
		}
		cout << q << endl;
	}
}

C++: #include<bits/stdc++.h>

using namespace std;

int main(){

  int m,n_min,n_max;

  while(1){

	cin>>m>>n_min>>n_max;

	if(m==0 && n_min==0 && n_max==0)
	  break;

	vector<int> score(m+1);
	int d=0;
	int num;

	for(int i=1;i<=m;++i)
	  cin>>score[i];

	for(int i=n_min;i<=n_max;++i){
	  if(score[i]-score[i+1] >= d){
		d = score[i]-score[i+1];
		num=i;
	  }
	}
	cout<<num<<endl;
  }
  
}

C++: #include"bits/stdc++.h"

#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}


void solve();

int main() {

	solve();
	return 0;

}

void solve() {

	ll m, n_min, n_max;
	vector<ll> s;



	cin >> m >> n_min >> n_max;

	while (m > 0) {
		ll gap = 0, ans = 0;
		s.resize(m);
		REP(i, m) {

			cin >> s[i];

		}

		FOR(i, n_min-1, n_max ) {

			if (s[i] - s[i + 1] >= gap) {

				ans = i+1;
				gap = s[i] - s[i + 1];

			}

		}

		cout << ans << endl;

	}

}

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,maxN+1)
        {
            gap = score[j-1] - score[j];

            if(gapMax <= gap)
            {
                gapnumber = j;
                gapMax = gap;
                
            }
        }
        cout << gapnumber << endl;
        gapMax  =-1;
        gapnumber = 0;
    
    }
    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define INF (1<<29)

int main()
{
    int m, nmin, nmax;
    while (cin >> m >> nmin >> nmax, m) {
        vector<int> P(m);
        for (int i = 0; i < m; i++) {
            cin >> P[i];
        } 
        int gap = P[nmin-1] - P[nmin], res = nmin;
        for (int i = nmin; i < nmax; i++) {
            if (gap < P[i] - P[i+1]) {
                gap = P[i] - P[i+1];
                res = i + 1;
            } else if (gap == P[i] - P[i+1]) {
                res = i + 1;
            }
        }
        cout << res << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
        int m,n1,n2,ans,max=0,s,p;
        int a[10000];
        cin >> m >> n1 >> n2;
        if(m==0 && n1==0 && n2==0) break;
        for(int i=0; i<m; i++){
          cin >> p;
          a[i] = p;
        }
        for(int i=n1; i<=n2; i++){
          s = a[i-1] - a[i];
          if(s >= max) {
                ans = i;
                max = s;
          }
        }
        cout << ans << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>

std::vector<int> P(10000);

int main() {
    int m, nmin, nmax;
    int i;
    while(std::cin >> m >> nmin >> nmax) {
        if(m == 0 && nmin == 0 && nmax == 0) break;
        for(i=0; i<m; ++i) {
            std::cin >> P[i];
        }
        std::sort(P.begin(), P.begin()+i, std::greater<int>());

        int max = 0;
        int maxN = 0;
        for(i=nmax; i>=nmin; --i) {
            int gap = P[i-1] - P[i];
            if(gap > max) {
                max = gap;
                maxN = i;
            }
        }
        std::cout << maxN << std::endl;
    }
}