Harryxun/stf_run huggingface dataset:
def popularity(votes, N, M):
    
    total_votes = sum(votes)
    coef = 1.0 / (4.0 * M)
    limit = coef * total_votes
    
    cnt = 0
    for vote in votes:
        if vote > limit:
            cnt += 1
    
    if cnt >= M:
    	return "Yes"
    
    return "No"
  
N, M = [int (x) for x in input().split()]
votes = [int (x) for x in input().split()]
print(popularity(votes, N, M))


### FIXED CODE ###

def swap(x,y,z):
  x, y = y, x
  x, z = z, x
  
  print('%d %d %d' % (x,y,z))
  
val = list(input().split(' '))
x, y, z = [ int(x) for x in val ]
swap(x,y,z)
N, D = map(int, input())
x = N//((2*D)+1)
if(x*((2*D)+1)>= N):
	print(N//((2*D)+1))
else:
	print(N//((2*D)+1)+1)

### FIXED CODE ###

N, D = map(int, input().split())
x = N//((2*D)+1)
if(x*((2*D)+1)>= N):
	print(N//((2*D)+1))
else:
	print((N//((2*D)+1)+1))
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


N = int(input())
A = list(map(int, input().split()))
X = [0] * (2 * 10**5 + 1)
for a in A:
    X[a] += 1
ans = 0
for a in A:
    if X[a] > 1:
        continue
    for d in make_divisors(a)[:-1]:
        if X[d]:
            break
    else:
        ans += 1

print(ans)

### FIXED CODE ###

def gcd(a, b):
    while b: a, b = b, a % b
    return a


def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2, 7, 61] if n < 1 << 32 else [2, 3, 5, 7, 11, 13, 17] if n < 1 << 48 else [2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
                                                                                     31, 37]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = y * y % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1


def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g):
                return g
            elif isPrimeMR(n // g):
                return n // g
            return findFactorRho(g)


def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i * i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += i % 2 + (3 if i % 3 == 1 else 1)
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret


def divisors(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p] + 1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return sorted(ret)


N = int(input())
A = list(map(int, input().split()))
ma = max(A)

X = [0] * (ma + 1)
Ans = [True] * (ma + 1)
ans = 0
A.sort()

for a in A:
    X[a] += 1
for a in A:
    if X[a] > 1:
        continue
    for d in divisors(a)[:-1]:
        if X[d]:
            break
    else:
        ans += 1
print(ans)
N,M = map(int,input().split())

a = [0]*M
b = [0]*M
c = [0]*M

for i in range(M):
    a[i],b[i],c[i] = map(int,input().split())

d = [[0]*N for i in range(N)]

for i in range(M):
    d[a[i]-1][b[i]-1] = c[i]
    d[b[i]-1][a[i]-1] = c[i]
    


for s in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][s]+d[s][j])

count = 0
for i in range(N):
    d[i][i] = float("inf")
    if d[a[i]-1][b[i]-1] != c[i]:

        count += 1
print(count)

### FIXED CODE ###

N,M = map(int,input().split())

a = [0]*M
b = [0]*M
c = [0]*M

for i in range(M):
    a[i],b[i],c[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1
    

d = [[float("inf")]*N for i in range(N)]

for i in range(M):
    d[a[i]][b[i]] = c[i]
    d[b[i]][a[i]] = c[i]
    
for i in range(N):
    d[i][i] = 0

for s in range(N):
    for j in range(N):
        for i in range(N):
            d[i][j] = min(d[i][j], d[i][s]+d[s][j])

count = 0
for i in range(M):
    if d[a[i]][b[i]] < c[i]:
        count += 1
print(count)
# coding: utf-8
import time
import re
import math
import fractions

def main():
    lst=[int(input()) for a in range(5)]
    lst2=[]
    index=0
    mx=0
    total=0
    for a in range(len(lst)):
        if math.ceil(list[a]/10)*10-list[a]>mx:
            mx=math.ceil(list[a])-list[a]
            index=a
    for a in range(len(lst)):
        if a==index:
            total+=lst[a]
        else:
            total+=math.ceil(lst[a]/10)*10
    print(total)
    
start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#"YNeos"[True::2]
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())
# global n,A,s,memo,mx,mn,L,B



### FIXED CODE ###

# coding: utf-8
import time
import re
import math
import fractions

def main():
    lst=[int(input()) for a in range(5)]
    index=0
    mx=0
    total=0
    for a in range(len(lst)):
        if math.ceil(lst[a]/10)*10-lst[a]>mx:
            mx=math.ceil(lst[a]/10)*10-lst[a]
            index=a
    #print(index)
    for a in range(len(lst)):
        if a==index:
            total+=lst[a]
        else:
            total+=math.ceil(lst[a]/10)*10
    print(total)
    
start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#"YNeos"[True::2]
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())
# global n,A,s,memo,mx,mn,L,B
import math
a,b=map(int, input().split())
f=math.gcd(a,b)
f2=a*b//f
print(f2)


### FIXED CODE ###

import fractions
a,b=map(int, input().split())
f=fractions.gcd(a,b)
f2=a*b//f
print(f2)
days = ["SUN", "MON", "TUE,","WED", "THU", "FRI", "SAT"]
s = input()
print(7-days.index(s))

### FIXED CODE ###

days = ["SUN", "MON", "TUE","WED", "THU", "FRI", "SAT"]
s = input()
print(7-days.index(s))
import sympy

N = int(input())

ans = 1
for i in range(2, N):
    ans += len(sympy.divisors(i))

print(ans)

### FIXED CODE ###

N = int(input())

ans = 0
for i in range(1, N):
    ans += (N - 1) // i

print(ans)
n = int(input())
A = list(map(int,input().split()))
color = []
cnt = 0

for i in range(n):
    c = A[i]//400
    if c<=7:
        color.append(c)
    else:
        cnt += 1

diff = set(color)
minimum = max(len(diff),1)
maximum = min(len(diff)+cnt)

print(minimum, maximum)

### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
color = []
cnt = 0

for i in range(n):
    c = A[i]//400
    if c<=7:
        color.append(c)
    else:
        cnt += 1

diff = set(color)
minimum = max(len(diff),1)
maximum = len(diff)+cnt

print(minimum, maximum)
import math
S = int(input())
print(math.floor(S/3600)+":"+math.floor(S -(math.floor(S/3600)/60)+":"+ S -math.floor(S/3600)-math.floor(S-(math.floor(S/3600)/60))

### FIXED CODE ###

S = int(input())
h = (S//3600)
m = (S - (h*3600))//60
b = S - (h*3600) - (m*60)
print(str(h)+":" +str(m) + ":" + str(b))
from bisect import *
n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# Aの累積和を保存しておく
# 各Aの要素について、Bが何冊読めるか二分探索する。
# 計算量: AlogB

for i in range(1,len(A)):
  A[i] += A[i-1]
  B[i] += B[i-1]

ans = 0
for i in range(len(A)):
  rest_time = k - A[i]
  if rest_time < 0:
    break
  numb = bisect_left(B, rest_time)
  anstmp = i + 1 + numb 
  ans = max(ans, anstmp)
print(ans)

### FIXED CODE ###

from bisect import *
n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# Aの累積和を保存しておく
# 各Aの要素について、Bが何冊読めるか二分探索する。
# 計算量: AlogB
A.insert(0, 0)

for i in range(1,len(A)):
  A[i] += A[i-1]
for i in range(1, len(B)):
  B[i] += B[i-1]

ans = 0
for i in range(len(A)):
  rest_time = k - A[i]
  if rest_time >= 0:
    numb = bisect_right(B, rest_time)
    anstmp = i + numb 
    ans = max(ans, anstmp)
print(ans)
a = input().split()
b = int(d[0])
c = int(d[1])
if b > c:
	first = b
    b = b - 1
else:
	first = c
	c = c - 1
if b > c:
	second = b
else:
	second = c
answer = first + second
print(str(answer))


### FIXED CODE ###

a = input().split()
b = int(a[0])
c = int(a[1])
if b > c:
	first = b
	b = b-1
else:
	first = c
	c = c-1
if b > c:
	second = b
else:
	second = c
answer = first + second
print(str(answer))
a, s, c = map(int,input().split())
print(a[0]+s[0]+c[0])

### FIXED CODE ###

a, s, c = input().split()
print(a[0]+s[0]+c[0])
n, m = map(int, input().split())
c = m - 2*n
if c <= 0:
    pirnt(n)
else:
    print(n + c//4)

### FIXED CODE ###

n, m = map(int, input().split())
c = m - 2*n
if c <= 0:
    print(m//2)
else:
    print(n + c//4)
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

ans = 'NO'
distance = abs(B-A)

t = distance/(V-W)

if 0 < t <= T:
  ans = 'YES'

print(ans)

### FIXED CODE ###

A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

ans = 'NO'
distance = abs(B-A)
if V == W:
  pass
else:
  t = distance/(V-W)
  if 0 < t <= T:
    ans = 'YES'

print(ans)
def run(x):
    '''

    '''
    print('{}'.format(0 if x==1 else 1))



if __name__ == '__main__':
    x = int(input())
    run(x)def run(x):
    '''

    '''
    print('{}'.format(0 if x==1 else 1))



if __name__ == '__main__':
    x = int(input())
    run(x)

### FIXED CODE ###

def run(x):
    '''

    '''
    print('{}'.format(0 if x==1 else 1))



if __name__ == '__main__':
    x = int(input())
    run(x)
n,m=map(int,input().split())
a=[0]*(n)
for _ in range(m):
  a[int(input())]+=1
dp=[0]*(n+1)
dp[0]=1
if a[1]!=1:
  dp[1]=1
for i in range(2,n+1):
  if a[i-2]==0 and a[i-1]==0:
    dp[i]=dp[i-2]+dp[i-1]
  elif a[i-1]!=0 and a[i-2]==0:
    dp[i]=dp[i-2]
  elif a[i-2]!=0 and a[i-1]==0:
    dp[i]=dp[i-1]
  else:
    dp[i]=0
print(dp[n]%(10**9+7))    

### FIXED CODE ###

n,m=map(int,input().split())
a=[0]*(n)
if n==1:
  print(1)
  exit()
if m>0:
  for _ in range(m):
    a[int(input())]+=1
dp=[0]*(n+1)
dp[0]=1
if a[1]!=1:
  dp[1]=1
for i in range(2,n+1):
  if a[i-2]==0 and a[i-1]==0:
    dp[i]=dp[i-2]+dp[i-1]
  elif a[i-1]!=0 and a[i-2]==0:
    dp[i]=dp[i-2]
  elif a[i-2]!=0 and a[i-1]==0:
    dp[i]=dp[i-1]
  else:
    dp[i]=0
print(dp[n]%(10**9+7))
package main

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

// 文字列を1行入力
func StrStdin() (stringReturned string) {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	stringReturned = scanner.Text()

	stringReturned = strings.TrimSpace(stringReturned)
	return
}

// 空白や空文字だけの値を除去したSplit()
func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
	stringSplited := strings.Split(stringTargeted, delim)

	for _, str := range stringSplited {
		if str != "" {
			stringReturned = append(stringReturned, str)
		}
	}
	return
}

// デリミタで分割して文字列スライスを取得
func SplitStrStdin(delim string) (stringReturned []string) {
	// 文字列で1行取得
	stringInput := StrStdin()

	// 空白で分割
	// stringSplited := strings.Split(stringInput, delim)
	stringReturned = SplitWithoutEmpty(stringInput, delim)

	return
}

// デリミタで分割して整数値スライスを取得
func SplitIntStdin(delim string) (intSlices []int, err error) {
	// 文字列スライスを取得
	stringSplited := SplitStrStdin(" ")

	// 整数スライスに保存
	for i := range stringSplited {
		var iparam int
		iparam, err = strconv.Atoi(stringSplited[i])
		if err != nil {
			return
		}
		intSlices = append(intSlices, iparam)
	}
	return
}

func main() {
	input, _ := SplitIntStdin(" ")
	N, M := input[0], input[1]

	input, _ = SplitIntStdin(" ")
	input = input[0:N]
	sum := 0
	for _, x := range input {
		sum += x
	}

	var M_f float64 = float64(M)
	var sum_f float64 = float64(sum)

	count := 0
	for _, x := range input {
		var x_f float64 = float64(x)
		if x_f >= sum_f/(4.0*M_f) {
			count += 1
		}
	}
	fmt.Println(sum_f / (4.0 * M_f))
	fmt.Println(count)
}

### FIXED CODE ###

n,m=map(int,input().split())
b=list(map(int,input().split()))
s=sum(b)
a=[i for i in b if i>=s/(4*m)]
print("Yes" if len(a)>=m else "No")
N=int(input())
D=int(input())
count=0
a = list(map(int,input().strip().split()))[:N]
for i in range(len(a)):
  distance=((i[0]**2)+(i[1]**2))**0.5
  if distance>D:
    count+=1
print(count)

### FIXED CODE ###

N,D=[int(i) for i in input().split()]
ans=0
for i in range(N):
  x,y=[int(i) for i in input().split()] 
  if x*x + y*y <= D*D:
      ans += 1
print(ans)
if R - L > 2019:
      print(0)
else:
    D = R - L
    L = L % 2019
    R = L + D
    a = 2018
    for i in range(D):
        for j in range(i+1,D+1):
            if (L+i)*(L+j)%2019 < a:
                a =(L+i)*(L+j)%2019
    print(a)


### FIXED CODE ###

L,R=map(int,input().split())
if R - L > 2019:
      print(0)
else:
    D = R - L
    L = L % 2019
    R = L + D
    a = 2018
    for i in range(D):
        for j in range(i+1,D+1):
            if (L+i)*(L+j)%2019 < a:
                a =(L+i)*(L+j)%2019
    print(a)
n = int(input())
all = set([i * j for i range(1, 10) for j range(1, 10)])
if n in all:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

# -*- coding: utf-8 -*-
a, b = map(int, input().split())

if a <= 9 and b <= 9:
  print(a * b)
else:
  print(-1)
c = [list(input()) for i in range(3)]
s = 0
for j in range(3):
  s += c[i][i]
print(s)  

### FIXED CODE ###

c = [list(input()) for i in range(3)]
s = ""
for j in range(3):
  s += str(c[j][j])
print(s)
string = input()
n = int(input())
for i in range(n):
    inp = [x for x in input().split()]
    a = int(inp[1])
    b = int(inp[2])
    if inp[0] == 'print':
        print(string[a:b+1])
    elif inp[0] == 'reverse':
        string = string[:a] + string[a:b+1][::-1] +string[b+1:]
    else:
        string = string[:a] + inp[3] + string[b+1]




### FIXED CODE ###

string = input()
for _ in range(int(input())):
    com = [x for x in input().split()]
    c = com[0]
    a,b = [int(com[i]) for i in range(1,3)]
    if c == 'reverse':
        string = string[:a] + string[a:b+1][::-1] + string[b+1:]
    if c == 'print':
        print(string[a:b+1])
    if c == 'replace':
        string = string[:a] + com[3] + string[b+1:]
def BellmanFord(edges,num_v,source):
  #グラフの初期化
  inf=float("inf")
  dist=[inf for i in range(num_v)]
  dist[source-1]=0
  
  #辺の緩和
  for i in range(num_v):
    for edge in edges:
      if edge[0] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
        dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
        if i==num_v-1: return -1
  
  return dist


N,M = [int(x) for x in input().split()]
edges = []
for _ in range(N):
    l = [int(x) for x in input().split()]
    l[2]*=-1
    edges.append(l)

route = BellmanFord(edges,N,1)
if(route == -1):
    print('inf')
else:
    print(-route[-1])


### FIXED CODE ###

from operator import itemgetter

def BellmanFord(edges,num_v,source):
  #グラフの初期化
  inf=float('inf')
  dist=[inf for i in range(num_v)]
  dist[source-1]=0

  #辺の緩和
  for i in range(num_v+1):
    for edge in edges:
      if edge[0] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
        dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
        if i==num_v and edge[1]==num_v: return -1

  return dist


#%%
N,M = [int(x) for x in input().split()]
edges = []
for _ in range(M):
    l = [int(x) for x in input().split()]
    l[2]*=-1
    edges.append(l)
#%%
route = BellmanFord(edges,N,1)
if(route == -1):
    print('inf')
else:
    print(-int(route[N-1]))
import math
r = int(input())
print(r ** 2 * math.pi, r * 2 * math.pi)

### FIXED CODE ###

import math
r = float(input())
print(r ** 2 * math.pi, r * 2 * math.pi)
day = list(map(int,input().split('/')))
day[0] = 2018
print(day[0],day[1],day[2],sep('/'))

### FIXED CODE ###

print(input().replace('017','018'))
n = input()
gr = itertools.groupby(n)
print(len(gr)-1)

### FIXED CODE ###

from itertools import groupby
print(len(list(groupby(input())))-1)
n = int(input())
cards = [[0 for i in range(13)] for j in range(4)]
n = int(input())
for i in range(n):
    card = list(input().split())
    card[1] = int(card[1])
    if card[0] == 'S':
        suit = 0 
    elif card[0] == 'H':
        suit = 1 
    elif card[0] == 'C':
        suit = 2 
    elif card[0] == 'D':
        suit = 3 
    cards[suit][card[1]-1] = 1 
for i in range(4):
    if i == 0:
        suit = 'S' 
    elif i == 1:
        suit = 'H' 
    elif i == 2:
        suit = 'C' 
    elif i == 3:
        suit = 'D' 
    for j in range(13):
        if not(cards[i][j]):
            print(suit, j+1)

### FIXED CODE ###

cards = [[0 for i in range(13)] for j in range(4)]
s2n = {'S': 0, 'H': 1, 'C': 2, 'D': 3}
n2s = 'SHCD'
n = int(input())
for i in range(n):
    card = list(input().split())
    card[1] = int(card[1])
    cards[s2n[card[0]]][card[1]-1] = 1
for i in range(4): 
    for j in range(13):
        if not(cards[i][j]):
            print(n2s[i], j+1)
N = int(input())
C = []
last_idx = [None for i in range(N+1)]
bef = [None for i in range(N+1)]
for i in range(1,N+1):
	c = int(input())
	C.append(c)
	if last_idx[c] != None:
		bef[i] = last_idx[c]
	last_idx[c] = i
dp = [0 for i in range(N+1)]
dp[1] = 1
for i in range(2, N+1):
	if bef[i] != None and bef[i] < i-1:
		dp[i] = dp[i-1] + dp[bef[i]]
	else:
		dp[i] = dp[i-1]
print(dp[N])

### FIXED CODE ###

MOD = 10**9 + 7
N = int(input())
C = []
last_idx = [0 for i in range(200001)]
bef = [0 for i in range(N+1)]
for i in range(1,N+1):
	c = int(input())
	C.append(c)
	bef[i] = last_idx[c]
	last_idx[c] = i
dp = [0 for i in range(N+1)]
dp[1] = 1
if N == 1 or N == 2:
	print(1)
	exit()

for i in range(2, N+1):
	if bef[i] < i-1:
		dp[i] = (dp[i-1] + dp[bef[i]]) % MOD
	else:
		dp[i] = dp[i-1]
print(dp[N])
N,M,K=map(int,input().split())
A =list(map(int,input().split()))
B =list(map(int,input().split()))
Sum = 0
Al = [0]
Bl = [0]
for i in range(N):
    Sum += A[i]
    Al.append(Sum)
Sum = 0
for j in range(M):
    Sum += B[i]
    Bl.append(Sum)
ans, j = 0, M
for i in range(N+1):
    if Al[i] > K:
        break
    while Bl[j] > K - Al[i]:
        j -= 1
    ans = max(ans,i+j)
print(ans)

### FIXED CODE ###

N,M,K=map(int,input().split())
A =list(map(int,input().split()))
B =list(map(int,input().split()))
Sum = 0
Al = [0]
Bl = [0]
for i in range(N):
    Sum += A[i]
    Al.append(Sum)
Sum = 0
for j in range(M):
    Sum += B[j]
    Bl.append(Sum)
ans, j = 0, M
for i in range(N+1):
    if Al[i] > K:
        break
    while Bl[j] > K - Al[i]:
        j -= 1
    ans = max(ans,i+j)
print(ans)
a=int(input())
b=input()
c=input()
d=""
for i in range(a):
  d=d+b[i]+c[i]
print(d)

### FIXED CODE ###

a=int(input())
b,c=input().split()
d=""
for i in range(a):
  d=d+b[i]+c[i]
print(d)
import sys;input=sys.stdin.readline

def main():
    n,q=map(int,input().split())
    event=[]
    stop=set()
    for i in range(n):
        s,t,x=map(int,input().split())
        event.append((s-x,x))
        event.append((t-x,-x))
    for i in range(q):
        event.append((int(input()),str(i)))
    
    event.sort()
    ans=[-1]*q
    minstop=float("inf")
    for t,x in event:
        if type(x)==str:
            ans[int(x)]=str(minstop)
            continue
        elif x>=0:
            stop.add(x)
        elif x<0:
            stop.remove(-x)
        if minstop!=x:
            minstop=min(stop or [-1])
    print("\n".join(ans))
    
if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys;input=sys.stdin.readline

n,q=map(int, input().split())
event=[]
for _ in range(n):
    s,t,x=map(int,input().split())
    event.append((s-x-0.5,1,x))
    event.append((t-x-0.5,-1,x))
for i in range(q):
    event.append((int(input()),0,i))
    
event.sort()
is_stop=False
stop=set()
minstop=float('inf')
ans=[-1]*q
for t,e,x in event:
    if e > 0:
        stop.add(x)
        if x<minstop:
            minstop=x
            is_stop=True
    elif e<0:
        stop.remove(x)
        if minstop==x:
            is_stop=False
    elif len(stop)>0:
        if not is_stop:
             minstop=min(stop)
             is_stop=True
        ans[x]=minstop
        
print('\n'.join(map(str, ans)))
from heapq import heappush,heappop,heapify

n,k = map(int,input().split())

# とりあえずネタは無視しておいしさが大きい寿司からk個を選び(hq)、満足ポイントを計算する。
# それに選ばれなかった寿司から、選ばれた寿司のネタにはないネタで、かつ、
# そのネタの中でおいしさが最大のものを選んでおく(rhq)。
# hqのうち、hqのネタ種類数が減らなように選んだおいしさが最小のものと、
# rhqのうちおいしさが最大のものを入れ替えて、満足ポイントを計算する。
# (こうすると、おいしさの合計は減るがネタの種類数は増える。)
# これを繰り返して、最大の満足ポイントを出力する。

tf = [False for _ in range(n)]
s = []
for i in range(n):
  t,d = map(int,input().split())
  t -= 1
  if tf[t]:
    s.append((0,d))
  else:
    s.append((1,d))
    tf[t] = True

s.sort(key = lambda x:-x[1])
hq = s[:k]
heapify(hq)

rhq = []
for t,d in s[k:]:
  if t == 1:
    rhq.append(-d)
heapify(rhq)

ans = 0
tsum = 0
dsum = 0
for t,d in hq:
  tsum += t
  dsum += d
ans = dsum+tsum**2

while(True):
  t,d = heappop(hq)
  if t == 1:
    break
  if len(rhq) == 0:
    break
  newd = heappop(rhq)
  dsum += -newd-d
  tsum += 1
  ans = max(dsum+tsum**2,ans)
print(ans)


### FIXED CODE ###

from heapq import heappush,heappop,heapify

n,k = map(int,input().split())

# とりあえずネタは無視しておいしさが大きい寿司からk個を選び(hq)、満足ポイントを計算する。
# それに選ばれなかった寿司から、選ばれた寿司のネタにはないネタで、かつ、
# そのネタの中でおいしさが最大のものを選んでおく(rhq)。
# hqのうち、hqのネタ種類数が減らなように選んだおいしさが最小のものと、
# rhqのうちおいしさが最大のものを入れ替えて、満足ポイントを計算する。
# (こうすると、おいしさの合計は減るがネタの種類数は増える。)
# これを繰り返して、最大の満足ポイントを出力する。

td = []
for i in range(n):
  td.append(tuple(map(int,input().split())))
td.sort(key = lambda x:(x[0],-x[1]))

tf = [False for _ in range(n)]
s = []
for t,d in td:
  t -= 1
  if tf[t]:
    s.append((0,d)) #そのネタの中でおいしさ最大でないもの
  else:
    s.append((1,d)) #そのネタの中でおいしさ最大のもの
    tf[t] = True

s.sort(key = lambda x:-x[1])
#print(s)
hq = s[:k]
heapify(hq)

rhq = []
for t,d in s[k:]:
  if t == 1:
    rhq.append(-d)
heapify(rhq)

ans = 0
tsum = 0
dsum = 0
for t,d in hq:
  tsum += t
  dsum += d
ans = dsum+tsum**2

while(True):
  t,d = heappop(hq)
  if t == 1:
    break
  if len(rhq) == 0:
    break
  newd = heappop(rhq)
  dsum += -newd-d
  tsum += 1
  ans = max(dsum+tsum**2,ans)
print(ans)
s = list(input())

if s[3] == s[4] and s[5] == s[6]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s = list(input())

if s[2] == s[3] and s[4] == s[5]:
  print("Yes")
else:
  print("No")
lpha=input()
cap=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
if(alpha in cap):
    print('A')
else:
    print('a')


### FIXED CODE ###

a=input()
if(a.islower()):
    print('a')
else:
    print('A')
N,X=map(int,input().split())
L=list(map(int,input().split()))
bound=1
D=0
for i in range(N+1):
  D+=L[i]
  if D<=X:
    bound+=1
  else:
    pass
print(bound)

### FIXED CODE ###

N,X=map(int,input().split())
L=list(map(int,input().split() ) )
bound=1
D=0
for n in L:
  D+=n
  if D<=X:
    bound+=1
  else:
    break
print(bound)
# -*- coding: utf-8 -*-
# Nの取得
index = int(input())
 
# n回ループして配列に入れる
max = 0
other = 0
l =　input().split()
for i in range(n):
 tmp = l[i]
 max = tmp if tmp > max else other = other +  l[i]
 
if max < tmp:
 print("Yes")
else: 
 print("No")

### FIXED CODE ###

# -*- coding: utf-8 -*-
# Nの取得
index = int(input())

# n回ループして配列に入れる
maximum = 0
other = 0
inputList = input().split()
for i in range(index):
    tmp = int(inputList[i])
    if tmp > maximum:
        maximum = tmp
        other = other + maximum
    else:
        other = other + tmp

if maximum < other - maximum:
    print("Yes")
else:
    print("No")