Problem:


Score : 200 points

Problem Statement

Joisino is working as a receptionist at a theater.

The theater has 100000 seats, numbered from 1 to 100000.

According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).

How many people are sitting at the theater now?

Constraints

1≤N≤1000

1≤l_i≤r_i≤100000

No seat is occupied by more than one person.

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
l_1 r_1
:
l_N r_N

Output

Print the number of people sitting at the theater.

Sample Input 1

1
24 30

Sample Output 1

7

There are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.

Sample Input 2

2
6 8
3 3

Sample Output 2

4



Sample input:
1
24 30


Sample output:
7

Submission status: Accepted

Solution code:
a = int(input())
b = []

for i in range(a):
  c = list(map(int,input().split()))
  b.append(c[1]-c[0]+1)
else:
  print(sum(b))

Submission status: Accepted

Solution code:
N = int(input())
box = [list(map(int, input().split())) for a in range(N)]

sum = 0
for i in range(N):
    sum += box[i][-1] - box[i][0] + 1
print((sum))

Submission status: Accepted

Solution code:
n = int(input())
d = [list(map(int,input().split())) for _ in range(n)]
print(sum([d[i][1]-d[i][0]+1 for i in range(n)]))

Submission status: Accepted

Solution code:
ans=0
n=int(input())
for _ in range(n):
    r,l=map(int,input().split())
    ans=ans+l-r+1
print(ans)

Submission status: Accepted

Solution code:
def print_ans(l,r,N):
  """print(sum(r)-sum(l)+N)
  Parameters
  --------------
  >>> print_ans([24],[30],1)
  7
  >>> print_ans([6,3],[8,3],2) 
  4
  """
  print(sum(r)-sum(l)+N)


  

def main():
  N = int(input())
  l = []
  r = []
  for i in range(N):
    s = list(map(int,input().split()))
    l.append(s[0])
    r.append(s[1])

  print_ans(l,r,N)


if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
print(sum([m[1]+1-m[0] for m in [list(map(int,input().split())) for i in range(int(input()))]]))

Submission status: Accepted

Solution code:
N = int(input())
x = 0
for i in range(N):
  l, r = map(int, input().split())
  x += r - l + 1
print(x)

Submission status: Accepted

Solution code:
N = int(input())
A= [list(map(int,input().split(" "))) for i in range(N)]
#print(A)
sum=0
for i in A:
    sum+=i[1]-i[0]+1
print(sum)

Submission status: Accepted

Solution code:
n = int(input())
count = 0

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

print(count)

Submission status: Accepted

Solution code:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
total = 0
for i in range(N):
    l, r = nl()
    total += r - l + 1
print(total)

Submission status: Accepted

Solution code:
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))


n = II()
lr = [LI() for _ in range(n)]
cnt = 0
for i in lr:
    cnt += (i[1] - i[0] + 1)
print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
nums=[]
for i in range(n):
    nums.append(list(map(int,input().split())))

#print(nums)
ans=[]
for j in nums:
    ans.append(j[1]-j[0]+1)

print(sum(ans))

Submission status: Accepted

Solution code:
# coding: utf-8
n = int(input())
ans = 0
for i in range(n):
    a, b = map(int, input().split())
    ans += b - a + 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
c=0
for i in range(n):
  a,b=map(int,input().split())
  c+=b-a+1
print(c)

Submission status: Accepted

Solution code:
n=int(input())
o=0
for i in range(n):
    l,r=map(int,input().split())
    o+=r-l+1
print(o)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

Submission status: Accepted

Solution code:
def abc():
    n = int(input())
    ans = 0
    for i in range(n):
        l, r = map(int, input().split())
        ans += r - l + 1
    print(ans)


abc()

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    ans = 0
    for _ in range(N):
        l, r = map(int, input().split())
        ans += r - l + 1
    print(ans)


main()

Submission status: Accepted

Solution code:
n = int(input())
input_list = []
for i in range(n) :
    a = [int(num) for num in input().split()]
    input_list.append(a)

count = 0
for i in input_list :
        count += (i[1]-i[0]+1)

print(count)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(N):
    l,r = map(int, input().split())
    ans += r - l + 1
print(ans)

Submission status: Accepted

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

print (ans)

Submission status: Accepted

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
#
# N, K = [int(sys.stdin.readline()) for _ in range(2)]
# X = np.array(list(map(int, sys.stdin.readline().split())))
#
# print(np.minimum(X, abs(X - K)).sum() * 2)

N = int(sys.stdin.readline())
L, R = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))
L = np.array(L)
R = np.array(R)
print(sum(R-L+1))

Submission status: Accepted

Solution code:
n = int(input())
li = [list(map(int,input().split())) for i in range(n)]
ans = 0
for i in range(n):
  ans += li[i][1] - li[i][0] +1
print(ans)

Submission status: Accepted

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
L, R = np.array(list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)])))

print((R - L + 1).sum())

Submission status: Accepted

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
data = []
for _ in range(N):
    data.append([int(x) for x in stdin.readline().rstrip().split()])

ans = 0
for i in data:
    ans += (i[1] - i[0] + 1)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for _ in range(n) :
        l = list(map(int, input().split()))
        ans += l[1] - l[0] + 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
l = []
for i in range(N):
    l.append(list(map(int, input().split())))

ans = 0

for i in range(N):
    ans += l[i][1]-l[i][0]+1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
lst = []
for i in range(n):
    lst.append(input().split())
ans = 0
for i in lst:
    l = i[1]
    r = i[0]
    ans += (int(l) - int(r) + 1) 

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

print(answer)

Submission status: Accepted

Solution code:
n=int(input())
d=[0]*n
for i in range(n):
  l,r=map(int,input().split())
  d[i]=r-l+1
print(sum(d))

Submission status: Accepted

Solution code:
n=int(input())
d=[0]*n
for i in range(n):
  l,r=map(int,input().split())
  d[i]=r-l+1
print(sum(d))

Submission status: Accepted

Solution code:
n=int(input())

g=0
for i in range(n):
    t=eval(input().replace(" ","-"))
    g+=1-t
print(g)

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
l,r = ([0]*n,[0]*n)
for i in range(n):
    l[i],r[i] = map(int,input().split())

cnt = 0
for j in range(n):
    cnt += r[j]-l[j]+1
print(cnt)

Submission status: Accepted

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N = int(input())

ans = 0
for i in range(N):
  a, b = mi()
  ans += b - a + 1
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, l: "List[int]", r: "List[int]"):
    ret = 0
    for i in range(N):
        ret += r[i] - l[i] + 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    l = [int()] * (N)  # type: "List[int]" 
    r = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        l[i] = int(next(tokens))
        r[i] = int(next(tokens))
    solve(N, l, r)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

n = int(input())
ans = 0

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

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    ans=0
    for _ in range(N):
        l, r = MI()
        ans += r - l + 1
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
seats = []
for i in range(0, 100000):
	seats.append(False)
for i in range(0, N):
	left, right = map(int, input().split())
	for j in range(left-1, right):
		seats[j] = True
cnt = 0
for i in range(0, 100000):
	if seats[i]: cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
seats = [input() for _ in range(n)]
sum = 0
for i in seats:
    l, r = map(int, i.split())
    sum += (r - l) + 1
print(sum)

Submission status: Accepted

Solution code:
print(sum(r - l + 1 for l, r in ((int(i) for i in input().split()) for _ in range(int(input())))))

Submission status: Accepted

Solution code:
N=int(input())
ans=0
for i in range(N):
    l,r=map(int,input().split())
    ans=ans+r-l+1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
tmp = 0
for i in range(N):
  l,r = map(int, input().split())
  tmp += r-l+1
print(tmp)

Submission status: Accepted

Solution code:
s=0
for _ in range(int(input())):
  a,b=map(int,input().split())
  s+=b-a+1
print(s)

Submission status: Accepted

Solution code:
N = int(input())
l = [0] * N
r = [0] * N
for i in range(N):
    l[i], r[i] = map(int, input().split())
    
cnt = 0
for i in range(N):
    cnt += r[i] - l[i] + 1
print(cnt)

Submission status: Accepted

Solution code:
N=int(input())
SUM=0
for i in range(N):
  l,r=map(int,input().split())
  SUM+=r-l+1
print(SUM)

Submission status: Accepted

Solution code:
n = int(input())
num = 0
for i in range(n):
  a, b = map(int,input().split())
  c = b-a+1
  num += c
print(num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
l=[]
r=[]
cnt=0
for i in range(n):
  l,r=map(int,input().split())
  if l!=r:
    cnt+=max(l,r)-min(l,r)+1
  else: cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, l: "List[int]", r: "List[int]"):
    ans = 0
    for _l, _r in zip(l, r):
        ans += _r - _l + 1
    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    l = [int()] * (N)  # type: "List[int]"
    r = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        l[i] = int(next(tokens))
        r[i] = int(next(tokens))
    solve(N, l, r)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from functools import reduce
n = [reduce(lambda l, r: r - l + 1, \
     map(lambda s: int(s), input().split())) for _ in range(int(input()))]
print(sum(n))

Submission status: Accepted

Solution code:
N=int(input())
s = [input().split() for i in range(N)]
sum=0
for i in range(N):
    list=s[i]
    sum+=int(list[1])-int(list[0])+1
print(sum)

Submission status: Accepted

Solution code:
N = (int(input()))

total = 0
for i in range(N):
    l,r = (int(i) for i in input().split())
    total += r-l+1

print(total)

Submission status: Accepted

Solution code:
N = int(input())
cnt = [0] * 100005
for i in range(N):
    l,r = map(int,input().split(" "))
    cnt[r+1] -= 1
    cnt[l] += 1
ans = 0
for i in range(100004):
    cnt[i+1] += cnt[i]
    if cnt[i] > 0:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
ans=0
for _ in range(N):
    l,r=map(int, input().split())
    ans+=r-l+1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
sum = 0
for i in range(n):
    l, r = map(int, input().split())
    sum += (r-l) + 1
print(sum)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for _ in range(N):
    l, r = map(int, input().split())
    for _ in range(l, r+1):
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = 0

for i in range(n):
	a, b = [ int(v) for v in input().split() ]
	s += b - a + 1
print(s)

Submission status: Accepted

Solution code:
n = int(input())
l=[]
r=[]
for i in range(n):
    l1,r1 = map(int,input().split())
    l.append(l1)
    r.append(r1)
sum = 0
for i in range(n):
    sum += r[i]-l[i]+1
print(sum)

Submission status: Accepted

Solution code:
N = int(input())
l = [list(map(int,input().split())) for i in range(N)]
sum = 0

for i in range(N):
    group = l[i]
    sum += (group[1] - group[0] + 1)
print(sum)

Submission status: Accepted

Solution code:

N = int(input())

ans = 0
for i in range(N):
    l,r = list(map(int,input().split(" ")))
    ans += abs(r-l)+1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
l = []
r = []
for i in range(N):
    temp_l, temp_r = input().split()
    l.append(int(temp_l))
    r.append(int(temp_r))
ans = 0
for i in range(N):
    ans += r[i] - l[i] + 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=[0]*n
r=[0]*n
for i in range(n):
  l[i],r[i]=map(int,input().split())
ans=0
for i in range(n):
  ans+=r[i]-l[i]+1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
g = 0
for _ in range(N):
    l,r = map(int,input().split())
    g += r-l+1
print(g)

Submission status: Accepted

Solution code:
n = int(input())
ret = 0
for i in range(n):
    item = list(map(int, input().split()))
    ret += item[1] - item[0] + 1

print(ret)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for _ in range(N):
    l, r = map(int, input().split())
    ans += r - l + 1

print(ans)

Submission status: Accepted

Solution code:
# 入力
N=int(input())

sm=0

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

# 出力
print(sm)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
lr_arr = [list(map(int, input().split())) for _ in range(n)]
for arr in lr_arr:
    ans += arr[1] - arr[0] + 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
lr = [list(map(int, input().split())) for _ in range(N)]
seats = 0
for seat in lr:
    seats += seat[1] - seat[0] + 1
print(seats)

Submission status: Accepted

Solution code:
N=int(input())
c=0
for i in range(N):
    l,n=map(int,input().split())
    m=n-l+1
    c+=m
print(c)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for i in range(n):
    ans+=~(eval(input().replace(' ','-')))+2
print(ans)

Submission status: Accepted

Solution code:
def ipt(N=0,switch=0):
    if N == 0:
        return list(map(int,input().split()))
    else:
        if switch==0:
            return [list(map(int,input().split())) for _ in range(N)]
        else:
            return [int(input()) for _ in range(N)]

N=int(input())
LR=ipt(N)
ans=0
for i in range(N):
    ans += LR[i][1] - LR[i][0] + 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=[0]*n
r=[0]*n
for i in range(n):
    l[i],r[i]=map(int, input().split())
print(sum(r[i]-l[i] for i in range(n))+n)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(n):
  l, r = [int(i) for i in input().split()]
  ans += r - l + 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for i in range(n):
    l=list(map(int,input().split()))
    ans+=l[1]-l[0]+1

print(ans)

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    ans = 0
    for i in range(N):
        l, r = list(map(int, input().split()))
        ans += (r-l+1)
    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
ans=0
for _ in range(int(input())):
	l,r=map(int,input().split())
	ans+=r-l+1
print(ans)

Submission status: Accepted

Solution code:
n = int(input()) 
l = [list(map(int, input().split())) for i in range(n)] 
print(sum([i[1]-i[0]+1 for i in l]))

Submission status: Accepted

Solution code:
n = int(input())
total = 0
for i in range(n):
  l, r = map(int,input().split())
  total += (r - l)  + 1
print(total)

Submission status: Accepted

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

print(count)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(N):
    l,r = map(int,input().split())
    ans += r - l + 1
print(ans)

Submission status: Accepted

Solution code:
a=0
for i in range(int(input())):
  b,c=map(int,input().split())
  a+=c-b+1
print(a)

Submission status: Accepted

Solution code:
n=int(input())
cnt=0
for i in range(n):
    l,r=map(int,input().split())
    cnt+=r-l+1
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N =int(input())
lr = [[int(i) for i in input().split()]for i in range(N)]
p = 0
for l,r in lr:
    p += r - l + 1
print(p)

Submission status: Accepted

Solution code:
print(sum(1-eval(input().replace(" ", "-"))
          for _ in range(int(input()))))

Submission status: Accepted

Solution code:
n=int(input())
List=list(list(map(int,input().split())) for i in range(n))
s=0
for i in range(n):
    s+=List[i][1]-List[i][0]+1
print(s)

Submission status: Accepted

Solution code:
n=int(input())
ans=[]
for i in range(n):
    l,r=map(int,input().split())
    x=r-l+1
    ans.append(x)

print(sum(ans))

Submission status: Accepted

Solution code:
n = int(input())
num = 0

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

print(num)

Submission status: Accepted

Solution code:


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

Submission status: Accepted

Solution code:
def read_input():
    n = int(input())

    sheets = []
    for i in range(n):
        l, r = map(int, input().split())
        sheets.append((l, r))

    return n, sheets

def submit():
    n, sheets = read_input()

    watcher = 0
    for sheet in sheets:
        watcher += sheet[1] - sheet[0] + 1

    print(watcher)


if __name__ == '__main__':
    submit()

Submission status: Accepted

Solution code:
N = int(input())
def a(x):
    x = list(map(int,x.split(" ")))
    return x[1]-x[0]+1
print(sum(map(a,[input() for x in range(N)])))

Submission status: Accepted

Solution code:
N=int(input())
all_sum=0
for _ in range(N):
    l,r=map(int,input().split())
    all_sum += (r-l+1)
print(all_sum)

Submission status: Accepted

Solution code:
# ABC073B - Theater
n = int(input())
lst = [list(map(int, input().rstrip().split())) for _ in range(n)]
total = 0
for i in lst:
    total += i[1] - i[0] + 1
print(total)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for _ in range(N):
  i = [int(x) for x in input().split()]
  ans+=i[1]-i[0]+1
print(ans)

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    ans = 0
    for i in range(n):
        a,b = f()
        ans += b- a+1
    
    print(ans)

solve()

Submission status: Accepted

Solution code:
N = int(input())
L = []
R = []
for i in range(N):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)
print(sum(R)-sum(L)+N)

Submission status: Accepted

Solution code:
N = int(input())
LR = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for i in range(N):
    ans += LR[i][1] - LR[i][0] + 1

print(ans)

Submission status: Accepted

Solution code:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    l = []
    r = []
    ans = 0
    for i in range(N):
        s1,s2 = (int(_) for _ in input().split())
        ans += s2 - s1 +1

    
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(N):
  A, B = map(int, input().split())
  ans += B - A +1
  
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
C = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for c in C:
    ans += c[1]- c[0] + 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(N):
    [l,r] = list(map(int,input().split()))
    ans += r-l+1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
lr = [list(map(int, input().split())) for _ in range(N)]
s = 0
for i in range(N):
  s += lr[i][1] - lr[i][0] + 1
print(s)

Submission status: Accepted

Solution code:
N = int(input())
x = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N):
	ans += x[i][1] - x[i][0] + 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=0
for i in range(n):
    a,b=map(int,input().split())
    s+=b-a+1
print(s)

Submission status: Accepted

Solution code:
n = int(input())
l, r = map(list, zip(*(map(int, input().split()) for i in range(n))))

print(sum(r_i - l_i + 1 for l_i, r_i in zip(l, r)))

Submission status: Accepted

Solution code:
# -*- coding utf-8 -*-
n=int(input())
ans=0
for i in range(n):
    l,r=map(int,input().split())
    if l==r:
        ans+=1
    else:
      ans= ans+r-l+1
      
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
seat = []
seats_occ = 0
for i in range(N):
    x = list(map(int,input().split()))
    seat.append(x)
    
for i in range(N):
    seats_occ += (seat[i][1] - seat[i][0]) + 1
    
print(seats_occ)

Submission status: Accepted

Solution code:
n=int(input())
cnt=0
for i in range(n):
    a,b=map(int,input().split())
    cnt+=b-a+1
print(cnt)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
sum=0
for i in range(n):
  l,r = [int(j) for j in input().split()]
  sum+=r-l+1
print(sum)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for i in range(n):
	x,y=[int(k) for k in input().split()]
	ans+=y-x
print(ans+n)

Submission status: Accepted

Solution code:
N  = int(input())
a = 0
for i in range(N):
    l, r = map(int, input().split())
    a += r - l + 1
print(a)

Submission status: Accepted

Solution code:
#ABC073B
N  = int(input())
ans = 0
for i in range(N):
    l, r = map(int, input().split())
    ans += r + 1 - l
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=[0]*100000
for i in range(n):
    a,b=map(int,input().split())
    for j in range(a,b+1):
        s[j-1]=1
print(sum(s))

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(N):
    l, r = map(int, input().split())
    ans += (r - l) + 1
print(ans)

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import numpy as np
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import math


N = int(input())
groups = []
for i in range(N):
    l,r = map(int,input().split())
    groups.append([l,r])

cnt = 0
for i in range(N):
    cnt += groups[i][1]-groups[i][0]+1

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
LR = [tuple(map(int, input().split())) for _ in range(N)]

count = 0
for l, r in LR:
	count += (r - l + 1)
print(count)

Submission status: Accepted

Solution code:
N=int(input())
list_n=[]
for i in range(100001):
    list_n.append(False)
for i in range(N):
    l,r = map(int,input().split())
    for j in range(l-1,r):
        list_n[j]=True
        
ans=0
for i in range(100000):
    if(list_n[i]):
        ans+=1
        
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for i in range(n):
  n,m=map(int,input().split())
  ans+=(m-n+1)
print(ans)

Submission status: Accepted

Solution code:
#coding: utf-8
N = int(input())
ans = 0
for i in range(N):
    l, r = map(int, input().split())
    ans += r - l + 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
num = 0
count = 0
while num < N:
    l = list(map(int, input().split()))
    count += (l[1] - l[0] + 1)
    num += 1
print(count)

Submission status: Accepted

Solution code:
N =int(input())
lr = [[int(i) for i in input().split()]for i in range(N)]
p = 0
for l,r in lr:
    p += r - l + 1
print(p)

Submission status: Accepted

Solution code:
n = int(input())
lr = [list(map(int, input().split())) for i in range(n)]
ninzu = 0
for i in lr:
	ninzu += i[1]-i[0]+1
print(ninzu)

Submission status: Accepted

Solution code:
n = int(input())
res = 0
for i in range(n):
    a,b = map(int,input().split())
    res += b-a+1
print(res)

Submission status: Accepted

Solution code:
n = int(input());print(sum(list(map(lambda x:(x[1]-x[0]+1), [list(map(int, input().split())) for _ in range(n)]))))

Submission status: Accepted

Solution code:
N = int(input())
li = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for i in range(N):
    ans += li[i][1] - li[i][0] + 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
seats = [0 for i in range(100001)]
for i in range(N):
    l, r = map(int, input().split())
    for j in range(l, r+1):
        seats[j] = 1
print(sum(seats))

Submission status: Accepted

Solution code:
n = int(input())

num = 0
for i in range(n):
    l, r = [int(n) for n in input().split()]
    num += (r - l + 1)

print(num)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(n):
    l, r = [int(item) for item in input().split()]
    ans += r - l + 1
print(ans)

Submission status: Accepted

Solution code:
import sys
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())

n = ni()
ans = 0
for i in range(n):
    l, r = nm()
    ans += r - l + 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n):
  ans=ans-l[i][0]+l[i][1]+1
print(ans)

Submission status: Accepted

Solution code:
N=  int(input())

res = 0
for i in range(0,N):
    l,r = map(int,input().split())
    res += r - l + 1

print(res)

Submission status: Accepted

Solution code:
N=int(input())
lr=[list(map(int, input().split())) for i in range(N)]
print(sum(list(zip(*lr))[1])-sum(list(zip(*lr))[0])+N)

Submission status: Accepted

Solution code:
_,*t=open(0);print(sum(1-eval(s.replace(' ','-'))for s in t))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
res = 0
for i in range(N):
  a,b=map(int,input().split())
  res += b-a+1
print(res)

Submission status: Accepted

Solution code:
n=int(input())
lr=[[int(i) for i in input().split()] for _ in range(n)]
persona=0
for i in range(n):
    persona+=lr[i][1]-lr[i][0]+1
print(persona)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(N):
    l, r = map(int, input().split())
    ans += r - l
print(ans + N)

Submission status: Accepted

Solution code:
n = int(raw_input())
count = 0
for i in range(n):
	l = map(int, raw_input().split())
	count += (l[1] - l[0] + 1)
print count

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)