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())
a = [input().split() for i in range(N)]
Set = {}
n = list(range(1,14))
Set['S'] = n.copy()
Set['H'] = n.copy()
Set['C'] = n.copy()
Set['D'] = n.copy()

for suit,num in a:
    Set[suit].remove(int(num))

for i in Set['S']:
    print("S {}".format(i))
for i in Set['H']:
    print("H {}".format(i))
for i in Set['C']:
    print("C {}".format(i))
for i in Set['D']:
    print("D {}".format(i))

Submission status: Accepted

Solution code:
s = []
h = []
c = []
d = []
for i in range(1, 14):
    s.append('S ' + str(i))
    h.append('H ' + str(i))
    c.append('C ' + str(i))
    d.append('D ' + str(i))

n = int(input())
i = 1
while i <= n:
    a = str(input())
    if (a in s):
        s.remove(a)
    elif (a in h):
        h.remove(a)
    elif (a in c):
        c.remove(a)
    elif (a in d):
        d.remove(a)
    i += 1

if (len(s) > 0):
    print('\n'.join(s))
if (len(h) > 0):
    print('\n'.join(h))
if (len(c) > 0):
    print('\n'.join(c))
if (len(d) > 0):
    print('\n'.join(d))

Submission status: Accepted

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

cDict = {}
for mark in 'S H C D'.split(' '):
  for rank in range(1, 14):
    cDict[mark + ' ' + str(rank)] = 0

for nn in range(n[0]):
  c = input()
  cDict[c] = 1

for mark in 'S H C D'.split(' '):
  for rank in range(1, 14):
    key = mark + ' ' + str(rank)
    if cDict[key] == 0:
      print(key)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
S = []
H = []
C = []
D = []
for i in range(0, n):
 x = list(input().split())
 if x[0] == 'S':
  S.append(int(x[1]))
 elif x[0] == 'H':
  H.append(int(x[1]))
 elif x[0] == 'C':
  C.append(int(x[1]))
 else:
  D.append(int(x[1]))
def pr(list, type):
 list.sort()
 for i in range(1, 14):
  if i not in list:
   print("{0} {1}".format(type, i))
pr(S, 'S')
pr(H, 'H')
pr(C, 'C')
pr(D, 'D')

Submission status: Accepted

Solution code:
n = input()
s = range(1,14)
h = range(1,14)
c = range(1,14)
d = range(1,14)


for i in range(n):
    a = raw_input().split()
    num = int(a[1])
    if a[0] == "S":
        s.remove(num)
    elif a[0] == "H":
        h.remove(num)
    elif a[0] == "C":
        c.remove(num)
    elif a[0] == "D":
        d.remove(num)


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:
from collections import OrderedDict
d = OrderedDict()
d['S'] = set()
d['H'] = set()
d['C'] = set()
d['D'] = set()
a = frozenset(range(1,14))

n = int(input())
for i in range(n):
    s, r = input().split()
    d[s].add(int(r))

for k, v in d.items():
    racks = a.difference(v)
    for rack in racks:
        print(k, rack)

Submission status: Accepted

Solution code:
n = int(input())
cards = []
for i in range(n):
    ins = input().split()
    suit = ins[0]
    num = ins[1]
    cards.append([suit, num])

for suit in ["S", "H", "C", "D"]:
    for i in range(1, 14):
        if len([card for card in cards if card[0] == suit and card[1] == str(i)]) == 0:
            print(" ".join([suit, str(i)]))

Submission status: Accepted

Solution code:
cards = {
'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)]
}
n = int(input())
for i in range(n):
    c, s = input().split()
    cards[c][int(s)-1] = int(s)
for i in ('S','H','C','D'):
    for j in range(13):
        if cards[i][j] == 0:
            print('{} {}'.format(i,j+1))

Submission status: Accepted

Solution code:
pictures = ['S','H','C','D']
card_li = []
for i in range(4):
    for j in range(1,14):
        card_li.append(pictures[i] + ' ' + str(j))
n = int(input())
for i in range(n): del card_li[card_li.index(input())]
for i in card_li:
    print(i)

Submission status: Accepted

Solution code:
#coding:utf-8

def ch2int(a):
    s=["S","H","C","D"]
    for i,b in enumerate(s):
        if a==b:
            return i

def int2ch(i):
    s=["S","H","C","D"]
    return s[i]

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

for i in range(n):
    c,x=list(map(str,input().split()))

    card[ch2int(c)][int(x)-1]=1

for i,x in enumerate(card):
    for j,y in enumerate(x):
        if y==0:
            print(int2ch(i)+" "+str(j+1))

Submission status: Accepted

Solution code:
flag = [False] * 53
n = int(input())
for i in range(n):
    c, n = map(str, input().split())
    n = int(n)
    if(c == "S"):
        flag[n] = True
    elif(c == "H"):
        flag[13 + n] = True
    elif(c == "C"):
        flag[26 + n] = True
    else:
        flag[39 + n] = True
suit = ["S", "H", "C", "D"]
for i in range(1, len(flag)):
    if(flag[i] == False):
        print(suit[(i - 1) // 13], (i - 1) % 13 + 1)

Submission status: Accepted

Solution code:
n = int(input())
s_l = []
h_l = []
c_l = []
d_l = []
for i in range(1, 14):
  s_l.append(i)
  h_l.append(i)
  c_l.append(i)
  d_l.append(i)

for i in range(0, n):
  mark, num = input().split()
  if mark == "S":
    s_l.remove(int(num))
  if mark == "H":
    h_l.remove(int(num))
  if mark == "C":
    c_l.remove(int(num))
  if mark == "D":
    d_l.remove(int(num))

for s in s_l:
  print("S {}".format(s))
for h in h_l:
  print("H {}".format(h))
for c in c_l:
  print("C {}".format(c))
for d in d_l:
  print("D {}".format(d))

Submission status: Accepted

Solution code:
S = ['S', 'H', 'C', 'D']
D = map(str, range(1, 14))
n = input()
T = [tuple(raw_input().split()) for _ in xrange(n)]

for t in [(s, d) for s in S for d in D]:
    if t not in T:
        print ' '.join(t)

Submission status: Accepted

Solution code:
trump_dictionary = {}
keys = ['S', 'H', 'C', 'D']
for key in keys:
    for num in range(13):
        trump_dictionary[key + ' ' + str(num + 1)] = 0

num = int(raw_input())
counter = 0
while counter < num:
    key = raw_input()
    if key in trump_dictionary:
        trump_dictionary.pop(key)
    counter += 1

for key in keys:
    for num in range(13):
        if key + ' ' + str(num + 1) in trump_dictionary:
            print(key + ' ' + str(num + 1))

Submission status: Accepted

Solution code:
s = list(range(1,14))
h = list(range(1,14))
c = list(range(1,14))
d = list(range(1,14))

n = int(input())
while n > 0:
    x = input().split(' ')
    x[1] = int(x[1])
    if x[0] == 'S':
        s[x[1]-1] = 0
    elif x[0] == 'H':
        h[x[1]-1] = 0
    elif x[0] == 'C':
        c[x[1]-1] = 0
    elif x[0] == 'D':
        d[x[1]-1] = 0
    n -= 1

for t in s:
    if t != 0: print("S %d" % t)
for t in h:
    if t != 0: print("H %d" % t)
for t in c:
    if t != 0: print("C %d" % t)
for t in d:
    if t != 0: print("D %d" % t)

Submission status: Accepted

Solution code:
trump = {
        "S": list(range(1,14)),
        "H": list(range(1,14)),
        "C": list(range(1,14)),
        "D": list(range(1,14)),
        }
for i in range(0, int(input())):
    a,b = input().split()
    trump[a].remove(int(b))
for k in ["S","H","C","D"]:
    for e in trump[k]:
        print("{0} {1}".format(k, str(e)))

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    # ??????????????\???
    my_cards = []  # ????????¶?????\??????????????????????????§
    card_num = int(input())
    for i in range(card_num):
        data = [x for x in input().split(' ')]
        suit = data[0]
        rank = int(data[1])
        my_cards.append((suit, rank))

    full_cards = []  # 52?????¨????????£??????????????????
    for r in range(1, 13+1):
        full_cards.append(('S', r))
        full_cards.append(('H', r))
        full_cards.append(('D', r))
        full_cards.append(('C', r))

    # ??????????????¨???????¶??????????????¢???????????????°??????????????????
    missing_cards = set(my_cards) ^ set(full_cards)
    missing_spades = [x for x in missing_cards if x[0]=='S']
    missing_hearts = [x for x in missing_cards if x[0] == 'H']
    missing_clubs = [x for x in missing_cards if x[0] == 'C']
    missing_diamonds = [x for x in missing_cards if x[0] == 'D']
    missing_spades.sort(key=lambda x: x[1])
    missing_hearts.sort(key=lambda x: x[1])
    missing_clubs.sort(key=lambda x: x[1])
    missing_diamonds.sort(key=lambda x: x[1])

    # ????¶???????????????¨???
    for s, r in missing_spades:
        print('{0} {1}'.format(s, r))
    for s, r in missing_hearts:
        print('{0} {1}'.format(s, r))
    for s, r in missing_clubs:
        print('{0} {1}'.format(s, r))
    for s, r in missing_diamonds:
        print('{0} {1}'.format(s, r))

Submission status: Accepted

Solution code:
marks = ['S', 'H', 'C', 'D']
cards = {x:[0 for y in range(13)] for x in marks}

cnt = int(input())
while cnt > 0:
    values = input().split()
    cards[values[0]][int(values[1]) - 1] += 1
    cnt -= 1

for key in marks:
    for val in range(13):
        if 0 == cards[key][val]:
            print('{0} {1}'.format(key, val + 1))

Submission status: Accepted

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

g = {0:"S",1:"H",2:"C",3:"D"}
h = {"S":0, "H":1, "C":2, "D":3}

for i in range(n):
    s,r = input().split()
    l[h[s]][int(r)-1] = 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
cards = [[False] * 14 for i in range(4)]
n = int(input())
for i in range(n):
    suit, rank = input().split()
    r = int(rank)
    if suit == "S":
        s = 0
    elif suit == "H":
        s = 1
    elif suit == "C":
        s = 2
    else:
        s = 3
    cards[s][r] = True

name = ["S", "H", "C", "D"]
for s in range(4):
    for r in range(1, 14):
        if not cards[s][r]:
            print(name[s], r)

Submission status: Accepted

Solution code:
cards = [[False for j in range(14)]for i in range(4)]
n = int(input())
for i in range(n):
	suit,rank = input().split()
	r = int(rank)
	if suit == "S":
		s = 0
	elif suit == "H":
		s = 1
	elif suit == "C":
		s = 2
	else:
		s = 3
	cards[s][r] = True
  	
name = ["S","H","C","D"]
for s in range(4):
	for r in range(1,14):
		if not cards[s][r]:
			print(name[s],r)

Submission status: Accepted

Solution code:
n=int(input())
t=dict()
tramp=[[True]*13 for i in range(4)]
pic={"S":0,"H":1,"C":2,"D":3}
pic2={j:i for i,j in pic.items()}
for i in range(n):
    a,b=input().split()
    tramp[pic[a]][int(b)-1]=False
for i in range(4):
    for j in range(13):
        if tramp[i][j]:
            print(pic2[i],j+1)

Submission status: Accepted

Solution code:
l=[]
for mark in ["S","H","C","D"]:
	for i in range(1,14):
		l.append(mark+" "+str(i))
n=input()
for i in range(int(n)):
	l.remove(input())
for i in l:
	print(i)

Submission status: Accepted

Solution code:
suits = {"S":0, "H":1, "C":2, "D":3}
cards = [[0 for i2 in range(13)] for i1 in ("S", "H", "C", "D")]
n = int(input())

for i in range(n):
    (suit, rank) = input().split(" ")
    cards[suits[suit]][int(rank) - 1] = 1

for suit in ("S", "H", "C", "D"):
    for number in range(13):
        if cards[suits[suit]][number] != 1:
            print(suit, number + 1)

Submission status: Accepted

Solution code:
from collections import OrderedDict

cards = OrderedDict()
cards['S'] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
cards['H'] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
cards['C'] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
cards['D'] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]

cardnow = int(input())
for j in range(cardnow):
    s,n = [i for i in input().split()]
    n = int(n)
    cards[s].remove(n)

for k,v in cards.items():
    for vv in v:
        print('{} {}'.format(k,vv))

Submission status: Accepted

Solution code:
# coding: utf-8
# Here your 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:
n=input()
s=range(1,14)
h=range(1,14)
c=range(1,14)
d=range(1,14)
trump={'S':s,'C':c,'H':h,'D':d}
for i in range(n):
    suit,num=raw_input().split()
    num=int(num)
    trump[suit].remove(num)
count=0
for suit in ['S','H','C','D']:
    for num in trump[suit]:
        print('%s %d'%(suit,num))

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())
base = [mark + str(rank) for mark in ["S ", "H ", "C ", "D "] for rank in range(1,14)]
for card in [input() for i in range(n)]:
    base.remove(card)
for elem in base:
    print(elem)

Submission status: Accepted

Solution code:
d = {}
m = int(input())
for i in range(m):
    [sp,nm] = input().split()
    d[sp + nm] = True

for sp in ['S','H','C','D']:
    for nm in range(1,14):
        key = sp + str(nm)
        if not key in d :
            print(sp,nm)

Submission status: Accepted

Solution code:
dic = {} #?????????"??????????¨???? ??????"??????????????°

for cardtype in ['S','H','C','D']:
    for i in range(1,13+1):
        dic["{0} {1}".format(cardtype,i)] = 0

n = int(input())
for i in range(n):
    dic[input()] += 1

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

Submission status: Accepted

Solution code:
S = 13 * 0
H = 13 * 1
C = 13 * 2
D = 13 * 3
 
#???????????????????¨??????????????????????????????????????????????????????????,???????????????:1???
#??????????????????????????????5???S(???0)+5???????????????11???D(???39)+11??§??¨??????
#?????????0???????????¨
card_count = [0 for i in range(53)] 

n = int(input())

for i in range(n):
    card_type, card_num = input().split()
    card_count[eval(card_type)+int(card_num)] += 1 #???????????£????¨??????¨???????????????????????°???1????¶????

for s in ['S','H','C','D']:
    for i in range(1, 13+1):
        if card_count[eval(s)+i] == 0: #??????????????°???0??????
            print("{0} {1}".format(s,i)) #?¨??????¨?????????????????????

Submission status: Accepted

Solution code:
'''
ITP-1_6-B
 ????¶???????????????????????????????
???????????±?????¨?????????????????????????????????????????¨????????¨?????????52?????????????????????????????? n ???????????????????????????????????????????????????????????? n ????????????????????\?????¨??????????¶??????????????????????????????????????????°?????????????????????????????????
???????????????????????£?????????????????????????????§??????????????????52?????????????????§??????
52??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????13??????????????????????????????
???Input
?????????????????????????????£??????????????????????????° n (n ??? 52)????????????????????????

?¶??????? n ??????????????????????????????????????????????????????????????????????????????????????§???????????????????????¨??´??°??§??????
????????????????????????????????¨?????????????????????'S'???????????????'H'???????????????'C'???????????????'D'??§??¨?????????????????????
??´??°??????????????????????????????(1 ??? 13)?????¨??????????????????
???Output
?¶??????????????????????????????????1???????????????????????????????????????????????\?????¨????§?????????????????????§???????????????????????¨??´??°??§?????????????????????????????????????????\????????¨????????¨????????????
???????????????????????????????????????????????????????????????????????§???????????????????????????
????????????????????´??????????????????????°????????????????????????????
'''
# import

# ?????°??????????????????

trumpData = {
        "S": list(range(1,14)),
        "H": list(range(1,14)),
        "C": list(range(1,14)),
        "D": list(range(1,14)),
        }

taroCard = int(input())
# ??????????????§??????????????????????????????????????????
for nc in range(taroCard):
    (trumpDataLostMark, trumpDataLostCnt) = input().split()
    index = trumpData[trumpDataLostMark].index(int(trumpDataLostCnt))
    del trumpData[trumpDataLostMark][index]

# ????¶???????????????????????????????
for trumpDataMark in ['S', 'H', 'C', 'D']:
    for trumpDataCnt in trumpData[trumpDataMark]:
        # Output
        print(trumpDataMark, trumpDataCnt)

Submission status: Accepted

Solution code:
#coding:utf-8

N = int(input())
buff = [y for x in range(N) for y in [input().split()]]
data = [(x[0], int(x[1])) for x in buff]
S = [x for x in data if x[0]=="S"]
H = [x for x in data if x[0]=="H"]
D = [x for x in data if x[0]=="D"]
C = [x for x in data if x[0]=="C"]

ansS = [("S", x) for x in range(1,14) if ("S", x) not in S]
ansH = [("H", x) for x in range(1,14) if ("H", x) not in H]
ansD = [("D", x) for x in range(1,14) if ("D", x) not in D]
ansC = [("C", x) for x in range(1,14) if ("C", x) not in C]

ans = ansS + ansH + ansC + ansD
[print(str(x[0]) + " " + str(x[1])) for x in ans]

Submission status: Accepted

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

n = int(input())
a = ['']*n
b = [0]*n
for i in range(n):
    a[i],b[i] = input().split()

array_S = []
for i in range(14):
    count = 0
    for j in range(n):
        if i == int(b[j]):
            if a[j] == 'S':
                break
        count += 1
        if count == n:
            array_S.append(i)
            
array_H = []
for i in range(14):
    count = 0
    for j in range(n):
        if i == int(b[j]):
            if a[j] == 'H':
                break
        count += 1
        if count == n:
            array_H.append(i)

array_C = []
for i in range(14):
    count = 0
    for j in range(n):
        if i == int(b[j]):
            if a[j] == 'C':
                break
        count += 1
        if count == n:
            array_C.append(i)
            
array_D = []
for i in range(14):
    count = 0
    for j in range(n):
        if i == int(b[j]):
            if a[j] == 'D':
                break
        count += 1
        if count == n:
            array_D.append(i)
            
for i in range(1,len(array_S)):
    print('S',array_S[i],sep =' ')
for i in range(1,len(array_H)):
    print('H',array_H[i],sep =' ')
for i in range(1,len(array_C)):
    print('C',array_C[i],sep =' ')
for i in range(1,len(array_D)):
    print('D',array_D[i],sep =' ')

Submission status: Accepted

Solution code:
l=[]

for x in ['S','H','C','D']:
    for y in [str(i+1) for i in range(13)]:
        l += [x+' '+y]

for n in range(int(input())):
  l.remove(input())
for i in l:
  print(i)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(len(suits)):
    for j in range(1, 14):
        cards.append(suits[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:
import sys

lines = [line for line in sys.stdin]
gs =['S','H','C','D']
js = list(map(str,range(1,14)))
all=[g + " " +j for g in gs for j in js]

for g in lines[1:]:
    g=g.strip()
    all.remove(g)

for g in all:
    print(g)

Submission status: Accepted

Solution code:
import sys

#f = open("test.txt", "r")
f = sys.stdin

num_rank = 14
s_list = [False] * num_rank
h_list = [False] * num_rank
c_list = [False] * num_rank
d_list = [False] * num_rank

n = f.readline()

n = int(n)

for i in range(n):
	[suit, num] = f.readline().split()
	num = int(num)
	if suit == "S":
		s_list[num] = True
	elif suit == "H":
		h_list[num] = True
	elif suit == "C":
		c_list[num] = True
	else:
		d_list[num] = True

for i in range(1, num_rank):
	if not s_list[i]:
		print("S " + str(i))
for i in range(1, num_rank):
	if not h_list[i]:
		print("H " + str(i))
for i in range(1, num_rank):
	if not c_list[i]:
		print("C " + str(i))
for i in range(1, num_rank):
	if not d_list[i]:
		print("D " + str(i))

Submission status: Accepted

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

def adding(card):
    if card[0] == 'S':
        S.append(int(card[1]))
    else:
        if card[0] == 'H':
            H.append(int(card[1]))
        else:
            if card[0] == 'C':
                C.append(int(card[1]))
            else:
                if card[0] == 'D':
                    D.append(int(card[1]))

def sort():
    S.sort()
    H.sort()
    C.sort()
    D.sort()

def check(pattern,cards):
    answer=[]
    for i in range(1,13+1):
        if not (i in cards):
            print pattern,i


if __name__ == '__main__':
    number = input()
    for i in range(number):
        card = map(str,raw_input().split())
        adding(card)
    sort()
    check('S',S)
    check('H',H)
    check('C',C)
    check('D',D)

Submission status: Accepted

Solution code:
cards = list()
mark = ["S","H","C","D"]
for i in (mark):
    for j in range(1,14):
        cards.append( i + " " + str(j) )
n = int(input())
for i in range(n):
    a = input()
    cards.remove(a)
if len(cards) > 0:
    print("\n" .join(cards))

Submission status: Accepted

Solution code:
#!usr/bin/env python3

import sys


def main():
    # s: spades
    # h: hearts
    # c: clubs
    # d: diamonds
    card_deck = {'S': [], 'H': [], 'C': [], 'D': []}
    card_symbols = ['S', 'H', 'C', 'D']

    n = int(sys.stdin.readline())
    for i in range(n):
        lst = [card for card in sys.stdin.readline().split()]
        card_deck[lst[0]].append(lst[1])

    for key, value in card_deck.items():
        card_deck[key].sort()

    for i in card_symbols:
        for card in range(1, 14):
            if not str(card) in card_deck[i]:
                print(i, card)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!usr/bin/env python3

import sys


def main():
    # S: spades
    # H: hearts
    # C: clubs
    # D: diamonds
    card_deck = {'S': [], 'H': [], 'C': [], 'D': []}
    card_symbols = ['S', 'H', 'C', 'D']

    n = int(sys.stdin.readline())
    for i in range(n):
        lst = [card for card in sys.stdin.readline().split()]
        card_deck[lst[0]].append(lst[1])

    for key, value in card_deck.items():
        card_deck[key].sort()

    for i in card_symbols:
        for card in range(1, 14):
            if not str(card) in card_deck[i]:
                print(i, card)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!usr/bin/env python3

import sys


def main():
    # S: spades
    # H: hearts
    # C: clubs
    # D: diamonds
    card_deck = {'S': [], 'H': [], 'C': [], 'D': []}
    card_symbols = ['S', 'H', 'C', 'D']

    n = int(sys.stdin.readline())
    for i in range(n):
        lst = [card for card in sys.stdin.readline().split()]
        card_deck[lst[0]].append(lst[1])

    for i in card_symbols:
        for card in range(1, 14):
            if not str(card) in card_deck[i]:
                print(i, card)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!usr/bin/env python3

import sys


def init_card_deck():
    # S: spades
    # H: hearts
    # C: clubs
    # D: diamonds
    card_deck = {'S': [], 'H': [], 'C': [], 'D': []}
    n = int(sys.stdin.readline())

    for i in range(n):
        lst = [card for card in sys.stdin.readline().split()]
        card_deck[lst[0]].append(lst[1])

    return card_deck


def print_missing_cards(card_deck):
    card_symbols = ['S', 'H', 'C', 'D']

    for i in card_symbols:
        for card in range(1, 14):
            if not str(card) in card_deck[i]:
                print(i, card)


def main():
    print_missing_cards(init_card_deck())


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

S = [False for i in range(13)]
D = [False for i in range(13)]
C = [False for i in range(13)]
H = [False for i in range(13)]


for i in range(n):
    a,b = input().split()
    b = int(b)
    if a == "S":
        S[b-1] = True
    elif a == "D":
        D[b-1] = True
    elif a == "C":
        C[b-1] = True
    elif a == "H":
        H[b-1] = True
        
for i in range(13):
    if S[i] == False:
        print("S "+str(i+1))

for i in range(13):
    if H[i] == False:
        print("H "+str(i+1))
        
for i in range(13):
    if C[i] == False:
        print("C "+str(i+1))
        
for i in range(13):
    if D[i] == False:
        print("D "+str(i+1))

Submission status: Accepted

Solution code:
all = [x for x in range(1,53)]

N = int(input())
i = 1

while i <= N:
	M, num = input().split()
	num = int(num)
	if M == 'S':
		all.remove(num)
	elif M == 'H':
		all.remove(num+13)
	elif M == 'C':
		all.remove(num+26)
	elif M == 'D':
		all.remove(num+39)
	
	i += 1

sN = 52 - N

for j in range(sN):
	if all[j] // 13 == 0 or (all[j] // 13 == 1 and all[j] % 13 == 0):
		print("S {}".format(all[j]))
	elif all[j] // 13 == 1 or (all[j] // 13 == 2 and all[j] % 13 == 0):
		print("H {}".format(all[j]-13))
	elif all[j] // 13 == 2 or (all[j] // 13 == 3 and all[j] % 13 == 0):
		print("C {}".format(all[j]-26))
	else:
		print("D {}".format(all[j]-39))

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:
import itertools

def find_missing(l):
    """
    l: a list of cards
    returns a list of missing cards in order of suit(spades, harts, clubs, diamonds) and rank
    """
    suits = ['S', 'H', 'C', 'D']
    ranks = [i for i in range(1, 14)]
    cards = list(itertools.product(suits, ranks))

    for suit in suits:
        for i in range(1, 14):
            if (suit, i) in l:
                cards.remove((suit, i))

    return cards

if __name__ == '__main__':

    num = int(input())
    cards = []

    for i in range(num):
        line = input().split(' ')
        cards.append((line[0], int(line[1])))

    missing = find_missing(cards)
    for (s, i) in missing:
        print("{0} {1}".format(s, i))

Submission status: Accepted

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

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

for c in card:
	print(c)

Submission status: Accepted

Solution code:
count = input()
Ss = []
Hs = []
Cs = []
Ds = []
for i in range(int(count)):
    mark, num = input().split()
    if mark is 'S':
        Ss.append(num)
    elif mark is 'H':
        Hs.append(num)
    elif mark is 'C':
        Cs.append(num)
    elif mark is 'D':
        Ds.append(num)

for i in range(1,14):
    if not(str(i) in Ss):
        print("S {0}".format(str(i)))
for i in range(1,14):
    if not(str(i) in Hs):
        print("H {0}".format(str(i)))
for i in range(1,14):
    if not(str(i) in Cs):
        print("C {0}".format(str(i)))
for i in range(1,14):
    if not(str(i) in Ds):
        print("D {0}".format(str(i)))

Submission status: Accepted

Solution code:
line = int(input())

s_set = [x for x in range(1, 14)]
h_set = s_set[:]
c_set = s_set[:]
d_set = s_set[:]

taro_list = []
for i in range(line):
    taro_list.append(input())

for card in taro_list:
    suite = card.split(" ")[0]
    num = int(card.split(" ")[1])
    if suite == "S": s_set.remove(num)
    if suite == "H": h_set.remove(num)
    if suite == "C": c_set.remove(num)
    if suite == "D": d_set.remove(num)

for e in s_set:
    print("S " + str(e))

for e in h_set:
    print("H " + str(e))


for e in c_set:
    print("C " + str(e))

for e in d_set:
    print("D " + str(e))

Submission status: Accepted

Solution code:
import sys
n = int(input())
card =[]
for i in range(n):
    card.append(str(input()))
#print(card)
	
for i in range(1,14):
	if 'S '+str(i) in card:
		print('', end='')
	else:
		print('S '+str(i))
		
for i in range(1,14):		
	if 'H '+str(i) in card:
		print('', end='')
	else:
		print('H '+str(i))
		
for i in range(1,14):		
	if 'C '+str(i) in card:
		print('', end='')
	else:
		print('C '+str(i))
		
for i in range(1,14):		
	if 'D '+str(i) in card:
		print('', end='')
	else:
		print('D '+str(i))

Submission status: Accepted

Solution code:
result = [(temp1 + str(temp2)) for temp1 in ('S ','H ','C ','D ') for temp2 in range(1,14)]

for check in range(int(input())) :
    result.remove(input())

for temp in result :
    print(temp)

Submission status: Accepted

Solution code:
import sys

n = int(input())    # ?????£?????????????????????????????°
pic_list = ['S', 'H', 'C', 'D']
card_dict = {'S':[], 'H':[], 'C':[], 'D':[]}        # ?????£?????????????????\?????????????????°
lost_card_dict = {'S':[], 'H':[], 'C':[], 'D':[]}   # ?¶??????????????????\?????????????????°

# ?????????????¨??????\???????????????
for i in range(n):
    pic, num = input().split()
    card_dict[pic].append(int(num))

# ?¶???????????????????????¨??????\????¨????
for pic in card_dict.keys():
    for j in range(1, 14):
        if not j in card_dict[pic]:
            lost_card_dict[pic].append(j)

# ?????????????????????
for pic in card_dict.keys():
    lost_card_dict[pic] = sorted(lost_card_dict[pic])

# ?¶????????????????????????????
for pic in pic_list:
    for k in range(len(lost_card_dict[pic])):
        print(pic, lost_card_dict[pic][k])