jiahuimbzuai/CoQuIR huggingface dataset:
//  [go]
package main
import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)
 
var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
 
func nextInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

type Item struct {
  Price int
}

type PriorityQueue []*Item

func (pq PriorityQueue) Len() int {
  return len(pq)
}

func (pq PriorityQueue) Less(i, j int) bool {
  return pq[j].Price < pq[i].Price
}

func (pq PriorityQueue) Swap(i, j int) {
  pq[i], pq[j] = pq[j], pq[i]
}

func (pq *PriorityQueue) Pop() interface{} {
  old := *pq
  n := len(old)
  item := old[n-1]
  *pq = old[0:n-1]
  return item
}

func (pq *PriorityQueue) Push(x interface{}) {
  item := x.(*Item)
  *pq = append(*pq, item)
}

func main() {
  sc.Buffer(make([]byte, 500000), 500000)
  sc.Split(bufio.ScanWords)
 
  n := nextInt()
  m := nextInt()
  
  as := make([]int, n)
  for i := 0; i < n; i++ {
    as[i] = nextInt()
  }
  priorityQueue := make(PriorityQueue, n, 1000*n)
  result := 0
  for i, a := range as {
    item := Item{}
    item.Price = a
    priorityQueue[i] = &item 
    result += a
  }
  heap.Init(&priorityQueue)
  
  for i := 0; i < m; i++ {
    item := heap.Pop(&priorityQueue).(*Item)
    newPrice := item.Price/2
    discountedPrice := item.Price - newPrice
    result -= discountedPrice
    newItem := Item{}
    newItem.Price = newPrice
    heap.Push(&priorityQueue, &newItem)
  }
  fmt.Println(result)
  
  
}
//  [go]
package main

import (
	"errors"
	"fmt"
	"math"
)

func main() {
	var N, M int
	fmt.Scanf("%d", &N)
	fmt.Scanf("%d", &M)

	pq := PriorityQueue{}
	var scan MyType
	for i := 0; i < N; i++ {
		fmt.Scanf("%f", &scan)
		pq.Add(scan)
	}

	for i := 0; i < M; i++ {
		pop, _ := pq.Pop()
		pq.Add(pop/2)
	}

	answer := 0
	for e, error := pq.Pop(); error == nil; e, error = pq.Pop() {
		answer += int(math.Trunc(float64(e)))
	}
	fmt.Println(answer)
}


type MyType float64

type PriorityQueue struct {
	s []MyType
}

func (pq *PriorityQueue) Add(e MyType) {
	pq.s = append(pq.s, e)

	ei := len(pq.s) - 1
	pi := ei / 2
	for ei != 0 {
		if pq.s[ei] > pq.s[pi] {
			tmp := pq.s[pi]
			pq.s[pi] = pq.s[ei]
			pq.s[ei] = tmp

			ei /= 2
			pi /= 2
		} else {
			break
		}
	}
	//fmt.Println(pq.s)
}

func (pq *PriorityQueue) Pop() (MyType, error) {
	if len(pq.s) == 0 {
		return 0, errors.New("empty!")
	}

	ret := pq.s[0]
	pq.s[0] = pq.s[len(pq.s)-1]
	pq.s = pq.s[0 : len(pq.s)-1]

	currentDepth := int(math.Log2(float64(len(pq.s))))
	ei := 0
	for int(math.Log2(float64(ei+1))) < currentDepth {
		//fmt.Println("current depth is ", currentDepth, "depth is ", math.Log2(float64(ei+1)), "ei is ", ei)

		var l, r MyType
		if len(pq.s) > ei * 2 {
			l = pq.s[ei*2]
		} else {
			l = 0
		}

		if len(pq.s) > ei * 2 + 1 {
			r = pq.s[ei*2+1]
		} else {
			r = 0
		}

		var target MyType
		var targetIndex int
		if l >= r {
			target = l
			targetIndex = ei * 2
		} else {
			target = r
			targetIndex = ei*2 + 1
		}

		if target > pq.s[ei] {
			tmp := pq.s[ei]
			pq.s[ei] = target
			pq.s[targetIndex] = tmp
			ei = targetIndex
		} else {
			break
		}
	}
	return ret, nil
}
//  [ruby]
eval"N,M,*A="+`dd`.split*?,;f=->i{d=k=0;A.map{|a|d-=b=(0..99).find{|j|a>>j<=i};k+=a>>b};X=k--~i/2*d+=M;d>=0};f[(0..10**9).bsearch &f];p X
//  [ruby]
# heap を使ったもの（パフォーマンス良い）
class PriorityQueue
  def initialize(array = [])
    @data = []
    array.each{|a| push(a)}
  end

  def push(element)
    @data.push(element)
    bottom_up
  end

  def pop
    if size == 0
      return nil
    elsif size == 1
      return @data.pop
    else
      min = @data[0]
      @data[0] = @data.pop
      top_down
      return min
    end
  end

  def size
    @data.size
  end

  private

  def swap(i, j)
    @data[i], @data[j] = @data[j], @data[i]
  end

  def parent_idx(target_idx)
    (target_idx - (target_idx.even? ? 2 : 1)) / 2
  end

  def bottom_up
    target_idx = size - 1
    return if target_idx == 0
    parent_idx = parent_idx(target_idx)
    while (@data[parent_idx] > @data[target_idx])
      swap(parent_idx, target_idx)
      target_idx = parent_idx
      break if target_idx == 0
      parent_idx = parent_idx(target_idx)
    end
  end

  def top_down
    target_idx = 0

    # child がある場合
    while (has_child?(target_idx))

      a = left_child_idx(target_idx)
      b = right_child_idx(target_idx)

      if @data[b].nil?
        c = a
      else
        c = @data[a] <= @data[b] ? a : b
      end

      if @data[target_idx] > @data[c]
        swap(target_idx, c)
        target_idx = c
      else
        return
      end
    end
  end

  # @param Integer
  # @return Integer
  def left_child_idx(idx)
    (idx * 2) + 1
  end

  # @param Integer
  # @return Integer
  def right_child_idx(idx)
    (idx * 2) + 2
  end

  # @param Integer
  # @return Boolent
  def has_child?(idx)
    ((idx * 2) + 1) < @data.size
  end
end

n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
e = a.map{|x| -x}
b = PriorityQueue.new(e)
m.times do
  c = b.pop
  b.push(-(-c / 2))
end
ans = 0
while b.size > 0
  ans -= b.pop
end
puts ans
//  [ruby]
class PriorityQueue
  def initialize(array = [])
    @data = []
    array.each{|a| add(a)}
  end

  def add(element)
    @data.push(element)
    bottom_up
  end

  # @return Integer
  def peek
    @data[0]
  end

  # @return Integer
  def poll
    if size == 0
      return nil
    elsif size == 1
      return @data.pop
    else
      min = @data[0]
      @data[0] = @data.pop
      top_down
      return min
    end
  end

  # @return Integer
  def size
    @data.size
  end

  private

  def swap(i, j)
    @data[i], @data[j] = @data[j], @data[i]
  end


  def bottom_up
    idx = size - 1
    while(has_parent?(idx))
      parent_idx = parent_idx(idx)
      if @data[parent_idx] > @data[idx]
        swap(parent_idx, idx)
        idx = parent_idx
      else
        return
      end
    end
  end

  def top_down
    idx = 0
    while (has_child?(idx))
      a = left_child_idx(idx)
      b = right_child_idx(idx)
      if @data[b].nil?
        c = a
      else
        c = @data[a] <= @data[b] ? a : b
      end
      if @data[idx] > @data[c]
        swap(idx, c)
        idx = c
      else
        return
      end
    end
  end


  # @param Integer
  # @return Integer
  def parent_idx(idx)
    (idx - (idx.even? ? 2 : 1)) / 2
  end

  # @param Integer
  # @return Integer
  def left_child_idx(idx)
    (idx * 2) + 1
  end

  # @param Integer
  # @return Integer
  def right_child_idx(idx)
    (idx * 2) + 2
  end

  # @param Integer
  # @return Boolent
  def has_child?(idx)
    ((idx * 2) + 1) < @data.size
  end

  def has_parent?(idx)
    idx > 0
  end
end

N,M=gets.split.map(&:to_i)
as=gets.split.map(&:to_i).map{|e|-e}
queue=PriorityQueue.new(as)
M.times do
    add=queue.poll
    queue.add(-(-add/2))
end
cnt=0
N.times do
    cnt+=-queue.poll
end
puts cnt
//  [rust]
pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                std::cmp::Ordering::Less => {
                    low = mid + 1;
                }
                std::cmp::Ordering::Equal | std::cmp::Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }

    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                std::cmp::Ordering::Less | std::cmp::Ordering::Equal => {
                    low = mid + 1;
                }
                std::cmp::Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}

#[test]
fn test_binary_search() {
    let v = vec![1, 3, 4, 4, 4, 6, 7, 12, 54, 60];

    assert_eq!(v.lower_bound(&4), 2);
    assert_eq!(v.upper_bound(&4), 5);
    assert_eq!(v.lower_bound(&2), 1);
    assert_eq!(v.upper_bound(&2), 1);
}

fn main() {
    proconio::input! {
        n: usize,
        m: usize,
        mut a_s: [usize; n],
    }
    a_s.sort();
    for _ in 0..m {
        let last = a_s.pop().unwrap();
        let new_num = last / 2;
        let index = a_s.lower_bound(&new_num);
        a_s.insert(index, new_num);
    }
    let ans = a_s.iter().sum::<usize>();
    println!("{}", ans);
}
//  [rust]
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

fn solve(xs: &Vec<u64>, m: usize, z: u64) -> Option<u64> {
    let mut n = m;
    let mut ys = vec![];
    for &x in xs.iter() {
        let mut y = x;
        while y > z && n > 0 {
            y /= 2;
            n -= 1;
        }
        if y <= z {
            ys.push(y);
        } else {
            return None
        }
    }
    ys.sort();
    ys.reverse();
    for i in 0..n {
        ys[i % xs.len()] /= 2;
    }
    Some(ys.iter().sum())
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let m: usize = sc.cin();
    let xs: Vec<u64> = (0..n).map(|_| sc.cin()).collect();

    let mut ans: u64 = xs.iter().sum();
    {
        let mut left = 0;
        let mut right = 1000000003;
        for _ in 0..100 {
            let mid = (left + right) / 2;
            if let Some(sm) = solve(&xs, m, mid) {
                ans = min!(ans, sm);
                right = mid;
            } else {
                left = mid;
            }
        }
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}
//  [swift]
class PQ{
    var size:Int = 0
    var heap = [Double]()
    
    func add(x:Double){
        heap.append(x)
        size += 1
        var index:Int = size - 1
        while(true){
            if(index == 0){
                break
            }
            let par_index:Int = (index-1) / 2
            if(heap[par_index] <= heap[index]){
                break
            }
            let tmp:Double = heap[index]
            heap[index] = heap[par_index]
            heap[par_index] = tmp
            index = par_index
        }
    }
    
    func getMin() -> Double{
        let res:Double = heap[0]
        var index = 0
        heap[index] = heap[size-1]
        size -= 1
        heap.removeLast()
        while(true){
            let leftIndex:Int = index * 2 + 1
            let rightIndex:Int = index * 2 + 2
            
            if(leftIndex >= size) {
                break
            }
            let L = heap[leftIndex]
            var R:Double = 2000000000
            if(rightIndex < size){
                R = heap[rightIndex]
            }
            
            if(heap[index] <= L && heap[index] <= R){
                break
            }else{
                if(L <= R){
                    let tmp:Double = heap[index]
                    heap[index] = heap[leftIndex]
                    heap[leftIndex] = tmp
                    index = leftIndex
                }else{
                    let tmp = heap[index]
                    heap[index] = heap[rightIndex]
                    heap[rightIndex] = tmp
                    index = rightIndex
                }
            }
        }
        return res
    }
    
}


var X = readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

var N:Int = X[0]
var M:Int = X[1]

var pq = PQ()

var A = readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

for i in 0..<N {
    let n:Int = A[i]
    let x:Double = -Double(n)
    pq.add(x)
}


for _ in 0..<M {
    var min:Double = pq.getMin()
    min /= 2.0
    pq.add(min)
}

var ans:Int = 0

for _ in 0..<N {
    ans += Int(-pq.getMin())
}

print(ans)
//  [swift]
struct Heap<Element: Comparable>: CollectionType {
  var items = [Element]()
  var startIndex: Int {
    return items.startIndex
  }
  var endIndex: Int {
    return items.endIndex
  }
  subscript(i: Int) -> Element {
    return items[i]
  }
  mutating func push(item: Element) {
    var i = items.count
    while i > 0 {
      let p = (i - 1) / 2
      if items[p] <= item {
        break
      }
      if i == items.count {
        items.append(items[p])
      } else {
        items[i] = items[p]
      }
      i = p
    }
    if i == items.count {
      items.append(item)
    } else {
      items[i] = item
    }
  }
  mutating func pop() -> Element {
    let ret = items[0]
    let x = items[items.count - 1]
    var i: Int = 0
    while i * 2 + 1 < items.count - 1 {
      var a = i * 2 + 1
      let b = i * 2 + 2
      if b < items.count - 1 && items[b] < items[a] {
        a = b
      }
      if items[a] >= x {
        break
      }
      items[i] = items[a]
      i = a
    }
    items[i] = x
    items.removeLast()
    return ret
  }
}
let M=Int(String(readLine()!.characters.split(" ")[1]))!
var q=Heap<Int>()
readLine()!.characters.split(" ").map{q.push(-Int(String($0))!)}
(0..<M).map{_ in q.push(q.pop()/2)}
print(q.reduce(0){$0-$1})
//  [python]
# tenka1-2017-beginnerB - Different Distribution
def main():
    N, *AB = map(int, open(0).read().split())
    A = max(zip(*[iter(AB)] * 2))
    ans = sum(A)
    print(ans)


if __name__ == "__main__":
    main()
//  [python]
import sys
read = sys.stdin.read

N, *AB = map(int, read().split())
AB = max(zip(*[iter(AB)] * 2))
print(sum(AB))
//  [python]
n,*t=map(int,open(0).read().split());print(sum(max(zip(t[::2],t[1::2]))))
//  [python]
# -*- coding: utf-8 -*-
import numpy as np

N = np.int64(input())
a = []
for i in range(N):
    a.append([int(x) for x in input().split()])
a = np.array(a)

lowest_person = a[:,0].max()
lowest_score = a[:,1].min()

num_people = lowest_person + lowest_score

print(num_people)
//  [python]
N=int(input())
A=[[int(i) for i in input().split()] for i in range(N)]
A.sort()
print(A[-1][0]+A[-1][1])
//  [python]
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
ab=sorted(ab,key=lambda x:x[0])
print(ab[-1][0]+ab[-1][1])
//  [java]
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int saveb = 0;
		int max = 0;
		int a = 0;
		int b = 0;
		for(int i = 0;i < n;i++){
			a = saori.saori_hayami();
			b = saori.saori_hayami();
			if(a > max){
				max = a;
				saveb = b;
			}
		}
		int ans = max + saveb;
		System.out.println(ans);


		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}
//  [java]
import static java.lang.System.out;
import java.io.InputStream;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Main {
	public static void main(String args[]) {
		MyInput in = new MyInput();
    int N = in.nextInt();
    int t = 0;
    int m = 0;
    int tmp = 0;
    for(int i = 0; i < N; i++) {
        tmp = in.nextInt();
        if(tmp > t) {
            t = tmp;
            m = in.nextInt();
        }
        else in.nextInt();
    }
    out.println(t + m);

	}
}

class MyInput {
	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;
	}

	public int readByte() { 
		if (hasNextByte()) return buffer[ptr++];
		else return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <=126;
	}

	private void skipUnprintable() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		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.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.nextLine();
		int minPoint = 0;
		int minRank = 0;
		for (int i = 0; i < N; i++) {
			int Ai = sc.nextInt();
			int Bi = sc.nextInt();
			sc.nextLine();
			if (i == 0 || Bi < minPoint) {
				minPoint = Bi;
				minRank = Ai;
			}
		}
		sc.close();
		
		System.out.println(minRank + minPoint);
	}
}
//  [java]
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve() {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[]a=new int[n];
		int[]b=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
		}
		int maxa=0;
		int maxb=0;
		int mina=Integer.MAX_VALUE/2;
		int minb=Integer.MAX_VALUE/2;
		for(int i=0;i<n;i++) {
			if(maxa<a[i]) {
				maxa=a[i];
				maxb=b[i];
			}
			if(mina<a[i]) {
				mina=a[i];
				minb=b[i];
			}
		}
		int ans=maxa+maxb;
		System.out.println(ans);
	}
}
//  [java]

import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
	Main m = new Main();
	m.answer();
    }

    private Scanner scan = new Scanner(System.in);
    private PriorityQueue<Data> dataQueue;

    public Main() {
	int N = Integer.parseInt(scan.next());
	dataQueue = new PriorityQueue<Data>(N);
	IntStream.range(0, N).forEach(i -> {
		int A = Integer.parseInt(scan.next());
		int B = Integer.parseInt(scan.next());
		dataQueue.add(new Data(A, B));
	    });
	scan.close();
    }

    public final void answer() {
	Data minData = dataQueue.poll();
	int result = minData.A + minData.B; 
	System.out.println(result);
    }

    private static class Data implements Comparable<Data> {
	int A;
	int B;

	public Data(int A, int B) {
	    this.A = A;
	    this.B = B;
	}

	@Override
	public int compareTo(Data o) {
	    return -(this.A - o.A);
	}
    }
}
//  [cpp]
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
 
 
const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int main() {

	int max = 2000000000;
	int n = getint();
	for(int i = 0; i < n; i++){
		int a = getint();
        int b = getint();
		if(a+b < max) {
			max = a+b;
		}
	}
	printf("%lld", max);
	return 0;
}
//  [cpp]
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<algorithm>
using namespace std;
 
 
const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int main() {

	int max = 2000000000;
	int n = getint();
	for(int i = 0; i < n; i++){
		int a = getint();
        int b = getint();
		if(a+b < max) {
			max = a+b;
		}
	}
	printf("%lld", max);
	return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N;
  cin >> N;
  long long A,B;
  map<long long, long long> mp;
  for(int i=0;i<N;i++){
    cin >> A >> B;
    mp[A] = B;
  }
  int ans = mp.rbegin()->first;
  for(int i=mp.rbegin()->second -1;i>=0;i--) ans ++;
  cout << ans << endl;
}
//  [cpp]
#include <iostream>
#include <vector>
#include <algorithm> 
#include <queue>
#include <functional>
#include <map>
#include <string>
using namespace std;




int main(void){

    int n;

    long mina = 0;
    int minb = 1000000005;

    cin >> n;

    for (int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        if (b < minb){
            minb = b;
            mina = a;
        }
    }


    while (minb >= 1){
        mina++;
        minb--;
    }

    cout << mina << endl;



}
//  [cpp]
#include <iostream>
using namespace std;

int main()
{
	int N, A, B,ans = 0,b = 1000000001;

	cin >> N;

	for (int n = 0; n < N; n++) {
		cin >> A >> B;
		if (ans < A)ans = A;
		if (B < b)b = B;
	}

	for (; b > 0; b--)
		ans++;

	cout << ans << endl;

	return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
int main(int argc, char** args)
{
    char str[30];
    unsigned long maxVal=0;
    unsigned long maxPos=0;
    unsigned long pos=0,val=0;
    unsigned long n=0;
    unsigned long result=0;
    memset(str,'\0',sizeof(str));
    
    fgets( str,sizeof(str), stdin);
    n=atol(str);
    
    for( int i=0; i<n; i++ )
    {
        fgets( str,sizeof(str), stdin);
        pos=atol(strtok(str," "));
        val=atol(strtok(NULL," "));
        if( maxPos<pos )
        {
            maxPos=pos;
            maxVal=val;
        }
    }
    result=maxPos+maxVal;
    printf("%ld\n",result);
    fflush(stdout);
}
//  [c]
a,b,m;main(n){for(gets(&n);~scanf("%d%d",&a,&b);m<a&&(m=a,n=a+b));printf("%d",n);}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    int n,a,b,ans,max=0;
    scanf("%d",&n);
    for (int i=0; i<n; i++){
        scanf("%d%d",&a,&b);
        if (a>max){
            max=a;
            ans=a+b;
        }
    }
    printf("%d\n",ans);
	return 0 ;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <stdbool.h>

typedef double db;
typedef int in;
typedef long int li;
typedef long long int lli;
typedef long ld;
typedef long lld;

#define pi M_PI
#define in scanf
#define out printf
#define inf INT_MAX
#define rep(i,n) for(int i=0;i<n;++i)
#define debugd(d) printf("%d\n",d)
#define debugs(s) printf("%s\n",s)
#define debugc(c) printf("%c\n",c)
#define debugf(f) printf("%f\n",f)

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int compare_intr(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}


int main (void)
{
  int n;
  in("%d\n",&n);
  int a[n],b[n];
  rep(i,n)
  {
    in("%d %d\n",&a[i],&b[i]);
  }
  qsort(a,n,sizeof(int),compare_int);
  qsort(b,n,sizeof(int),compare_intr);
  printf("%d \n",a[n-1]+b[n-1]);
  return 0;
}
//  [c]
A[2<<17];*p=A;main(n){for(;~scanf("%d",p++););qsort(p=A+1,*A,8,"\x8b\7+\6\xc3");for(n=*p;p[2];)n+=fmin(*p-p++[2],p[2]-*p++);n+=p[1];printf("%d",n);}
//  [c]
#include<stdio.h>
#include<stdlib.h>

int cmp_1(const void *a,const void *b)
{
  return*(int*)a-*(int*)b;
}

int cmp_2(const void *a,const void *b)
{
  return*(int*)b-*(int*)a;
}

int main()
{
  int n;
  
  scanf("%d",&n);
  
  int a[n],b[n];
  int i;
  int ans;
  
  for(i=0;i<n;i++)
  {
    scanf("%d%d",&a[i],&b[i]);
  }
  
  qsort(a,n,sizeof(int),cmp_1);
  qsort(b,n,sizeof(int),cmp_2);
  
  ans=a[0]-1;
  for(i=1;i<n;i++)
  {
    ans+=a[i]-a[i-1]-1;
  }  
  ans+=b[n-1];

  printf("%d\n",ans+n);
  
  return 0;
}
//  [javascript]
'use strict'
function Main(input){
  input=input.trim().split(/\s+/).map(x=>x-0);
  var N=input.shift();
  var A=[];
  var B=[];
  while(input.length>0){
    B.push(input.pop());
    A.push(input.pop());
  }
  var M=Math.max.apply(null,A);
  var S=B[A.indexOf(M)];
  console.log(M+S);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));
//  [javascript]
function Main(input){
	var max = 0;
	var ans = 0;
	input = input.split("\n");
	for(var i=1;i<input.length;i++){
		var mem = input[i].split(" ").map(Number);
		if(max<mem[0]){
			max = mem[0];
			ans = mem[0]+mem[1];
		}
	}
	console.log(ans)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [javascript]
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}
function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  var max = 0;
  var add = 0;
  input.shift();
  for(var i = 0; i < N; i++){
    var tmp = myconv(input[i],4);
    if(max < tmp[0]){
       max = tmp[0];
       add = tmp[1];
    }
  }
  myout(max + add);
}
Main(myin());
//  [javascript]
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

var memo = {};

function Main(input) {
    var n = parseInt(input[0], 10);
    var worstRank = 0;
    var worstScore = 0;
    for (var i = 0; i < n; i++) {
        var tokens = input[i + 1].split(' ');
        var a = parseInt(tokens[0], 10);
        var b = parseInt(tokens[1], 10);

        if (a > worstRank) {
            worstRank = a;
            worstScore = b;
        }
    }

    var entryNumber = worstRank + worstScore;

    console.log(entryNumber);

    return 0;
}
//  [javascript]
'use strict'
 
function Main(input) {
    var params = input.split('\n');
    const n = params[0];
    
    let minScore = 0;
    let lowest = 0;
    for (let i = 1; i < params.length; i++) {
        const arg = params[i].split(' ');
        if (arg[0] > lowest) {
            lowest = parseInt(arg[0], 10);
            minScore = parseInt(arg[1], 10);
        }
    }
    console.log(lowest + minScore);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";
const main = arg => {
  let Info = arg.split("\n");
  let Num = Info.shift();
  // .map(x => x*1)については型変換の常套句
  let personInfo = Info.map(i => i.split(" ").map(x => x*1));
  let infoMap = new Map();
  let As = [];
  
  // 情報をそれぞれの値に格納する（別にmapでなくてもよかった）
  personInfo.forEach((x) => {
  	infoMap.set(x[0],x[1]); 
    As.push(x[0]);
  })
  // 一番最下位に近い人とその人の下に何人いるかの可能性だけ探ればいい
  let Amax = Math.max(...As);
  let ans = Amax + infoMap.get(Amax);
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

type Pair struct {
	a, b int
}

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()

	aMax := Pair{a: -1, b: 0}
	for i := 0; i < n; i++ {
		a, b := ri(), ri()
		if a > aMax.a {
			aMax = Pair{a: a, b: b}
		}
	}

	fmt.Println(aMax.a + aMax.b)
}
//  [go]
package main

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

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for B - Different Distribution
	var N int
	fmt.Scanf("%d", &N)

	sc.Split(bufio.ScanWords)
	var A, B int
	var max int = 0
	var maxnum int
	for i := 0; i < N; i++ {
		A = nextInt()
		B = nextInt()
		if max < A {
			max = A
			maxnum = B
		}
	}

	fmt.Println(max + maxnum)
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

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

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	minA, minB := nextInt(), nextInt()
	for i := 0; i < n-1; i++ {
		a, b := nextInt(), nextInt()
		if a > minA {
			minA = a
			minB = b
		}
	}
	fmt.Println(minA + minB)
}
//  [go]
package main

import (
	"fmt"
	"sort"
)

type fact struct {
	a, b int
}

type facts []fact

func (f facts) Len() int {
	return len(f)
}

func (f facts) Swap(i, j int) {
	f[i], f[j] = f[j], f[i]
}

func (f facts) Less(i, j int) bool {
	return f[i].a > f[j].a
}

func main() {
	var n int
	fmt.Scan(&n)
	s := make(facts, n)
	for key := range s {
		fmt.Scan(&s[key].a, &s[key].b)
	}
	sort.Sort(s)
	fmt.Print(s[0].a+s[0].b)
}
//  [go]
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	a, b := 0, math.MaxInt32
	for i := 0; i < n; i++ {
		var tmp1, tmp2 int
		fmt.Scan(&tmp1, &tmp2)
		if b > tmp2 {
			b = tmp2
			a = tmp1
		}
	}
	fmt.Println(a + b)
}
//  [go]
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var to, tp, order, point int
	for i := 0; i < n; i++ {
		fmt.Scan(&to, &tp)
		if to > order {
			order = to
			point = tp
		}
	}
	fmt.Println(order + point)
}
//  [ruby]
p $<.map{|e|a,b=e.split;b ?a.to_i+b.to_i: 9**10}.min
//  [ruby]
n = gets.to_i
num = 0
point = 10**9 + 1
n.times do |i|
  a,b = gets.split.map(&:to_i)
  if b < point
    point = b
    num = a
  end
end
puts num + point
//  [ruby]
n = gets.to_i
a_max = 0
bb = 0
n.times do
  a, b = gets.split.map(&:to_i)
  if a > a_max
    a_max = a
    bb = b
  end
end
puts a_max + bb
//  [ruby]
gets;p$<.map{|s|eval s.split*?+}.min
//  [ruby]
n = gets.chomp.to_i
info = []
n.times do
    info << gets.chomp.split.map(&:to_i)
end
info.sort!
puts info[-1][0] + info[-1][1]
//  [ruby]
n = gets.to_i
a = Array.new(n){ gets.split.map &:to_i }
a.sort!
ans = a[-1].inject(:+)
puts ans
//  [rust]
use std::io::Read;
use std::cmp::{max, min};

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut max_a: usize = 0;
    let mut min_b: usize = 1_000_000_001;

    for _ in 0..n {
        max_a = max(max_a, iterator.next().unwrap().parse().unwrap());
        min_b = min(min_b, iterator.next().unwrap().parse().unwrap());
    }

    return format!("{}", max_a + min_b);
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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(non_snake_case, unused_variables)]
fn main() {
    input! {
        N: usize,
        AB: [(usize, usize); N],
    }
    let mut lowest: usize = 0;
    let mut min_score = 0;
    for i in 0..N {
        if lowest<AB[i].0 {
            lowest = AB[i].0;
            min_score = AB[i].1;
        }
    }
    println!("{}", lowest+min_score);
}
//  [rust]
#[allow(dead_code)]
fn main() {
    let n = i::u();
    let ab = i::uv2(n);
    let mut a_max = 0;
    let mut b_max = 0;
    for (a, b) in ab {
        if a > a_max {
            a_max = a;
            b_max = b;
        }
    }
    println!("{}", b_max + a_max);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }
    pub fn str() -> String {
        read()
    }
    pub fn s() -> Vec<char> {
        str().chars().collect()
    }
    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn u4() -> (usize, usize, usize, usize) {
        (read(), read(), read(), read())
    }

    pub fn u5() -> (usize, usize, usize, usize, usize) {
        (read(), read(), read(), read(), read())
    }

    pub fn u6() -> (usize, usize, usize, usize, usize, usize) {
        (read(), read(), read(), read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn iv3(n: usize) -> Vec<(i64, i64, i64)> {
        (0..n).map(|_| iv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn uv4(n: usize) -> Vec<(usize, usize, usize, usize)> {
        (0..n)
            .map(|_| uv(4))
            .map(|a| (a[0], a[1], a[2], a[3]))
            .collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}
//  [rust]
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let ab: Vec<(i32, i32)> = (0..n).map(|_| (read(), read())).collect();

    let maxi = ab.iter().max_by_key(|&&k| k.0).unwrap();
    let ans = maxi.0 + maxi.1;

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}
//  [rust]
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{n:usize, v:[(i64,i64);n]};
    let mut v = v;
    v.sort();
    v.reverse();
    println!("{}", v[0].1 + v[0].0);
}
//  [swift]
print((0..<Int(readLine()!)!).map{_ in readLine()!.characters.split(" ").reduce(0){$0+Int(String($1))!}}.minElement()!)
//  [swift]
print((0..<Int(readLine()!)!).reduce(2000000000){i,_ in min(i,readLine()!.characters.split(" ").reduce(0){$0+Int(String($1))!})})
//  [typescript]
"use strict";

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

function main(input) {
  const [
    [n],
    ...infos
  ] = input.trim().split("\n").map(e => e.split(" ").map(Number));

  const last = infos.reduce((p, c) => p[0] - c[0] > 0 ? p : c, [0, 0]);
  const ans = last[0] + last[1];
  console.log(ans);
}
//  [python]
a, b = map(int, input().split())
L = [int(input()) for _ in range(a)]
print(len(L)+(b-sum(L))//min(L))
//  [python]
import sys
input = sys.stdin.readline

'''
N種類のドーナツ、お菓子の粉Xグラム
mグラム消費するとドーナツを1種類作ることができる

条件：必ずN種類のドーナツを1つ以上作る
その上で
最大で作れる個数を作る

優先すべきは全てのドーナツを作ること
次に最小の粉で作れるドーナツを最大まで作ること
'''
N, X = map(int,input().split())

li = [input().strip() for i in range(N)]

li = list(map(int,li))

m = li[0]#最小の初期値
c = 0 #全て1つ分の値段の保持

for i in li:
    if i < m:
        m = i
    c += i

# N 個分は確定で存在しているからあとはもっとも安いの何個？

t = int((X - c) / m) + N

print(t)
//  [python]
N, X = map(int, input().split())
powder_list = []
[powder_list.append(int(input())) for i in range(N)]

min_donut = min(powder_list)
atleast_donut = sum(powder_list)

print(N + int((X - atleast_donut) / min_donut))
//  [python]
import numpy as np
N,X = input().split()
N = int(N)
X = int(X)
m = np.zeros(N)
for i in range(N):
    m[i] = int(input())
    X = X - m[i]
    
over = X // min(m)

print(int(N+over))
//  [python]
N, X = map(int, input().split())

mn = [0]*N
for i in range(N):
  mn[i] = int(input())
  
ans = N
x = X - sum(mn)

while(x >= min(mn)):
  if x // min(mn) == 0:
    mn[mn.index(min(mn))] = 1000000
  else:
    if x >= min(mn):
      x -= min(mn)
      ans += 1
      
print(ans)
//  [python]
N, X = map(int, input().split())

mn = [0]*N
for i in range(N):
  mn[i] = int(input())
  
ans = N
x = X - sum(mn)

while(x >= min(mn)):
  if x // min(mn) == 0:
    mn[mn.index(min(mn))] = 1000000
  else:
    x -= min(mn)
    ans += 1
      
print(ans)
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static int N, M;
	public static int[] array;

	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(f.readLine());
		N = Integer.parseInt(st.nextToken());
		M = Integer.parseInt(st.nextToken());
		array = new int[N];
		for (int i = 0; i < N; i++) {
			array[i] = Integer.parseInt(f.readLine());
		}
		for (int i : array) {
			M -= i;
		}
		Arrays.sort(array);
		int res = array.length;
		res += (M / array[0]);
		System.out.println(res);
	}
}
//  [java]
import java.util.*;
import java.io.*;

public class Main{

	public static void main(String[] args) throws IOException {
		int N = readInt(), X = readInt(), min = Integer.MAX_VALUE; for(int i = 1; i<=N; i++) {
			int k = readInt(); X-=k; min = Math.min(k, min);
		}
		println(N + X/min);
		exit();
	}

	final private static int BUFFER_SIZE = 1 << 16;
	private static DataInputStream din = new DataInputStream(System.in);
	private static byte[] buffer = new byte[BUFFER_SIZE];
	private static int bufferPointer = 0, bytesRead = 0;
	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	public static String readLine() throws IOException {
		byte[] buf = new byte[64]; // line length
		int cnt = 0, c;
		while ((c = Read()) != -1) {
			if (c == '\n')
				break;
			buf[cnt++] = (byte) c;
		}
		return new String(buf, 0, cnt);
	}

	public static String read() throws IOException {
		byte[] ret = new byte[1024];
		int idx = 0;
		byte c = Read();
		while (c <= ' ') {
			c = Read();
		}
		do {
			ret[idx++] = c;
			c = Read();
		} while (c != -1 && c != ' ' && c != '\n' && c != '\r');
		return new String(ret, 0, idx);
	}

	public static int readInt() throws IOException {
		int ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (neg)
			return -ret;
		return ret;
	}

	public static long readLong() throws IOException {
		long ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');
		if (neg)
			return -ret;
		return ret;
	}

	public static double readDouble() throws IOException {
		double ret = 0, div = 1;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();

		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (c == '.') {
			while ((c = Read()) >= '0' && c <= '9') {
				ret += (c - '0') / (div *= 10);
			}
		}

		if (neg)
			return -ret;
		return ret;
	}

	private static void fillBuffer() throws IOException {
		bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
		if (bytesRead == -1)
			buffer[0] = -1;
	}

	private static byte Read() throws IOException {
		if (bufferPointer == bytesRead)
			fillBuffer();
		return buffer[bufferPointer++];
	}

	public void close() throws IOException {
		if (din == null)
			return;
		din.close();
	}

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		din.close();
		pr.close();
		System.exit(0);
	}
}
//  [java]
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int x = cin.nextInt();
        int [] m = new int[n];
        for (int i = 0; i < n; i++) {
            m[i] = cin.nextInt();
        }
        int remain = x - Arrays.stream(m).sum();
        int minCount = remain / Arrays.stream(m).min().orElse(remain);
        System.out.println(n + minCount);

    }
}