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: Runtime Error

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

ans = 0

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

Submission status: Runtime Error

Solution code:

def theather():
  total = 0
  try:
    N = int(input())
    l_r = (list(map(lambda x: int(x), input().split(' '))) for _ in range(N))
  except:
    return
  if not (1 <= N and N <= 1000): return
  for l, r in l_r:
    if 1 <= l and l <= 100000 or 1 <= r and r <= 100000:
      total += r - l + 1
    else:
      return
  print(total)

if __name__ == "__main__":
  theater()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
ans = N
for i in range(N):
    a,b = map(int,input())
    ans += b - a
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    ans=0
    for i n range(n):
        l,r=INTM()
        ans+=r-l+1
    print(ans)
if __name__ == '__main__':
    do()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
sum=0
for i range(N):

Submission status: Runtime Error

Solution code:
N=int(input())
sum=0
for i range(N):
  l, r =map(int, input().split())

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
sum=0
for i range(N):
  l, r =map(int,input().split())

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
lst = [[int(j) for j in i] for i in sys.stdin.readlines()]n = int(input())
lst = [[int(i) for i in input().split()] for _ in range(n)]
p = 0
for i in lst:
  p += i[1] - i[0] + 1
print(p)

Submission status: Runtime Error

Solution code:

import sys

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

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

for i in range(n):
    a = list(input().split())
print(a)
l = [0]
r = [0]
for m in range(n):
    l.append(a[m])
    r.append(a[m+1])

print(l)
print(r)
for p in range(1,n+1):
    s += int(r[p])-int(l[p])+1

print(s)

Submission status: Runtime Error

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

for i in range(n):
    a = list(input().split())
"""
a = [input().split() for i in range(n)]
"""
print(a)
l = [0]
r = [0]
for m in range(n):
    l.append(a[m])
    r.append(a[m+1])

print(l)
print(r)
for p in range(1,n+1):
    s += int(r[p])-int(l[p])+1

print(s)

Submission status: Runtime Error

Solution code:
n = int(input())
s = 0
for i in range(n):
    a = list(input().split())

l = [0]
r = [0]
for m in range(n):
    l.append(a[m][0])
    r.append(a[m][1])

for p in range(1,n+1):
    s += int(r[p])-int(l[p])+1

print(s)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
N = int(input())

count = 0

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

Submission status: Runtime Error

Solution code:
N = int(input())

count = 0

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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: Runtime Error

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

number = 0

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

print(number)

Submission status: Runtime Error

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

print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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: Runtime Error

Solution code:
N=int(input())
res=0
for n in N:
  l,r=[int(x) for x in input().split()]
  res+=r-l+1
else:
  print(res)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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 = input()
  l = []
  r = []
  for i in range(N):
    s = list(map(int,input().split()))
    l.add(s[0])
    r.add(s[1])

  print_ans(l,r,N)


if __name__ == '__main__':
  main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
p gets.to_i.times.map{eval"-%d+%d+1"%gets.split}.inject :+

Submission status: Runtime Error

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: Runtime Error

Solution code:
# 075B
h,w = map(int, input().split())
ss = [list(map(str,str(input()))) for _ in range(h)]
# print(ss)
def count_bombs(ss,i,j):
    count=0
    if ss[i][j]=='#':
        return '#'
    for y in [-1,0,1]:
        for x in [-1,0,1]:
#             print(i+y, x+j, count)
            if 0<=i+y<h and 0<=j+x<w and ss[i+y][j+x]=='#':
                count+=1
    return str(count)

for i in range(h):
    for j in range(w):
        ss[i][j] = count_bombs(ss,i,j)
#         print('## ',i,j,ss[i][j])
for s in ss:
    print(''.join(s))

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())
a=[[0 if s=="." else "#" for s in list(input())] for i in range(h)]
for _ in range(h):
  for s in range(w):
    if a[_][s]=="#":
      try:
        a[_-1][s]+=1
      except:
        continue
      try:
        a[_+1][s]+=1
      except:
        continue
      try:
        a[_][s-1]+=1
      except:
        continue
      try:
        a[_][s+1]+=1
      except:
        continue
      try:
        a[_+1][s+1]+=1
      except:
        continue
      try:
        a[_+1][s-1]+=1
      except:
        continue
      try:
        a[_-1][s+1]+=1
      except:
        continue
      try:
        a[_-1][s-1]+=1
      except:
        continue
    print(a)
for s in range(h):
  print(a[s])

Submission status: Runtime Error

Solution code:
import collections
list = [0] * 100000
N = int(input())
for i in range(N):
    t = input().split(" ")
    L = int(t[0])
    R = int(t[1])
    for j in range(L-1,R):
        list[j] = 1
CC = collections.Counter(list)
print(CC.most_common()[1][1])

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64

int main(){
    int n;
    cin >> n;
    llong ans=0;
    int l,r;
    REP(i,n){
        cin >> l >> r;
        ans+=r-l+1;
    }
    cout << ans << endl;

}

Submission status: Runtime Error

Solution code:
a = int(input())
b = [input().split() for i in range(a)]
c = 0

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())

ans=0

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

print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())

ans=0

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

print(ans)

Submission status: Runtime Error

Solution code:
# input
N = int(input())
L = [list(map(int, input().split()))]

ans = 0

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

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a=raw_input()
for i in range(a):
	b=raw_input()
	c=raw_input()
	c=c-b
	c=c+1
	print c-b+1

Submission status: Runtime Error

Solution code:
a=input()
for i in range(a):
	b=input()
	c=input()
	print c-b+1

Submission status: Runtime Error

Solution code:
#include <cstdio>
#include <iostream>
#include <math.h>
using namespace std;

int main() {
  int N;
  int sum;
  int x, y;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> x >> y;
    sum += (y - x + 1);
  }
  cout << sum << endl;
  return 0;
}

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())

val = 0
for num in range(0,N):
    row = input().split()
    val = val + row[1] - row[0]

val = val - N
print(val)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = input()
a = [0] * 100000
for i in xrange(n):
	l, r = [int(x) for x in raw_input().split()]
	if l == r:
		a[l] = 1
		continue
	a[l:r + 1] = [1] * (r - l + 1)
print a.count(1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
ans = 0
N = int(input())
for i in range(N):
  r1, r2 = input().sprit()
  ans += int(r2) - int(r1) + 1
print(ans)

Submission status: Runtime Error

Solution code:
ans = 0
N = int(input())
for i in range(N):
  r1, r2 = input().sprit()
  ans += r2 - r1 + 1
print(ans)

Submission status: Runtime Error

Solution code:
ans = 0
for i in range(int(input())):
  r1, r2 = input().sprit()
  ans += r2 - r1 + 1
print(ans)

Submission status: Runtime Error

Solution code:
print(sum([(lambda x:b+1-a)(map(int,input().split())for _ in  int(input())]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=input()
now=0
for i in range(0,N):
    lr=(input()).split(' ')
    now=now+((int)(lr[1])-(int)(lr[0])+1)

print(now)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

def aaa(seat_list):
	return seat_list[len(seat_list)-1] - seat_list[0]+1

value = int(input())
people = 0
# while True:
# 	try:
# 		seat = input()
# 		if seat:
# 			string_seat = seat.split()
# 			seat_list = []
# 			seat_list = [int(x) for x in (string_seat)]
# 			people += aaa(seat_list)
# 	except EOFError:
# 		break
while True:
	seat = input()
	if seat:
		string_seat = seat.split()
		seat_list = []
		seat_list = [int(x) for x in (string_seat)]
		people += aaa(seat_list)
		print(people)
	else:
		break
print(people)

Submission status: Runtime Error

Solution code:
# coding:utf-8

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:


def aaa(seat_list):
	return seat_list[len(seat_list)-1] - seat_list[0]

value = int(input())

people = 0
while True:
	try:
		seat = input()
		if seat:
			string_seat = seat.split()
			seat_list = []
			seat_list = [int(x) for x in (string_seat)]
			people += aaa(seat_list)
		except EOFError:
		break
print(people)

Submission status: Runtime Error

Solution code:


def aaa(seat_list):
	return seat_list[len(seat_list)-1] - seat_list[0]

value = int(input())

people = 0
# while True:
# 	try:
# 		seat = input()
# 		seat_list.append(int(seat.split(" "))
# 	except EOFError:
# 		break
while True:
	seat = input()
	if seat:
		string_seat = seat.split()
		seat_list = []
		seat_list = [int(x) for x in (string_seat)]
		people += aaa(seat_list)
	else:
		break

print(people)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
l = [0]*100000
n = int(raw_input())
for x in xrange(n):
	a = map(int,raw_input().strip().split())
	for y in xrange(a[0],a[1]+1):
		l[y] = 1
ans = 0
for x in l:
	if x == 1:
		ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
p = 0
for _ in n:
  i,j = [int(k) for k in input().split()]
  p += j-i+1
print(p)

Submission status: Runtime Error

Solution code:
n = int(input())
p = 0
for _ in n:
  i,j = [int(i) for i in input().split()]
  p += j-i+1
print(p)