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:
def card_suit_check(s):
    if(s=='S'):
        return 0
    elif(s=='H'):
        return 1
    elif(s=='C'):
        return 2
    elif(s=='D'):
        return 3
    else:
        return False

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


card_list =list([[0 for i in range(13)] for j in range(4)])

n = int(input())
for i in range(n):
    suit,card_num = input().split()
    row = card_suit_check(suit)
    col = int(card_num) - 1
    card_list[row][col] = 1

for i in range(len(card_list)):
    for j in range(len(card_list[0])):
        if card_list[i][j] == 0:
            suit = convert_to_card_suit(i)
            miss_card_num = j + 1
            print(suit+' '+str(miss_card_num))

Submission status: Accepted

Solution code:
tbl=[[i for i in range(1,14)] for _ in range(4)]
n=int(input())
for _ in range(n):
    a,b=input().split()
    b=int(b)
    if a=="S":
        tbl[0].remove(b)
    if a=="H":
        tbl[1].remove(b)
    if a=="C":
        tbl[2].remove(b)
    if a=="D":
        tbl[3].remove(b)
for i in range(4):
    for j in tbl[i]:
        print("SHCD"[i],j)

Submission status: Accepted

Solution code:
from collections import OrderedDict

spade = {i for i in range(1, 13+1)}
heart = spade.copy()
crub = spade.copy()
diamond = spade.copy()

cards = OrderedDict()
cards['S'] = spade
cards['H'] = heart
cards['C'] = crub
cards['D'] = diamond

num_cards = int(input())

for i in range(num_cards):
    line = input().split()
    card, number = line[0], int(line[1])
    cards[card].remove(number)

for k, v in cards.items():
    sorted(v)
    for card in v:
        print(k, card)

Submission status: Accepted

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

n=int(input())

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


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("%s %d" %(s[i], j))

Submission status: Accepted

Solution code:
cards=[[False for i in range(13)] for j in range(4)]

n=int(input())

for i1 in range(n):
    a,b=input().split(" ")
    b=int(b)
    if a=="S":
        cards[0][b-1]=True
    elif a=="H":
        cards[1][b-1]=True
    elif a=="C":
        cards[2][b-1]=True
    elif a=="D":
        cards[3][b-1]=True

for i in range(4):
    for j in range(13):
        if cards[i][j]==False:
            if i==0:
                print("S",j+1)
            elif i==1:
                print("H",j+1)
            elif i==2:
                print("C",j+1)
            elif i==3:
                print("D",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())
for i 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:
n=int(input())
cards=[input() for i in range(n)]
ans=[]
for i in "SHCD":
    for j in range(1,14):
        number=i+" "+str(j)
        if number not in cards:ans.append(number)

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

Submission status: Accepted

Solution code:
card = []
for i in ['S ','H ','C ','D ']:
    for j in range(13):
        num = i + str(j+1)
        card.append(num)

n = int(input())
for i in range(n):
    del_num = input()
    card.remove(del_num)

for i in card:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())    # total card number
cards = []
for i in range(n):
    cards.append(input().split())

S_list = [s for s in range(1, 14)]
H_list = [h for h in range(1, 14)]
C_list = [c for c in range(1, 14)]
D_list = [d for d in range(1, 14)]

for card in cards:
    if card[0] == 'S':
        S_list.remove(int(card[1]))
    elif card[0] == 'H':
        H_list.remove(int(card[1]))
    elif card[0] == 'C':
        C_list.remove(int(card[1]))
    elif card[0] == 'D':
        D_list.remove(int(card[1]))

for ss in S_list:
    print('S {}'.format(ss))
for hh in H_list:
    print('H {}'.format(hh))
for cc in C_list:
    print('C {}'.format(cc))
for dd in D_list:
    print('D {}'.format(dd))

Submission status: Accepted

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

cards = []

for i in kigou:
    for j in range(1,14):
        cards.append([i, j])

n = int(input())

for i in range(n):
    card = input().split()
    card[1] = int(card[1])
    cards.remove(card)

for i in cards:
    print(' '.join(map(str, i)))

Submission status: Accepted

Solution code:
cards = [(c, i) for c in "SHCD" for i in range(1, 14)]
for _ in range(int(input())):
    s, r = input().split()
    cards.remove((s, int(r)))
for s, r in cards:
    print(s, r)

Submission status: Accepted

Solution code:
cd=[]
suits=['S','H','C','D']
for i in range(int(input())):
    s,n=map(str,input().split())
    cd.append(suits.index(s)*13+int(n)-1)
for i in range(52):
    if not(i in cd):
        print(suits[i//13],i%13+1)

Submission status: Accepted

Solution code:
class Card:
    def __init__(self, args=None, mark=None, no=None):
        if args != None:
            self.mark = args[0]
            self.no = int(args[1])
        else:
            self.mark = mark
            self.no = no


n = int(input())

cards = []
for i in range(0, n):
    cards.append(Card(args=list(input().split(' '))))

nothings = []
marks = ['S', 'H', 'C', 'D']

for mark in marks:
    for i in range(1, 14):
        for card in cards:
            if card.mark == mark and card.no == i:
                break
        else:
            nothings.append(Card(mark=mark, no=i))

for card in nothings:
    print("{} {}".format(card.mark, card.no))

Submission status: Accepted

Solution code:
n = int(input())

s_list = []
h_list = []
c_list = []
d_list = []

def mk_list(cards_list):
    for j in range(1, 14):
        if j == y:
            cards_list.append(y)
        else:
            continue
    return cards_list

for i in range(n):
    x, y = input().strip().split()
    y =int(y)

    if x is 'S':
        mk_list(s_list)
    elif x is 'H':
        mk_list(h_list)
    elif x is 'C':
        mk_list(c_list)
    elif x is 'D':
        mk_list(d_list)

def check_card(symble, cards_list):
    for k in range(1, 14):
        if k not in cards_list:
            print('{} {}'.format(symble, k))
        else:
            continue

check_card('S', s_list)
check_card('H', h_list)
check_card('C', c_list)
check_card('D', d_list)

Submission status: Accepted

Solution code:
n = int(input())
count = 0 
s = []
h = []
c = []
d = []
for _ in range(n):
    a = [x for x in input().split()]
    if a[0 ] == "S":
        s.append(int(a[1]))
    elif a[0 ] == "H":
        h.append(int(a[1]))
    elif a[0 ] == "C":
        c.append(int(a[1]))
    else:
        d.append(int(a[1]))
for _ in range(1,14):
    if _ not in s:
        print("S", _)
for _ in range(1,14):
    if _ not in h:
        print("H", _)
for _ in range(1,14):
    if _ not in c:
        print("C", _)
for _ in range(1,14):
    if _ not in d:
        print("D", _)

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 i in range(n):
    ch, rank = map(str, 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:
n = int(input())
cards = list()
for i in range(1, 53):
    if i <= 13:
        cards.append("S %d" % i)
    elif i <= 26:
        cards.append("H %d" % (i-13))
    elif i <= 39:
        cards.append("C %d" % (i-26))
    else:
        cards.append("D %d" % (i-39))
for i in range(n):
    cards.remove(input())
if cards:
    print("\n".join(cards))

Submission status: Accepted

Solution code:
num = int(input())

a = [ [0 for x in range(14)] for y in range(4)]

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

for i in range(num):
    m,t = input().split()
    n = int(t)
    if m == "S":
        a[0][n] =1
    elif m == "H":
        a[1][n] =1
    elif m == "C":
        a[2][n] =1
    elif m == "D":
        a[3][n] =1

for i in range(4):
    for j in range(1,14):
        if a[i][j] ==0:
            print(mark[i], j)

Submission status: Accepted

Solution code:
n = int(input())
a = [input() for _ in range(n)]

l = []
for s in ['S', 'H', 'C', 'D']:
    for i in range(1, 14):
        l.append(s + ' ' + str(i))

for i in range(n):
    l.remove(a[i])

if l:print(*l, sep='\n')

Submission status: Accepted

Solution code:
#coding: utf-8

cards = [[0 for i in range(13)] for j in range(4)]
suits = {'S':0, 'H':1, 'C':2, 'D':3, 0:'S', 1:'H', 2:'C', 3:'D'}
n = int(input())
for i in range(n):
    a, b = map(str, input().split())
    c = int(b) - 1
    cards[suits[a]][c] = 1
for i in range(4):
    for j in range(13):
        if cards[i][j] == 0:
            print(suits[i], j + 1)

Submission status: Accepted

Solution code:
num = int(input())

S = [x for x in range(1,14)]
H = [x for x in range(1,14)]
C = [x for x in range(1,14)]
D = [x for x in range(1,14)]

for i in range(num):
    s = input().split()
    
    if s[0]=="S":        
        S.remove(int(s[1]))
    elif s[0]=="H":        
        H.remove(int(s[1]))
    elif s[0]=="C":        
        C.remove(int(s[1]))
    elif s[0]=="D":        
        D.remove(int(s[1]))
    
for i in range(len(S)):
    print("S",S[i])
for i in range(len(H)):
    print("H",H[i])
for i in range(len(C)):
    print("C",C[i])
for i in range(len(D)):
    print("D",D[i])

Submission status: Accepted

Solution code:
def test():

	S = [0]*13
	H = [0]*13
	C = [0]*13
	D = [0]*13

	n = int(input())

	for num in range(n):
		
		card =input().split()
		kind = card[0]
		number = int(card[1])

		if kind == 'S':
			S[number-1] = 1
		elif kind == 'H':
			H[number-1] = 1
		elif kind == 'C':
			C[number-1] = 1
		elif kind == 'D':
			D[number-1] = 1

	for i in range(13):
		if S[i] == 0:
			print(f"S {i+1}")
	for i in range(13):
		if H[i] == 0:
			print(f"H {i+1}")
	for i in range(13):
		if C[i] == 0:
			print(f"C {i+1}")
	for i in range(13):
		if D[i] == 0:
			print(f"D {i+1}")


if __name__ == "__main__":
	test()

Submission status: Accepted

Solution code:
card = {"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):
    c, r = input().split()
    card[c].remove(int(r))
    
for i in ["S","H","C","D"]:
    [print("%s %d" % (i,j)) for j in card[i]]

Submission status: Accepted

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

Submission status: Accepted

Solution code:
P = []
for X in "SHCD":
    for i in range(1, 13+1):
        P.append("{} {}".format(X, i))

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

for c in P:
    print(c)

Submission status: Accepted

Solution code:
n=int(raw_input())
s=[]
h=[]
c=[]
d=[]
ss=[]
hh=[]
cc=[]
dd=[]

for i in range(n):
	a=raw_input().split()
	
	if a[0]=="S":
		s.append(int(a[1]))
	elif a[0]=="H":
		h.append(int(a[1]))
	elif a[0]=="C":
		c.append(int(a[1]))
	elif a[0]=="D":
		d.append(int(a[1]))
for i in range(1,14):
	if i not in s:
		ss.append(i)
	if i not in h:
		hh.append(i)
	if i not in c:
		cc.append(i)
	if i not in d:
		dd.append(i)
for i in ss:
	print "S "+str(i)
for i in hh:
	print "H "+str(i)
for i in cc:
	print "C "+str(i)
for i in dd:
	print "D "+str(i)

Submission status: Accepted

Solution code:
cards = [[False for i in range(13)] for j in range(4)]
# 0: S, 1: H, 2: C, 3:D
pattern = ["S", "H", "C", "D"]
n = int(input())
for i in range(n):
    ch,rank = 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())
l=[]
for i in range(n):
    lt=list(map(str,input().split()))
    l.append(lt)
for i in range(4):
    for j in range(1,13+1):
        if i==0:
            m='S'
        elif i==1:
            m='H'
        elif i==2:
            m='C'
        else:
            m='D'
        temp=[m,str(j)]
        if l.count(temp)==0:
            print(m,j)

Submission status: Accepted

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

n = int(input())

for i in range(n):
    s, r = input().split()
    r = int(r)
    if s == 'S':
        cards.append(0 + r)
    elif s == 'H':
        cards.append(13 + r)
    elif s == 'C':
        cards.append(26 + r)
    elif s == 'D':
        cards.append(39 + r)

for j in range(1, 53):
    if not j in cards:
        print(suits[(j-1)//13], (j-1)%13+1)

Submission status: Accepted

Solution code:
def convert(sym):
	if sym == 'S':
		return 0
	if sym == 'H':
		return 1
	if sym == 'C':
		return 2
	if sym == 'D':
		return 3

	if sym == 0:
		return 'S'
	if sym == 1:
		return 'H'
	if sym == 2:
		return 'C'
	if sym == 3:
		return 'D'

grid = [[0 for j in range(13)] for i in range(4)]

n = int(input())
for i in range(n):
	x, y = map(str, input().split())
	y = int(y)- 1
	grid[convert(x)][y] += 1

for i in range(4):
	for j in range(13):
		if (grid[i][j] < 1):
			print(convert(i), j+1)

Submission status: Accepted

Solution code:
a = []

n = int(input())

for i in ['S', 'H', 'C', 'D']:
    for j in range(1, 14):
        a.append([i, j])

for i in range(1, n + 1):
    ca, integer = input().split()
    a.remove([ca, int(integer)])

for i in range(len(a)):
    print(a[i][0]+' %d' % (a[i][1]))

Submission status: Accepted

Solution code:
# 何回ループするか
times = int(input())
# トランプ生成
cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]

for time in range(times):
    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:
a=int(input())
#持っているカードの状態を、初期値をFalseとする4x13の２次元配列に記録する
cards = [[False for i in range(13)] for j in range(4)]
pattern =['S', 'H', 'C', 'D']
# 呼ばれたカードをTrueにする
for _ in range(a):
    ch, rank = input().split()
    cards[pattern.index(ch)][int(rank)-1] = True

# 2重ループによって呼ばれていないカードを表示する
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:
cards = [[True for i in range(13)] for j in range(4)]

n = int(input())
for i in range(n):
    mark, number = input().split()
    number = int(number)
    
    if mark == 'S':
        cards[0][number-1] = False
    elif mark == 'H':
        cards[1][number-1] = False
    elif mark == 'C':
        cards[2][number-1] = False
    else:
        cards[3][number-1] = False
        
for i in range(4):
    for j in range(13):
        if cards[i][j] == True:
            if i == 0:
                print("S ", j+1, sep="")
            elif i == 1:
                print("H ", j+1, sep="")
            elif i == 2:
                print("C ", j+1, sep="")
            else:
                print("D ", j+1, sep="")

Submission status: Accepted

Solution code:
n = int(input())
s = set()
for i in range(0, n):
     s.add(input())

for i in'SHCD':[print(i+' '+str(j))for j in range(1,14)if i+' '+str(j)not in s]

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:
found = []
for s in range(4):
    suit = []
    for i in range (14):
        suit.append(False)
    found.append(suit)
    
num_card = int(input())
for i in range(num_card):
    suit, rank = input().split()
    suit = 'SHCD'. index(suit)
    rank = int(rank)
    found[suit][rank] = True
    
for s in range(4):
    for r in range(1,14):
        if found[s][r] == False:
            suit = 'SHCD'[s]
            print(suit, r)

Submission status: Accepted

Solution code:
found = []
for s in range(4):
    suit = []
    for i in range (14):
            suit.append(False)
    found.append(suit)
    
num_card = int(input())
for i in range (num_card):
    suit, rank = input().split()
    suit = 'SHCD'.index(suit)
    rank = int(rank)
    found[suit][rank] = True
        
for s in range(4):
    for r in range(1,14):
        if found[s][r] == False:
            suit = 'SHCD'[s]
            print (suit, r)

Submission status: Accepted

Solution code:
E = ["S","H","C","D"]
n=int(input())
A=[[0 for j in range(14)] for i in range(4)]
for j in range(n):
	a,b=input().split()
	a=E.index(a)
	b=int(b)
	A[a][b]=1
	
for z in range(4):
	for c in range(1,14):
		if A[z][c]==0:
			print(f"{E[z]} {c}")

Submission status: Accepted

Solution code:
E = ["S","H","C","D"]
n=int(input())
c = [[0 for i in range(14)] for j in range(4)]
for i in range(n):
	a,b=input().split()
	a=E.index(a)
	b=int(b)
	c[a][b]=1
	
for z in range(4):
	for f in range(1,14):
		if c[z][f]==0:
			print(f"{E[z]} {f}")

Submission status: Accepted

Solution code:
E = ["S","H","C","D"]
n=int(input())
x=[[0 for j in range(14)]for i in range(4)]
for i in range(n):
	a,b=input().split()
	a=E.index(a)
	b=int(b)
	x[a][b]=1
	
for z in range(4):
	for c in range(1,14):
		if x[z][c]==0:
			print(f"{E[z]} {c}")

Submission status: Accepted

Solution code:
import sys,os,re
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate
sys.setrecursionlimit(10**6)

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

n=int(input())
for i in range(n):
    s,m=input().split()
    card[mark.index(s)][int(m)-1]=True

for i in range(4):
    for j in range(13):
        if not card[i][j]:
            print(mark[i],j+1)

Submission status: Accepted

Solution code:
n=int(input())
list=[[0 for i in range(13)]for j in range(4)]
for aa in range(n):
	x,y=(input().split())
	y=int(y)-1
	if x=='S' :
		list[0][y]=1
	elif x=='H' :
		list[1][y]=1
	elif x=='C' :
		list[2][y]=1
	elif x=='D' :
		list[3][y]=1
for z in range(13):
	if list[0][z]==0:
		print('S '+str(z+1))		
for z in range(13):
	if list[1][z]==0:
		print('H '+str(z+1))
for z in range(13):
	if list[2][z]==0:
		print('C '+str(z+1))
for z in range(13):
	if list[3][z]==0:
		print('D '+str(z+1))

Submission status: Accepted

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

def i2c(i):
	return i2c_[i]

def c2i(c):
	if c == 'S': return 0
	if c == 'H': return 1
	if c == 'C': return 2
	if c == 'D': return 3
	return -1

n=int(input())

have = [[False for j in range(14)] for i in range(4)]

for i in range(n):
	c, x = input().split()
	have[c2i(c)][int(x)] = True

for i in range(4):
	for j in range(1,14):
		if not have[i][j]:
			print(f"{i2c(i)} {j}")

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(list)
n = int(input())
for i in range(n):
    mark, num = input().split()
    d[mark].append(int(num))
# print(d)

for m in "SHCD":
    m_num = d[m]
    for i in range(1,14):
        if i not in m_num:
            print(m, i)

Submission status: Accepted

Solution code:
lst = [True for i in range(52)]
n = int(input())
for i in range (n):
    suit, rank = input().split()
    rankn = int(rank)
    if suit == 'S':
        lst[rankn-1] = False
    elif suit == 'H':
        lst[rankn+12] = False
    elif suit == 'C':
        lst[rankn+25] = False
    else:
        lst[rankn+38] = False
for i in range(52):
    tf = lst[i]
    if i <= 12 and tf:
        print ('S %d' % (i+1))
    elif 12 < i <= 25 and tf:
        print ('H %d' % (i-12))
    elif 25 < i <= 38 and tf:
        print ('C %d' % (i-25))
    elif tf:
        print ('D %d' % (i-38))

Submission status: Accepted

Solution code:
suits = ["S", "H", "C", "D"]
cards = {}
for s in suits:
    cards[s] = list(range(1, 14))

n = int(input())
for i in range(n):
    card = input().split()
    suit, rank = card[0], int(card[1])
    cards[suit].remove(rank)

for suit, ranks in cards.items():
    if ranks:
        for r in ranks:
            print(suit, r)

Submission status: Accepted

Solution code:
l=[0 for i in range(52)]
letter = ['S','H','C','D']
n = int(input())
for i in range(n):
    a,b = input().split()
    for i in range(4):
        if a==letter[i]:
            l[13*i+(int(b)-1)]=1

for i in range(52):
    if l[i]==0:
        s = letter[int(i/13)]
        num = i%13+1
        print(s,num)

Submission status: Accepted

Solution code:
n = int(input())
a = list()
for i in range(n):
	x, y = input().split()
	y = int(y)
	if x == "S":
		a.append(y + 0)
	if x == "H":
		a.append(y + 13)
	if x == "C":
		a.append(y + 26)
	if x == "D":
		a.append(y + 39)
for i in range(1, 53):
	if not (i in a):
		if i <= 13:
			print("S {}".format(i - 0))
		elif i <= 26:
			print("H {}".format(i - 13))
		elif i <= 39:
			print("C {}".format(i - 26))
		else:
			print("D {}".format(i - 39))

Submission status: Accepted

Solution code:
n = int(input())
S = [0 for x in range(13)]
H = [0 for x in range(13)]
C = [0 for x in range(13)]
D = [0 for x in range(13)]


def printLost(k,K):
  for x in range(13):
    if K[x] == 0:
      print("{} {}".format(k,x+1))


for i in range(n):
  k,l = input().split()
  if k == "S":
    S[int(l) -1] = 1
  if k == "H":
    H[int(l) -1] = 1
  if k == "C":
    C[int(l) -1] = 1
  if k == "D":
    D[int(l) -1] = 1

printLost('S',S)
printLost('H',H)
printLost('C',C)
printLost('D',D)

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:
s = {suits: list(range(1, 14)) for suits in ["S", "H", "C", "D"]}

n = int(input())
for i in range(n):
    pict, num = tuple(input().split())
    s[pict].remove(int(num))

for i in s:
    for j in s[i]:
        print(i + " " + str(j))

Submission status: Accepted

Solution code:
n = int(input())

num_set = {i for i in range(1, 14)}
S, H, C, D = set(), set(), set(), set()

for i in range(n):
    mark, num = input().split()
    num = int(num)
    if mark == "S":
        S.add(num)
    elif mark == "H":
        H.add(num)
    elif mark == "C":
        C.add(num)
    elif mark == "D":
        D.add(num)

S_dash, H_dash, C_dash, D_dash = list(
    num_set - S), list(num_set - H), list(num_set - C), list(num_set - D)
S_dash.sort()
H_dash.sort()
C_dash.sort()
D_dash.sort()

for i in S_dash:
    print("S", i)

for i in H_dash:
    print("H", i)

for i in C_dash:
    print("C", i)

for i in D_dash:
    print("D", i)

Submission status: Accepted

Solution code:
n = int(input())
s = list()
h = list()
c = list()
d = list()
for i in range(n):
  a = input().split()
  p = a[0]
  q = int(a[1])
  if p == 'S':
    s.append(q)
  elif p == 'H':
    h.append(q)
  elif p == 'C':
    c.append(q)
  else:# p == 'D'
    d.append(q)
x = 1
for j in range(13):
  if x not in s:
    print('S',x)
  x += 1
x =1
for k in range(13):
  if x not in h:
    print('H',x)
  x += 1
x = 1
for l in range(13):
  if x not in c:
    print('C',x)
  x += 1
x =1
for m in range(13):
  if x not in d:
    print('D',x)
  x += 1

Submission status: Accepted

Solution code:
n = int(input())
L = [[True for i in range(13)]for j in range(4)]
S = ("S","H","C","D")
for i in range(n):
    s,m = input().split()
    for j in range(4):
        if s==S[j]:
            L[j][int(m)-1]=False
for i in range(4):
    for j in range(13):
        if L[i][j]:
            print(S[i]+" "+str(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 j in range(1,14):
    if table[i][j] == False:
      print("%s %d"%(suits[i],j))

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:
import operator
N =int(input())
exist_cards = [input() for _ in range(N)]

SUITS = 'S H C D'.split()
suits_prior =dict(zip(SUITS,range(4)))
prior_suits = {v:k for k,v in suits_prior.items()}

def multisort(xs, specs):
    getter = operator.itemgetter if isinstance(specs,list) or isinstance(specs,tuple) else operator.attrgetter
    for key, reverse in reversed(specs):
        xs.sort(key=getter(key), reverse=reverse)
    return xs
cards =[]
for suit in SUITS:
    for i in range(1,14):
        cards.append(suit+" "+str(i))
missings = map(lambda s:s.split(),set(cards).difference(exist_cards))
missings2 = [[suits_prior[suit],int(val)] for suit,val in missings]
ms =  multisort(missings2, ((0, False), (1, False)))
ans = [[prior_suits[k],v] for k,v in ms]
for x in ans:
    print(" ".join([str(e) for e in x]))

Submission status: Accepted

Solution code:
marks = "SHCD"
cards = { 'S':{}, 'H':{}, 'C':{}, 'D':{} }

N = int(input())

for _ in range(N):
    m, n = input().split()
    cards[m][int(n)] = n

for m in marks:
    for i in range(1, 14):
        if i not in cards[m]:
            print(m, i)

Submission status: Accepted

Solution code:
n = int(input())

card = []
for suit in range(4):
    st = []
    for rank in range(14):
        st.append(False)
    card.append(st)
#print(card)

for i in range(n):
    suit,rank = input().split()
    suit = "SHCD".index(suit)
    rank = int(rank)
    card[suit][rank] = True
    
    
for suit in range(4):
    for rank in range(1,14):
        if card[suit][rank] == False:
            print("SHCD"[suit],rank)

Submission status: Accepted

Solution code:
n = int(input())
card = []
for suit in range(4):
    st = []
    for rank in range(14):
        st.append(False)
    card.append(st)
    
for i in range(n):
    suit, rank = input().split()
    suit = 'SHCD'.index(suit)
    rank = int(rank)
    card[suit][rank] = True

for suit in range(4):
    for rank in range(1, 14):
        if card[suit][rank] == False:
            print('SHCD'[suit], rank)

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):
   s,num = input().split()
   num = int(num)
   cards[s][num - 1] = 1

for c in ["S","H","C","D"]:
   for i in range(13):
       if cards[c][i] == 0:
           print(c, str(i + 1))

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):
    s,num = input().split()
    num = int(num)
    cards[s][num - 1] = 1
 
for c in ["S","H","C","D"]:
    for i in range(13):
        if cards[c][i] == 0:
            print(c, str(i + 1))

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]

while True:
    try:
        m,n = input().split()
        if m == "S":
            del s[s.index(int(n))]
        elif m == "H":
            del h[h.index(int(n))]
        elif m == "C":
            del c[c.index(int(n))]
        elif m == "D":
            del d[d.index(int(n))]
    except:
        break

if len(s) > 0:
    for i in range(len(s)):
        print("S " + str(s[i]))

if len(h) > 0:
    for i in range(len(h)):
        print("H " + str(h[i])) 

if len(c) > 0:
    for i in range(len(c)):
        print("C " + str(c[i]))

if len(d) > 0:
    for i in range(len(d)):
        print("D " + str(d[i]))

Submission status: Accepted

Solution code:
marks = ["S","H","C","D"]
numbers = range(1, 14)
cards = [(m, str(n)) for m in marks for n in numbers]

n = int(input())
for i in range(n):
    c = tuple(input().split())
    if c in cards:
        cards.remove(c)
for j in cards:
    print("{} {}".format(j[0], j[1]))

Submission status: Accepted

Solution code:
import itertools

def create_cards(suits: list, ranks: list) -> set:
    return list(itertools.product(suits, ranks))


if __name__ == "__main__":
    suits = ["S", "H", "C", "D"]
    ranks = [str(elem) for elem in range(1, 14)]
    cards = create_cards(suits, ranks)

    elem_num = int(input())
    for i in range(elem_num):
        symbol, num= input().split()
        cards.remove((symbol, num))
    
    for suit, rank in cards:
        print(f"{suit} {rank}")