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



Sample input:
3
cat dog
fish fish
lion tiger


Sample output:
1 7

Submission status: Accepted

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

taroScore = 0
hanakoScore = 0

for i in range(n):
    sortedCards = sorted(cards[i])
    if cards[i][0] == cards[i][1]:
        taroScore += 1
        hanakoScore += 1
    elif cards[i][0] == sortedCards[0]:
      hanakoScore += 3
    else:
        taroScore += 3

print(taroScore, hanakoScore)

Submission status: Accepted

Solution code:
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_h>card_t:
            H+=3
        else:
            T+=3
print(T,H)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
x, y = 0, 0
for _ in range(n):
    info = input().split()
    if info[0] > info[1]:
        x += 3
    elif info[0] < info[1]:
        y += 3
    else:
        x += 1
        y += 1
print(x, y)

Submission status: Accepted

Solution code:
T,H = 0,0
n = int(input())
for i in range(n):
    S1,S2 = input().split()
    if S1 < S2:
        H += 3
    elif S1 > S2:
        T += 3
    else:
        T += 1
        H += 1
print(T,H)

Submission status: Accepted

Solution code:
n = int(input())
Taro_ans = 0
Hanako_ans = 0
for i in range(n) :
    a, b = list(input().split())
    Taro = list(a)
    Hanako = list(b)
    length = min(len(Taro), len(Hanako))
    for i in range(length) :
        if ord(Taro[i]) > ord(Hanako[i]) :
            Taro_ans += 3
            break
        elif ord(Taro[i]) < ord(Hanako[i]) :
            Hanako_ans += 3
            break
        if i == length -1 :
            if len(Taro) > length :
                Taro_ans += 3
            elif len(Hanako) > length :
                Hanako_ans += 3
            else :
                Taro_ans += 1
                Hanako_ans += 1
print(Taro_ans, Hanako_ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
cards = [input().split() for _ in range(n)]
p_t = 0
p_h = 0
for card in cards:
    if card[0] == card[1]:
        p_t += 1
        p_h += 1
    elif card[0] > card[1]:
        p_t += 3
    else:
        p_h += 3
print(p_t, p_h)

Submission status: Accepted

Solution code:
turn = int(input())
tp, hp = 0, 0
for i in range(turn):
    t, h = input().split()
    if t == h:
        tp += 1
        hp += 1
    elif t > h:
        tp += 3
    elif t < h:
        hp += 3
print(tp, hp)

Submission status: Accepted

Solution code:
#9_C
class player:
    def __init__(self):
        self.my_cards=[]
        self.point=0
    def draw(self,letter):
        self.my_cards.append(letter)

    def open(self,num):
        return self.my_cards[num]
    
    def buttle(self,letter,num):
        if(self.my_cards[num]>letter):
            self.point+=3
        elif(self.my_cards[num]==letter):
            self.point+=1
            
    def show(self):
        return self.point
    def check(self):
        return self.my_cards

##main##
n=int(input())
taro=player()
hanako=player()
for i in range(n):
    val=input().split()
    taro.draw(val[0])
    hanako.draw(val[1])
for i in range(n):
    taro.buttle(hanako.open(i),i)
    hanako.buttle(taro.open(i),i)
    
print(taro.show(),hanako.show())

Submission status: Accepted

Solution code:
def main(listseq):
    x = y = 0
    for strings in listseq:
        a, b = strings.split(" ")
        if a < b: y += 3
        elif a > b: x += 3
        elif a == b: x += 1; y += 1
    return x, y


times = int(input())
words = [input() for _ in range(times)]
a, b = main(words)
print(f"{a} {b}")

Submission status: Accepted

Solution code:
n = int(input())
Tp = 0
Hp = 0
tmp = "abcdefghijklmnopqrstuvwxyz"
alph = list(tmp)

for i in range(n):
    Ta,Ha = input().split()
    lTa = list(Ta)
    lHa = list(Ha)
    num = 0

    if (len(Ta) <= len(Ha)):  #definition of num
        num = len(Ta)

    else:
        num = len(Ha)

    if (Ta in Ha and lTa[0] == lHa[0]): #drow a
        if (Ta == Ha):
            Tp += 1
            Hp += 1
        else:
            Hp += 3

    elif (Ha in Ta and Ha != Ta and lTa[0] == lHa[0]):
        Tp += 3


    else:
        for i in range(len(lTa)):  # convert alphabet to number
            for j in range(26):
                if (lTa[i] == alph[j]):
                    lTa[i] = int(j)

                else :
                    continue

        for i in range(len(lHa)):  # convert alphabet to number
            for j in range(26):
                if (lHa[i] == alph[j]):
                    lHa[i] = int(j)

                else :
                    continue

        for i in range(num):
            if (lTa[i] < lHa[i]):
                Hp +=3
                break
            elif (lHa[i] < lTa[i]):
                Tp +=3
                break
            elif (lHa[i] == lTa[i]):
                continue

print(Tp,Hp)

Submission status: Accepted

Solution code:
N=int(input())
right=0
left=0
for i in range(N):
    a,b=input().split()
    if a>b:
        left+=3
    elif a<b:
        right+=3
    else:
        left+=1
        right+=1
print(f"{left} {right}")

Submission status: Accepted

Solution code:
from enum import Enum

class Type(Enum):
    win_Taro = 0
    win_Hanako = 1
    Even = 2

def comp_str(A, B):
    if A > B:
        return Type.win_Taro
    elif A < B:
        return Type.win_Hanako
    else:
        return Type.Even

N = int(input())

point_Taro = 0
point_Hanako = 0

for loop in range(N):
    line = str(input()).split()
    ret_type = comp_str(line[0], line[1])
    if ret_type == Type.win_Taro:
        point_Taro += 3
    elif ret_type == Type.win_Hanako:
        point_Hanako += 3
    else:
        point_Taro += 1
        point_Hanako += 1

print("%d %d"%(point_Taro, point_Hanako))

Submission status: Accepted

Solution code:
taro = 0
hanako = 0

n = int(input())
for i in range(n):
    t, h = input().split()
    if t < h:
        hanako += 3
    elif t == h:
        taro += 1
        hanako += 1
    elif h < t:
        taro += 3
print("%d %d" % (taro, hanako))

Submission status: Accepted

Solution code:
n=int(input())
tp=0
hp=0
for i in range(n):
  taro,hanako=(str(buff) for buff in input().split())
  if taro>hanako:
    tp+=3
  elif taro<hanako:
    hp+=3
  else:
    tp+=1
    hp+=1
print(tp,hp)

Submission status: Accepted

Solution code:
n = int(input())

t, h = 0, 0

for i in range(n):
    s1, s2 = input().split()
    if s1 > s2:
        t += 3
    elif s1 < s2:
        h += 3
    else:
        t += 1
        h += 1

print(t, h)

Submission status: Accepted

Solution code:
n = int(input())
count_taro = 0
count_hanako = 0
for i in range(n):
  taro,hanako = map(str, input().split())
  if taro > hanako:
    count_taro += 3
  if hanako > taro:
    count_hanako += 3
  if hanako == taro:
    count_hanako += 1
    count_taro += 1
print(count_taro, count_hanako)

Submission status: Accepted

Solution code:
n=int(input())
m=0
l=0
for i in range(n):
    a=[]
    x,y=map(str,input().split())
    a.append(x)
    a.append(y)
    b=sorted(a)
    if x==y:
        m+=1
        l+=1
    else:
        if x==b[1]:
            m+=3
        elif y==b[1]:
            l+=3
print(m,l)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

t=0
h=0

for j in c:
    if j[0]>j[1]:
        t+=3
    elif j[0]<j[1]:
        h+=3
    else:
        t+=1
        h+=1
print(t, h)

Submission status: Accepted

Solution code:
while True:
    try:
        a = int(input())
        t=0
        h=0
        for i in range(a):
            b,c=input().split()
            if b>c:
                t+=3
            elif c>b:
                h+=3
            else:
                t+=1
                h+=1
        print(t,h)
    except EOFError:break

Submission status: Accepted

Solution code:
n = int(input())
T = 0
H = 0
for _ in range(n):
    t, h = map(str, input().split())
    if t > h:
        T += 3
    elif t < h:
        H += 3
    else:
        T += 1
        H += 1
print(T, H)

Submission status: Accepted

Solution code:
turn=int(input())
duel=[input().split(" ")for i in range(turn)]
point=[0,0]
for i in duel:
    if i[0]==i[1]:
        point[0],point[1]=point[0]+1,point[1]+1
    if i[0]>i[1]:
        point[0]+=3
    if i[0]<i[1]:
        point[1]+=3
print(" ".join(map(str,point)))

Submission status: Accepted

Solution code:
n = int(input())
ta = 0
ha = 0

for i in range(n):
    taha = list(map(str, input().split()))
    jud = sorted(taha)
    #print(taha)
    #print(jud)
    if taha[0] == taha[1]:
        ta += 1
        ha += 1
    
    elif taha[0] == jud[0]:
        ha += 3

    else:
        ta += 3

print("{} {}" .format(ta, ha))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
r = s = 0
for i in range(n):
  a, b = input().split()
  if a > b:
    r += 3
  elif a < b:
    s += 3
  else:
    r += 1; s += 1
print(r,s)

Submission status: Accepted

Solution code:
N = int(input())
tarou = 0
hanako = 0
for _ in range(N):
    t,h = input().split()
    if t == h:
        tarou += 1
        hanako += 1
    elif [t,h] != sorted([t,h]):
        tarou += 3
    else:
        hanako += 3
print(tarou, hanako)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
# 9_C
n = int(input())
score_t, score_h = 0, 0
for i in range(n):
    t, h = input().split()
    if t > h:
        score_t += 3
    elif h > t:
        score_h += 3
    else:
        score_t += 1
        score_h += 1
print(f"{score_t} {score_h}")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

Submission status: Accepted

Solution code:
n = int(input())
t_co = h_co = 0

for i in range(n):
    t_str, h_str = list(map(str, input().split()))
    
    if t_str > h_str:
        t_co += 3
    
    elif h_str == t_str:
        t_co += 1
        h_co += 1
    else:
        h_co += 3
        
print(t_co, h_co)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
taro = 0
hana = 0
for i in range(n):
    val = list(input().split())
    if val[0]<val[1]:
        hana += 3
    elif val[0]>val[1]:
        taro += 3
    else:
        taro += 1
        hana += 1
print(taro,hana,sep=' ')

Submission status: Accepted

Solution code:

loop = int(input())
ans = [0, 0]
for _ in range(loop):
    
    arr = input().split()
    
    if arr[0] > arr[1]:
        ans[0] += 3
    elif arr[0] < arr[1]:
        ans[1] += 3
    else:
        ans[0] += 1
        ans[1] += 1

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

Submission status: Accepted

Solution code:
n=int(input())
t=0
h=0
for i in range(n):
    taro,hana=map(str,input().split())
    if taro>hana:
        t+=3
    elif hana>taro:
        h+=3
    else:
        h+=1
        t+=1
print("%s %d"%(t,h))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input());
x = 0;
y = 0;
for i in range(0,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);

Submission status: Accepted

Solution code:
n=int(input())
alpha='abcdefghijklmnopqrstuvwxyz'
t,h=0,0
for i in range(n):
    x,y=map(str,input().split())
    if x==y:
        t+=1
        h+=1
    elif x<y:
        h+=3
    else:
        t+=3
print(t,h)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a=int(input())
sum1=0
sum2=0
for i in range(a):
    b,c=input().split()
    if b>c:
        sum1+=3
    elif b<c:
        sum2+=3
    else:
        sum1+=1
        sum2+=1
print("{} {}".format(sum1,sum2))

Submission status: Accepted

Solution code:
n=int(input())
s=0
t=0
for i in range(n):
    a,b=input().split()
    if a==b:
        s+=1
        t+=1
    elif a>b:
        s+=3
    elif b>a:
        t+=3
print(f'{s} {t}')

Submission status: Accepted

Solution code:
n = int(input())
taro, hanako = 0, 0
for _ in range(n):
    
    data = input().split()
    if data[0] > data[1]:
        taro += 3
    elif data[0] < data[1]:
        hanako += 3
    else:
        hanako += 1
        taro += 1
        
print(taro, hanako)

Submission status: Accepted

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

p_taro = 0
p_hanako = 0

#Pythonでは辞書で後ろの方にある方が大きい扱い
# "a" < "b" = True

for i in range(n):
    if cards[i][0] > cards[i][1]:   #太郎が花子に勝った時
        p_taro += 3
    elif cards[i][0] < cards[i][1]:
        p_hanako += 3
    else:
        p_taro += 1
        p_hanako += 1
print(p_taro, p_hanako)

Submission status: Accepted

Solution code:
n=int(input())
out=[0,0]
for _ in range(n):
    lst=input().split()
    if lst[0]==lst[1] :
        out[0]+=1
        out[1]+=1
    elif lst[0]<lst[1]:
        out[1]+=3
    else : out[0]+=3

print(" ".join(map(str,out)))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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)

Submission status: Accepted

Solution code:
total_cards = int(input())

taro_score = 0
hanako_score = 0

for _ in range(total_cards):
    taro_card, hanako_card = input().split()
    
    if taro_card > hanako_card:
        taro_score += 3
    
    if hanako_card > taro_card:
        hanako_score += 3
    
    if hanako_card == taro_card:
        taro_score += 1
        hanako_score += 1

print(str(taro_score) + " " + str(hanako_score))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())

    score_t = 0
    score_h = 0
    for _ in range(n):
        t, h = map(str, input().split())
        if t == h:
            score_t += 1
            score_h += 1
        if t > h:
            score_t += 3
        if h > t:
            score_h += 3
    print(score_t, score_h)


resolve()

Submission status: Accepted

Solution code:
n = int(input())
t_won = 0
h_won = 0
#Pythonでは文字列の辞書順での大小関係を比較演算子を使って比較可能
#比較を行い、太郎と花子それぞれの勝ち数をカウント
for i in range(n):
    t_wd,h_wd = input().split()
    if   t_wd > h_wd:
        t_won += 1
    elif t_wd < h_wd:
        h_won += 1

#    print(t_won)
#    print(h_won)
#    print(n-t_won-h_won)
#    print()

print(t_won*3 + (n-t_won-h_won), h_won*3 + (n-t_won-h_won))
#勝ったら3pointなので*3
#n-t_won-h_wonで引き分け分を足す

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#61 カードゲーム

n = int(input())
a1 = b1 = 0

for i in range(n):
    
    a,b = input().split()
    
    if a > b:
        a1 += 3
        
    elif a < b:
        b1 += 3
        
    elif a == b:
        a1 += 1
        b1 += 1
        
print(a1, b1)

Submission status: Accepted

Solution code:
n = int(input())
ts, hs = 0, 0
for i in range(n):
    t, h = input().split()
    if t > h:
        ts += 3
    elif t < h:
        hs += 3
    elif t == h:
        ts += 1; hs += 1
print(str(ts) + ' ' + str(hs))

Submission status: Accepted

Solution code:
n = int(input())
cards = [input().split() for _ in range(n)]

t = 0
h = 0

for card in cards:
    if card[0] > card[1]:
        t += 3
    elif card[0] < card[1]:
        h += 3
    else:
        t += 1
        h += 1
print(t, h)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, *C = open(0).read().split()
N = int(N)
a = b = 0
for i in range(0, len(C), 2):
    c1 = C[i]
    c2 = C[i+1]
    if c1 == c2:
        a += 1
        b += 1
    elif c1 > c2:
        a += 3
    else:
        b += 3
print(a, b)

Submission status: Accepted

Solution code:
n = int(input())

taro = 0
hanako = 0

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
cards = [input() for _ in range(n)]
t = 0
h = 0
for card in cards:
  c = card.split(' ')
  i = 0
  while True:
    l, r = [0, 0]
    if i < len(c[0]):
      l = ord(c[0][i])
    if i < len(c[1]):
      r = ord(c[1][i])
    if l == 0 and r == 0:
      t += 1
      h += 1
      break
    if r < l:
      t += 3
      break
    elif l < r:
      h += 3
      break
    i += 1
print("{0} {1}".format(t, h))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
card = [input().split() for _ in range(n)]
t = 0
h = 0
for i in range(n):
    if card[i][0] == card[i][1]:
        t += 1
        h += 1
    elif card[i][0] < card[i][1]:
        h += 3
    elif card[i][0] > card[i][1]:
        t += 3
print(f'{t} {h}')

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-

def main():
    turns = int(input())
    animals=[]
    scores=[0,0]
    for _ in range(turns):
        animals=list(input().split())
        if animals[0]==animals[1]:
            scores[0]+=1
            scores[1]+=1
        elif  animals[0]>animals[1]:
            scores[0]+=3
        else:
            scores[1]+=3
    print(*scores)

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
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}")

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:

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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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}')

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
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}")

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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}")

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)