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:
n=int(input())
ans=0
for i in range(n):
  r,l=(int(i) for i in input().split())
  ans+=l-r+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 = s + (b - a + 1)

print(s)

Submission status: Accepted

Solution code:
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
#73
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:
from sys import stdin
n = int(stdin.readline().rstrip())
data = [list(map(int, stdin.readline().rstrip().split())) for _ in range(n)]
print(sum([l[1]-l[0]+1 for l in data]))

Submission status: Accepted

Solution code:
cnt = 0

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc073/tasks/abc073_b

import itertools
import collections
import bisect

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

    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

answer = 0

for i in range(n):
    answer += r[i] - l[i] + 1

print(answer)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
n = S()
if "9" in n:
    print("Yes")
else:
    print("No")
"""
#B
n = I()
f = [0 for i in range(100002)]
for i in range(n):
    l,r = LI()
    f[l] += 1
    f[r+1] -= 1
ans = 0
for i in range(1,100001):
    f[i] += f[i-1]
    if f[i]:
        ans += 1
print(ans)
#C
"""
n = I()
d = defaultdict(int)
for i in range(n):
    a = I()
    d[a] ^= 1
d = list(d.values())
print(sum(d))
"""
#D
"""
def dfs(n,k,l,a):
    if n == 0:
        a.append(l)
    for i in range(n):
        dfs(n-1,k[:i]+k[i+1:],l+[k[i]],a)
n,m,R = LI()
r = LI()
f = [i for i in range(n)]
for i in range(R):
    r[i] -= 1
v = [[float("inf") for j in range(n)] for i in range(n)]
for i in range(n):
    v[i][i] = 0
for i in range(m):
    a,b,c = LI()
    a -= 1
    b -= 1
    v[a][b] = c
    v[b][a] = c
for k in range(n):
    for i in range(n):
        for j in range(n):
            v[i][j] = min(v[i][j],v[i][k]+v[k][j])
l = []
dfs(R,r,[],l)
ans = float("inf")
for k in l:
    d = 0
    for i in range(R-1):
        d += v[k[i]][k[i+1]]
    ans = min(ans,d)
print(ans)
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Accepted

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

for i in range(n):
    cnt += box[i][-1] - box[i][0] + 1

print(cnt)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
sl=[]
for i in range(N):
  sl.append(list(map(int,input().split())))
sl.sort()
sl_table = [True for i in range(len(sl))]

for i in range(N):
  for j in range(min(i+1,N),N):
    if sl[j][0]-sl[i][1]>0:
      break
    sl[i]=[min(min(sl[i]),min(sl[j])),max(max(sl[i]),max(sl[j]))]
    sl_table[j]=False

print(sum((s[1]-s[0]+1)*sl_table[i] for i,s in enumerate(sl)))

Submission status: Accepted

Solution code:
import sys

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

    return ans


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

Submission status: Accepted

Solution code:
ans=0
for i in range(int(input())):
    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(0,n):
  l,r=map(int,input().split())
  ans+=r-l+1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 073 B 
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:
n = int(input())
lr = []
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):
    a,b = map(int,input().split())
    ans += b-a+1

print(ans)

Submission status: Accepted

Solution code:
cnt = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def theater(N: int, queries: list)->int:
    return sum(r - l + 1 for l, r in queries)


if __name__ == "__main__":
    N = int(input())
    queries = [tuple(int(s) for s in input().split()) for _ in range(N)]
    ans = theater(N, queries)
    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:
n = int(input())
seats = [list(map(int, input().split())) for _ in range(n)]
count = 0
for l,r in seats:
    count += (r-l+1)
print(count)

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()) 
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:
N = int(input())
lrs = [ [ int(x) for x in input().split()] for _ in range(N) ]

ans = 0
for l, r in lrs:
    ans += (r - l + 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())

l = [list(map(int,input().split())) for i in range(n)]

c = 0

for i in range(n):
	c += (l[i][1] - l[i][0] +1)
print(c)

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())
L = [list(map(int, input().split())) for _ in range(N)]
print(sum([r - l + 1 for l, r in L]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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
for i in range(N):
  l,r=map(int,input().split())
  s+=r-l+1
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
e = [[int(i) for i in input().split()] for i in range(n)]

count = 0
for x in e:
    count += x[1]-x[0]+1
print(count)

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:
N = int(input())

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

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)


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:
ans = 0
n = int(input())
for i in range(n):
  a, b = map(int, input().split())
  ans += b - a + 1
print(ans)

Submission status: Accepted

Solution code:
"""AtCoder"""
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:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

s = 0
N = int(input())

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

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:
import numpy as np

INF=1e18
MOD=1e9+7

N=int(input())

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

print(ans)

Submission status: Accepted

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

ans = 0
for i in S:
    ans += i[1] - i[0] + 1

print( ans )

Submission status: Accepted

Solution code:
# coding: utf-8
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:
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 _ in range(n):
    l,r = map(int,input().split())
    ans += r-l+1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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:
N = int(input())
ans = 0
for i in range(0,N,1):
  l, r = map(int,input().split())
  ans += r-l+1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = []

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

print(sum(ans))

Submission status: Accepted

Solution code:

n=int(input())
cnt=0
for idx in range(n):
    st,en=map(int, input().split())
    cnt+= en-st+1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


N = int(input())

ans = 0

for _ in range(N):
    L,R = map(int,input().split())
    ans += R - L + 1


print("%d"%(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
list_l = []
list_r = []
ans = 0
for time in range(N) :
    A = [int(i) for i in input().split()]
    list_l.append(A[0])
    list_r.append(A[1])
    ans += list_r[time] - list_l[time] + 1
print(ans)

Submission status: Accepted

Solution code:
print(sum(1-eval(s.replace(' ','-'))for s in open(0).readlines()[1:]))

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

def swap(s,pos):
    s[pos]-=1
    s[pos+1]+=1
    print(s)
    if pos == n-2: return s
    if s[pos+2] == 0: swap(s,pos+1)
    return s


n = ip()                              #入力整数1つ
#h,w= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
s = 0
for i in range(n):
    x,y = (int(i) for i in input().split())
    s+=(y-x+1)
print(s)

Submission status: Accepted

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

ans = sum(r - l + 1 for l, r in lr)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
lr = set()
for i in range(N):
    l,r = map(int,input().split())
    for j in range(l,r+1):
        lr.add(j)
print(len(lr))

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][1] - l[i][0] +1
  
print(ans)

Submission status: Accepted

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

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())
a = []
ans=0
for i in range(n):
    a.append(list(map(int, input().split())))
for i in range(n):
    ans+=a[i][1]-a[i][0]+1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
abs_lst=[]
for i in range(int(input())):
    a,b=map(int,input().split())
    abs_lst.append(b-a+1)
print(sum(abs_lst))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
int_n = int(input())

counter = 0
for i in range(int_n):
    int_s, int_e = map(int, input().split())
    counter += (int_e - int_s + 1)

print(counter)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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())
L = [list(map(int, input().split())) for i in range(N)]

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    lr = []
    for i in range(n):
        l, r = map(int, input().split())
        lr.append((l, r))

    ans = 0
    for s in lr:
        l, r = s
        ans += (r - l) + 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# ABC 073
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
N = getInt()
count = 0
for i in range(N):
    r,l = getIntList()
    count += l-r+1
print(count)

Submission status: Accepted

Solution code:
ans = 0
n = int(input())
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 = [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:
n=int(input())
res=0
for i in range(n):
  l, r=map(int, input().split())
  res+=r-l+1
print(res)

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())
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())

cnt = []
for i in range(N):
    _l, _r = list(map(int, input().split()))
    cnt.append(_r - _l + 1)

print(sum(cnt))

Submission status: Accepted

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

Submission status: Accepted

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

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:
n = int(input())

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

count = 0
for a in ln:
  count += a[1] - a[0] + 1
  
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


abc073_b()

Submission status: Accepted

Solution code:
N = int(input())
sum=0
for i in range(N):
    a, b = map(int, input().split())

    sum += b-a+1

print(sum)

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:
#B Theather
a = int(input())
s = 0
for i in range(a):
    t1,t2 = map(int, input().split())
    s += t2 - t1 +1
print(s)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(N):
    t = input().split(" ")
    L = int(t[0])
    R = int(t[1])
    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:
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:
# -*- coding: utf-8 -*-


def main():
    """Function."""
    n = int(input())

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

    print(total)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())#读入，注意不加int()会RE
ans=0#ans为最终答案
for i in range (0,n):#[0,n)中有n个数，强迫症可以这么写:for i in range (1,n+1)即[1,n+1)即[1,n]
    s=input().split()#一行输入多组数据
    ans+=int(s[1])-int(s[0])+1#区间元素个数为(末项-首项+1)
print(ans)#print自带回车

Submission status: Accepted

Solution code:
n=int(input())
ans=0
while n>0:
    n-=1
    s=input().split()
    ans+=int(s[1])-int(s[0])+1
print(ans)

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

def solve(N, ls_ct):
    # Uncomment the following if you want to check the input.
    # print('N =', N)
    #print('ls_ct =', ls_ct)
    y = 0
    for i in ls_ct:
        y += abs((i[0]-i[1]))+1
    print(y)

def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ls_ct = [list(map(int, sys.stdin.readline().strip().split())) for j in range(N)]
    return (N, ls_ct)

def main():
    solve(*readQuestion())

# Uncomment before submission
main()

Submission status: Accepted

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

import sys

def solve(n, ls_lr):
    print(sum([r - l + 1 for (l,r) in ls_lr]))


def readQuestion():
    ws = sys.stdin.readline().strip().split()
    n = int(ws[0])
    ls_lr = [list(map(int, sys.stdin.readline().strip().split())) for j in range(n)]
    return (n, ls_lr,)

def main():
    solve(*readQuestion())

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum)

Submission status: Accepted

Solution code:
N = int(input())
lr = [[int(_) for _ in input().split()] for i in range(N)]

result = sum(r - l + 1 for l, r in lr)

print(result)

Submission status: Accepted

Solution code:
# coding: utf-8
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().strip().split(" "))
    Sum+=(r-l)+1


print(Sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for i in range(n):
	l,r=input().strip().split(' ')
	l,r=[int(l),int(r)]
	ans+=(r-l+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:
p = 0
for i in range(int(input())):
    l, r = map(int, input().split())
    p += r-l+1
print(p)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
num_list = []
ans = 0

for _ in range(n):
    num_list.append(list(map(int,input().split())))

for num in num_list:
    ans += abs(num[0]-num[1])+1
print(ans)

Submission status: Accepted

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

ans = 0
for l,r in src:
    ans += r-l+1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = []
for i in range(n):#h:高さ
    s.append([int(m) for m in input().split()])
count = 0
for j in range(n):
    count += s[j][1] - s[j][0] + 1
print(count)

Submission status: Accepted

Solution code:
n = int(input())
# lr=[[0,0] for i in range(n)]
num=0

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

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())
lr = [list(map(int,input().split())) for _ in range(n)]
ans=0
for lri in lr:
    ans += lri[1]-lri[0]+1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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())
l=0;k=0
count=0
for i in range(n):
    l,k=map(int,input().split())
    count+=k-l+1
    
print(count)

Submission status: Accepted

Solution code:
N = int(input())

R = 0

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

print(R)

Submission status: Accepted

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

li = [list(map(int, input().split())) for i in range(times)]

for item in li:
        count += 1 + item[1] - item[0]

print(count)

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:
a = int(input())
b = [input().split() for i in range(a)]
c = 0

for i in range(a):
  c = c + int(b[i][1]) - int(b[i][0]) + 1
print(c)

Submission status: Accepted

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

sum = 0
for i in range(N):
    l, r = list(map(int, input().rstrip().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())
    ans += r - l + 1

print(ans)

Submission status: Accepted

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

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 _ in range(N):
    l, r = map(int, input().split())
    ans += (r-l) + 1
print(ans)