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

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

ans=0
for a in range(N):
    for b in range(N):
        new_grid=[]
        new_grid.extend(grid[a:])
        new_grid.extend(grid[:a])
        for i in range(N):
            new_grid[i] = new_grid[i][b:]+new_grid[i][:b]
        #print(new_grid)

        flag=True
        for i in range(N):
            for j in range(N):
                if new_grid[i][j]==new_grid[j][i]:
                    continue
                else:
                    flag=False
                    break
        if flag:
            ans+=1
print(ans)


### FIXED CODE ###

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

ans=0
for a in range(N):
    new_grid=[]
    new_grid.extend(grid[a:])
    new_grid.extend(grid[:a])

    flag=True
    for i in range(N):
        for j in range(N):
            if new_grid[i][j]==new_grid[j][i]:
                continue
            else:
                flag=False
                break
    if flag:
        ans+=1
print(ans*N)
### BUGGY CODE ###

N,M = map(int,input().split())
H = [int(i) for i in input().split()]
list_N = list(range(1,N+1))
for j in range(M):
    A,B = map(int,input().split())
    if H[A-1]<H[B-1]:
        if A in list_N:
            list_N.remove(A)
    elif H[A-1]>H[B-1]:
        if B in list_N:
            list_N.remove(B)
    else:
        if A in list_N:
            list_N.remove(A)
        if B in list_N:
            list_N.remove(B)
print(len(list_N))

### FIXED CODE ###

def set1():
    N,M = [int(i) for i in input().split()]
    H = [int(i) for i in input().split()]
    set_N = set([i for i in range(1, N+1)])
    for i in range(M):
        A,B = [int(i) for i in input().split()]
        if H[A-1] < H[B-1]:
            if A in set_N:
                set_N.remove(A)
        elif H[B-1] < H[A-1]:
            if B in set_N:
                set_N.remove(B)
        else:
            if A in set_N:
                set_N.remove(A)
            if B in set_N:
                set_N.remove(B)
    print(len(set_N))

if __name__ == "__main__":
    set1()
### BUGGY CODE ###

import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


dic = dict()

n = ni()
a = []
for _ in range(n):
    a.append(ni())
    
b = sorted(a)

for i, ai in enumerate(a):
    dic[ai] = (i, b.index(ai))
    
cnt = 0
for ord1, ord2 in dic.values():
    if ord1%2 != ord2%2:
        cnt += 1
        
print(cnt // 2)

### FIXED CODE ###

import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from bisect import bisect_left

dic = dict()

n = ni()
a = []
for _ in range(n):
    a.append(ni())
    
b = sorted(a)

for i, ai in enumerate(a):
    dic[ai] = (i, bisect_left(b,ai))
    
cnt = 0
for ord1, ord2 in dic.values():
    if ord1%2 != ord2%2:
        cnt += 1
        
print(cnt // 2)
### BUGGY CODE ###

#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n = I()
    sli = [input() for i in range(n)]
    setli = set(sli)
    rank = {}
    for i in setli:
        j = sli.count(i)
        rank[i] = j
    # print(sorted(rank.items(), key=lambda x: x[1])
    for i in sorted([k for k, v in rank.items() if v == max(rank.values())]):
        print(i)


# Solve
if __name__ == "__main__":
    solve()


### FIXED CODE ###

#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n = I()
    sli = [input() for i in range(n)]
    rank = defaultdict(lambda: 0)
    for i in sli:
        rank[i] += 1
    rank = list(rank.items())
    rank.sort(key=lambda x: (-x[1], x[0]))
    for i, j in rank:
        if j == rank[0][1]:
            print(i)


# Solve
if __name__ == "__main__":
    solve()
### BUGGY CODE ###

N, M = list(map(int, input().split(' ')))
AC_total = 0
WA_total = 0
ac_list = []
wa_dict = {}
for i in range(M):
    p, s = input().split(' ')
    if p not in ac_list:
        if s == 'WA':
            if p in wa_dict:
                wa_dict[p] += 1
            else:
                wa_dict[p] = 1
        else:
            AC_total += 1
            if p in wa_dict:
                WA_total += wa_dict[p]
            ac_list.append(p)
print('{} {}'.format(AC_total, WA_total))

### FIXED CODE ###

N, M = list(map(int, input().split(' ')))
AC_total = 0
WA_total = 0
ac_list = [False] * N
wa_list = [0] * N
for i in range(M):
    p, s = input().split(' ')
    p = int(p) - 1
    if not ac_list[p]:
        if s == 'WA':
            wa_list[p] += 1
        else:
            AC_total += 1
            WA_total += wa_list[p]
            ac_list[p] = True
print('{} {}'.format(AC_total, WA_total))
### BUGGY CODE ###

n, *a = map(int, open(0).read().split())
# すべての組み合わせ
# あるビットについて、そのビットが立つ回数
mod = 10 ** 9 + 7
ans = 0
for i in range(60):
    cnt = 0
    for j in range(n):
        cnt += a[j] >> i & 1
    ans = (ans + (1 << i) * cnt * (n - cnt) % mod) % mod
print(ans)


### FIXED CODE ###

n, *a = map(int, open(0).read().split())
mod = 10 ** 9 + 7
ans = 0
for i in range(60):
    cnt = 0
    for j in range(n):
        cnt += a[j] >> i & 1
    ans = (ans + (1 << i) * cnt * (n - cnt) % mod) % mod
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m):
    b, c = map(int, input().split())
    a += [c]*b
a.sort(reverse=True)
print(sum(a[:n]))


### FIXED CODE ###

from collections import defaultdict
n, m = map(int, input().split())
a = list(map(int, input().split()))
add = defaultdict(int)
for i in a:
    add[i] += 1
for i in range(m):
    b, c = map(int, input().split())
    add[c] += b

output = 0
cnt = 0
print()
for i, v in sorted(add.items(), reverse=True):
    if cnt+v >= n:
        output += i*(n-cnt)
        break
    else:
        output += i*v
        cnt += v
print(output)
### BUGGY CODE ###

import sys  
import numpy as np

N = int(input())
a = list(map(int, input().split()))

a_ = list(set(a))
temp = []
for i in a:
    temp.append(a.count(i+1) + a.count(i) + a.count(i-1))

print(max(temp))

### FIXED CODE ###


import sys  
import numpy as np
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
k = [0] * max(3,(max(a)+1))

for p in a:
    k[p] += 1
ans = 0
for q,r,s in zip(k, k[1:] , k[2:]):
    ans = max(ans, q+r+s)

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

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

datas = [0] * (n+1)
for a in an:
    datas[a] += 1

for k in range(0,n):
    ans=0
    for i in range(1,n+1):
        if datas[i] > 1:
            if i == an[k]:
                ans += (datas[i]-1) * (datas[i]-2)/2
            else:
                ans += datas[i] * (datas[i]-1)/2
    print(int(ans))



### FIXED CODE ###

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

datas = [0] * (n+1)
for a in an:
    datas[a] += 1

ans = 0
for i in range(1,n+1):
    if datas[i] > 1:
        ans += datas[i] * (datas[i]-1)/2
ans = int(ans)

for k in range(0,n):
    if datas[an[k]] > 1:
        print(int(ans - datas[an[k]] * (datas[an[k]]-1)/2 + (datas[an[k]]-1) * (datas[an[k]]-2)/2))
    else:
        print(ans)
### BUGGY CODE ###

str = [input() for i in range(2)]
nums = list(map(int, str[1].split()))
maxCount = 0
idx = 0

for index, item in enumerate(nums):
    count = 0
    if idx > index:
        break
    for i in range(len(nums)-index-1):
        if nums[index+i] >= nums[index+i+1]:
            count = count + 1
            idx = index+i+1
            if count >= maxCount:
                maxCount = count
        else:
            idx = 0
            break
        
print(maxCount)
        


### FIXED CODE ###

str = [input() for i in range(2)]
nums = list(map(int, str[1].split()))
maxCount = 0
index = -1
count = 0

for i in range(len(nums)-1):
    if nums[i] >= nums[i+1]:
        count = count + 1
        if count >= maxCount:
            maxCount = count
    else:
        count = 0
        
print(maxCount)
### BUGGY CODE ###

class WarshallFloyd:
    def __init__(self,n):
        self.v = n
        self.d = []
        for i in range(n):
            self.d.append([1e100]*n)
            self.d[i][i] = 0

    def path(self,x,y,c):
        if x == y:
            return False
        self.d[x][y] = c
        self.d[y][x] = c
        return True

    def build(self):
        for k in range(self.v):
            for i in range(self.v):
                for j in range(self.v):
                    self.d[i][j] = min(self.d[i][j], self.d[i][k] + self.d[k][j])

n,m,l = map(int,input().split())
wf = WarshallFloyd(n)
for i in range(m):
    a,b,c = map(int,input().split())
    wf.path(a-1,b-1,c)
wf.build()
d = []
for i in range(n):
    d.append([1e100]*n)
    for j in range(n):
        if i == j:
            d[i][j] = 0
        elif wf.d[i][j] <= l:
            d[i][j] = 1

for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

q = int(input())
for i in range(q):
    s,t = map(int,input().split())
    ans = d[s-1][t-1]
    if ans == 1e100:
        print(-1)
    else:
        print(ans - 1)


### FIXED CODE ###

import sys
input = sys.stdin.readline

class WarshallFloyd:
    def __init__(self,n):
        self.v = n
        self.d = []
        for i in range(n):
            self.d.append([1e100]*n)
            self.d[i][i] = 0

    def path(self,x,y,c):
        if x == y:
            return False
        self.d[x][y] = c
        self.d[y][x] = c
        return True

    def build(self):
        for k in range(self.v):
            for i in range(self.v):
                for j in range(self.v):
                    self.d[i][j] = min(self.d[i][j], self.d[i][k] + self.d[k][j])
        return self.d

n,m,l = map(int,input().split())
wf = WarshallFloyd(n)
for i in range(m):
    a,b,c = map(int,input().split())
    wf.path(a-1,b-1,c)
d = wf.build()

wf = WarshallFloyd(n)
for i in range(1,n):
    for j in range(i):
        if d[i][j] <= l:
            wf.path(i,j,1)

ans = wf.build()

q = int(input())
for i in range(q):
    s,t = map(int,input().split())
    if ans[s-1][t-1] == 1e100:
        print(-1)
    else:
        print(ans[s-1][t-1] - 1)
### BUGGY CODE ###

N = int(input())

flag = 0
res = 0
while N >= 0:
	n = N % 10
	if flag == 2:
		if n <= 4:
			flag = 0
			res += n
		elif n == 5:
			flag = 1
			res += 4
		elif n >= 6:
			flag = 1
			res += 9 - n
	else:
		if flag == 1:
			n += 1
		if n == 5:
			flag = 2
			res += 5
		elif n > 5:
			flag = 1
			res += 10 - n
		else:
			flag = 0
			res += n
		
	N = N // 10
	if N == 0 and flag == 0:
		break

print(res)

### FIXED CODE ###

N = input()

nagasa = len(N)
flag = 0
res = 0
for i in range(nagasa):
	s = nagasa - i - 1
	n = int(N[s])

	if flag == 2:
		if n <= 4:
			flag = 0
			res += n
		elif n == 5:
			flag = 1
			res += 4
		elif n >= 6:
			flag = 1
			res += 9 - n
	else:
		if flag == 1:
			n += 1
		if n == 5:
			flag = 2
			res += 5
		elif n > 5:
			flag = 1
			res += 10 - n
		else:
			flag = 0
			res += n

if flag == 1:
	print(res + 1)
else:
	print(res)
### BUGGY CODE ###

n = int(input())
s = input()
lis = list(s)
lis1 = [0]*n


for i in range(n):
    lis1[i] += lis[0:i+1].count("W")
    if lis[i] == "W":
        lis1[i] -= 1

for i in range(n):
    lis1[i] += lis[i:n].count("E")
    if lis[i] == "E":
        lis1[i] -= 1

print(min(lis1))

### FIXED CODE ###

n = int(input())
s = input()
lis = list(s)

left_w_count = 0
right_e_count = lis[1:].count("E")
ans = right_e_count
for i in range(1,n):
    if lis[i-1] == "W":
        left_w_count += 1
    if lis[i] == "E":
        right_e_count -= 1
    ans = min(ans, left_w_count + right_e_count)

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

def dfs(n):
    adj = [chr(i+97) for i in range(26)]
    
    stack = ['a']
    while stack:
        node = stack.pop(0)
        if len(node) == n:
            print(node)
        else:
            limit = ord(max(node))%97+2
            for child in adj[:limit]:
                stack.append(node+child)
    return -1

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    dfs(n)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def dfs(s,n,adj):
    adj = 'abcdefghij'
    if len(s) == n:
        print(s)
    else:
        for child in adj[:len(set(s))+1]:
            dfs(s+child,n,adj)
    return -1

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    adj = 'abcdefghij'
    dfs('a',n,adj)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
import fractions

lcm = a[0]
for i in range(1, n):
    lcm = lcm * a[i] // fractions.gcd(lcm, a[i])

b = [0]*n
for i in range(n):
    b[i] = lcm//a[i]

print(sum(b) % (10**9+7))





### FIXED CODE ###

n = int(input())

import fractions
import collections
a = collections.deque(list(map(int, input().split())))
 
lcm = a.popleft()
a.append(lcm)
for i in range(1, n):
    tem = a.popleft()
    lcm = lcm * tem // fractions.gcd(lcm, tem)
    a.append(tem)
 
ans = 0
for i in range(n):
    tem = a.popleft()
    ans += lcm // tem
 
print(ans % (10**9+7))
### BUGGY CODE ###

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

neighbors = {}
for _ in range(m):
  a, b = map(int, input().split())
  if a not in neighbors.keys():
    neighbors.update({a:[]})
  if b not in neighbors[a]:
    neighbors[a].append(b)
  if b not in neighbors.keys():
    neighbors.update({b:[]})
  if a not in neighbors[b]:
    neighbors[b].append(a)
#print(neighbors)
lst = [0] * (n - 1)
visited = set()
queue = [[0, [1]]]
while queue:
  #print(queue)
  pre, next_rooms = queue.pop(0)
  #print(pre, next_rooms)
  for next_room in next_rooms:
    if next_room in visited:
      continue
    if lst[next_room - 2] == 0 and next_room != 1:
      lst[next_room - 2] = pre
    visited.add(next_room)
    rooms = []
    for nei in neighbors[next_room]:
      rooms.append(nei)
    rooms = [next_room, rooms]
    queue.append(rooms)
if 0 in lst:
  print('No')
else:
  print('Yes')
  for i in range(n - 1):
    print(lst[i])

### FIXED CODE ###

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

neighbors = {}
for _ in range(m):
  a, b = map(int, input().split())
  if a not in neighbors.keys():
    neighbors.update({a:set()})
  if b not in neighbors[a]:
    neighbors[a].add(b)
  if b not in neighbors.keys():
    neighbors.update({b:set()})
  if a not in neighbors[b]:
    neighbors[b].add(a)
#print(neighbors)
lst = [0] * (n - 1)
visited = set()
queue = [[0, set([1])]]
while queue:
  #print(queue)
  pre_room, rooms = queue.pop(0)
  #print(pre_room, rooms)
  for room in rooms:
    if room in visited:
      continue
    if lst[room - 2] == 0 and room != 1:
      lst[room - 2] = pre_room
    visited.add(room)
    next_rooms = set()
    for nei in neighbors[room]:
      next_rooms.add(nei)
    next_rooms = [room, next_rooms]
    queue.append(next_rooms)
if 0 in lst:
  print('No')
else:
  print('Yes')
  for i in range(n - 1):
    print(lst[i])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
 

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

T = [[]for i in range(N)]

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

X = [0 for i in range(N)]
for i in range(Q):
    p, x = map(int, input().split())
    X[p-1] += x

ans = [X[i] for i in range(N)]

def dfs(x, p):
    for j in range(len(T[x])):
        if T[x][j] == p:
            continue
        ans[T[x][j]] += ans[x]
        dfs(T[x][j], x)

dfs(0, -1)

for i in range(N):
    print(ans[i], end =" ")


### FIXED CODE ###

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

F = [0 for i in range(N)]
T = [[]for i in range(N)]

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

X = [0 for i in range(N)]
for i in range(Q):
    p, x = map(int, input().split())
    X[p-1] += x

ans = [X[i] for i in range(N)]
for i in range(N):
    F[i] = 1
    for j in range(len(T[i])):
        if F[T[i][j]] == 1:
            continue
        ans[T[i][j]] += ans[i]

for i in range(N):
    print(ans[i], end =" ")
### BUGGY CODE ###

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

point = 1
for i in range(n):
    if k > i:
        point *= a[i]
        continue
    now = point
    now //= a[i - k]
    now *= a[i]
    if now > point:
        print('Yes')
    else:
        print('No')
    point = now


### FIXED CODE ###

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

point = 0
for i in range(n):
    if k > i:
        point += a[i]
        continue
    now = point
    now -= a[i - k]
    now += a[i]
    if now > point:
        print('Yes')
    else:
        print('No')
    point = now
### BUGGY CODE ###

import sys
import numpy as np
input = sys.stdin.readline

N=int(input())
A=map(int,input().split())
Q=int(input())
numbers=[]
for _ in range(Q):
    B,C=map(int,input().split())
    numbers.append([B,C])
answers=[0 for _ in range(100001)]
for a in A:
    answers[a]+=a
for number in numbers:
    suuji=answers[number[0]]//number[0]
    answers[number[0]]=0
    answers[number[1]]+=suuji*number[1]

    answer=np.array(answers)
    answer=np.nonzero(answer)
    suuji=0
    for a in answer[0]:
        suuji+=answers[a]
    print(suuji)
    

### FIXED CODE ###

import sys
input = sys.stdin.readline

N=int(input())
A=map(int,input().split())
Q=int(input())
numbers=[]
for _ in range(Q):
    B,C=map(int,input().split())
    numbers.append([B,C])
answers=[0 for _ in range(100001)]
for a in A:
    answers[a]+=a
whole=sum(answers)
for number in numbers:
    suuji=answers[number[0]]//number[0]
    answers[number[0]]=0
    answers[number[1]]+=suuji*number[1]
    whole+=(number[1]-number[0])*suuji
    print(whole)
### BUGGY CODE ###

import sys
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid_int(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    R, C, K = NMI()
    grid = defaultdict(int)
    for i in range(K):
        r, c, v = NMI()
        grid[(r-1, c-1)] = v

    dp = [[[0]*4 for _ in range(C+2)] for _ in range(R+2)]

    for r in range(R+1):
        for c in range(C+1):
            for i in range(4):
                now = dp[r][c][i]
                val = grid[(r, c)]

                if i == 3:
                    # 取らずに下
                    dp[r + 1][c][0] = max(now, dp[r + 1][c][0])
                    continue

                # 取って下
                dp[r+1][c][0] = max(now + val, dp[r+1][c][0])
                # 取らずに下
                dp[r+1][c][0] = max(now, dp[r+1][c][0])
                # 取って横
                dp[r][c+1][i+1] = max(now + val, dp[r][c+1][i+1])
                # 取らずに横
                dp[r][c+1][i] = max(now, dp[r][c+1][i])

    print(max(dp[R][C]))


if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid_int(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    R, C, K = NMI()
    grid = make_grid_int(R, C, 0)
    for i in range(K):
        r, c, v = NMI()
        grid[r-1][c-1] = v

    dp0 = [[0 for _ in range(C + 2)] for _ in range(R + 2)]
    dp1 = [[0 for _ in range(C + 2)] for _ in range(R + 2)]
    dp2 = [[0 for _ in range(C + 2)] for _ in range(R + 2)]
    dp3 = [[0 for _ in range(C + 2)] for _ in range(R + 2)]

    for r in range(R+1):
        for c in range(C+1):
            now0 = dp0[r][c]
            now1 = dp1[r][c]
            now2 = dp2[r][c]
            now3 = dp3[r][c]
            try:
                val = grid[r][c]
            except:
                val = 0

            dp0[r+1][c] = max(now3, dp0[r+1][c])

            # 取って下
            dp0[r+1][c] = max(now0 + val, now1 + val, now2 + val, dp0[r+1][c])
            # 取らずに下
            dp0[r+1][c] = max(now0, now1, now2, now3, dp0[r+1][c])
            # 取って横
            dp1[r][c+1] = max(now0 + val, dp1[r][c+1])
            dp2[r][c+1] = max(now1 + val, dp2[r][c+1])
            dp3[r][c+1] = max(now2 + val, dp3[r][c+1])

            # 取らずに横
            dp1[r][c+1] = max(now1, dp1[r][c+1])
            dp2[r][c+1] = max(now2, dp2[r][c+1])
            dp0[r][c+1] = max(now0, dp0[r][c+1])

    print(max(dp0[R][C], dp1[R][C], dp2[R][C], dp3[R][C]))


if __name__ == "__main__":
    main()
### BUGGY CODE ###

from collections import deque
N,D,A = [int(i) for i in input().split()]
preXH = [[int(i) for i in input().split()] for j in range(N)]
preXH.sort()
XH = [[x,h//A + bool(h%A)] for x,h in preXH]
Xs = [xxx[0] for xxx in XH]
ans = 0
DP = [0]*N#ダメイジの合計
for n,d in enumerate(DP):
    if d<XH[n][1]:#殺しきれてない
        bonu = XH[n][1]-d
        ans += bonu
        reach = XH[n][0] + 2*D
        for m in range(n,N):
            if XH[m][0] <= reach:
                DP[m] += bonu
            else:break
print(ans)

### FIXED CODE ###

import sys
fastinput = sys.stdin.readline
N,D,A = [int(i) for i in fastinput().split()]
preXH = [[int(i) for i in fastinput().split()] for j in range(N)]
preXH.sort()
XH = [[x,h//A + bool(h%A)] for x,h in preXH]
X = [x for x,h in XH]+[100000000000000000]
Diff = [X[m+1]-X[m] for m in range(N)]
reach = []
count = 0
l = X[0]
r = X[0]+2*D
for m in range(1,N+1):
    while r<X[m]:#l一個すすめる
        reach.append(m-1)
        r += Diff[count]
        count += 1

damage = 0
ans = 0
DIFF = [0]*N#ダメイジのdiff
for n,d in enumerate(DIFF):
    damage += d
    if damage<XH[n][1]:#殺しきれてない
        bonu = XH[n][1]-damage
        damage += bonu
        ans += bonu
        if reach[n]<N-1:DIFF[reach[n]+1] -= bonu
print(ans)
### BUGGY CODE ###

n, k, q = map(int, input().split())
a = [0] + list(int(input()) for _ in range(q))
p = [0]

a = sorted(a)

for i in range(1, n + 1):
    p.append(a.count(i))
    
for j in range(1, n + 1):
    if k - (q - p[j]) > 0:
        print('Yes')
    else:
        print('No')   

### FIXED CODE ###

n, k, q = map(int, input().split())
a = [0] + list(int(input()) for _ in range(q))
p = [k - q] * (n + 1)

for i in range(1, q + 1):
    p[a[i]] += 1
    
for j in range(1, n + 1):
    if p[j] > 0:
        print('Yes')
    else:
        print('No')