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

N = int(input())
l = list(map(int,input().split()))
s = set(l)
ss = list(s)
ss.sort(reverse= True)
r = []  
for i in ss:
  if l.count(i) >= 4:
    	r.append(i)
    	r.append(i)
  elif l.count(i) >= 2:
    	r.append(i)
  if len(r) >= 2:
    print(r[0]*r[1])
    exit()
print(0)

### FIXED CODE ###

import collections
N = int(input())
l = list(map(int,input().split()))
c = collections.Counter(l)
dic = sorted(c.items(), reverse=True)
r = []
for j in dic:
    k = j[0]
    v = j[1]
    if v >= 4:
    	r.append(k)
    	r.append(k)
    elif v >= 2:
    	r.append(k)
    if len(r) >= 2:
      print(r[0]*r[1])
      exit()
print(0)
### BUGGY CODE ###

H, W = map(int, input().split())

y, x = map(int, input().split())
start = (x-1, y-1)

y, x = map(int, input().split())
goal = (x-1, y-1)

field = [[c for c in input()] for i in range(H)]
dist_table = [[-1] * W for i in range(H)]
sx, sy = start
dist_table[sy][sx] = 0

move1 = ((-1, 0), (1, 0), (0, 1), (0, -1))
move2 = ((-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2),\
         (-1, -2), (-1, -1), (-1, 1), (-1, 2),\
         (0, -2), (0, 2),\
         (1, -2), (1, -1), (1, 1), (1, 2),\
         (2, -2), (2, -1), (2, 0), (2, 1), (2, 2))

queue1 = [start]
queue2 = []

while queue1:
    now_x, now_y = queue1.pop()
    if (now_x, now_y) == goal:
        break
    queue2.append((now_x, now_y))
    dist = dist_table[now_y][now_x]
    for dx, dy in move1:
        tx, ty = now_x + dx, now_y + dy
        if 0 <= tx < W and 0 <= ty < H and field[ty][tx] == '.':
            if dist_table[ty][tx] == -1:
                dist_table[ty][tx] = dist
                queue1.append((tx, ty))
    if len(queue1) == 0:
        while queue2:
            now_x, now_y = queue2.pop()
            dist = dist_table[now_y][now_x]
            for dx, dy in move2:
                tx, ty = now_x + dx, now_y + dy
                if 0 <= tx < W and 0 <= ty < H and field[ty][tx] == '.':
                    if dist_table[ty][tx] == -1:
                        dist_table[ty][tx] = dist + 1
                        queue1.append((tx, ty))
gx, gy = goal
print(dist_table[gy][gx])


### FIXED CODE ###

def main():
    H, W = map(int, input().split())

    y, x = map(int, input().split())
    start = (x+1, y+1)

    y, x = map(int, input().split())
    goal = (x+1, y+1)

    dist_table = [[-2] * (W+4)]
    dist_table.append([-2] * (W+4))
    for _ in range(H):
        row = '##' + input() + '##'
        row = [-1 if c == '.' else -2 for c in row]
        dist_table.append(row)
    dist_table.append([-2] * (W+4))
    dist_table.append([-2] * (W+4))



    sx, sy = start
    dist_table[sy][sx] = 0

    move1 = ((-1, 0), (1, 0), (0, 1), (0, -1))
    move2 = ((-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2),\
            (-1, -2), (-1, -1), (-1, 1), (-1, 2),\
            (0, -2), (0, 2),\
            (1, -2), (1, -1), (1, 1), (1, 2),\
            (2, -2), (2, -1), (2, 0), (2, 1), (2, 2))

    queue1 = [start]
    queue2 = []

    while queue1:
        now_x, now_y = queue1.pop()
        if (now_x, now_y) == goal:
            break
        queue2.append((now_x, now_y))
        dist = dist_table[now_y][now_x]
        for dx, dy in move1:
            tx, ty = now_x + dx, now_y + dy
            if dist_table[ty][tx] == -1:
                dist_table[ty][tx] = dist
                queue1.append((tx, ty))
        if len(queue1) == 0:
            while queue2:
                now_x, now_y = queue2.pop()
                dist = dist_table[now_y][now_x]
                for dx, dy in move2:
                    tx, ty = now_x + dx, now_y + dy
                    if dist_table[ty][tx] == -1:
                        dist_table[ty][tx] = dist + 1
                        queue1.append((tx, ty))
    gx, gy = goal
    print(dist_table[gy][gx])

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

a,b = map(int,input().split())
ans = 0
for i in range(a,b+1):
    ans = ans^i
print(ans)

### FIXED CODE ###

a,b = map(int,input().split())
nu = 0
if a % 2 == 1:
    nu = a
    a += 1
num = (b-a) // 4
a += 4 * num
ans = a
for i in range(a+1,b+1):
    ans ^= i
ans ^= nu
print(ans)
### BUGGY CODE ###

from collections import deque

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

sys.setrecursionlimit(5000)

def bfs(point, field, target):
    visited = []
    que = deque()
    que.append((point, 1))
    
    while True:
        v, depth = que.popleft()
        visited.append(v)
        for a in [(v[0]-1, v[1]), (v[0]+1, v[1]), (v[0], v[1]-1), (v[0], v[1]+1)]:
            if field[a[0]][a[1]] == '.' and a not in visited:
                if a == target:
                    return depth + 1
                else:
                    que.append((a, depth+1))
        if len(que) == 0:
            return 0

def main():
    H, W = list(map(int, input().split()))
    target = (H, W)
    field = [['#'] * (W + 2) for _ in range(H + 2)]
    for i in range(H):
        values = list(input())
        field[i+1][1:-1] = values

    number_of_whites = 0
    for i in range(1, H+1):
        for j in range(1, W+1):
            if field[i][j] == '.':
                number_of_whites += 1
    shortest_path = bfs((1, 1), field, target)
    if shortest_path > 0:
        print(number_of_whites - shortest_path)
    else:
        print(-1)
        
if __name__ == '__main__':
    main()

### FIXED CODE ###

H, W = list(map(int, input().split()))
M = [[-1]*(W+2)]
ans = 0
for _ in range(H):
    s = input()
    ans += s.count('.')
    M.append([-1]+[0 if c=='.' else -1 for c in s]+[-1])
M += [[-1]*(W+2)]

queue = [(1,1)]
M[1][1] = 1
dr = [(+1,0),(-1,0),(0,+1),(0,-1)]
turn = 1
while len(queue)>0:
    turn += 1
    queue_new = []
    for qx, qy in queue:
        for dx, dy in dr:
            x, y = qx+dx, qy+dy
            if M[y][x]==0:
                M[y][x] = turn
                queue_new.append((x,y))
    queue = queue_new

print(ans-M[H][W] if M[H][W]>0 else -1)
### BUGGY CODE ###

N = int(input())
List = list(map(int, input().split()))
res = 0
New_List = sorted(List)
Flag = [1]*N
for i in range(1,N):
  if Flag[i] ==1:
    for j in range(i):
      if New_List[i] == New_List[j]:
        Flag[i] = 0
        Flag[j] = 0
      if Flag[j] == 1:
        if New_List[i] % New_List[j] == 0:
          Flag[i] = 0
        else:
          pass
      elif Flag[j] == 0:
        pass
  else:
    pass
res = Flag.count(1)
print(res)

### FIXED CODE ###

N = int(input())
List = list(map(int, input().split()))
res = 0
List.sort()
K = List[N-1]+1
Flag = [1]*K
for i in range(N):
  if Flag[List[i]] ==1:
    res +=1
    for j in range(List[i],K,List[i]):
      Flag[j] = 0
    if i != N-1 and List[i] == List[i+1]:
      res += -1
print(res)
### BUGGY CODE ###

import copy
s=input().split()
num=[int(i) for i in s[:3]]
K=int(s[3])
num_=[0,0,0]
for i in range(K):
	for j in range(3):
		num_[j]=num[(j+1)%3]+num[(j+2)%3]
	num=copy.deepcopy(num_)
	if i%100==0 and abs(num[0]-num[1])>10**18:
		break
if abs(num[0]-num[1])>10**18:
	print("Unfair")
else:
	print(num[0]-num[1])


### FIXED CODE ###

s=input().split()
ans=int(s[0])-int(s[1])
if abs(ans)>10**18:
  print("Unfair")
elif int(s[3])%2==0:
  print(int(s[0])-int(s[1]))
else:
  print(-1*(int(s[0])-int(s[1])))
### BUGGY CODE ###

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

from collections import defaultdict

MOD = 10**9 + 7

primes = defaultdict(int)

for a in A:
    p = 2
    while p * p <= a:
        if a % p == 0:
            cnt = 0
            while a % p == 0:
                cnt += 1
                a //= p
            primes[p] = max(primes[p], cnt)
        p += 1
    if a != 1:
        if a not in primes:
            primes[a] = 1

lcm = 1
for p in primes:
    lcm = lcm * pow(p, primes[p], MOD) % MOD

ans = 0
for a in A:
    ans += lcm * pow(a, MOD-2, MOD) % MOD
    ans %= MOD

print(ans)

### FIXED CODE ###

from functools import reduce
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
 
MOD = 10 ** 9 + 7
 
lcm = reduce(lambda x,y: x*(y//gcd(x,y)), A)
lcm %= MOD

coef = sum(pow(a, MOD-2, MOD) for a in A)
ans = lcm * coef % MOD

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

def main():
    n = int(input())
    As = list(map(int, input().split()))

    As.append(0)
    for i in range(n):
        s = 0
        ans = 0
        for j in range(n+1):
            if j == i:
                continue
            ans += abs(As[j] - s)
            s = As[j]
        print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n = int(input())
    As = [0] + list(map(int, input().split())) + [0]

    cumsum = [0] * (n+1)
    for i in range(1, n+2):
        cumsum[i-1] = abs(As[i] - As[i-1])
    cumsum_sum = sum(cumsum)
    for i in range(1, n+1):
        ans = cumsum_sum - cumsum[i-1] - cumsum[i] + abs(As[i+1] - As[i-1])
        print(ans)


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

n = input()
a = input().split()
n = int(n)
a = [int(s) for s in a]
s =0

for f in range(n):
  ai = a[f]
  for g in range(n):
    if g != f:
        if ai == a[g]:
            s = s+1

if s>0: print("NO")
else: print('YES')

### FIXED CODE ###

n = input()
a = input().split()
n = int(n)
a = [int(s) for s in a]
a.sort()
#print(a)
s=0

for i in range(len(a)-1):
    #print(a[i],a[i+1])
    
    if a[i]==a[i+1]:
        print("NO")
        s=s+1
        break
        
if s == 0: print("YES")
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
d = {}
d_sum = {}
for i in range(N):
  if A[i] in d:
    d[A[i]] += 1
    d_sum[A[i]] += d[A[i]] - 1
  else:
    d[A[i]] = 1
    d_sum[A[i]] = 0
#print(A, d,d_sum)
#print(sum(A), sum(d.values()))
for i in range(N):
  print(sum(d_sum.values()) - (d[A[i]] - 1))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
d = {}
d_sum = {}
for i in range(N):
  if A[i] in d:
    d[A[i]] += 1
    d_sum[A[i]] += d[A[i]] - 1
  else:
    d[A[i]] = 1
    d_sum[A[i]] = 0
#print(A, d,d_sum)
#print(sum(A), sum(d.values()))
ans = sum(d_sum.values())
for i in range(N):
  print(ans - (d[A[i]] - 1))
### BUGGY CODE ###

s = list(str(input()))
t = list(str(input()))

def judge(S,T):
    count = 0
    while True:
        if count == len(S):
            break
        if S[count] == T[count]:
            count = count + 1
        else:
            c1 = S[count]
            c2 = T[count]
            for i in range(len(S)):
                if S[i] == c1:
                    S[i] = c2
                elif S[i] == c2:
                    S[i] = c1
            count = count + 1
    if S == T:
        print("Yes")
    else:
        print("No")
    #print(S)
    #print(T)
    
judge(s,t)

### FIXED CODE ###

s = list(str(input()))
t = list(str(input()))

def judge(S,T):
    start = [-1 for i in range(26) ] 
    goal = [-1 for i in range(26)]
    for i in range(len(S)):
        a = ord(S[i]) - ord('a')
        b = ord(T[i]) - ord('a')
        if start[a] != -1 or goal[b] != -1:
            if start[a]!= b or goal[b] !=a:
                print("No")
                break
        else:
            start[a] = b
            goal[b] =a
        if i==len(S)-1:
            print("Yes")
            
judge(s,t)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
count = ''
for i in range(1,n+1):
  count+=(str(a.count(i))+'\n')
print(count)

### FIXED CODE ###

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

count = [0]*n

for i in a:
  count[i-1]+=1
for i in count:
  print(i)
### BUGGY CODE ###

import math  
from functools import reduce

n = int(input())
count = 0

def gcd(*numbers):
    return reduce(math.gcd, numbers)

for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            m = gcd(i,j,k)
            count += m
print(count)   

### FIXED CODE ###


import math

n = int(input())
count = 0

for i in range(1,n+1):
    for j in range(1,n+1):
        t = math.gcd(i,j)
        for k in range(1,n+1):
            m = math.gcd(t,k)
            count += m
print(count)
### BUGGY CODE ###

from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    for i in range(N):
        ans = 0
        a = A[:]
        del a[i]
        C = Counter(a)
        val = C.values()
        for num in val:
            ans += num * (num - 1) // 2
        print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import Counter

def choose(n):
    return n * (n - 1) // 2


def main():
    N = int(input())
    A = list(map(int, input().split()))
    C = Counter(A)
    cnt = 0
    for c in C.values():
        cnt += choose(c)

    for a in A:
        ans = cnt
        ans -= choose(C[a])
        ans += choose(C[a] - 1)
        print(ans)


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

from collections import deque
import sys
from collections import defaultdict
input = sys.stdin.readline
H, W = map(int, input().split())
C = [list(input()) for i in range(H)]

INF = 10 ** 9
n = H * W
d =[[INF for _ in range(n)] for _ in range(n)]
go = [[1, 0], [0, 1], [-1, 0], [0, -1]]
for x in range(W):
    for y in range(H):
        for temp in go:
            gx,gy = temp
            nx = x + gx
            ny = y + gy
            if 0<= nx < W and 0<= ny < H and C[ny][nx] != "#":
                d[ny * W + nx][y * W + x] = 1
                d[y * W + x] [ny * W + nx]= 1
for i in range(n):
    d[i][i] = 0
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if C[i//W][i%W] != "#" and C[j//W][j%W] != "#" and C[k//W][k%W] != "#":
                    d[i][j] = min(d[i][j],d[i][k] + d[k][j])
ans = d
# print(ans)
x  = 0
for temp in ans:
    for k in temp:
        if k != INF:
            if k > x:
                x = k
print(x)



### FIXED CODE ###

from collections import deque
import sys
from collections import defaultdict
input = sys.stdin.readline



H, W = map(int, input().split())
C = [list(input()) for i in range(H)]
INF = 10 ** 9
go = [[1, 0], [0, 1], [-1, 0], [0, -1]]
que = deque()
ans  = -1
for sx in range(W):
    for sy in range(H): # スタート地点のループ
        if C[sy][sx] == "#":
            continue
        
        dist = [[-1 for _ in range(W)] for _ in range(H)]
        
        que.append((sy,sx))
        dist[sy][sx] = 0
        while que:
            y,x = que.popleft()
            for temp in go:
                gx,gy = temp
                nx = x + gx
                ny = y + gy
                if 0<= nx < W and 0<= ny < H and C[ny][nx] != "#":
                    if dist[ny][nx] == -1: # ここの更新にminはいらない(幅優先なので自明に最短距離を進む)
                        dist[ny][nx] = dist[y][x] + 1
                        que.append( (ny,nx))
        for temp in dist:
            cand = max(temp)
            ans = max(ans,cand)
print(ans)
### BUGGY CODE ###

def resolve():
    import math
    def divisor(n):
        ass = []
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                if i != 1:
                    ass.append(i)
                if i ** 2 == n:
                    continue
                ass.append(n // i)
        return ass

    n = int(input())
    a = list(map(int, input().split()))
    a = list(set(a))
    a = sorted(a)
    pair = False
    divisors = set(divisor(a[0]))
    ggcd = a[0]
    for i in range(1, len(a)):
        divs = set(divisor(a[i]))
        if len(divs & divisors) != 0:
            pair = True
            break
        else:
            divisors = divisors | divs
    for i in range(1, len(a)):
        ggcd = math.gcd(ggcd, a[i])
        if ggcd == 1:
            break
    if ggcd != 1:
        print("not coprime")
    else:
        if pair:
            print("setwise coprime")
        else:
            print("pairwise coprime")
resolve()

### FIXED CODE ###

def resolve():
    import math
    n = int(input())
    a = list(set(map(int, input().split())))
    maxa = max(a)

    ggcd = a[0]
    for i in range(1, len(a)):
        ggcd = math.gcd(ggcd, a[i])
        if ggcd == 1:
            break

    pair = False

    c = [0] * (10**6+ 1)
    for i in a:
        c[i] += 1

    for i in range(2, maxa+1):
        cnt = 0
        for j in range(i, maxa+1, i):

            cnt += c[j]
        if cnt > 1:
            pair = True

    if ggcd != 1:
        print("not coprime")
    else:
        if pair:
            print("setwise coprime")
        else:
            print("pairwise coprime")
resolve()
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def main():
    n,m = map(int,input().split())
    money = [[] for _ in range(10**5)]
    dp = [0] * m

    for _ in range(n):
        a,b = map(int,input().split())
        money[a-1].append(b)

    max1 = []
    for i in range(m):
        max1 += money[i]
        if max1:
            dp[i] = max1.pop(max1.index(max(max1)))
        if i >= 1:
            dp[i] += dp[i-1]

    print(dp[-1])

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import heapq
imput = sys.stdin.readline

def main():
    n,m = map(int,input().split())
    money = [[] for _ in range(10**5)]
    dp = [0] * m
    hq = []
    heapq.heapify(hq)

    for _ in range(n):
        a,b = map(int,input().split())
        money[a-1] += [b]

    for i in range(m):
        for j in money[i]:
            heapq.heappush(hq,-j)
        if hq:
            dp[i] += -heapq.heappop(hq)
        if i >= 1:
            dp[i] += dp[i-1]
    print(dp[-1])

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

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

ans = 0
for i in range(n - 1):
  for j in range(i + 1, n):
    ans += a[i] ^ a[j]

print(ans % (10 ** 9 + 7))

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
MOD = 10 ** 9 + 7
digit = 60
o=[0]*digit
z=[0]*digit

for i in a:
  for j in range(digit):
    if (i >> j) & 1:
      o[j] += 1
    else:
      z[j] += 1
ans = 0    
for j in range(digit):
  ans += (o[j]*z[j]*pow(2,j,MOD))
print(ans % MOD)
### BUGGY CODE ###

a,b=map(int,input().split())
a=input()
e=[]
for i in range(b):
    c,d=map(int, input().split())
    e.append(a[c-1:d].count("AC"))
for i in range(b):
    print(e[i])

### FIXED CODE ###

a,b=map(int,input().split())
a=input()
c=[0]*len(a)
for i in range(len(a)-1):
    if (a[i]+a[i+1])=="AC":c[i+1]=c[i]+1
    else:c[i+1]=c[i]
for i in range(b):
    d,e=map(int,input().split())
    print(c[e-1]-c[d-1])
### BUGGY CODE ###

N=int(input())
H=list(map(int,input().split()))
a=0
for i in range(1,N):
    a=max(H[:i])
    if H[i]<a-1:
        print("No")
        break
else:
    print("Yes")

### FIXED CODE ###

N=int(input())
H=list(map(int,input().split()))
a=H[0]
for i in range(1,N):
    if H[i]<a-1:
        print("No")
        break
    a=max(a,H[i])
else:
    print("Yes")
### BUGGY CODE ###

import copy

H, W = map(int, input().split())
dist_matrix = [[10000] * W for i in range(H)]
black_h_list = []
black_w_list = []
for i in range(H):
  line_list = list(input())
  for j in range(W):
    if line_list[j] == "#":  
      black_h_list.append(i)
      black_w_list.append(j)

#print(black_h_list)
#print(black_w_list)

for i in range(H):
  for j in range(W):
    min_dist = H+W+2
    for k in range(len(black_h_list)):
      dist = abs(i-black_h_list[k]) + abs(j-black_w_list[k])
      if min_dist > dist:
        min_dist = dist
    dist_matrix[i][j] = min_dist

#print(dist_matrix)
    
max_value = 0
for i in range(H):
  for j in range(W):
    if max_value < dist_matrix[i][j]:
      max_value = dist_matrix[i][j]
      
print(max_value)

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline
 
H, W = map(int, input().split())
mark_matrix = [[True]*(W+2)]
#mark_matrix.extend([[True]+[False]*(W)+[True] for _ in range(H)])
mark_matrix.extend([[True]+[x!='.' for x in input()] for _ in range(H)])
mark_matrix[H].append(True)
mark_matrix.append([True]*(W+2))
#queue = []
queue = deque()
for i in range(1,H+1):
  for j in range(1,W+1):
    if mark_matrix[i][j]:
      queue.append((i,j))
#  line = input()
#  for j,ch in enumerate(line):
#    if ch == "#":
#      mark_matrix[i+1][j+1] = True
#      queue.append((i+1,j+1))
#for i in range(1,H+1):
#  mark_matrix[i][0] = True
#  mark_matrix[i][W+1] = True
#for j in range(W+2):
#  mark_matrix[0][j] = True
#  mark_matrix[H+1][j] = True
#print(mark_matrix)
 
#cnt = 0
#print(queue)
max_value = 0
while(True):
  #print(len(queue))
  if len(queue) == 0:
    break
  
  new_queue = deque()
  for i,j in queue:
  
    if not mark_matrix[i-1][j]:
      mark_matrix[i-1][j] = True
      #queue.append((i-1,j))
      new_queue.append((i-1,j))
    if not mark_matrix[i+1][j]:
      mark_matrix[i+1][j] = True
      #queue.append((i+1,j))
      new_queue.append((i+1,j))
    if not mark_matrix[i][j-1]:
      mark_matrix[i][j-1] = True
      #queue.append((i,j-1))
      new_queue.append((i,j-1))
    if not mark_matrix[i][j+1]:
      mark_matrix[i][j+1] = True
      #queue.append((i,j+1))
      new_queue.append((i,j+1))
 
  if len(new_queue) == 0:
    break
  else:
    queue = new_queue
    max_value += 1
  
#print(cnt)
#print(dist_matrix)
print(max_value)
### BUGGY CODE ###

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

cnt = [0] * ((10**6) + 1)
ans = 0

for i in a:
    for j in range(i, (10**6)+1,i):
        cnt[j] += 1

for i in a:
    if cnt[i] == 1:
        ans += 1

print(ans)

### FIXED CODE ###

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

a_max = max(a)
cnt = [0] * (max(a) + 1)
ans = 0

for ai in a:
    for multi in range(ai, a_max + 1, ai):
        cnt[multi] += 1

for ai in a:
    if cnt[ai] == 1:
        ans += 1

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

s = input()
k = int(input())
sub = []
for i in range(len(s)):
    for j in range(i, len(s) + 1):
        sub.append(s[i:j])
print(sorted(list(set(sub)))[k])

### FIXED CODE ###

s = input()
k = int(input())
sub = []
for i in range(len(s)):
    for j in range(i, i + k + 1):
        sub.append(s[i:j])
print(sorted(set(sub))[k])
### BUGGY CODE ###

import math
import sys
input=sys.stdin.buffer.readline
def main():
    N,D,A=map(int,input().split())
    monster=[list(map(int,input().split())) for i in range(N)]
    monster.sort(key=lambda x:x[0])
    ans=0
    for i in range(N):
        if(monster[i][1]==0):
            continue
        cnt=math.ceil(monster[i][1]/A)
        ans+=cnt
        for j in range(i+1,N):
            if monster[j][0]-monster[i][0]>2*D:
                break
            monster[j][1]=max(0,monster[j][1]-cnt*A)
    print(ans)

if __name__=='__main__':
    main()

### FIXED CODE ###

import bisect
import math
N,D,A=map(int,input().split())
tmp=[list(map(int,input().split())) for i in range(N)]
tmp.sort(key=lambda x:x[0])
monster=[];X=[]
for i in range(N):
    monster.append(tmp[i][1]);X.append(tmp[i][0])
minus=[0]*(N+1)
ans=0
damage=0
for i in range(N):
    damage-=minus[i]
    monster[i]=max(0,monster[i]-damage)
    if(monster[i]==0):
        continue
    cnt=math.ceil(monster[i]/A)
    monster[i]=0
    ans+=cnt
    b=bisect.bisect_left(X,X[i]+2*D+1)
    minus[b]+=cnt*A
    damage+=A*cnt
print(ans)