Harryxun/stf_run huggingface dataset:
N = int(input())
Z=[]
for i in range(N):
	t, x, y = map(int, input().split())
	if t % 2 == 0:
		if x + y <= t and (x + y) % 2 == 0:
			Z.append(1)
		else:
			Z.append(0)
	else:
		if x + y <= t and (x + y) % 2 == 1:
			Z.append(1)
		else:
			Z.append(0)
	i += 1
if Z.count(0) >=1:
	print('No')
else:
	print('Yes')




### FIXED CODE ###

a, b = map(int, input().split())
if a * b % 2 == 0:
  print("Even")
else:
    print("Odd")
import sys
input = sys.stdin.readline
q = int(input())

p=1000003

flist=[1 for i in range(p)]
flist[0]=1
for i in range(1,p):
    flist[i]=flist[i-1]*i%p

for i in range(q):
  x,d,n=(int(i) for i in input().split())
  if d==0:
    ans=pow(x,n,p)
  elif p<=x+n-1:
    ans=0
  else:
    x=x*pow(d,p-2,p)%p
    ans=pow(d,n,p)*flist[x+n-1]*pow(flist[x-1],p-2,p)%p
  print(ans%p)

### FIXED CODE ###

import sys
input = sys.stdin.readline
q = int(input())

p=1000003

flist=[1 for i in range(p)]
for i in range(1,p):
    flist[i]=flist[i-1]*i%p

for i in range(q):
  x,d,n=(int(i) for i in input().split())
  if d==0:
    ans=pow(x,n,p)
  else:
    x=x*pow(d,p-2,p)%p    
    if p<=x+n-1:
      ans=0
    else:
      ans=pow(d,n,p)*flist[x+n-1]*pow(flist[x-1],p-2,p)%p
  print(ans%p)
n=int(input())

for a in range(1,10):
    for b in range(1,10):
        if a*b==n:
            flag=True
print("Yes" if flag else "No")

### FIXED CODE ###

from sys import exit

N = int(input())

for i in range(1, 10):
    for j in range(1, 10):
        if N == i * j:
            print('Yes')
            exit()
print('No')
import math

def lcm(x, y):
    div, _ = divmod(x * y, math.gcd(x, y))
    return div


A, B, C, D = map(int, input().split())

# 変数C の倍数が A, B 区間内に存在しうる数
#Ccount = (B // C) - ((A - 1) // C)
divBC, _ = divmod(B, C)
divA1C, _ = divmod(A-1, C)
Ccount = divBC - divA1C

# 変数D の倍数が A, B 区間内に存在しうる数
#Dcount = (B // D) - ((A - 1) // D)
divBD, _ = divmod(B, D)
divA1D, _ = divmod(A-1, D)
Dcount = divBD - divA1D

# 変数C, D の最小公倍数が A, B 区間内に存在しうる数
#CDcross = (B // lcm(C, D)) - ((A - 1) // lcm(C, D))
divBlcmCD, _ = divmod(B, lcm(C, D))
divA1lcmCD, _ = divmod(A-1, lcm(C, D))
CDcross =divBlcmCD - divA1lcmCD

# Cが存在しうる数と Dが存在しうる数を引き、重複する（＝最小公倍数）数は引きすぎなので戻す
print((B-A+1) - ((Ccount + Dcount - CDcross)))

### FIXED CODE ###

from fractions import gcd

def lcm(x, y):
    return ((x * y) // gcd(x, y))


A, B, C, D = map(int, input().split())

# 変数C の倍数が A, B 区間内に存在しうる数
Ccount = (B // C) - ((A - 1) // C)

# 変数D の倍数が A, B 区間内に存在しうる数
Dcount = (B // D) - ((A - 1) // D)

# 変数C, D の最小公倍数が A, B 区間内に存在しうる数
CDcross = (B // lcm(C, D)) - ((A - 1) // lcm(C, D))

# Cが存在しうる数と Dが存在しうる数を引き、重複する（＝最小公倍数）数は引きすぎなので戻す
print((B-A+1) - ((Ccount + Dcount - CDcross)))
n = int(input())
ans = 0
for i,p in enumerate(map(int,input().split())):
  if i + 1 == p:
    ans += 1
print(max(ans-1), 0)

### FIXED CODE ###

from math import ceil

n = int(input())
ans = 0
tmp = 0
for i,p in enumerate(map(int,input().split())):
    if i + 1 == p:
        tmp += 1
    elif tmp:
        ans += ceil(tmp / 2)
        tmp = 0
print(ans + ceil(tmp / 2))
N, K = map(int,input().split())
A = list(map(int,input().split()))
MOD = 10**9 + 7

LANK = list(set(A))
LANK.sort()
LANK2 = [0] * 2000
for i, l in enumerate(LANK):
    LANK2[l] = i

LANK = [-1] * N
for i,a in enumerate(A):
    LANK[i] = LANK2[a]

back = [0] * N
for i,a in enumerate(A[::-1]):
    cnt = 0
    for j,a2 in enumerate(A[::-1]):
        if i > j and a > a2:
            cnt += 1
    back[N-1-i] = cnt
    
SUM = 0
tmp = K(K-1)//2
tmp %= MOD
# print('a')
for i,a in enumerate(A):
    SUM += (LANK[i] * tmp)%MOD
    SUM += (back[i] * K)%MOD
    SUM %= MOD
print(SUM)

### FIXED CODE ###

N, k = map(int,input().split())
A = list(map(int,input().split()))
MOD = 10**9+7

ans = 0
for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            if i > j:
                ans += k*(k-1)//2
            elif i < j:
                ans += k*(k+1)//2
            ans %= MOD

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

print(count)
    

### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))
count = 0
a = p[0]
for x in range(len(p)):
  if p[x] <= a:
    count += 1
    a = p[x]
  
print(count)
import sys
import math

N = int(input())
# N, K = [int(i) for i in input().split()]

if N % 2 == 1:
    print(0)
    sys.exit(0)

count = 0
digit = math.ceil(math.log(N, 5))
for i in range(1, digit+1):
    x = 5 ** i
    count += (N // (x * 2))
print(count)


### FIXED CODE ###

import sys
import math

N = int(input())
# N, K = [int(i) for i in input().split()]
if N == 0:
    print(0)
    sys.exit(0)
if N % 2 == 1:
    print(0)
    sys.exit(0)

count = 0
digit = math.ceil(math.log(N, 5))
for i in range(1, digit+1):
    x = 5 ** i
    count += (N // (x * 2))
print(count)
l=list(map(int, input()))
print(l.count(1)

### FIXED CODE ###

l=list(map(int, input()))
print(l.count(1))
import sys

def main():

	p = 0

	args = sys.argv
	n = int(args[1])
	for i in range(1, n+1):
		if i % 2 == 1:
			p = p + 1
	
	print(p/n)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys

def main():

	p = 0

	args = sys.argv
	n = int(input())
	
	print((int(n/2) + n%2 )/n)

if __name__ == "__main__":
    main()
from math import sqrt
N = int(input())
A = sorted(list(map(int, input().split())))
m = 10**6
dp = [0]*10**6
ans = 0

for a in A:
    for i in range(1, m//a):
        dp[a*i] += 1
for a in A:
    if dp[a] == 1:
        ans += 1

print(ans)

### FIXED CODE ###

N = int(input())
A = sorted(list(map(int, input().split())))
m = A[-1]+1
dp = [0]*(m*2)
ans = 0

for a in A:
    for i in range(0, m//a+1):
        dp[a*i] += 1
for a in A:
    if dp[a] == 1:
        ans += 1

print(ans)
k = input()
output = "ACL" *k
print(output)

### FIXED CODE ###

n = int(input())

output = 'ACL'*n
print(output)
S=input()
T=input()
print(T+S)

### FIXED CODE ###

S,T = input().split()
print(T+S)
# ABC 137, c
from collections import Counter
import math
n = int(input())
d = []
for i in range(n):
    s = ''.join(sorted(input()))
    d.append(s)

C = Counter(d).most_common()
def comb(n, r):
    if n < r:
        return(0)
    f = math.factorial
    return (f(n) / f(r) / f(n-r))

count = 0
for key, value in C:
    count += comb(value, 2)
print(int(count))


### FIXED CODE ###

# ABC 137, c
n = int(input())
S = []
D = {}
count = 0
for i in range(n):
    s = ''.join(sorted(input()))
    if s in D:
        count += D[s]
        D[s] += 1
    else:
        D[s] =1
print(count)
import bisect
n,k = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
a.sort()
zero = bisect.bisect_left(a,0)
for i in range(zero):
    if cnt > -2*sum(a[0:zero])+sum(a[zero:n-zero]):
        cnt = -2*sum(a[0:zero])+sum(a[zero:n-zero])
    else:
        break
for i in range(zero):
    if cnt > -sum(a[0:zero])+2*sum(a[zero:n-zero]):
        cnt = -sum(a[0:zero])+2*sum(a[zero:n-zero])
    else:
        break
print(c)

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
c=10**10
for i in range(n-k+1):
    c=min(c,-a[i]+a[i+k-1]\
          +min(abs(a[i]),abs(a[i+k-1])))
print(c)
N=int(input())
a=[0]*(N-1)
b=[0]*(N-1)
c=[0]*(N-1)
d=[[] for _ in range(N)]
e=[ set() for _ in range(N)] #存在する色のリスト
maxi=0
for i in range(N-1):
    a[i],b[i] = map(int,input().split())
    d[a[i]-1].append(b[i]-1)
    d[b[i]-1].append(a[i]-1)
for j in d:
    maxi=max(maxi,len(j))
for i in range(N-1):
    pos=set([i+1 for i in range(maxi)])
    pos= pos- e[a[i]-1] -e[b[i]-1]
    col=min(pos)
    c[i]=col
    e[a[i]-1].add(col)
    e[b[i]-1].add(col)
   
print(maxi)
for color in c:
    print(color)


### FIXED CODE ###

from collections import deque

N=int(input())
a=[0]*(N-1)
b=[0]*(N-1)
c=[set() for _ in range(N)] # 使用している色
d=[set() for _ in range(N)] # 隣接リスト
e=[ False for _ in range(N)] #訪問ずみかどうか
f=[0]*N  #答え
for i in range(N-1):
    a[i],b[i] = map(int,input().split())
    d[a[i]-1].add(b[i]-1)
    d[b[i]-1].add(a[i]-1)

maxi=max([len(d[i]) for i in range(N-1)])
print(maxi)
#print("c:",c)
#print("d",d)
#print("e",e)

#x=0としてBFSする

v=deque([0])
e[0]=True
color=1

while v:
  p = v.popleft()
  for q in d[p]:
    if e[q]==False:
      while color in c[p]:
        color +=1
        if color>maxi:
          color=1
      c[p].add(color)
      c[q].add(color)
      f[q]=color
      e[q]=True
      v.append(q)
      
for i in range(N-1):
  print( f[b[i]-1])
N,M = int(input())
A = list(map(int, input().split()))

print(N-sum(A))

### FIXED CODE ###

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

if N-sum(A) < 0:
    print("-1")
else:
    print(N-sum(A))
S = input()
str_list = [*S]
even_str = str_list[0::2]
odd_str = str_list[1::2]
if ("L" in even_str):
  print("No")
elif ("R" in odd_str):
  print("No")
else:
  print("Yes")
  

### FIXED CODE ###

S = input()
str_list = list(S)
odd_str = str_list[0::2]
even_str = str_list[1::2]
if ('R' in even_str):
  print('No')
elif ('L' in odd_str):
  print('No')
else:
  print('Yes')
N,A,B = map(int,input().split())

Blue='b'*A
Red='r'*B
ans = ''
for i in range(1,N):
    ans = ans + Blue + Red
    if N <= len(ans):
        ans2=ans[:N]
        print(ans2.count('b'))
        break

### FIXED CODE ###

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

ans = N // (A+B) * A
rem = N % (A+B)
ans += min(rem,A)

print(ans)
m,*a = map(int,open(0).read().split())
am = []
ap = []
amap = am.append
apap = ap.append
for i in a:
  if i >= 0:
    apap(i)
  else:
    amap(i)
ans = []
ansap = ans.append
for _ in range(m-1):
  if ap == []:
    x = max(am)
    y = min(am)
    am.remove(x)
    am.remove(y)
    apap(x-y)
  elif am == []:
    x = min(ap)
    y = max(ap)
    ap.remove(x)
    ap.remove(y)
    amap(x-y)
  elif len(ap) > len(am):
    x = am.pop()
    y = ap.pop()
    amap(x-y)
  else:
    x = ap.pop()
    y = am.pop()
    apap(x-y)
  ansap(" ".join((str(x),str(y))))

print(ap[0])
print("\n".join(ans))

### FIXED CODE ###

n= int(input())
a = list(map(int,input().split()))
xy = []
xyap = xy.append
ap = max(a)
a.remove(ap)
am = min(a)
a.remove(am)
for i in a:
  if i>0:
    xyap((am,i))
    am -= i
  else:
    xyap((ap,i))
    ap -= i
xyap((ap,am))
print(ap-am)
for i in xy:
  print(*i)
def main():
    from math import gcd
    n, m = map(int, input().split())

    if gcd(n, m) == 1:
        print(1)
        exit()

    l = int(m / n)
    for i in range(l, 1, -1):
        p, q = divmod(m, i)
        if q != 0 or p < n:
            continue

        print(i)
        break


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n, m = map(int, input().split())
    for i in range(int(m / n), 0, -1):
        if m % i == 0:
            print(i)
            break


if __name__ == '__main__':
    main()
import itertools

def comb(a,b):
    if a<=0:
        return 0
    if b==1:
        return a
    elif b==2:
        return a*(a-1)//2
    else:
        return a*(a-1)*(a-2)//6

def tmp(L, K):
    ret=[]
    if K==1:
        bases=itertools.combinations(range(L+1),K)    
        for b in bases:
            ret+=[ k*10**b[0] for k in range(1,10)]
    if K==2:
        bases=itertools.combinations(range(L+1),K)
        kk=list(itertools.product(range(1,10),range(1,10)))
        for b in bases:
            ret+=[ k[0]*10**b[0] + k[1]*10**b[1] for k in kk]
    return ret

Nst=input()
K=int(input())
L=len(Nst)
N1=int(Nst[0])
N2=int(Nst[1])

if K==1:
    ans=comb( L-1, K) * 9 + N1
elif K>=2:
    ans=comb( L-1, K) * 9**(K) + comb( L-1, K-1) * 9**(K-1) *(N1-1)
    lst=[ 10**(L-1)*N1 + a for a in tmp(L-1, K-1)]
    ans+=sum([x <= int(Nst) for x in lst])
print (ans)

### FIXED CODE ###

import itertools

def comb(a,b):
    if a<=0:
        return 0
    if b==1:
        return a
    elif b==2:
        return a*(a-1)//2
    else:
        return a*(a-1)*(a-2)//6

def tmp(L, K):
    ret=[]
    if K==1:
        bases=itertools.combinations(range(L+1),K)    
        for b in bases:
            ret+=[ k*10**b[0] for k in range(1,10)]
    if K==2:
        bases=itertools.combinations(range(L+1),K)
        kk=list(itertools.product(range(1,10),range(1,10)))
        for b in bases:
            ret+=[ k[0]*10**b[0] + k[1]*10**b[1] for k in kk]
    return ret

Nst=input()
K=int(input())
L=len(Nst)
N1=int(Nst[0])

if K==1:
    ans=comb( L-1, K) * 9 + N1
elif K>=2:
    ans=comb( L-1, K) * 9**(K) + comb( L-1, K-1) * 9**(K-1) *(N1-1)
    lst=[ 10**(L-1)*N1 + a for a in tmp(L-1, K-1)]
    ans+=sum([x <= int(Nst) for x in lst])
print (ans)
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n,x,y = [int(i) for i in readline().split()]

ans = [0] * n

for a in range(1, n+1):
    for b in range(a+1, n+1):
        d = b - a
        d2 = abs(X-a) + abs(Y-b) + 1
        d = d if d < d2 else d2
        ans[d] += 1

for i in range(1, n):
    print(ans[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n,x,y = [int(i) for i in readline().split()]

ans = [0] * n

for a in range(1, n+1):
    for b in range(a+1, n+1):
        d = b - a
        d2 = abs(x-a) + abs(y-b) + 1
        d = d if d < d2 else d2
        ans[d] += 1

for i in range(1, n):
    print(ans[i])
s = input()
k = int(input())

notone = 101
for i, n in enumerate(s):
    if n != "1":
        notone = int(n)
        notonei = i
        break

if k < notonei:
    print(1)
else:
    print(notone)

### FIXED CODE ###

s = input()
k = int(input())

notone = 1
notonei = 101
for i, n in enumerate(s):
    if n != "1":
        notone = int(n)
        notonei = i
        break

if k <= notonei:
    print(1)
else:
    print(notone)
from sys import stdin

h,w,a,b = [int(x) for x in stdin.readline().rstrip().split()]

li = [[0 for _ in range(w)]for _ in range(h)]
if a > w//2 or b > h//2:
    print("No")
    exit()
elif h%a != 0 or w%b != 0:
    if a != 0 and b != 0:
        print("No")
        exit()
    else:
        if a == 0:
            a = 1
        elif b == 0:
            b = 1
        count = 0
        for i in range(h):
            for s in range(a):
                li[i][s+a*count] = 1
            count += 1
            count = count%(h//a)
        for p in range(h):
            print(''.join(map(str, li[p])))
elif w%h != 0 and h%w != 0:
    print("No")
    exit()
else:
    count = 0
    for i in range(h):
        for s in range(a):
            li[i][s+a*count] = 1
        count += 1
        count = count%(h//a)
    li2 = [li[q][0] for q in range(h)]
    if li2.count(0) == b or li2.count(1) == b:
        for p in range(h):
            print(''.join(map(str, li[p])))
    else:
        print("No")

### FIXED CODE ###

from sys import stdin
h,w,b,a = map(int,stdin.readline().rstrip().split())
li = []
for i in range(a):
    s = "0"*b+"1"*(w-b)
    li.append(s)
for j in range(h-a):
    s = "1"*b+"0"*(w-b)
    li.append(s)
for i in li:
    print(i)
def fibonacci(n):
    if n == 0 or n == 1:
         F[n] = 1
        return F[n]
    if F[n] is not None:
        return F[n]
    F[n] = fibonacci(n - 1) + fibonacci(n - 2)
    return F[n]


n = int(input())
F = [None] * n
print(fibonacci(n))

### FIXED CODE ###

def fibonacci(n):
    if n == 0 or n == 1:
        F[n] = 1
        return F[n]
    if F[n] is not None:
        return F[n]
    F[n] = fibonacci(n - 1) + fibonacci(n - 2)
    return F[n]


n = int(input())
F = [None]*(n + 1)
print(fibonacci(n))
_in = list(map(int, input().split()))
k = _in[0]
n = _in[1]
p = 0
_i = list(map(int, input().split()))
dis = 0
mdis = k - _i[n-1] + _i[0]
for i in range(1,n-2):
    dis = _i[i+1]- _i[i]
    if dis>=mdis:
        mdis = dis
print(k-mdis)

### FIXED CODE ###

s = str(input())
if s[2]==s[3] and s[4]==s[5]:
    print("Yes")
else:
    print("No")
N, Q = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(N-1)]
process = [list(map(int, input().split())) for _ in range(Q)]

graph = [[] for _ in range(N+1)]

for edge in edges:
    graph[edge[0]].append(edge[1])

count = [0] * (N+1)

def dfs(p,x):
    count[p] += x
    for i in graph[p]:
        dfs(i,x)

for i in process:
    dfs(i[0], i[1])

del count[0]

print(' '.join(map(str, count)))

### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]

n,q = map(int, input().split())
#長さn個のリストを入れ子にしたリストの作成：adj
adj = [[] for i in range(n)]

#adjに繋がっている要素を上流下流関わらず全て加える。
for j in range(n-1):
    a,b=map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1) 

#加算する値を合計したリストの作成
queries = [0 for i in range(n)]
for j in range(q):
    p, x = map(int, input().split())
    queries[p-1] += x

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

#aの値，直前の値，直前のaの値
st = [(0, 0, -1)] 

#つながってる奴の一番後ろから処理していく。
#０スタート→1,2繋がってるなら2にいく。2に3が繋がってるなら次は3。
#3に繋がってるのがなければ1に戻る。
#この際，aの直前の値をタプルで保持したままリストに挿入して保管しておく。
while st:
    #stの先頭を取り出す。初期値は末尾のため-1
    l = st.pop()  
    ans[l[0]] = l[1] + queries[l[0]]
    for v in adj[l[0]]:
        if v != l[2]:
            st.append((v, ans[l[0]], l[0]))

print(*ans)
import math
N = int(input())
for i in range(1, N+1):
    ans = 0
    for x in range(1, math.sqrt(i)):
        for y in range(1, math.sqrt(i)):
            for z in range(1, math.sqrt(i)):
                tmp = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if tmp == i:
                    ans += 1
    print(ans)

### FIXED CODE ###

N = int(input())

ans = [0 for _ in range(10**4+50)]

for x in range(1, 105):
    for y in range(1, 105):
        for z in range(1, 105):
            tmp = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if tmp < 10**4+50:
                ans[tmp] += 1

for i in range(1, N+1):
    print(ans[i])
N = int(input())
s = str(input())
t = str(input())

word = s + t

for i in range(N):
    if word[len(s) - 1] == word[len(s)] and :
        s = s[:N - 1]
        word = s + t
    
print(len(word))
    


### FIXED CODE ###

import sys
N = int(input())
s = str(input())
t = str(input())

answer = 2 * N
for i in range(N, 2 * N + 1):
    if s[len(s) - (2 * N - i):] == t[:2 * N - i]:
        answer = i
        break
    
print(answer)
0 0 1 2

### FIXED CODE ###

sx, sy, tx, ty = map(int, input().split())

ans = ''
if sx <= tx and sy <= ty:
    ans += 'R'*abs(sx-tx) + 'U'*abs(sy-ty) + 'L'*abs(sx-tx) + 'D'*abs(sy-ty)
    ans += 'L' + 'U'*(abs(ty-sy)+1) + 'R'*(abs(tx-sx)+1) + 'D'
    ans += 'R' + 'D'*(abs(ty-sy)+1) + 'L'*(abs(tx-sx)+1) + 'U'
    print(ans)
elif sx > tx and sy <= ty:
    ans += 'L'*abs(sx-tx) + 'U'*abs(sy-ty) + 'R'*abs(sx-tx) + 'D'*abs(sy-ty)
    ans += 'R' + 'U'*(abs(ty-sy)+1) + 'L'*(abs(tx-sx)+1) + 'D'
    ans += 'L' + 'D'*(abs(ty-sy)+1) + 'R'*(abs(tx-sx)+1) + 'U'
    print(ans)
elif sx > tx and sy > ty:
    ans += 'L'*abs(sx-tx) + 'D'*abs(sy-ty) + 'R'*abs(sx-tx) + 'U'*abs(sy-ty)
    ans += 'R' + 'D'*(abs(ty-sy)+1) + 'L'*(abs(tx-sx)+1) + 'U'
    ans += 'L' + 'U'*(abs(ty-sy)+1) + 'R'*(abs(tx-sx)+1) + 'D'
    print(ans)
elif sx <= tx and sy > ty:
    ans += 'R'*abs(sx-tx) + 'D'*abs(sy-ty) + 'L'*abs(sx-tx) + 'U'*abs(sy-ty)
    ans += 'L' + 'D'*(abs(ty-sy)+1) + 'R'*(abs(tx-sx)+1) + 'U'
    ans += 'R' + 'U'*(abs(ty-sy)+1) + 'L'*(abs(tx-sx)+1) + 'D'
    print(ans)
n = int(input())
sum = 0
for i in range(n):
  l, r = map(int, input().split())
  sum + = r-l+1
print(sum)

  

### FIXED CODE ###

n = int(input())
sum = 0
for i in range(n):
  l, r = map(int, input().split())
  sum += r-l+1
print(sum)
import numpy as np
h, w, m = map(int, input().split())
arr = np.zeros([h,w])
for _ in range(m):
    c_h, c_w = map(int, input().split())
    arr[c_h-1, c_w-1] = 1

### FIXED CODE ###

h, w, m = map(int, input().split())
h_cnt = [0 for i in range(h)]
w_cnt = [0 for i in range(w)]
bomb = set()

for i in range(m):
    _h, _w = map(int, input().split())
    h_cnt[_h-1] += 1
    w_cnt[_w-1] += 1
    bomb.add(((_h-1),(_w-1))) #爆破対象の位置を判断

h_max = max(h_cnt)
w_max = max(w_cnt)

max_h = []
max_w = []

for i in range(h):
    if h_cnt[i] == h_max:
        max_h.append(i)

for i in range(w):
    if w_cnt[i] == w_max:
        max_w.append(i)

flg = True

for i in max_h:
    for j in max_w:
        if (i,j) not in bomb:
            flg = False
            break
print(h_max+w_max-1 if flg else h_max+w_max)
from fractions import gcd
a,b,c,d = map(int,input().split())
l = (c*d) // fractions.gcd(c,d)
 
x = b//c - (a-1)//c
y = b//d - (a-1)//d
z = b//l - (a-1)//l
s = int(x+y-z)
 
print(b-a+1-s)

### FIXED CODE ###

s = ''
for i in input():
    if s == i:
        print("Bad")
        exit()
    s = i
print("Good")
a=input().split()
n=int(a[0])
d=int(a[1])


if n%(d*2+1)==0:
	print(int(n/(d*2+1)))
elif n%(d*2+1)!=0:
	print(int(n/(d*2+1))+1)


### FIXED CODE ###

r=int(input())
print(3*r*r)
N = int(input())
n = "three"

for i in (N):
  S = input().split()
  If S == Y:
    n = "four"
    break
print(n)
    

  

### FIXED CODE ###

N = int(input())
number = "Three"
S = input().split()

for i in range(N):
  if S[i] == "Y":
    number = "Four"
    break

print(number)
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
A, B, C, D = (int(a) for a in input().split())
a = B - A + 1
b = abs(B // C - (A - 1) // C)
c = abs(B // D - (A - 1) // D)
d = abs(B // (C * D) - (A - 1) // (lcm(C, D)))
print(a - (b + c - d))

### FIXED CODE ###

def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x
import math
A, B, C, D = (int(a) for a in input().split())
lcm = gcd(C, D)
a = B - A + 1
b = abs(B // C - (A - 1) // C)
c = abs(B // D - (A - 1) // D)
d = abs(B // ((C * D) // lcm) - (A - 1) // ((C * D) // lcm))
print(a - (b + c - d))
import sys
input = sys.stdin.readline
N = int(input())


node = [0 for i in range(N)]
neigh = [[] for j in range(N)]
ans = [0 for i in range(N)]
visited = [0 for i in range(N)]
k = 1

for i in range(N-1):
    ai,bi = map(int,input().split())
    node[ai-1] += 1
    node[bi-1] += 1
    neigh[ai-1].append(bi-1)
    neigh[bi-1].append(ai-1)
c = list(map(int,input().split()))
c.sort(reverse=True)
flag = False
def dfs(neighbor,start):
    global flag
    global k
    if sum(visited) == N:
        return 0

    for i in neighbor[start]:
        
        if visited[i] == 0:
            ans[i] = c[k]
            k += 1
            visited[i] = 1
            try:
                dfs(neighbor,i)
            except NotImplementedError:
                flag = True
                return 0




m = max(node)
nn = node.index(m)
#nn = [node[i] for i in range(N) if node[i] == m][0]
visited[nn] = 1
ans[nn] = max(c)
"""
if N == 9999:
    print(100)
    print(' '.join([str(i) for i in range(N)]))
    exit()
"""
dfs(neigh,nn)
if flag:
    print(100)
    print(' '.join([str(i) for i in range(N)]))
    exit()
ans2 = ' '.join([str(ans[i]) for i in range(N)])


print(sum(c)-max(c))
print(ans2)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
N = int(input())


node = [0 for i in range(N)]
neigh = [[] for j in range(N)]
ans = [0 for i in range(N)]
visited = [0 for i in range(N)]
k = 1

for i in range(N-1):
    ai,bi = map(int,input().split())
    node[ai-1] += 1
    node[bi-1] += 1
    neigh[ai-1].append(bi-1)
    neigh[bi-1].append(ai-1)
c = list(map(int,input().split()))
c.sort(reverse=True)
flag = False
def dfs(neighbor,start):
    global flag
    global k
    if sum(visited) == N:
        return 0

    for i in neighbor[start]:
        
        if visited[i] == 0:
            ans[i] = c[k]
            k += 1
            visited[i] = 1
            try:
                dfs(neighbor,i)
            except RuntimeError:
                flag = True
                return 0




m = max(node)
nn = node.index(m)
#nn = [node[i] for i in range(N) if node[i] == m][0]
visited[nn] = 1
ans[nn] = max(c)

dfs(neigh,nn)
"""
if flag:
    print(100)
    print(' '.join([str(i) for i in range(N)]))
    exit()
"""
ans2 = ' '.join([str(ans[i]) for i in range(N)])


print(sum(c)-max(c))
print(ans2)
t = list(input())
l = len(t)
if t[0] == "?":
    t[0] = "P"
for i in range(l):
    if t[i] == "?":
        if t[i-1] == "P":
            t[i] = "D"
            print(t[i],end="")
        elif t[i+1] == "P":
            t[i] = "D"
            print(t[i],end="")
        else:
            t[i] = "P"
            print(t[i],end="")
    else:
        print(t[i],end="")

### FIXED CODE ###

t = list(input())
l = len(t)

for i in range(l):
    if t[i] == "?":
        t[i] = "D"
        print(t[i],end="")
    else:
        print(t[i],end="")