Problem:


Score : 100 points

Problem Statement

We conducted a survey on newspaper subscriptions.
More specifically, we asked each of the N respondents the following two questions:

Question 1: Are you subscribing to Newspaper X?

Question 2: Are you subscribing to Newspaper Y?

As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2.

What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y?

Write a program to answer this question.

Constraints

1 \leq N \leq 100

0 \leq A \leq N

0 \leq B \leq N

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

Print the maximum possible number and the minimum possible number of respondents subscribing to both newspapers, in this order, with a space in between.

Sample Input 1

10 3 5

Sample Output 1

3 0

In this sample, out of the 10 respondents, 3 answered they are subscribing to Newspaper X, and 5 answered they are subscribing to Newspaper Y.

Here, the number of respondents subscribing to both newspapers is at most 3 and at least 0.

Sample Input 2

10 7 5

Sample Output 2

5 2

In this sample, out of the 10 respondents, 7 answered they are subscribing to Newspaper X, and 5 answered they are subscribing to Newspaper Y.

Here, the number of respondents subscribing to both newspapers is at most 5 and at least 2.

Sample Input 3

100 100 100

Sample Output 3

100 100



Sample input:
10 3 5


Sample output:
3 0

Submission status: Runtime Error

Solution code:
import numpy as np


class Person:
    def __init__(self, list_score_my, list_score_other, list_eatable):
        self.list_score_my = list_score_my
        self.list_score_other = list_score_other
        self.list_eatable = list_eatable
        self.eatable = True
        self.score_sum = 0

    # other
    def get_score_max_other(self):
        return np.max(self.list_score_other)

    def get_score_max_other_eatable(self):
        return np.max(self.list_score_other * self.list_eatable)

    def get_index_of_score_max_other_eatable(self):
        return np.where(self.list_score_other == self.get_score_max_other_eatable())

    def is_other_has_same_max_score(self):
        flag = 0
        score_other_max = np.max(self.list_score_other)
        for i in self.list_score_other:
            if(self.list_score_other[i] == self.score_other_max):
                flag += 1

        if(flag > 1):
            return True
        else:
            return False

    # my
    def get_score_max_my(self):
        return np.max(self.list_score_my)

    def get_score_max_my_eatable(self):
        return np.max(self.list_score_my * self.list_eatable)

    def get_index_of_score_max_my_eatable(self):
        return np.where(self.list_score_my == self.get_score_max_my_eatable())

    def is_i_have_same_max_score(self):
        flag = 0
        self.score_my_max = np.max(self.list_score_my)
        for i in range(len(self.list_score_my)):
            if(self.list_score_my[i] == self.score_my_max):
                flag += 1
        if(flag > 1):
            return True
        else:
            return False

    def eat(self, index):
        self.list_eatable[index] = False
        self.score_sum += self.list_score_my[index]

    def print_score(self):
        print(self.list_score_my)


def get_data(ryouri_goukei_num):
    list_score_a = np.empty(ryouri_goukei_num)
    list_score_b = np.empty(ryouri_goukei_num)
    list_ryouri_is_eatable = np.empty(ryouri_goukei_num)

    for i in range(ryouri_goukei_num):
        inputData = input()
        splitData = inputData.split()
        a_data = int(splitData[0])
        b_data = int(splitData[1])
        list_score_a[i] = a_data
        list_score_b[i] = b_data
        list_ryouri_is_eatable[i] = True

    return list_score_a, list_score_b, list_ryouri_is_eatable


def main():
    ryouri_goukei_num = int(input())
    list_score_a, list_score_b, list_ryouri_is_eatable = get_data(
        ryouri_goukei_num)
    sum_score_a = 0
    sum_score_b = 0
    a_turn = True
    b_turn = False
    takahashi = Person(list_score_a, list_score_b, list_ryouri_is_eatable)
    aoki = Person(list_score_b, list_score_a, list_ryouri_is_eatable)

    takahashi.print_score()
    aoki.print_score()

    for i in range(ryouri_goukei_num):
        if(takahashi.eatable):
            if(takahashi.is_i_have_same_max_score()):
                takahashi.eat(takahashi.get_index_of_score_max_other_eatable())
            else:
                takahashi.eat(takahashi.get_index_of_score_max_my_eatable())

            takahashi.eatable = False
            aoki.eatable = True
            list_ryouri_is_eatable = takahashi.eatable
            continue

        if(aoki.eatable):
            if(aoki.is_i_have_same_max_score()):
                aoki.eat(aoki.get_index_of_score_max_other_eatable())
            else:
                aoki.eat(aoki.get_index_of_score_max_my_eatable())

            takahashi.eatable = True
            aoki.eatable = False
            list_ryouri_is_eatable = aoki.eatable
            continue

    print(takahashi.score_sum - aoki.score_sum)


main()

Submission status: Runtime Error

Solution code:
print(min(n,a,b=map(int,input().split())),max(0,a+b-n))

Submission status: Runtime Error

Solution code:
N=int(input())
ps=[]
tp=[]
ap=[]
for i in range(N):
  p=input().split()
  ps.append([int(p[0])+int(p[1]),i])
  tp.append(int(p[0]))
  ap.append(int(p[1]))
    
def is_even(num):
  if num % 2 == 0:
    return True
  else:
    return False

T=0
A=0
calc=sorted(ps,reverse=True)
for i in range(N):
  p,j = calc.pop()
  if is_even(i):
    T+=tp[j]
  else:
    A+=ap[j]
print(T-A)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10000000000000000)
N, M = map(int, input().split())
T = {}
D = [0 for _ in range(N+1)]
P = [0 for _ in range(N+1)]
root_id = {i for i in range(1, N+1)}
for _ in range(N+M-1):
    a, b = map(int, input().split())
    if a not in T:
        T[a] = [b]
    else:
        T[a].append(b)
    if b in root_id:
        root_id.remove(b)
root_id = root_id.pop()

def setdep(i, p, d):
    if D[i] == 0:
        D[i] = d
        P[i] = p
    else:
        if D[i] > d:
            T[p].remove(i)
            return None
        else: # D[i] < d:
            T[P[i]].remove(i)
            P[i] = p
    if i not in T:
        return None
    for j in T[i]:
        setdep(j, i, d+1)

setdep(root_id, 0, 1)
for p in P[1:]:
    print(p)

Submission status: Runtime Error

Solution code:
n = int(input())

a = input()
b = input()
c = input()

ans = 0

for count in range(n):
    tmp = 0
    if a[count] == b[count]:
        if a[count] != c[count]:
            tmp += 1
    else:
        tmp += 1
        if (a[count] != c[count]) & (b[count] != c[count]):
            tmp += 1
    ans += tmp
    
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
A, B = [], []
Z = []
 
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
 
    Z.append(-a - b)
 
indexes = np.argsort(Z)
ans = 0
for cnt, i in enumerate(indexes):
    if cnt % 2 == 0:
        ans += A[i]
    else:
        ans -= B[i]

Submission status: Runtime Error

Solution code:
N = int(input())
A_dict = {}
B_dict = {}
i = 0
flg = 0
while i < N:
    l = list(map(int, input().split()))
    A = l[0]
    B = l[1]
    A_dict[str(i)] = A
    B_dict[str(i)] = B
    if flg == 0 and A != B:
        flg = 1
    i+=1

taka = 0
aoki = 0
for i in range(N):
    if flg == 0:
        A_max_key = max(A_dict, key=A_dict.get)
        taka += A_dict[str(A_max_key)]

        if len(A_dict) != 0:
            A_dict.pop(A_max_key)
        if len(B_dict) != 0:
            B_dict.pop(A_max_key)
        if len(B_dict) == 0:
            break

        B_max_key = max(B_dict, key=B_dict.get)
        aoki += max(B_dict.values())

        if len(A_dict) != 0:
            A_dict.pop(B_max_key)
        if len(B_dict) != 0:
            B_dict.pop(B_max_key)
        if len(A_dict) == 0:
            break
    else:
        B_max_key = max(B_dict, key=B_dict.get)
        taka += A_dict[B_max_key]

        if len(A_dict) != 0:
            A_dict.pop(B_max_key)
        if len(B_dict) != 0:
            B_dict.pop(B_max_key)
        if len(B_dict) == 0:
            break

        B_max_key = max(B_dict, key=B_dict.get)
        aoki += max(B_dict.values())

        if len(A_dict) != 0:
            A_dict.pop(B_max_key)
        if len(B_dict) != 0:
            B_dict.pop(B_max_key)
        if len(B_dict) == 0:
            break

print(taka, aoki)

Submission status: Runtime Error

Solution code:
import sys

import numpy as np

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    N = ii()
    AB = iml(N)
    ll = []
    for a, b in AB:
        ll.append(a + b)
    ind = np.argsort(ll)
    t = [AB[i][0] for i in ind[::2]]
    a = [AB[i][1] for i in ind[1::2]]
    return sum(t) - sum(a)


if __name__ == "__main__":
    print(solve())

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
m=A+B
print(min(A, B), max(0,m-N))

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split());min(a,b);print(t,max(max(a,b)-n+t,0))

Submission status: Runtime Error

Solution code:
N = int(input())
dish = []
 for i in range(N):
     a, b = map(int, input().split())
     dish.append((a+b, (a,b)))

"""while True:
    try:
        a, b = map(int, input().split())
    except EOFError:
        break
    dish.append((a+b, (a,b)))
"""

l = sorted(dish)

t=a = 0
for i, (_, (a_i, b_i)) in enumerate(l):
    if i % 2 == 0:
        #takahashi
        t += a_i
    else:
        a += b_i

print(t-a)

Submission status: Runtime Error

Solution code:
from collections import deque
def inpl(): return list(map(int, input().split()))

N, M = inpl()
G = {i:[] for i in range(N)}
X = [0]*(N)
searched = [0]*(N)
pairents = [-1]*N

for _ in range(N-1+M):
    a, b = inpl()
    G[a-1].append(b-1)
    X[b-1] += 1

q = X.index(0)

Q = deque([q])
while Q:
    p = Q.popleft()
    for q in G[p]:
        if searched[q] <= searched[p]:
            searched[q] = searched[p] + 1
            Q.append(q)

for a in range(N):
    for b in G[a]:
        if searched[b] == searched[a] + 1:
            pairents[b] = a
for p in pairents:
    print(p+1)

Submission status: Runtime Error

Solution code:
N=int(input())
if N%2==1:
    A=[]
    for i in range(N):
        a,b=map(int,input().split())
        c=a-b
        A.append([a,-b])
    A.sort()
    ao=0
    t=0
    for j in range(N):
        if j%2==0:
            ao+=A[j][0]
        else:
            t+=A[j][1]
    print(ao+t)

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    n, a, b = input().split()
    N, A, B = int(n), int(a), int(b)

    ans_max = min(A, B)

    n_mid = N / 2
    if (A + B) <= N
        ans_min = 0
    else:
        ans_min = max((A - n_mid) + (B - n_mid), 0)

    print('{0} {1}'.format(ans_max, ans_min))

Submission status: Runtime Error

Solution code:
N=int(input())
A=[]
for i in range(N):
    a,b=map(int,input().split())
    c=a-b
    A.append([a,-b])
A.sort()
ao=0
t=0
for j in range(N):
    if j%2==0:
        ao+=A[j][0]
    else:
        t+=A[j][1]
print(ao+t)

Submission status: Runtime Error

Solution code:
import sys
from collections import deque
def input(): return sys.stdin.readline()
def inpl(): return [int(i) for i in input().split()]
from collections import defaultdict
N, M = inpl()
Edge = defaultdict(lambda: [])
Par = set(range(N)) 
for _ in range(N-1+M):
    A, B = inpl()
    Par.discard(B-1)
    Edge[A-1].append(B-1)
par = list(Par)[0]
dist = [0]*N
Q = deque([par])
while Q:
    st = Q.pop()
    for en in Edge[st]:
        if dist[en] < dist[st] + 1:
            dist[en] = dist[st] + 1
            if len(Edge[en]) == 1:
                Q.append(en)
            else:
                Q.appendleft(en)
Ans = [0]*N
Q = deque([par]) 
while Q:
    st = Q.pop()
    for en in Edge[st]:
        if dist[en] == dist[st] + 1:
            Ans[en] = st+1
            Q.appendleft(en)
for i in Ans:
    print(i)

Submission status: Runtime Error

Solution code:
import sys
file= lambda location: {True:sys.stdin, False:open(location,"r")}[location==""]

location="subs.txt"#Enter location here
sys.stdin=file(location)
raw_input=sys.stdin.readline

for i in xrange(int(raw_input())):
N,A,B=map(int,raw_input().split())
m=A+B
if A==B==N:
	print N,N
elif(m>N):
	if A==B:
		print A,1
	else:
		print min(A,B),abs(A-B)
else:
	print min(A,B),0

Submission status: Runtime Error

Solution code:
N=int(input())
LA=[0]*N
LD=[0]*N
for i in range(N):
    A,B=input().split()
    LA[i]=int(A)
    LD[i]=int(A)+int(B)

isRunned=True
while(isRunned):
    isRunned=False
    for i in range(N-1):
        if LD[i]<LD[i+1]:    
            LD[i],LD[i+1]=LD[i+1],LD[i]
            LA[i],LA[i+1]=LA[i+1],LA[i]
            isRunned=True
        

print(sum(LA[::2])-(sum(LD[1::2])-sum(LA[1::2])))

Submission status: Runtime Error

Solution code:
# coding: utf-8

import sys

lines = sys.stdin.readlines()

n,a,b,c = lines
n = int(n.strip('\n'))
a = str(a.strip('\n'))
b = str(b.strip('\n'))
c = str(c.strip('\n'))

num = 0
if not(n == a == b == c):
  for i in range(n):
    if not(a[i] == b[i] == c[i]):
      if a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        num = num+1
      else:
        num = num+2

print(num)       

sys.exit(0)

Submission status: Runtime Error

Solution code:
import sys
from collections import defaultdict
sys.setrecursionlimit(100000)

N, M = map(int, input().split())
AB = []
D = defaultdict(lambda: [])
for i in range(N + M - 1):
    a, b = map(int, input().split())
    AB.append((a - 1, b - 1))
    D[a - 1].append(b - 1)

z = [0]*N
for a, b in AB:
    z[b] += 1

ans = [-1]*N
root = z.index(0)
ok = [False]*N
def rec(u, p):
    ans[u] = p
    ok[u] = True
    for v in D[u]:
        z[v] -= 1
    for v in D[u]:
        if z[v] == 0 and not ok[v]:
            rec(v, u)


rec(root, -1)

for i in range(N):
    print(ans[i] + 1)

Submission status: Runtime Error

Solution code:
print(str(max(A,B)) + " " + str(max(A+B-N,0)))

Submission status: Runtime Error

Solution code:
N=int(input())
LA=[0]*N
LB=[0]*N
for i in range(N):
    A,B=[int(x) for x in input().split()]
    LA[i]=A
    LB[i]=B

PA=0
PB=0

LD=[0]*N
for i in range(N):
    LD[i]=LA[i]+LB[i]

isRunned=True
while(isRunned):
    isRunned=False
    for i in range(N-1):
        if LD[i]<LD[i+1]:
            LD[i],LD[i+1]=LD[i+1],LD[i]
            LA[i],LA[i+1]=LA[i+1],LA[i]
            LB[i],LB[i+1]=LB[i+1],LB[i]
            isRunned=True
        

print(sum(LA[::2])-sum(LB[1::2]))

Submission status: Runtime Error

Solution code:
n = int(input())
long ans = 0
li = []
for i in range(n):
    a, b = map(int, input().split())
    li.append([a+b, a, b])

li = sorted(li)
for i in range(n):
    if i%2 == 0:
        ans += li[i][1]
    if i%2 == 1:
        ans -= li[i][2]

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
happiness = []

for n in range(N):
    num = input().split()
    a = int(num[0])
    b = int(num[1])
    happiness.append([a + b, a, b])

happiness.reverse()

sum = 0
turn = 0

for n in range(N):
    if turn == 0:
        sum += happiness[n][1]
    else:
        sum -= happiness[n][2]
    turn ^= 1

print(sum)

Submission status: Runtime Error

Solution code:
n,a,b = map(int, input().split())
min_num = 0
max_num = 0

if a == b and a == n:
    min_num = n
    max_num = n
elif a == n or b == n
    min_num = min(a,b)
    max_num = min(a,b)
elif a == 0 or b == 0:
    pass
elif n >= a + b:
    max_num = min(a,b)
elif n < a + b:
    min_num = abs(int(n/2)-max(a,b))
    max_num = min(a,b)

print(max_num, min_num)

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    n = int(input())
    c = []
    d = []
    e = []
    
    for i in range(0, n):
        a, b = map(int, input().split())
        c.append(a)
        d.append(b)
        e.append(a + b)
    
    li1, li2 = sorted(e), sorted(range(len(e)), key=lambda k: e[k])
    
    turn = 0
    happy = 0

    for i in range(n - 1, -1, -1):
        now = li1[i]
        if (turn == 0):
            max = 0
            maxKey = 0
            for j in range(i, -1, -1):
                if (now == li1[j] and max < c[li2[j]]):
                    max = c[li2[j]]
                    maxKey = j
                else:
                    li2[i], li2[maxKey] = li2[maxKey], li2[i]
                    break
            happy += c[li2[i]]
        else:

            max = 0
            maxKey = 0
            for j in range(i, -1, -1):
                if (now == li1[j] and max < d[li2[j]]):
                    max = d[li2[j]]
                    maxKey = j
                else:
                    li2[i], li2[maxKey] = li2[maxKey], li2[i]
                    break

            happy -= d[li2[i]]
        turn = (turn + 1) % 2
    print(happy)

Submission status: Runtime Error

Solution code:
import numpy as np
N,M=[int(i) for i in input().split(" ")]
 
G=np.zeros((N,N),dtype=np.int)
for i in range(N+M-1):
    A,B=[int(j)-1 for j in input().split(" ")]
    G[A][B]=1
for i in range(M):
    x=np.sum(G,axis=0).argmax()
    y=np.sum(G,axis=1).argmax()
    G[y][x]-=1
 
for l in G.T:
    if np.sum(l)==0:
        print("0")
    else:
        print(l.argmax()+1)

Submission status: Runtime Error

Solution code:
n = input()
a = input()
b = input()
c = input()

la = list(a)
lb = list(b)
lc = list(c)

total = 0
for i in range(int(n)):
    count = 0
    if la[i] != lb[i]:
        count += 1
    if la[i] != lc[i]:
        count += 1
    if lb[i] != lc[i]:
        count += 1

    if count == 3:
        total += 2
    elif count == 2:
        total += 1
    elif count == 1:
        total += 1
    else:
        total += 0

print(total)

Submission status: Runtime Error

Solution code:
N=int(input())
A=int(input())
B=int(input())
sum=A+B
if sum>=N:
   if A>B:
      print(B and sum-N)
   if A<=B:
      print(A and sum-N)

else:
   if A>B:
      print(B and 0)
   if A<=B:
      print(A and 0)

Submission status: Runtime Error

Solution code:
n = int(input())
a = input()
b = input()
c = input()

t = n * 2;

for i in range(n):
    if a[i] == b[i] : t -= 1
    if b[i] == c[i] : t -= 1
    if c[i] == a[i] : t -= 1
    
    if a[i] == b[i] and b[i] == c[i] and c[i] == a[i] : t += 1
    
print(t)

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
AB = np.zeros((3, N))

for i in range(N):
    tmpA, tmpB = map(int, input().split())
    AB[0, i] = tmpA + tmpB
    AB[1, i] = tmpA
    AB[2, i] = tmpB

AB = AB[:, np.argsort(AB[0, :])][::-1]

point = 0
for i in range(N):
    if i%2==0:
        point += AB[1, i]
    else:
        point -= AB[2, i]
 
print(int(point))

Submission status: Runtime Error

Solution code:
import sys

if __name__ == '__main__':
    n, a, b = sys.argv[1:4]
    N, A, B = int(n), int(a), int(b)

    ans_max = min(A, B)

    n_mid = N // 2
    if A <= (n_mid) and B <= (n_mid):
        ans_min = 0
    else:
        ans_min = (A - n_mid) + (B - n_mid)

    print('{0} {1}'.format(ans_max, ans_min))

Submission status: Runtime Error

Solution code:
import math
from fractions import Fraction

def saidai(x,y):
    if x > y:
        big=x-y
        big=x-big
        return big
    elif x < y:
        big=y-x
        big=y - big
        return big
        
def saisho(n,x,y):
    both=math.gcd(x,y)
    
    return both

a = float(Fraction(3,10))
b = float(Fraction(5,10))

print(saidai(3,5))
print(saisho(10,int(a),int(b)))

Submission status: Runtime Error

Solution code:
knrejaegg

Submission status: Runtime Error

Solution code:
sum=A+B
if sum>=N:
   if A>B:
      print(B and sum-N)
   if A<=B:
      print(A and sum-N)

else:
   if A>B:
      print(B and 0)
   if A<=B:
      print(A and 0)

Submission status: Runtime Error

Solution code:
n = int(input())
res_tak = [0 for i in range(n)]
res_she = [0 for i in range(n)]
for j in range(n):
    a, b = (int(i) for i in input().split())
    res_tak[j] = a
    res_she[j] = b
tak = 0
she = 0
for i in range(n):
    if i & 1 == 1:
        she += max(res_she)
        j=0
        while res_she[j]==max(res_she):
            j+=1
        res_she[j] = 0
        res_tak[j] = 0
    else:
        tak += max(res_tak)
        j=0
        while res_tak[j]==max(res_tak):
            j+=1
        res_she[j] = 0
        res_tak[j] = 0


print(abs(she-tak))

Submission status: Runtime Error

Solution code:
from sys import stdin
total, a, b = stdin.readline().rstrip()
if a > b:
    max_num = b
    if total < (a+b):
        min_num = abs(a - b)
    else:
        min_num = 0
elif a == b:
    min_num = a
    max_num = b
else:
    max_num = a
    if total < (a+b):
        min_num = abs(a - b)
    else:
        min_num = 0

print(int(max_num), int(min_num))

Submission status: Runtime Error

Solution code:
n, a, b, c = [input() for i in range(4)]
n = int(n)

ret = 0
for i in range(n):
    if (a[i] == b[i]) and (a[i] == c[i]):
        pass

    elif (a[i] == b[i]) and (a[i] != c[i]):
        c = c[:i] + a[i] + c[i + 1:]
        ret += 1

    elif a[i] == c[i] and a[i] != b[i]:
        b = b[:i] + a[i] + b[i + 1:]
        ret += 1

    elif a[i] != c[i] and b[i] == c[i]:
        a = a[:i] + b[i] + a[i + 1:]
        ret += 1

    elif a[i] != b[i] and a[i] != c[i]:
        b = b[:i] + a[i] + b[i + 1:]
        c = c[:i] + a[i] + c[i + 1:]
        ret += 2


print(ret)

Submission status: Runtime Error

Solution code:
N=int(input())
LA=[0]*N
LB=[0]*N
for i in range(N):
    A,B=[int(x) for x in input().split()]
    LA[i]=A
    LB[i]=B

PA=0
PB=0

LD=[0]*N
for i in range(N):
    LD[i]=LA[i]+LB[i]


SLD=sorted(LD)
SLD.reverse()
if N%2==0:
    for i in range(0,N,2):
        PA+=LA[LD.index(SLD[i])]
        PB+=LB[LD.index(SLD[i+1])]
else:
    for i in range(0,N-1,2):
        PA+=LA[LD.index(SLD[i])]
        PB+=LB[LD.index(SLD[i+1])]

    PA+=LA[LD.index(SLD[N-1])]

print(PA-PB)

Submission status: Runtime Error

Solution code:
N=int(input())
A=[]
for i in range(N):
    a,b=map(int,input().split())
    c=a-b
    A.append([c,-a,-b])
A.sort()
ao=0
t=0
for j in range(N):
    if j%2==0:
        ao+=-1*A[j][1]
    else:
        t+=-1*A[j][2]
print(ao-t)

Submission status: Runtime Error

Solution code:
from sys import stdin

N = int(stdin.readline().rstrip())
A =  stdin.readline().rstrip()
B =  stdin.readline().rstrip()
C =  stdin.readline().rstrip()

str_len = len(A)

count = 0


for i in range(str_len):
    if A[i]==B[i]:
        if C[i]==B[i]:
            continue
        else:
            count = count + 1
    elif A[i]==C[i]:
        count = count + 1
    elif B[i]==C[i]:
        count = count + 1
    else:
        count = count + 2
print(str(count))

Submission status: Runtime Error

Solution code:
from collections import deque
N, M = map(int, input().split())
graph = [] 
for i in range(N + M - 1):
    a, b = map(int, input().split())
    graph += [[a,b]]

path = [[] for i in range(N)]  
parent = [[] for i in range(N)]
ans = [-1 for i in range(N)]
for p in graph:
    parent[p[1]-1] += [p[0]-1]
    path[p[0]-1] += [p[1]-1]

root = -1
for i in range(N):
    if parent[i] == []:
        root = i
        ans[i] = -1
    
que = deque()
for v in path[root]:
    que.append([root, v])
while que:
    u, V = que.popleft()
    ans[V] = u
    for v in path[V]:
        que.append([V, v])

for i in range(N):
    print(ans[i]+1)

Submission status: Runtime Error

Solution code:
n = int(input())

aa = []
for i in range(n):
	k,l = map(int,input().split())
	aa.append([k,l])
aa.sort(key = lambda x:x[1])
aa.reverse()
co = 0
ma = 0
kkk = 0
for i in range(n):
	if i % 2 == 0:
		ma = max(aa,key = lambda x:x[0])[0]
		for j in range(len(aa)):
			if ma == aa[j][0]:
				co += aa.pop(j)[0]
				break
	else:
		co -= aa.pop(0)[1]

print(co)

Submission status: Runtime Error

Solution code:
N = int(input())
Nlist=[]
Takalist=[]
Aokilist=[]
for n in range(N):
    Nlist.append(n)
    a,b = map(int,input().split())
    Takalist.append(a)
    Aokilist.append(b)

Taka = 0
Aoki = 0


flg = 0
for n in range(N):
    if flg == 0:
        big = max(Takalist)
        Taka += big
        num = Takalist.index(big)
        Aokilist[num]=0
        Takalist[num]=0
        flg=1

    elif flg == 1:
        big = max(Aokilist)
        Aoki += big
        num = Aokilist.index(big)
        Aokilist[num]=0
        Takalist[num]=0
        flg=0

print(Taka-Aoki)

Submission status: Runtime Error

Solution code:
from sys import stdin

total, a, b = stdin.readline().rstrip()
if a > b:
    max_num = b
    if total < a+b:
        min_num = a - b
    else:
        min_num = 0
else:
    max_num = a
    if total < a+b:
        min_num = a - b
    else:
        min_num = 0

print(int(max_num), int(min_num))

Submission status: Runtime Error

Solution code:
n=int(input())
a=input()
b=input()
c=input()
tim = 0
for i in range(n):
    if a[i] == b[i] and b[i] != c[i]:
        tim+=1
    elif b[i] == c[i] and c[i] != a[i]:
        tim+=1
    elif c[i] == a[i] and a[i] != b[i]:
        tim+=1
    elif c[i] == a[i] and a[i] == b[i]:
        tim+=0
    else:
        tim+=2
print(tim)

Submission status: Runtime Error

Solution code:
n=input()
a=input()
b=input()
c=input()
tim = 0
for i in range(int(n)):
    if a[i] == b[i] and b[i] != c[i]:
        tim+=1
    elif b[i] == c[i] and c[i] != a[i]:
        tim+=1
    elif c[i] == a[i] and a[i] != b[i]:
        tim+=1
    elif c[i] == a[i] and a[i] == b[i]:
        tim+=0
    else:
        tim+=2
print(tim)

Submission status: Runtime Error

Solution code:
from sys import stdin

N = int(stdin.readline().rstrip())
A =  stdin.readline().rstrip()
B =  stdin.readline().rstrip()
C =  stdin.readline().rstrip()

str_len = len(A)

count = 0


for i in range(str_len):
    if A[i]==B[i]:
        if C[i]==B[i]:
            continue
        else:
            count = count + 1
    elif A[i]==C[i]:
        count = count + 1
    else:
        count = count + 2

print(count)

Submission status: Runtime Error

Solution code:
n,a,b,c = (i for i in input().split())
tim = 0
for i in range(n):
    if a[i] == b[i] and b[i] != c[i]:
        tim+=1
    elif b[i] == c[i] and c[i] != a[i]:
        tim+=1
    elif c[i] == a[i] and a[i] != b[i]:
        tim+=1
    elif c[i] == a[i] and a[i] == b[i]:
        tim+=0
    else:
        tim+=2
print(tim)

Submission status: Runtime Error

Solution code:
total, a, b = stdin.readline().rstrip()
if a > b:
  min = b
  if total < a+b:
    max = a - b
  else:
    max = 0
else:
  min = a
  if total < a+b:
  	max = a - b
  else:
    max = 0
    
print(int(max), int(min))

Submission status: Runtime Error

Solution code:
n=input()
a=input()
b=input()
c=input()
tim = 0
for i in range(n):
    if a[i] == b[i] and b[i] != c[i]:
        tim+=1
    elif b[i] == c[i] and c[i] != a[i]:
        tim+=1
    elif c[i] == a[i] and a[i] != b[i]:
        tim+=1
    elif c[i] == a[i] and a[i] == b[i]:
        tim+=0
    else:
        tim+=2
print(tim)

Submission status: Runtime Error

Solution code:
n = input()
a = input()
b = input()
c = input()
ans = 0
for i in range(len(a)):
    #print(a[i], b[i], c[i])
    if a[i]==b[i] and b[i]==c[i]:
        ans += 0
    elif a[i]==b[i] or b[i]==c[i] or c[i]==a[i]:
        ans += 1
    else:
        ans += 2

print(ans)

Submission status: Runtime Error

Solution code:
import sys

n = int(sys.argv[1])
a = int(sys.argv[2])
b = int(sys.argv[3])
x = max(a, b)
y = a+b-n
if y < 0:
    y = 0
print(x, y)

Submission status: Runtime Error

Solution code:
n = int(input())
a = int(input())
b = int(input())
x = max(a, b)
y = a+b-n
if y < 0:
    y = 0
print(x, y)

Submission status: Runtime Error

Solution code:
from sys import stdin
N,A,B=[int(x) for x in stdin.readline().rstrip().split()]
if N==A and A==B and B==N:
    print(N,N)
else:
    if A=B:
        print(A,(A+B)-N)
    else:
        if A>=B:
            if (A+B)>N:
                print(B,A-B)
            else:
                print(B,0)
        else:
            if (A+B)>N:
                print(A,B-A)
            else:
                print(A,0)

Submission status: Runtime Error

Solution code:
n = input().split()
N = int(n[0])
A = int(n[1])
B = int(n[2])

if A > B or A == B:
    a = A
    b = B
elif B < A:
    a = B
    b = A

if a != b:
    if a+b < N:
        print(str(b) + ' ' + str(0))
    elif a+b > N:
        print(str(b) + ' ' + str(a - (N-b)))
elif a < N//2:
    print(str(a) + ' ' + str(0))
elif a > N//2:
    print(str(a) + ' ' + str(a-(N-b)))

Submission status: Runtime Error

Solution code:
for i in range(1000):
  print("Enter data: ", end="")
  inputstr = input().strip()
  if inputstr == "":
    break
  inputarray= inputstr.split(" ")
  n = int(inputarray[0])
  a = int(inputarray[1])
  b = int(inputarray[2])
  d1 = min(a,b)
  if a+b > n:
    d2 = abs(a+b-n)
  else:
    d2 = 0
  print (str(max(d1,d2)) + " " + str(min(d1,d2)))

Submission status: Runtime Error

Solution code:
n=int(input())
a=input()
b=input()
c=input()
al=list(a)
bl=list(b)
cl=list(c)

count=0

for i in range(n):
    if al[i]==bl[i]:
        if al[i]==cl[i]:
            plus=2
        else:
            plus=1
    elif bl[i]==cl[i]:
        plus=1
    elif al[i]==cl[i]:
        plus=1
    else:
        plus=0
        
    count+=plus
    
print(count)

Submission status: Runtime Error

Solution code:
from sys import stdin

A, B, C = [int(x) for x in stdin.readline().rstrip().split()]




if B+C <= A:
    print(str(max(B,C)) + ' ' + str(0))
else:
    print(str(max(B1,C)) + ' ' +str(B+C-A))

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split(' '))

if n > 100 or a > n or b > n:
    raise ValueError

ret_max  = min(a,b)	

if n > a + b :
    ret_min = 0
else : 
    ret_min = max(a, b) - min(a,b)

print({} {}).format(ret_max, ret_min)

Submission status: Runtime Error

Solution code:
#include<iostream>
#include "bits/stdc++.h"
using namespace std;

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A, B) << " " << max(min(A,B) - (N - max(A,B)),0);
    return 0;
}

Submission status: Runtime Error

Solution code:
n, a, b = map(int, raw_input().split())

minN = 0
maxN = 0

if (a + b < n):
    minN = 0
else:
    minN = (a + b) - n
maxN = min(a, b)
    
print(str(maxN) + " " + str(minN))

Submission status: Runtime Error

Solution code:
n = int(input())
a = int(input())
b = int(input())

c = 0
d = a + b -n
if (a > b):
    c = b
else:
    c = a

if (d < 0):
    d = 0
    
print(str(c) + " " + str(d))

Submission status: Runtime Error

Solution code:
# n, a, b = map(int, input().split())
print(min(a, b), max((a+b-10), 0))

Submission status: Runtime Error

Solution code:
n,a,b = map(int, input().slit())
if a > b:
  c = b
else:
  c = a
if 0 <= a + b - n:
  d = a + b -n
else:
  d = 0
print(c,d)

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split())
q=min(b,c)
w=b+c-a
print("{} {}".format(q,max(0,w))