Problem:

Finding Missing Cards

  Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).

The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.

Input

  In the first line, the number of cards n (n ≤ 52) is given.

  In the following n lines, data of the n cards are given. Each card is given by a pair of a character and an integer which represent its suit and rank respectively. A suit is represented by 'S', 'H', 'C' and 'D' for spades, hearts, clubs and diamonds respectively. A rank is represented by an integer from 1 to 13.

Output

  Print the missing cards. The same as the input format, each card should be printed with a character and an integer separated by a space character in a line.
 Arrange the missing cards in the following priorities:

Print cards of spades, hearts, clubs and diamonds in this order.

If the suits are equal, print cards with lower ranks first.

Sample Input

47
S 10
S 11
S 12
S 13
H 1
H 2
S 6
S 7
S 8
S 9
H 6
H 8
H 9
H 10
H 11
H 4
H 5
S 2
S 3
S 4
S 5
H 12
H 13
C 1
C 2
D 1
D 2
D 3
D 4
D 5
D 6
D 7
C 3
C 4
C 5
C 6
C 7
C 8
C 9
C 10
C 11
C 13
D 9
D 10
D 11
D 12
D 13

Sample Output

S 1
H 3
H 7
C 12
D 8

Note

      解説      

	



Sample input:
47
S 10
S 11
S 12
S 13
H 1
H 2
S 6
S 7
S 8
S 9
H 6
H 8
H 9
H 10
H 11
H 4
H 5
S 2
S 3
S 4
S 5
H 12
H 13
C 1
C 2
D 1
D 2
D 3
D 4
D 5
D 6
D 7
C 3
C 4
C 5
C 6
C 7
C 8
C 9
C 10
C 11
C 13
D 9
D 10
D 11
D 12
D 13


Sample output:
S 1
H 3
H 7
C 12
D 8

Submission status: Accepted

Solution code:
n = int(input())
S = [1,2,3,4,5,6,7,8,9,10,11,12,13]
C = [1,2,3,4,5,6,7,8,9,10,11,12,13]
H = [1,2,3,4,5,6,7,8,9,10,11,12,13]
D = [1,2,3,4,5,6,7,8,9,10,11,12,13]

for i in range(n):
    variations,number = input().split()
    if variations == 'S':
        S.remove(int(number))
    if variations == 'C':
        C.remove(int(number))
    if variations == 'H':
        H.remove(int(number))
    if variations == 'D':
        D.remove(int(number))

for i in range(len(S)):
    print('{} {}'.format('S',S[i]))

for i in range(len(H)):
    print('{} {}'.format('H',H[i]))

for i in range(len(C)):
    print('{} {}'.format('C',C[i]))

for i in range(len(D)):
    print('{} {}'.format('D',D[i]))

Submission status: Accepted

Solution code:
n = int(input())
cards = [[False for i in range(13)] for j in range(4)] #二次元配列を作る
pattern = ["S", "H", "C", "D"] #スート
for i in range(n):
    st, rank = input().split()
    cards[pattern.index(st)][int(rank)-1] = True #入力と表示を別にする
    
for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i], j+1)

Submission status: Accepted

Solution code:
n=int(input())
a=list()
b=["S","H","C","D"]

for i in range(n):
    s,r=input().split()
    r=int(r)
    if s=="S":
        a.append(0+r)
    elif s=="H":
        a.append(13+r)
    elif s=="C":
        a.append(26+r)
    elif s=="D":
        a.append(39+r)
for k in range(1,53):
    if not k in a:
        print(b[(k-1)//13],(k-1)%13+1)

Submission status: Accepted

Solution code:
cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]

num_lines = int(input())

for i in range(num_lines):
    line = input().split()
    cards[pattern.index(line[0])][int(line[1]) - 1] = True

for mark in range(4):
    for j in range(13):
        if cards[mark][j] == False:
            print(pattern[mark], j+1)

Submission status: Accepted

Solution code:
d = dict()
for i in "HSDC":
    d[i] = set()
for _ in range(int(input())):
    mark,num = input().split()
    d[mark].add(int(num))
for i in "SHCD":
    for j in range(1,14):
        if j not in d[i]:
            print(i,j)

Submission status: Accepted

Solution code:
N = int(input()) #手持ちのカード枚数

cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]
'''
0: S
1: H
2: C
3: D
'''
for n in range(N):
    ch,rank = input().split()
    rank = int(rank)
    cards[pattern.index(ch)][rank-1] = True

for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i], j+1)

Submission status: Accepted

Solution code:
#ITP1_6_B

card = [[False for i in range(13)] for j in range(4)]
suit = ["S", "H", "C", "D"]

n = int(input())
for i in range(n):
    si, sn = input().split()
    card[suit.index(si)][int(sn) - 1] = True

for i in range(4):
    for j in range(13):
        if card[i][j] == False:
            print(suit[i], j + 1)

Submission status: Accepted

Solution code:
cards = []

for i in range(13):
    cards.append('S {0}'.format(i + 1))

for i in range(13):
    cards.append('H {0}'.format(i + 1))

for i in range(13):
    cards.append('C {0}'.format(i + 1))

for i in range(13):
    cards.append('D {0}'.format(i + 1))


n = int(input())
for _ in range(n):
    card = input()
    if card in cards:
        cards.remove(card)

for _ in range(len(cards)):
    print(cards[_])

Submission status: Accepted

Solution code:
n = int(input())

cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]

for i in range(n):
    ch, rank = map(str, input().split())
    cards[pattern.index(ch)][int(rank) - 1] = True

for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i], j + 1)

Submission status: Accepted

Solution code:
n = int(input())

lst=[]
for i in range(n):
    s, r = input().split()
    r = int(r)-1
    if   s=="H":
        r += 13
    elif s=="C":
        r += 26
    elif s=="D":
        r += 39
    lst.append(r)

for i in range(52):
    if not (i in lst):
        ss = i // 13
        if   ss==0:
            print("S", i % 13 + 1)
        elif ss==1:
            print("H", i % 13 + 1)
        elif ss==2:
            print("C", i % 13 + 1)
        else:
            print("D", i % 13 + 1)

Submission status: Accepted

Solution code:
S=[False,False,False,False,False,False,False,False,False,False,False,False,False]
H=[False,False,False,False,False,False,False,False,False,False,False,False,False]
C=[False,False,False,False,False,False,False,False,False,False,False,False,False]
D=[False,False,False,False,False,False,False,False,False,False,False,False,False]
n=int(input())

for i in range(n):
    data=input().split()
    num=int(data[1])
    
    if(data[0]=='S'):
        S[num-1]=True
    if(data[0]=='H'):
        H[num-1]=True
    if(data[0]=='C'):
        C[num-1]=True
    if(data[0]=='D'):
        D[num-1]=True

for i in range(13):
    if not S[i]:
        print('S',i+1)
        
for i in range(13):
    if not H[i]:
        print('H',i+1)

for i in range(13):
    if not C[i]:
        print('C',i+1)

for i in range(13):
    if not D[i]:
        print('D',i+1)

Submission status: Accepted

Solution code:
suits = ['S','H','C','D']

table = [[False]*14 for i in range(4)]

n = int(input())

for loop in range(n):
  mark,num = input().split()

  num = int(num)

  if mark == 'S':
    table[0][num] = True
  elif mark == 'H':
    table[1][num] = True
  elif mark == 'C':
    table[2][num] = True
  else:
    table[3][num] = True

for i in range(4):
  for j in range(1,14):
    if table[i][j] == False:
      print(suits[i], j)

Submission status: Accepted

Solution code:
suit = ["S","H","C","D"]
num=[]

for i in range(1,14):
    num.append(i)

li=[]
for i in suit:
    for j in num:
        li.append(i+" "+str(j))

n=int(input())

for i in range(n):
    sn=str(input())
    if (sn in li):
        li.remove(sn)

for i in range(len(li)):
    print(li[i])

Submission status: Accepted

Solution code:
cards = [[False for i in range(13)] for i in range(4)]
pattern = ['S', 'H', 'C', 'D']

N = int(input())
for i in range(N):
    p = input()
    ch,b = p.split()
    num = int(b)
    cards[pattern.index(ch)][num-1] = True

for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print('{0} {1}'.format(pattern[i], j+1))

Submission status: Accepted

Solution code:
cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]

N=int(input())
i=0
while i<N:
    gara,num=input().split()
    num=int(num)
    cards[pattern.index(gara)][num-1] = True
    i+=1
for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i], j+1)

Submission status: Accepted

Solution code:
n = int(input())
count = 0
pattern = ['S', 'H', 'C', 'D']
cards = [[ False for i in range(13)] for j in range(4)]#初期値
while count < n:
    ch, rank = input().split(' ')
    rank = int(rank)
    cards[pattern.index(ch)][rank - 1] = True
    count += 1


for j in range(4):
    for i in range(13):
        if cards[j][i] == False:
            print(pattern[j], str(i + 1))

Submission status: Accepted

Solution code:
#配列のすべての要素に-1を代入
S = [-1] * 13
H = [-1] * 13
C = [-1] * 13
D = [-1] * 13

#照合
n = int(input())
for i in range(n):
    x = input().split()
    mark = x[0]
    num = int(x[1])
    if mark == 'S':
        S[(num-1)] = 1
    elif mark == 'H':
        H[(num-1)] = 1
    elif mark == 'C':
        C[(num-1)] = 1
    else:
        D[(num-1)] = 1

#表示
for i in range(13):
    if S[i] == -1:
        print('S', (i+1))
for i in range(13):
    if H[i] == -1:
        print('H', (i+1))
for i in range(13):      
    if C[i] == -1:
        print('C', (i+1))
for i in range(13):
    if D[i] == -1:
        print('D', (i+1))

Submission status: Accepted

Solution code:


cards = [[False for i in range(14)] for m in range(4)]

pattern = ["S", "H", "C", "D"]

N = int(input())

for j in range(N):
	
	mark,num = input().split()
	num = int(num)
	
	if mark== 'S':
		cards[0][num] = True
	
	elif mark=='H':
		cards[1][num] = True
	
	elif mark=='C':
		cards[2][num] = True
	
	else:
		cards[3][num] = True
		
for k in range(4):
	for l in range(1,14):
		if cards[k][l] == False:
			print(f"{pattern[k]} {l}")

Submission status: Accepted

Solution code:
"""
title:不足しているカードの発見
memo:
for文で
print(記号, カード番号)で出力すると
求められている出力の形になる
"""
from collections import defaultdict
N = int(input())
# input_cards = [int(input()) for x in range(n)]
input_cards = []  # inputデータを保存
correct_list = []  # トランプのリスト

for i in range(N):  # 入力カードのリストを作成
    suit, num = map(str, input().split())
    input_cards.append(suit + "_" + num)
# print(input_cards)
card_suits = ["S", "H", "C", "D"]  # 出力もこの順で返す
for i in card_suits:  # 本来あるべきカードの組み合わせ（52枚）のデッキのリスト
    for j in range(1, 14):
        correct_list.append(i + "_" + str(j))

diff_list = set(correct_list) - set(input_cards)  # 足りないカードのリストを作成
# print(diff_list)
# print(type(diff_list))
S, H, C, D = [], [], [], []
for i in diff_list:  # diff_listの中からS, H, C, Dの順にカードを取り出す
    if i[0] == "S":
        S.append(int(i[2:]))
    elif i[0] == "H":
        H.append(int(i[2:]))
    elif i[0] == "C":
        C.append(int(i[2:]))
    elif i[0] == "D":
        D.append(int(i[2:]))

S = sorted(S)
H = sorted(H)
C = sorted(C)
D = sorted(D)
# print(S, H, C, D)

for i in S:
    print("S " + str(i))
for i in H:
    print("H " + str(i))
for i in C:
    print("C " + str(i))
for i in D:
    print("D " + str(i))

Submission status: Accepted

Solution code:
n = int(input())

card = []

for i in range(n):
    card.append(list(map(str, input().split())))
    
ans = []

for i in range(1, 14):
    if not ['S', str(i)] in card:
        ans.append(['S', str(i)])
        
for i in range(1, 14):
    if not ['H', str(i)] in card:
        ans.append(['H', str(i)])
        
for i in range(1, 14):
    if not ['C', str(i)] in card:
        ans.append(['C', str(i)])
        
for i in range(1, 14):
    if not ['D', str(i)] in card:
        ans.append(['D', str(i)])
for i in range(len(ans)):
    print(ans[i][0] + ' ' + ans[i][1])

Submission status: Accepted

Solution code:
n = int(input())
S = [a for a in range(1,14)]
H = [b for b in range(1,14)]
C = [c for c in range(1,14)]
D = [d for d in range(1,14)]
for i in range(n):
    mark,num = input().split()
    if mark == "S":
        S.remove(int(num))
    elif mark == "H":
        H.remove(int(num))
    elif mark == "C":
        C.remove(int(num))
    elif mark == "D":
        D.remove(int(num))
for s in S:
    print("S {}".format(s))
for h in H:
    print("H {}".format(h))
for c in C:
    print("C {}".format(c))
for d in D:
    print("D {}".format(d))

Submission status: Accepted

Solution code:
mark = ['S','H','C','D']
card ={ (n,format(k)):0 for n in mark for k in range(1,14)}
n = int(input())
for num in range(n):
    card[tuple(input().split())] = 1
for m ,n in card.items():
    if n == 0:
        k,j = m
        print( "{} {}".format(k,j))

Submission status: Accepted

Solution code:
cards = list(range(1, 53))
n = int(input())

for i in range(n):
  mark, num = input().split()
  if mark == 'H':
    cards.remove(int(num) + 13)
  elif mark == 'C':
    cards.remove(int(num) + 26)
  elif mark == 'D':
    cards.remove(int(num) + 39)
  else:
    cards.remove(int(num))

for card in cards:
  if card > 39:
    mark = 'D'
    card -= 39
  elif card > 26:
    mark = 'C'
    card -= 26
  elif card > 13:
    mark = 'H'
    card -= 13
  else:
    mark = 'S'
  print(mark, str(card))

Submission status: Accepted

Solution code:
cards = {}
for i in ['S', 'H', 'C', 'D']:
    cards.setdefault(i, [])
n = input()
for i in range(int(n)):
    suit, rank = input().split()
    cards[suit].append(rank)
for suit in cards.keys():
    if len(cards[suit]) != 13:
        print('\n'.join([f'{suit} {rank}' for rank in range(1, 14, 1) if str(rank) not in cards[suit]]))

Submission status: Accepted

Solution code:
n=int(input())
card_list=[input() for i in range(n)]
for suit in ["S","H","C","D"]:
    for number in range(1, 14):
        card_check=suit+" "+str(number)
        if not(card_check in card_list):print(card_check)

Submission status: Accepted

Solution code:
cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]

N = int(input())
for g in range(N):
    ch, rank = input().split()
    rank = int(rank)
    cards[pattern.index(ch)][rank-1] = True
for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i], j+1)

Submission status: Accepted

Solution code:
suits = ['S','H','C','D']

table = [[False]*14 for i in range(4)]

N = int(input())

for loop in range(N):

    mark,num = input().split()
    num = int(num)

    if mark == 'S':
        table[0][num] = True
    elif mark == 'H':
        table[1][num] = True
    elif mark == 'C':
        table[2][num] = True
    else:
        table[3][num] = True

for i in range(4):
    for k in range(1,14):
        if table[i][k] == False:
            print("%s %d"%(suits[i],k))

Submission status: Accepted

Solution code:
n = int(input())
a = []

for i in range(n):
    x,y = input().split()
    z = int(y)
    if x == "S":
        a.append(z + 0)
    elif x == "H":
        a.append(z + 13)
    elif x == "C":
        a.append(z + 26)
    elif x == "D":
        a.append(z + 39)

for i in range(1,53):
    if not i in a:
        if i <= 13:
            print("S {}".format(i))
        elif i <= 26:
            print("H {}".format(i - 13))
        elif i <= 39:
            print("C {}".format(i - 26))
        elif i <= 52:
            print("D {}".format(i - 39))

Submission status: Accepted

Solution code:
def main():
    cards = {
        'S': [0] * 13,
        'H': [0] * 13,
        'C': [0] * 13,
        'D': [0] * 13
    }

    n = int(input())
    for _ in range(n):
        a, b = input().split()
        cards[a][int(b) - 1] = 1

    for a, b in cards.items():
        for i in range(13):
            if b[i] == 0:
                print(a, i + 1)


main()

Submission status: Accepted

Solution code:
# coding: utf-8
n = int(input())
cards = [[True for i in range(13)] for j in range(4)] #j = 0 S, j = 1 H, j = 2 C, j = 3 D
for i in range(n):
    line = input().rstrip().split()
    if line[0] == "S":
        mark = 0
    elif line[0] == "H":
        mark = 1
    elif line[0] == "C":
        mark = 2
    else:
        mark = 3
    cards[mark][int(line[1]) - 1] = False

for i in range(4):
    for j in range(13):
        if cards[i][j] == True:
            if i == 0:
                print("S", end=" ")
            elif i == 1:
                print("H", end=" ")
            elif i == 2:
                print("C", end=" ")
            else:
                print("D", end=" ")
            print(j+1)

Submission status: Accepted

Solution code:
card_num = int(input())
all_cards = {(st, num) for st in 'SHCD' for num in range(1, 14)}
your_cards = set()

for _ in range(card_num):
    st, num = input().split()
    your_cards.add((st, int(num)))

rest = all_cards - your_cards
for st, num in sorted(rest, key=lambda c: ('SHCD'.index(c[0]), c[1])):
    print(st, num)

Submission status: Accepted

Solution code:
n = int(input())
n_card = list(range(1, 14))
card = {'S':n_card.copy(), 'H':n_card.copy(), 'C':n_card.copy(), 'D': n_card.copy()}
for i in range(n):
    s, val = input().split()
    val = int(val)
    card[s].remove(val)
for k in 'SHCD':
    for item in card[k]:
        print(k, item)

Submission status: Accepted

Solution code:
n = int(input())
cards = []
for i in range(n):
    s, a = input().split()
    cards.append((s, int(a)))
l = [(s, a) for s in "SHCD" for a in range(1,14) if (s,a)not in cards]
for s, a in l:
    print(s + " " + str(a))

Submission status: Accepted

Solution code:
N = int(input())
x = [f"{x} {i}" for x in 'SHCD' for i in range(1,14) ]
[x.remove(input()) for i in range(N)]
for i in x:
    print(i)

Submission status: Accepted

Solution code:
i=input
l={i()for _ in[0]*int(i())}
for j in [f'{a} {b}'for a in'SHCD'for b in range(1,14)if f'{a} {b}'not in l]:print(j)

Submission status: Accepted

Solution code:
def suit2num(suit):
    if suit == 'S':
        return 0
    elif suit == 'H':
        return 1
    elif suit == 'C':
        return 2
    elif suit == 'D':
        return 3

def num2suit(num):
    if num == 0:
        return 'S'
    elif num == 1:
        return 'H'
    elif num == 2:
        return 'C'
    elif num == 3:
        return 'D'

num = int(input())
card = [[0 for i in range(13)] for j in range(4)]

while num > 0:
    list = input().split()
    a = suit2num(list[0])
    b = int(list[1]) - 1
    card[a][b] = 1
    num -= 1

for i in range(4):
    for j in range(13):
        if card[i][j] == 0:
            print(num2suit(i), j + 1)

Submission status: Accepted

Solution code:
n = int(input())

card = [[], [], [], []]
for x in range(n):
    mark, num = map(str, input().split())
    num = int(num) - 1
    if mark == "S":
        mark = 0
    elif mark == "H":
        mark = 1
    elif mark == "C":
        mark = 2
    else:
        mark = 3

    card[mark].append(num)

for x in range(4):
    if x == 0:
        mark= "S"
    elif x == 1:
        mark = "H"
    elif x == 2:
        mark = "C"
    else:
        mark = "D"
    for y in range(13):
        if y not in card[x]:
            print(mark, y + 1)

Submission status: Accepted

Solution code:
SUITS = ('S', 'H', 'C', 'D')
cards = {suit:{i for i in range(1, 14)} for suit in SUITS}

n = input() # 読み捨て
for i in range(int(n)): 
    suit, number = input().split()
    cards[suit].discard(int(number))

for suit in SUITS:
    for i in cards[suit]:
        print(suit, i)

Submission status: Accepted

Solution code:
a=input()
b=int(a)
check_list=list()
for i in range(b):
    c=input()
    d=c.split()
    mark=d[0]
    if mark=="S":
        check_list.append(int(d[1]))
    elif mark=="H":
        check_list.append(int(d[1])+13)
    elif mark=="C":
        check_list.append(int(d[1])+26)
    elif mark=="D":
        check_list.append(int(d[1])+39)
for i in range(1,53):
    if i in check_list:
        pass
    elif not (i in check_list):
        if i<=13:
            print("S",i)
        elif 13<i<=26:
            print("H",i-13)
        elif 26<i<=39:
            print("C",i-26)
        else:
            print("D",i-39)

Submission status: Accepted

Solution code:
suit = "H"
cou_car = int(input())
exist_flg = [[True for i in range(13)] for j in range(4)]
for i in range(cou_car):
    disc = input()
    disc_car = disc.split(" ")
    disc_num =int(disc_car[1])
    disc_sui = disc_car[0]
    num_suit = 5
    if disc_sui == "S":
        num_suit = 0
    elif disc_sui == "H":
        num_suit = 1
    elif disc_sui == "C":
        num_suit = 2
    elif disc_sui == "D":
        num_suit = 3
    exist_flg[num_suit][disc_num - 1] = False
for j in range(52):
    if int((j - j % 13) / 13)  == 0:
        suit = "S"
    elif int((j - j % 13) / 13) == 1:
        suit = "H"
    elif int((j - j % 13) / 13) == 2:
        suit = "C"
    elif int((j - j % 13) / 13) == 3:
        suit = "D"
    if exist_flg[int((j -j % 13) / 13)][j % 13]:
        print(suit + " " + str(j % 13 + 1))

Submission status: Accepted

Solution code:
card = [f'{s} {i}' for s in 'SHCD' for i in range(1, 14)]
num = int(input())
for i in range(num):
    card.remove(input())
for i in card:
    print(i)

Submission status: Accepted

Solution code:
cards = list()
suits = ['S','H','C','D']
n = int(input())
for i in range(n):
    x,y = input().split()
    y = int(y)
    if x == 'S':
        cards.append(y+0)
    elif x == 'H':
        cards.append(y+13)
    elif x == 'C':
        cards.append(y+26)
    elif x == 'D':
        cards.append(y+39)
for i in range(1,53):
    if not(i in cards):
        print(suits[(i-1)//13],(i-1)%13+1)

Submission status: Accepted

Solution code:
import sys
c=[f"{s} {i}"for s in "SHCD" for i in range(1,14)]
input()
for s in sys.stdin:
 c.remove(s.strip())
if c!=[]:print(*c,sep="\n")

Submission status: Accepted

Solution code:
n = int(input())

s = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"]
h = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"]
c = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"]
d = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"]


for i in range(n):
    mark, num = input().split()
    if mark == "S":
        s.remove(num)
    elif mark == "H":
        h.remove(num)
    elif mark == "C":
        c.remove(num)
    elif mark == "D":
        d.remove(num)


for m in range(len(s)):
    print ("S %s" % s[m])
for m in range(len(h)):
    print ("H %s" % h[m])
for m in range(len(c)):
    print ("C %s" % c[m])
for m in range(len(d)):
    print ("D %s" % d[m])

Submission status: Accepted

Solution code:
mark = ('S', 'H', 'C', 'D')
tr = {m:{i for i in range(1, 14)} for m in mark}
n = int(input())
for i in range(n):
    m, p = input().split()
    tr[m].remove(int(p))
for j in mark:
    for q in sorted(tr[j]):
        print(j, q)

Submission status: Accepted

Solution code:
k=[]
for m in ['S','H','C','D']:
    for n in range(1,14):
        k.append([m,str(n)])
n=int(input())
for i in range(n):
    a=input().split()
    k.remove(a)
for i in k:print(*i)

Submission status: Accepted

Solution code:
L = []
A = ["S","H","C","D"]
for i in A :
    for j in range(1,14) :
        L.append("{} {}".format(i,j))

N = int(input())
for i in range(N) :
    l = input()
    L.remove(l)
for i in range(len(L)) :
    print(L[i])

Submission status: Accepted

Solution code:
import sys

SUITS = ['S', 'H', 'C', 'D']
SUIT_INDEX = {suit: i for i, suit in enumerate(SUITS)}

remain_cards = {(suit, rank) for rank in range(1, 14) for suit in range(4)}

lines = int(sys.stdin.readline())
for _ in range(lines):
    suit, rank = sys.stdin.readline().strip().split()
    suit = SUIT_INDEX[suit]
    rank = int(rank)
    remain_cards.remove((suit, rank))

for suit, rank in sorted(remain_cards):
    print(f'{SUITS[suit]} {rank}')

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

SUITS = ('S', 'H', 'C', 'D')
cards = dict()

for key in SUITS:
    cards[key] = [False for i in range(14)]

n = int(sys.stdin.readline())
for i in range(n):
    suit, rank_s = sys.stdin.readline().split()
    rank = int(rank_s)

    cards[suit][rank] = True

for suit in SUITS:
    for rank in range(1, 14):
        if cards[suit][rank] == False:
            print(suit, rank)

Submission status: Accepted

Solution code:
s = [i for i in range(1, 14)]
h = [i for i in range(1, 14)]
c = [i for i in range(1, 14)]
d = [i for i in range(1, 14)]

n = int(input())
for i in range(n):
    line = input().split()
    if line[0] == "S":
        s.remove(int(line[1]))
    elif line[0] == "H":
        h.remove(int(line[1]))
    elif line[0] == "C":
        c.remove(int(line[1]))
    elif line[0] == "D":
        d.remove(int(line[1]))
for i in s:
    print("S"+" "+str(i))
for i in h:
    print("H"+" "+str(i))
for i in c:
    print("C"+" "+str(i))
for i in d:
    print("D"+" "+str(i))

Submission status: Accepted

Solution code:
suits = ['S','H','C','D']

table = [[False]*14 for i in range(4)]

n = int(input())

for loop in range(n):

    mark,num = input().split()
    num = int(num)

    if mark == 'S':
        table[0][num] = True
    elif mark == 'H':
        table[1][num] = True
    elif mark == 'C':
        table[2][num] = True
    else:
        table[3][num] = True

for i in range(4):
    for k in range(1,14):
        if table[i][k] == False:
            print("%s %d"%(suits[i],k))

Submission status: Accepted

Solution code:
pattern=['S','H','C','D']
number=[i for i in range(1,14)]
Trunp=[]
for p in range(len(pattern)):
    for n in range(len(number)):
        Trunp+=[pattern[p]+' '+str(number[n])]

cnt=int(input())
for i in range(cnt):
    card=input()
    if card in Trunp:
        Trunp.remove(card)

for i2 in range(len(Trunp)):
    print(Trunp[i2])

Submission status: Accepted

Solution code:
true_cards = [(f'{shcd} {n}') for n in range(1,14) for shcd in ['S', 'H', 'C', 'D']]
n = int(input())
cards=[input() for _ in range(n)]
missed_cards = set(true_cards) - set(cards)
[print(f'{shcd} {n}')  for shcd in ['S', 'H', 'C', 'D'] for n in range(1,14) if f'{shcd} {n}'in missed_cards]

Submission status: Accepted

Solution code:
cards = []
patterns = ['S', 'H', 'C', 'D']

for i in patterns:
    for j in range(1, 14):
        cards.append('{} {}'.format(i, j))

n = int(input())

for _ in range(n):
    card = input()
    cards.remove(card)

for c in cards:
    print(c)

Submission status: Accepted

Solution code:
def main():
    cardList = makeCardList()
    n = int(input())
    for a in range(n):
        card = input()
        cardList[cardToIndex(card)] = ''
    for x in range(len(cardList)):
        if cardList[x]:
            print(cardList[x])

def makeCardList():
    cardList = []
    suits = ['S', 'H', 'C', 'D']
    for s in range(4):
        for r in range(13):
            cardList.append(suits[s] + ' ' + str(r+1))
    return cardList

def cardToIndex(c):
    dict = {'S':0, 'H':1, 'C':2, 'D':3}
    return (dict[c[0]] * 13 + int(c[2:]) - 1)

main()

Submission status: Accepted

Solution code:
maisu=int(input())
mochihuda=[]
hikaku=[]

for i in range(maisu):
    huda=list(map(str,input().split()))
    huda[1]=int(huda[1])
    mochihuda.append(huda)

for i in range(1,5):
    for j in range(1,14):
        if i==1:
            hikaku=['S',j]
        elif i==2:
            hikaku=['H',j]
        elif i==3:
            hikaku=['C',j]
        elif i==4:
            hikaku=['D',j]

        if hikaku not in mochihuda:
            print(str(hikaku[0])+" "+str(hikaku[1]))

        hikaku=[]

Submission status: Accepted

Solution code:

n =  int(input())

mark = ["S","H","C","D"]

card = [1] * 52

while ( n > 0 ):
    (m,mn)  =  map(str,input().split())
    j = 0
    while (j < 4):
        if (m == mark[j]):
            break
        j = j +1
    card [(int(mn) -1 ) + j*13] = 0
    n = n -1

for i in range (0,52):
    if ( card[i] == 1 ):
        print (mark[i//13], (i % 13) +1)

Submission status: Accepted

Solution code:
card=['S','H','C','D']
num=[[False]*14 for i in range(4)]
N=int(input())
for i in range(N):
    s,m=input().split()
    m=int(m)
    if s=='S':
        num[0][m]=True
    elif s=='H':
        num[1][m]=True
    elif s=='C':
        num[2][m]=True
    else:
        num[3][m]=True
for i in range(4):
    for j in range(1,14):
        if num[i][j] == False:
            print("%s %d"%(card[i],j))

Submission status: Accepted

Solution code:
n=int(input())
s=["S "+str(i+1) for i in range(13)]
h=["H "+str(i+1) for i in range(13)]
c=["C "+str(i+1) for i in range(13)]
d=["D "+str(i+1) for i in range(13)]
al=s.copy()
al.extend(h)
al.extend(c)
al.extend(d)

card = [input() for i in range(n)]

for item in al:
    if not item in card:
        print(item)

Submission status: Accepted

Solution code:
deck = list()
for s in ["S", "H", "C", "D"]:
    for i in range(1,14):
        deck.append(s + " " + str(i))

n = int(input())
for _ in range(n):
    deck.remove(input()) 

if len(deck) > 0:
    print("\n".join(deck))

Submission status: Accepted

Solution code:
n = int(input())
cards = ["{} {}".format(suit, str(number)) for suit in ["S", "H", "C", "D"] for number in range(1,14)]
for _ in range(n):
    cards.remove(input())
for card in cards:
    print(card)

Submission status: Accepted

Solution code:
num = int(input())
S = [ "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" , "10" , "11" , "12" , "13" ]
H = [ "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" , "10" , "11" , "12" , "13" ]
C = [ "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" , "10" , "11" , "12" , "13" ]
D = [ "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" , "10" , "11" , "12" , "13" ]
numnum = 0
countnum = 0
while countnum < num:
    z = input()
    for a in z.split():
        if numnum == 0:
            flower = a
            numnum = 1
        else:
            no = a
            numnum = 0
    if flower == "S":
        S.remove(no)
    elif flower == "H":
        H.remove(no)
    elif flower == "C":
        C.remove(no)
    else:
        D.remove(no)
    countnum += 1
for i in S:
    print ( "S " + i )
for i in H:
    print ( "H " + i )
for i in C:
    print ( "C " + i )
for i in D:
    print ( "D " + i )

Submission status: Accepted

Solution code:
n = int(input())

soots = ["S", "H", "C", "D"]

sootlist = []
numlist = []

for i in range(n):
    soot, num = map(str, input().split())
    sootlist.append(soot)
    numlist.append(int(num))

ans_sootlist = []
ans_numlist = []

for soot in soots:
    for num in range(1, 14):
        flag = 0
        for s, n in zip(sootlist, numlist):
            if soot == s and num == n:
                flag = 1
                break
        if flag == 1:
            continue
        else:
            ans_sootlist.append(soot)
            ans_numlist.append(num)

for soot, num in zip(ans_sootlist, ans_numlist):
    print(soot, num)

Submission status: Accepted

Solution code:
answer = [["S", str(i)] for i in range(1, 14)]
answer.extend([["H", str(i)] for i in range(1, 14)])
answer.extend([["C", str(i)] for i in range(1, 14)])
answer.extend([["D", str(i)] for i in range(1, 14)])
N = int(input())
for i in range(N):
    card = input().split()
    answer.remove(card)
for i in range(52-N):
    print(" ".join(answer[i]))

Submission status: Accepted

Solution code:
n = int(input())
a = [str(input()) for i in range(n)]
for i in range(1,14):
    if "S " + str(i) not in a:
        print("S " + str(i))
for i in range(1,14):
    if "H " + str(i) not in a:
        print("H " + str(i))
for i in range(1,14):
    if "C " + str(i) not in a:
        print("C " + str(i))
for i in range(1,14):
    if "D " + str(i) not in a:
        print("D " + str(i))

Submission status: Accepted

Solution code:
cards = {
    'S':[0]*13,
    'H':[0]*13,
    'C':[0]*13,
    'D':[0]*13
}
n = int(input())
for i in range(n):
    icon,num = input().split()
    cards[icon][int(num)-1] = 1

for i in ['S','H','C','D']:
    for j in range(13):
        if cards[i][j] == 0:
            print('{} {}'.format(i,j+1))