jiahuimbzuai/CoQuIR huggingface dataset:
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

bool check(const vl& L,const ll& N){
	FOR(i,0,N-1)if(L[i+1] < L[i])return 0;
	return 1;
}

vl Sort(vl L,ll N){
	random_device rnd;
	while(!check(L,N)){
		ll a = rnd()%N;
		ll b = rnd()%N;
		if(L[a] > L[b])swap(L[a],L[b]);
	}
	return L;
}

signed main(){
	ll N;
	cin >> N;
	vl L(N);
	FOR(i,0,N)cin >> L[i];
	vl ans = Sort(L,N);
	ll SUM = 0;
	FOR(i,0,N)SUM += ans[i];
	Yes(SUM-ans[N-1] > ans[N-1]);
}
//  [cpp]
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-9;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int l[10];
random_device rnd;
mt19937 mt(rnd());
uniform_int_distribution<> rd(0, 65533);
void bogo_sort(int n) {
	bool f = true;
	bool used[10];
	while (f) {
		fill(used, used + n, false);
		vector<int> v; int cnt = 0;
		while (cnt<n) {
			int t = rd(mt) % n;
			if (used[t])continue;
			v.push_back(l[t]); used[t] = true; cnt++;
		}
		rep(i, n) {
			l[i] = v[i];
		}
		f = false;
		rep(i, n - 1) {
			if (l[i] > l[i + 1])f = true;
		}
	}
}
int main() {
	int n; cin >> n;
	rep(i, n) {
		cin >> l[i];
	}
	bogo_sort(n);
	int sum = 0;
	rep(i, n - 1) {
		sum += l[i];
	}
	if (sum > l[n - 1]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	//stop
	return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

bool check(const vl& L,const ll& N){
	FOR(i,0,N-1)if(L[i+1] < L[i])return 0;
	return 1;
}

vl Sort(vl L,ll N){
	random_device rnd;
	while(!check(L,N)){
		ll a = rnd()%N;
		ll b = rnd()%N;
		if(a-b)swap(L[a],L[b]);
	}
	return L;
}

signed main(){
	ll N;
	cin >> N;
	vl L(N);
	FOR(i,0,N)cin >> L[i];
	vl ans = Sort(L,N);
	ll SUM = 0;
	DEBUG(ans)
	FOR(i,0,N)SUM += ans[i];
	Yes(SUM-ans[N-1] > ans[N-1]);
}
//  [c]
#include <stdio.h>
 
int main(void){
  int n, max=0, max_i=0, sum=0, sum2;
  scanf("%d", &n);
  int l[n];
  for(int i=0; i<n;i++){
    scanf("%d", &l[i]);
    if(l[i]>max){
      max = l[i];
      max_i = i;
    }
    sum+=l[i];
  }
  
  sum2 = sum - l[max_i];
  
  if(max<sum2){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}
//  [c]
#include <stdio.h>
#define SIZE 10000
int main() {
	int n, a[SIZE],ans,i,sum=0,max=1;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	    scanf("%d",&a[i]);
	    if(max<=a[i]){
	        max=a[i];
	    }
	    sum+=a[i];
	}
	ans = sum-max;
	if(max<ans){
	    printf("Yes\n");
	}
	else{
	    printf("No\n");
	}
	
	return 0;
}
//  [c]

#include<stdio.h>
int main()
{
    int N, max=0, i, sum=0, sum1=0;
    scanf("%d",&N);
    int L[N];

    for(i=0; i<N; i++)
        scanf("%d",&L[i]);
        
    max = L[0];
    for(i=0; i<N; i++)
        if(L[i] > max)
            max = L[i];
            
    for(i=0; i<N; i++)
        sum = sum + L[i];
        
    sum1 = sum - max;
    if(sum1>max)
        printf("Yes\n");
    else
        printf("No\n");

}

// Author: Sorowar Mahabub
//  [javascript]
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let N = lines.shift() - 0;
    let Ln = lines[0].split(" ").map((v) => v - 0);
    Ln.sort((a, b) => b - a);
    let max = Ln.shift();
    let sum = Ln.reduce((ac, value, index, array) => ac + value, 0);

    console.log(max < sum ? "Yes" : "No");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
N = lines.shift() * 1
line = lines.shift().split(' ')
sum = 0
for (i=0;i<N;i++) {
    sum += line[i] * 1
}
bool = true
for (i=0;i<N;i++) {
    if (sum-line[i] * 1 <= line[i] * 1) {
        bool = false
        break;
    }
}
console.log(bool?'Yes':'No')
//  [javascript]
function main(input) {
    const nums = input.trim().split(/\n/)[1]
        .split(/\s/).map(str => { return Number(str) })
        .sort((a, b) => { return b - a });
    const sum = nums.slice(1).reduce((res, pre) => {
        return res + pre;
    }, 0);
    console.log(nums[0] < sum ? 'Yes' : 'No');
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	l := iSScan(n)
	if max(l)-(sum(l)-max(l)) < 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}
//  [go]
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

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

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	l := scanInts(n)
	sort.Ints(l)
	a := 0
	for i := 0; i < n-1; i++ {
		a += l[i]
	}
	if a <= l[n-1] {
		fmt.Fprintln(wr, "No")
	} else {
		fmt.Fprintln(wr, "Yes")
	}
}
//  [ruby]
n,*a=`dd`.split.map(&:to_i)
s=a.sum
a.each do |i|
  if s-i<=i
    puts 'No'
    exit
  end
end
puts 'Yes'
//  [ruby]
n = gets.to_i
l = gets.split.map(&:to_i)

if l.max < l.sum - l.max
  puts 'Yes'
else
  puts 'No'
end
//  [ruby]
n = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i)
if (arr.max * 2< arr.sum)
  puts "Yes"
else
  puts "No"
end
//  [rust]
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut arr:Vec<usize> = (0..n).map(|_| read()).collect();
    arr.sort();
    let last = arr.pop().unwrap();
    let sum:usize = arr.iter().sum();
    let ans = if last < sum {"Yes"} else {"No"};
    println!("{}", ans);
}
//  [rust]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    l: [usize; n]
    }
    let s = l.iter().sum::<usize>();
    let m = l.iter().max().unwrap();
    let ans = if *m < s - *m {"Yes"} else {"No"};
    println!("{}", ans);
}
//  [swift]
let N = Int(readLine()!)!
let L = readLine()!.split(separator: " ").map { Int($0)! }.sorted()

print(L.last! < L[0 ..< L.count - 1].reduce(0, +) ? "Yes" : "No")
//  [swift]
let N = Int(readLine()!)!
var Ls: [Int] = readLine()!.split(separator: " ").map { Int($0)! }

Ls.sort()
print(Ls.dropLast().reduce(0, +) > Ls.last! ? "Yes" : "No")
//  [swift]
import Foundation

class Scanner {
    static func readInt() -> Int {
        return Int(readLine()!)!
    }
    
    static func readIntArr() -> [Int] {
        return readLine()!.split(separator: " ").map { Int($0)! }
    }
    
    static func readM(_ n: Int) -> [[Int]] {
        var res = [[Int]]()
        for _ in 0..<n {
            res.append(readIntArr())
        }
        return res
    }
    
    static func readUknownIntMat() -> [[Int]] {
        var res = [[Int]]()
        while let line = readLine() {
            res.append(line.split(separator: " ").map { Int($0)! })
        }
        return res
    }
    
    static func readString() -> String {
        return readLine()!
    }
}

class Printer {
    static func printIntArray(_ arr: [Int]) {
        print(arr.map { String($0) }.joined(separator: " "))
    }
}


class Solution {
    func canFormPolygon(_ arr: [Int]) -> Bool {
        let total = arr.reduce(0) {$0 + $1}
        for side in arr {
            guard 0 < total-(2*side) else {
                return false
            }
        }
        return true
    }
}

let n = Scanner.readInt()
let arr = Scanner.readIntArr()
print(Solution().canFormPolygon(arr) ? "Yes" : "No")
//  [typescript]
namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length == 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }

  async function slove() {
    const sc = new Scanner();
    const n = +(await sc.getLine());
    const L = (await sc.getLine()).split(' ').map((x) => +x);
    L.sort((a, b) => {
      if (a > b) return 1;
      else return -1;
    }).reverse();
    const sum = (array: any[]) => {
      return array.reduce((prev, current, i, arr) => {
        return prev + current;
      });
    };
    if (L[0] >= sum(L) - L[0]) {
      console.log('No');
    } else {
      console.log('Yes');
    }
    sc.close();
  }

  slove();
}
//  [typescript]
const main = (input: string) => {
  const lines = input.trim().split("\n");
  const N = parseInt(lines[0])
  let L = lines[1].split(" ").map(str => parseInt(str));
  const maxLength = Math.max(...L);
  let sum = 0;

  const compareFunc　=　(a: number, b: number) => {
    return a - b;
  }

  L.sort(compareFunc)

  for (let i = 0; i < N - 1; i++) {
    sum += L[i];
  }

  console.log(sum > maxLength ? "Yes" : "No")
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
import * as fs from 'fs';

namespace AtCoder {
    export interface Pramable {
        args: string[][];
    }

    export interface Task {
        main(this: Task): void;
    }
}

namespace AtCoder.abc117 {
    export class TaskB implements AtCoder.Pramable, AtCoder.Task {
        constructor(public args: string[][]) {
        }

        public main(this: TaskB): void {

            const l: number[] = this.args[1].map(Number);
            const max: number = Math.max(...l);
            const sum: number = l.reduce((acc: number, cur: number) => acc + cur, 0);

            if (max < sum - max) {
                console.log('Yes');
            } else {
                console.log('No');
            }
        }
    }

    const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(x => x.split(' '));
    const task: TaskB = new TaskB(args);
    task.main();
}
//  [python]
def solve():
  n = int(input())
  query = []
  for i in range(n):
    tmp = input()
    s,p = tmp.split()
    query.append((s,p,i+1))
  query.sort()
  count = 0
  while count<1000:
    count += 1
    for i in range(n):
      for j in range(i+1,n):
        if query[i][0] == query[j][0]:
          if int(query[i][1]) <int(query[j][1]):
            buf = query[i]
            query[i] = query[j]
            query[j] = buf
            
    
  for i in range(n):
    print(query[i][2])
solve()
//  [python]
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def solve():
    N = int(input())
    X = []
    for i in range(N):
        S,P = map(str, input().split())
        P = int(P)
        X.append((S,P,i))
    X.sort(key=lambda x: x[1], reverse=True)
    X.sort(key=lambda x: x[0])

    for x in X:
        print(x[2]+1)

    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
        def dump(*args):
            names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
            print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
    except:
        def dump(*args):
            pass

    solve()

# vim: set foldmethod=marker:}}}
//  [python]
def nig (x,y):
    if x[0] == y[0]: return -1 if x[1]>y[1] else 1
    return -1 if x[0] < y[0] else 1
cuc_fuk = []
for x in range(input()):
    a,b = raw_input().split()
    cuc_fuk.append((a,int(b),x+1))
for piss in sorted(cuc_fuk, cmp = nig ):
    print piss[2]
//  [java]
import java.awt.*;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;

public class Main {

    public static int aa = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, List<Point>> map = new HashMap<>();

        for (int i = 0; i<n; i++) {
            String s = sc.next();
            Integer p = sc.nextInt();
            Point po = new Point(p, i+1);
            List<Point> list = map.getOrDefault(s, new ArrayList<>());
            list.add(po);
            map.put(s, list);
        }

        List<String> keys = map.keySet().stream().sorted().collect(Collectors.toList());

        for (String k : keys) {
            List<Point> l = map.get(k);
            l.sort((e1, e2) -> e2.x - e1.x);
            for (Point a : l)
                System.out.println(a.y);
        }

    }
}
//  [java]
import java.time.Instant;
import java.util.*;
import java.util.function.ToLongFunction;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Pair<String, Integer>> SP = new ArrayList<>();
		for(int i=0; i<N; i++){
			SP.add(new Pair<String, Integer>(i+1, sc.next(),sc.nextInt()));
		}

		Comparator<Pair> comparator = Comparator.<Pair, String> comparing(pair -> (String)pair.a)
		        .<Integer>thenComparing(pair -> -1 * (int)pair.b);

		SP = SP.stream().sorted(comparator).collect(Collectors.toList());

		for(Pair pair : SP){
			System.out.println(pair.n);
		}






	}

	static class Pair<T1, T2>   {
		int n;
	    T1 a;
	    T2 b;
	    public Pair(int n, T1 a,T2 b) {
	        this.n = n;
	    	this.a = a;
	        this.b = b;
	    }

	    T1 getA(){
	    	return a;
	    }

	    T2 getB(){
	    	return b;
	    }

	}
}
//  [java]
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main
{

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());

		List<String> cities = new ArrayList<>();
		List<Integer> points = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			cities.add(sc.next());
			points.add(Integer.parseInt(sc.next()));
		}

		List<String> citiesInOrder = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			if (!citiesInOrder.contains(cities.get(i))) {
				citiesInOrder.add(cities.get(i));
				Collections.sort(citiesInOrder, Comparator.naturalOrder());
			}
		}

		for (int i = 0; i < n; i++) {
			String city = cities.get(i);

			points.set(i, (citiesInOrder.size() - (IntStream.range(0, citiesInOrder.size()).map(j -> citiesInOrder.get(j).equals(city) ? j : -1).filter(j -> j >= 0).min().getAsInt())) * 1000 + points.get(i));
		}

		List<Integer> pointsInOrder = points.stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList());

		List<Integer> ranks = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			int point = points.get(i);

			ranks.add(IntStream.range(0, n).map(j -> pointsInOrder.get(j).equals(point) ? j : -1).filter(j -> j >= 0).min().getAsInt() + 1);
		}

		for (int i = 1; i <= n; i++) {
			int mokeke = i;

			System.out.println(IntStream.range(0, n)
										.map(j -> ranks.get(j).equals(mokeke) ? j : -1)
										.filter(j -> j >= 0).min().getAsInt() + 1);
		}



		sc.close();
	}
}
//  [cpp]
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
struct node{
	string s;
	int data,number;
}f[10000001];
bool cmp(node &a,node &b){
	if(a.s != b.s) return a.s < b.s;
	else return a.data > b.data;
}
int main(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> f[i].s >> f[i].data;
		f[i].number = i;
	}
	sort(f+1,f+1+n,cmp);
	for(int i = 1; i <= n; i++) cout << f[i].number << endl;
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef long long ll;

int		str_cmp(const void *s1, const void *s2)
{
	return strcmp(*(char **)s1, *(char **)s2);
}

int main()
{
	int N;
	scanf("%d", &N);
	char str[N][11];
	int p[N];
	char **sort;
	sort = (char**)malloc(sizeof(char*) * N);
	int i = 0;
	int len;
	while (i < N)
	{
		scanf("%s", str[i]);
		scanf("%d", &p[i]);
		len = strlen(str[i]);
		sort[i] = (char*)malloc(sizeof(char) * (len + 1));
		strcpy(sort[i], str[i]);
		i++;
	}
	qsort(sort, N, sizeof *sort, str_cmp);
	i = 0;
	int n;
	int j,k;
	int max = -1;
	int index;
	while (i < N)
	{
		n = 0;
		j = 0;
		while (j < N)
		{
			if (strcmp(sort[i], str[j]) == 0)
			{
				k = 0;
				max = -1;
				while (k < N)
				{
					if (strcmp(str[j], str[k]) == 0)
					{
						if (p[k] > max)
						{
							max = p[k];
							index = k;
						}
					}
					k++;
				}
			}
			j++;
		}
		printf("%d\n", index + 1);
		p[index] = -1;
		i++;
	}
	return (0);
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct{
  int Num;
  char S[20];
  int P;
} Pair;

int f(const void *a,const void *b){
  return ((Pair*)b)->P-((Pair*)a)->P;
}

int g(const void *a,const void *b){
  return strcmp(((Pair*)a)->S,((Pair*)b)->S);
}

int main(){
  int N;
  scanf("%d\n",&N);
  Pair A[200];
  for(int i=0;i<N;i++){
    A[i].Num=i+1;
    scanf("%s %d\n",A[i].S,&A[i].P);
  }
  qsort(A,N,sizeof(Pair),f);
  qsort(A,N,sizeof(Pair),g);
  for(int i=0;i<N;i++)
    printf("%d\n",A[i].Num);
  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
	char s[11];
	int p;
	int no;
} data;

int cmpstr(const void *x, const void *y) {
	int res = strcmp(((data *)x)->s, ((data *)y)->s);
	if (res == 0)
		return ((data *)y)->p - ((data *)x)->p;
	else
		return res;
}

int main() {
	int n;
	data d[100];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s%d", d[i].s, &d[i].p);
		d[i].no = i + 1;
	}
	qsort(d, n, sizeof(data), cmpstr);
	for (int i = 0; i < n; i++) {
		printf("%d\n", d[i].no);
	}
	return 0;
}
//  [javascript]
function Main(input) {

	input = input.split("\n");
	var N = parseInt(input[0]);
	var lists = [];
	
	function List(name,score,num){
	    this.name = name;
	    this.score = score;
	    this.num = num;
	}
	
	List.prototype.show = function(){
	    return this.num;
	}
	
	for(var i = 0;i < N;i++){
	     pass = input[i+1].split(" ");
	     lists[i] = new List(pass[0],parseInt(pass[1]),parseInt(i+1));
	}
	
	lists.sort((a,b) => { return (a.name > b.name) ? 1
    						   : (a.name < b.name) ? -1
      				           : (b.score >= a.score)? 1 : -1; });
    for(var j = 0;j < N;j++){
        console.log(lists[j].show());
    }
    //console.log(lists);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]


function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  var R = new Array(N);
  for(var i=0;i<N;i++){
    var tmp=input[i+1].split(" ");
    R[i]=[i+1,tmp[0],parseInt(tmp[1])];
  }
  R.sort(function(a,b){
    if (a[1] < b[1]) return -1;
    if (a[1] > b[1]) return 1;
    if (a[2] < b[2]) return 1;
    if (a[2] > b[2]) return -1;
    return 0;
  })

  var ans="";
  for(var i=0;i<N;i++){
    if(i!=N-1){
      ans+=R[i][0]+"\n";
    }else{
      ans+=R[i][0];
    }
  }
  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";
function Main(input) {
  const args = input.split('\n');
  const N = parseInt(args.shift());
  const SP = args
  .filter((f, i) => i < N)
  .map((m1, i) => {
    const ms = m1.split(' ');
    return {
      S: ms[0],
      P: parseInt(ms[1]),
      i: i + 1
    };
  })
  .sort((a ,b) => {
    const cS = b.S.localeCompare(a.S);
    if (b.S !== a.S) {
      return b.S < a.S ? 1 : -1;
    }
    return b.P - a.P;
  }).forEach((f) => {
    console.log(f.i);
  });
}

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

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

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

type rest struct {
	S   string
	P   int
	idx int
}
type rests []rest
type rests2 []rest
type mystrings []string

func (a rests) Len() int           { return len(a) }
func (a rests) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a rests) Less(i, j int) bool { return a[i].P > a[j].P }

func (a rests2) Len() int           { return len(a) }
func (a rests2) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a rests2) Less(i, j int) bool { return a[i].S < a[j].S }

func (a mystrings) Len() int           { return len(a) }
func (a mystrings) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a mystrings) Less(i, j int) bool { return a[i] < a[j] }

func main() {
	N := getStdinInt()
	r := make(rests, N)
	ls := make([]string, N)
	for i := 0; i < N; i++ {
		list := getStdinArr()
		r[i].S = list[0]
		r[i].P, _ = strconv.Atoi(list[1])
		r[i].idx = i + 1
		find := false
		for _, val := range ls {
			if r[i].S == val {
				find = true
				break
			}
		}
		if !find {
			ls[i] = r[i].S
		}
	}

	sort.Sort(rests(r))
	sort.Sort(mystrings(ls))
	for _, val2 := range ls {
		for _, val := range r {
			if val2 == val.S {
				fmt.Printf("%d\n", val.idx)
			}
		}
	}

	/*
			func (a ByAge) Len() int { return len(a) }
		func (a ByAge) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
		func (a ByAge) Less(i, j int) bool { return a[i].Age < a[j].Age }

		--以下実行例
		people := []Person{
		{"A", 1},
		{"D", 4},
		{"B", 2},
		{"C", 3},
		}
		sort.Sort(ByAge(people))
	*/
}

func getStdin() string {
	return readLine()
}
func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 1024*1024*10)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

type pair struct {
	rn string
	p  int
	i  int
}

func main() {
	n := nextInt()
	s := make([]pair, n)
 // 入力とid付与
	for i := 0; i < n; i++ {
		s[i].rn = nextStr()
		s[i].p = nextInt()
		s[i].i = i + 1
	}
  // 同名ごとのソート
	sort.Slice(s, func(i, j int) bool {
		if s[i].rn == s[j].rn {
			return s[i].p > s[j].p
		}
		return s[i].rn < s[j].rn
	})

	for _, v := range s {
		fmt.Println(v.i)
	}
}

func init() {
	const max = 1024
	var buf = make([]byte, max)
	sc.Buffer(buf, max)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	s := make([]pair, n)

	for i := 0; i < n; i++ {
		s[i].f = nextStr()
		s[i].s = nextInt()
		s[i].i = i + 1
	}
	sortPairs(s)
	for _, v := range s {
		fmt.Println(v.i)
	}
}

type pair struct { // f=first, s=second
	f string
	s int
	i int
}

// []pair をf->sの順でソートする
func sortPairs(s []pair) {
	sort.Slice(s, func(i, j int) bool {
		if s[i].f == s[j].f {
			return s[i].s > s[j].s // 点数大きい順
		}
		return s[i].f < s[j].f
	})
	return
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}
//  [ruby]
n = gets.chomp.to_i

arr = n.times.map { |i|
    p, s = gets.chomp.split(" ")
    [i + 1, p, s.to_i]
}

arr.sort_by! { |row|
    [row[1], -row[2]]
}.each { |row|
    puts row[0]
}
//  [ruby]
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

# 空白区切の入力値を数値の配列で返却する
def gets_s_list()
  gets.chomp.split(" ")
end

n = gets_i
list = []
n.times do |i|
  s, p = gets_s_list
  list.push [i+1, s, p.to_i]
end

list.sort_by{|x| [x[1], -x[2]]}.each{|x| puts x[0]}
//  [ruby]
n = gets.to_i
r = []
for i in 1..n
  s = gets.split
  r << [i, s[0], s[1]]
end
r.sort_by!{|x| [x[1], -x[2].to_i]}
r.each do |a|
  puts a[0]
end
//  [rust]
use std::cmp::Reverse;
use std::collections::BTreeMap;
use whiteread::parse_line;

fn main() {
    let n: u32 = parse_line().unwrap();
    let mut dic: BTreeMap<String, Vec<(u32, u32)>> = BTreeMap::new();

    for i in 1..=n {
        let (s, p): (String, u32) = parse_line().unwrap();
        dic.entry(s)
            .and_modify(|x| x.push((i, p)))
            .or_insert(vec![(i, p)]);
    }
    for (_, v) in dic.iter() {
        let mut v = v.clone();
        v.sort_by_key(|x| Reverse(x.1));
        let mut iter = v.iter();
        while let Some((i, _)) = iter.next() {
            println!("{}", i);
        }
    }
}
//  [rust]
#![allow(non_snake_case)]
use std::cmp::Ordering;

#[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" ) } ; }
#[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 ! 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 ) * } } ; }

#[derive (Debug, Eq, PartialEq)]
struct Restaurant {
    id: usize,
    city: String,
    point: i32,
}

impl Restaurant {
    fn new(id: usize, city: String, point: i32) -> Self {
        Restaurant {
            id: id,
            city: city,
            point: point,
        }
    }
}

impl Ord for Restaurant {
    fn cmp(&self, other: &Self) -> Ordering {
        if self.city != other.city {
            self.city.cmp(&other.city)
        } else {
            other.point.cmp(&self.point)
        }
    }
}

impl PartialOrd for Restaurant {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

fn main() {
    input! {
        N: usize,
        rs_: [(String, i32); N],
    }
    let mut rs = vec![];
    for i in 0..N {
        rs.push(Restaurant::new(i, rs_[i].0.clone(), rs_[i].1.clone()));
    }
    rs.sort();

    for i in 0..N {
        println!("{}", rs[i].id + 1);
    }
}
//  [rust]
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:usize,
    mut b:[(String,isize);a],
    }
    let mut b = b.iter().enumerate().collect_vec();
    b.sort_by(|a, b| (a.1).0.cmp(&(b.1).0).then((b.1).1.cmp(&(a.1).1)));
    for i in 0..a {
        println!("{}", b[i].0+1);
    }
}
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element? {
        return self.maxElement()
    }
    func min() -> Element? {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
//    func enumerated() -> [(Int, Element)] {
//        return self.enumerate()
//    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}
//func gcd(x: Int, _ y: Int) -> Int {
//    if y == 0 {
//        return x
//    } else {
//        return gcd(y, x%y)
//    }
//}
//func lcm(x: Int, _ y: Int) -> Int {
//    return x * y / gcd(x, y)
//}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let N = readInt()!
var book = [(Int, String, Int)]()
var citys = [String]()
for i in 1...N {
    let input = readStringSplit(by: " ")
    book += [(i, input[0], Int(input[1])!)]
    if !citys.contains(input[0]) {
        citys += [input[0]]
    }
}
citys.sort()
book = book.sort{$0.2 > $1.2}
for s in citys {
    for i in 0..<N {
        if book[i].1 == s {
            print(book[i].0)
        }
    }
}
//  [swift]
func sReadLine() -> [String] {
    return readLine()!.characters.split(" ").map{String($0)}
}
func sReadInt() -> [Int] {
    let strs = sReadLine()
    return strs.map{Int($0)!}
}
func readInt() -> Int {
    return Int(readLine()!)!
}
/************** main *****************/
let n = readInt()
var sparr: [(String, Int, Int)] = (1...n).map { i in
    let sp = sReadLine()
    return (sp[0], Int(sp[1])!, i)
}
for ssp in sparr.sort({$0.0 == $1.0 ? $0.1 > $1.1 : $0.0 < $1.0}) {
    print(ssp.2)
}
//  [swift]
var restaurants = [(Int, String, Int)]()
for i in 1...Int(readLine()!)! {
  let input = readLine()!.characters.split(" ").map{String($0)}
  restaurants += [(i, input[0], Int(input[1])!)]
}
restaurants.sortInPlace{
  if $0.1==$1.1 {
    return $0.2>$1.2
  }
  return $0.1<$1.1
}
for restaurant in restaurants {
  print(restaurant.0)
}
//  [typescript]
'use strict'
function Main(input) {
    input = input.trim().split(/\n/)
    input.shift()
    input = input.map(elem => {
      return elem.split(' ')
    })

    input = input.map((elem, index) => {
      return [
         index+1,
         elem[0], // 都市名
         parseInt(elem[1], 10) // 点数
      ]
    })
  
    input.sort((a, b) => {
      if(a[1] !== b[1]) {
        return a[1].localeCompare(b[1])
      } else{
        return b[2] - a[2]
      }
    })

    input.forEach(elem => {
        console.log(elem[0])
    })

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const n = Number(stdin.split('\n')[0])

const [, ..._sp] = stdin.trim().split('\n')
const sp = _sp.map(e => e.split(' '))

const ans = _ => {
  for (let i = 0; i < sp.length; i++) {
    sp[i][1] = Number(sp[i][1])
    sp[i].push(i + 1)
  }

  // sp.sort((a, b) => b[1] - a[1])

  sp.sort((a, b) => {
    const nameA = a[0]
    const nameB = b[0]
    if (nameA < nameB) {
      return -1
    }
    if (nameA > nameB) {
      return 1
    }
    return 0
  })

  let tmp = []
  for (let i = 0; i < sp.length; i++) {
    const [name, score, id] = sp[i]
    const nextName = i < sp.length - 1 ? sp[i + 1][0] : 0

    if (name === nextName) {
      tmp.push([score, id])
    } else if (name !== nextName) {
      tmp.push([score, id])
      const res = tmp.sort((a, b) => b[0] - a[0])
      res.forEach(e => {
        console.log(e[1])
      })
      tmp = []
    }
  }
}

ans()
//  [typescript]
const log = console.log;

const createScanFunctions = (input: string) => {
  const str = input.trim();
  const len = str.length;
  let index = 0;

  const scan = () => {
    const startIndex = index;

    while (index < len) {
      const char = str[index];

      if (char === " " || char === "\n")
        return str.substring(startIndex, index++);

      index++;
    }

    return str.substr(startIndex);
  };

  const scanInt = () => parseInt(scan());

  return { scan, scanInt };
};

// ----

interface Restaurant {
  no: number;
  city: string;
  point: number;
}

function Main(input: string): void {
  const { scan, scanInt } = createScanFunctions(input);

  const n = scanInt();

  const restaurantList = new Array<Restaurant>(n);

  for (let i = 1; i <= n; i++) {
    restaurantList[i] = {
      no: i,
      city: scan(),
      point: scanInt()
    };
  }

  restaurantList.sort((a, b) => {
    const cityComparison = a.city.localeCompare(b.city);

    return cityComparison || b.point - a.point;
  });

  const answerList = new Array<number>(n);

  for (let i = 0; i < n; i++) {
    answerList[i] = restaurantList[i].no;
  }

  log(answerList.join("\n"));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [python]
n,k = map(int,input().split())
a = list(map(int,input().split()))

p = []
m = []
for i in a:
    if i >= 0:
        p.append(i)
    else:
        m.insert(0,-i)
p.insert(0,0)
m.insert(0,0)

ans = 10**9
for i in range(k+1):
    if i < len(p) and k-i < len(m):
        d_p = p[i]
        d_m = m[k-i]
        d = min(d_p,d_m)*2 + max(d_p,d_m)
        ans = min(ans,d)

print(ans)
//  [python]
n,k=[int(i) for i in input().split()]
x=[int(i) for i in input().split()]

# ==================================================-
# 二分探索
# functionを満たす,search_listの最大の要素を出力
# 【注意点】searchリストの初めの方はfunctionを満たし、後ろに行くにつれて満たさなくなるべき
import math
import sys
sys.setrecursionlimit(10**9)
def binary_research(start,end,function):
    if start==end:
        return start
    middle=math.ceil((start+end)/2)
    if function(middle):
        start=middle
    else:
        end=middle-1
    return binary_research(start, end, function)
positive=[]
negative=[]
zero=False


for i in x:
    if i<0:
        negative.append(abs(i))
    elif i>0:
        positive.append(i)
    else:
        zero=True
positive.sort()
negative.sort()


def function(time):
    if time==-1:
        return True
    ans_list=[]
    ans=0
    if zero:
        ans+=1
    for i in positive:
        if i<=time:
            ans_list.append(i)
            ans+=1
        else:
            break
    negative_list=[]
    for i in negative:
        if i<=time:
            negative_list.append(i)
        else:
            break
    negative_list=negative_list[::-1]
    newans=ans
    while negative_list:
        newans,ans_list,negative_list=function2(ans_list,negative_list,newans,time)
        ans=max(ans,newans)
        if ans_list==[]:
            break
        else:
            ans_list.pop()
            newans-=1
    if ans>=k:
        return False
    return True



def function2(ans_list,negative_list,ans,time):
    if ans_list==[]:
        max_num=0
    else:
        max_num=ans_list[-1]
    remain_time=time-max_num*2
    while negative_list:
        i=negative_list.pop()
        if max_num==0:
            if i<=remain_time:
                ans+=1
        elif max_num+i+min(i,max_num)<=time:
            ans+=1
        else:
            negative_list.append(i)
            break
    return ans,ans_list,negative_list


print(binary_research(-1,3*10**8+1,function)+1)
//  [python]
import numpy as np
import math


N, K = map(int, input().split())
ina = list(map(int, input().split()))

X = np.zeros(N, dtype=int)

for n in range(N):
    X[n] = ina[n]


D = np.zeros(N - K+1, dtype=int)

for i in range(N-K+1):
    if X[i] > 0:
        D[i] = X[i+K-1]
    elif X[i+K-1] < 0:
        D[i] = abs(X[i])
    else:
        D[i] = min(abs(X[i]), abs(X[i+K-1])) + X[i+K-1] - X[i]

# print(D)
        
print(min(D))
//  [java]
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int []po=new int[n];
        for(int i=0;i<n;i++)po[i]=sc.nextInt();
        int ans=Integer.MAX_VALUE;
        for(int i=0;i<n-k+1;i++){
            int sum=0;
            for(int j=1;j<k;j++)
                sum+=po[i+j]-po[i+j-1];
            sum+=Math.min(Math.abs(po[i]),Math.abs(po[i+k-1]));
            ans=Math.min(ans,sum);
        }
        System.out.println(ans);
    }
}
//  [java]
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int K = sc.nextInt();
	int[] l = new int[N-1];
	int[] x = new int[N];
	if(K == 1) {
	    System.out.println(sc.nextInt());
	    return;
	}
	for(int i = 0; i<N; i++) {
	    x[i] = sc.nextInt();
	    if(i > 0) {
		l[i-1] = x[i] - x[i-1];
	    }
	}
	int min = Integer.MAX_VALUE;
	for(int i = 0; i+K-2 < N-1; i++) {
	    int kl = 0;
	    for(int j = 0; j< K-1; j++){
		kl = kl + l[i+j];
	    }
	    int n = Math.min(Math.abs(x[i])+kl, Math.abs(x[i+K-1])+kl);
	    if(n<min) min = n;
	}
	System.out.println(min);

    }
}
//  [java]
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		int countMinus = 0;
		ArrayList<Integer> candle = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			int c = sc.nextInt();
			candle.add(c);
			if(c < 0) {
				countMinus++;
			}
		}
		
		// 要素数１の時は処理が面倒臭くなりそうなので最初に除外
		if(candle.size() == 1) {
			System.out.println(Math.abs(candle.get(0)));
			System.exit(0);
		}
		
		int minusMax = 0;
		for(int i = candle.size() - 1; i >=0; i--) {
			if(candle.get(i) > 0) {
				continue;
			}else {
				if(minusMax == k) {
					candle.remove(i);
					continue;
				}else {
					minusMax++;
				}
			}
		}
		
		int minTime = 0;
		for(int i = 0; i <= candle.size() - k; i++) {
			int first = candle.get(i);
			int end = candle.get(i + k - 1);
			
			int time = 0;
			if((first < 0) & (end > 0)) {
				first = Math.abs(first);
				time = Math.min(first, end) * 2 + Math.max(first, end);
			}else if(end < 0){
				time = Math.abs(first);
			}else if(first > 0) {
				time = end;
			}
			
			if(i == 0) {
				minTime = time;
			}else {
				minTime = Math.min(minTime, time);
			}
		}
		
		System.out.println(minTime);
	}

}