Harryxun/stf_run huggingface dataset:
N, Q = [int(item) for item in input().split()]

tree_list = [input() for _ in range(1,N)]
tree_list_int = [[int(k) for k in i.split()] for i in tree_list]
query_list = [input() for _ in range(Q)]
query_list_int = [[int(k) for k in i.split()]  for i in query_list]

val_list = [0 for _ in range(N)]
node_index = [[] for _ in range(N)]
cumulated_sum_list = [0] * N

# make graph(relation)
for a, b in tree_list_int:
    node_index[a -1].append(b - 1) #親位置に子のindexを追加
    node_index[b -1].append(a - 1) #子位置に親のindexを追加

for index, val in query_list_int:
    val_list[index-1] += val #加算する値を親位置へ記載

def dfs(child_index, pairent_index):
    for child in node_index[child_index]: #とあるノード（再帰していく）の子ノードを線形探索

        if child != pairent_index: #子ノードが親ノードでないとき
            val_list[child] += val_list[child_index] #累積和の計算
            dfs(child, child_index) #再帰する。子にノード子を挿入。今回の子を親に

    return val_list

res = dfs(0, -1) #0はルート、-1は親を持っていない事

for i in res:
    print(i)

### FIXED CODE ###

N, Q = [int(item) for item in input().split()]

tree_list = [input().split() for j in range(1, N)]

query_list = [input().split() for k in range(Q)]
query_list_int = [[int(k) for k in i] for i in query_list]

val_list = [0 for _ in range(N)]

linked_node_list = [[] for _ in range(N)]

for a, b in tree_list:
    a, b = int(a)-1, int(b) -1
    linked_node_list[a].append(b)
    linked_node_list[b].append(a)


for index, val in query_list_int:
    val_list[index-1] += val

stack = [0]
parent = [0] * (N+1)

while True:
    v=stack.pop()
    for child in linked_node_list[v]:
        if child != parent[v]:
            parent[child] = v
            stack.append(child)
            val_list[child] += val_list[v]
    if not stack:
        break

print(*val_list)
inputs = [flaot(i) for i in input()]

print(max(inputs) - min(inputs))

### FIXED CODE ###

def get_input():
    while True:
        try:
            yield input()
        except EOFError:
            break

inputs = [float(i) for i in get_input()]

print(max(inputs) - min(inputs))
N = input()
A = list(input().split())
A = list(map(int,A))
A = sorted(A,reverse = True)
a = 0
b = 0
while len(A) != 0 :
  a += A.pop(0)
  b += A.pop(0)
print(a-b)

### FIXED CODE ###

N = input()
A = list(input().split())
A = list(map(int,A))
A = sorted(A,reverse = True)
a = 0
b = 0
try :
  while len(A) != 0 :
    a += A.pop(0)
    b += A.pop(0)
  print(a-b)
except IndexError :
  print(a-b)
N = int(input())
A = list(map(int, input().split()))
i=1
sum=A[0]
while A[0]<=10**18 and i<=N-1:
   sum*=A[i]
   i+=1
if sum>10**18:
   sum=-1
print(sum)

### FIXED CODE ###

a,b = map(int, input().split()) 
print(a*b)
s=list(str,input())
count = 0
for i in range(2):
    if s[i] == 1 :
        count +=1    
break
print(count())

### FIXED CODE ###

s=list(input())
count = 0
for i in range(3):
    if s[i] == '1':
        count = count + 1    
print(count)
def get_root(s):
    if s != root[s]:
        root[s] = get_root(root[s])
        return root[s]
    return s

def unite(s, t):
    root_s = get_root(s)
    root_t = get_root(t)
    if not root_s == root_t:
        if rank[s] == rank[t]:
            root[root_t] = root_s
            rank[root_s] += 1
        elif rank[s] > rank[t]:
            root[root_t] = root_s
        else:
            root[root_s] = root_t

def same(s, t):
    if get_root(s) == get_root(t):
        return True
    else:
        return False

n, m = map(int, input().split())
root = [i for i in range(n)]
rank = [1 for _ in range(n)]
size = [1 for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    if not same(a - 1, b - 1):
        unite(a - 1, b - 1)
x = [0] * n
ans = 0
for i in range(n):
    j = get_root(i)
    x[j] += 1
    ans = max(ans, x[j])
print(ans)

### FIXED CODE ###

"""
def get_root(s):
    if s != root[s]:
        root[s] = get_root(root[s])
        return root[s]
    return s

def unite(s, t):
    root_s = get_root(s)
    root_t = get_root(t)
    if not root_s == root_t:
        if rank[s] == rank[t]:
            root[root_t] = root_s
            rank[root_s] += 1
        elif rank[s] > rank[t]:
            root[root_t] = root_s
        else:
            root[root_s] = root_t

def same(s, t):
    if get_root(s) == get_root(t):
        return True
    else:
        return False

n, m = map(int, input().split())
root = [i for i in range(n)]
rank = [1 for _ in range(n)]
size = [1 for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    if not same(a - 1, b - 1):
        unite(a - 1, b - 1)
x = [0] * n
ans = 0
for i in range(n):
    j = get_root(i)
    x[j] += 1
    ans = max(ans, x[j])
print(ans)
"""

from collections import deque

def bfs(s):
    q = deque()
    q.append(s)
    visit[s] = 1
    cnt = 1
    while q:
        p = q.popleft()
        for j in G[p]:
            if visit[j] == 0:
                q.append(j)
                visit[j] = 1
                cnt += 1
    global ans
    ans = max(ans, cnt)
    return

n, m = map(int, input().split())
G = [[] for _ in range(n + 1)]
for _ in range(m):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
visit = [0] * (n + 1)
ans = 0
for i in range(1, n + 1):
    if visit[i] == 0:
        bfs(i)
print(ans)
S=input()
if (S==ABC):
  print("ARC")
else:
  print("ABC")

### FIXED CODE ###

S=input()
if (S=="ABC"):
  print("ARC")
else:
  print("ABC")
n=int(input())
a = [int(input()) for _ in range(n)]
position = a.index(2)
if position == False:
  print(str(-1))
  exit()
position = position + 1
for i in range(n+1): # 最高でもn+!回だけ探してやれば十分
  position = a.index(position) + 1
  if position==1:
    print(str(i+2))
    exit()
print(str(-1))

### FIXED CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
pos=0
for i in range(n+1):
  if a[pos] == 2:
    print(i+1)
    exit()
  pos = a[pos]-1
print(-1)
N, M = map(int,input().split())
X = sorted(list(map(int, input().split())))
if  M <= N:
    print(0)
else:
    L = []
    for i in range(M-1):
        L.append(X[i+1]-X[i])
L = sorted(L)
print(sum(L[:M-N]))

### FIXED CODE ###

N, M = map(int,input().split())
X = sorted(list(map(int, input().split())))
if  M <= N:
    print(0)
else:
    L = []
    for i in range(M-1):
        L.append(X[i+1]-X[i])
    L = sorted(L)
    print(sum(L[:M-N]))
N=int(input())
A=list(map(int,input().split()))

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

cogcd=[0 for i in range(N)]
allgcd=GCD(A[0],A[1])
cogcd[0]=A[1]
cogcd[1]=A[0]

for i in range(2,N):
  for j in range(i):
    cogcd[j]=GCD(cogcd[j],A[i])
  cogcd[i]=allgcd
  allgcd=GCD(allgcd,A[i])
print(max(cogcd))

### FIXED CODE ###

A,B,T=map(int,input().split())
print(int(T/A)*B)
n = int(input())
a = list(map(int, input().split()))

a.sort()
if a[0] == 1:
    if a[1] != 1:
        print(1)
    else:
        print(0)
else:
    cnt = 1
    b = []
    for i in range(n-1):
        if a[i] != a[i+1]:
            b.append([a[i], cnt])
            cnt = 1
        else:
            cnt += 1
    b.append([a[n-1], cnt])

    ret = 0
    d_lst = []
    for c in b:
        num, cnt = c
        for d in d_lst:
            if num % d == 0:
                break
        else:
            if cnt == 1:
                ret += 1
            d_lst.append(num)

    print(ret)


### FIXED CODE ###

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

a.sort()
if a[0] == 1:
    if len(a) == 1 or a[1] != 1:
        print(1)
    else:
        print(0)
else:
    a_max = a[-1]
    seive = [True for _ in range(a_max + 1)]
    a += [-1]
    ret = 0
    add = 1
    for i in range(n):
        if a[i] != a[i+1]:
            if seive[a[i]]:
                ret += add
                j = 2 * a[i]
                while j <= a_max:
                    seive[j] = False
                    j += a[i]
            add = 1
        else:
            add = 0
    print(ret)
N = input()

if N == 1:
    print("Hello World")
else:
    A, B = map(int, input().split())
    print(A + B)


### FIXED CODE ###

N = int(input())

if N == 1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A + B)
if __name__ == '__main__':

    n,k = map(int,input().split())
    A = [0]
    AA= list(map(int,input().split()))
    A = A + AA

    B = set()
    cnt = 0
    ind = 1
    startind = 0
    D = []
    while True:
        if A[ind] not in B:
            B.add(ind)
            D.append(ind)
            cnt += 1
            ind = A[ind]
        else:
            B.add(ind)
            D.append(ind)
            cnt += 1
            startind = A[ind]
            break

    C = set()
    ind = startind
    ANS = []
    while True:
        if A[ind] not in C:
            C.add(ind)
            ind = A[ind]
            ANS.append(ind)
        else:
            C.add(ind)
            ANS.append(A[ind])
            break

    if k > cnt:
        tmp = k - cnt
        tmp = tmp % (len(C))
        print(ANS[tmp-1])
    else:
        print(D[k])
    

### FIXED CODE ###

if __name__ == '__main__':

    n,k = map(int,input().split())
    A = [0]
    AA= list(map(int,input().split()))
    A = A + AA

    B = set()
    cnt = 0
    ind = 1
    startind = 0
    D = []
    while True:
        if A[ind] not in B:
            B.add(ind)
            D.append(ind)
            cnt += 1
            ind = A[ind]
        else:
            B.add(ind)
            D.append(ind)
            cnt += 1
            startind = A[ind]
            break

    C = set()
    ind = startind
    ANS = []
    while True:
        if A[ind] not in C:
            C.add(ind)
            ind = A[ind]
            ANS.append(ind)
        else:
            C.add(ind)
            ANS.append(A[ind])
            break

    if k >= cnt:
        tmp = k - cnt
        tmp = tmp % (len(C))
        print(ANS[tmp-1])
    else:
        print(D[k])
input_data = []
data = input()


memory="first"
i=0
k=0

#最後二つが同じなら削除
if data[-1]==data[-2]:
    k+=1
    data=data[:-2]

max_len=len(data)
while max_len!=i:
    if data[i] == memory:
        memory=data[i:i+2]
        print(memory)
        i+=2
    else:
        memory=data[i]
        i+=1        
    k+=1
    
print(k)

### FIXED CODE ###

input_data = []
data = input()


memory="first"
i=0
k=0

#最後二つが同じなら削除
if data[-1]==data[-2]:
    k+=1
    data=data[:-2]

max_len=len(data)
while max_len!=i:
    try:
        if data[i] != memory:
            memory=data[i]
            i+=1             
        else:
            memory=data[i:i+2]
            i+=2
    except:
        break
    k+=1
    
print(k)
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))

maxcost = -float('inf')
for pi in p:    # O(n^2)
    curr, costs = pi, [0]
    while pi != p[curr-1]:
        curr = p[curr-1]
        costs.append(costs[-1]+c[curr-1])
    loopsum = costs[-1]+c[pi-1]
    if loopsum > 0:
        maxcost = max(maxcost, loopsum*(k//len(costs))+max(costs[1:k % len(costs)+1]))
    else:
        maxcost = max(maxcost, max(costs[1:min(k, n)]))

print(maxcost)


### FIXED CODE ###

import numpy as np
 
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
 
cycles, check = [], [False]*n
for pi in p:
    if not check[pi-1]:
        curr, cycle = pi, []
        check[pi-1] = True
        while pi != p[curr-1]:
            check[curr-1] = True
            cycle.append(c[curr-1])
            curr = p[curr-1]
        check[curr-1] = True
        cycles.append(cycle + [c[curr-1]])
 
scores = []
for cycle in (np.array(cycle) for cycle in cycles):
    for i in range(cycle.size):
        cum = np.roll(cycle, i).cumsum()
        if cum[-1] > 0 and k > cycle.size:
            scores.append(cum[-1]*(k//cycle.size-1) + np.concatenate([cum, cum[:k % cycle.size]+cum[-1]]).max())
        else:
            scores.append(cum[:min(k, cum.size)].max())
print(max(scores))
n = int(input())
if n % 2 == 1:
  print(0)
else:
  first = 10
  count = 0
  while n >= first:
    count += n //first
    first = 5 *first
print(count)
  



  

### FIXED CODE ###

n = int(input())
if n % 2 == 1:
  print(0)
else:
  first = 10
  count = 0
  if n >= first:
    while n >= first:
      count += n //first
      first = 5 *first
  
  print(count)
S, T = [input() for _ in range(2)]

S = sorted(S)
T = sorted(T)
print(S,T)
flg = False
if len(S) < len(T):
  for i, s in enumerate(S):
    print(T[i], s)
    if T[i] <= s:
      #print("T>S")      
      flg = True
      
if len(S) == len(T):
  for i, s in enumerate(S):
    if T[i] < s[i]:
      #print("T>S")
      flg =True
    
if flg:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

s = input()
s_dash = sorted(s)
#print(s_dash)

t = input()
t_dash = sorted(t, reverse=True)
#print(t_dash)

if s_dash < t_dash:
  print('Yes')
else:
  print('No')
from numba import njit
import numpy as np
@njit
def main():
    n=int(input())
    p=list(map(int,input().split()))
    h=[min(i//n,n-i//n-1,i%n,n-i%n-1) for i in range(n**2)]
    h=np.array(h)
    stay=np.full(n**2,1)
    ans=0
    def func(x,c):
        # hを更新
        todo=[[x,c]]
        seen=set(())
        while todo:
            v,c=todo.pop()
            nvs=[v+n,v-n]
            if v%n<n-1:nvs.append(v+1)
            if v%n>0:nvs.append(v-1)
            for nv in nvs:
                if nv<0 or n**2<=nv:continue
                if nv in seen:continue
                if h[nv]>c:
                    h[nv]=c
                    todo.append([nv,c+stay[nv]])
                seen.add(nv)
    for x in p:
        c=h[x-1]
        ans+=c
        stay[x-1]=0
        func(x-1,c)
    print(ans)
    #for i in range(n):
    #    print(h[i*n:(i+1)*n])
if __name__=='__main__':
    main()

### FIXED CODE ###

from numba import njit
import numpy as np
@njit
def dfs(v,c,h,stay):
    # hを更新
    x,y=divmod(v,n)
    for dx,dy in ((0,1),(0,-1),(1,0),(-1,0)):
        nx,ny=x+dx,y+dy
        if 0<=nx<n and 0<=ny<n:
            nv=nx*n+ny
            if h[nv]>c:
                h[nv]=c
                dfs(nv,c+stay[nv],h,stay)

@njit
def main(n,p):
    h=[min(i//n,n-i//n-1,i%n,n-i%n-1) for i in range(n**2)]
    h=np.array(h)
    stay=np.full(n**2,1)
    ans=0

    for v in p:
        c=h[v]
        ans+=c
        stay[v]=0
        dfs(v,c,h,stay)
    print(ans)

    #for i in range(n):
    #    print(h[i*n:(i+1)*n])
if __name__=='__main__':
    n=int(input())
    p=np.array(list(map(int,input().split())),np.int32)
    p-=1
    main(n,p)
print(n // min([a,b,c,d,e]) + 5)


### FIXED CODE ###

import math

n, a, b, c, d, e = [int(input()) for _ in range(6)]
print(math.ceil(n / min([a,b,c,d,e])) + 4)
import sys
input = sys.stdin.readline().strip
a,b,c,d=map(int,input().split())
if b<c or d<a:
    print(0)
elif print(max(b,d)-min(a,c))


### FIXED CODE ###

import sys
input = sys.stdin.readline().strip
a,b,c,d=map(int,input().split())
if b<c or d<a:
    print(0)
else: print(min(b,d)-max(a,c))
k= input ()  
odd=1
even=0
for i in range(2,k+1) 
     if i%2==0:
        even+=1
     else:
           odd+=1
print(odd*even)

### FIXED CODE ###

import math

n = int( input())

print( math.ceil(n/2) * math.floor(n/2))
if __name__ == '__main__':
    a = input().spit()
    if a[0]%2 == 1 and a[1]%2 == 1:
        print("Yes")
    else:
        print("No")





### FIXED CODE ###

if __name__ == '__main__':
    a = input().split()
    if int(a[0])%2 == 1 and int(a[1])%2 == 1:
        print("Yes")
    else:
        print("No")
N,T = [int(i) for i in input()]
ans = LTE
for i in range(N):
  c1,c2 = [int(j) for j in input()]
  
  if c2 <= T:
    ans = c1
    
print(ans)

### FIXED CODE ###

N, T = [int(i) for i in input().split()]
ans = 1500
for i in range(N):
    c1, c2 = [int(j) for j in input().split()]

    if c2 <= T:
        ans = min(c1,ans)

if ans == 1500:
    ans = "TLE"
print(ans)
n, *a = map(int, read(0).open().split())
a2 = sorted(a)[:-2]
for i in range(n):
    if a[i]==a2[1]:
        print(a[0])
    else:
        print(a[1])

### FIXED CODE ###

n, *a = map(int, open(0).read().split())
a2 = sorted(a)[-2:]
for i in range(n):
    if a[i]==a2[1]:
        print(a2[0])
    else:
        print(a2[1])
st=input().split()
N=int(st[0]);A=int(st[1]);B=int(st[2])
print min(N*A,B)

### FIXED CODE ###

s=input().split()
N=int(s[0]);A=int(s[1]);B=int(s[2])
if (N*A<=B):
    print("{0}".format(N*A))
else:
    print("{0}".format(B))
# -*- coding: utf-8 -*-
def primeFactors(n):
    res = []
    while n%2==0:
        res.append(2)
        n //= 2
    x = 3
    while n>1 and n>=x*x:
        while n%x==0:
            res.append(x)
            n //= x
        x += 2
    if n>1:
        res.append(n)
    return res

class BiCoeff(object):
    def __init__(self, MAX, m):
        super(BiCoeff, self).__init__()
        fac = [0]*MAX
        finv = [0]*MAX
        inv = [0]*MAX

        fac[0] = 1
        fac[1] = 1
        finv[0] = 1
        finv[1] = 1
        inv[1] = 1
        for i in range(2,MAX):
            fac[i] = (fac[i-1]*i)%m
            inv[i] = m - (inv[m%i] * (m//i))%m
            finv[i] = (finv[i-1] * inv[i])%m

        self.MAX = MAX
        self.m = m
        self.fac = fac
        self.finv = finv
        self.inv = inv

    def calc(self,n,k):
        if n<k:
            return 0
        if n<0 or k<0:
            return 0
        return (self.fac[n] * (self.finv[k]*self.finv[n-k])%self.m)%self.m

from collections import defaultdict
MOD = 10**9 + 7
n,m = map(int, input().split())

bicoeff = BiCoeff(2*n,MOD)

d = defaultdict(int)
for p in primeFactors(m):
    d[p] += 1

res = 1
for v in d.values():
    res *= bicoeff.calc(n-1+v,n-1)
    res %= MOD
print(res)


### FIXED CODE ###

# -*- coding: utf-8 -*-
import unittest
import math

MOD = 10**9+7


def func(n,m):
    fac = [1 for _ in range(n+100)]
    finv = [1 for _ in range(n+100)]
    inv = [1 for _ in range(n+100)]
    for i in range(2,n+100):
        fac[i] = (fac[i-1]*i)%MOD
        inv[i] = (MOD - inv[MOD%i] * (MOD//i))%MOD
        finv[i] = (finv[i-1]*inv[i])%MOD

    def comb(a,b):
        return (fac[a]*((finv[b]*finv[a-b])%MOD))%MOD

    fact = {}
    for x in range(2, math.ceil(math.sqrt(m))+1):
        while m%x==0:
            if x not in fact:
                fact[x] = 0
            fact[x] += 1
            m = m//x
        if m==1:
            break
    if m!=1:
        fact[m] = 1

    ret = 1
    for k in fact.values():
        ret *= comb(k+n-1,k)
        ret %= MOD
    return ret

class Test(unittest.TestCase):
    def test(self):
        self.assertEqual(func(2,6), 4)
        self.assertEqual(func(3,12), 18)
        self.assertEqual(func(100000, 1000000000), 957870001)
        self.assertEqual(func(2,3), 2)

if __name__ == '__main__':
    n,m = map(int, input().split())
    print(func(n,m))
    # unittest.main()
def bfs(count, x, y, cheese):
    queue = [(count,x,y)]
    while len(queue)>0:
        tempc,tempx,tempy = queue.pop(0)
        if geo[tempx][tempy] == cheese:
            return tempc,tempx,tempy
        for i in range(4):
            neox = tempx+dx[i]
            neoy = tempy+dy[i]
            if canGoTo(neox,neoy):
                if (tempc+1,neox,neoy) not in queue:
                    queue.append((tempc+1,neox,neoy))

    return (-1,-1,-1)

def canGoTo(x,y):
    if 0<=x<H and 0<=y<W:
        return not visited[x][y]
    return False

dx = [0,1,0,-1]
dy = [-1,0,1,0]

data = input().split(' ')
H,W,N = map(int, data)

#maps
geo = [[None for i in range(W)] for j in range(H)]
visited = [[False for i in range(W)] for j in range(H)]

x,y=-1,-1
for i in range(H):
    line = input()
    for j in range(W):
        p = line[j:j+1]
        geo[i][j] = p
        if p == 'X':
            visited[i][j] = True
        elif p == 'S':
            x,y, = i,j
            
count = 0
for n in range(1,N+1):
    count,x,y = bfs(count,x,y,str(n))
print(count)

### FIXED CODE ###

import copy
from collections import deque
def bfs(count, x, y, cheese):
    q = deque()
    q.append((count,x,y))
    tempVisited = copy.deepcopy(visited)
    tempVisited[x][y] = True
    
    while len(q)>0:
        tempc,tempx,tempy = q.popleft()
        if geo[tempx][tempy] == cheese:
            return tempc,tempx,tempy
        for i in range(4):
            neox = tempx+dx[i]
            neoy = tempy+dy[i]
            if canGoTo(neox,neoy, tempVisited):
                if (tempc+1,neox,neoy) not in q:
                    q.append((tempc+1,neox,neoy))
                    tempVisited[neox][neoy]=True
    return (-1,-1,-1)

def canGoTo(x,y,tempVisited):
    if 0<=x<H and 0<=y<W:
        return not tempVisited[x][y]
    return False

dx = [0,1,0,-1]
dy = [-1,0,1,0]

data = input().split(' ')
H,W,N = map(int, data)

#maps
geo = [[None for i in range(W)] for j in range(H)]
visited = [[False for i in range(W)] for j in range(H)]

x,y=-1,-1
for i in range(H):
    line = input()
    for j in range(W):
        p = line[j:j+1]
        geo[i][j] = p
        if p == 'X':
            visited[i][j] = True
        elif p == 'S':
            x,y, = i,j
            
count = 0
for n in range(1,N+1):
    count,x,y = bfs(count,x,y,str(n))
print(count)
from sys import stdin
N = int(input())
S = input()
K = int(input())
def search():
  val = S[K]
  for x in range(1, N):
    if S[x] != val:
      S[x] = *
  return S
print(search())
		

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    n=int(input())
    s=list(input())
    k=int(input())
    val=s[k-1]
    for i in range(n):
        if s[i]!=val:
            s[i]='*'
    print(''.join(s))


resolve()
n=int(input())

ans=0

for i in range(N):
    l,r=map(int,input())
    ans+=r-l+1

print(ans)

### FIXED CODE ###

n=int(input())

ans=0

for i in range(n):
    l,r=map(int,input().split())
    ans+=r-l+1

print(ans)
import numpy as np

c = np.zeros(int(2e5))
c_1 = np.ones(int(2e5))

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

for i in range(n):
    c[a[i] - 1] += 1

ans = int(sum(c * (c - c_1) / 2))

for i in range(n):
    print(ans - int(c[a[i]-1]-1))

### FIXED CODE ###

import numpy as np

c = np.zeros(int(2e5))
c_1 = np.ones(int(2e5))

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

for i in range(n):
    c[a[i] - 1] += 1

ans = int(sum(c * (c - c_1) / 2))

for i in range(n):
    print(ans - int(c[a[i]-1]-1))
S = int(input()) 
h = int((S / 60) / 60) % 60
m = int(S / 60) % 60
s = int(S % 60)

print"{0}:{1}:{2}".format(h,m,s)

### FIXED CODE ###

S = int(input()) 
h = int((S / 60) / 60) % 60
m = int(S / 60) % 60
s = int(S % 60)

print("{0}:{1}:{2}".format(h,m,s))
# coding: utf-8
 
n, m, x, y = map(int, input().split())
xn = list(map(int, input().split()))
ym = list(map(int, input().split()))
 
if x < y:
    z = range(x, y+1)
    if max(xn) < z and min(ym)>=z:
        print("War")
    else:
        print("No War")
else:
    print("No War")

### FIXED CODE ###

# coding: utf-8
 
n, m, x, y = map(int, input().split())
xn = list(map(int, input().split()))
ym = list(map(int, input().split()))
xn.append(x)
ym.append(y)
flag = 0

if max(xn) < min(ym):
    print("No War")
else:
    print("War")
x, n = map(int, input().split())
p = list(map(int, input().split()))

if n == 0:
    print(x)
else:
    num = set(range(1, 101)) ^ set(p)
    num = sorted([[abs(i - x), i] for i in num])
    
    if len(num) >= 2 and num[0][0] == num[1][0]:
        print(min(num[0][1], num[1][1]))
    else:
        print(num[0][1])


### FIXED CODE ###

x, n = map(int, input().split())
p = list(map(int, input().split()))

if n == 0:
    print(x)
else:
    num = list(set(range(-200, 200)) ^ set(p))
    num = sorted([[abs(i - x), i] for i in num])
    if len(num) >= 2 and num[0][0] == num[1][0]:
        print(min(num[0][1], num[1][1]))
    else:
        print(num[0][1])
N = int(input())
W = list(map(int,input().split()))
ans = inf
for t in range(N):
    ans = min(ans,abs(sum(W[:t])-sum(W[t:])))

print(ans)


### FIXED CODE ###

from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N = int(input())
W = list(map(int,input().split()))
ans = inf
for t in range(N):
    ans = min(ans,abs(sum(W[:t])-sum(W[t:])))

print(ans)