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

n=int(input())
s=list(input())
rlist=[]
glist=[]
blist=[]
ans=0
if len(s)<=3:
    print(0)
    exit()
for i in range(n):
    if s[i]=="R":
        rlist.append(i)
    elif s[i]=="G":
        glist.append(i)
    else:
        blist.append(i)
if len(rlist)==0 or len(glist)==0 or len(blist)==0:
    print(0)
    exit()
ans+=len(rlist)*len(glist)*len(blist)
for i in rlist:
    for j in blist:
        if i>j :
            if 2*i-j in glist:
                ans-=1
        else:
            if 2*j-i in glist:
                ans-=1
for i in glist:
    for j in blist:
        if i>j :
            if 2*i-j in rlist:
                ans-=1
        else:
            if 2*j-i in rlist:
                ans-=1
for i in rlist:
    for j in glist:
        if i>j :
            if 2*i-j in blist:
                ans-=1
        else:
            if 2*j-i in blist:
                ans-=1


print(ans)

### FIXED CODE ###

def binary_search(list,target):

	result = -1
	left = 0
	right = len(list) - 1

	while left <= right:
		center = int((left + right)/2)
		if list[center] == target:
			result = center
			break
		elif list[center] < target:
			left = center + 1
		elif list[center] > target:
			right = center - 1

	if result == -1:
		return result
	else:
		return result


if __name__=="__main__":
    n=int(input())
    s=list(input())
    rlist=[]
    glist=[]
    blist=[]
    ans=0
    if len(s)<=3:
        print(0)
        exit()
    for i in range(n):
        if s[i]=="R":
            rlist.append(i)
        elif s[i]=="G":
            glist.append(i)
        else:
            blist.append(i)
    if len(rlist)==0 or len(glist)==0 or len(blist)==0:
        print(0)
        exit()
    ans+=len(rlist)*len(glist)*len(blist)
    for i in range(n-2):
        for j in range(i+1,n-1):
            k=2*j-i
            if s[i]==s[j]:
                continue
            elif k>len(s)-1:
                continue
            else:
                if s[k]!=s[i] and s[k]!=s[j]:
                    ans-=1

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

N=int(input())
total=0

def divisor_count(n):
    count=0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            count=count+1
            if i != n // i:
                count=count+1
    return count

for i in range(1,N):
  total=total+divisor_count(i)
print (total)

### FIXED CODE ###

N=int(input())
a=1
count=0
while a<N:
  count=count+(N-1)//a
  a=a+1
else:
  print(count)
### BUGGY CODE ###

N = int(input())
s = []
for i in range(N):
  s += [''.join(sorted(input()))]
set_s = set(s)
cnt = 0
for j in set_s:
  cnt += s.count(j)*(s.count(j) - 1) // 2
print(int(cnt+0.5))

### FIXED CODE ###

from collections import Counter

N = int(input())
s = []
for i in range(N):
  s += [''.join(sorted(input()))]
cnt = sum([x*(x - 1) // 2 for x in Counter(s).values()])
print(int(cnt+0.5))
### BUGGY CODE ###

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

SL = sorted(L)

for i in range (0, max(L)):
	print(len([j for j in SL if j == i+1]))

for i in range (max(L), N):
	print(0)

### FIXED CODE ###

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

K = [0]*N

for i in range (0, N-1):
	K[L[i]-1]+=1

print(*K, sep = "\n")
### BUGGY CODE ###

import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
s = [i for i in S()]
#print(s)

a = [-1 for i in range(N)]
v = []
n = 0
for i in range(N)[::-1]:
  if s[i] not in v:
    v.append(s[i])
    n += 1
  a[i] = n

finished = [[-1]*10 for i in range(10)]
ans = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    if finished[int(s[i])][int(s[j])] == True:
      continue
    else:
      ans += a[j + 1]
    finished[int(s[i])][int(s[j])] = True
print(ans)

### FIXED CODE ###

import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
s = S()

cnt = 0
for a in range(10):
    for b in range(10):
        n = 0
        ab = [a,b]
        for i in range(N):
            if int(s[i]) == ab[n]:
                n += 1
            if n == 2:
                for c in range(10):
                    for j in range(i+1,N):
                        if int(s[j]) == c:
                            cnt += 1
                            break
                else:
                    break
print(cnt)
### BUGGY CODE ###

n = int(input())
t = 1
for i in range(1, n+1):
    t *= i
print(t % (10**9+7))

### FIXED CODE ###

n = int(input())
t = 1
d = 10**9+7
for i in range(1, n+1):
    t = t * i % d
print(t)
### BUGGY CODE ###

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


for k in range(K):
    D=[0]*(N+1)
    for i,d in enumerate(A):
        left=max(0,i-d)
        right= min(N-1,i+d)
        D[left]+=1
        D[right+1]-=1
    for i in range(N):
        D[i+1]+=D[i]
    A= D[:-1]

print(" ".join(map(str,A)))


### FIXED CODE ###

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


for k in range(K):
    if all(a==N for a in A):
        break
    D=[0]*(N+1)
    for i,d in enumerate(A):
        left=max(0,i-d)
        right= min(N-1,i+d)
        D[left]+=1
        D[right+1]-=1
    for i in range(N):
        D[i+1]+=D[i]
    A= D[:-1]

print(" ".join(map(str,A)))
### BUGGY CODE ###

h,w = map(int, input().split())
S = [""] * (h+2)
s = "#"*(w+2)
S[0] = s
for i in range(1, h+1):
    s = input()
    S[i] = "#" + s + "#"

S[h+1] = "#"*(w+2)
ans = 0
for i in range((h)):
    for j in range((w)):
        cnt = 1
        if S[i+1][j+1] == ".":
        
            #ue
            idx = 1
            while S[i+1-idx][j+1] != "#":
                cnt += 1
                idx += 1
            #sita
            idx = 1
            while S[i+1+idx][j+1] != "#":
                cnt += 1
                idx += 1

            #hidari
            idx = 1
            while S[i+1][j+1-idx] != "#":
                cnt += 1
                idx += 1
            #migi
            idx = 1
            while S[i+1][j+1+idx] != "#":
                cnt += 1
                idx += 1

        ans = max(ans, cnt)

print(ans)

### FIXED CODE ###

h,w = map(int, input().split())

grid = [input() for i in range(h)]

L = [[0 for i in range(w)] for j in range(h)]
R = [[0 for i in range(w)] for j in range(h)]
D = [[0 for i in range(w)] for j in range(h)]
U = [[0 for i in range(w)] for j in range(h)]

#左上から
for i in range(h):
    for j in range(w):
        if grid[i][j] == "#":
            L[i][j] = 0
            U[i][j] = 0
        else:
            if j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j-1] + 1
            
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1

#右下から
for i in reversed(range(h)):
    for j in reversed(range(w)):
        if grid[i][j] == "#":
            R[i][j] = 0
            D[i][j] = 0
        else:
            if j == w-1:
                R[i][j] = 1
            else:
                R[i][j] = R[i][j+1] + 1
                
            if i == h-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j] + 1


ans = 0
for i in range(h):
    for j in range(w):
        if grid[i][j] == "#":
            continue
        tmp = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
        ans = max(ans, tmp)

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

import numpy as np
A, B, Q = map(int,input().split())
s_list = [int(input()) for i in range(A)]
t_list = [int(input()) for i in range(B)]
x_list = [int(input()) for i in range(Q)]


def get_dist_to_first_cp(x,li):
    dist1 = [l - x  for l in li]
    abs_dist1 = list(map(abs,dist1))
    dist_to_first_cp = min(abs_dist1)
    first_cp_num = np.argmin(abs_dist1)
    first_cp_pos = x + dist1[first_cp_num]
    return dist_to_first_cp, first_cp_pos
    


u_list = s_list + t_list
for i, x in enumerate(x_list):
    # shrine first
    dist_to_first_cp, first_cp_pos = get_dist_to_first_cp(x,s_list)
    dist2 = [t - first_cp_pos for t in t_list]
    dist_to_sec_cp = min(map(abs,dist2))
    ans_s = dist_to_first_cp + dist_to_sec_cp
    # temple first
    dist_to_first_cp, first_cp_pos = get_dist_to_first_cp(x,t_list)
    dist2 = [s - first_cp_pos for s in s_list]
    dist_to_sec_cp = min(map(abs,dist2))
    
    ans_t = dist_to_first_cp + dist_to_sec_cp

    print(min(ans_s,ans_t))


### FIXED CODE ###

import bisect

A, B, Q = map(int,input().split())
INF = 10**18
s_list = [-INF] +  [int(input()) for i in range(A)] + [INF]
t_list = [-INF] + [int(input()) for i in range(B)] + [INF]
x_list = [int(input()) for i in range(Q)]

for x in x_list:
    
    b, d = bisect.bisect_right(s_list, x), bisect.bisect_right(t_list, x)
    a = b - 1
    c = d - 1 
    ans = INF
    for s in [s_list[a], s_list[b]]:
        for t in [t_list[c], t_list[d]]:
            dist1 = abs(s-x) + abs(t-s)
            dist2 = abs(t-x) + abs(t-s)
            ans = min(ans, dist1,dist2)
    print(ans)
### BUGGY CODE ###

N = int(input())
list1 = [int(input()) for i in range(N)]

for i in range(N):
  list2 = list1[:i]+list1[i+1:]
  print(max(list2))



### FIXED CODE ###

N = int(input())
list1 = [int(input()) for i in range(N)]

max1 = list1.index(max(list1))
max2 = max(list1)
list2 = list1[:max1]+list1[max1+1:]
max3 = max(list2)

for i in range(N):
  if i != max1:
    print(max2)
  else:
    print(max3)
### BUGGY CODE ###

from collections import deque 
N = int(input())
S = input()
s = deque(list(S))
count = 0
def findb(ind,checker):
    global count
    b = S[ind:].count("B")
    if b > 0:
        if ind + checker < N:
            if S[ind+checker] == "B":
                b -= 1
        count += b
def findg(ind,checker):
    global count
    g = S[ind:].count("G")
    if g > 0:
        if ind + checker < N:
            if S[ind+checker] == "G":
                g -= 1
        count += g
def findr(ind,checker):
    global count
    r = S[ind:].count("R")
    if r > 0:
        if ind + checker < N:
            if S[ind+checker] == "R":
                r -= 1
        count += r
for i in range(N-2):
    temp = s.popleft()
    if temp == "R":
        for j in [x for x, y in enumerate(S[i:]) if y == 'G']:
            findb(i+j,j)
        for j in [x for x, y in enumerate(S[i:]) if y == 'B']:
            findg(i+j,j)
    elif temp == "G":
        for j in [x for x, y in enumerate(S[i:]) if y == 'B']:
            findr(i+j,j)
        for j in [x for x, y in enumerate(S[i:]) if y == 'R']:
            findb(i+j,j)
    else:
        for j in [x for x, y in enumerate(S[i:]) if y == 'R']:
            findg(i+j,j)
        for j in [x for x, y in enumerate(S[i:]) if y == 'G']:
            findr(i+j,j)
print(count)

### FIXED CODE ###

N = int(input())
S = input()
r = S.count('R')
g = S.count('G')
b = S.count('B')
count = r * g * b
for i in range(N):
    for j in range(i+1,N-1):
        if 2*j - i <= N-1:
            l = set([S[i],S[j],S[2*j-i]])
            if len(l) == 3:
                count -= 1
print(count)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
C = list(map(lambda x: int(x) - 1, input().split()))

M = int(N**0.5)
K = (N + M - 1) // M

query = []

for i in range(Q):
    l, r, = map(int, input().split())
    query.append((l - 1, r, i))

query.sort(key = lambda x: (x[0] // M, x[1]))

lt, rt = 0, 0
S = [0 for _ in range(N)]
tmp = 0
res = [0 for _ in range(Q)]

for l, r, i in query:
    while lt > l:
        lt -= 1
        if S[C[lt]] == 0:
            tmp += 1
        S[C[lt]] += 1
    while rt < r:
        if S[C[rt]] == 0:
            tmp += 1
        S[C[rt]] += 1
        rt += 1
    while lt < l:
        if S[C[lt]] == 1:
            tmp -= 1
        S[C[lt]] -= 1
        lt += 1
    while rt > r:
        rt -= 1
        if S[C[rt]] == 1:
            tmp -= 1
        S[C[rt]] -= 1
    res[i] = tmp

print('\n'.join(map(str, res)))

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

N, Q = map(int, input().split())
C = list(map(lambda x: int(x) - 1, input().split()))

query = []

for i in range(Q):
    l, r, = map(int, input().split())
    query.append((l - 1, r, i))

query.sort(key = lambda x: x[1])

rt = 0
L = [None for _ in range(N)]
res = [0 for _ in range(Q)]
bit = [0 for _ in range(N + 1)]

for l, r, id in query:
    while rt < r:
        if L[C[rt]] is not None:
            idx = L[C[rt]] + 1
            while idx <= N:
                bit[idx] -= 1
                idx += idx & -idx
        L[C[rt]] = rt
        idx = rt + 1
        while idx <= N:
            bit[idx] += 1
            idx += idx & -idx
        rt += 1
    sr = 0
    sl = 0
    idx = r
    while idx:
        sr += bit[idx]
        idx -= idx & -idx
    idx = l
    while idx:
        sl += bit[idx]
        idx -= idx & -idx
    res[id] = sr - sl

print('\n'.join(map(str, res)))
### BUGGY CODE ###

N, K = map(int, input().split())
plist = list(map(int, input().split()))
kitaiti = [sum(range(p+1))/p for p in plist]
ans = 0
for i in range(N-K+1):
    ans = max(ans, sum(kitaiti[i:i+K]))
print(ans)

### FIXED CODE ###

import numpy as np
N, K = map(int, input().split())
plist = list(map(int, input().split()))
kitaiti = np.array([(0.5*(p+1)) for p in plist])
ans = 0
val = sum(kitaiti[:K])
ans = max(ans, val)
for i in range(1, N-K+1):
    # print(i-1, i+K)
    val -= kitaiti[i-1]
    val += kitaiti[i+K-1]
    ans = max(ans, val)
print(ans)
### BUGGY CODE ###

def main():
    R, C, K = map(int, input().split())
    items = [[0 for _ in range(C)] for _ in range(R)]
    for _ in range(K):
        r, c, v = map(int, input().split())
        items[r - 1][c - 1] = v
    dp = [[[0 for _ in range(C)] for _ in range(R)] for _ in range(4)]
    dp[1][0][0] = items[0][0]
    for r in range(R):
        for c in range(C):
            for i in range(4):
                tmp = dp[i][r][c]
                # right
                if c != C - 1:
                    # unpick
                    dp[i][r][c + 1] = max(dp[i][r][c+1], tmp)
                    # pick
                    if i < 3:
                        dp[i+1][r][c + 1] = max(dp[i+1][r]
                                                [c + 1], tmp + items[r][c + 1])
                # down
                if r != R - 1:
                    # unpick
                    dp[i][r + 1][c] = max(dp[i][r + 1][c], tmp)
                    # pick
                    dp[1][r + 1][c] = max(dp[1][r + 1][c],
                                          tmp + items[r + 1][c])
    ans = 0
    for i in range(4):
        ans = max(ans, dp[i][-1][-1])
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from sys import stdin
input = stdin.readline
def main():
    R, C, K = map(int, input().split())
    items = [[0 for _ in range(C)] for _ in range(R)]
    for _ in range(K):
        r, c, v = map(int, input().split())
        items[r - 1][c - 1] = v
    dp = [[[0 for _ in range(C)] for _ in range(R)] for _ in range(4)]
    dp[1][0][0] = items[0][0]
    for r in range(R):
        for c in range(C):
            for i in range(4):
                tmp = dp[i][r][c]
                # right
                if c != C - 1:
                    # unpick
                    dp[i][r][c + 1] = max(dp[i][r][c+1], tmp)
                    # pick
                    if i < 3:
                        dp[i+1][r][c + 1] = max(dp[i+1][r]
                                                [c + 1], tmp + items[r][c + 1])
                # down
                if r != R - 1:
                    # unpick
                    dp[0][r + 1][c] = max(dp[0][r + 1][c], tmp)
                    # pick
                    dp[1][r + 1][c] = max(dp[1][r + 1][c],
                                          tmp + items[r + 1][c])
    ans = 0
    for i in range(4):
        ans = max(ans, dp[i][-1][-1])
    print(ans)


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

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

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

dp = {}

dp[1] = 0
dp[2] = abs(H[1]-H[0])

for i in range(3, N+1):
    li = []
    for j in range(1,min(K+1,i)):
        li.append(dp[i-j]+abs(H[i-1]-H[i-(j+1)]))
    dp[i] = min(li)

print(dp[N])

### FIXED CODE ###

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

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

dp = {}

dp[1] = 0
dp[2] = abs(H[1]-H[0])

for i in range(3, N+1):
    li = []
    for j in range(1,min(K+1,i)):
        li.append(dp[i-j]+abs(H[i-1]-H[i-(j+1)]))
    dp[i] = min(li)

print(dp[N])
### BUGGY CODE ###

import bisect

N=int(input())

line=[]

for _ in range(N):
    A=int(input())
    index=bisect.bisect_left(line,A)
    if index==0:
        line.insert(index,A)
    else:
        line[index-1]=A
        line.sort()
    
    #print(line)

print(len(line))

### FIXED CODE ###

import bisect
import collections

N=int(input())

line=collections.deque()

for _ in range(N):
    A=int(input())
    index=bisect.bisect_left(line,A)
    if index==0:
        line.appendleft(A)
    else:
        line[index-1]=A
    #print(line)
    
    #print(line)

print(len(line))
### BUGGY CODE ###

import heapq

N,M = (int(i) for i in input().split())
A = list(map(int,input().split()))
A.sort()

for i in range(M):
    B,C = (int(i) for i in input().split())
    i = 0
    while C > A[0] and i < B:
        heapq.heappop(A)
        heapq.heappush(A,C)
        i += 1

print(sum(A))


### FIXED CODE ###

import heapq

N,M = (int(i) for i in input().split())
A = list(map(int,input().split()))
A.sort()
D = []
len = 0
BC = [0] * M

for i in range(M):
    BC[i] = list(map(int,input().split()))
BC.sort(key = lambda x:x[1],reverse = True)
for i in range(M):
    D.extend([BC[i][1]] * BC[i][0])
    len += BC[i][0]
    if len > N:
        break
cnt = min(N,len)
for i in range(cnt):
    if A[0] < D[i]:
        heapq.heapreplace(A,D[i])
    else:
        break
print(sum(A))
### BUGGY CODE ###

N=int(input())
list=[]
for a in range(N):
    A=int(input())
    if A in list:
        list.remove(A)
    else:
        list.append(A)
print(len(list))


### FIXED CODE ###

from collections import Counter
N=int(input())

numbers=[]

for _ in range(N):
    A=int(input())
    numbers.append(A)

answers=Counter(numbers)

answer=0
for value in answers.values():
    if value%2==1:
        answer+=1
print(answer)
### BUGGY CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split()))

# print(H)
H = sorted(H, reverse=True)
# print(H)

for _ in range(K):
    if len(H) == 0:
        break
    H.pop(0)

# print(H)

result = 0
for h in H:
    result += h
    
print(result)

### FIXED CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split()))

# print(H)
# print(H)

if N <= K:
    print(0)
else:
    H = sorted(H, reverse=True)
    # for _ in range(K):
    #     if len(H) == 0:
    #         break
    #     H.pop(0)
    
    # print(H)
    
    result = 0
    for i in range(K, N):
        result += H[i]

    print(result)
### BUGGY CODE ###

int_n = int(input())

ar_int_a = []
for i in range(int_n):
    ar_int_a.append(int(input()))

numbers = set(ar_int_a)

# written = [i for i in numbers if ar_int_a.count(i) % 2 == 1]

written = 0
for i in numbers:
    if ar_int_a.count(i) % 2 == 1:
        written += 1

# print(len(written))
print(written)

### FIXED CODE ###

from collections import defaultdict


int_n = int(input())

counter = defaultdict(int)

for i in range(int_n):
    counter[int(input())] += 1

written = 0
for c in counter.values():
    if c % 2 == 1:
        written += 1


print(written)
### BUGGY CODE ###

from math import factorial

num=int(input())
stl=[]

count=0

for i in range(num):
    str=input()
    stll=list(str)
    stll.sort()
    str=''.join(stll)        
    stl.append(str)

duplicate=[x for x in set(stl) if stl.count(x) > 1]
if duplicate:
    for dup in duplicate:
        n=stl.count(dup)
        count=count+factorial(n) // factorial(2) // factorial(n - 2)

    
print(count)

### FIXED CODE ###

num=int(input())
stl =[''.join(sorted(input())) for i in range(num)]

#duplicate=[x for x in set(stl) if stl.count(x) > 1]

t = {}
for i in range(num):
  if stl[i] in t:
    t[stl[i]] += 1
  else:
    t[stl[i]] = 1
print(sum(t[k] * (t[k] -1) // 2 for k in t))
### BUGGY CODE ###

n = int(input())
if n == 1:
  print(1)
  exit()
  
chk = []
for i in range(n):
  a = int(input())
  chk.append((i,a))
  
from heapq import heapify,heappop,heappush
from bisect import bisect_left,insort_left
heapify(chk)
ans = 1

c = []
for j in range(n):
  i,a = heappop(chk)
  if j == 0:
    c.append((a,n-i))
  else:
    ind = bisect_left(c,(a,n-i))
    if ind == 0:
      ans += 1
      insort_left(c,(a,n-i))
    else:
      c[ind-1] = (a,n-i)
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
if n == 1:
  print(1)
  exit()
  
chk = []
for i in range(n):
  a = int(input())
  chk.append((i,a))
  
from bisect import bisect_left,insort_left
from collections import deque
ans = 1

c = deque([])
for j in chk:
  i,a = j
  if i == 0:
    c.append((a,n-i))
  else:
    ind = bisect_left(c,(a,n-i))
    if ind == 0:
      ans += 1
      c.appendleft((a,n-i))
    else:
      c[ind-1] = (a,n-i)
      
print(ans)
### BUGGY CODE ###

h = int(input())
temp = 1
ans = 1
cnt = 0
while(True):
  h = h // 2
  cnt += 1
  if(cnt != 1):
  	temp *= 2
  	ans += temp
  if(h == 1):
    break
print(ans + 2**cnt)

### FIXED CODE ###

h = int(input())
if(h == 1):
  print(1)
  exit()
cnt = 1
point = 0
list = [0 for i in range(100)]
while (h>point+1):
  list[cnt] = ((list[cnt-1] * 2) +1)
  point += 2**cnt
  cnt += 1

print(list[cnt-1]*2+1)
### BUGGY CODE ###

# coding: utf-8

import sys
from collections import deque

#n, q = map(int, input().split())
n = int(input())
tasks = {
    "insert": "appendleft",
    "delete": "remove",
    "deleteFirst": "popleft",
    "deleteLast": "pop"
}

a = deque()

for i in range(n):
    input_line = input()
    if input_line in tasks:
        #deleteFirst,deleteLast
        task = input_line
        eval("a.{}()".format(tasks[task]))
    else:
        #insert,delete
        try:
            task, item = input_line.split()
            eval("a.{}({})".format(tasks[task], item))
        except:
            pass

print(*a)

### FIXED CODE ###

# coding: utf-8

import sys
from collections import deque

n = int(input())

task_name = (
    "insert",
    "delete",
    "deleteFirst",
    "deleteLast",
)

a = deque()

for task in map(lambda x: [x] if x in task_name else x.split(), sys.stdin.readlines()):
    #deleteFirst,deleteLast
    if len(task) == 1:
        if task[0] == "deleteFirst":
            a.popleft()
        else:
            a.pop()

    #insert,delete
    else:
        if task[0] == "insert":
            a.appendleft(task[1])
        elif task[1] in a:
            a.remove(task[1])

print(*a)
### BUGGY CODE ###

def main():
	N, M, Q = map(int, input().split())
	LR = [[0 for _ in range(N+1)] for _ in range(N+1)]
	ans = [0]*Q
	for _ in range(M):
		l, r = map(int, input().split())
		LR[l][r] += 1
	for i in range(Q):
		p, q = map(int, input().split())
		for a in range(p, q+1):
			for b in range(a, q+1):
				ans[i] += LR[a][b]
	for a in ans:
		print(a)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
	N, M, Q = map(int, input().split())
	LR = [[0 for _ in range(N+1)] for _ in range(N+1)]
	ans = [0]*Q
	for _ in range(M):
		l, r = map(int, input().split())
		LR[l][r] += 1
	for i in range(1, N+1):
		for j in range(1, N+1):
			LR[i][j] += LR[i][j-1]
	for i in range(1, N+1):
		for j in range(1, N+1):
			LR[i][j] += LR[i-1][j]

	for i in range(Q):
		p, q = map(int, input().split())
		ans[i] = LR[q][q] + LR[p-1][p-1] - LR[p-1][q] - LR[q][p-1]
	for a in ans:
		print(a)


if __name__ == '__main__':
    main()