jiahuimbzuai/CoQuIR huggingface dataset:
//  [go]
package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

var sc = newScanner()

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

type Task struct {
	a int
	b int
}

type sortTasks []Task

func (s sortTasks) Less(i, j int) bool {
	if s[i].b == s[j].b {
		return s[i].a > s[j].a
	}
	return s[i].b > s[j].b
}

func (s sortTasks) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s sortTasks) Len() int {
	return len(s)
}

func main() {
	n, m := scanInt(), scanInt()
	tasks := make([]Task, n)
	for i := 0; i < n; i++ {
		tasks[i] = Task{scanInt(), scanInt()}
	}
	answer := maxRevenue(n, m, tasks)
	fmt.Println(answer)
}

func debug(a ...interface{}) {
	// fmt.Println(a...)
}

func maxRevenue(n, m int, tasks []Task) int {
	sort.Sort(sortTasks(tasks))
	revenue := 0
	index := 0
	debug(tasks)
	for i := m; i > 0; i-- {
		debug("i:", i)
		for ; index < n; index++ {
			if tasks[index].a <= i {
				revenue += tasks[index].b
				index++
				break
			}
		}
	}
	return revenue
}
//  [go]
package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

var sc = newScanner()

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

type Task struct {
	a int
	b int
}

type sortTasks []Task

func (s sortTasks) Less(i, j int) bool {
	if s[i].b == s[j].b {
		return s[i].a > s[j].a
	}
	return s[i].b > s[j].b
}

func (s sortTasks) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s sortTasks) Len() int {
	return len(s)
}

func main() {
	n, m := scanInt(), scanInt()
	tasks := make([]Task, n)
	for i := 0; i < n; i++ {
		tasks[i] = Task{scanInt(), scanInt()}
	}
	answer := maxRevenue(n, m, tasks)
	fmt.Println(answer)
}

func debug(a ...interface{}) {
	// fmt.Println(a...)
}

func maxRevenue(n, m int, tasks []Task) int {
	sort.Sort(sortTasks(tasks))
	revenue := 0
	index := 0
	debug(tasks)
	for i := m; i > 0; i-- {
		debug("i:", i)
		for j := index; j < n; j++ {
			debug(i, j, tasks[j])
			if tasks[j].a <= i {
				revenue += tasks[j].b
				index = j + 1
				break
			}
			index = j
		}
	}
	return revenue
}
//  [ruby]
N, M = gets.split.map(&:to_i)
S = N.times.map { gets.split.map(&:to_i) }.sort_by{|v| -v[1] }
bitset = Array.new(M + 1, &:itself) # a variant of Union Find Tree.

class << bitset
  def next_clear_bit(base)
    return size if base >= size
    return base if self[base] == base
    self[base] = next_clear_bit(self[base])
  end
  
  def extend_trailling_set_bits(base)
    r = next_clear_bit(base)
    return nil if r >= size
    self[r] = r + 1
    r
  end
end

puts S.inject(0){|s, (a, b)| bitset.extend_trailling_set_bits(a) ? s + b : s }
//  [ruby]
N, M = gets.split.map(&:to_i)
S = N.times.map { gets.split.map(&:to_i) }.sort_by{|v| -v[1] }
bitset = Array.new(M + 1, &:itself) # a variant of Union Find Tree.

class << bitset
  def next_clear_bit(base)
    return size if base >= size
    return base if self[base] == base
    self[base] = next_clear_bit(self[base])
  end
  
  def extend_trailling_set_bits(base)
    r = next_clear_bit(base)
    return nil if r >= size
    self[r] = next_clear_bit(r + 1)
    r
  end
end

puts S.inject(0){|s, (a, b)| bitset.extend_trailling_set_bits(a) ? s + b : s }
//  [ruby]
(N,M),*AB = $<.map{|ln| ln.split.map(&:to_i) }

g, *W = 0, *0..M
D = lambda{|d|
	return M < d ? M : W[d] == d ? d : W[d] = D[W[d]]
}
AB.sort_by{|*,b|-b}.each{|a,b|
	next if M == d = D[a-1]
	g, W[d] = g+b, d+1
}
p g
//  [ruby]
class PriorityQueue
  attr_accessor(:node)
  
  def initialize(src = [])
    @node = []
    src.each do |e|
      push(e)
    end
  end

  def push(x)
    @node << x
    bottom_up
  end

  def pop
    res = @node.first
    top_down
    return res
  end
  
  def bottom_up
    i = @node.size - 1
    v = @node[i]
    while i > 0
      parent = (i - 1) >> 1
      break if @node[parent] >= v
      
      @node[parent], @node[i] = @node[i], @node[parent]
      i = parent
    end
    
    @node[i] = v
  end

  def top_down
    i = 0
    tmp = @node.pop
    while (i << 1) + 1 < @node.size
      lhs = (i << 1) + 1
      rhs = (i << 1) + 2
      m = lhs
      
      if rhs < @node.size && @node[lhs] < @node[rhs]
        m = rhs
      end
      
      break if @node[m] <= tmp
      @node[i] = @node[m]
      i = m
    end
    
    @node[i] = tmp unless @node.empty?
  end
end

n, m = $stdin.readline.chomp.split.map(&:to_i)
t = Array.new(m) { Array.new }
n.times do
  a, b = $stdin.readline.chomp.split.map(&:to_i)
  t[a - 1] << b
end

res = 0
pq = PriorityQueue.new
m.times do |i|
  t[i].each do |b|
    pq.push(b)
  end

  if !pq.node.empty?
    res += pq.pop
  end
end
puts res
//  [ruby]
class SkewHeap
  def initialize(rev = nil)
    @rev = rev
  end
  def push(k)
    @root = meld(@root, Node.new(k))
  end
  def top
    @root.key
  end
  def empty?
    @root.nil?
  end
  def pop
    key = @root.key
    @root = meld(@root.lchild, @root.rchild)
    key
  end
  def meld(lhs, rhs)
    return lhs unless rhs
    return rhs unless lhs
    lhs, rhs = rhs, lhs unless lhs < rhs
    lhs, rhs = rhs, lhs if @rev
    lhs.rchild = meld(lhs.rchild, rhs)
    lhs.lchild, lhs.rchild = lhs.lchild, lhs.rchild
    lhs
  end
  class Node
    include Comparable
    attr_accessor :key, :lchild, :rchild
    def initialize(k)
      @key = k
    end
    def <=>(other)
      @key <=> other.key
    end
  end
end

N,M=gets.split.map(&:to_i)
X=N.times.map{gets.split.map(&:to_i)}.sort{|l,r|l[0]<=>r[0]}
a=0
q=SkewHeap.new(true)
(1..M).each do |i|
  q.push(X.shift[1]) until X.empty? || i<X.first[0]
  a+=q.pop unless q.empty?
end
p a
//  [ruby]
n, m = gets.chomp.split.map(&:to_i)
hs = Hash.new
ar = []

n.times do
  a, b = gets.chomp.split.map(&:to_i)
  hs[a] ||= []
  hs[a] << b
end

res = 0
m.times do |i|
  ar.push(*hs[i + 1])
  if !ar.empty?
    ar.sort!
    res += ar.pop
  end
end
puts res
//  [rust]
// https://atcoder.jp/contests/abc137/tasks/abc137_d
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize, m: usize,
        jobs: [(usize, i64); n]
    };

    let mut bucket = vec![vec![]; m];
    for (day, profit) in jobs {
        if m >= day {
            bucket[m-day].push(profit);
        }
    }

    let mut total = 0;
    let mut pq = BinaryHeap::new();
    for i in (0..m).rev() {
        for &p in &bucket[i] {
            pq.push(p);
        }
        if let Some(x) = pq.pop() {
            total += x;
        }
    }
    println!("{}", total);
}
//  [rust]
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let m = get!(usize);
    let mut ws = vec![vec![]; m];
    for _ in 0 .. n {
        let a = get!(usize);
        let b = get!();
        if a <= m {
            ws[a-1].push(b);
        }
    }
    let mut pq = std::collections::BinaryHeap::new();
    let mut ans = 0;
    for i in 0 .. ws.len() {
        for &w in ws[i].iter() {
            pq.push(w);
        }
        if let Some(w) = pq.pop() {
            ans += w;
        }
    }
    println!("{}", ans);
}
//  [rust]

#[derive(Debug)]
struct UnionFindBitset { bitset: Vec<usize> }
impl UnionFindBitset {
  fn new(size: usize) -> UnionFindBitset {
    let mut bitset = (0 .. size).collect::<Vec<usize>>();
    UnionFindBitset{ bitset: bitset }
  }
  
  fn next_clear_bit(&mut self, base : usize) -> Option<usize> {
    if base >= self.bitset.len() { 
      None 
    } else if base == self.bitset[base] { 
      Some(base) 
    } else {
      let t = self.bitset[base];
      let r = self.next_clear_bit(t);
      self.bitset[base] = r.unwrap_or(self.bitset.len());
      r
    }
  }
  
  fn extend_bits(&mut self, base : usize) ->  Option<usize> {
    let r = self.next_clear_bit(base);
    if r.is_none() { return r; }
    let i = r.unwrap();
    let j = self.next_clear_bit(i + 1).unwrap_or(self.bitset.len());
    self.bitset[i] = j;
    r
  }
}

fn main(){
  let mut stdin = String::new();
  std::io::Read::read_to_string(
      &mut std::io::stdin(),
      &mut stdin).unwrap();
  let mut stdin = stdin.split_whitespace();
  let mut get = || stdin.next().unwrap();
  
  macro_rules! get {
      () => {
        (get().parse::<usize>().unwrap(), get().parse::<usize>().unwrap())
      };
  }

  let (n, m) = get!();

  let mut bitset = UnionFindBitset::new(m + 1);
  let mut jobs = Vec::with_capacity(n);
  
  for i in 0 .. n {
    jobs.push(get!());  
  }
  jobs.sort_by_key(|x| x.1 );
  jobs.reverse();
  let mut ans = 0;
  
  for j in jobs.into_iter() {
    if let Some(_) = bitset.extend_bits(j.0) {
      ans += j.1;
    }
  }
  
  print!("{}", ans)
}
//  [rust]
use proconio::input;
 
fn main() {
  input! {
    n: usize,
    m: usize,
    mut abs: [(usize,usize);n]
  }
  abs.sort_by(|a, b| a.1.cmp(&b.1));
  abs.reverse();
  
  let mut result = 0;
  for i in 0..=m {
    for mut a in abs.iter_mut() {
      if a.0 <= i {
        result += a.1;
        a.0 = usize::max_value();
        break
      }
    }
  }
  
  println!("{}", result);
}
//  [rust]
use proconio::input;
use std::cmp::Ordering;
 
fn main() {
  input! {
    n: usize,
    m: usize,
    mut abs: [(usize,usize);n]
  }
  abs.sort_by(|a, b| {
    let result = a.1.cmp(&b.1);
    if result == Ordering::Equal {
      a.0.cmp(&b.0)
    } else {
      result
    }
  });
  abs.reverse();
  
  let mut result = 0;
  let mut index = m;
  let mut abs_index = 0;
  while 0 < index {
    while abs_index < n {
      let (day, val) = abs[abs_index];
      abs_index += 1; 
      if day <= index {
        result += val;
        break
      }
    }
    index -= 1;
  }
  
  println!("{}", result);
}
//  [rust]
use proconio::input;
 
fn main() {
  input! {
    n: usize,
    m: usize,
    mut abs: [(usize,usize);n]
  }
  abs.sort_by(|a, b| a.1.cmp(&b.1));
  abs.reverse();
  
  let mut result = 0;
  let mut index = m;
  let mut abs_index = 0;
  while 0 < index {
    while abs_index < n {
      let (day, val) = abs[abs_index];
      abs_index += 1; 
      if day <= index {
        result += val;
        break
      }
    }
    index -= 1;
  }
  
  println!("{}", result);
}
//  [swift]
import Foundation

func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}

func main() {
    let nm = readWords { Int($0)! }
    let n = nm[0]
    let m = nm[1]

    let ab: [(Int, Int)] = (1...n).map { _ in 
        let ab = readWords { Int($0)! }
        return (ab[0], ab[1])
    }.sorted(by: <)

    var ans = 0
    var pq = PriorityQueue<Int>(<=)
    var i = 0
    for day in 1...m {
        while i < n && ab[i].0 <= day {
            pq.push(ab[i].1)
            i += 1
        }
        if let b = pq.pop() {
            ans += b
        }
    }

    print(ans)
}

private struct PriorityQueue<T: Comparable> {
    private var data: [T]
    private var ordered: (T, T) -> Bool
    
    public var isEmpty: Bool {
        return data.isEmpty
    }
    
    public var count: Int {
        return data.count
    }

    init(_ order: @escaping (T, T) -> Bool) {
        self.data = []
        self.ordered = order
    }

    init<Seq: Sequence>(_ seq: Seq, _ order: @escaping (T, T) -> Bool) where Seq.Element == T {
        self.data = []
        self.ordered = order
        
        for x in seq {
            push(x)
        }
    }
    
    public mutating func pop() -> T? {
        return data.popLast().map { item in
            var item = item
            if !isEmpty {
                swap(&item, &data[0])
                siftDown()
            }
            return item
        }
    }
    
    public mutating func push(_ item: T) {
        let oldLen = count
        data.append(item)
        siftUp(oldLen)
    }
    
    private mutating func siftDown() {
        var pos = 0
        let end = count
        
        data.withUnsafeMutableBufferPointer { bufferPointer in
            let _data = bufferPointer.baseAddress!
            swap(&_data[0], &_data[end])
            
            var child = 2 * pos + 1
            while child < end {
                let right = child + 1
                if right < end && ordered(_data[child], _data[right]) {
                    child = right
                }
                swap(&_data[pos], &_data[child])
                pos = child
                child = 2 * pos + 1
            }
        }
        siftUp(pos)
    }
    
    private mutating func siftUp(_ pos: Int) {
        var pos = pos
        while pos > 0 {
            let parent = (pos - 1) / 2;
            if ordered(data[pos], data[parent]) {
                break
            }
            data.swapAt(pos, parent)
            pos = parent
        }
    }
}

extension PriorityQueue: Sequence, IteratorProtocol {
    mutating func next() -> T? {
        return pop()
    }
}

main()
//  [swift]
import Foundation

func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}

func main() {
    let nm = readWords { Int($0)! }
    let n = nm[0]
    let m = nm[1]

    let ab: [(Int, Int)] = (1...n).map { _ in 
        let ab = readWords { Int($0)! }
        return (ab[0], ab[1])
    }.sorted(by: <)

    var ans = 0
    var pq = PriorityQueue<Int>(>=)
    var i = 0
    for day in 1...m {
        while i < n && ab[i].0 <= day {
            pq.push(ab[i].1)
            i += 1
        }
        if let b = pq.pop() {
            ans += b
        }
    }

    print(ans)
}

private struct PriorityQueue<T> {
    private var data: [T]
    private var ordered: (T, T) -> Bool
    
    public var isEmpty: Bool {
        return data.isEmpty
    }
    
    public var count: Int {
        return data.count
    }

    init(_ order: @escaping (T, T) -> Bool) {
        self.data = []
        self.ordered = order
    }

    init<Seq: Sequence>(_ seq: Seq, _ order: @escaping (T, T) -> Bool) where Seq.Element == T {
        self.data = []
        self.ordered = order
        
        for x in seq {
            push(x)
        }
    }
    
    public mutating func pop() -> T? {
        return data.popLast().map { item in
            var item = item
            if !isEmpty {
                swap(&item, &data[0])
                siftDown()
            }
            return item
        }
    }
    
    public mutating func push(_ item: T) {
        let oldLen = count
        data.append(item)
        siftUp(oldLen)
    }
    
    private mutating func siftDown() {
        var pos = 0
        let end = count
        
        data.withUnsafeMutableBufferPointer { bufferPointer in
            let _data = bufferPointer.baseAddress!
            swap(&_data[0], &_data[end])
            
            var child = 2 * pos + 1
            while child < end {
                let right = child + 1
                if right < end && ordered(_data[right], _data[child]) {
                    child = right
                }
                swap(&_data[pos], &_data[child])
                pos = child
                child = 2 * pos + 1
            }
        }
        siftUp(pos)
    }
    
    private mutating func siftUp(_ pos: Int) {
        var pos = pos
        while pos > 0 {
            let parent = (pos - 1) / 2;
            if ordered(data[parent], data[pos]) {
                break
            }
            data.swapAt(pos, parent)
            pos = parent
        }
    }
}

extension PriorityQueue: Sequence, IteratorProtocol {
    mutating func next() -> T? {
        return pop()
    }
}

main()
//  [swift]
import Foundation

func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}
struct PriorityQueue<T: Comparable> {
    private var data: [T]
    private var ordered: (T, T) -> Bool
    
    public var isEmpty: Bool {
        return data.isEmpty
    }
    
    public var count: Int {
        return data.count
    }

    init(_ order: @escaping (T, T) -> Bool) {
        self.data = []
        self.ordered = order
    }

    init<Seq: Sequence>(_ seq: Seq, _ order: @escaping (T, T) -> Bool) where Seq.Element == T {
        self.data = []
        self.ordered = order
        
        for x in seq {
            push(x)
        }
    }
    
    public mutating func pop() -> T? {
        return data.popLast().map { item in
            var item = item
            if !isEmpty {
                swap(&item, &data[0])
                siftDown()
            }
            return item
        }
    }
    
    public mutating func push(_ item: T) {
        let oldLen = count
        data.append(item)
        siftUp(oldLen)
    }
    
    private mutating func siftDown() {
        var pos = 0
        let end = count
        
        data.withUnsafeMutableBufferPointer { bufferPointer in
            let _data = bufferPointer.baseAddress!
            swap(&_data[0], &_data[end])
            
            var child = 2 * pos + 1
            while child < end {
                let right = child + 1
                if right < end && ordered(_data[child], _data[right]) {
                    child = right
                }
                swap(&_data[pos], &_data[child])
                pos = child
                child = 2 * pos + 1
            }
        }
        siftUp(pos)
    }
    
    private mutating func siftUp(_ pos: Int) {
        var pos = pos
        while pos > 0 {
            let parent = (pos - 1) / 2;
            if ordered(data[pos], data[parent]) {
                break
            }
            data.swapAt(pos, parent)
            pos = parent
        }
    }
}

extension PriorityQueue: Sequence, IteratorProtocol {
    mutating func next() -> T? {
        return pop()
    }
}

    let nm = readWords { Int($0)! }
    let n = nm[0]
    let m = nm[1]

    let ab: [(Int, Int)] = (1...n).map { _ in 
        let ab = readWords { Int($0)! }
        return (ab[0], ab[1])
    }.sorted(by: <)

    var ans = 0
    var pq = PriorityQueue<Int>(<=)
    var i = 0
    for day in 1...m {
        while i < n && ab[i].0 <= day {
            pq.push(ab[i].1)
            i += 1
        }
        if let b = pq.pop() {
            ans += b
        }
    }

    print(ans)
//  [swift]
import Foundation

func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}

struct Pair: Comparable {
    var a: Int
    var b: Int
    static func <(lhs: Pair, rhs: Pair) -> Bool {
        return (lhs.b, lhs.a) < (rhs.b, rhs.a)
    }
}

func main() {
    let nm = readWords { Int($0)! }
    let n = nm[0]
    let m = nm[1]

    var q = PriorityQueue<Pair>(<=)
    for _ in 1...n {
        let ab = readWords { Int($0)! }
        q.push(Pair(a: ab[0], b: ab[1]))
    }

    var ans = 0
    var limit = m
    while let p = q.pop() {
        guard p.a <= limit else { continue }
        ans += p.b
        limit -= 1
    }

    print(ans)
}

private struct PriorityQueue<T: Comparable> {
    private var data: [T]
    private var ordered: (T, T) -> Bool
    
    public var isEmpty: Bool {
        return data.isEmpty
    }
    
    public var count: Int {
        return data.count
    }

    init(_ order: @escaping (T, T) -> Bool) {
        self.data = []
        self.ordered = order
    }

    init<Seq: Sequence>(_ seq: Seq, _ order: @escaping (T, T) -> Bool) where Seq.Element == T {
        self.data = []
        self.ordered = order
        
        for x in seq {
            push(x)
        }
    }
    
    public mutating func pop() -> T? {
        return data.popLast().map { item in
            var item = item
            if !isEmpty {
                swap(&item, &data[0])
                siftDown()
            }
            return item
        }
    }
    
    public mutating func push(_ item: T) {
        let oldLen = count
        data.append(item)
        siftUp(oldLen)
    }
    
    private mutating func siftDown() {
        var pos = 0
        let end = count
        
        data.withUnsafeMutableBufferPointer { bufferPointer in
            let _data = bufferPointer.baseAddress!
            swap(&_data[0], &_data[end])
            
            var child = 2 * pos + 1
            while child < end {
                let right = child + 1
                if right < end && ordered(_data[child], _data[right]) {
                    child = right
                }
                swap(&_data[pos], &_data[child])
                pos = child
                child = 2 * pos + 1
            }
        }
        siftUp(pos)
    }
    
    private mutating func siftUp(_ pos: Int) {
        var pos = pos
        while pos > 0 {
            let parent = (pos - 1) / 2;
            if ordered(data[pos], data[parent]) {
                break
            }
            data.swapAt(pos, parent)
            pos = parent
        }
    }
}

extension PriorityQueue: Sequence, IteratorProtocol {
    mutating func next() -> T? {
        return pop()
    }
}

main()
//  [typescript]
import * as fs from 'fs';

export class Reader {
    lines: string[];
    currentLine: number;

    constructor() {
        this.lines = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        this.currentLine = 0;
    }

    readLine(): string {
        return this.lines[this.currentLine++];
    }

    readInt(): number {
        return Number(this.readLine());
    }

    readInts(): number[] {
        return this.readLine().split(" ").map(Number);
    }
}

let reader = new Reader();

let [N, M] = reader.readInts();
let jobs: {reward: number, day: number}[] = [];

for(let i=0; i<N; i++) {
    let [day, reward] = reader.readInts();
    jobs.push({day: day, reward:reward});
}

jobs.sort((job0, job1) => {
    if (job1.reward > job0.reward)
        return 1;
    if (job1.reward < job0.reward)
        return -1;
    return job1.day-job0.day;
});
let totalReward = 0;
let today = 0;

for(let job of jobs) {
    if (job.day+today <= M) {
        totalReward += job.reward;
        today += 1;
    }
}

console.log(totalReward);
//  [typescript]
import * as fs from 'fs';

export class Reader {
    lines: string[];
    currentLine: number;

    constructor() {
        this.lines = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        this.currentLine = 0;
    }

    readLine(): string {
        return this.lines[this.currentLine++];
    }

    readInt(): number {
        return Number(this.readLine());
    }

    readInts(): number[] {
        return this.readLine().split(" ").map(Number);
    }
}

let reader = new Reader();

let [N, M] = reader.readInts();
let jobs: {reward: number, day: number}[] = [];

for(let i=0; i<N; i++) {
    let [day, reward] = reader.readInts();
    jobs.push({day: day, reward:reward});
}

jobs.sort((job0, job1) => {
    if (job1.reward > job0.reward)
        return 1;
    if (job1.reward < job0.reward)
        return -1;
    return job1.day-job0.day;
});
let totalReward = 0;
let today = 0;
console.log(jobs);

for(let job of jobs) {
    if (job.day+today <= M) {
        totalReward += job.reward;
        today += 1;
    }
}

console.log(totalReward);
//  [typescript]
function main(input) {
  input = input.trim().split('\n');
  const [n, m] = input[0].split(' ').map(n => Number(n));
  const abs = input.slice(1).map(a => a.split(' ').map(b => Number(b)));
  const map = {};
  for (let i = 0; i < n; i++) {
    const [a, b] = abs[i];
    if (!map[a]) {
      map[a] = [];
    }
    map[a].push(b);
  }
  const ps = [];
  let result = 0;
  for (let i = 1; i <= m; i++) {
    if (map[i]) {
      ps.push(...map[i]);
    }
    if (!ps.length) continue;
    const max = Math.max(...ps);
    result += max;
    const index = ps.indexOf(max);
    ps.splice(index, 1);
  }
  console.log(result);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [python]
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

ans = -1
d = float('inf')
for i in range(n):
    b = abs(a - (t - 0.006 * h[i]))
    if b < d:
        d = b
        ans = i + 1

print(ans)
//  [python]
N = int(input())
T, A = map(int, input().split())
H = map(int, input().split())

t = [T - h * 0.006 for h in H]
ans = 10**9
for i in range(len(t)):
    if abs(t[i] - A) < ans:
        ans_i = i
        ans = abs(t[i] - A)
print(ans_i + 1)
//  [python]
N = int(input())
T, A = map(int, input().split(' '))
H = map(int, input().split(' '))

ans = -1
abs_val = 1e9

for i, v in enumerate(H):
  if abs_val > abs((T - v * 0.006) - A):
    abs_val = abs((T - v * 0.006) - A)
    ans = i
print(ans + 1)
//  [python]
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
def avg_tmp(t, x):
  return t- x*0.006
ans, ans_index = 10000000, 0
for i in range(n):
  if abs(avg_tmp(t, h[i]) -a) < abs(ans-a):
         ans = abs(avg_tmp(t, h[i]))
         ans_index = i+1
print(ans_index)
//  [python]
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
def avg_tmp(t, x):
  return t- x*0.006
ans, ans_index = 10000000, 0
for i in range(n):
  if abs(avg_tmp(t, h[i]) -a) <= abs(ans-a):
         ans = abs(avg_tmp(t, h[i]))
         ans_index = i+1
print(ans_index)
//  [python]
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
def avg_tmp(t, x):
  return int(t- x*0.006)
ans, ans_index = 10000000, 0
for i in range(n):
  if abs(avg_tmp(t, h[i]) -a) <= abs(ans-a):
         ans = abs(avg_tmp(t, h[i]))
         ans_index = i
print(ans_index +1)
//  [java]
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	static FastScanner sc;
	static PrintWriter out;
	public static void main(String[] args){
		sc = new FastScanner();
		out = new PrintWriter(System.out);
//		solve();
		out.println(solve());
		out.flush();
	}

	static int solve(){
		int N = sc.nextInt();
		int T = sc.nextInt();
		int A = sc.nextInt();
		double min = Integer.MAX_VALUE;
		double tmp = 0;
		int idx = 0;
		for(int i=1;i<=N;i++){
			tmp = Math.abs(A- (T - sc.nextInt() * 0.006));
			if(tmp < min){
				idx = i;
				min = tmp;
			}
		}
		return idx;
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		}else{
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	public double nextDouble() { return Double.parseDouble(next());}
}
//  [java]


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int n = fs.nextInt();
        final int t = fs.nextInt();
        final int a = fs.nextInt();
        int closestDist = (int) 1e9;
        int res = -1;
        for (int i = 0; i < n; i++) {
            int curr = t - (fs.nextInt() * 6) / 1000;
            if (Math.abs(curr - a) < closestDist) {
                closestDist = Math.abs(curr - a);
                res = i + 1;
            }
        }
        System.out.println(res);
    }

    static final class Utils {
        public static void shuffleSort(int[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffleSort(long[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffle(int[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void shuffle(long[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void swap(int[] arr, int i, int j) {
            final int t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        public static void swap(long[] arr, int i, int j) {
            final long t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        private Utils() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}
//  [java]
//package reedeka;
import java.util.*;
import java.io.*;
import java.math.*;

public class Palace {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n, t, a;
		n = sc.nextInt();
		t = sc.nextInt();
		a = sc.nextInt();
		int i;
		double tmp, temp, s;
		int index = 1;
		int h;
		h = sc.nextInt();
		temp = t - 0.006*h;
		tmp = Math.abs(a - temp);
		for(i=2; i<=n; i++) {
			h = sc.nextInt();
			temp = t - 0.006*h;
			s = Math.abs(a-temp);
			if(s<tmp) {
				tmp = s;
				index = i;
			}
		}
		System.out.println(index);
	}
}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		double t = sc.nextDouble(), a = sc.nextDouble();
		double tem = Double.MAX_VALUE;
		int ans = 0;
		for(int i = 0; i < n; i++) {
			double h = sc.nextDouble();
			double ave = t - h * 0.006;
			if(tem > Math.abs(t - ave)) {
				tem = Math.abs(t - ave);
				ans = i+1;
			}
		}
		System.out.println(ans);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}
//  [cpp]
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t, a;
    cin >> n >> t >> a;
    vector<int> h(n);
    int idx = -1, MIN = INF;
    rep(i, 0, n){
        cin >> h[i];
        int tmp = t * 1000 - h[i] * 6;
        if(abs(tmp - a * 1000) < MIN){
            MIN = abs(tmp - a * 1000);
            idx = i;
        }
    }
    cout << idx + 1 << endl;
}
//  [cpp]
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, T, A;
    cin >> N >> T >> A;
    ll ans = -1;
    double diff = INT_MAX;
    for (ll i = 0; i < N; i++) {
        ll H;
        cin >> H;
        double t = T - H * 0.006;
        double d = abs(t - A);
        if (d < diff) {
            ans = i;
            diff = d;
        }
    }

    cout << ans + 1 << endl;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n, t, a; cin >> n >> t >> a;
  t *= 1000, a *= 1000;
  V<> h(n); for (int i = 0; i < n; ++i) cin >> h[i];
  int res = -1, mn = 1e9;
  for (int i = 0; i < n; ++i) {
    if (mn > abs(t - 6 * h[i] - a)) {
      res = i;
      mn = abs(t - 6 * h[i] - a);
    }
  }
  cout << res + 1 << '\n';
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    cout << fixed << setprecision(5);
    int n, t, a, h, res;
    vector<pair<float, int>>vec;
    cin >> n;
    cin >> t >> a;
    // vec.push_back(make_pair(a, 0));
    for(int i=0; i<n; i++){
      cin >> h;
      float ans=t-(h*0.006);
      vec.push_back(make_pair(ans, i));
    }
    int mn=1000000;
    sort(vec.rbegin(), vec.rend());
    for(int i=0; i<vec.size(); i++){
      // cout << vec[i]. first << " " << vec[i].second << endl;
      if(abs(vec[i].first-a)<mn){
        mn=abs(vec[i].first-a);
        res=vec[i].second;
      }
    }
    cout << res+1;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    cout << fixed << setprecision(5);
    int n, t, a, h, res;
    vector<pair<float, int>>vec;
    cin >> n;
    cin >> t >> a;
    vec.push_back(make_pair(a, 0));
    for(int i=0; i<n; i++){
      cin >> h;
      float ans=t-(h*0.006);
      ans-=a;
      vec.push_back(make_pair(ans, i));
    }
    sort(vec.rbegin(), vec.rend());
    for(int i=0; i<vec.size(); i++){
      // cout << vec[i]. first << " " << vec[i].second << endl;
      if(vec[i].first==a){
        res=vec[i+1].second;
      }
    }
    cout << res+1;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    cout << fixed << setprecision(5);
    int n, t, a, h, res;
    vector<pair<float, int>>vec;
    cin >> n;
    cin >> t >> a;
    vec.push_back(make_pair(a, 0));
    for(int i=0; i<n; i++){
      cin >> h;
      float ans=(t-h)*0.006;
      vec.push_back(make_pair(ans, i));
    }
    sort(vec.rbegin(), vec.rend());
    for(int i=0; i<vec.size(); i++){
      if(vec[i].first==a){
        res=vec[i+1].second;
      }
    }
    cout << res+1;
}
//  [c]
#include <stdio.h>
int main(){
  
    int N,i,a;
    double H[1000],Ta[1000],Tb[1000];
    double T,A,x,max=1000;
  
    scanf(" %d", &N);
    scanf(" %lf %lf", &T, &A);
  
    for(i = 0; i < N; ++i){
      scanf(" %lf", &H[i]);
    }
  
    for(i = 0; i < N; ++i){
      Ta[i] = T - H[i] * 0.006;
    }
  
    for(i = 0; i < N; ++i){
      x = A - Ta[i];
      if(x < 0){
        Tb[i] = Ta[i] - A;
      }
      else {
        Tb[i] = A - Ta[i];
      }
    }
  
    for(i = 0; i < N; ++i){
      if(Tb[i] < max){
        max = Tb[i];
        a = i + 1;
      }
    }
  
    printf("%d\n", a);
  
    return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

int main()
{
    long long n;
    long long t, a;
    long long ans;
    long long hi;
    long long minv = 1ll << 50ll;
    long long h;

    scanf("%lld", &n);
    scanf("%lld %lld", &t, &a); t *= 1000; a *= 1000;

    for (long long i = 0; i < n; i++) {
        scanf("%lld", &h);
        
        hi = t - h * 6;

        if (minv > abs(a - hi)) {
            minv = abs(a - hi);
            ans = i + 1;
        }
    }

    printf("%lld\n", ans);

    return 0;
}
//  [c]
#include<stdio.h>
#include<math.h>
int main(){
  int n,t,a,h1;
  scanf("%d\n",&n);
  scanf("%d %d\n", &t,&a);
  scanf("%d",&h1);
  int flag = 1;
  double t1=t-h1*0.006;
  for (int i = 2; i <= n; i++) {
    int h;
    scanf("%d", &h);
    double t0=t-h*0.006;
    if (fabs(a-t0)<fabs(a-t1)){
      flag = i;
      t1 = t0;
    }
  }
  printf("%d\n", flag);
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


long int gcd(long int a, long int b){
  long int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


int main(void){
  int n,t,a;
  scanf("%d%d%d",&n,&t,&a);
  int h[n+1];
  for(int i=0;i<n+1;i++){
    h[i]=0;
  }
  int min=1e8;
  int ans;
  for(int i=0;i<n;i++){
    scanf("%d",&h[i]);
    double deg=t-h[i]*0.006;
    if(deg-a<0){
      deg-=a;
      deg*=(-1);
    }else{
      deg-=a;
    }
    if(deg<min){
      min=deg;
      ans=i+1;
    }
  }
  printf("%d\n",ans);
  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


long int gcd(long int a, long int b){
  long int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


int main(void){
  int n,t,a;
  scanf("%d%d%d",&n,&t,&a);
  int h[n+1];
  for(int i=0;i<n+1;i++){
    h[i]=0;
  }
  int min=1e8;
  int ans;
  for(int i=0;i<n;i++){
    scanf("%d",&h[i]);
    double dif=t-h[i]*0.006-a;
    if(dif<0){
      dif*=(-1);
    }
    if(dif<min){
      min=dif;
      ans=i+1;
    }
  }
  printf("%d\n",ans);
  return 0;
}
//  [c]
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int N;
    cin >> N;
    int T, A;
    cin >> T >> A;
    vector<int> H(N);
    for (int i = 0; i < N; i++) cin >> H[i];

    double min_diff = 999999;
    int min_idx = -1;
    for (int i = 0; i < N; ++i) {
        int h = H[i];
        double t = T - h * 0.006;
        if (min_diff > (abs(double(A) - double(t)))) {
            min_diff = abs(double(A) - double(t));
            min_idx = i;
        }
    }
    cout << min_idx + 1 << endl;
    return 0;
}
//  [javascript]
"use strict";

var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/),
    cid = 0;

function next() {
    return +cin[cid++];
} // number一個取得
function nextstr() {
    return cin[cid++];
} // 文字列一個取得
function nextbig() {
    return BigInt(cin[cid++]);
} // BigInteger一個取得
// 長さnの配列として取得。aは文字列フラグ
function nexts(n, a) {
    return a ? cin.slice(cid, cid += n) : cin.slice(cid, cid += n).map(a => +a);
}
// 長さnのBigInt配列として取得。
function nextsbig(n) {
    return cin.slice(cid, cid += n).map(a => BigInt(a));
}
// w個ずつを組にして長さhの配列。aは文字列フラグ。
function nextm(h, w, a) {
    var r = [],
        i = 0;
    if (a)
        for (; i < h; i++) r.push(cin.slice(cid, cid += w));
    else
        for (; i < h; i++) r.push(cin.slice(cid, cid += w).map(a => +a));
    return r;
}
// 多次元配列。v,a1,a2,a3 なら、3次元。[[値vで長さa3の配列]をa2個並べた配列]をa1個並べた配列。
function xArray(v) {
    var a = arguments,
        l = a.length,
        r = "Array(a[" + --l + "]).fill().map(x=>{return " + v + ";})";
    while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")";
    return eval(r);
}


console.log(main().toString());

function main() {
    let n = next();
    let t = next();
    let a = next();
    let h = nexts(n);
    let target = (t - a) * 1000 / 6
    let ans = 0;
    let min = 100000;
    let diff = 100000;
    for (let i = 0; i < n; i++) {
        diff = Math.abs(target - h[i]);
        if (min > diff) {
            min = diff;
            ans = i + 1;
        }
    }
    return ans;
}
//  [javascript]
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    tmp2 = input[1].split(" ");
    tmp3 = input[2].split(" ");
    T = parseInt(tmp2[0]);
    A = parseInt(tmp2[1]);
    var ans;
    var ansAmari;
	//文字列から10進数に変換するときはparseIntを使います
    for(i = 0;i < parseInt(input[0]);i++){
        kion = T - parseInt(tmp3[i]) * 0.006;
        amari = A - kion;
        if(ansAmari > Math.abs(amari) || i === 0){
            ans = i+1;
            ansAmari = Math.abs(amari);
        }
    }
	console.log('%d',ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
N = inp.shift() * 1
l = inp.shift().split(' ')
T = l.shift() * 1
A = l.shift() * 1
l = inp.shift().split(' ')
min = 10000
j = 0
for(i=0; i<N; i++) {
    abs = Math.abs(A - (T - (l[i] * 1) * 0.006))
    if (min > abs) {
        min = abs
        j = i
    }
}
console.log(j+1)
//  [javascript]
function main(input) {
  const args = input.split('\n');
  const ary2 = args[1].split(' ').map(n => parseInt(n, 10));
  const N = parseInt(args[0], 10); //候補地数
  const T = ary2[0]; //気温求めるパラメータ
  const A = ary2[1]; //理想気温
  const ary = args[2].split(' ').map(n => parseInt(n, 10));
  let min_gap; //理想気温に最も近い気温
  let idx; //敵地番号
  
  for (let i = 0; i < ary.length; i++) {
    if (ary[i] === 0) { 
      idx = (i + 1);
      break;
    } else {
      ave = T - (ary[i] * 0.006); //平均気温
      gap = Math.abs(A - ave);
      if (!min_gap || min_gap > gap) {
        min_gap = gap;
        idx = i + 1; // 帳尻合わせ
      }
    }
  }
  
  console.log(idx);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function main(input) {
  const args = input.split('\n');
  const ary2 = args[1].split(' ').map(n => parseInt(n, 10));
  const N = parseInt(args[0], 10); //候補地数
  const T = ary2[0]; //気温求めるパラメータ
  const A = ary2[1]; //理想気温
  const ary = args[2].split(' ').map(n => parseInt(n, 10));
  let min_gap; //理想気温に最も近い気温
  let idx; //敵地番号
  
  for (let i = 0; i < ary.length; i++) {
    // 理想気温とズレが所持ない時点で最適解なのでブレイク
    if (ary[i] === 0) { 
      idx = (i + 1);
      break;
    }
    ave = T - (ary[i] * 0.006); //平均気温
    gap = Math.abs(A - ave);
    if (!min_gap || min_gap > gap) {
      min_gap = gap;
      idx = i + 1; // 帳尻合わせ
    }
  }
  
  console.log(idx);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));