akhauriyash/Code-Regression huggingface dataset:
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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<_>>()
    };

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

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

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"2018 218"# => "Yes",
// r#"2763 0"# => "No",
r#"999"# => "ABC",

}

fn solve(src: &str) -> String {
    input! {
        source = src,
        s: chars,
    }

    let mut ans:i64 = 0;

    for i in 0..s.len() {
        if s[i] == '+' {
            ans += 1;
        } else {
            ans -= 1;
        }
    }

    ans.to_string()
}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main() {
    int n,x;
    while (1){
        cin >> n >>x;
        if (n==0&&x==0) {
            break;
        }
        int ans=0;
        for (int i=1; i<=n;i++ ) {
            for (int j=1; j<i; j++) {
                for (int k=1; k<j; k++) {
                    if (i+j+k==x) {
                        ans++;
                        //cout <<"("<<i<<","<<j<<","<<k<<")"<<endl;
                    }
                }
            }
        }
        cout << ans<<endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int n, x;
    cin >> n >> x;
    vector<int> m(n);
    int sum = 0;

    for(int i = 0; i < n; i++){
        cin >> m[i];
        sum += m[i];
    }
    int ans = n;
    sort(m.begin(), m.end());
    while(sum + m[0] <= x){
        ans++;
        sum += m[0];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void)
{
	int x,h;
	double s,y,n;

	scanf("%d %d",&x,&h);
	while(x!=0 && h!=0){
		n=(x/2.0)*(x/2.0)+h*h;
		y=sqrt(n);
		s=x*x+x*y/2*4;
		printf("%lf\n",s);
		scanf("%d %d",&x,&h);
	}
	return 0;
}

Measured memory_bytes: 1060
package main

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

func main() {
	defer writer.Flush()
	T = make([]string, M)
	N := ReadInt()
	for i := 0; i < N; i++ {
		cmd, key := ReadString(), ReadString()
		if cmd == "insert" {
			insert(key)
		} else {
			if find(key) {
				Println("yes")
			} else {
				Println("no")
			}
		}
	}
}

var M = 1046527
var T []string

var charMap = map[byte]int{
	'A': 1,
	'C': 2,
	'G': 3,
	'T': 4,
}

func keyToInt(key string) int {
	v := 0
	for _, c := range []byte(key) {
		v = v*5 + charMap[c]
	}
	return v
}

func h1(key int) int {
	return key % len(T)
}

func h2(key int) int {
	return 1 + key%(len(T)-1)
}

func hash(key int, i int) int {
	return (h1(key) + i*h2(key)) % len(T)
}

func insert(key string) {
	k := keyToInt(key)
	for i := 0; ; i++ {
		// オープンハッシュ法
		h := hash(k, i)
		if T[h] == "" {
			T[h] = key
			return
		} else if T[h] == key {
			return
		}
	}
}

func find(key string) bool {
	k := keyToInt(key)
	for i := 0; ; i++ {
		h := hash(k, i)
		if T[h] == "" {
			return false
		}
		if T[h] == key {
			return true
		}
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }

var writer = bufio.NewWriter(os.Stdout)

func Printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }
func Println(a ...interface{})               { fmt.Fprintln(writer, a...) }



Measured memory_bytes: 38788
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defmacro aif (expr then else)
    `(let ((it ,expr))
       ,then
       ,else))

(defun main (x line)
  (apply #'min
         (mapcar (lambda (f)
                   (count-if (lambda (p) (funcall f x p)) line))
                 (list #'< #'>))))

(let* ((n (read))
       (m (read))
       (x (read))
       (line (read-times m)))
  (princ (main x line)))


Measured memory_bytes: 15968
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		String[] c = new String[h];
		for (int i = 0; i < h; i++) {
			c[i] = sc.next();
		}
		for (int j = 0; j < h; j++) {
			for (int i = 0; i < 2; i++) {
				System.out.println(c[j]);
			}
		}
	}
}


Measured memory_bytes: 23764
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

//-----------------------
const int MOD = (int)1e9 + 7;
struct mint { int n; mint(int n = 0) : n(n) { } };
mint operator+(mint a, mint b) { return (a.n += b.n) >= MOD ? a.n - MOD : a.n; }
mint operator-(mint a, mint b) { return (a.n -= b.n) < 0 ? a.n + MOD : a.n; }
mint operator*(mint a, mint b) { return 1LL * a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
ostream &operator<<(ostream &os, mint a) { return os << a.n; }
istream &operator>>(istream &is, mint& a) { return is >> a.n; }
mint operator^(mint a, long long n) { mint r = 1;
    while (n) { if (n & 1) r *= a; a *= a; n >>= 1; } return r; }
mint inv(mint x) { long long a = x.n, b = MOD, u = 1, v = 0;
    while (b) { long long t = a/b; swap((a -= t*b), b); swap((u -= t*v), v); }
    return mint(u); }
bool operator<(const mint &a, const mint &b) { return a.n < b.n; }
//-----------------------

using Graph = vector<vector<int>>;
enum { W, B };
vector<vector<mint>> dp;
void dfs(Graph &g, int u, int p) {
    dp[u][W] = dp[u][B] = 1;
    for (int v: g[u]) if (v != p) {
        dfs(g, v, u);
        dp[u][W] *= dp[v][W] + dp[v][B];
        dp[u][B] *= dp[v][W];
    }
}

int main() {
    int n; cin >> n;
    Graph g(n);
    for (int i = 0; i < n - 1; i++) {
        int x, y; cin >> x >> y; x--, y--;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }
    dp.assign(n, vector<mint>(2));
    dfs(g, 0, -1);
    cout << dp[0][W] + dp[0][B] << endl;
    return 0;
}

Measured memory_bytes: 18176
#include <iostream> 
#include <algorithm> 
using namespace std;

int main(){
  int N;
  cin >> N;
  int a[101];
  
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  
  sort(a, a + N, greater<int>());
  
  int Alice = 0;
  int Bob = 0;
  for(int i = 0; i < N; i++){
    if(i % 2 == 0){
      Alice += a[i];
    }
    
    else{
      Bob += a[i];
    }
  }
  cout << Alice - Bob << endl;
}
      
    


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

int main(void){
    string res;
    for(int n; cin >> n, n; cout << res << endl){
        int sum = n != 1;
        for(int i = 2; i * i <= n; i++)
            if(!(n % i)) sum += i + (i * i != n ? n / i:0);
        res = sum == n ? "perfect number":sum > n ? "abundant number":"deficient number";
    }

    return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<string>
using namespace std;

int ch(string &a){
  char b;
  b = a[a.length()-1];
  
  for(int i=a.length()-1;i>0;i--){
    a[i] = a[i-1];
  }
  a[0] = b;
  return 0;
}

  
int main(){
  string a,b;
  cin>>a>>b;
  int i=0;
  
  while(i<a.length()){
    if(a==b){
      cout<<"Yes"<<endl;
      return 0;
    }
    ch(a);
    i++;
  }
  
  cout<<"No"<<endl;
  return 0;
}
    

Measured memory_bytes: 256
#include <stdio.h>
#include<string.h> 

int main(void){
    int n,m,clear=0,penalty=0,qn,pe[100001][2]={0};//pe[][0]=ペナル数 pe[][1]=ACとったことがあるかあり=1なし=0
    char pf[3];
    
    scanf("%d%d",&n,&m);
    
    for(int i=0;i<m;i++){
       scanf("%d%s",&qn,pf);
        if(!pe[qn][1]){
            if(strcmp("WA",pf)==0){pe[qn][0]++;}
            if(strcmp("AC",pf)==0){clear++;pe[qn][1]=1;}
        }
    }
    for(int i=1;i<=n;i++){
        penalty+=pe[i][0]*pe[i][1];
    }
    printf("%d %d",clear,penalty);
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();
		int n = r.ri();
		int s = getDigitSum(n);
		if((n%s)==0)
			print("Yes");
		else
			print("No");
	}
	
	public static int getDigitSum(int n) {
		String str = ""+n;
		int sum = 0;
		for(int i = 0; i<str.length();i++) {
			sum += Integer.parseInt(""+str.charAt(i));
		}
		return sum;
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}
	
	public static void swap(int[] arr, int pos1, int pos2) {
		int temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	public static void swap(long[] arr, int pos1, int pos2) {
		long temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	
	public static String al(String s) {
		return s + "\n";
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}


Measured memory_bytes: 20180
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder_1
{
    class Program
    {
        static void Main(string[] args)
        {
            string nyu = Console.ReadLine();
            
            if(nyu == "A")
            {
                Console.WriteLine("T");
            }
            else if(nyu == "T")
            {
                Console.WriteLine("A");
            }
            else if(nyu == "C")
            {
                Console.WriteLine("G");
            }
            else
            {
                Console.WriteLine("C");
            }
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
    int n;
    cin >> n;
    int array[n];
    for(int i=0; i<n; i++){
        cin >> array[i];
    }
    for(int j=n-1; j>-1; j--){
        cout << array[j] << flush;
        if(j!=0) cout << " "<< flush;
    }
    cout << endl;
}


Measured memory_bytes: 3084
#!/usr/bin/env python3

import sys

sys.setrecursionlimit(1000000)

n, m = [int(x) for x in input().split()]
edges = []
g = [[] for _ in range(n)]
for _ in range(m):
    a, b = [int(x) for x in input().split()]
    a -= 1
    b -= 1
    e = len(edges)
    g[a].append(e)
    g[b].append(e)
    edges.append((a, b))

if m % 2 == 1:
    print(-1)
    sys.exit(0)


visited = [False] * n
visitede = [False] * m


def build_stree(i):
    cts = []
    for e in g[i]:
        j = edges[e][1 if edges[e][0] == i else 0]
        if visited[j]:
            continue
        visitede[e] = True
        visited[j] = True
        cts.append((e, build_stree(j)))
    return i, cts


visited[0] = True
st = build_stree(0)

rev_e = [None if v else False for v in visitede]


def pos(t):
    i, cts = t
    for _, ct in cts:
        pos(ct)
    es = [e for e in g[i] if rev_e[e] is None]
    assert len(es) <= 1
    if not es:
        return
    f = es[0]
    rev_e[f] = (sum(
        (edges[e][0] == i) ^ rev_e[e]
        for e in g[i] if e != f
    ) % 2 != 0) ^ (edges[f][0] == i)


pos(st)

for ed, re in zip(edges, rev_e):
    if re:
        b, a = ed
    else:
        a, b = ed
    print(a + 1, b + 1)


Measured memory_bytes: 174228
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;
int main(){
	int s,t,u;
	cin >> s;
	t = s % 100;
	u = s / 100;
	u = u % 100;
	if (t > 0 && t <= 12) {
		if (u > 0 && u <= 12) {
			cout << "AMBIGUOUS" << endl;
		}
		else {
			cout << "YYMM" << endl;
		}
	}
	else if (u > 0 && u <= 12) {
		cout << "MMYY" << endl;
	}
	else {
		cout << "NA" << endl;
	}
}

Measured memory_bytes: 256
from collections import deque

N,M=map(int,input().split())
G=[[] for _ in range(N+1)]
for i in range(M):
  a,b=map(int,input().split())
  G[a].append(b)
  G[b].append(a)

ans=[0]*(N+1)
d=deque([1])
while d:
  c=d.popleft()
  for g in G[c]:
    if not ans[g]:
      d.append(g)
      ans[g]=c

print('Yes')
for i in range(2, N+1):
  print(ans[i])

Measured memory_bytes: 34132
#include <iostream>
using namespace std;

int main(void){
    int n,i,k,a[110],min,x;
    
    int dp[110][110];
    int length,left,mid,right;
    
    cin>>n;
    
    cin>>a[0]>>a[1];
    for(i=2;i<n+1;i++){
        cin>>x>>a[i];
    }
    
    for(i=0;i<n;i++){
        dp[i][i]=0;
    }

    for(length=1;length<n;length++){
        for(left=0;left<n-length;left++){
            min=1000000000;
            right=left+length;
            for(mid=left;mid<right;mid++){
                x=dp[left][mid]+dp[mid+1][right]+a[left]*a[mid+1]*a[right+1];
                if(x<min)min=x;
            }
            dp[left][right]=min;
        }
    
    }

    cout<<dp[0][n-1]<<endl;
    return 0;
}


Measured memory_bytes: 3148
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    int a;
    string b, c,ans="";
    cin >> a >> b >> c;
    rep(i, a) {
        ans += b[i];
        ans += c[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

sm = 0
for i in range(N):
    sm += 1 / A[i]
print(1/sm)


Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 2019
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

s=list(ss())
k=ii()

500000000000000
5*10^14

if len(list(set(s)))==1:
    print(s[0])
    exit()

cnt=0
chk=True
ans=1
for i in range(len(s)):
    if chk and s[i]=="1":
        cnt+=1
    elif chk and s[i]!="1":
        chk=False
        ans=int(s[i])

    else:
        chk=False

if cnt >=k:
    print(1)
else:
    print(ans)




Measured memory_bytes: 63468
#include <algorithm>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>


using namespace std;


class Solution {
 public:
  void solve(std::istream& in, std::ostream& out) {
    int n;
    in >> n;
    int ar[n];
    for (int ctr1 = 0; ctr1 < n; ++ctr1)
      in >> ar[ctr1];
    sort(ar, ar + n);
    reverse(ar, ar + n);
    int rez = ar[0] / 2;
    rez += accumulate(ar + 1, ar + n, 0);
    out << rez;
  }
};

void solve(std::istream& in, std::ostream& out)
{
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}
// Powered by caide (code generator, tester, and library code inliner)


#include <fstream>
#include <iostream>


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


  istream& in = cin;


  ostream& out = cout;

  solve(in, out);
  return 0;
}



Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>

#include <climits>
#include <cmath>
#include <cstring>

#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	ll arr[100002] = {};
	ll n,k;
	cin >> n >> k;
	for(int i=0 ; i<n ; i++)
	{
		int a,b;
		cin >> a >> b;
		arr[a] += b;
	}

	for(int i=0 ; i<=100000 ; i++)
	{
		if(arr[i] > 0)
		{
			if(k-arr[i] <= 0)
			{
				cout << i; return 0;
			}
			k -= arr[i];
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int b, x, t = 1, y = 0;
	cin >> b >> x;
	if(b == 1)
	{
		if(x == 1)
		{
			cout << "Yes" << endl;
			cout << 1 << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	else if(b == 2)
	{
		if(x == 2)
		{
			cout << "Yes" << endl;
			cout << 1 << endl << 2 << endl << 3 << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	else
	{
		if(x == 1 || x == 2*b-1)
		{
			cout << "No" << endl;
		}
		else
		{
			if(x == 2)
			{
				cout << "Yes" << endl;
				for(int i = 0; i < 2*b-1; i++)
				{
					if(i == b-2)
					{
						cout << x+1 << endl;
					}
					else if(i == b-1)
					{
						cout << x << endl;
					}
					else if(i == b)
					{
						cout << x-1 << endl;
					}
					else if(i == b+1)
					{
						cout << x+2 << endl;
					}
					else
					{
						if(y == 0 && t >= x-1)
						{
							t += 4;
							y = 1;
						}
						cout << t << endl;
						t++;
					}
				}
			}
			else
		    {
				cout << "Yes" << endl;
				for(int i = 0; i < 2*b-1; i++)
				{
					if(i == b-2)
					{
						cout << x-1 << endl;
					}
					else if(i == b-1)
					{
						cout << x << endl;
					}
					else if(i == b)
					{
						cout << x+1 << endl;
					}
					else if(i == b+1)
					{
						cout << x-2 << endl;
					}
					else
					{
						if(y == 0 && t >= x-2)
						{
							t += 4;
							y = 1;
						}
						cout << t << endl;
						t++;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 1536
# ABC126 D - Even Relation
import sys
sys.setrecursionlimit(20000000)

def dfs(node,distance):
    for next_node,edge_distangce in G[node]:
        if ans[next_node]==-1:
            ans[next_node] = (distance+edge_distangce)%2
            dfs(next_node,distance+edge_distangce)

N = int(input())
G = [[] for _ in range(N)]

for i in range(N-1):
    u,v,w = map(int,input().split())
    G[u-1].append([v-1,w])
    G[v-1].append([u-1,w])

ans = [-1]*N
dfs(0,0)
print(*ans,sep='\n')

Measured memory_bytes: 87176
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Route>[] graph = new ArrayList[n + 1];
		for (int i = 1; i <= n; i++) {
		    graph[i] = new ArrayList<Route>();
		}
		for (int i = 0; i < n - 1; i++) {
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    int c = sc.nextInt();
		    graph[a].add(new Route(a, b, c));
		    graph[b].add(new Route(b, a, c));
		}
		int q = sc.nextInt();
		int k = sc.nextInt();
		ArrayDeque<Route> deq = new ArrayDeque<>();
		deq.add(new Route(0, k, 0));
		long[] costs = new long[n + 1];
		while (deq.size() > 0) {
	        Route r = deq.poll();
	        costs[r.to] = r.cost;
	        for (Route x : graph[r.to]) {
	            if (x.to != r.from) {
	                x.cost += r.cost;
	                deq.add(x);
	            }
	        }
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < q; i++) {
		    sb.append(costs[sc.nextInt()] + costs[sc.nextInt()]).append("\n");
		}
	    System.out.print(sb);
   }
   
   static class Route {
       int from;
       int to;
       long cost;
       
       public Route(int from, int to, long cost) {
           this.from = from;
           this.to = to;
           this.cost = cost;
       }
   }
}




Measured memory_bytes: 175344
#include<bits/stdc++.h>
using namespace std;
 
ifstream fin("input.in");
int n, k , a[1001], ans = 0;


int main() {
  cin >> n >> k;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a, a+n);
  for(int i = 0; i < k; i++){
    ans += a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3644
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()
    val buff = mutableListOf<String>()

    val first = next()
    buff.add(first)

    var lastLetter = first.takeLast(1)

    repeat(n-1) {
        val word = next()
        if (word in buff) {
            println("No")
            return
        }

        if (word.take(1) != lastLetter) {
            println("No")
            return
        }

        lastLetter = word.takeLast(1)
        buff.add(word)
    }

    println("Yes")
}

fun next() = readLine()!!
fun nextInt() = next().toInt()

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 33844
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> card(101,0);
  int i;
  int a;
  
  for(i=0;i<N;i++){
    cin >> a;
    if(card.at(a) == 0){
      card.at(a) = a;
    }
    else {
      card.at(a) = 0;
    }
  }
  
  
  
  int pick;
  pick = 0;//alice
  int sum;
  sum = 0;

  for(i=100;i>0;i--){
    if(card.at(i) != 0){
      if(pick == 0){
        sum += card.at(i);
        pick = 1;
      }
      else {
        sum -= card.at(i);
        pick = 0;
      }
    }
  }
  cout << sum << endl;
}




Measured memory_bytes: 256
N = int(input())
S1 = input()
S2 = input()
S = [S1,S2]
mod = 10**9+7
ans = 1
i = 0
prev = None
while i < N:
    if S[0][i] == S[1][i]:
        i += 1
        if prev is None:
            ans *= 3
        elif prev:
            ans *= 2
        else:
            ans *= 1
        prev = True
    else:
        i += 2
        if prev is None:
            ans *= 6
        elif prev:
            ans *= 2
        else:
            ans *= 3
        prev = False
    ans %= mod
print(ans%mod)

Measured memory_bytes: 3064
#include <algorithm>
#include <cstdio>
const int N=100005;
int fst[N],sz[N],n,tot=0;
long long ans=0;
struct Edge{
	int to,v,nxt;
}e[N*2];
void addedge(int x,int y,int z){
	e[++tot].to=y;e[tot].v=z;e[tot].nxt=fst[x];fst[x]=tot;
}
void dfs(int x,int fa){
	bool flag=0;sz[x]=1;
	for (int i=fst[x];i;i=e[i].nxt){
		int y=e[i].to;
		if (y!=fa){
			dfs(y,x);
			ans+=2ll*e[i].v*std::min(sz[y],n-sz[y]);
			sz[x]+=sz[y];
			if (sz[y]*2==n) ans-=e[i].v;
			flag|=sz[y]*2>=n;
		}
	}
	if (!flag && sz[x]*2>n){
		int v=100000000;
		for (int i=fst[x];i;i=e[i].nxt) v=std::min(v,e[i].v);
		ans-=v;
	}
}
int main(){
	scanf("%d\n",&n);
	for (int i=1;i<n;i++){
		int x,y,z;
		scanf("%d%d%d\n",&x,&y,&z);
		addedge(x,y,z);
		addedge(y,x,z);
	}
	dfs(1,0);
	printf("%lld\n",ans);
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;

int dp[100001][2], a[101], n;

// p = {0, 1} : {first, second}

int recur(int k, bool p) {
	if(k < a[0])
		return not p;

	int &ret = dp[k][p];
	if(ret != -1)
		return ret;

	for(int i = 0; i < n and k - a[i] >= 0; ++i)
		if(recur(k-a[i], not p) == p)
			return ret = p;
	
	return ret = not p;
}

int main() {
	int k;
	cin >> n >> k;

	for(int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a, a+n);

	memset(dp, -1, sizeof dp);
	cout << (recur(k, 0) == 0 ? "First":"Second") << endl;
	return 0;
}

Measured memory_bytes: 8832
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <map>
#include<algorithm>
using namespace std; 
int main(){
    int n; cin >> n;
    vector<long long> a(n+1);
    vector<long long> s(n);
    long long ans=0;
    for (int i=0;i<n+1;i++){
        cin >> a[i];
    }
    for (int i=0;i<n;i++){
        cin >> s[i];
    }
    for (int i=0;i<n;i++){
        if (a[i]>=s[i]){
            ans+=s[i];
        }
        else if (a[i]+a[i+1]>=s[i]){
            a[i+1]=a[i+1]-(s[i]-a[i]);
            ans+=s[i];
        }
        else{
            ans+=a[i]+a[i+1];
            a[i+1]=0;
        }
    }
    cout << ans << "\n";
}




Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		long[] V=new long[N];
		long[] hidarikara=new long[N];
		long[] migikara=new long[N];
		long[][] houseki=new long[N+1][2];
		for(int i=0; i<N; i++) {
			V[i]=sc.nextLong();
			houseki[i][0]=V[i];
			houseki[i][1]=i;
		}
		quick_sort(houseki,0,N-1);
		for(int i=0; i<N; i++) {
			hidarikara[i]=V[i];
			migikara[i]=V[N-i-1];
		}

		long max=0;	//最大値
		ArrayList<Long> ten=new ArrayList<Long>();
		for(int i=0; i<=N; i++) {	//何個石を取る作業をするか
			long tmpsum=0;
			if(i<=K) {//取る操作だけでおわるか？
				for(int j=0; j<=i; j++) {
					tmpsum=0L;
					ten=new ArrayList<Long>();
					//左から j個、右から(i-j)個取る
					for(int k=0; k<j; k++) {
						ten.add(hidarikara[k]);
						tmpsum+=hidarikara[k];
					}
					for(int k=0; k<(i-j); k++) {
						ten.add(migikara[k]);
						tmpsum+=migikara[k];
					}
					Collections.sort(ten);
					int nokori=K-i;	//取り出してつぎにいろいろする
					for(int k=0; k<Math.min(ten.size(), nokori); k++) {
						long gets=ten.get(k);
						if(gets<0) {
							tmpsum-=gets;
						}
						else {
							break;
						}
					}
					max=Math.max(max,tmpsum);
				}
			}
			else {
				break;
			}
		}
		pl(max);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static void quick_sort(long[][] d, int left, int right) {
		if (left>=right) {
			return;
		}
		long p = d[(left+right)/2][0];
		int l = left, r = right;
		long tmp,tmp1,tmp2;
		while(l<=r) {
			while(d[l][0] < p) { l++; }
			while(d[r][0] > p) { r--; }
			if (l<=r) {
				tmp = d[l][0]; d[l][0] = d[r][0]; d[r][0] = tmp;
				tmp1=d[l][1]; tmp2=d[r][1]; d[l][1]=tmp2; d[r][1]=tmp1;
				l++; r--;
			}
		}
		quick_sort(d, left, r);
		quick_sort(d, l, right);
	}
}

Measured memory_bytes: 25940
#include<bits/stdc++.h>
using namespace std;

long long N,K;
long long ans;

int main()
{
    scanf("%lld%lld",&N,&K);

    for(int i = 1; i <= N; i++)
    {
        if(i <= K)continue;
        ans += (N + 1) / i * (i - K) + max(0LL,(N + 1) % i - K);
    }
    printf("%lld\n",ans - N * (K == 0));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int INF = 1e9;
const int MOD = INF+7;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.rbegin(),v.rend()
#define MP make_pair
#define pb push_back
using P = pair<int,int>;
//b

signed main(){
    int N, L;
    cin >> N >> L;
    int MIN = 1e9;
    int ans = 0;
    bool c = false;
    for(int i=1;i<=N;i++){
        ans += L+i-1;
    }
    if(L > 0){
        ans -= L;
    }
    else if(abs(L-1) > N) ans -= (L+N-1); 

    cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a1=1e9,a2=-1e9,b1=1e9,b2=-1e9;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		long long a,b;
		scanf("%lld%lld",&a,&b);
		long long x=a+b,y=a-b;
		a1=min(a1,x);
		a2=max(a2,x);
		b1=min(b1,y);
		b2=max(b2,y);
	}
	printf("%lld\n",max(a2-a1,b2-b1));
	return 0;
}

Measured memory_bytes: 3812
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int N,K,A,B,C;
vector<long long int>pl,mi;

int main()
{
    cout << fixed << setprecision(18);
    cin>>A>>B>>C;
    if((3*max({A,B,C})-(A+B+C))%2==0){
        cout<<(3*max({A,B,C})-(A+B+C))/2<<endl;
    }else{
        cout<<(3*max({A,B,C})-(A+B+C))/2+2<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

#define ll long long
#define mx  3000005
#define mod 1000000007
#define lim 100

using namespace std;


int main() {
	ios_base ::sync_with_stdio(false);
	int t;
	cin>>t;

	while(t--)
	{
		ll a,b,c,d;cin>>a>>b>>c>>d;

	     if(a<b || b>d)
	     {
		  cout<<"No\n";
		  continue;
	     }

	     ll g=__gcd(b,d);

	     ll worst=g-a%g;

	     if(c>=b-worst)
	     	cout<<"Yes\n";
		else
			cout<<"No\n";

	}

     return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

    int t1, t2, r1, r2; cin>>t1>>t2>>r1>>r2;

    if(r1 == -1 || r2 == -1){
        if(t1 > t2) cout << "Bob" << endl;
        else if(t1 < t2) cout << "Alice" << endl;
        else cout << "Draw" << endl;
    }
    else{
        if(r1 > r2) cout << "Alice" << endl;
        else if(r1 < r2) cout << "Bob" << endl;
        else cout << "Draw" << endl;
    }

    return 0;
}


Measured memory_bytes: 3148
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b,c,d;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b){
        d = a;
        a = b;
        b = d;
    }
    if(b>c) {
        d = b;
        b = c;
        c = d;
    }
    if(a>b){
        d = a;
        a = b;
        b = d;
    }
        printf("%d %d %d\n",a,b,c);
    
    return 0;
}



Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

// FOR FOLDING {
#define debug(var)  do{ std::cout << #var << " : "; view(var); }while(0)
using ll = long long;
using ld = long double;
inline int num (const std::string& S, int idx) noexcept { return S.at(idx) - '0'; }
inline int ctoi(char c) noexcept { return c - '0'; }
inline bool isNumber(char c) noexcept { return ('0'<c && c<'9'? true : false); }
inline int safeCtoi(char c) { if(isNumber(c)) { return ctoi(c); } else { throw 1; } }
inline char itoc(int i) noexcept { return i + '0'; }
inline unsigned int bitMask(int i) noexcept { return (1 << i); }
inline bool isTrue(unsigned int bit, int i) noexcept { return bit & bitMask(i); }
inline bool isEven(int num) noexcept { return !num%2; }
inline bool isOdd(int num) noexcept { return num%2; }
template<typename T> inline short sgn(T num) noexcept { return (num==0? 0 : (num>0? 1 : -1) ); }
template<typename T> inline bool isZero(T num) noexcept { return (num==0? true : false); }
template<typename T> inline bool isPositive(T num) noexcept { return (num>0? true : false); }
template<typename T> inline bool isNegative(T num) noexcept { return (num<0? true : false); }
template<typename T> void view(T e) noexcept { cout << e; }
template<typename T> void view(std::vector<T> v) noexcept { for(const auto& e : v) cout << e << " "; }
template<typename T> void view(std::vector<std::vector<T>> vv) noexcept { for(const auto& v : vv) view(v); }
// }

int sum(vector<int> const& v){
	int res = 0;
	for(const auto& e : v){
		res += e;
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<int> a(m);
	for(auto& e : a) cin >> e;
	int playingDays = n - sum(a);
	if( playingDays >= 0 ){
		cout << playingDays << endl;
	}else{
		cout << -1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3664
#include <iostream>
using namespace std;

int main() {
  int n;
  cin >> n;
  int p[n];
  for(int i = 0; i < n; i++) cin >> p[i];

  int cnt = 0;
  for(int i = 1; i < n-1; i++) {
    if((p[i-1] > p[i] && p[i] > p[i+1]) || (p[i-1] < p[i] && p[i] < p[i+1])) cnt++;
  }

  cout << cnt;
}


Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
using namespace std;

int main() {
	int a, b, c, d, dur;
	cin >> a >> b >> c >> d;
	if (a <= b && b <= c && c <= d) dur = 0;
	else if (a <= c && c <= b && b <= d) dur = b - c;
	else if (a <= c && c <= d && d <= b) dur = d - c;
	else if (c <= d && d <= a && a <= b) dur = 0;
	else if (c <= a && a <= d && d <= b) dur = d - a;
	else if (c <= a && a <= b && b <= d) dur = b - a;
	cout << dur;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdint>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <memory>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

// constexpr std::int64_t INF = 1ull << 50;
constexpr int INF = 1 << 20;

auto main() -> int {
  int N;
  std::cin >> N;

  auto f = [](const auto& a, const auto& b) {
    auto& af = std::get<1>(a);
    auto& as = std::get<2>(a);
    auto& bf = std::get<1>(b);
    auto& bs = std::get<2>(b);
    return af == bf ? as < bs : af > bf;
  };
  using psi = std::tuple<int, std::string, int>; // index, name, point
  std::priority_queue<psi, std::vector<psi>, decltype(f)> q(f);

  for (auto i = 0; i < N; ++i) {
    std::string Si{};
    int Pi;
    std::cin >> Si >> Pi;
    q.emplace(i, std::move(Si), Pi);
  }

  while (!q.empty()) {
    const auto& v = q.top();
    std::cout << (std::get<0>(v) + 1) << std::endl;
    q.pop();
  }
}


Measured memory_bytes: 888
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  // s = 00+01+02 = 00+11+22 = 02+12+22 = 10+11+12
  // 02 = x
  // s = x+00+01
  // 22 = s-00-11 = x+01-11
  // 12 = s-02-22 = -x+00+11
  // 21 = s-01-11 = x+00-11
  // a         b        x
  // 2x+b-2c   c        -x+a+c
  // -x+2c     x+a-c    x+b-c
  // a+b+x = 3c
  int x = 3*c-a-b;
  printf("%d %d %d\n%d %d %d\n%d %d %d\n",a,b,x,2*x+b-2*c,c,-x+a+c,-x+2*c,x+a-c,x+b-c);
  return 0;
}


Measured memory_bytes: 256
MOD=10**9+7
N,M=map(int,input().split())
A=[True]*(N+2)

for i in range(M):
    a=(int(input())+1)
    A[a]=False

S=[0]*(N+2)
S[1]=1
for i in range(2,N+2):
    if(A[i]):
        S[i]=(S[i-1]+S[i-2])%MOD
    else:
        S[i]=0
print(S[N+1])

Measured memory_bytes: 7668
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1e9 + 10;//10^9
ll MOD  = 1000000007;
int dy[] = {0,0,1,-1};
int dx[] = {1,-1,0,0};

int main(void){
    int N;
    cin >> N;
    ll X[N], Y[N], Z[N];
    ll maxZ = 0;
    for(int i = 0; i < N; i++){
        cin >> X[i] >> Y[i];
        Z[i] = abs(X[i]) + abs(Y[i]);
        maxZ = max(maxZ, Z[i]);
    }
    bool l = 1;
    for(int i = 0; i < N - 1; i++){
        if((Z[i] - Z[i+1]) % 2) l = 0;
    }
    vector<ll> ArmLong(38);
    for(int i = 37; i >= 0; i--){
        ArmLong[i] = pow(2, 37-i);
    }
    
    if(l == 0){
        cout << -1 << endl;
    }else{
        if(Z[0] % 2 == 1){
            cout << 38 << endl;
            for(int i = 0; i < 38; i++) cout << ArmLong[i] << " ";
            cout << endl;
            for(int i = 0; i < N; i++){
                for(int j = 0; j < 38; j++){
                    if(abs(X[i]) > abs(Y[i])){
                        if(X[i] > 0){
                            cout << "R";
                            X[i] -= ArmLong[j];
                        }else{
                            cout << "L";
                            X[i] += ArmLong[j];
                        }
                    }else{
                        if(Y[i] > 0){
                            cout << "U";
                            Y[i] -= ArmLong[j];
                        }else{
                            cout << "D";
                            Y[i] += ArmLong[j];
                        }
                    }
                }
                cout << endl;
            }
        }else{
            cout << 39 << endl;
            for(int i = 0; i < 38; i++) cout << ArmLong[i] << " ";
            cout << 1 << endl;
            for(int i = 0; i < N; i++){
                X[i]++;
                for(int j = 0; j < 38; j++){
                    if(abs(X[i]) > abs(Y[i])){
                        if(X[i] > 0){
                            cout << "R";
                            X[i] -= ArmLong[j];
                        }else{
                            cout << "L";
                            X[i] += ArmLong[j];
                        }
                    }else{
                        if(Y[i] > 0){
                            cout << "U";
                            Y[i] -= ArmLong[j];
                        }else{
                            cout << "D";
                            Y[i] += ArmLong[j];
                        }
                    }
                }
                cout << "L";
                cout << endl;
                
            }
        }
    }
    
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// ＜仕様＞
// d[i][j]にはあらかじめその辺のコストを入れておく．
// ただし，辺が存在しない要素にはINFを入れ，d[i][i] = 0とする．
// 負閉路の検出には，d[i][i] < 0かどうかを見れば良い．

const ll INF = 2e9;

ll dist[505][505];

void warchall_floyd(int N){
    rep(k,N)rep(i,N){
        if(dist[i][k] == INF) continue;
        rep(j,N){
            if(dist[k][j] == INF) continue;
	        chmin(dist[i][j], dist[i][k]+dist[k][j]);
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	rep(i,10)rep(j,10){
		cin >> dist[i][j];
	}
    warchall_floyd(10);
	ll ans = 0;
	rep(i,h)rep(j,w){
		int a;
		cin >> a;
		if(a == -1) continue;
		ans += dist[a][1];
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
from math import ceil
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
lst0 = [a%10, b%10, c%10, d%10, e%10]
lst = [(a-1)%10, (b-1)%10, (c-1)%10, (d-1)%10, (e-1)%10]
time0 = [int(a/10), int(b/10), int(c/10), int(d/10), int(e/10)]
time = [ceil(a/10), ceil(b/10), ceil(c/10), ceil(d/10), ceil(e/10)]
last = lst.index(min(lst))
time.pop(last)
print(sum(time)*10+lst0[last]+time0[last]*10)

Measured memory_bytes: 3064