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:
cardlist = []
card = []

for j in range(1,5):
    for k in range(1,14):
        if j == 1:
            cardlist.append(["S", "{}".format(k)])
        elif j == 2:
            cardlist.append(["H", "{}".format(k)])
        elif j == 3:
            cardlist.append(["C", "{}".format(k)])
        elif j == 4:
            cardlist.append(["D", "{}".format(k)])

num = int(input())

for i in range(num):
    card.append(input().split())

for i in range(num):
    cardlist.remove(card[i])

for i in range(52-num):
    print("{0} {1}".format(cardlist[i][0], cardlist[i][1]))

Submission status: Accepted

Solution code:
n = int(input())
array = [input().split() for i in range(n)]
S = []
H = []
C = []
D = []
for i in range(1,14):
    S.append(i)
    H.append(i)
    C.append(i)
    D.append(i)
for i in range(n):
    if array[i][0] == "S":
        S[int(array[i][1])-1]=" "
    elif array[i][0] == "H":
        H[int(array[i][1])-1]=" "
    elif array[i][0] == "C":
        C[int(array[i][1])-1]=" "
    else:
        D[int(array[i][1])-1]=" "
for i in range(13):
    if S[i] != " ":
        print("S "+str(S[i]))
for i in range(13):
    if H[i] != " ":
        print("H "+str(H[i]))
for i in range(13):
    if C[i] != " ":
        print("C "+str(C[i]))
for i in range(13):
    if D[i] != " ":
        print("D "+str(D[i]))

Submission status: Accepted

Solution code:
cards_remain=[]
suit=["S","H","C","D"]
cards_set=[]
output=[]

count_card=input()

for l in range(int(count_card)):
        cards_remain.append(input())

for m in suit:
    for n in range(13):
        cards_set.append(m+" "+str(n+1))

for p in cards_set:
    if p not in  cards_remain:
        output.append(p)

for x in output:
        print(x)

Submission status: Accepted

Solution code:
x = {"S": list(range(1, 14)), "H": list(range(1, 14)),
     "C": list(range(1, 14)), "D": list(range(1, 14))}
n = int(input())
for i in range(n):
    tmp = input().split()
    key = tmp[0]
    num = int(tmp[1])
    x[key].remove(num)

keys = ["S", "H", "C", "D"]
for key in keys:
    if len(x[key])==0:
        pass
    else:
        for i in x[key]:
            print(key, i)

Submission status: Accepted

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

import sys
import os


d = {}
d['S'] = [None for i in range(13)]
d['H'] = [None for i in range(13)]
d['C'] = [None for i in range(13)]
d['D'] = [None for i in range(13)]

N = int(input())
for i in range(N):
    sep = input().split()
    mark = sep[0]
    number = int(sep[1])

    d[mark][number - 1] = True

for mark in ['S', 'H', 'C', 'D']:
    lst = d[mark]
    for i, val in enumerate(lst):
        if val is None:
            print(mark, i + 1)

Submission status: Accepted

Solution code:
# cording: utf-8

num = int(input())

list = []
scard = []
hcard = []
ccard = []
dcard = []

for i in range(num):
    card = input().rstrip().split(" ")
    list.append(card)

for i in range(num):
    if (list[i][0] == 'S'):
        scard.append(list[i][1])
    elif (list[i][0] == 'H'):
        hcard.append(list[i][1])
    elif (list[i][0] == 'C'):
        ccard.append(list[i][1])        
    else:
        dcard.append(list[i][1])

sscard = sorted([ int(x) for x in scard])
shcard = sorted([ int(x) for x in hcard])
sccard = sorted([ int(x) for x in ccard])
sdcard = sorted([ int(x) for x in dcard])

for i in range(1,14):
    if i not in sscard:
        print("S" + " " + str(i))
for i in range(1,14):
    if i not in shcard:
        print("H" + " " + str(i))
for i in range(1,14):
    if i not in sccard:
        print("C" + " " + str(i))
for i in range(1,14):
    if i not in sdcard:
        print("D" + " " + str(i))

Submission status: Accepted

Solution code:
seed = [i for i in range(1,14)]
deck = {}
for s in ['S','H','C','D']:
    deck[s] = seed[:]

n = int(input())
for i in range(n):
    s,v = input().split()
    deck[s][int(v)-1] = 0

for s in ['S','H','C','D']:
    for i in deck[s]:
        if i != 0:
            print(s,i)

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:
N = int(input())
cards = []
for i in range(N):
    s,r = input().split()
    cards.append((s,int(r)))
for s,r in [(s,r) for s in 'SHCD' for r in range(1,14) if (s,r) not in cards]:
    print(s, r)

Submission status: Accepted

Solution code:
n = int(input())

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

mark = [""]*n
num = [""]*n

for i in range(n):
    mark[i], num[i] = input().split()

for i in range(n):
    if mark[i] == "S":
        S[int(num[i])-1] = 0
    if mark[i] == "H":
        H[int(num[i])-1] = 0
    if mark[i] == "C":
        C[int(num[i])-1] = 0
    if mark[i] == "D":
        D[int(num[i])-1] = 0

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Here your code !

def func():
    try:
        line = input()
    except:
        print("input error")
        return -1
        
    marks = ("S","H","C","D")
    cards = []
    while(True):
        try:
            line = input().rstrip()
            elements = line.split(" ")
            if(elements[0] in marks):
                elements[1]=int(elements[1])
                cards.append(elements)
            else:
                print("1input error")
                return -1
        except EOFError:
            break
        except :
            print("input error")
            return -1
    
    result=""
    for mark in marks:
        for i in range(1,14):
            if([mark,i] not in cards):
                result += mark+" "+str(i)+"\n"
    if(len(result)>0):
        print(result.rstrip())
func()

Submission status: Accepted

Solution code:
n=int(input())
card={"S":[0]*13,"H":[0]*13,"C":[0]*13,"D":[0]*13}

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


for a in ("S","H","C","D"):
    for b in range(13):
        if card[a][b] == 0:
            print(a,b+1)

Submission status: Accepted

Solution code:
spades = []
hearts = []
clubs = []
diamonds = []

mspades = []
mhearts = []
mclubs = []
mdiamonds = []

n = int(input())

i = 0

while i < n:
    card = input()
    if 'S' in card:
        spades.append(card)
    elif 'H' in card:
        hearts.append(card)
    elif 'C' in card:
        clubs.append(card)
    else:
        diamonds.append(card)
    i += 1


deck = [spades, hearts, clubs, diamonds]
mdeck = [mspades, mhearts, mclubs, mdiamonds]
symbols = ['S ', 'H ', 'C ', 'D ']

onDeck = 0

while onDeck < 4:
    rank = 1
    while rank <= 13:    
        if symbols[onDeck] + str(rank) in deck[onDeck]:
            pass
        else:
            mdeck[onDeck].append(symbols[onDeck] + str(rank))
        rank += 1
    onDeck += 1

onmDeck = 0

while onmDeck < 4:
    if mdeck[onmDeck] != []:
        print("\n".join(mdeck[onmDeck]))
    onmDeck += 1

Submission status: Accepted

Solution code:
cards = [
          "{0} {1}".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:
n = int(input())
cards =[ [s + " " + str(i) for i in range(1,14)] for s in ["S","H","C","D"]]
for _ in range(n):
    suit, num = input().split(" ")
    if suit == "S":
        cards[0][int(num) - 1] = 0
    elif suit == "H":
        cards[1][int(num) - 1] = 0
    elif suit == "C":
        cards[2][int(num) - 1] = 0
    elif suit == "D":
        cards[3][int(num) - 1] = 0
for s in cards:
    for i in s:
        if i != 0:
            print(i)

Submission status: Accepted

Solution code:
n = input()

data = {
    '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)]
}

for i in range(n):
    s,num = raw_input().split()
    data[s][int(num)-1] = 1

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

Submission status: Accepted

Solution code:
A = [[i for i in range(1 ,14)] for j in range(4)]
a = int(input())
for i in range(a):
    b,c = map(str,input().split())
    c=int(c)
    if b=="S":
        A[0].remove(c)
    if b=="H":
        A[1].remove(c)
    if b=="C":
        A[2].remove(c)
    if b=="D":
        A[3].remove(c)
def name(number,name):
    if A[number]==[]:
        pass
    else:    
        x=A[number]
        x=map(str,x)
        print("%s " %name+("\n%s " %name).join(x))
    
name(0,"S")
name(1,"H")
name(2,"C")
name(3,"D")

Submission status: Accepted

Solution code:
cards = []
mark = ["S","H","C","D"]
for i in range(4):
    mk = mark[i]
    for j in range(1,14):
        cards.append("{} {}".format(mk,j))
n = int(input())
for _ in range(n):
    card = input()
    cards.remove(card)
for i in cards:
    print(i)

Submission status: Accepted

Solution code:
from sys import stdin

cards = {}

n = int(input())
for line in stdin:
    m, num = line.rstrip().split(' ')
    cards[(m, int(num))] = True

for s in ['S','H','C','D']:
    for i in range(1, 14):
        if not (s, i) in cards:
            print("{} {}".format(s, i))

Submission status: Accepted

Solution code:
N = int(input())

#??????????????????????????????
FL =[]
for i in range(13):
 FL.append("S " + str(i+1))
for i in range(13):
 FL.append("H " + str(i+1))
for i in range(13):
 FL.append("C " + str(i+1))
for i in range(13):
 FL.append("D " + str(i+1))

for i in range(N):
 D = str(input())
 FL.remove(D)

for i in range(52 - N):
 print(FL[i])

Submission status: Accepted

Solution code:
n = int(raw_input())
s = ["S"]
h = ["H"]
c = ["C"]
d = ["D"]
card_list = [s,h,c,d]

for i in range(n):
    card = raw_input().split()
    for v in card_list:
        if v[0] == card[0]:
            v.append(int(card[1]))
# print card_list

for i in card_list:
    for j in range(1, 14):
        if not j in i:
            print "%s %d" % (i[0], j)

Submission status: Accepted

Solution code:
n = int(input())
temochi=[]
for i in range(n):
    temochi.append(input())
for x in ['S','H','C','D']:
    for y in range(1,14):
        z = '{} {}'.format(x,y)
        if not(z in temochi): print(z)

Submission status: Accepted

Solution code:
N = int(input())
a = []
typ = ["S ", "H ", "C ", "D "]
for i in range(N):
    a.append(input())

for i in range(4):
    for j in range(1, 14):
        if typ[i] + str(j) not in a:
            print(typ[i] + str(j))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
cards = [[0 for i in range(13)] for j in range(4)]
s2n = {'S': 0, 'H': 1, 'C': 2, 'D': 3}
n2s = 'SHCD'
n = int(input())
for i in range(n):
    card = list(input().split())
    card[1] = int(card[1])
    if card[0] == 'S':
        suit = 0 
    elif card[0] == 'H':
        suit = 1 
    elif card[0] == 'C':
        suit = 2 
    elif card[0] == 'D':
        suit = 3 
    cards[suit][card[1]-1] = 1
for i in range(4): 
    for j in range(13):
        if not(cards[i][j]):
            print(n2s[i], j+1)

Submission status: Accepted

Solution code:
cards = [[0 for i in range(13)] for j in range(4)]
s2n = {'S': 0, 'H': 1, 'C': 2, 'D': 3}
n2s = 'SHCD'
n = int(input())
for i in range(n):
    card = list(input().split())
    card[1] = int(card[1])
    cards[s2n[card[0]]][card[1]-1] = 1
for i in range(4): 
    for j in range(13):
        if not(cards[i][j]):
            print(n2s[i], j+1)

Submission status: Accepted

Solution code:
cards = [[0 for i in range(13)] for j in range(4)]
s2n = {'S': 0, 'H': 1, 'C': 2, 'D': 3}
n2s = 'SHCD'
n = int(input())
for i in range(n):
    card = list(input().split())
    card[1] = int(card[1])
    cards[s2n[card[0]]][card[1]-1] = 1
for i in range(4): 
    for j in range(13):
        if not cards[i][j]:
            print(n2s[i], j+1)

Submission status: Accepted

Solution code:
#coding:utf-8

n = int(input().rstrip())

sl = [i for i in range(1,14)]
hl = [i for i in range(1,14)]
cl = [i for i in range(1,14)]
dl = [i for i in range(1,14)]

for i in range(n):
    mark, rank = input().rstrip().split(" ")
    rank = int(rank)

    if mark == "S":
        sl.remove(rank)
    elif mark =="H":
        hl.remove(rank)
    elif mark =="C":
        cl.remove(rank)
    else:
        dl.remove(rank)

#??????
"""
sl.reverse()
hl.reverse()
cl.reverse()
dl.reverse()
"""
for j in sl:
    print("S "+ str(j))
for j in hl:
    print("H "+ str(j))
for j in cl:
    print("C "+ str(j))
for j in dl:
    print("D "+ str(j))

Submission status: Accepted

Solution code:
n = int(input())
S = []
C = []
H = []
D = []
for i in range(1, 14):
    S.append(i)
    C.append(i)
    H.append(i)
    D.append(i)
for i in range(n):
    s = input().split(" ")
    if s[0] == "S":
        S.remove(int(s[1]))
    elif s[0] == "C":
        C.remove(int(s[1]))
    elif s[0] == "H":
        H.remove(int(s[1]))
    else:
        D.remove(int(s[1]))
for i in range(len(S)):
    print("S {0}".format(S[i]))
for i in range(len(H)):
    print("H {0}".format(H[i]))
for i in range(len(C)):
    print("C {0}".format(C[i]))
for i in range(len(D)):
    print("D {0}".format(D[i]))

Submission status: Accepted

Solution code:
n = int(input())
cards = []
for i in range(n):
    s,r = input().strip().split()
    cards.append((s,int(r)))

for (s,r) in [(s,r) for s in 'SHCD' for r in range(1,14) if (s,r) not in cards]:
    print(s,r)

Submission status: Accepted

Solution code:
c = { 
    'S' : [0 for _ in range(13)], 'H' : [0 for _ in range(13)],
    'C' : [0 for _ in range(13)], 'D' : [0 for _ in range(13)]
}
 
x = int(input())
for _ in range(x):
    (a, b) = input().split()
    b = int(b)
    c[a][b - 1] = b
 
for a in ('S', 'H', 'C', 'D'):
    for b in range(13):
        if c[a][b] == 0:
            print('{0:s} {1:d}'.format(a, b+1))

Submission status: Accepted

Solution code:
c=[[False for i in range(13)]for j in range(4)]
n=int(input())
for i in range(n):
    s=input()
    mark=s.split(' ')[0]
    rank=int(s.split(' ')[1])
    if mark=='S':
        c[0][rank-1]=True
    elif mark=='H':
        c[1][rank-1]=True
    elif mark=='C':
        c[2][rank-1]=True
    else:
        c[3][rank-1]=True
for i in range(4):
    for j in range(13):
        if c[i][j]==False:
            mark=''
            if i==0:mark='S'
            elif i==1:mark='H'
            elif i==2:mark='C'
            else:mark='D'
            print(mark+' '+str(j+1))

Submission status: Accepted

Solution code:
m={"S":[], "D":[], "H":[], "C":[]}
for i in range(int(input())):
    mark, num=input().split()
    m[mark].append(int(num))
for j in ["S", "H", "C", "D"]:
    nai=set(range(1,14))-set(m[j])
    for k in nai:
        print(j, k)

Submission status: Accepted

Solution code:
epochs = int(input())
patterns = ['S', 'H', 'C', 'D']
checker = {pattern: [True]*13 for pattern in patterns}
for i in range(epochs):
    pattern, num = input().split()
    num = int(num)
    checker[pattern][num-1] = False
 
for pattern in patterns:
    for i in range(13):
        if checker[pattern][i]:
            print(pattern, i+1)

Submission status: Accepted

Solution code:
n = int(input())
s = [0 for s in range(13)]
h = [0 for s in range(13)]
c = [0 for s in range(13)]
d = [0 for s in range(13)]
for i in range(n):
    design, N = input().split()
    N = int(N)
    if design == "S":
        s[N-1] = 1
    elif design == "H":
        h[N-1] = 1
    elif design == "C":
        c[N-1] = 1
    else:
        d[N-1] = 1

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

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

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

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

Submission status: Accepted

Solution code:
n = int(input())
cards = {
    'S': [],
    'H': [],
    'C': [],
    'D': []
}

for _ in range(n):
    color, rank = input().split()
    cards[color].append(rank)

for color in ['S', 'H', 'C', 'D']:
    for rank in [x for x in range(1, 14) if str(x) not in cards[color]]:
        print(color, rank)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
??´?????????
"""

suits = {"S": 0, "H": 1, "C": 2, "D": 3}
nsuits = ["S", "H", "C", "D"]

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

for i in range(n):
    inp = input().split(" ")
    s = inp[0]
    c = int(inp[1]) - 1
    cards[suits[s]][c] = 1

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

Submission status: Accepted

Solution code:
n = int(input())
S = []
H = []
C = []
D = []
for i in range(n):
    mark, num = input().split()
    if mark == "S":
        S.append(int(num))
    elif mark == "H":
        H.append(int(num))
    elif mark == "C":
        C.append(int(num))
    elif mark == "D":
        D.append(int(num))
marks = ['S', 'H', 'C', 'D']
cards = [sorted(S), sorted(H), sorted(C), sorted(D)]
for i in range(4):
    mark = marks[i]
    for num in range(1,14):
        if not(num in cards[i]):
            print('{0} {1}'.format(mark, num))

Submission status: Accepted

Solution code:
Suits = ['S', 'H', 'C', 'D']
Taro = []
Missing = []
n = int(input())
for i in range(n):
    Taro.append(input())
for j in range(52):
    card = Suits[j//13] + ' ' + str(j % 13 + 1)
    if card not in Taro:
        Missing.append(card)
if Missing != []:
    print('\n'.join(Missing))

Submission status: Accepted

Solution code:
N = int(input())
m = {
    'S': list(range(1, 14)),
    'H': list(range(1, 14)),
    'C': list(range(1, 14)),
    'D': list(range(1, 14))
}
for i in range(N):
    shape, num = input().strip().split(' ')
    num = int(num)
    m[shape].remove(num)
for k in ['S', 'H', 'C', 'D']:
    if len(m[k]) > 0:
        for x in m[k]:
            print('%s %d' % (k, x))

Submission status: Accepted

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

for _ in range(n):
    raw = input().split(" ")
    if str(raw[0]) == "S":
        S.append(int(raw[1]))
    elif str(raw[0]) == "H":
        H.append(int(raw[1]))
    elif str(raw[0]) == "C":
        C.append(int(raw[1]))
    elif str(raw[0]) == "D":
        D.append(int(raw[1]))

M = [S, H, C, D]
M_name = ["S", "H", "C", "D"]

for m, m_name in zip(M, M_name):
    for i in range(1,14):
        if i not in m:
            print ("%s %d"%(m_name, i))

Submission status: Accepted

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

n = int(input())

for p in patterns:
	for i in range(1, 13+1):
		cards.append(p + ' ' + str(i))

for i in range(n):
	cards.remove(input())

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

Submission status: Accepted

Solution code:
n=int(input())
S=[int(0) for i in range(1,14)]
H=[int(0) for i in range(1,14)]
D=[int(0) for i in range(1,14)]
C=[int(0) for i in range(1,14)]
for i in range(n):
    K,y=[(i) for i in input().split()]
    if K=='S':
        S[int(y)-1]=1
    elif K=='H':
        H[int(y)-1]=1
    elif K=='D':
        D[int(y)-1]=1
    else:
        C[int(y)-1]=1
for i in range(1,14):
    if S[int(i)-1]==0:
        print('S',"{0}".format(i))
for i in range(1,14):
    if H[int(i)-1]==0:
        print('H',"{0}".format(i))
for i in range(1,14):
    if C[int(i)-1]==0:
        print('C',"{0}".format(i))
for i in range(1,14):
    if D[int(i)-1]==0:
        print('D',"{0}".format(i))

Submission status: Accepted

Solution code:
n = int(input())
cards = ['{0} {1}'.format(m,r) for m in ['S','H','C','D'] for r in range(1,14)]
[cards.remove(input()) for i in range(n)]
[print(c) for c in cards]

Submission status: Accepted

Solution code:
from collections import OrderedDict

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

count = int(input())

for n in range(count):
    input_key = input()
    cards[input_key] = not(cards[input_key])

for k, v in cards.items():
    if not v:
        print(k)

Submission status: Accepted

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

n = int(input())
p_cards = []

for x in range(n):
    p_cards.append(str(input()))

for y in p_cards:
    all_cards.remove(y)

for z in all_cards:
    print(z)

Submission status: Accepted

Solution code:
n = int(input())
used = [[False for _ in range(13)] for _ in range(4)]

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

  return -1

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

  return 'N'

for _ in range(n):
  suit, num = input().split()

  used[suit2Num(suit)][int(num)-1] = True

for i in range(4):
  for j in range(13):
    if not used[i][j]:
      print( num2Suit(i),j+1, sep =' ' )

Submission status: Accepted

Solution code:
pri = {'S':0,'H':13,'C':26,'D':39}
total_cards = set()
for pic in pri.keys():
	for rank in range(1,14):
		total_cards.add(pic + ' ' + str(rank))
cards = set()
for _ in range(eval(input())):
	cards.add(input())
no_cards = list(total_cards - cards)
no_cards.sort(key = lambda c: pri[c[0]] + int(c[2:]))
for i in range(len(no_cards)):
	print(no_cards[i])

Submission status: Accepted

Solution code:
listS=[1,2,3,4,5,6,7,8,9,10,11,12,13]
listH=[1,2,3,4,5,6,7,8,9,10,11,12,13]
listC=[1,2,3,4,5,6,7,8,9,10,11,12,13]
listD=[1,2,3,4,5,6,7,8,9,10,11,12,13]

n=int(input())

for i in range(n):
    m, s = map(str,input().split())

    if m == "S":
        listS.remove(int(s))

    elif  m == "H":
        listH.remove(int(s))

    elif m == "C":
        listC.remove(int(s))

    else:
        listD.remove(int(s))

for i in listS:
    print("S "+str(i))
for i in listH:
    print("H "+str(i))
for i in listC:
    print("C "+str(i))
for i in listD:
    print("D "+str(i))

Submission status: Accepted

Solution code:
x = 1
i = 0
j = 0
card = [[0 for a in range (13)]  for b in range (4)]
checknum = int(input())
while x <= checknum: #????????????????????\???
	picture, num = input().split()
	num = int(num)
	if picture == 'S':
		card[0][num - 1] = num
	if picture == 'H':
		card[1][num - 1] = num
	if picture == 'C':
		card[2][num - 1] = num
	if picture == 'D':
		card[3][num - 1] = num
	x += 1
# index = [(i, j)for i, mini_card in enumerate(card) for j, elem in enumerate(mini_card) if elem == 0]
for i, mini_card in enumerate(card):
	for j, elem in enumerate(mini_card):
		if elem == 0:
			if i == 0:
				i = str('S')
			elif i == 1:
				i = str('H')
			elif i == 2:
				i = str('C')
			elif i == 3:
				i = str('D')
			j += 1
			print(i, j)
# print (card)

Submission status: Accepted

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

nums={1,2,3,4,5,6,7,8,9,10,11,12,13}

s_have={int(s[1]) for s in card_have if s[0]=="S"}
h_have={int(h[1]) for h in card_have if h[0]=="H"}
c_have={int(c[1]) for c in card_have if c[0]=="C"}
d_have={int(d[1]) for d in card_have if d[0]=="D"}

s_lost=list(nums^s_have)
h_lost=list(nums^h_have)
c_lost=list(nums^c_have)
d_lost=list(nums^d_have)

s_lost.sort()
h_lost.sort()
c_lost.sort()
d_lost.sort()

for s in s_lost:
    print("S",s)
for h in h_lost:
    print("H",h)
for c in c_lost:
    print("C",c)
for d in d_lost:
    print("D",d)

Submission status: Accepted

Solution code:
class FMC:
    rank_list = [1,2,3,4,5,6,7,8,9,10,11,12,13]
    def __init__(self):
        self.S = []
        self.H = []
        self.C = []
        self.D = []
        self.found_list = []

    def input_card(self, pic, rank):
        if pic == "S":
            self.S.append(rank)
        if pic == "H":
            self.H.append(rank)
        if pic == "C":
            self.C.append(rank)
        if pic == "D":
            self.D.append(rank)

    def finding_rank(self, pic):
        if pic == "S":
            check_list = self.S
        if pic == "H":
            check_list = self.H
        if pic == "C":
            check_list = self.C
        if pic == "D":
            check_list = self.D
        for i in self.rank_list:
            if i not in check_list:
                self.found_list.append([pic, i])

    def finding_missing_cards(self):
        self.finding_rank("S")
        self.finding_rank("H")
        self.finding_rank("C")
        self.finding_rank("D")
        for i in range(len(self.found_list)):
            print(self.found_list[i][0], end=" ")
            print(self.found_list[i][1])

fmc = FMC()

n = input()
n = int(n)

for i in range(n):
    card = input().split()
    pic = card[0]
    rank = card[1]
    rank = int(rank)
    fmc.input_card(pic, rank)

fmc.finding_missing_cards()

Submission status: Accepted

Solution code:
N = int(input())
MN = [ (mark,number) for mark in ['S', 'H', 'C', 'D'] for number in range(1,14) ]
for _ in range(N):
    mark,number = input().split()
    MN.remove((mark,int(number)))
for (mark, number) in MN:
    print(mark, number)

Submission status: Accepted

Solution code:
cardlist = [[i for i in range(1,14)] for j in range(4)]
n = int(input())
for s in range(0, n):
    x,y = map(str,input().split())
    y = int(y)
    if x == "S":
        cardlist[0].remove(y)
    elif x == "H":
        cardlist[1].remove(y)
    elif x == "C":
        cardlist[2].remove(y)
    else:
        cardlist[3].remove(y)
for z in cardlist[0]:
    print("S", z)
for z in cardlist[1]:
    print("H", z)
for z in cardlist[2]:
    print("C", z)
for z in cardlist[3]:
    print("D", z)

Submission status: Accepted

Solution code:
cardlist = [[i for i in range(1,14)] for j in range(4)]
n=int(input())
for s in range(0,n):
  x,y=(input().split())
  y=int(y)
  if   x =="S":
    cardlist[0].remove(y)
  elif x =="H":
    cardlist[1].remove(y)
  elif x =="C":
    cardlist[2].remove(y)
  else:
    cardlist[3].remove(y)
for i in cardlist[0]:
  print("S",i)
for i in cardlist[1]:
  print("H",i)
for i in cardlist[2]:
  print("C",i)
for i in cardlist[3]:
  print("D",i)

Submission status: Accepted

Solution code:
cards = {'S': set(), 'H': set(), 'C': set(), 'D': set()}
n = int(raw_input())
for i in range(n):
    pattern, rank = map(str, raw_input().split())
    cards[pattern].add(int(rank))
result = list(cards['S'].symmetric_difference(set(range(1, 14))))
for i in result:
    print("S " + str(i))
result = list(cards['H'].symmetric_difference(set(range(1, 14))))
for i in result:
    print("H " + str(i))
result = list(cards['C'].symmetric_difference(set(range(1, 14))))
for i in result:
    print("C " + str(i))
result = list(cards['D'].symmetric_difference(set(range(1, 14))))
for i in result:
    print("D " + str(i))

Submission status: Accepted

Solution code:
master_set = set()
for mk in [1, 2, 3, 4]:
    for i in range(1, 14):
        master_set.add((mk, i))

idx = int(input())
distribute_set = set()
bufstr = []
soot_dict = {'S': 1, 'H': 2, 'C': 3, 'D': 4}
rev_soot_dict = {1: 'S', 2: 'H', 3: 'C', 4: 'D'}
for i in range(idx):
    bufstr = input().split()
    distribute_set = distribute_set | \
                     {(soot_dict[bufstr[0]], int(bufstr[1]))}

master_set = master_set - distribute_set

out_set = sorted(list(master_set), key=lambda x: (x[0], x[1]))

for out in out_set:
    print("{} {}".format(rev_soot_dict[out[0]],
                         out[1]
                         ))

Submission status: Accepted

Solution code:
s= [i+1 for i in range(13)]
h= [i+1 for i in range(13)]
c= [i+1 for i in range(13)]
d= [i+1 for i in range(13)]
 
n=int(input())
for cnt in range(n):
    e,n =input().split()
    if e == 'S':s[int(n)-1]=0
    elif e == 'H':h[int(n)-1]=0
    elif e == 'C':c[int(n)-1]=0
    elif e == 'D':d[int(n)-1]=0
 
for i in s:
    if i != 0: print('S '+repr(i))
for i in h:
    if i != 0: print('H '+repr(i))
for i in c:
    if i != 0: print('C '+repr(i))
for i in d:
    if i != 0: print('D '+repr(i))

Submission status: Accepted

Solution code:
n=int(input())                                                              
s_card=[]
h_card=[]
c_card=[]
d_card=[]
for _ in range(n):
    card=str(input())
    if 'S' in card:
        s_card.append(card)
    elif 'H' in card:
        h_card.append(card)
    elif 'C' in card:
        c_card.append(card)
    elif 'D' in card:
        d_card.append(card)
for s in range(1,14):
    S=('S '+str(s))
    if (S in s_card) == False:
        print(S)
for h in range(1,14):
    H=('H '+str(h))
    if (H in h_card) == False:
        print(H)
for c in range(1,14):
    C=('C '+str(c))
    if (C in c_card) == False:
        print(C)
for d in range(1,14):
    D=('D '+str(d))
    if (D in d_card) ==False:
        print(D)

Submission status: Accepted

Solution code:
n = int(input())
card = set()
for i in range(n):
    card_type, card_num = input().split()
    card.add(card_type + card_num)
for card_type in ["S", "H", "C", "D"]:
    for card_num in range(1, 14):
        if card_type + str(card_num) not in card:
            print(card_type + " " + str(card_num))

Submission status: Accepted

Solution code:
cards = []
cards = ["%s %s" % (s, n) for s in ['S', 'H', 'C', 'D'] for n in range(1,14,1)]

input_cards = []
input_cards_num = int(raw_input())
for i in range(1, input_cards_num + 1, 1) :
    input_card = raw_input()
    cards.remove(input_card)

for card in cards:
    print(card)