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:
#16Bmissing
def mn(li):
    if li[0]== "S":
        c[0]=0
    elif li[0]== "H":
        li[0]=1
    elif li[0]== "C":
        li[0]=2
    elif li[0]== "D":
        li[0]=3
    li[1]=int(li[1])
    return li
def nm(nu):
    if nu==0:
        co="S"
    elif nu==1:
        co="H"
    elif nu==2:
        co="C"
    elif nu==3:
        co="D"
#    co+=??? ???+str(li[1])
    return co
T=[]
for i in range(4):
    T.append([])
    for j in range(14):
        T[i].append(0)
N=int(input())
for i in range(N):
    c=[j for j in input().split()]
    c=mn(c)
  #  print(c)
    T[c[0]][c[1]]=1
#print(T)
for i in range(4):
    for j in range(1,14):
        if T[i][j]==0:
            print(nm(i)+" "+str(j))

Submission status: Accepted

Solution code:
def findcard(cards):
    master = list(map(str, range(1,14)))
    spade = []
    hart = []
    club = []
    dia = []
    for w in cards:
        mark = w[0]
        num = w[1]
        if mark == "S":
            spade.append(num)
        elif mark == "H":
            hart.append(num)
        elif mark == "C":
            club.append(num)
        elif mark == "D":
            dia.append(num)

    for i in master:
        if i not in spade:
            print("S "+ i)

    for i in master:
        if i not in hart:
            print("H "+ i)

    for i in master:
        if i not in club:
            print("C " + i)

    for i in master:
        if i not in dia:
            print("D " + i)


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

findcard(cards)

Submission status: Accepted

Solution code:
# Aizu Problem ITP_1_6_B: Finding Missing Cards
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


cards = {s: set(range(1, 14)) for s in ['D', 'H', 'C', 'S']}
N = int(input())
for _ in range(N):
    suit, face = input().split()
    face = int(face)
    cards[suit].remove(face)

for suit in ['S', 'H', 'C', 'D']:
    for face in cards[suit]:
        print(suit, face)

Submission status: Accepted

Solution code:
def extraction(array, design):
    for i in range(1, 14):
        if i not in array:
            print(design, i)
            
n = int(input())
S = []
H = []
C = []
D = []
for i in range(n):
    design, num = input().split()
    if design == "S":
        S.append(int(num))
    elif design == "H":
        H.append(int(num))
    elif design == "C":
        C.append(int(num))
    else:
        D.append(int(num))
extraction(S, "S")
extraction(H, "H")
extraction(C, "C")
extraction(D, "D")

Submission status: Accepted

Solution code:
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):
    m,num = [i for i in input().split()]
    if(m == 'S'):
        s[int(num) - 1] += 1
    if(m == 'H'):
        h[int(num) - 1] += 1
    if(m == 'C'):
        c[int(num) - 1] += 1
    if(m == 'D'):
        d[int(num) - 1] += 1
for i in range(13):
    x1 = s[i]
    if(x1 == 0):
        print('S',i + 1)
for i in range(13):
    x2 = h[i]
    if(x2 == 0):
        print('H',i + 1)
for i in range(13):
    x3 = c[i]
    if(x3 == 0):
        print('C',i + 1)
for i in range(13):
    x4 = d[i]
    if(x4 == 0):
        print('D',i + 1)

Submission status: Accepted

Solution code:
s,h,c,d = [[0 for i in range(13)] for j in range(4)]
n = int(input())
for i in range(n):
    m,num = [i for i in input().split()]
    if(m == 'S'):
        s[int(num) - 1] += 1
    if(m == 'H'):
        h[int(num) - 1] += 1
    if(m == 'C'):
        c[int(num) - 1] += 1
    if(m == 'D'):
        d[int(num) - 1] += 1
for i in range(13):
    x1 = s[i]
    if(x1 == 0):
        print('S',i + 1)
for i in range(13):
    x2 = h[i]
    if(x2 == 0):
        print('H',i + 1)
for i in range(13):
    x3 = c[i]
    if(x3 == 0):
        print('C',i + 1)
for i in range(13):
    x4 = d[i]
    if(x4 == 0):
        print('D',i + 1)

Submission status: Accepted

Solution code:
num = int(input())
a = "SHCD"
table = [[i,m] for i in a for m in range(1,14)]

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

for m in table:
    print("{0} {1}".format(m[0],m[1]))

Submission status: Accepted

Solution code:
box = [
		[1,2,3,4,5,6,7,8,9,10,11,12,13],	#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
	]
gara = ["S", "H", "C", "D"]
num = int(input())

def popper(suit, num):
	if   suit == "S":box[0].remove(int(num))
	elif suit == "H":box[1].remove(int(num))
	elif suit == "C":box[2].remove(int(num))
	elif suit == "D":box[3].remove(int(num))
	
for i in range(num):
	suit, card_num = input().split()
	popper(suit, card_num)

for i in range(4):
	for j in range(len(box[i])):
		print("{} {}".format(gara[i], box[i][j]))

Submission status: Accepted

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

n = int(input())

for i in range(n):
	s, num = input().split()
	cards[s][int(num)-1] = 1
	
for i in ["S", "H", "C", "D"]:
	for j in range(13):
		if cards[i][j] == 0:
			print(i,j+1)

Submission status: Accepted

Solution code:
def Input(egara, rank):
    if(egara == 'S'):
        S[rank] = True
    if(egara == 'H'):
        H[rank] = True
    if(egara == 'C'):
        C[rank] = True
    if(egara == 'D'):
        D[rank] = True

def Output():
    for egara in ['S', 'H', 'C', 'D']:
        if(egara == 'S'):
            for rank in range(13):
                if S[rank] == False:
                    print('S ' + str(rank + 1))
        if(egara == 'H'):
            for rank in range(13):
                if H[rank] == False:
                    print('H ' + str(rank + 1))
        if(egara == 'C'):
            for rank in range(13):
                if C[rank] == False:
                    print('C ' + str(rank + 1))
        if(egara == 'D'):
            for rank in range(13):
                if D[rank] == False:
                    print('D ' + str(rank + 1))
n = int(input())

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

for idx in range(n):
    Card = input().split()
    EGARA = Card[0]
    RANK = int(Card[1]) - 1
    Input(EGARA, RANK)

Output()

Submission status: Accepted

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

for i in range(count):
	suit, num = input().split(" ")
	if suit == "S":
		S.remove(int(num))
	elif suit == "C":
		C.remove(int(num))
	elif suit == "H":
		H.remove(int(num))
	elif suit == "D":
		D.remove(int(num))

if len(S) != 0:
	for j in range(len(S)):
		print("S " + str(S[j]))
if len(H) != 0:
	for j in range(len(H)):
		print("H " + str(H[j]))
if len(C) != 0:
	for j in range(len(C)):
		print("C " + str(C[j]))
if len(D) != 0:
	for j in range(len(D)):
		print("D " + str(D[j]))

Submission status: Accepted

Solution code:
all_cards = int(input())
cards = {'S':[0]*13, 'H':[0]*13, 'C':[0]*13, 'D':[0]*13}
for i in range(all_cards):
    mark, num_cards = input().split()
    cards[mark][ int(num_cards) - 1] = 1
for i in ["S", "H", "C", "D"]:
    for j in range(13):
        if cards[i][j] == 0:
            print(i, j + 1)

Submission status: Accepted

Solution code:
N = int(input())
S = ["S"]
H = ["H"]
C = ["C"]
D = ["D"]
for i in range(N):
    s, n = input().split()
    if s == "S":
        S.append(int(n))
    elif s == "H":
        H.append(int(n))
    elif s == "C":
        C.append(int(n))
    else:
        D.append(int(n))

def finder(d):
    for j in range(1, 14):
        if j not in d:
            print(d[0], j)

finder(S)
finder(H)
finder(C)
finder(D)

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import OrderedDict

d = OrderedDict(("{} {}".format(c, n), 0) for c in "SHCD" for n in range(1, 14))

n = int(input())

if n != 52:
    for _ in range(n):
        d.pop(input())

    for k in d:
        print(k)

Submission status: Accepted

Solution code:
S_cards=[]
H_cards=[]
C_cards=[]
D_cards=[]

for i in range(1,14):
    S_cards.append(i)
    H_cards.append(i)
    C_cards.append(i)
    D_cards.append(i)

now_cards=int(input())
for i in range(0,now_cards):
    kind_num=[]
    kind_num=input().split()
    if kind_num[0]=='S':
        S_cards.remove(int(kind_num[1]))
    elif kind_num[0]=='H':
        H_cards.remove(int(kind_num[1]))
    elif kind_num[0]=='C':
        C_cards.remove(int(kind_num[1]))
    elif kind_num[0]=='D':
        D_cards.remove(int(kind_num[1]))
for i in range(0,len(S_cards)):
    print('S',S_cards[i])
for i in range(0,len(H_cards)):
    print('H',H_cards[i])
for i in range(0,len(C_cards)):
    print('C',C_cards[i])
for i in range(0,len(D_cards)):
    print('D',D_cards[i])

Submission status: Accepted

Solution code:
n=int(input())
s,h,c,d=[],[],[],[]

for i in range(n):
    m,r=input().split()
    if m == 'S':
        s.append(int(r))
    elif m == 'H':
        h.append(int(r))
    elif m == 'C':
        c.append(int(r))
    elif m == 'D':
        d.append(int(r))

for i in range(1,14):
    if i not in s:
        print('S', str(i))
for i in range(1,14):
    if i not in h:
        print('H', str(i))
for i in range(1,14):
    if i not in c:
        print('C', str(i))
for i in range(1,14):
    if i not in d:
        print('D', str(i))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def not_card(li, c_type):
    for i in range(1, 14):
        if i not in li:
            print('{} {}'.format(c_type, i))

n = int(input())
card_s = []
card_h = []
card_c = []
card_d = []
for i in range(n):
    card_type, num = input().split()
    num = int(num)
    if   card_type == 'S':
        card_s.append(num)
    elif card_type == 'H':
        card_h.append(num)
    elif card_type == 'C':
        card_c.append(num)
    else:
        card_d.append(num)
card = [card_s, card_h, card_c, card_d]
for array, w in zip(card, 'SHCD'):
    not_card(array, w)

Submission status: Accepted

Solution code:
N = int(input())
cards = ["{0} {1}".format(type, order) for type in ('S', 'H', 'C', 'D') for order in range(1,14)]
for i in range(N):
    card = input()
    cards.remove(card)
for rest in cards:
    print(rest)

Submission status: Accepted

Solution code:
# (c) midandfeed
from functools import cmp_to_key
def func(*a):
	q = ['S', 'H', 'C', 'D']	
	return(q.index(a[0][0]))

n = int(input())
cards = []
for i in range(1, 14):
	cards.append(('S', i))
	cards.append(('H', i))
	cards.append(('C', i))
	cards.append(('D', i))
cards.sort(key = func)	

q = []
for _ in range(n):
	a, b = [x for x in input().split()]
	q.append((a,int(b)))
	
for x in cards:
	if (x not in q):
		print("{} {}".format(x[0], x[1]))

Submission status: Accepted

Solution code:
suits, cards = ['S', 'H', 'C', 'D'], [[i for i in range(1,14)] for j in range(4)]
n = int(input())
for i in range(n):
    s, i = input().split()
    cards[suits.index(s)].remove(int(i))
for si in range(4):
    for i in cards[si]:
        print('%s %d' %(suits[si], i))

Submission status: Accepted

Solution code:
num = [x for x in range(1, 14)]
mark = ('S', 'H', 'C', 'D')
cards = {m:num[:] for m in mark}
for i in range(int(input())):
    card = input().split()
    cards[card[0]].remove(int(card[1]))
for m in mark:
    lacks = cards[m]
    for c in lacks:
        print(m + ' ' + str(c))

Submission status: Accepted

Solution code:
n = int(raw_input())

s = set()
h = set()
c = set()
d = set()

def print_card(mark, nums):
    r = set(range(1,14)) - nums
    if not len(r) == 0:
        for i in sorted(r):
            print mark, i
    return 0

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

print_card("S",s)
print_card("H",h) 
print_card("C",c)
print_card("D",d)

Submission status: Accepted

Solution code:
types = ["S", "H", "C", "D"]
cards = []
for type in types:
    for i in range(13):
        cards.append({type: str(i+1)})
n = int(input())
for _ in range(n):
    type, num = input().split()
    cards.remove({type: num})
for card in cards:
    for k, v in card.items():
        print(k, v)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
c = list(itertools.product(['S', 'H', 'C', 'D'], range(1,14)))
for _ in range(n):
    s, num = input().split()
    c.remove((s, int(num)))
for i in range(4*13 - n):
    print(c[i][0], c[i][1])

Submission status: Accepted

Solution code:
def main():
    n = int(input())
   
    S = [i for i in range(1, 14)]
    H = [i for i in range(1, 14)]
    C = [i for i in range(1, 14)]
    D = [i for i in range(1, 14)]

    T = []
    St = []
    Ht = []
    Ct = []
    Dt = []
    for x in range(n):
        T.append(input().split())
        T[x][1] = int(T[x][1])
        if T[x][0] == "S":
            St.append(T[x][1])
        elif T[x][0] == "H":
            Ht.append(T[x][1])
        elif T[x][0] == "C":
            Ct.append(T[x][1])
        elif T[x][0] == "D":
            Dt.append(T[x][1])

    Ans = []
    for x in range(13):
        if x + 1 not in St:
             Ans.append(["S", x + 1])

    for x in range(13):
        if x + 1 not in Ht:
             Ans.append(["H", x + 1])

    for x in range(13):
        if x + 1 not in Ct:
             Ans.append(["C", x + 1])

    for x in range(13):
        if x + 1 not in Dt:
             Ans.append(["D", x + 1])

    for x in range(len(Ans)):
        print(Ans[x][0], Ans[x][1])

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
cards = []
for pic in ['S', 'H', 'C', 'D']:
    for i in range(1, 14):
        cards.append('%s %d' % (pic, i))

c = int(input())
for i in range(c):
    k = input()
    if k in cards:
        del cards[cards.index(k)]

for card in cards:
    print(card)

Submission status: Accepted

Solution code:
all_cards = [[],[],[],[]]
for i in range(4):
	for j in range(13):
		all_cards[i].append(j+1)

n = int(raw_input())
for i in range(n):
	card = raw_input().split(" ")
	#print card
	if card[0] == "S":
		all_cards[0].remove(int(card[1]))
	elif card[0] == "H":
		all_cards[1].remove(int(card[1]))
	elif card[0] == "C":
		all_cards[2].remove(int(card[1]))
	else:
		all_cards[3].remove(int(card[1]))

for i in range(len(all_cards[0])):
	print("S {:}".format(all_cards[0][i]))
for i in range(len(all_cards[1])):
	print("H {:}".format(all_cards[1][i]))
for i in range(len(all_cards[2])):
	print("C {:}".format(all_cards[2][i]))
for i in range(len(all_cards[3])):
	print("D {:}".format(all_cards[3][i]))

Submission status: Accepted

Solution code:
n = int(input())
spade = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}
hart = set(spade)
club = set(spade)
diamond = set(spade)
trump = [spade, hart, club, diamond]
suit_def = ['S', 'H', 'C', 'D']

for i in range(n):
    card = list(input().split())
    suit = card[0]
    number = int(card[1])
    if suit == 'S':
        spade.remove(number)
    elif suit == 'H':
        hart.remove(number)
    elif suit == 'C':
        club.remove(number)
    else:
        diamond.remove(number)

for i, j in zip(trump, suit_def):
    for k in i:
        print(j, k)

Submission status: Accepted

Solution code:
def main():
    
    deck = set()
    for item in range(1,14):
        deck = deck | {('H ' + str(item))}
        deck = deck | {('D ' + str(item))}
        deck = deck | {('C ' + str(item))}
        deck = deck | {('S ' + str(item))}
    suits_order = ['S', 'H', 'C', 'D']
    
    n = int(input())
    cards = [input() for i in range(n)]
    remains = sorted(sorted(list(deck - set(cards)), key = lambda x: int(x[2:])), key = lambda x: suits_order.index(x[:1]))
    for item in remains:
        print(item)


main()

Submission status: Accepted

Solution code:
line = input()
n = int(line)

fullcards = {
    'S':set(range(1,14)),
    'H':set(range(1,14)),
    'C':set(range(1,14)),
    'D':set(range(1,14))
    }

cards = {
    'S':set({}),
    'H':set({}),
    'C':set({}),
    'D':set({})
    }

for i in range(n):
    line = input()
    suit, rank = line.split()
    rank = int(rank)
    cards[suit].add(rank)

for s in ['S', 'H', 'C', 'D']:
    for r in fullcards[s] - cards[s]:
        print('%s %d' % (s, r) )

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_B&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    n = int(input())
    S = dict()
    H = dict()
    C = dict()
    D = dict()

    for _ in range(n):
        suit, num = input().strip().split()
        num = int(num)
        if suit == 'S':
            S[num] = num
        elif suit == 'H':
            H[num] = num
        elif suit == 'C':
            C[num] = num
        else:
            D[num] = num


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


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
import sys

def main():
    lines = sys.stdin.readlines()

    remaining_cards_num = 0
    S = [] # Spade
    H = [] # Heart
    C = [] # Club
    D = [] # Diamond
    for index, line in enumerate(lines):
        line = line.strip('\n')
        elems = line.split(" ")
        #print elems
        if index == 0:
            remaining_cards_num = int(elems[0])
        elif index <= remaining_cards_num:
            if elems[0] == "S":
                S.append(int(elems[1]))
            elif elems[0] == "H":
                H.append(int(elems[1]))
            elif elems[0] == "C":
                C.append(int(elems[1]))
            elif elems[0] == "D":
                D.append(int(elems[1]))
        else:
            break

    for i in range(1, 13+1):
        if i not in S:
            print("S %d" % (i))
    for i in range(1, 13+1):
        if i not in H:
            print("H %d" % (i))
    for i in range(1, 13+1):
        if i not in C:
            print("C %d" % (i))
    for i in range(1, 13+1):
        if i not in D:
            print("D %d" % (i))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
L={'S':[],'H':[],'C':[],'D':[]}
for i in [input().split() for i in range(int(input()))]:
  L[i[0]].append(int(i[1]))
for i in ['S','H','C','D']:
  for j in range(1,14):
    if j not in L[i]:
      print(i,j)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
r=range
v=input
l=[i+" "+str(j)for i in"SHCD" for j in r(1,14)]
for i in r(int(v())):l.remove(v())
for i in l:print(i)

Submission status: Accepted

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

import fileinput
import math

def main():
    allCard = cardPool()

    n = int(input())

    for i in range(n):
        a, b = input().split()
        allCard.remove(a + ' ' + b)

    for i in allCard:
        print(i)


def cardPool():
    mark = ['S', 'H', 'C', 'D']
    cards = []

    for i in mark:
        for j in range(1, 14):
            cards.append(i + ' ' + str(j))

    return cards

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
fullcards={
    "S":set(range(1,14)),
    "H":set(range(1,14)),
    "C":set(range(1,14)),
    "D":set(range(1,14))
    }
cards={
    "S":set({}),
    "H":set({}),
    "C":set({}),
    "D":set({})
    }
for i in range(n):
    line=input()
    suit,rank=line.split()
    rank=int(rank)
    cards[suit].add(rank)
for s in ['S','H','C','D']:
    for r in fullcards[s]-cards[s]:
        print('%s %d' % (s,r))

Submission status: Accepted

Solution code:
num = int(input())
cards = [ (design, rank) for design in ['S','H','C','D'] for rank in range(1,14) ]
for i in range(num):
    design, rank = input().split()
    cards.remove((design, int(rank)))
for (design, rank) in cards:
    print(design, rank)

Submission status: Accepted

Solution code:
n=int(input())
a=[[0 for i in range(13)]for j in range(4)]
for k in range(n):
    card=input().split()
    p=5
    if (card[0]=="S"):
        p=0
    elif (card[0]=="H"):
        p=1
    elif (card[0]=="C"):
        p=2
    else:
        p=3
    q=int(card[1])-1
    a[p][q]=1
for i in range(4):
    for j in range(13):
        if a[i][j]==0:
            type=""
            if i==0 :
                type="S"
            elif i==1:
                type="H"
            elif i==2:
                type="C"
            else:
                type="D"
            print("{0} {1}".format(type,j+1))

Submission status: Accepted

Solution code:
card=[]
pattern=['S','H','C','D']
N=int(input())
for p in pattern:
 for i in range(1,13+1):
  card.append(p+' '+str(i))
for i in range(N):
 card.remove(input())
for i in range(len(card)):
 print(card[i])

Submission status: Accepted

Solution code:
symboldict = {'S':0, 'H':1, 'C':2, 'D':3} 
cardlist = [[0 for i in range(13)] for j in range(4)] 

total = int(input())
for i in range(total):
    sym, num = input().split()
    cardlist[symboldict[sym]][int(num) - 1] = 1
cnt = 0;
numdict = {num:sym for sym,num in symboldict.items()}
for j in range(len(cardlist)):
    for i in range(len(cardlist[j])):
        if cardlist[j][i] == 0:
            print(numdict[j], i + 1)

Submission status: Accepted

Solution code:
sys={}
sys['S']=[]
sys['H']=[]
sys['C']=[]
sys['D']=[]
s=[]
h=[]
c=[]
d=[]
for i in range(input()):
    x=raw_input().split()
    if x[0]=='S':
        sys['S'].append(int(x[1]))
    elif x[0]=='H':
        sys['H'].append(int(x[1]))
    elif x[0]=='C':
        sys['C'].append(int(x[1]))
    elif x[0]=='D':
        sys['D'].append(int(x[1]))

for i in range(1,14):
    if i not in sys['S']:
        s.append(str(i))
    if i not in sys['H']:
        h.append(str(i))
    if i not in sys['C']:
        c.append(str(i))
    if i not in sys['D']:
        d.append(str(i))
for w in s:
    print 'S '+w
for w in h:
    print 'H '+w
for w in c:
    print 'C '+w
for w in d:
    print 'D '+w

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    nums = set(range(1, 13 + 1))

    cards = {
        "S": set(),
        "H": set(),
        "C": set(),
        "D": set(),
    }
    for _ in range(n):
        mark, num = input().split()
        cards[mark].add(int(num))

    for mark in ("S", "H", "C", "D"):
        a = nums - cards[mark]
        for num in sorted(list(a)):
            print(mark, num)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import itertools
s=['S','H','C','D']
n=[str(i) for i in range(1,14)]
c=[x+' '+y for x,y in itertools.product(s,n)]
for _ in range(int(input())):
 c.remove(input())
if c!=[]:print('\n'.join(c))

Submission status: Accepted

Solution code:
from itertools import *
n=[str(i)for i in range(1,14)]
c=[x+' '+y for x,y in product('SHCD',n)]
for _ in range(int(input())):
 c.remove(input())
if c!=[]:print('\n'.join(c))

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:
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:
n = int(input())

spade = [1,2,3,4,5,6,7,8,9,10,11,12,13]
heart = [1,2,3,4,5,6,7,8,9,10,11,12,13]
club = [1,2,3,4,5,6,7,8,9,10,11,12,13]
diamond = [1,2,3,4,5,6,7,8,9,10,11,12,13]

for i in range(n):
    suit,number = input().split()

    if suit == 'S':
        spade.remove(int(number))
    if suit == 'H':
        heart.remove(int(number))
    if suit == 'C':
        club.remove(int(number))
    if suit == 'D':
        diamond.remove(int(number))

for i in range(len(spade)):
    print(end = 'S ')
    print(*spade[i:i+1])
for i in range(len(heart)):
    print(end = 'H ')
    print(*heart[i:i+1])
for i in range(len(club)):
    print(end = 'C ')
    print(*club[i:i+1])
for i in range(len(diamond)):
    print(end = 'D ')
    print(*diamond[i:i+1])

Submission status: Accepted

Solution code:
n = int(input())

a = []
s = []
h = []
c = []
d = []
for i in range(n):
    a.append(list(map(str,input().split())))
    egara = a[i][0]
    num = int(a[i][1])
    if egara == "S":
        s.append(num)
    elif egara == "H":
        h.append(num)
    elif egara == "C":
        c.append(num)
    else:
        d.append(num)
s.sort()
h.sort()
c.sort()
d.sort()

def check(l, m):
    if len(l) != 13:
        for i in range(13):
            if (i+1) not in l:
                print(m + " " + str(i+1))
check(s, "S")
check(h, "H")
check(c, "C")
check(d, "D")

Submission status: Accepted

Solution code:
d = {
    'S': set([i for i in range(1,14)]),
    'H': set([i for i in range(1,14)]),
    'C': set([i for i in range(1,14)]),
    'D': set([i for i in range(1,14)])
}
for _ in range(int(input())):
    m, n = [i for i in input().split()]
    d[m].remove(int(n))

for m in ['S','H','C','D']:
    for i in d[m]:
        print(m, i)

Submission status: Accepted

Solution code:
S=[i for i in range(1,14)]
H=[i for i in range(1,14)]
C=[i for i in range(1,14)]
D=[i for i in range(1,14)]
cards=int(input())
for i in range(0,cards):
    mark,rank=input().split()
    rank=int(rank)
    if mark=="S":
        S.remove(rank)
    elif mark=="H":
        H.remove(rank)
    elif mark=="C":
        C.remove(rank)
    elif mark=="D":
        D.remove(rank)
for i in S:
    print("S",i)
for i in H:
    print("H",i)
for i in C:
    print("C",i)
for i in D:
    print("D",i)

Submission status: Accepted

Solution code:
number = int(input())
dict = {}
for x in ["S","H","C","D"]:
        dict[x] = [i for i in range(1,14)]
for i in range(number):
    x,y = map(str,input().split())
    dict[x].remove(int(y))
for x in ["S","H","C","D"]:
    for i in dict[x]:
        print(x,i)