Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

class SEGTree:
    def __init__(self,n,op,e):
        self.Unit=e
        self.Op=op
        i=1<<(n.bit_length()-1)
        if i!=n:
            i*=2
        self.SEG=[self.Unit]*(2*i-1)
        self.d=i
    def update(self,i,x):
        i+=self.d-1
        self.SEG[i]=x
        while i>0:
            i=(i-1)//2
            self.SEG[i]=self.Op(self.SEG[i*2+1],self.SEG[i*2+2])
    def find(self,a,b,k,l,r):
        if r<=a or b<=l:
            return self.Unit
        if a<=l and r<=b:
            return self.SEG[k]
        else:
            c1=self.find(a,b,2*k+1,l,(l+r)//2)
            c2=self.find(a,b,2*k+2,(l+r)//2,r)
            return self.Op(c1,c2)
    def get(self,a,b):
        return self.find(a,b,0,0,self.d)

INF=10**30
N,K=map(int,input().split())
A=[int(input()) for i in range(N)]
M=max(A)
SEG=SEGTree(M+1,max,0)

ans=0
for i in range(N):
    l=max(0,A[i]-K)
    r=min(M,A[i]+K)
    res=SEG.get(l,r+1)
    ans=max(ans,res+1)
    if SEG.get(A[i],A[i]+1)<res+1:
        SEG.update(A[i],res+1)
print(ans)

### FIXED CODE ###

import sys
input=sys.stdin.readline

class SEGTree:
    def __init__(self,N,op,e):
        self.size=2**(N-1).bit_length()
        self.e=e
        self.op=op
        self.SEG=[self.e]*(self.size*2)
    
    def update(self,i,x):
        i+=self.size
        self.SEG[i]=x
        while i>0:
            i>>=1
            self.SEG[i]=self.op(self.SEG[i*2],self.SEG[i*2+1])
            
    def query(self,l,r):
        l+=self.size
        r+=self.size
        lres,rres=self.e,self.e
        
        while l<r:
            if l&1:
                lres=self.op(lres,self.SEG[l])
                l+=1
            if r&1:
                r-=1
                rres=self.op(self.SEG[r],rres)
            l>>=1
            r>>=1
        res=self.op(lres,rres)
        return res
    
    def get(self,i):
        return self.SEG[i+self.size]

N,K=map(int,input().split())
A=[int(input()) for i in range(N)]
M=max(A)
seg=SEGTree(M+1,max,0)
 
ans=0
for i in range(N):
    l=max(0,A[i]-K)
    r=min(M,A[i]+K)
    res=seg.query(l,r+1)+1
    ans=max(ans,res)
    if seg.get(A[i])<res:
        seg.update(A[i],res)
print(ans)
### BUGGY CODE ###

n = int(input())
A = list(map(int, input().split()))

MOD = 10**9+7
ans = 0

for i in range(60):
    cnt = 0
    for a in A:
        cnt += a>>i&1
    ans += cnt*(n-cnt)*2**i
    ans %= MOD

print(ans)



### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))

MOD = 10**9+7
ans = 0

for i in range(60):
    cnt = 0
    for a in A:
        cnt += a>>i&1
    ans += cnt*(n-cnt)*2**i
    ans %= MOD

print(ans)
### BUGGY CODE ###

from collections import Counter
from itertools import combinations
#from sys.stdin import readline

N = int(input())
S = [input() for _ in range(N)]
ans = 0
for s1, s2 in combinations(S, 2):
  if Counter(s1) == Counter(s2):
    ans +=1
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())
S={}
for _ in range(N):
  s = ''.join(sorted(input().rstrip()))
  if s in S:
    S[s] += 1
  else:
    S[s] = 1

ans=0
for s in S.values():
  ans += s*(s-1)//2
  
print(ans)
### BUGGY CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

h, w = MAP()
A = [list(input()) for i in range(h)]

def bfs():
    que = deque([])
    
    dx = [0, 1, 0, -1]
    dy = [1, 0, -1, 0]

    d = [[INF] * w for i in range(h)]
    
    for i in range(h):
        for j in range(w):
            if A[i][j] == "#":
                sy, sx = i, j
                d[sy][sx] = 0
                que.append((sy, sx))
    while que:
        p = que.popleft()
        ans = d[p[0]][p[1]]
        for i in range(4):
            ny, nx = p[0] + dy[i], p[1] + dx[i]
            
            if 0 <= ny < h and 0 <= nx < w and d[ny][nx] == INF:
                d[ny][nx] = d[p[0]][p[1]] + 1
                A[ny][nx] = "#"
                que.append((ny, nx))
 
                #ans = max(ans, d[ny][nx])     
    return ans
print(bfs())



### FIXED CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

h, w = MAP()
A = [list(input()) for i in range(h)]


def bfs():
    que = deque([])
    
    dx = [0, 1, 0, -1]
    dy = [1, 0, -1, 0]

    d = [[INF] * w for i in range(h)]
    
    for i in range(h):
        for j in range(w):
            if A[i][j] == "#":
                sy, sx = i, j
                d[sy][sx] = 0
                que.append((sy, sx))
    ans = 0
    while que:
        p = que.popleft()
        for i in range(4):
            ny, nx = p[0] + dy[i], p[1] + dx[i]
            
            if 0 <= ny < h and 0 <= nx < w and d[ny][nx] == INF and A[ny][nx] == ".":
                d[ny][nx] = d[p[0]][p[1]] + 1
                # A[ny][nx] = "#"
                que.append((ny, nx))
 
                ans = max(ans, d[ny][nx])     
#    print(*d, sep="\n")
    return ans


if __name__ == "__main__":
    print(bfs())
### BUGGY CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))


N, X, Y = LI()
path = [[mod for i in range(N)] for i in range(N)]
for i in range(N):
    path[i][i] = 0

for i in range(N - 1):
    path[i][i + 1] = 1
    path[i + 1][i] = 1
    
path[X - 1][Y - 1] = 1
path[Y - 1][X - 1] = 1

for k in range(N):
    for i in range(N):
        for j in range(N):
            path[i][j] = min(path[i][j], path[i][k] + path[k][j])

anss = [0 for i in range(N)]
# print(path)
for i in range(N):
    for j in range(N):
        anss[path[i][j]] += 1

for i in range(1, N):
    print(anss[i] // 2)

### FIXED CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))


N, X, Y = LI()
X -= 1
Y -= 1
anss = [0 for i in range(N)]

for i in range(N):
    for j in range(i + 1, N):
        anss[min(
            abs(i - j), 
            abs(X - i) + 1 + abs(j - Y),
            abs(Y - i) + 1 + abs(X - j)
        )] += 1

for i in range(1, N):
    print(anss[i])
### BUGGY CODE ###

h,w = map(int, input().split())
a = ["#"+input()+"#" for _ in range(h)]
s = "#"*(w+2)
a = [s] + a + [s]


ds = [[0] + [-1]*w + [0] for _ in range(h)]
ds = [[0]*(w+2)] + ds + [[0]*(w+2)]

vectors = [(-1,0),(1,0),(0,-1),(0,1)]

stack = []

ans = 0

for i in range(1,h+1):
    for j in range(1,w+1):
        if a[i][j] == "#":
            stack.append((i,j))
            ds[i][j] = 0

while stack:
    nh,nw = stack.pop(0)
    for vh,vw in vectors:
        if ds[nh+vh][nw+vw] == -1:
            stack.append((nh+vh,nw+vw))
            ds[nh+vh][nw+vw] = ds[nh][nw] + 1
            ans = ds[nh][nw] + 1

print(ans)


### FIXED CODE ###

import numpy as np
import copy

h, w = map(int, input().split())
a = [input() for _ in range(h)]

a = np.array([[0 if (ai[j] == "#") else np.inf for j in range(w)] for ai in a])

for i in range(1, h):
    a[i] = np.minimum(a[i], a[i - 1] + 1)
for i in range(h - 2, -1, -1):
    a[i] = np.minimum(a[i], a[i + 1] + 1)
for i in range(1, w):
    a[:, i] = np.minimum(a[:, i], a[:, i - 1] + 1)
for i in range(w - 2, -1, -1):
    a[:, i] = np.minimum(a[:, i], a[:, i + 1] + 1)

print(int(a.max()))
### BUGGY CODE ###

n,m,k=map(int,input().split())
A=[]
B=[]
for i in range(m):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
C=[]
D=[]
for i in range(k):
    c,d=map(int,input().split())
    C.append(c)
    D.append(d)
union=[]
for i in range(n):
    br=0
    for j in range(len(union)):
        if i+1 in set(union[j]):
            br=1
            break
    if br==1:
        continue
    fri=[i+1]
    mark=[0]
    while 0 in set(mark):
        for s in range(len(fri)):
            if mark[s]==0:
                for t in range(m):
                    if A[t]==fri[s] and B[t] not in set(fri):
                        fri.append(B[t])
                        mark.append(0)
                    if B[t]==fri[s] and A[t] not in set(fri):
                        fri.append(A[t])
                        mark.append(0)
                mark[s]=1
    union.append(fri)
counter=[]
for i in range(n):
    counter.append(0)

for i in range(m):
    counter[A[i]-1]+=1
    counter[B[i]-1]+=1
for i in range(k):
    for j in range(len(union)):
        if C[i] in union[j] and D[i] in union[j]:
            counter[C[i]-1]+=1
            counter[D[i]-1]+=1
            break

for i in range(n):
    for j in range(len(union)):
        if i+1 in union[j]:
            print(len(union[j])-counter[i]-1,end=" ")
            break

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**7)

def dfs(x):
    if seen[x-1]==0:
        uni[cnt].add(x)
        seen[x-1]=1
        for i in fri[x-1]:
            dfs(i)
    

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

fri=[[] for i in range(n)]
blk=[[] for i in range(n)]

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

for i in range(k):
    c,d=map(int,input().split())
    blk[c-1].append(d)
    blk[d-1].append(c)


seen=[0 for i in range(n)]

uni=[]
cnt=0
for i in range(1,n+1):
    if seen[i-1]==0:
        uni.append(set())
        dfs(i)
        cnt+=1

seq=[0 for i in range(n)]

for unii in uni:
    for j in unii:
        cj=len(unii)-len(fri[j-1])-len(unii&set(blk[j-1]))-1
        seq[j-1]=cj

print(*seq)
### BUGGY CODE ###

n=int(input())
lista = [int(i) for i in input().split()]

import fractions
import copy

list_ans=[]

for i in range(n):
	listb=copy.deepcopy(lista)
	listb.pop(i)
#	print(listb)

	ans= listb[0]

	for i in range(1,n-1):
		ans=fractions.gcd(ans,listb[i])
#	print(ans)
	list_ans.append(ans)

print(int(max(list_ans)))


	

### FIXED CODE ###

n=int(input())
lista = [int(i) for i in input().split()]

import fractions
import copy

listb=[]
listc=[]
ansb= lista[0]

for i in range(1,n-1):
	ansb=fractions.gcd(ansb,lista[i])
#	print(ansb)
	listb.append(ansb)

#print(int(max(list_ans)))
ansc= lista[n-1]

for i in range(n-2,0,-1):
	ansc=fractions.gcd(ansc,lista[i])
#	print(ansc)
	listc.append(ansc)


list_b=[lista[0]]
listb=[1]+list_b+listb
list_c=[lista[n-1]]
listc=list(reversed(listc))+list_c+[1]
#print(listb)
#print(listc)

ans=0
list_ans=[listc[0],listb[n-1]]
for i in range(1,n-1):
	ans=fractions.gcd(listb[i],listc[i])
	list_ans.append(ans)
	
ansans=max(list_ans)

if n==2:
	ansans=max(lista[0],lista[1])
	
print(ansans)
### BUGGY CODE ###

N=int(input())
K =int(input()) 

def dp(N, K):
  if N < 10:
    if K == 0:
      return 1
    if K == 1:
      return N
    return 0
  q, r = divmod(N, 10)
  ret = 0
  if K >= 1: # 下一桁が0でないときはKを1消化
    ret += dp(q, K-1) * r # 下一桁がr以下の時
    ret += dp(q-1, K-1) * (9-r) # 下一桁がrより上の時はq-1であれば成立
  ret += dp(q, K) # 下一桁が0のとき
  return ret

print(dp(N, K))

### FIXED CODE ###

from functools import lru_cache

N=int(input())
K =int(input()) 

@lru_cache(None)
def dp(N, K):
  if N < 10:
    if K == 0:
      return 1
    if K == 1:
      return N
    return 0
  q, r = divmod(N, 10)
  ret = 0
  if K >= 1: # 下一桁が0でないときはKを1消化
    ret += dp(q, K-1) * r # 下一桁がr以下の時
    ret += dp(q-1, K-1) * (9-r) # 下一桁がrより上の時はq-1であれば成立
  ret += dp(q, K) # 下一桁が0のとき
  return ret

print(dp(N, K))
### BUGGY CODE ###

n = int(input())
a = []

for _ in range(n):
  a.append(int(input()))

tmp = []

for i in range(len(a)):
  tmp = a[:]
  del tmp[i]
  print(max(tmp))
  tmp.clear


### FIXED CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
#print(a)
a_sort = sorted(a)
#print(a_sort)

max_number = a_sort[-1]
sub_max_number = a_sort[-2]

for i in range(n):
  if a[i] == max_number:
    print(sub_max_number)
  else:
    print(max_number)
### BUGGY CODE ###

import math
from functools import reduce

def gcd_list(numbers):
    gcd = reduce(math.gcd, numbers)
    return gcd

K = int(input())
sumk = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            sumk += gcd_list([i,j,k])
print(sumk)
   

### FIXED CODE ###

import math
from functools import reduce

def gcd_list(numbers):
    gcd = reduce(math.gcd, numbers)
    return gcd

K = int(input())
numberslist = []
sumgcd = 0
for i in range(1, K+1):
    for j in range(i, K+1):
        for k in range(j, K+1):
            if i == j == k:
                sumgcd += gcd_list([i,j,k])
            elif i == j or j == k or k == i:
                sumgcd += gcd_list([i,j,k])*3
            else:
                sumgcd += gcd_list([i,j,k])*6
                 
print(sumgcd)
### BUGGY CODE ###

import sys
N=int(input())
A=list(map(int,input().split()))
c=0
for i in range(1,N+1):
    for j in range(N):
        if A[j]!=i:
            c+=1
        elif A[j]==i:
            break
    if c+i==N:
        print(c)
        sys.exit()
    continue
print(-1)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
c=1
for i in range(N):
    if A[i]==c:
        c+=1
if c==1:
    print(-1)
else:
    print(N-c+1)
### BUGGY CODE ###

# coding: utf-8
# Your code here!

import bisect
 
N, K = map(int, input().rstrip().split(' '))
X = sorted(list(map(int, input().rstrip().split(' '))))

i = bisect.bisect_left(X, 0)
X.insert(i, 0)

memo = [[-1] * (N + 1) for _ in range(K)]
 
def recursive(current_k, cost, i, left_i, right_i):
    if K == current_k:
        return cost
    if memo[current_k][i] != -1:
        return memo[current_k][i]
       
    left_cost = 1e10 
    if left_i >= 0:
        left_cost = recursive(current_k + 1, cost + X[i] - X[left_i], left_i, left_i - 1, right_i)
        
    right_cost = 1e10
    if right_i <= N:
        right_cost = recursive(current_k + 1, cost + X[right_i] - X[i], right_i, left_i, right_i + 1)
        
    min_cost = min(left_cost, right_cost)
    
    memo[current_k][i] = min_cost
    
    return min_cost
    
print(recursive(0, 0, i, i - 1, i + 1))


### FIXED CODE ###

# coding: utf-8
# Your code here!

N, K = map(int, input().rstrip().split(' '))
X = list(map(int, input().rstrip().split(' ')))

min_cost = int(1e10)
for i in range(K, N+1):
    min_cost = min(min_cost, X[i-1] - X[i-K] + min(abs(X[i-1]), abs(X[i-K])))
    
print(min_cost)
### BUGGY CODE ###

from collections import deque

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

graphs = [[[] for _ in range(n)], [[] for _ in range(n)]]
cands = [set(), set()]
for _ in range(k):
    x, y = map(int, input().split())
    graphs[0][x - 1].append(y - 1)
    graphs[0][y - 1].append(x - 1)
    cands[0].add(x - 1)
for _ in range(l):
    x, y = map(int, input().split())
    graphs[1][x - 1].append(y - 1)
    graphs[1][y - 1].append(x - 1)
    cands[1].add(x - 1)

groups = [[], []]
groups_inv = [[-1] * n, [-1] * n]
def dfs(start, size, case, num):
    q = deque(maxlen=size)
    q.append(start)
    used = {start}
    groups[case].append(used)
    groups_inv[case][start] = num
    while q:
        node = q.popleft()
        for to in graphs[case][node]:
            if to in used:
                continue
            q.append(to)
            used.add(to)
            groups_inv[case][to] = num

for i in range(2):
    count = 0
    for node in cands[i]:
        if groups_inv[i][node] == -1:
            dfs(node, n, i, count)
            count += 1

print(*[
    1 if groups_inv[0][i] == -1 or groups_inv[1][i] == -1
    else len(groups[0][groups_inv[0][i]] & groups[1][groups_inv[1][i]])
    for i in range(n)
])


### FIXED CODE ###

from collections import deque

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

graphs = [[[] for _ in range(n)], [[] for _ in range(n)]]
cands = [set(), set()]
for _ in range(k):
    x, y = map(int, input().split())
    graphs[0][x - 1].append(y - 1)
    graphs[0][y - 1].append(x - 1)
    cands[0].add(x - 1)
for _ in range(l):
    x, y = map(int, input().split())
    graphs[1][x - 1].append(y - 1)
    graphs[1][y - 1].append(x - 1)
    cands[1].add(x - 1)

groups = [[], []]
groups_inv = [[-1] * n, [-1] * n]
def dfs(start, case, num):
    q = deque()
    q.append(start)
    used = {start}
    groups[case].append(used)
    groups_inv[case][start] = num
    while q:
        node = q.popleft()
        for to in graphs[case][node]:
            if to in used:
                continue
            q.append(to)
            used.add(to)
            groups_inv[case][to] = num

for i in range(2):
    count = 0
    for node in cands[i]:
        if groups_inv[i][node] == -1:
            dfs(node, i, count)
            count += 1

ret = [-1] * n
for i in range(n):
    if groups_inv[0][i] == -1 or groups_inv[1][i] == -1:
        ret[i] = 1
    elif ret[i] == -1:
        cities = groups[0][groups_inv[0][i]] & groups[1][groups_inv[1][i]]
        for city in cities:
            ret[city] = len(cities)
print(*ret)
### BUGGY CODE ###

from collections import deque

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

c1 = deque(list(0 for i in range(N)))
c2 = deque()
c3 = deque()
c4 = deque()
c5 = deque()
c6 = deque()

counter = 0
def transfer(start, end, capacity):
    for i in range(capacity):
        if len(start) != 0:
            end.append(start.pop())
        else:
            break

while len(c6) != N:
    counter += 1
    transfer(c5, c6, E)
    transfer(c4, c5, D)
    transfer(c3, c4, C)
    transfer(c2, c3, B)
    transfer(c1, c2, A)
print(counter)


### FIXED CODE ###

import math
from collections import deque

N = int(input())
X = deque()
for i in range(5):
        X.append(int(input()))
m = min(X)
print(math.ceil(N/m)+4)
### BUGGY CODE ###

N=int(input())
A=[]
for i in range(N):
  A.append(list(input()))
c=0  
for i in range(len(A)-1):
  for j in range(i+1,len(A)):
    if sorted(A[i])==sorted(A[j]):
      c+=1
print(c)      
  


### FIXED CODE ###

N=int(input())
dic={}
for i in range(N):
  s=sorted(list(input()))
  s="".join(s)
  if s in dic:
    dic[s]+=1
  else:
    dic[s]=1
count=0
u=len(dic)
for i in range(u):
  kk=dic.popitem()
  count+=kk[1]*(kk[1]-1)/2
print(int(count))
### BUGGY CODE ###

import numpy as np
MOD = 10 ** 9 + 7

dp = np.zeros(13, dtype = np.int64)
dp[0] = 1

move = np.arange(0,52,4) % 13
for s in input():
  prev = dp[move]
  dp = np.zeros(13, dtype=np.int64)
  if s == '?':
    add = np.ones(10, dtype = np.int64)
  else:
    s = int(s)
    add = np.zeros(s+1, dtype=np.int64)
    add[-1] = 1
  dp = np.convolve(prev, add)
  dp[:len(dp) - 13] += dp[13:]
  dp %= MOD
  
print(dp[5])


### FIXED CODE ###

MOD = 10 ** 9 + 7
S = input()

dp = [0] * 13
dp[0] = 1

for s in S:
  prev = [x for x in dp]
  dp = [0] * 13
  if s == '?':
    add = range(10)
  else:
    add = [int(s)]
  for i in range(13):
    for x in add:
      dp[(10*i+x)%13] += prev[i]
  dp = [x % MOD for x in dp]
  
print(dp[5])
### BUGGY CODE ###

import numpy as np
from sys import stdin
s = stdin.readline()[:-1]

length = len(s)

dp = np.zeros((100100,13))

s = list(reversed(s))

dp[0][0]=1
ten = 1
mod = 1000000007


for i in range(length):
	if s[i] == '?':
		for num in range(10):
			d = num*ten
			for j in range(13):
				k = (j+d)%13
				dp[i+1][k] += dp[i][j]
				dp[i+1][k] %= mod
	else:
		num = int(s[i])
		d = num*ten
		for j in range(13):
			k = (j+d)%13
			dp[i+1][k] += dp[i][j]
			dp[i+1][k] %= mod
	ten *= 10
	ten %= 13

print(int(dp[length][5]%mod))

### FIXED CODE ###

from sys import stdin
s = stdin.readline()[:-1]

length = len(s)

dp = [[0 for i in range(13)]for j in range(100100)]

s = list(reversed(s))

dp[0][0]=1
ten = 1
mod = 1000000007


for i in range(length):
	if s[i] == '?':
		for num in range(10):
			d = num*ten
			for j in range(13):
				k = (j+d)%13
				dp[i+1][k] += dp[i][j]
				dp[i+1][k] %= mod
	else:
		num = int(s[i])
		d = num*ten
		for j in range(13):
			k = (j+d)%13
			dp[i+1][k] += dp[i][j]
			dp[i+1][k] %= mod
	ten *= 10
	ten %= 13

print(int(dp[length][5]%mod))
### BUGGY CODE ###

n,k=map(int,input().split())
arr=[]
for i in range(n):
  a,b=map(int,input().split())
  for j in range(b):
    arr.append(a)
arr.sort()
print(arr[k-1])

### FIXED CODE ###

n,k=map(int,input().split())
nums=[]
for i in range(n):
  nums.append(list(map(int,input().split())))
nums.sort(key=lambda x:x[0])
cnt=0
i=0
while cnt<k:
  cnt+=nums[i][1]
  if cnt>=k:
    print(nums[i][0])
    break
  i+=1
### BUGGY CODE ###

# 入力は二行でそれぞれ[数値]

input_nums = int(input())
input_line = input()

result = 0

for k in range(input_nums):
    for j in range(k):
        for i in range(j):
            if(j-i == k-j):
                pass
            elif(input_line[i] == input_line[j]):
                pass
            elif(input_line[i] == input_line[k]):
                pass
            elif(input_line[j] == input_line[k]):
                pass
            else:
                result = result + 1

print(result)


### FIXED CODE ###

N = int(input())
S = input()

ans = S.count("R")*S.count("G")*S.count("B")

for i in range(N-2):
    for j in range(i+1, N-1):
        k = j-i + j
        if k < N and S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            ans -= 1

print(ans)
### BUGGY CODE ###

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

H = [int(i) for i in input().split()]

paths = []
for i in range(M):
    paths.append(list(map(int, input().split())))
    paths[-1][0] -= 1
    paths[-1][1] -= 1
    
good = []
bad = []

for i in  range(N):
    flag = True
    if i in bad:
        continue
    for path in paths:
        if i in path:
            bi = path[0]
            if bi == i:
                bi = path[1]
            if H[i] <= H[bi]:
                bad.append(i)
                flag = False
                break
            else:
                bad.append(bi)
    if flag:
        good.append(i)
        
print(len(good))

### FIXED CODE ###

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

H = [int(i) for i in input().split()]

paths = []
for i in range(M):
    paths.append(list(map(int, input().split())))
    paths[-1][0] -= 1
    paths[-1][1] -= 1
    
bad = set()

for path in paths:
  if H[path[0]] == H[path[1]]:
    bad.add(path[0])
    bad.add(path[1])
  elif H[path[0]] > H[path[1]]:
    bad.add(path[1])
  else:
    bad.add(path[0])
        
print(N-len(bad))