AtCoder Beginner Contest 073 - Theater

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
24 30

-----Sample Output-----
7

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

Difficulty: EASY

Starter code:

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


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


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


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


a = int(input())
b = [map(int, input().split()) for x in range(a)]
print(sum((B - A + 1 for (A, B) in b)))


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


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


N = int(input())
ppl = 0
for i in range(N):
	tmp = input().split(' ')
	ppl += int(tmp[1]) - int(tmp[0]) + 1
print(ppl)


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


n = int(input())
a = 0
for _ in [0] * n:
	(d, s) = map(int, input().split())
	a += s - d + 1
print(a)


print(sum((1 - eval(input().replace(' ', '-')) for i in range(int(input())))))


n = int(input())
c = 0
for i in range(n):
	(s, e) = map(int, input().split())
	c += e - s + 1
print(c)


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


n = int(input())
data = [input().split() for i in range(n)]
ans = 0
for i in range(n):
	ans += int(data[i][1]) - int(data[i][0]) + 1
print(ans)


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


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

def __starting_point():
	main()
__starting_point()


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


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


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


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


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


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


N = int(input())
s = 0
for i in range(N):
	(L, R) = map(int, input().split())
	s += R - L + 1
print(s)


N = int(input())
LR = [tuple(map(int, input().split())) for _ in range(N)]
print(sum((r - l + 1 for (l, r) in LR)))


C = [list(map(int, input().split())) for _ in range(int(input()))]
print(sum([c[1] - c[0] + 1 for c in C]))


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


(*N,) = map(int, open(0).read().split())
print(sum(N[::2]) - sum(N[1::2]))


print(sum([-eval(input().replace(' ', '-')) + 1 for _ in range(int(input()))]))


with open(0) as f:
	(N, *lr) = map(int, f.read().split())
print(sum(lr[1::2]) - sum(lr[::2]) + N)


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


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


n = int(input())
tmp = 0
num_person = []
for _ in range(n):
	(l, r) = map(int, input().split())
	tmp = r - l + 1
	num_person.append(tmp)
ans = 0
for i in num_person:
	ans += i
print(ans)


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


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


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


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


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


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


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


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


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


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


IS = lambda : int(input())
IA = lambda : [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]
ans = 0
for (l, r) in IM(IS()):
	ans += r - l + 1
print(ans)


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


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


a = 0
for i in range(int(input())):
	a -= eval(input().replace(' ', '-')) - 1
print(a)


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


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


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


n = int(input())
ans = 0
while n > 0:
	(a, b) = map(int, input().split())
	ans += b - a + 1
	n -= 1
print(ans)


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


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


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


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


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


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


(n, *s) = map(int, open(0).read().split())
print(sum((s[i + 1] - s[i] + 1 for i in range(0, n * 2, 2))))


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


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

def __starting_point():
	main()
__starting_point()


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


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


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


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


N = int(input())
a = 0
for _ in range(N):
	a = a + abs(eval(input().replace(' ', '-'))) + 1
print(a)


a = int(input())
x = ''
y = 0
for i in range(a):
	x = input().split()
	y += abs(int(x[0]) - int(x[1])) + 1
print(y)


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


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


n = int(input())
seat = [0] * (10 ** 5 + 1)
for i in range(n):
	(l, r) = list(map(int, input().split()))
	seat[l - 1] += 1
	seat[r] -= 1
for i in range(1, 10 ** 5):
	seat[i] += seat[i - 1]
res = 0
for i in range(10 ** 5):
	if seat[i] == 1:
		res += 1
print(res)


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


n = int(input())
l = [tuple(map(int, input().split())) for i in range(n)]
cnt = 0
for i in l:
	cnt += i[1] - i[0] + 1
print(cnt)


print(sum([1 + len(range(*list(map(int, input().split())))) for i in range(int(input()))]))


(N, *_LR) = map(int, open(0).read().split())
LR = list(zip(*[map(int, iter(_LR))] * 2))
ans = 0
for (l, r) in LR:
	ans += r - l + 1
print(ans)


print(sum([(lambda x: int(x[1]) + 1 - int(x[0]))(input().split()) for _ in [0] * int(input())]))


N = int(input())
n = 0
for i in range(N):
	(x1, y1) = [int(i) for i in input().split()]
	n += y1 - x1 + 1
print(n)


print(sum([1 - eval(input().replace(' ', '-')) for _ in [0] * int(input())]))


n = int(input())
flg = [0] * 100000
for _ in range(n):
	(l, r) = list(map(int, input().split()))
	for i in range(l, r + 1):
		flg[i - 1] = 1
print(flg.count(1))


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


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


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


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


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


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


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


N = int(input())
ct = 0
for _ in range(N):
	l = list(map(int, input().split()))
	ct += l[1] - l[0] + 1
print(ct)


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]))
print(c + a)


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


from typing import List

def answer(n: int, lrs: List[List[int]]) -> int:
	number_of_people_sitting = 0
	for lr in lrs:
		(l, r) = lr
		number_of_people_sitting += r - l + 1
	return number_of_people_sitting

def main():
	n = int(input())
	lrs = [map(int, input().split()) for _ in range(n)]
	print(answer(n, lrs))

def __starting_point():
	main()
__starting_point()


n = int(input())
s = 0
for _ in [0] * n:
	s -= eval(input().replace(' ', '-')) - 1
print(s)


ans = 0
for _ in range(int(input())):
	ans += eval('-' + input().replace(' ', '+')) + 1
print(ans)


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


N = int(input())
a = 0
for i in range(N):
	line = list(map(int, input().split()))
	a += line[-1] - line[0] + 1
print(a)


n = int(input())
a = n
for i in range(n):
	a -= eval(input().replace(' ', '-'))
print(a)


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


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


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


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


n = int(input())
p = 0
for i in range(n):
	(p1, p2) = map(int, input().split())
	p += p2 - p1 + 1
print(p)


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


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


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


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


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


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


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


N = int(input())
x = 0
for i in range(N):
	(s, g) = map(int, input().split())
	le = g - s + 1
	x += le
print(x)


n = int(input())
c = 0
for _ in range(n):
	(l, r) = [int(x) for x in input().split()]
	c += r - l + 1
print(c)


print(sum((s[1] - s[0] + 1 for s in [list(map(int, input().split())) for _ in range(int(input()))])))


(_, *l) = map(int, open(0).read().split())
print(sum((j - i + 1 for (i, j) in zip(l[::2], l[1::2]))))


def mapt(fn, *args):
	return tuple(map(fn, *args))

def Input():
	return mapt(int, input().split(' '))

def main():
	n = int(input())
	data = [Input() for _ in range(n)]
	ans = 0
	for (start, end) in data:
		for _ in range(start, end + 1):
			ans += 1
	print(ans)
main()


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)


import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce
rr = lambda : sys.stdin.readline().rstrip()
rs = lambda : sys.stdin.readline().split()
ri = lambda : int(sys.stdin.readline())
rm = lambda : list(map(int, sys.stdin.readline().split()))
rl = lambda : list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10 ** 9 + 7
n = ri()
li = np.zeros(200000)
for _ in range(n):
	(l, r) = rm()
	li[l:r + 1] = 1
print(int(sum(li)))


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


(x, *y) = map(int, open(0).read().split())
print(sum(y[1::2]) - sum(y[0::2]) + x)


print(sum(((lambda a, b: int(b) - int(a) + 1)(*input().split()) for _ in [0] * int(input()))))


import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):

	def assertIO(self, input, output):
		(stdout, stdin) = (sys.stdout, sys.stdin)
		(sys.stdout, sys.stdin) = (StringIO(), StringIO(input))
		resolve()
		sys.stdout.seek(0)
		out = sys.stdout.read()[:-1]
		(sys.stdout, sys.stdin) = (stdout, stdin)
		self.assertEqual(out, output)

	def test_入力例_1(self):
		input = '1\n24 30'
		output = '7'
		self.assertIO(input, output)

	def test_入力例_2(self):
		input = '2\n6 8\n3 3'
		output = '4'
		self.assertIO(input, output)

def resolve():
	N = int(input())
	LR = [list(map(int, input().split())) for _ in range(N)]
	ans = 0
	for lr in LR:
		(l, r) = lr
		ans += r - l + 1
	print(ans)

def __starting_point():
	resolve()
__starting_point()