The game of billiards involves two players knocking 3 balls around
on a green baize table. Well, there is more to it, but for our
purposes this is sufficient.
The game consists of several rounds and in each round both players
obtain a score, based on how well they played. Once all the rounds
have been played, the total score of each player is determined by
adding up the scores in all the rounds and the player with the higher
total score is declared the winner.
The Siruseri Sports Club organises an annual billiards game where
the top two players of Siruseri play against each other. The Manager
of Siruseri Sports Club decided to add his own twist to the game by
changing the rules for determining the winner. In his version, at the
end of each round, the cumulative score for each player is calculated, and the leader and her current lead are found. Once
all the rounds are over the player who had the maximum lead at the
end of any round in the game is declared the winner.

Consider the following score sheet for a game with 5 rounds:
RoundPlayer 1Player 2114082289134390110411210658890

The total scores of both players, the leader and the lead after
each round for this game is given below:RoundPlayer 1Player 2LeaderLead114082Player 1582229216Player 1133319326Player 274431432Player 215519522Player 23
Note that the above table contains the cumulative scores.
The winner of this game is Player 1 as he had the maximum lead (58
at the end of round 1) during the game.
Your task is to help the Manager find the winner and the winning
lead. You may assume that the scores will be such that there will
always be a single winner.  That is, there are no ties.
Input
The first line of the input will contain a single integer N (N
≤ 10000) indicating the number of rounds in the game.  Lines
2,3,...,N+1 describe the scores of the two players in the N rounds.
Line i+1 contains two integer Si and Ti, the scores of the Player 1
and 2 respectively, in round i.  You may assume that 1 ≤ Si ≤
1000 and 1 ≤ Ti ≤ 1000.  
Output
Your output must consist of a single line containing two integers
W and L, where W is 1 or 2 and indicates the winner and L is the
maximum lead attained by the winner.
Example
Input:
5
140 82
89 134
90 110
112 106
88 90

Output:
1 58

Difficulty: interview

Starter code:

Solutions:
s1=s2=lead=0
mlead1=mlead2=0
for _ in range(int(input())):
    x, y= list(map(int, input().split()))
    s1, s2= s1+x, s2+y
    if(s1>s2):
        lead=(s1-s2)
        mlead1= max(mlead1, lead)
    else:
        lead=(s2-s1)
        mlead2= max(mlead2, lead)
if(mlead1<(mlead2)):
    print('2', mlead2)
else:
    print('1', mlead1)



s1=s2=lead=0
mlead1=mlead2=0
for _ in range(int(input())):
    x, y= list(map(int, input().split()))
    s1, s2= s1+x, s2+y
    if(s1>s2):
        lead=(s1-s2)
        mlead1= max(mlead1, lead)
    else:
        lead=(s1-s2)
        mlead2= min(mlead2, lead)
if(mlead1<(-mlead2)):
    print('2', -mlead2)
else:
    print('1', mlead1)



s1=s2=lead=0
mlead1=mlead2=0
for _ in range(int(input())):
    x, y= list(map(int, input().split()))
    s1, s2= s1+x, s2+y
    if(s1>s2):
        lead=(s1-s2)
        mlead1= max(mlead1, lead)
    else:
        lead=(s1-s2)
        mlead2= min(mlead2, lead)
if(mlead1<(-mlead2)):
    print('2', -mlead2)
else:
    print('1', mlead1)



# cook your dish here
try:
    n1=int(input())
    wina=winb=ma=mb=n=m=0
    for i in range(n1):
        a,b=list(map(int,input().split()))
        n+=a
        m+=b
        if n>m and n-m>ma:
            ma=n-m
        elif n<m and m-n>mb:
            mb=m-n
    if ma>mb:
        print('1',ma)
    elif ma<mb:
        print('2',mb)
except:pass



n= int(input())
l=[]
x=0
y=0
for i in range(n):
    a,b= map(int,input().split())
    x=x+a
    y=y+b
    l.append(x-y)
q=abs(max(l))
w=abs(min(l))
if w>q:
    r=2 
    q=w
else:
    r=1 
r=[r,q]
for p in r:
    print(p,end=' ')

# cook your dish here
l=[]
m=[]
c=[]
s,k=0,0
for i in range(int(input())):
    a,b=map(int,input().split(" "))
    s=s+a
    k=k+b
    l.append(s)
    m.append(k)
for j in range(len(l)):
    c.append(abs(l[j]-m[j]))
if(l[c.index(max(c))]>m[c.index(max(c))]):
    print("1",end=" ")
else:
    print("2",end=" ")
print(max(c))

# cook your dish here
l=0
m=0
p1=[0]
p2=[0]
l1=[0]
l2=[0]
for i in range(int(input())):
    a,b=map(int,input().split())
    p1.append(a+l)
    p2.append(b+m)
    l=p1[-1]
    m=p2[-1]
for x,y in zip(p1,p2):
    d=x-y
    if(d>0):
        l1.append(d)
    if(d<0):
        l2.append(abs(d))
if(max(l1)>max(l2)):
    print(1,end=" ")
    print(max(l1))
else:
    print(2,end=" ")
    print(max(l2))


# cook your dish here
try:
    t=int(input())
    l1=[]
    l2=[]
    n1=0
    n2=0
    for i in range(t):
        x,y=list(map(int,input().split()))
        n1+=x
        n2+=y
        if n1>n2:
            l1.append(n1-n2)
            l2.append(0)
        else:
            l1.append(0)
            l2.append(n2-n1)
    m1=max(l1)
    m2=max(l2)
    if m1>m2:
        print(1,m1)
    else:
        print(2,m2)
except:pass


maxLead = 0
a_sum = 0
b_sum = 0
for _ in range (int(input())):
    a,b = map(int,input().split())
    a_sum += a 
    b_sum += b 
    if(a_sum>b_sum):
        lead = a_sum - b_sum 
        if lead>maxLead:
            maxLead = lead 
            w = 1 
    else:
        lead = b_sum - a_sum 
        if(lead > maxLead):
            maxLead = lead
            w = 2
print(w,maxLead)

val, A, B=0, 0, 0
for a in range(int(input())):
    c,d=input().split()
    A+=int(c)
    B+=int(d)
    b=abs(A-B)
    if b>val:
        val=b
        if int(c)>int(d):
            w=1
        else:
            w=2
print(w, val)

val=0
A=0
B=0
for a in range(int(input())):
    c,d=input().split()
    A+=int(c)
    B+=int(d)
    b=abs(A-B)
    if b>val:
        val=b
        if int(c)>int(d):
            w=1
        else:
            w=2
print(str(w)+' '+str(val))


# cook your dish here
rounds = input()
rounds = int(rounds)
lead = 0
s1 = 0
s2 = 0
for i in range(rounds):
    
    scores = input()
    scores = scores.split()
    s1 += int(scores[0])
    s2 += int(scores[1])
    if (s1 - s2 > lead ):
        leader = 1
        lead = s1 - s2
    elif (s2 - s1 > lead):
        leader = 2
        lead = s2 - s1
        
print(str(leader) + " " + str(lead))

n = int(input())
p1 = 0
p2 = 0
lead = 0
winner = 0
for i in range(n):
    player1,player2 = list(map(int,input().split()))
    p1+=player1
    p2+=player2
    if abs(p1-p2)>lead:
        lead = abs(p1-p2)
        if p2>p1:
            winner = 2 
        else:
            winner = 1
        
print(winner,lead)
    
    


t=int(input())
l1=[]
l2=[]
n1=0
n2=0
for i in range(t):
    x,y=list(map(int,input().split()))
    n1+=x
    n2+=y
    if n1>n2:
        l1.append(n1-n2)
        l2.append(0)
    else:
        l1.append(0)
        l2.append(n2-n1)
m1=max(l1)
m2=max(l2)
if m1>m2:
    print(1,m1)
else:
    print(2,m2)


# cook your dish here
t = int(input())
l1 = []
l2 =[]
p1 =0
p2 = 0
for _ in range(t):
    n,m= map(int,input().split())
    p1+=n
    p2+=m    
    if p1 > p2:
       l = p1-p2
       l1.append(l)
       l2.append(0)
    else:
        l = p2 -p1
        l1.append(0)
        l2.append(l)
w1 =max(l1)
w2 = max(l2)
if w1 > w2:
    print('1',w1,sep = ' ')
else:
    print('2',w2,sep = ' ')
        

t=int(input())
l=[]
l1=[]
p1=0
p2=0
for i in range(t):
    n,m=map(int,input().split())
    p1+=n
    p2+=m
    if p1>p2:
        l.append(p1-p2)
        l1.append(0)
    else:
        l.append(0)
        l1.append(p2-p1)
m1=max(l)
m2=max(l1)
if m1>m2:
    print(1,m1)
else:
    print(2,m2)

t=int(input())
l=[]
l1=[]
p1=0
p2=0
for i in range(t):
    n,m=map(int,input().split())
    p1+=n
    p2+=m
    if p1>p2:
        l.append(p1-p2)
        l1.append(0)
    else:
        l.append(0)
        l1.append(p2-p1)
m1=max(l)
m2=max(l1)
if m1>m2:
    print(1,m1)
else:
    print(2,m2)

t=int(input())
l=[]
l1=[]
p1=0
p2=0
for i in range(t):
    n,m=map(int,input().split())
    p1+=n
    p2+=m
    if p1>p2:
        l.append(p1-p2)
        l1.append(0)
    else:
        l.append(0)
        l1.append(p2-p1)
m1=max(l)
m2=max(l1)
if m1>m2:
    print(1,m1)
else:
    print(2,m2)

t=int(input())
l1=0
l2=0
s1=0
s2=0
for i in range(t):
    ss1,ss2=list(map(int,input().split()))
    s1+=ss1
    s2+=ss2
    if s1-s2<0:
        if s2-s1>=l2:
            l2=s2-s1
    else:
        if s1-s2>=l1:
            l1=s1-s2
if l1>l2:
    print(1,l1)
else:
    print(2,l2)


# cook your dish here
n=int(input())
i=0
s1=0
s2=0
m=0
w=0
while i<n:
	a,b=input().split()
	a=int(a)
	b=int(b)
	s1+=a
	s2+=b
	if s1>s2:
		l=s1-s2
		if l>m:
			m=l
			w=1
	else:
		l=s2-s1
		if l>m:
			m=l
			w=2
	i+=1
print(w,m)

n=int(input())
i=0
s1=0
s2=0
m=0
w=0
while i<n:
	a,b=input().split()
	a=int(a)
	b=int(b)
	s1+=a
	s2+=b
	if s1>s2:
		l=s1-s2
		if l>m:
			m=l
			w=1
	else:
		l=s2-s1
		if l>m:
			m=l
			w=2
	i+=1
print(w,m)

n=int(input())
p1=[]
p2=[]
a,b=0,0
for i in range(n):
    s,t=map(int,input().split(' '))
    a+=s
    b+=t
    if(a>b):
        p1.append(a-b)
        p2.append(0)
    else:
        p2.append(b-a)
        p1.append(0)
if(max(p1)>max(p2)):
    print('1',max(p1),end=" ")
else:
    print('2',max(p2),end=" ")
    

# cook your dish here
n=int(input())
p1=[]
p2=[]
a,b=0,0
for i in range(n):
    s,t=map(int,input().split(' '))
    a+=s
    b+=t
    if(a>b):
        p1.append(a-b)
        p2.append(0)
    else:
        p2.append(b-a)
        p1.append(0)
if(max(p1)>max(p2)):
    print('1',max(p1),end=" ")
else:
    print('2',max(p2),end=" ")
    

# cook your dish here
n=int(input())
p1=[]
p2=[]
a,b=0,0
for i in range(n):
    s,t=map(int,input().split(' '))
    a+=s
    b+=t
    if(a>b):
        p1.append(a-b)
        p2.append(0)
    else:
        p2.append(b-a)
        p1.append(0)
if(max(p1)>max(p2)):
    print('1',max(p1),end=" ")
else:
    print('2',max(p2),end=" ")