Problem:
Card Game Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card.
  The name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of that turn. The winner obtains 3 points. In the case of a draw, they obtain 1 point each. Write a program which reads a sequence of cards Taro and Hanako have and reports the final scores of the game. Input In the first line, the number of cards n is given. In the following n lines, the cards for n turns are given respectively. For each line, the first string represents the Taro's card and the second one represents Hanako's card. Constraints  n ≤ 1000  The length of the string ≤ 100  Output Print the final scores of Taro and Hanako respectively. Put a single space character between them. Sample Input 3
cat dog
fish fish
lion tiger Sample Output 1 7

Solution (Python):
n=int(input())
na=0
nb=0
for i in range(n):
  a,b=input().split(' ')
  if len(a) <  len(b):
    for i in range(len(a)):
      if a[i]>b[i]:
        na+=3
        break
      elif a[i]<b[i]:
        nb+=3
        break
      elif i==len(a)-1:
         nb+=3
  else:
     for i in range(len(b)):
      if a[i]>b[i]:
        na+=3
        break
      elif a[i]<b[i]:
        nb+=3
        break
      elif i==len(b)-1:
        if len(a) ==len(b):
          na+=1
          nb+=1 
        else:
         na+=3 

print(f"{na} {nb}")

Solution (Python):
n=int(input())
a=0
b=0
for i in range(n):
    A,B=map(str,input().split())
    if A>B:
        a+=3
    if A<B:
        b+=3
    if A==B:
        a+=1
        b+=1
print(a,b)

Solution (Python):
n=int(input())
T=0
H=0
for i in range(n):
    t,h=input().split()
   
    if t>h:
        T=T+3
    elif t==h:
        T=T+1
        H=H+1
    else:
        H=H+3
print(T,H)

Solution (Python):
n=int(input())
x=0
y=0
for i in range(n):
    a,b=map(str,input().split())
    if a>b:
        x+=3
    elif a<b:
        y+=3
    else:
        x+=1
        y+=1
print(x,y)

Solution (Python):
N=int(input())
x=0
y=0
for i in range(N):
    a,b=input().split()
    if a<b:
        y+=3
    elif a==b:
        x+=1
        y+=1
    else:
        x+=3
print(x,y)

Solution (Python):
n = int(input())
taro=0
hanako=0
for i in range(n):
    T,H = input().split()
    if T==H:
        taro = taro+1
        hanako = hanako+1
    elif T>H:
        taro = taro+3
    elif T<H:
        hanako = hanako+3
print(taro,hanako)

Solution (Python):
n = int(input())
T = 0
H = 0
        
for i in range(n):
    x = str(input())
    x = x.split()
    if x[0] == x[1]:
        T += 1
        H += 1
    elif x[0] < x[1]:
        H += 3
    elif x[0] > x[1]:
        T += 3
    
print(T,H)

Solution (Python):

import sys
input = sys.stdin.readline


def lexicograph(a: str, b: str):
    l = min(len(a), len(b))
    for i in range(l):
        if ord(a[i].lower()) == ord(b[i].lower()):
            continue
        elif ord(a[i].lower()) < ord(b[i].lower()):
            return True
        else:
            return False
    if len(a) < len(b):
        return True
    else:
        return False


m = int(input())
taro = 0
hana = 0
for _ in range(m):
    a, b = input().strip().split()
    if a == b:
        taro += 1
        hana += 1
    elif lexicograph(a, b):
        hana += 3
    else:
        taro += 3

print(taro, hana)

Solution (Python):
n=int(input())
k=0
l=0
for i in range(n):
    a,b=input().split()
    mylist=[a,b]
    newlist=sorted(mylist)
    if a !=b:
        if newlist[1]==a:
            k+=3
        if newlist[1]==b:
            l+=3
    else:
        k+=1
        l+=1
    
print(k,l)

Solution (Python):
n=int(input())
t=0
h=0
for i in range(n):
    word=list(map(str,input().split()))
    if word[0]==word[1]:
        t+=1
        h+=1
    elif word[0]>word[1]:
        t+=3
    else:
        h+=3
print(f'{t} {h}')

Solution (Python):

n = int(input())
card = []
tc = []
hc = []

taro = 0
hanako = 0
counter = 0

i = 0
j = 0
k = 0
for i in range(n):
    card.append(list(input().split()))
    tc.append(list(card[i][0]))
    hc.append(list(card[i][1]))

    if len(card[i][0]) <= len(card[i][1]):
        counter = len(card[i][0])
    else:
        counter = len(card[i][1])
    
    for j in range(counter):
        if ord(tc[i][j].lower()) < ord(hc[i][j].lower()):
            hanako += 3
            break
        elif ord(tc[i][j].lower()) > ord(hc[i][j].lower()):
            taro += 3
            break
        else:
            if j == counter - 1:
                if len(card[i][0]) < len(card[i][1]):
                    hanako += 3
                elif len(card[i][0]) > len(card[i][1]):
                    taro += 3
                else:
                    taro += 1
                    hanako += 1

                break

print("%d %d" % (taro, hanako))

Solution (Python):
num = int(input())
A,B = 0,0
for index in range(num):
    a,b = input().split()
    if a == b:
        A,B = A+1,B+1
    elif a > b:
        A += 3
    else:
        B += 3
print(f"{A} {B}")

Solution (Python):
n=int(input())
T=0
H=0
for i in range(n):
    card_t,card_h=input().split()
    if card_t==card_h:
        T+=1
        H+=1
    else:
        if card_t>card_h:
            T+=3
        else:
            H+=3
print(T,H)

Solution (Python):
n = int(input())
t = 0
h = 0
for i in range(n):
    a,b = map(str,input().split())
    if a > b:
        t += 3
    if a < b:
        h += 3
    if a== b:
        t += 1
        h += 1
print(t,h)

Solution (Python):
N=int(input())
x=0
y=0
for i in range(N):
    a,b=input().split()
    if a<b:
        y+=3
    elif a==b:
        x+=1
        y+=1
    else:
        x+=3
print(x,y)

Solution (Python):
p=0
q=0
n=int(input())
for i in range(n):
    m=list(input().split())
    
    if len(m[0])<=len(m[1]):
        r=len(m[0])
    elif len(m[0])>len(m[1]):
        r=len(m[1])
    for j in range(r):
        x=ord(m[0][j:j+1])
        y=ord(m[1][j:j+1])
        if x>y:
            p+=3
            break
        elif x<y:
            q+=3
            break
    if x==y:
        if len(m[0])<len(m[1]):
            q+=3
        elif len(m[0])>len(m[1]):
            p+=3
        else:
            p+=1
            q+=1
        
print(p,end=' ')
print(q)

Solution (Python):
N=int(input())
x=0
y=0
for i in range(N):
    a,b=input().split()
    if a<b:
        y+=3
    elif a==b:
        x+=1
        y+=1
    else:
        x+=3
print(x,y)

Solution (Python):
n = int(input())

a = 0
b = 0

for i in range(n):
    x, y = map(str,input().split())
    if(x < y):
        b = b + 3
    elif(x > y):
        a = a + 3
    else:
        a = a + 1
        b = b + 1
        
print(a, b)

Solution (Python):
N = int(input())
taro = 0
hanako = 0
for n in range(N):
    t_str, h_str = map(str, input().split())
    if t_str == h_str:
        taro += 1
        hanako += 1
    else:
        min_len = min(len(t_str), len(h_str))
        for l in range(min_len):
            if t_str[l] < h_str[l]:
                hanako += 3
                break
            elif t_str[l] > h_str[l]:
                taro += 3
                break
            if l == min_len - 1:
                if len(t_str) < len(h_str):
                    hanako += 3
                    break
                else:
                    taro += 3
                    break
print("{} {}".format(taro, hanako))

Solution (Python):
n = int(input())

aScore = 0
bScore = 0

for _ in range(n):
    a, b = input().split()
    if a > b:
        aScore += 3
    elif b > a:
        bScore += 3
    else:
        aScore += 1
        bScore += 1

print("{} {}".format(aScore,bScore))

Solution (Python):
n = int(input())
i = 1
t,h = 0,0
while i <= n:
    s1,s2 = map(str,input().split())
    if s1 < s2 :
        h += 3
    elif s1 > s2 :
        t += 3
    else:
        t += 1
        h += 1
    i += 1
print(t,h)

Solution (Python):
n = int(input())
t_t = 0
h_t = 0
for i in range(n):
    k = input()
    t, h = k.split()
    if t > h:
        t_t += 3
    elif t < h:
        h_t += 3
    elif t == h:
        t_t += 1
        h_t += 1
print(t_t, h_t)

Solution (Python):
num = int(input())
result_a = 0
result_b = 0
for i in range(num):
    a, b = map(str, input().split())
    if a  == b:
        result_a += 1
        result_b += 1
    elif a < b:
        result_b += 3
    else:
        result_a += 3
        
print(result_a, result_b)

Solution (Python):
n = int(input())
tp = 0
hp = 0

for i in range(n):
    l = input().split()
    if l[0] == l[1]:
        tp += 1
        hp += 1

    elif l[0] > l[1]:
        tp += 3

    elif l[0] < l[1]:
        hp += 3

print(f"{tp} {hp}")

Solution (Python):
n = int(input())
WIN = 3
DROW = 1
tarou = 0
hanako = 0
for i in range(n):
    t, h = input().split()
    if t == h:
        tarou += DROW
        hanako += DROW
    if t > h:
        tarou += WIN
    if t < h:
        hanako += WIN
print(tarou, hanako)

Solution (Python):
N= int(input())

x=0
y=0

for i in range(N):
    a,b = input().split()
    if a<b:
        y+=3
    elif a==b:
        x+=1
        y+=1
    else:
        x+=3
print(x,y)

Solution (Python):
n = int(input())
list_point = [0, 0]

for _ in range(n):
    word1, word2 = map(str, input().split(" "))
    if word1 == word2:
        list_point[0] += 1
        list_point[1] += 1
    elif word1 > word2:
        list_point[0] += 3
    elif word1 < word2:
        list_point[1] += 3
    else:
        print("Error!")

print(list_point[0], list_point[1])

Solution (Python):
n = int(input())
t = 0
h = 0
for _ in range(n):
    a, b = input().split()
    if a > b:
        t +=3
    elif a < b:
        h += 3
    else:
        t += 1
        h += 1
print(t,h)

Solution (Python):
n = int(input())

a = 0
b = 0
for i in range(n):
  aw , bw = input().split()
  
  if aw > bw:
    a += 3
  elif aw < bw :
    b += 3
  else :
    a += 1
    b += 1

print(a,b)

Solution (Python):
import string
a=0
b=0

n=int(input())
for i in range(n):
    t,h=map(str,input().split())
    if t==h:
        a+=1
        b+=1
    elif t>h:
        a+=3
    else:
        b+=3
    
print(a,b)

Solution (Python):
cards = int(input())
tarou_win = 0
hanako_win = 0
hikiwake = 0
for _ in range(cards):
    tarou_word, hanako_word = input().split() 
    if tarou_word > hanako_word:
        tarou_win += 1
    elif tarou_word < hanako_word:
        hanako_win += 1
    else :
        hikiwake += 1
print(tarou_win * 3 + hikiwake ,hanako_win * 3 + hikiwake)

Solution (Python):
n = input()
hana = 0
taro = 0
while True:
  try:
    a, b = input().split()
    if a < b:
      hana += 3
    elif a == b:
      hana += 1
      taro += 1
    else:
      taro += 3
  except EOFError:
    break
print(taro, hana)

Solution (Python):
n = int(input())
t = 0
h = 0
for i in range(n):
    s = input().split()
    if s[0] < s[1]:
        h += 3
    elif s[0] > s[1]:
        t += 3
    else:
        t += 1
        h += 1
print(t,h)

Solution (Python):
n = int(input())
c = [0, 0]
for i in range(n):
    t, h = input().split()
    if t == h:
        c[0] += 1
        c[1] += 1
    elif t > h:
        c[0] += 3
    else:
        c[1] += 3
print(c[0], c[1])

Solution (Python):
a = int(input())
x = 0
y = 0
for i in range(a):
    b,c = input().split(' ')
    if b < c:
        x = x + 3
    elif b == c:
        x = x + 1
        y = y + 1
    elif b > c:
        y = y + 3
print(str(y) + ' ' + str(x))

Solution (Python):
n = int(input())
point = [0,0]
for _ in range(n):
    a,b = input().split()
    if a==b:
        point = list(map(lambda x:x+1 ,point))
    elif a > b:
        point[0]+=3
    else:
        point[1]+=3
print(*point)

Solution (Python):
n=int(input())
a=0
b=0
for i in range(n):
    x,y=map(str,input().split())
    if x > y:
        a += 3
    elif y > x:
        b += 3
    elif x == y:
        a += 1
        b += 1
print(a,b)

Solution (Python):
n = int(input())

taro_point = 0
hana_point = 0

for j in range(n):
    t, h = input().split()

    if t > h:
        taro_point += 3

    elif t < h:
        hana_point += 3

    else:
        taro_point += 1
        hana_point += 1

print(taro_point, hana_point)

Solution (Python):
N = int(input())
a_score = 0
b_score = 0
for i in range(N):
  a = list(x for x in input().split())
  if a[0] == a[1]:
    a_score += 1
    b_score += 1
  else:
    b = sorted(a)
    if a[0] == b[0]:
      b_score += 3
    else:
      a_score += 3
print(f'{a_score} {b_score}')

Solution (Python):
n=int(input())
a=0
b=0
for i in range(n):
    A,B=map(str,input().split())
    if A>B:
        a+=3
    if A<B:
        b+=3
    if A==B:
        a+=1
        b+=1
print(a,b)

Solution (Python):
x = 0
y = 0
n = int(input())
for i in range(n):
    a, b = map(str,input().split())
    if a > b:
        x += 3
    if a < b:
        y += 3
    if a == b:
        x += 1
        y += 1

print(x,y)

Solution (Python):
n=int(input())
taro=0
hanako=0
for i in range(n):
    a,b=map(str,input().split())
    if a>b:
        taro+=3
    elif a<b:
        hanako+=3
    else :
        taro+=1
        hanako+=1
        
print(taro,hanako)

Solution (Python):
a = int(input())
b = 0
c = 0
for i in range(a):
    d, e = map(str,input().split())
    if d < e :
        c += 3
    elif d > e  :
        b += 3
    else:
        b += 1
        c += 1
print(b,c)

Solution (Python):
n=int(input())
a=0
b=0

for i in range(n):
    card=input().split()
    if card[0]>card[1]:
        a+=3
    elif card[0]<card[1]:
        b+=3
    else:
        a+=1
        b+=1

print(a, b)

Solution (Python):
n = int(input())
taro = 0
hanako = 0
for _ in range(n):
    cards = input().split()
    if cards[0] == cards[1]:
        taro += 1
        hanako += 1
    elif cards == sorted(cards):
        taro += 3
    else:
        hanako += 3
print(hanako, taro)

Solution (Python):


n = int(input())
t_s = 0
h_s = 0
for i in range(n):
  a,b = input().split()
  if a<b:
    h_s+=3
  elif a>b:
    t_s+=3
  else:
    t_s+=1
    h_s+=1
print(t_s, h_s)

Solution (Python):
n = int(input())

i=0
taro=0
hanako=0
while i<n:
  t, h=input().split()
  
  if t>h:
    taro+=3
  
  elif t==h:
    taro+=1
    hanako+=1
  
  elif t<h:
    hanako+=3

  i+=1
  
print(str(taro)+' '+str(hanako))

Solution (Python):
n = int(input())

score = [0,0]
for _ in range(n):
    card = list(map(str, input().split()))
    if card[0] > card[1]:
        score = list(map(lambda x,y: x+y, score, [3,0]))
    elif card[0] < card[1]:
        score = list(map(lambda x,y: x+y, score, [0,3]))
    else:
        score = list(map(lambda x,y: x+y, score, [1,1]))
print(*score)

Solution (Python):

n=int(input())
a=0
b=0
for i in range(n):
    A,B=map(str,input().split())
    if A>B:
        a+=3
    if A<B:
        b+=3
    if A==B:
        a+=1
        b+=1
print(a,b)

Solution (Python):
n = int(input())
t_score = 0
h_score = 0
for _ in range(n):
    taro, hana = input().split()
    if taro > hana:
        t_score+=3
    elif taro < hana:
        h_score+=3
    else:
        t_score+=1
        h_score+=1
print(t_score, h_score)

Solution (Python):
n = int(input())

p_taro = 0
p_hanako = 0

for _ in range(n):
    t, h = input().split()

    if t > h:
        p_taro += 3
    elif h > t:
        p_hanako += 3
    else:
        p_taro += 1
        p_hanako += 1

print(p_taro, p_hanako)

Solution (Python):
n=int(input())
a=0
b=0
for i in range(n):
    A,B=map(str,input().split())
    if A > B :
        a+=3
    if A < B :
        b+=3
    if A == B :
        a+=1
        b+=1
print(a,b)

Solution (Python):
n = int(input())
Taro = 0
Hanako = 0
for i in range(n):
    A,B = input().split()
    if A > B:
        Taro += 3
    elif A < B:
        Hanako += 3
    elif A == B:
        Taro += 1
        Hanako += 1
print(Taro,Hanako)

Solution (Python):
n = int(input())
p1 = 0
p2 = 0

for i in range(n):
    w1, w2 = map(str, input().split())
    
    size = min(len(w1), len(w2))
    
    
    if w1 == w2:
        p1 = p1 + 1
        p2 = p2 + 1
        
        
    elif w1[0:size] == w2[0:size]:
        if len(w1) < len(w2):
            p2 = p2 + 3
        else:
            p1 = p1 + 3
        
        
    else:
        for j in range(size):
            
            if ord(w1[j]) == ord(w2[j]):
                pass
            elif ord(w1[j]) < ord(w2[j]):
                p2 = p2 + 3
                
                break
            else:
                p1 = p1 + 3
                break
        

print(p1, p2)

Solution (Python):

from sys import stdin







n = int(stdin.readline().rstrip())
p_taro = 0
p_hanako = 0

for i in range(n):
  cardsput = stdin.readline().rstrip().split()
  if (cardsput[0] == cardsput[1]):
    p_taro += 1
    p_hanako += 1
  elif (cardsput[0] < cardsput[1]):
    p_hanako += 3
  else:
    p_taro += 3

else:
  print("{0} {1}".format(p_taro, p_hanako))

Solution (Python):
player1, player2 = 0, 0
n = int(input())
for i in range(n):
    card1, card2 = str(input()).split()
    if card1 > card2:
        player1 += 3
    elif card1 < card2:
        player2 += 3
    else:
        player1 += 1
        player2 += 1
print('{} {}'.format(player1, player2))

Solution (Python):
point = [0,0]

n = int(input())

for i in range(n):
    
    a,b = map(str,input().split())
    
    if a == b:
        point[0] += 1
        point[1] += 1
        continue
    
    n2 = min(len(a),len(b))
    
    for i2 in range(n2):
        ac = ord(a[i2])
        bc = ord(b[i2])
        
        if ac > bc:
            point[0] += 3
            break
        elif bc > ac:
            point[1] += 3
            break
        
        if i2 == len(a)-1:
            point[1] += 3
        
        elif i2 == len(b)-1:
            point[0] += 3
            

print(' '.join(map(str,point)))

Solution (Python):
n = int(input())

taro = 0
hana = 0

for x in range(n):
    t, h = list(input().split())
    if t == h:
        taro +=1
        hana +=1
    elif t > h:
        taro +=3
    else:
        hana +=3

print(taro, hana, sep=" ")

Solution (Python):
import sys

input = sys.stdin.readline

def main():
    tarou, hanako = 0,0
    n = int(input())
    for i in range(n):
        s = input().split()
        if s[0] == s[1]:
            tarou += 1
            hanako += 1
        elif s[0] < s[1]:
            hanako += 3
        elif s[0] > s[1]:
            tarou += 3
        
    print(tarou,hanako)
if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
x=0
y=0
for i in range(n):
    a,b=input().split()
    if a<b: y+=3
    elif a==b:
        x+=1
        y+=1
    else: x+=3
print(x,y)

Solution (Python):
def run():
    card_num=int(input())

    player1_point=0
    player2_point=0

    for i in range(card_num):
        card1,card2=input().split()
    
        if card1==card2:
            player1_point+=1
            player2_point+=1
            
        else:
            if card1 == sorted([card1,card2])[1]:
                player1_point+=3
            else:
                player2_point+=3

    print(f"{player1_point} {player2_point}")


run()

Solution (Python):
num=int(input())
lis=[]
staro=0
shanako=0
for x in range(num):
	lis.append(input().split(' '))

for i in lis:
	taro=i[0]
	hanako=i[1]

	if taro > hanako:
		staro+=3

	elif taro < hanako:
		shanako+=3

	else:

		staro+=1
		shanako+=1

print(f"{staro} {shanako}")

Solution (Python):
n=int(input())
h=0
t=0

for _ in range(n):
    x,y=input().split()
    if x<y:
        h+=3
    elif x>y:
        t+=3
    else:
        h+=1 
        t+=1
        
print(t,h)

Solution (Python):
n=int(input())
T=0
H=0

for i in range(n):
    cards_t,cards_h=map(str,input().split())
    
    if cards_t==cards_h:
        T+=1
        H+=1
    elif cards_t>cards_h:
        T+=3
    else:
        H+=3
print(T,H)

Solution (Python):
n=int(input())

taro = 0
hanako = 0

for idx in range(n):
    cc = input().split()

    if cc[0] == cc[1]:
        taro += 1
        hanako += 1
    elif cc[0] < cc[1]:
        hanako += 3
    else:
        taro += 3

print(taro, hanako)

Solution (Python):
n = int(input())
t_score = 0
h_score = 0

for i in range(n):
    cards = list(input().split())
    t_card, h_card = cards[0], cards[1]
    if t_card == h_card:
        t_score += 1
        h_score += 1
    else:
        cards.sort(reverse=True)
        if cards[0] == t_card:
            t_score += 3
        else:
            h_score += 3

print(t_score, h_score)

Solution (Python):
n = int(input())

T = 0
H = 0

for i in range(n) :
    t,h = input().split()
    if t == h :
        T += 1
        H += 1
    elif t>h :
        T += 3
    else :
        H += 3
print(T,H)

Solution (Python):
n=int(input())
t_p,h_p=0,0
for i in range(n):
    t,h=map(str,input().split())
    if t==h:
        t_p+=1
        h_p+=1
    else:
        cmp=[t,h]
        cmp_sort=sorted(cmp)

        if cmp==cmp_sort:
            h_p+=3
        else:
            t_p+=3

print(t_p,h_p)

Solution (Python):
n = int(input())
Taro = 0
Hanako = 0
for i in range(n):
    s = input().split()
    if s[0] > s[1]:
        Taro += 3
    elif s[0] < s[1]:
        Hanako += 3
    else:
        Taro += 1
        Hanako += 1
print(Taro,Hanako)

Solution (Python):
n = int(input())
taro_point, hanako_point = 0, 0
for _ in range(n):
    cards = input().split()
    if cards[0] > cards[1]:
        taro_point += 3
    elif cards[1] > cards[0]:
        hanako_point += 3
    else:
        taro_point += 1
        hanako_point += 1
print(taro_point, hanako_point)

Solution (Python):
n = int(input())
st, sw = 0, 0

for i in range(n):
    wt, wh = input().split()
    if wt > wh:
        st += 3
    elif wt < wh:
        sw += 3
    else:
        st += 1
        sw += 1

print(st, sw)

Solution (Python):
n = int(input())

Data = [input().split() for i in range(n)]

taro = 0
hanako = 0
for a,b in Data:
    if a>b:
        taro += 3
    elif a==b:
        taro += 1
        hanako += 1
    else:
        hanako += 3
print(*[taro, hanako])

Solution (Python):
n = int(input())

p1=0
p2=0

for i in range(n):
    
    a,b = input().split()
    
    if a > b:
        p1 += 3
    elif b > a:
        p2 += 3
    else:
        p1 += 1
        p2 += 1
        
print(p1,p2)

Solution (Python):

n = int(input())
t = 0
h = 0
l = 0
for i in range(n):
    word1 , word2 = map(str,input().split())
    if word1 >= word2:
        l = len(word2)
    else:
        l  = len(word1)
    if word1 == word2:
        t += 1
        h += 1
    elif word1[:l] == word2[:l]:
        if len(word1) > len(word2):
            t += 3
        else:
            h += 3
    else:
        for j in range(l):
            if ord(word1[j]) > ord(word2[j]):
                t += 3
                break
            elif ord(word1[j]) < ord(word2[j]):
                h += 3
                break
print(t,h)

Solution (Python):
sumt=0
sumh=0

n=int(input())
for i in range(n):
    t,h=input().split()
    if t<h:
        sumh+=3
    if t>h:
        sumt+=3
    if t==h:
        sumh+=1
        sumt+=1
print(f'{sumt} {sumh}')

Solution (Python):

tp,hp = 0,0
n = int(input())

for i in range(n):
    t,h = input().split()
    if t>h:
        tp += 3
    elif t<h:
        hp += 3
    elif t==h:
        tp += 1; hp  += 1
        
print(tp,hp)

Solution (Python):
n = int(input())
taro = 0
hanako = 0

for i in range(n):
    t,h = input().split()

    if t > h:
        taro +=3
    elif t < h:
        hanako += 3
    else:
        taro += 1
        hanako += 1

print(taro,hanako)

Solution (Python):



try:
   scores = [0] * 2 
   n = int(input())
   
   for i in range(n):
      cards = []
      animals = input()
      
      
      for j in range(len(animals)):
         if animals[j] == " ":
            sp = j
            break
      
      taro = animals[0 : sp]
      hanako = animals[sp + 1 : len(animals)]
      
      cards = []
      cards.append(taro)
      cards.append(hanako)
      
      
      
      if taro == hanako:
         scores[0] += 1
         scores[1] += 1
      else:
         
         new_cards = sorted(cards)
         if cards[0] == new_cards[0]:
            
            scores[1] += 3
         else:
            
            scores[0] += 3

   print(scores[0], scores[1])

except EOFError:
   pass

Solution (Python):
n = int(input())
taro = 0
hanako = 0
for _ in range(n):
    t, h = input().split()
    if t < h:
        hanako += 3
    elif t == h:
        taro += 1
        hanako += 1
    elif t > h:
        taro += 3
print(taro,hanako)

Solution (Python):



n = int(input())
TP = int()
HP = int()
W=[]
for i in range(n):
    tW,hW = input().split()
    W.append(tW)
    W.append(hW)
    W = sorted(W)
    
    if tW==hW:
        TP += 1
        HP += 1
    elif tW==W[0]:
        HP += 3
    else:
        TP += 3
    
    
    W=[]
print(TP,HP)

Solution (Python):
def resolve():
    n = int(input())
    ans = [0] * 2
    for i in range(n):
        s = input().split()
        if s[0] == s[1]:
            ans[0] += 1
            ans[1] += 1
        elif s[0] < s[1]:
            ans[1] += 3
        else:
            ans[0] += 3
    print(*ans)


resolve()

Solution (Python):
N = int(input())
taro,hanako = 0,0
for i in range(N):
    s,t = input().split()
    if s > t:
        taro += 3
    elif s < t:
        hanako += 3
    else:
        taro += 1
        hanako += 1

print(taro,hanako)

Solution (Python):
num_T = 0
num_H = 0


turnCount = int(input())
for i in range(turnCount):
    T, H = input().split(" ")
    if T == H:
        num_T += 1
        num_H += 1
    elif T > H:
        num_T += 3
    else:
        num_H += 3
    
print(f"{num_T} {num_H}")

Solution (Python):


n=int(input())

Taro=0
Hanako=0

for i in range(n):
    Tcard,Hcard=input().split()
    
    if Tcard==Hcard:
        Taro+=1
        Hanako+=1
    elif Tcard>Hcard:
        Taro+=3
    else:
        Hanako+=3

print(Taro,Hanako)

Solution (Python):
n = int(input())

Taro = 0; Hanako = 0
for i in range(n):
    cards = input().split()
    Tcard = list(cards[0]); Hcard = list(cards[1])
    if Tcard == Hcard:
        Taro += 1
        Hanako += 1
        continue

    for c in range(min(len(Tcard), len(Hcard))):
        if Tcard[c] > Hcard[c]:
            Taro += 3
            break
        elif Tcard[c] == Hcard[c]:
            if c+1 == len(Tcard):
                Hanako += 3
            elif c+1 == len(Hcard):
                Taro += 3
            continue
        elif Tcard[c] < Hcard[c]:
            Hanako += 3
            break
            
print(Taro, Hanako)

Solution (Python):
n = int(input())
taro = hanako = 0
for i in range(n):
    cards = input().split()
    if cards[0] > cards[1]:
        taro += 3
    elif cards[0] < cards[1]:
        hanako += 3
    else:
        taro += 1
        hanako += 1

print(taro, hanako)

Solution (Python):
n = int(input())
t = 0
h = 0
for i in range(n):
    a, b = input().split()
    if a == b:
        t += 1
        h += 1
    elif a > b:
        t += 3
    else:
        h += 3
print(t, h)

Solution (Python):
if __name__ == '__main__':
    game_count = int(input())
    deck_taro = [''] * game_count
    deck_hanako = [''] * game_count
    for i in range(game_count):
        data = [x for x in input().split(' ')]
        deck_taro[i] = data[0]
        deck_hanako[i] = data[1]

    point_taro = 0
    point_hanako = 0
    for i in range(game_count):
        if deck_taro[i] < deck_hanako[i]:
            point_hanako += 3
        elif deck_taro[i] > deck_hanako[i]:
            point_taro += 3
        else:
            point_hanako += 1
            point_taro += 1

    print('{0} {1}'.format(point_taro, point_hanako))

Solution (Python):
n = int(input())
T = 0
H = 0

for _ in range(n):
    a, b = [str(i) for i in input().split()]
    if a == b:
        T += 1
        H += 1
    elif a<b:
        H += 3
    elif a>b:
        T += 3
print(T, H)

Solution (Python):
def card_game():
    n = int(input())
    player1 = 0
    player2 = 0

    for _ in range(n):
        tmp = input().split()
        if tmp[0] > tmp[1]:
            player1 += 3
        elif tmp[0] < tmp[1]:
            player2 += 3
        else:
            player1 += 1
            player2 += 1

    print(f"{player1} {player2}")


if __name__ == "__main__":
    card_game()

Solution (Python):
from string import *

n = int(input())

Ta = []
Ha = []

Taro = 0
Hana = 0

for i in range(n):
    T, H = map(str,input().split())
        
    Ta = []
    Ha = []
        
    Tlen = len(T)
    Tlist = list(T)
    tsum = 0
        
    Hlen = len(H)
    Hlist = list(H)
    hsum = 0
        
    for k in range(Tlen):
        t = ascii_lowercase.find(Tlist[k])
        Ta.append(t)
        
    for k in range(Hlen): 
        h = ascii_lowercase.find(Hlist[k])
        Ha.append(h)
    
    if Ta==Ha :
        Taro += 1
        Hana += 1
        
    else :
        while True:
            
            mojisu = min(Tlen, Hlen)
    
            for j in range(mojisu):
                if Ta[j]>Ha[j]:
                    Taro += 3
                    break
                if Ha[j]>Ta[j]:
                    Hana += 3
                    break
                if Ta[j]==Ha[j]:
                    if j==mojisu-1:
                        if Tlen>Hlen:
                            Taro += 3
                            break
                        if Hlen>Tlen:
                            Hana += 3
                            break
                    pass
            break

print(Taro,Hana)

Solution (Python):
c = int(input())
x=0
y=0

for i in range(c):
    a,b = input().split()
    
    if a > b:
        x+=3
    elif b > a:
        y+=3
    else:
        x+=1
        y+=1
        
print(x, y)

Solution (Python):
N = int(input())
Taro, Hanako = 0, 0

for i in range(N):
    temp_data = list(map(str, input().split()))
    TEMP_data = temp_data.copy()
    TEMP_data.sort(reverse=True)
    if temp_data[0] == temp_data[1]:
        Taro += 1
        Hanako += 1
    else:
        if temp_data[0] == TEMP_data[0]:
            Taro += 3
        elif temp_data[1] == TEMP_data[0]:
            Hanako += 3

print(Taro, Hanako, sep=' ')

Solution (Python):
n = int(input())

t_num=0
h_num=0

for i in range(n):
    tarou, hanako = map(str, input().split())
    
    if tarou > hanako:
        t_num += 3
    elif hanako > tarou:
        h_num +=3
    else:
        t_num += 1
        h_num += 1
print(t_num,h_num)

Solution (Python):
n = int(input())
taro = 0
hanako = 0
for i in range(n):
    s = input().split()
    card_taro = s[0]
    card_hanako = s[1]
    s_sorted = sorted(s)
    if card_taro == card_hanako:
        taro = taro + 1
        hanako = hanako+1
    elif s_sorted.index(card_taro) > s_sorted.index(card_hanako):
        taro = taro + 3
    elif s_sorted.index(card_taro) < s_sorted.index(card_hanako):
        hanako = hanako + 3
    
print(f"{taro} {hanako}")

Solution (Python):
n=int(input())
taro=0
hanako=0
for i in range(n):
    T,H=map(str,input().split())
    if T<H:
        hanako+=3
    elif T>H:
        taro+=3
    else:
        taro+=1
        hanako+=1
print(taro, hanako)

Solution (Python):
n = int(input())
taro_point = 0
hanako_point = 0

for i in range(n):
    taro_card, hanako_card = input().split()
    if taro_card > hanako_card:
        taro_point += 3
    elif taro_card < hanako_card:
        hanako_point += 3
    else:
        taro_point += 1
        hanako_point += 1

print(str(taro_point) + ' ' + str(hanako_point))