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:
'''
?????????????????????
??????????????¨??????????????\?????????
???????????????????????¨????????????
??????????????????
????????????????????£????¶????????????°???????????????????????????
?¬????????????????????????°??????1??\????????????
??????????????¨?????????????????????????????????????????¨??????????????°????????????????????????
??????1??\???????????°??????????????????????¬???????????????¨???????????????
???????????£?????????????????¨??????????????\?????????
??£?????¨??????????????????????????????
??????????????????????????????????????£????????????????????\?????§??§????????????
??????????????????????????????????????????????????§????????°??§????????????
??§?????£?????¨?????§?????£?????????????????´??????

??£?????¨?????§?????¶??????????????????????????????????´????
????????????????????????????????°??????????????????
????????????????????£???????????°?????????????????????1????????§???????????°?¶????????????°??????
?????????????????\???????????????????´????
?????????4???????????¶??????????????????????????????

??°??????????????£???int????????????
??°???????????????????????¨???????????????????´??????????????????¨?????????????????????????¶??????°????????????

??????2??\????????????????????´???????????????????????????
'''


import re

#eCard = ['S 1', 'S 5', 'H 1', 'D 2', 'C 8', 'S 13']
eCard = []
n = int(input())
i = 0
while i < n:
    eCard.append(input())
    i += 1

#print(eCard)
#???????????????????????£?????¨?????§????´¢???????????????
S = []
H = []
D = []
C = []

missingS = []
missingH = []
missingD = []
missingC = []


def assortSuit(s, sc):
    i = 0

#??????????????????????????¢?????\?????????????????????
    while i < int(len(eCard)):
        if re.match(s, eCard[i]):
            Smatch = re.search('\d+', eCard[i])
            sc.append(int(Smatch.group()))#????????????????????????????????£?????????????????¨???????????°???????????????
        i += 1

#S = re.search(???^S.*???, eCard)
assortSuit('^S', S)
assortSuit('^H', H)
assortSuit('^D', D)
assortSuit('^C', C)

def selectMissingCards(c, mc):
    c.sort()
#???????????°???????°?????????°????????????????????¨???
    smallerC = 1
    while smallerC < c[0]:
        mc.append(smallerC)
        smallerC += 1
        
        
    i = 0

    while i < len(c)-1:
        m = c[i+1] - c[i]
    
        if m > 1:
            h = 1
            while h < m:
                mc.append(c[i]+h)
                h += 1
        i += 1
    largerC = c[i] + 1
    while largerC <= 13:
        mc.append(largerC)
        largerC += 1
        
            

selectMissingCards(S, missingS)
selectMissingCards(H, missingH)
selectMissingCards(D, missingD)
selectMissingCards(C, missingC)

'''
print(missingS)
print(missingH)
print(missingD)
print(missingC)
'''

missingCards = []

def allMissingCards(mc, s):
    #??????????????????????????????????????°?????????????????????????????????????????????????´????
    i = 0
    while i < len(mc):
        missingCards.append(s + str(mc[i]))
        i += 1
    
allMissingCards(missingS, "S ")
allMissingCards(missingH, "H ")
allMissingCards(missingC, "C ")
allMissingCards(missingD, "D ")

#print(missingCards)

i = 0
while i < len(missingCards):
    print(missingCards[i])
    i += 1
    


'''
if S:
    #??°?????????????????????????´????
    
    Scard = re.search(???\d+???, S)#?????????????????????????????????????????£?????¨???????????§?????????????????°??????????????¨???
    SeCard = []
    SeCard.append(int(Scard.group()))
    print(SeCard)
'''

Submission status: Accepted

Solution code:
n = input()
a = []
for i in range(n):
	x,y = raw_input().split()
	z = int(y)
	if x == 'S':
		pass
	elif x == 'H':
		z += 13
	elif x == 'C':
		z += 26
	else:
		z += 39
	a.append(z)
a.sort()
b = []
for j in range(1,53):
	if j in a:
		pass
	else:
		b.append(j)
for k in range(0, int(len(b))):
	i = 0
	while True:
		if b[k] <= 13: break
		i += 1
		b[k] = b[k] - 13
	if i == 0:	print 'S %d' %b[k]
	elif i == 1:print 'H %d' %b[k]
	elif i == 2:print 'C %d' %b[k]	
	else:print 'D %d' %b[k]

Submission status: Accepted

Solution code:
# coding:utf-8
n = input()
card = []
for i in range(1,14):
    card.append(('S', str(i)))
for i in range(1,14):
    card.append(('H', str(i)))
for i in range(1,14):
    card.append(('C', str(i)))
for i in range(1,14):
    card.append(('D', str(i)))
array = [raw_input().split() for i in range(n)]
src_set = set(card)
array_set = set(map(tuple, array))
answer = sorted(src_set ^ array_set, key=card.index)
for v1,v2 in answer:
    print v1,v2

Submission status: Accepted

Solution code:
n = int(input())

SN = set([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])
HN = set([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])
DN = set([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])
CN = set([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])

for i in range(n):
    M, N = input().split()

    if M == "S":
        SN.remove(int(N))
    elif M == "H":
        HN.remove(int(N))
    elif M == "C":
        CN.remove(int(N))
    elif M == "D":
        DN.remove(int(N))

for i in SN:
    print('S {0}'.format(i))
for i in HN:
    print('H {0}'.format(i))
for i in CN:
    print('C {0}'.format(i))
for i in DN:
    print('D {0}'.format(i))

Submission status: Accepted

Solution code:
n = int(input())

S = set()
H = set()
C = set()
D = set()

for i in range(1, 14):
    S.add(i)
    H.add(i)
    C.add(i)
    D.add(i)

for i in range(n):
    sp = input()
    spSpl = sp.split()

    tp = spSpl[0]
    num = int(spSpl[1])

    if(tp == 'S'):
        S.remove(num)
    elif(tp == 'H'):
        H.remove(num)
    elif(tp == 'C'):
        C.remove(num)
    else:
        D.remove(num)

for s in S:
    print('S', s)

for s in H:
    print('H', s)

for s in C:
    print('C', s)

for s in D:
    print('D', s)

Submission status: Accepted

Solution code:
n=int(input())
spade=set(range(1,14,1))
heart=set(range(1,14,1))
club=set(range(1,14,1))
diamond=set(range(1,14,1))
for a in range(n):
    e,b=input().split()
    if e=="S":
        spade.remove(int(b))
    if e=="H":
        heart.remove(int(b))
    if e=="C":
        club.remove(int(b))
    if e=="D":
        diamond.remove(int(b))
for i in spade:
    print("S",i)
for i in heart:
    print("H",i)
for i in club:
    print("C", i)
for i in diamond:
    print("D",i)

Submission status: Accepted

Solution code:
from collections import OrderedDict
def solve():
    n = int(input())
    if n >= 52:
        return
    m = OrderedDict()
    for c in "SHCD":
        for i in range(1, 14):
            m[c + " " + str(i)] = 0
    for _ in range(n):
        del m[input()]
    print(*m.keys(), sep="\n")
solve()

Submission status: Accepted

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

n=int(input()) 

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

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

Submission status: Accepted

Solution code:
cards = [
    "{} {}".format(s, r) for s in ('S', 'H', 'C', 'D') for r in range(1, 13 + 1)
]

count = int(input())


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


for n in cards:
    print(n)

Submission status: Accepted

Solution code:
c=[s+' '+str(i)for s in'SHCD'for i in range(1,14)]
[c.remove(input())for _ in range(int(input()))]
if c:print(*c,sep='\n')

Submission status: Accepted

Solution code:
c=[s+' '+str(i)for s in'SHCD'for i in range(1,14)]
for _ in range(int(input())):c.remove(input())
if c:print(*c,sep='\n')

Submission status: Accepted

Solution code:
from itertools import product
tranps = [s+" "+str(n) for s, n in product(['S', 'H', 'C', 'D'], range(1, 14))]
n = int(raw_input())
tranp_in = [raw_input() for i in range(0,n)]
for tranp in tranps:
    if tranp in tranp_in:
        continue
    print tranp

Submission status: Accepted

Solution code:
c=[s+' '+str(i)for s in'SHCD'for i in range(1,14)]
for _ in[0]*int(input()):c.remove(input())
if c:print(*c,sep='\n')

Submission status: Accepted

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

x = int(input())

for i in range(x):
    ss, nn = map(str, input().split())

    try:
        if ss == "H":
            h.remove(int(nn))
        elif ss == "C":
            c.remove(int(nn))
        elif ss == "D":
            d.remove(int(nn))
        elif ss == "S":
            s.remove(int(nn))
    except ValueError:
        break

for i in range(len(s)):
    print ("S "+ str(s[i]))
    
for i in range(len(h)):
    print ("H "+ str(h[i]))

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

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

Submission status: Accepted

Solution code:
Cards = [
    "S 1", "S 2", "S 3", "S 4", "S 5", "S 6", "S 7", "S 8", "S 9", "S 10", "S 11", "S 12", "S 13",
    "H 1", "H 2", "H 3", "H 4", "H 5", "H 6", "H 7", "H 8", "H 9", "H 10", "H 11", "H 12", "H 13",
    "C 1", "C 2", "C 3", "C 4", "C 5", "C 6", "C 7", "C 8", "C 9", "C 10", "C 11", "C 12", "C 13",
    "D 1", "D 2", "D 3", "D 4", "D 5", "D 6", "D 7", "D 8", "D 9", "D 10", "D 11", "D 12", "D 13",
]

n = input()

for i in range(int(n)):
    rm = input()
    Cards.remove(rm)

for i in range(52 - int(n)):
    print(Cards.pop(0))

Submission status: Accepted

Solution code:
all_card = []
number = [str(x) for x in range(1,14)]
pattern = ['S','H','C','D']
for i in pattern:
    for j in number:
        card = i + ' ' + j
        all_card.append(card)
n = int(input())
exist = []
for i in range(n):
    exist.append(input())
for i in all_card:
    if i in exist:
        pass
    else:
        print(i)

Submission status: Accepted

Solution code:
num = int(input())
deck = {}
for _ in range(num):
    c, n = input().split()
    n = int(n)
    if c in deck:
        deck[c].add(n)
    else:
        deck[c] = set([n])

cs = ['S', 'H', 'C', 'D']
alln = set(range(1, 14))
for c in cs:
    remain = sorted(list(alln - deck[c]))
    for r in remain:
        print(c, r)

Submission status: Accepted

Solution code:
n = int(input())
k = 0
buffer = []
ref = []
while k<n:
    x,y = map(str, input().split())
    buffer.append([x,y])
    k = k + 1



for i in range(13):
    ref.append(['S',str(i+1)])
for i in range(13):
    ref.append(['H',str(i+1)])
for i in range(13):
    ref.append(['C',str(i+1)])    
for i in range(13):
    ref.append(['D',str(i+1)])


for sample in ref:
    if sample not in buffer:
        print(sample[0]+' '+sample[1])

Submission status: Accepted

Solution code:
n=int(input())
card=[[0 for i in range(13)] for j in range(4) ]
mk={0:"S",1:"H",2:"C",3:"D"}
for i in range(n) :
    mark,number=input().split()
    number=int(number)
    if mark=="S" : mark=int(0)
    elif mark=="H" : mark=int(1)
    elif mark=="C" : mark=int(2)
    elif mark=="D" : mark=int(3)
    card[mark][number-1]=1
for m in range(4) :
    for num in range(13) :
        if card[m][num]==0 :
            print("{} {}".format(mk[m],num+1))

Submission status: Accepted

Solution code:
list = []
for x in ["S", "H", "C", "D"]:
    for y in [str(i) for i in range(1, 14)]:
        list.append(x+" "+y)
n = int(input())
while n > 0:
    list.remove(input())
    n -= 1
for i in list:
    print(i)

Submission status: Accepted

Solution code:
cards = []
for i in ['S','H','C','D']:
    for j in range(1, 14):
        cards.append(i + " " + str(j))
N = int(input())
for i in range(N):
    cards.remove(input())

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

Submission status: Accepted

Solution code:
c = [x+' '+y for x in ['S','H','C','D'] for y in [str(i) for i in range(1,14)]]
for i in range(int(input())):
    c.remove(input())
for i in c:
    print (i)

Submission status: Accepted

Solution code:
n = int(input())
c = [[0 for i in range(13)] for j in range(4)]

for i in range(n):
    a, b = (i for i in input().split())

    if a == "S":
        c[0][int(b)-1] = 1
    elif a == "H":
        c[1][int(b)-1] = 1
    elif a == "C":
        c[2][int(b)-1] = 1
    elif a == "D":
        c[3][int(b)-1] = 1

for i in range(4):
    for j in range(13):
        if c[i][j] == 0:
            if i == 0:
                print('S ' + str(j+1))
            elif i == 1:
                print('H ' + str(j+1))
            elif i == 2:
                print('C ' + str(j+1))
            elif i == 3:
                print('D ' + str(j+1))

Submission status: Accepted

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

import sys

class suits():
    def __init__(self, symbol):
        self.exist = [False for i in range(14)]
        self.symbol = symbol

    def mark_exist(self, rank):
        self.exist[rank] = True

    def is_exist(self, rank):
        return self.exist[rank]

spade = suits('S')
heart = suits('H')
club = suits('C')
diamond = suits('D')

n = int(sys.stdin.readline())
for i in range(n):
    suit, rank_s = sys.stdin.readline().split()
    rank = int(rank_s)
    if suit == 'S':
        spade.mark_exist(rank)
    elif suit == 'H':
        heart.mark_exist(rank)
    elif suit == 'C':
        club.mark_exist(rank)
    elif suit == 'D':
        diamond.mark_exist(rank)
    else:
        raise ValueError

for s in (spade, heart, club, diamond):
    for rank in range(1, 14):
        if s.is_exist(rank) == False:
            print(s.symbol, rank)

Submission status: Accepted

Solution code:
mark = ['S','H','C','D']
number = [str(x) for x in range(1,14)]
all_card = []
for m in mark:
    for n in number:
        c = m + ' ' + n
        all_card.append(c)
missing = all_card.copy()
for _ in range(int(input())):
    e_card = input()
    missing.remove(e_card)
for _ in missing:
    print(_)

Submission status: Accepted

Solution code:
n = int(input())
i = 0

card_S = []
card_H = []
card_C = []
card_D = []

while i < n:
	mark, num = input().split()
	if mark == "S":
		card_S.append(int(num))
	elif mark == "H":
		card_H.append(int(num))
	elif mark == "C":
		card_C.append(int(num))
	else:
		card_D.append(int(num))
	i += 1

i = 1
while i < 14:
	if not(i in card_S):
		print("S " + str(i))
	i += 1

i = 1
while i < 14:
	if not(i in card_H):
		print("H " + str(i))
	i += 1

i = 1
while i < 14:
	if not(i in card_C):
		print("C " + str(i))
	i += 1

i = 1
while i < 14:
	if not(i in card_D):
		print("D " + str(i))
	i += 1

Submission status: Accepted

Solution code:
N = int(input())
l = [input() for i in range(N)]
cl = ['{} {}'.format(i,j) for i in ['S', 'H', 'C', 'D'] for j in range(1,14) if '{} {}'.format(i,j) not in l ]
for i in cl: print(i)

Submission status: Accepted

Solution code:
def missingcheck(data,suit):
    for i in range(13):
        if '{} {}'.format(suit,str(i+1)) not in data:
            print('{} {}'.format(suit,str(i+1)))

n = int(input())
data = []
for i in range(n):
    data.append(input())
missingcheck(data,'S')
missingcheck(data,'H')
missingcheck(data,'C')
missingcheck(data,'D')

Submission status: Accepted

Solution code:
c = {'S' : [0]*13, 'H' : [0]*13, 'C' : [0]*13, 'D' : [0]*13}
n = int(input())
for i in range(n) :
    s, num = input().split()
    c[s][int(num) - 1] = 1
for i in c :
    for j in range(13) :
        if c[i][j] == 0 :
            print(i, j+1)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
n = int(input())
card =[[c for c in input().rstrip().split()] for i in range(n)]
card = [c[0] + c[1] for c in card]
picture = ("S", "H", "C", "D")
numeric = tuple(str(num) for num in range(1, 14))
for c in picture:
    for num in numeric:
        if c + num not in card:
            print("{0} {1}".format(c, num))

Submission status: Accepted

Solution code:
T = []
for i in range(52):
    T.append(False)
for i in range(int(input())):
    #print(input())
    mark, num = input().split()
    num = int(num) - 1
    if mark == "S":
        num += 0
    elif mark == "H":
        num += 13
    elif mark == "C":
        num += 26
    elif mark == "D":
        num += 39
    T[num] = True
for idx, i in enumerate(T):
    if not i:
        mark = idx // 13
        if mark == 0:
            mark = "S"
        elif mark == 1:
            mark = "H"
        elif mark == 2:
            mark = "C"
        elif mark == 3:
            mark = "D"
        print(mark, (idx % 13) + 1)

Submission status: Accepted

Solution code:
s = [0] * 13
h = [0] * 13
c = [0] * 13
d = [0] * 13
N = int(input())
i = 0
while i < N:
    m, n = map(str, input().split(' '))
    n = int(n) - 1
    if m == 'S':
        s[n] = 1
    elif m == 'H':
        h[n] = 1
    elif m == 'C':
        c[n] = 1
    elif m == 'D':
        d[n] = 1
    i += 1
ans = ''
j = 0
while j < 13:
    if s[j] == 0:
        ans += 'S ' + str(j + 1) + '\n'
    j += 1
j = 0
while j < 13:
    if h[j] == 0:
        ans += 'H ' + str(j + 1) + '\n'
    j += 1
j = 0
while j < 13:
    if c[j] == 0:
        ans += 'C ' + str(j + 1) + '\n'
    j += 1
j = 0
while j < 13:
    if d[j] == 0:
        ans += 'D ' + str(j + 1) + '\n'
    j += 1
if ans != '':
    print(ans[:-1])

Submission status: Accepted

Solution code:
#!/usr/bin/env python

if __name__ == '__main__':
    trump = [ '%c %d' % (c, r) for c in 'SHCD' for r in range(1,14) ]

    n = int(raw_input())
    for _ in range(n):
        trump.remove(raw_input())

    for t in trump:
        print t

Submission status: Accepted

Solution code:
import sys

cards_num = int(sys.stdin.readline())
cards =[ card[:-1] for card in sys.stdin.readlines() ]

all_cards = [ i + ' ' + str(j) for i in 'SHCD' for j in range(1,14) ]

missing_cards = [i for i in all_cards if not(i in cards) ]

for s in missing_cards:
    print(s)

Submission status: Accepted

Solution code:
n = int(input())

cards = []
have = []
nothave = []

for j in range(1, 14):
    cards.append(("S", j))
for j in range(1, 14):
    cards.append(("H", j))
for j in range(1, 14):
    cards.append(("C", j))
for j in range(1, 14):
    cards.append(("D", j))

for i in range(n):
    a, b = input().split()
    have.append((a, int(b)))

for i in range(52):
    if cards[i] not in have:
        nothave.append(cards[i])

for i in nothave:
    print(i[0], i[1])

Submission status: Accepted

Solution code:
n=int(input())
chr=[]
dig=[]
Snumber,Hnumber,Cnumber,Dnumber=[],[],[],[]
a,b,c,d=[1,2,3,4,5,6,7,8,9,10,11,12,13],[1,2,3,4,5,6,7,8,9,10,11,12,13],[1,2,3,4,5,6,7,8,9,10,11,12,13],[1,2,3,4,5,6,7,8,9,10,11,12,13]
S_s,H_s,C_s,D_s=[],[],[],[]
for l in range(n):
   card=list(map(str,input().split(" ")))
   chr.append(card[0])
   dig.append(card[1])
for l in range(n):
    if chr[l]=='S':
        Snumber.append(dig[l])
    elif  chr[l]=='H':
        Hnumber.append(dig[l])
    elif chr[l]=='C':
        Cnumber.append(dig[l])
    else:
        Dnumber.append(dig[l])
s=list(map(int,Snumber))
s.sort()
h=list(map(int,Hnumber))
h.sort()
c2=list(map(int,Cnumber))
c2.sort()
d2=list(map(int,Dnumber))
d2.sort()
k=0           
for i in range(len(Snumber[:])):
    n=int(i)
    m=int(s[n])-1
    del a[m-k]
    k=k+1
k=0           
for i in range(len(Hnumber[:])):
    n=int(i)
    m=int(h[n])-1
    del b[m-k]
    k=k+1
k=0           
for i in range(len(Cnumber[:])):
    n=int(i)
    m=int(c2[n])-1
    del c[m-k]
    k=k+1
k=0           
for i in range(len(Dnumber[:])):
    n=int(i)
    m=int(d2[n])-1
    del d[m-k]
    k=k+1

for i in range(len(a)):
    print('S '+str(a[i]))
for i in range(len(b)):
    print('H '+str(b[i]))
for i in range(len(c)):
    print('C '+str(c[i]))
for i in range(len(d)):
    print('D '+str(d[i]))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
'import sys'
c={
    'S':[0]*13,
    'H':[0]*13,
    'C':[0]*13,
    'D':[0]*13
}
n=int(input())
for i in range(n):
    s,num=input().split()
    c[s][int(num)-1]=1
for i in["S","H","C","D"]:
    for j in range(13):
        if c[i][j]==0:
            print(i,j+1)

Submission status: Accepted

Solution code:
n = int(input())
s = []
h = []
c = []
d = []
numbers = range(1, 14)
for _ in range(n):
  string, num = input().split()
  if "S" in string:
    s.append(int(num))
  elif "H" in string:
    h.append(int(num))
  elif "C" in string:
    c.append(int(num))
  else:
    d.append(int(num))
set_s = set(numbers) - set(s)
set_h = set(numbers) - set(h)
set_c = set(numbers) - set(c)
set_d = set(numbers) - set(d)
for element in sorted(set_s):
  print("S %d" % element)
for element in sorted(set_h):
  print("H %d" % element)
for element in sorted(set_c):
  print("C %d" % element)
for element in sorted(set_d):
  print("D %d" % element)

Submission status: Accepted

Solution code:
l = [x + " " + y for x in ["S", "H", "C", "D"] for y in [str(i) for i in range(1, 14)]]
n = int(input())
while n > 0:
  l.remove(input())
  n -= 1
for i in l:
  print(i)

Submission status: Accepted

Solution code:
n = int(input())
card = [input().split() for i in range(n)]
suits ='SHCD'
lsts = [[0 for i in range(13)] for j in range(4)]

for i in range (n):
    for j in range(4):
        if card[i][0] == suits[j]:
            lsts[j][int(card[i][1])-1] += 1
for i in range (4):
    for j in range(13):
        if lsts[i][j] == 0:
            print(suits[i],j+1)

Submission status: Accepted

Solution code:
n = int(input())
arr = [[0 for i in range(4)] for j in range(13)]

for i in range(n):
	nums = list(input().split(" "))
	card = int(nums[1]) -1
	if nums[0] == "S":
		arr[card][0] = 1
	elif nums[0] == "H":
		arr[card][1] = 1
	elif nums[0] == "C":
		arr[card][2] = 1
	elif nums[0] == "D":
		arr[card][3] = 1

for y in range(4):
	for x in range(13):
		if arr[x][y] != 1 and y == 0:
				print("S" + " " + str(x+1))
		elif arr[x][y] != 1 and  y == 1:
				print("H" + " " + str(x+1))
		elif arr[x][y] != 1 and  y == 2:
				print("C" + " " + str(x+1))
		elif arr[x][y] != 1 and  y == 3:
				print("D" + " " + str(x+1))

Submission status: Accepted

Solution code:
dict_list = {'S': [], 'H': [], 'C': [], 'D': []}
out_list = {'S': [], 'H': [], 'C': [], 'D': []}
count = int(input())
for i in range(count):
    x, y = input().split()
    dict_list[x].append(int(y))

for key, value in dict_list.items():
    for num in range(1, 14):
        if num not in value:
            out_list[key].append(num)

for key, value in out_list.items():
    for num in value:
        print('{a} {b}'.format(a=key, b=num))

Submission status: Accepted

Solution code:
from collections import defaultdict

if __name__ == '__main__' :
        n = int(input())
        dic = defaultdict(list)
        for i in range(n):
            s,num = input().split(" ")
            dic[s].append(int(num))

        for s in ["S","H","C","D"]:
            for i in range(1,14):
                if i not in dic[s]:
                    print(s + " " + str(i))

Submission status: Accepted

Solution code:
import sys

l = []
keys = ['S','H','C','D']
dicts = {}
for i in sys.stdin:
    l.append(i)

for i in range(1,len(l)):
    l[i] = l[i].split()

for i in range(1,len(l)):
    if l[i][0] not in dicts:
        a = []
        a.append(int(l[i][1]))
        dicts[l[i][0]] = a
    else:
        dicts[l[i][0]].append(int(l[i][1]))

for key in dicts:
    dicts[key] = sorted(dicts[key])

for data in keys:
    for j in range(1,14):
        if j not in dicts[data]:
            print(data,j)

Submission status: Accepted

Solution code:
cardset = ["S 1","S 2","S 3","S 4","S 5","S 6","S 7","S 8","S 9","S 10","S 11","S 12","S 13","H 1","H 2","H 3","H 4","H 5","H 6","H 7","H 8","H 9","H 10","H 11","H 12","H 13","C 1","C 2","C 3","C 4","C 5","C 6","C 7","C 8","C 9","C 10","C 11","C 12","C 13","D 1","D 2","D 3","D 4","D 5","D 6","D 7","D 8","D 9","D 10","D 11","D 12","D 13"]
n = int(input())
i = 0
while i < n:
    cardset.remove(str(input()))
    i += 1
for x in cardset:
    print(x)

Submission status: Accepted

Solution code:
d = {"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]}
n = int(input())
for i in range(n):
    N, M = map(str,input().split())
    d[N][int(M)-1] ="None"

for j in range(len(d)):
    if j==0:
        list_d = d["S"]
        c = "S"
    elif j == 1:
        list_d = d["H"]
        c = "H"
    elif j == 2:
        list_d = d["C"]
        c = "C"
    else:
        list_d = d["D"]
        c = "D"
    for i in range(len(list_d)):
        if(list_d[i] != "None"):
            print(c , list_d[i])

Submission status: Accepted

Solution code:
spade = [True for i in range(13)]
heart = [True for i in range(13)]
club = [True for i in range(13)]
dia = [True for i in range(13)]

n = int(input())
for i in range(n):
  suit, num = map(str,input().split())
  if suit == "S":
    spade[int(num)-1] = False
  elif suit =="H":
    heart[int(num)-1] = False
  elif suit == "C":
    club[int(num)-1] = False
  elif suit == "D":
    dia[int(num)-1] = False

for i in range(13):
  if spade[i]:
    print("S {0}".format(i+1))

for i in range(13):
  if heart[i]:
    print("H {0}".format(i+1))

for i in range(13):
  if club[i]:
    print("C {0}".format(i+1))

for i in range(13):
  if dia[i]:
    print("D {0}".format(i+1))

Submission status: Accepted

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

n = int(input())
s = []
h = []
c = []
d = []

for i in range(13):
    s.append(i + 1)
    h.append(i + 1)
    c.append(i + 1)
    d.append(i + 1)

for j in range(n):
    x = list(input().split())
    if x[0] is 'S':
        s.remove(int(x[1]))
    elif x[0] is 'H':
        h.remove(int(x[1]))
    elif x[0] is 'C':
        c.remove(int(x[1]))
    elif x[0] is 'D':
        d.remove(int(x[1]))

if len(s) != 0:
    for i in range(len(s)):
        print('{0} {1}'.format('S', s[i]))

if len(h) != 0:
    for i in range(len(h)):
        print('{0} {1}'.format('H', h[i]))

if len(c) != 0:
    for i in range(len(c)):
        print('{0} {1}'.format('C', c[i]))

if len(d) != 0:
    for i in range(len(d)):
        print('{0} {1}'.format('D', d[i]))

Submission status: Accepted

Solution code:
from collections import OrderedDict as od
a = {n for n in range(1,14)}
dic = od({"S":[],"H":[], "C":[], "D":[]})
N = int(input())
for n in range(N):
    card, num = tuple(input().split())
    dic[card].append(int(num))

dic["S"] = list(a - set(dic["S"]))
dic["H"] = list(a - set(dic["H"]))
dic["C"] = list(a - set(dic["C"]))
dic["D"] = list(a - set(dic["D"]))

for card,num in dic.items():
    num.sort()
    for n in num:
        print("{0} {1}".format(card,n))

Submission status: Accepted

Solution code:
cardTypeList = ['S', 'H', 'C', 'D']
havingCardList = []
for i in range(0, int(input())):
    cardType, num = list(input().split())
    havingCardList.append([cardType, int(num)])

# 全体を確認して　持っているリストになかったら表示用リストに追加
displayList = []
for i in cardTypeList:
    for j in range(1, 13 + 1):
        compareList = [i, j]
        if compareList not in havingCardList:
            print(*compareList)

Submission status: Accepted

Solution code:
n = int(input())
S = [0 for i in range(13)]
H = [0 for i in range(13)]
C = [0 for i in range(13)]
D = [0 for i in range(13)]
for i in range(n):
	data = input().split()
	num = int(data[1])
	if data[0]=='S':
		S[num-1] = 1
	elif data[0]=='H':
		H[num-1] = 1
	elif data[0]=='C':
		C[num-1] = 1
	else:
		D[num-1] = 1
for j in range(13):
	if S[j]==0:
		print('S %d' % (j+1))
for j in range(13):
	if H[j]==0:
		print('H %d' % (j+1))
for j in range(13):
	if C[j]==0:
		print('C %d' % (j+1))
for j in range(13):
	if D[j]==0:
		print('D %d' % (j+1))

Submission status: Accepted

Solution code:
n = int(input())
i = 0

cardlist = ["S 1","S 2","S 3","S 4","S 5","S 6","S 7","S 8","S 9","S 10","S 11","S 12","S 13",
"H 1","H 2","H 3","H 4","H 5","H 6","H 7","H 8","H 9","H 10","H 11","H 12","H 13",
"C 1","C 2","C 3","C 4","C 5","C 6","C 7","C 8","C 9","C 10","C 11","C 12","C 13",
"D 1","D 2","D 3","D 4","D 5","D 6","D 7","D 8","D 9","D 10","D 11","D 12","D 13"
]
while i < n:
	card = input()
	cardlist.remove(card)
	i += 1
	
for k in range(len(cardlist)):
	print(cardlist[k])

Submission status: Accepted

Solution code:
N = int(input())
card = []
for x in range(52):
    card.append(0)
for x in range(N):
    a, b = map(str, input().split())
    if a == 'S':
        card[13 * 0 + int(b) - 1] = 1
    elif a == 'H':
        card[13 * 1 + int(b) - 1] = 1
    elif a == 'C':
        card[13 * 2 + int(b) - 1] = 1
    elif a == 'D':
        card[13 * 3 + int(b) - 1] = 1
for x in range(52):
    if card[x] == 0:
        if x < 13: print("S " + str(x + 1))
        elif x < 26: print("H " + str(( x + 1) - 13 ))
        elif x < 39: print("C " + str(( x + 1) - 26 ))
        else: print("D " + str(( x + 1) - 39))

Submission status: Accepted

Solution code:
a = int(input())
cards = [[False for x in range(13)] for y in range(4)]
for i in range(a):
    s, v = map(str, input().split())
    u = int(v)
    if s == 'S':
        cards[0][u-1] = True
    elif s == 'H':
        cards[1][u-1] = True
    elif s == 'C':
        cards[2][u-1] = True
    elif s == 'D':
        cards[3][u-1] = True
    else:
        pass

for j in range(13):
    if cards[0][j]:
        continue
    else:
        print("S ", end="")
        print(j+1)

for j in range(13):
    if cards[1][j]:
        continue
    else:
        print("H ", end="")
        print(j+1)

for j in range(13):
    if cards[2][j]:
        continue
    else:
        print("C ", end="")
        print(j+1)

for j in range(13):
    if cards[3][j]:
        continue
    else:
        print("D ", end="")
        print(j+1)

Submission status: Accepted

Solution code:
#! python3
# finding_missing_cards.py

cards = {mark: [] for mark in ['S', 'H', 'C', 'D']}

n = int(input())
for i in range(n):
    mark, num = [x for x in input().split(' ')]
    cards[mark].append(int(num))

for k, v in cards.items():
    for i in range(1, 14):
        if i not in v:
            print(k, i)

Submission status: Accepted

Solution code:
n = int(input())

remind = []
for i in range(n):
   remind.append(input())

egaraList = ["S ", "H ", "C ", "D "]
for egara in egaraList:
   for j in range(1, 14):
      if egara + str(j) not in remind:
         print(egara + str(j))

Submission status: Accepted

Solution code:
n = int(input()) 

remind = [] 
for i in range(n): 
   remind.append(input()) 

egara = ["S ", "H ", "C ", "D "] 
for i in range(4): 
   for j in range(1, 14): 
      if egara[i] + str(j) not in remind: 
         print(egara[i] + str(j))