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

alpha = list('abcdefghijklmnopqrstuvwxyza')

def one_caesar(word):
	new_word = ""
	for s in word:
		if s == ".":
			new_word += "."
			continue
		new_word += alpha[alpha.index(s) + 1]
	return new_word

while True:
	sentence = raw_input().split()
	while 'the' not in sentence or 'that' not in sentence or 'this' not in sentence:
		for i in range(len(sentence)):
			sentence[i] = one_caesar(sentence[i])

	print " ".join(sentence)

### FIXED CODE ###

import string, sys

alpha = 'abcdefghijklmnopqrstuvwxyza'
tbl = string.maketrans(alpha[:-1], alpha[1:])

for s in sys.stdin:
	while not('the' in s or 'that' in s or 'this' in s):
		s = s.translate(tbl)
	print s[:-1]
### BUGGY CODE ###

N = int(input())
S1 = input()
S = [(a, p) for p, a in enumerate(S1)]
count = 0
for i in range(N):
    for k in range(i+1,N):
        if S[i][0] != S[k][0]:
            count += (N-k-1)-S1.count(S[i][0],k+1,N)-S1.count(S[k][0],k+1,N)
            if 2*k-i < N:
                if S[2*k-i][0]!= S[i][0] and S[2*k-i][0]!=S[k][0]:
                    count -= 1 
print(count)    

### FIXED CODE ###

N = int(input())
S = list(input())
count = S.count("R")*S.count("B")*S.count("G")
for i in range(N):
    for j in range(i+1,N):
        if 2*j-i < N:
            if S[i]!=S[j] and S[2*j-i]!=S[i] and S[2*j-i]!=S[j]:
                count-=1
print(count)
### BUGGY CODE ###

import sys
input=sys.stdin.readline
s=' '+input().rstrip()
t=' '+input().rstrip()
m=len(s)-1
n=len(t)-1
dp=[[0]*(n+1) for i in range(m+1)]
for i in range(1,m+1):
    for j in range(1,n+1):
        if s[i]==t[j]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])
ans=''
while m>0 and n>0:
    if dp[m][n]==dp[m][n-1]:
        n-=1
    elif dp[m][n]==dp[m-1][n]:
        m-=1
    elif dp[m][n]==dp[m-1][n-1]+1:
        ans=s[m]+ans
        m-=1
        n-=1
print(ans)

### FIXED CODE ###

import sys
input=sys.stdin.readline
s=' '+input().rstrip()
t=' '+input().rstrip()
m=len(s)-1
n=len(t)-1
dp=[[0]*(n+1) for i in range(m+1)]
for i in range(1,m+1):
    for j in range(1,n+1):
        if s[i]==t[j]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])
ans=''
while m>0 and n>0:
    if dp[m][n]==dp[m][n-1]:
        n-=1
    elif dp[m][n]==dp[m-1][n]:
        m-=1
    elif dp[m][n]==dp[m-1][n-1]+1:
        ans=s[m]+ans
        m-=1
        n-=1
print(ans)
### BUGGY CODE ###

import itertools
n = input()
l = list(map(int,input().split()))
combi = list(itertools.combinations(l,3))
ans = 0
for i in combi:
    a,b,c = i[0],i[1],i[2]
    if a<b+c and b<a+c and c<a+b:
        ans += 1
print(ans)
    

### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
l = sorted(l)
ans = 0
for c in range(n):
    a=0
    b=c-1
    while a<b:
        if l[a]+l[b]>l[c]:
            ans+=b-a
            b-=1
        else:
            a+=1
print(ans)
### BUGGY CODE ###

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

ans = N
for i in range(N + 1):
    left_num = S[:i].count('#')
    right_num = S[i:].count('.')
    if right_num in [0, N - i]:
        ans = min(ans, left_num)
        break
    else:
        ans = min(ans, (left_num + right_num))
print(ans)

### FIXED CODE ###

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

all_black_num = S.count('#')
all_white_num = N - all_black_num

if all_black_num == 0 or all_white_num == 0:
    ans = 0
else:
    left_black_num = 0
    left_white_num = 0
    right_white_num = all_white_num - left_white_num
    right_black_num = all_black_num - left_black_num
    ans = left_black_num + right_white_num
    for i, c in enumerate(S):
        if c == '#':
            left_black_num += 1
        elif c == '.':
            left_white_num += 1
        right_white_num = all_white_num - left_white_num
        right_black_num = all_black_num - left_black_num
        ans = min(ans, left_black_num + right_white_num)
        if right_black_num == N - i - 1:
            break
print(ans)
### BUGGY CODE ###

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

### FIXED CODE ###

import math
n = int(input())

print(math.factorial(n) % (10**9+7))
### BUGGY CODE ###

N = int(input())
A = list(sorted(list(map(int, input().split()))))
# N = 2
# A = list(sorted([5,2,8,5,1,5]))
group = []
ret = 0
for n in range(N):
    group.append([A.pop(0), A.pop(), A.pop()])
for g in group:
    ret += list(sorted(g))[1]
print(ret)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort()
ret = 0
for n in range(N, N*3, 2):
    ret += A[n]
print(ret)
### BUGGY CODE ###

N,W = list(map(int,input().split()))
w_l = []
v_l = []
for i in range(N):
    w,v = list(map(int,input().split()))
    w_l.append(w)
    v_l.append(v)
def knapsack(N,W,w_l,v_l):
    if (N==0 or W==0):
        return 0
    elif(w_l[N-1]>W):
        return knapsack(N-1,W,w_l,v_l)
    
    else:
        return max(knapsack(N-1,W,w_l,v_l), v_l[N-1]+knapsack(N-1,W-w_l[N-1],w_l,v_l))
ans = knapsack(N,W,w_l,v_l)
print(ans)

### FIXED CODE ###

import numpy as np
N,W = map(int,input().split())
V_sum = 0
w_l = []
v_l = []
for i in range(N):
    w,v = list(map(int,input().split()))
    V_sum+=v
    w_l.append(w)
    v_l.append(v)
dp = np.full(V_sum+1,W+1)
dp[0] = 0
for i in range(N):
    dp[v_l[i]:] = np.minimum(dp[v_l[i]:],dp[:-v_l[i]]+w_l[i])
for i in range(V_sum,-1,-1):
    if dp[i]<=W:
        print(i)
        break
### BUGGY CODE ###

X,Y,Z,K = map(int,input().split())
l_a = list(map(int,input().split()))
l_b = list(map(int,input().split()))
l_c = list(map(int,input().split()))
l_a.sort(reverse = True)  
l_b.sort(reverse = True)  
l_c.sort(reverse = True)
l_d = [a + b for a in l_a for b in l_b]
l_d.sort(reverse = True)
l_d[:3000]
l_e = [ab + c for ab in l_d for c in l_c]
l_e.sort(reverse = True)
 
for i in range(K):
    print(l_e[i])

### FIXED CODE ###

X,Y,Z,K=map(int,input().split())
A=[int(x) for x in input().split()]
A.sort(reverse=True)
B=[int(x) for x in input().split()]
B.sort(reverse=True)
C=[int(x) for x in input().split()]
C.sort(reverse=True)
D=[a+b for a in A for b in B]
D.sort(reverse=True)
D=D[:3000]
E=[ab+c for ab in D for c in C]
E.sort(reverse=True)
for i in range(K):
  print(E[i])
### BUGGY CODE ###

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

ans = 0
for i in range(0,k+1):
    for j in range(0,k+1):
        for t in range(0, k+1):
            if i+j+t == s:
                ans += 1
print(ans)


### FIXED CODE ###

from bisect import bisect
k, s = map(int, input().split())
ans = 0
rekkyo = []
for i in range(0,k+1):
    for j in range(0,k+1):
        if 0<=s-i-j<=k:
            ans+=1
print(ans)
### BUGGY CODE ###

import sys


def main():
    input = sys.stdin.readline
    n, q = map(int, input().split())
    s = input()
    li = [map(int, input().split()) for i in range(q)]

    for i, j in li:
        count = 0
        for k in range(i-1, j-1):
            if s[k:k+2] == "AC":
                count += 1
        print(count)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys


def main():
    input = sys.stdin.readline
    n, q = map(int, input().split())
    s = input()
    li = [map(int, input().split()) for i in range(q)]
    count = [0]*len(s)

    for i in range(1, len(s)):
        if s[i] == "C" and s[i-1] == "A":
            count[i] = count[i-1] + 1
        else:
            count[i] = count[i-1]
   
    for i, j in li:
        print(count[j-1] - count[i-1])


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

n = int(input())
factor = []
tmp = n
for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
    while tmp % i == 0:
        factor.append(i)
        tmp //= i
if tmp != 1:
    factor.append(tmp)
w = len(factor)
if w == 0:
    factor.append(n)
    w = 1
if w == 1:
    print(n - 1)
else:
    ans = 1000000000000
    for i in range(1, 2 ** w // 2):
        f2 = [1, 1]
        for j in range(w):
            f2[i & (2 ** j) == 0] *= factor[j]
        ans = min(ans, sum(f2) - 2)
        if ans < n ** 0.5 * 1.5:
            break
    print(ans)


### FIXED CODE ###

n = int(input())
ans = 1000000000000
for i in range(1, int(n ** 0.5) + 1):
    if n % i == 0:
        a = i
        b = n // i
        ans = min(ans, a + b - 2)
print(ans)
### BUGGY CODE ###

input()
b=[]
for a in map(int,input().split()):
    b+=[a]
    b=b[::-1]
print(*b)

### FIXED CODE ###

n=int(input())
b=[0]*n
for i,a in enumerate(map(int,input().split())):
    if n%2:
        b[n//2+-~i//2*[-1,1][i%2]]=a
    else:
        b[n//2+-~i//2*[1,-1][i%2]]=a
print(*b)
### BUGGY CODE ###

#!/usr/local/bin/python3
N = int(input())
A = list(map(int, input().split()))[::-1]

ans = 0
while N != 0:
    m = max(A)
    idx = A.index(m) + 1
    ans += (len(A[:idx]) * m) - sum(A[:idx])
    A = A[idx:]
    N -= idx

print(ans)


### FIXED CODE ###

#!/usr/local/bin/python3
N = int(input())
A = list(map(int, input().split()))

m = ans = 0
for i in range(N):
    m = max(m, A[i])
    ans += m - A[i]

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

if __name__ == '__main__':
    N = int(input())
    X = list(map(int, input().split()))

    for i in range(N):
        x = X[:]
        x.pop(i)
        x.sort()
        print(x[int(N/2-1)])


### FIXED CODE ###

if __name__ == '__main__':
    N = int(input())
    X = list(map(int, input().split()))
    x = sorted(X[:])
    min_median = x[int(N/2-1)]
    max_median = x[int(N/2)]
    for i in range(N):
        if X[i] <= min_median:
            print(max_median)
        else:
            print(min_median)
### BUGGY CODE ###

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

res = 0

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

print(res)


### FIXED CODE ###

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

res = 0

Rn = S.count('R')
Gn = S.count('G')
Bn = S.count('B')

res = Rn * Gn * Bn

for p in range(1, N - 1):
  for q in range(1, min(p, N - p - 1) + 1):
    i, j, k = p - q, p, p + q
    if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
      res -= 1

print(res)
### BUGGY CODE ###

n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(n):
    if p[i] <= min(p[:i+1]):
        count += 1
print(count)

### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))
count = 0
MIN = p[0]
for i in range(n):
    if p[i] <= MIN:
        count += 1
        MIN = p[i]
        if MIN == 1:
            break
print(count)
### BUGGY CODE ###

n=int(input())
a = list(map(int,input().split()))
cnt = [0,0,0] #1個の個数、二個の個数、三個の個数
for i in range(n):
    cnt[a[i]-1] += 1
    
def f(i,j,k):
    if [i,j,k] == [0,0,0]:
        return 0.0
    if dp[i][j][k] != 0.0:
        return dp[i][j][k]
    tmp = 0.0
    if i>0:
        tmp += f(i-1,j,k)*float(i)/float(i+j+k)
    if j>0:
        tmp += f(i+1,j-1,k)*float(j)/float(i+j+k)
    if k>0:
        tmp += f(i,j+1,k-1)*float(k)/float(i+j+k)
    tmp += float(n)/float(i+j+k)
    

    dp[i][j][k] = tmp
    return tmp

dp = [[[0.0 for i in range(n+1)] for j in range(n+1)] for k in range(n+1)]
dp[0][0][0] = 0.0

print(f(cnt[0],cnt[1],cnt[2]))

### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = tuple(map(int,input().split()))
c1 = a.count(1)
c2 = a.count(2)
c3 = a.count(3)

dp = [[[0.0]*(n+1) for i in range(n+1)] for j in range(n+1)] 
dp[0][0][0] = 0
for i in range(c3+1):
    for j in range(c2+c3-i+1):
        for k in range(n-i-j+1):
            if i == j == k == 0:
                continue
            tmp = n
            if k != 0:
                tmp += k*dp[k-1][j][i]
            if j != 0:
                tmp += j*dp[k+1][j-1][i]
            if i != 0:
                tmp += i*dp[k][j+1][i-1]
            dp[k][j][i] = tmp/(i+j+k)

print(dp[c1][c2][c3])
### BUGGY CODE ###

from operator import itemgetter
import sys

# スペース区切りの整数入力
n,d,a = map(int, input().split())

#指定数分の2つの整数を順番に受けてリストに入力
e = []
for i in range(n):
    e.append([int(x) for x in input().split()])
e.sort(key=itemgetter(0))

atk_times_sum = 0

for i in range(n):
    if e[i][1] <= 0:
        continue
    #atk_l = e[i][0]
    atk_u = e[i][0] + d*2
    if e[i][1] % a == 0:
        atk_times = e[i][1] // a
    else:
        atk_times = e[i][1] // a + 1
    atk_times_sum += atk_times
    for j in range(i,n):
        #if atk_l <= e[j][0] and e[j][0] <= atk_u:
        if e[j][0] <= atk_u:
            e[j][1] -=  a * atk_times
        else:
            break

print(atk_times_sum)

### FIXED CODE ###

from operator import itemgetter
from collections import deque
import sys

# スペース区切りの整数入力
n,d,a = map(int, input().split())

#指定数分の2つの整数を順番に受けてリストに入力
e = []
for i in range(n):
    e.append([int(x) for x in input().split()])
e.sort(key=itemgetter(0))

atk_times_sum = 0
atk_que = deque()
atk_acm_p = 0

for i in range(n):
    while len(atk_que) > 0:
        if atk_que[0][0] < e[i][0]:
            atk_u,atk_p = atk_que.popleft()
            atk_acm_p -= atk_p
        else:
            break
    e[i][1] -= atk_acm_p
    if e[i][1] <= 0:
        continue
    atk_u = e[i][0] + d*2
    if e[i][1] % a == 0:
        atk_times = e[i][1] // a
    else:
        atk_times = e[i][1] // a + 1
    e[i][1] = 0 
    atk_times_sum += atk_times
    atk_p = a * atk_times
    atk_acm_p += atk_p
    atk_que.append([atk_u,atk_p])

print(atk_times_sum)
### BUGGY CODE ###

n= int(input())
a = list(map(int,input().split()))
ans = int(a[0])

for i in range(1, n):
    ans *= a[i]
    
if ans > 10 ** 18:
    print("-1")
else:
    print(ans)

### FIXED CODE ###

import sys

n= int(input())
a = list(map(int,input().split()))
ans = a[0]
ans_max = 10 ** 18

if 0 in a:
    print(0)
    sys.exit()

for i in range(1, n):
    ans *= a[i]
    if ans > ans_max:
        print("-1")
        sys.exit()

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

# author:  Taichicchi
# created: 17.09.2020 23:46:19

import sys

N = int(input())

S = input()

cnt = 0

for i in map(lambda x: str(x).zfill(3), range(1000)):
    f = 0
    for j in range(len(S)):
        if S[j] == i[f]:
            f += 1
        if f == 3:
            break
    if f == 3:
        cnt += 1

print(cnt)


### FIXED CODE ###

# author:  Taichicchi
# created: 17.09.2020 23:46:19


N = int(input())

S = input()

cnt = 0

for i in map(lambda x: str(x).zfill(3), range(1000)):
    f = 0
    for s in S:
        if s == i[f]:
            f += 1
        if f == 3:
            break
    if f == 3:
        cnt += 1

print(cnt)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

if __name__ == '__main__':
  n=int(input())
  #A=list(map(int,input().strip("\n").split()))
  A=input().strip("\n")
  q=int(input())
  Ans=[]
  for i in range(q):
    #b,c=map(int,input().strip("\n").split())
    b,c=input().strip("\n").split()
    A=A.replace(b,c)
    Ans.append(eval(A.replace(" ","+")))
  for ans in Ans:
    print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline

if __name__ == '__main__':
  n=int(input())
  A_str=input().strip("\n")
  A=A_str.split()
  q=int(input())

  C={}
  for a in A:
    if a in C:
      C[a]+=1
    else:
      C[a]=1
  
  def rep(b,c):
    if c in C:
      C[c]+=C[b]
    else:
      C[c]=C[b] 
    C[b]=0
    #print(b,c,C)

  Ans=[]
  ans=''
  b,c=input().strip("\n").split()
  #tmp=eval(A_str.replace(b,c).replace(" ","+"))
  tmp=0
  hoge=map(int,A)
  for a in hoge:
    if str(a)==b:
      tmp+=int(c)
    else:
      tmp+=a
  #ans+=str(tmp)
  #ans+="\n"
  Ans.append(tmp)
  if b in C:
    rep(b,c)
  for i in range(1,q-1):
    b,c=input().strip("\n").split()
    if b in C:
      tmp+=(int(c)-int(b))*C[b]
      rep(b,c)
    #ans+=str(tmp)+"\n"
    Ans.append(tmp)
  b,c=input().strip("\n").split()
  if b in C:
    tmp+=(int(c)-int(b))*C[b]
  #ans+=str(tmp)
  Ans.append(tmp)
  #print(ans)
  for ans in Ans:
    print(ans)
### BUGGY CODE ###

a, b, c, d = map(int, input().split())

cnt = 0    
print(sum([1 for x in range(a, b+1) if x % c != 0 and x % d != 0]))



### FIXED CODE ###

A, B, C, D = map(int, input().split())
 
def gcd(a, b):
    while a%b!=0:
        a, b = b, a%b
    return b
 
X = B//C - (A-1)//C
Y = B//D - (A-1)//D
CD = C*D // gcd(C, D)
XY = B//CD - (A-1)//CD
 
print(B-A+1-(X+Y-XY))
### BUGGY CODE ###


input_line = input()
abk = input_line.split(" ") 
ABK = [int(n) for n in abk]
 
 
for i in range(ABK[2]):
 
    if ABK[0] > 0:
        ABK[0] -= 1
 
    elif ABK[1] > 0: 
        ABK[1] -= 1
 
    else:
        pass
print(ABK[0]," ",ABK[1])
 
 

### FIXED CODE ###


input_line = input()
abk = input_line.split(" ") 
ABK = [int(n) for n in abk]



if ABK[0] + ABK[1] <= ABK[2]:
    A = 0
    B = 0

elif ABK[0] <= ABK[2] and ABK[1] > ABK[2] - ABK[0]:
    A = 0
    B = ABK[1] -  (ABK[2] - ABK[0])

elif ABK[0] > ABK[2]:
    A = ABK[0] - ABK[2]
    B = ABK[1]

    
print(A," ",B)
### BUGGY CODE ###

n=int(input())

def gcd(a,b):
    if a < b:
      a, b = b, a
    while b != 0:
      a, b = b, a % b
    return a

ans=0
for a in range(1,n+1):
    for b in range(1,n+1):
        for c in range(1,n+1):
            i=gcd(a,b)
            j=gcd(c,i)
            ans+=j
    
print(ans)

### FIXED CODE ###

n=int(input())
 
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
  
ans=0
for a in range(1,n+1):
    for b in range(1,n+1):
        for c in range(1,n+1):
            
            ans+=gcd(a,b,c)  
print(ans)
### BUGGY CODE ###

count = int(input())

strlist = []
for i in range(count):
  strlist.append(input())

for i in range(count - 1):
  for j in range(i + 1, count):
    if strlist[i] > strlist[j]:
      tmp = strlist[i]
      strlist[i] = strlist[j]
      strlist[j] = tmp

duplication = 0
for i in range(count - 1):
  if strlist[i] == strlist[i + 1]:
    duplication += 1
    
print(count - duplication)

### FIXED CODE ###

count = int(input())

strlist = set()
for i in range(count):
  strlist.add(input())

print(len(strlist))
### BUGGY CODE ###

"""
    高橋君の状態で場合分け
    if Takahashi's condition is going dead
        he should eat cookies enable him recover
    else Takahashi's condition is good
        he is able to eat delicious cookies.
"""

a, b, c = map(int, input().split())

takahashi = True
takahashi_condition = True
count = 0

""" Start eating cookies"""
while takahashi_condition:
    if takahashi:
        if c > 0:
            c -= 1
            takahashi = False
            count += 1
        elif b > 0:
            b -= 1
            takahashi = True
            count += 1
            if b == 0:
                break
    else:
        if a == 0 and b == 0:
            break
        elif b > 0:
            b -= 1
            takahashi = True
            count += 1
        elif a > 0:
            takahashi = True
            a -= 1
        

print(count)

### FIXED CODE ###


a, b, c = map(int, input().split())

if a+b+1 > c:
    count = b+c
else:
    count = b+(a+b+1)

print(count)
### BUGGY CODE ###

n,k,q = map(int,input().split())
plist = [k]*n
for j in range(q):
  s = int(input())
  for i in range(n):
    plist[i] -= 1
  plist[s-1] += 1
  
for i in plist:
  if i <= 0:
    print('No')
  else:print('Yes')


### FIXED CODE ###

n,k,q = map(int,input().split())
plist = [k-q]*n
for i in range(q):
  s = int(input())
  plist[s-1] += 1
for i in plist:
  if i <= 0:
    print('No')
  else:print('Yes')
### BUGGY CODE ###

N,M=map(int,input().split())
A=[int(input()) for i in range(M)]
if 1 in A:
    B=[1]+[0]*N
else:
    B=[1]+[1]+[0]*(N-1)
for i in range(2,N+1):
    if i not in A:
        B[i]=B[i-1]+B[i-2]
print(B[-1]%(10**9+7))

### FIXED CODE ###

N,M=map(int,input().split())
B=[1]+[1]+[0]*(N-1)
for j in range(M):
    a=int(input())
    B[a]=-1
    if a==1:
        B[a]=0
i=2
while i<=N:
    if B[i]==-1:
        B[i]=0
    else:
        B[i] = (B[i - 1] + B[i - 2]) % (10 ** 9 + 7)
    i+=1
print(B[N])
### BUGGY CODE ###

while 1:
	n,k=map(int,raw_input().split())
	if n==0:break
	a=[int(raw_input()) for i in range(n)]
	ans=-999999999
	for i in range(n-k):
		ans=max(ans,sum(a[i:i+k]))
	print ans

### FIXED CODE ###

while 1:
	n,k=map(int,raw_input().split())
	if n==0:break
	a=[int(raw_input()) for i in range(n)]
	cur=mx=sum(a[:k])
	for i in range(n-k):
		cur=cur-a[i]+a[i+k]
		mx=max(mx,cur)
	print mx
### BUGGY CODE ###

# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
K = ir()
cand = set()
length = len(S)
for i in range(length):
    for j in range(i+1, length+1):
        cand.add(S[i:j])

cand = sorted(list(cand))
answer = cand[K-1]
print(answer)


### FIXED CODE ###

S = list(input())
K = int(input())
st = set()
for i in range(len(S)):
    for j in range(6):
        st.add(''.join(S[i:i+j]))

st_list = sorted(list(st))
if '' in st_list:
    st_list.remove('')
print(st_list[K-1])
### BUGGY CODE ###

class SegmentTreeMax():
  def __init__(self,n,init):
    self.offset=2**((n-1).bit_length())
    self.tree=[init]*(2*self.offset)
    self.init=init
  def update(self,pos,val):
    pos+=self.offset
    self.tree[pos]=val
    while pos>1:
      pos=pos//2
      self.tree[pos]=max(self.tree[2*pos],self.tree[2*pos+1])
  def query(self,l,r):
    l+=self.offset
    r+=self.offset
    ret=self.init
    while l<=r:
      ret=max(ret,self.tree[r])
      r=(r-1)//2
      ret=max(ret,self.tree[l])
      l=(l+1)//2
    return ret

mod=998244353
n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
arr=sorted(arr,key=lambda x:x[0])
st=SegmentTreeMax(n,0)
ranges=[]
for i in range(n):
  x=arr[i][0]+arr[i][1]
  l=-1
  r=n
  while r-l!=1:
    mid=(l+r)//2
    if arr[mid][0]>=x:
      r=mid
    else:
      l=mid
  ranges.append(l)
  st.update(i,r)
for i in range(n-1,-1,-1):
  ranges[i]=st.query(i,ranges[i])
  st.update(i,ranges[i])
dp=[0]*(n+1)
dp[-1]=1
for i in range(n-1,-1,-1):
  j=ranges[i]
  dp[i]=dp[i+1]+dp[j]
  dp[i]%=mod
print(dp[0])

### FIXED CODE ###

#reference Segment-Tree code from:https://ikatakos.com/pot/programming_algorithm/data_structure/segment_tree

def bisect(pos):
  l=-1
  r=n
  while r-l!=1:
    mid=(l+r)//2
    if arr[mid][0]>=pos:
      r=mid
    else:
      l=mid
  return r

mod=998244353
n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
arr=sorted(arr,key=lambda x:x[0])
poss=[]
for i in range(n):
  poss.append(bisect(arr[i][0]+arr[i][1]))
poss.append(n)

offset=2**((n-1).bit_length())
st=[0]*(2*offset)

def update(pos,x):
  pos+=offset
  st[pos]=x
  while pos>1:
    y=st[pos^1]
    if x<=y:
      break
    pos>>=1
    st[pos]=x

def get_max(l,r):
  ret=0
  l+=offset
  r+=offset
  while l<r:
    if r&1:
      ret=max(ret,st[r-1])
    if l&1:
      ret=max(ret,st[l])
      l+=1
    l>>=1
    r>>=1
  return ret

for i in range(n):
  update(i,poss[i])
for i in range(n-1,-1,-1):
  poss[i]=get_max(i,poss[i])
  update(i,poss[i])

dp=[0]*(n+1)
dp[-1]=1
for i in range(n-1,-1,-1):
  dp[i]+=dp[i+1]
  dp[i]%=mod
  pos=poss[i]
  dp[i]+=dp[pos]
  dp[i]%=mod
print(dp[0]%mod)
### BUGGY CODE ###

def test():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [float('inf')]*N
    dp[0] = 0
    
    for i in range(1,N):
        dp[i] = min(dp[i-j]+abs(h[i] - h[i-j]) for j in range(1,min(K,i)+1))
    
    print(dp[N-1])
    
if __name__ == '__main__':
    test()

### FIXED CODE ###

def test():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    dp = [float('inf')]*N
    dp[0] = 0
 
    for i in range(1, N):
        dp[i] = min(dp[j] + abs(H[i] - H[j]) for j in range(max(i-K, 0), i))
 
    print(dp[-1])
 
if __name__ == '__main__':
    test()
### BUGGY CODE ###

def main():
    N = int(input())
    a = []
    b = []
    for _ in range(N):
        ai, bi = map(int, input().split())
        a.append(ai)
        b.append(bi)
    ans = 0
    s = 1
    while True:
        if sum(a) == 0:
            print(ans)
            exit()
        ma = max(a)
        mb = max(b)
        ans += ma * s
        if ma >= mb:
            i = a.index(ma)
        else:
            i = b.index(mb)
        a[i] = 0
        b[i] = 0
        t = a
        a = b
        b = t
        s *= -1


main()


### FIXED CODE ###

def main():
    N = int(input())
    ab = [[int(i) for i in input().split()] for _ in range(N)]
    ab = sorted(ab, key=lambda x: x[0] + x[1], reverse=True)
    ans = 0
    for i in range(N):
        if i % 2 == 0:
            ans += ab[i][0]
        else:
            ans -= ab[i][1]
    print(ans)


main()