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


Card = collections.namedtuple("Card", ("suit", "number"))
suit_rank = {"S": 0, "H": 1, "C": 2, "D": 3}


# すべてのカードを用意
ans = set()
for suit, number in itertools.product("SHCD", range(1, 14), repeat=1):
    ans.add(Card(suit, number))

n = int(input())
cards = {Card(suit, int(number)) for (suit, number) in [input().split() for _ in range(n)]}

ans.difference_update(cards)
ans = list(ans)
ans.sort(key=lambda x: x.number)
ans.sort(key=lambda x: suit_rank[x.suit])
for a in ans:
    print(a.suit, a.number)

Submission status: Accepted

Solution code:
n = int(input())
S = [0]*14
H = [0]*14
C = [0]*14
D = [0]*14
for _ in range(n):
    a, b = input().split()
    b = int(b)
    if a == "S":
        S[b] = 1
    elif a == "H":
        H[b] = 1
    elif a == "C":
        C[b] = 1
    else:
        D[b] = 1
        
for i in range(1, 14):
    if S[i] == 0:
        print("S", i)
for i in range(1, 14):
    if H[i] == 0:
        print("H", i)
for i in range(1, 14):
    if C[i] == 0:
        print("C", i)
for i in range(1, 14):
    if D[i] == 0:
        print("D", i)

Submission status: Accepted

Solution code:
have_n = int(input())

have_dict = {"S": [], "H": [], "C": [], "D": []}

for _ in range(have_n):
    suit, rank = input().split()
    rank = int(rank)
    
    have_dict[suit].append(rank)

for suit in have_dict.keys():
    for rank in range(1, 14):
        if not rank in have_dict[suit]:
            print(suit, rank)

Submission status: Accepted

Solution code:

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

def get_type_index(type_str):
    if type_str == 'S':
        return 0
    elif type_str == 'H':
        return 1
    elif type_str == 'C':
        return 2
    else:
        return 3

def get_type_str(type_index):
    if type_index == 0:
        return 'S'
    elif type_index == 1:
        return 'H'
    elif type_index == 2:
        return 'C'
    else:
        return 'D'

def is_exist_card(type_index, num):
    return trump_card[type_index][num - 1] == 1

def set_card(type_str, num):
    type_index = get_type_index(type_str)
    trump_card[type_index][num - 1] = 1

N = int(input())
for i in range(N):
    type_str, card_num_str = input().split()
    set_card(type_str, int(card_num_str))

for type_index in range(len(trump_card)):
    for num in range(1, len(trump_card[type_index]) + 1):
        if not is_exist_card(type_index, num):
            print(get_type_str(type_index), num)

Submission status: Accepted

Solution code:
n=int(input())
s=(list(range(1,14)))
h=(list(range(1,14)))
c=(list(range(1,14)))
d=(list(range(1,14)))
hand=[map(str,raw_input().split()) for i in range(n)]
for a in hand:
    if a[0]=="S":
        s.remove(int(a[1]))
    if a[0]=="H":
        h.remove(int(a[1]))
    if a[0]=="C":
        c.remove(int(a[1]))
    if a[0]=="D":
        d.remove(int(a[1]))
if len(s)!=0:
    for a in s:
        print "S "+str(a)
if len(h)!=0:
    for a in h:
        print "H "+str(a)
if len(c)!=0:
    for a in c:
        print "C "+str(a)
if len(d)!=0:
    for a in d:
        print "D "+str(a)

Submission status: Accepted

Solution code:
n = int(input())
marks = ["S", "H", "C", "D"]
cards = {mark:[] for mark in marks}
for _ in range(n):
    suit, rank = input().split()
    cards[suit].append(int(rank))
for mark in marks:
    card = cards[mark]
    for num in range(1, 14):
        if num not in card:
            print("{} {}".format(mark, num))

Submission status: Accepted

Solution code:
n = int(input())
count = 0
T = []
while count != n:
    g, num = input().split()
    T.append(g+num)
    count += 1
for g in 'SHCD':
    for num in range(1,14):
        if g+str(num) not in T:
            print(g, num)

Submission status: Accepted

Solution code:
list = [f"{s} {i}" for s in "SHCD" for i in range(1,14)]
for j in range(int(input())):list.remove(input())
for k in list:print(k)

Submission status: Accepted

Solution code:
def find_missing_cards(suit_list):

    cards = [[ 0 for a in range(13)],
             [ 0 for a in range(13)],
             [ 0 for a in range(13)],
             [ 0 for a in range(13)]]

    suit_to_index = {"S" : 0, "H" : 1, "C" : 2, "D" : 3}
    index_to_suits = {0 : "S", 1 : "H", 2 : "C", 3 : "D"}

    for i in range(len(suit_list)):
        cards[ suit_to_index[ suit_list[i][0] ] ][ suit_list[i][1] - 1 ] = 1

    for i, l in enumerate(cards):
        for j in range(len(l)):
            if cards[i][j] == 0:
                print(index_to_suits[i] + " " + str( j + 1 ) )

if __name__ == "__main__":

    n = int(input())
    suit_list = list()

    while(n > 0):
        param = input().split(" ")

        suit = param[0]
        number = int(param[1])

        suit_list.append([suit, number])

        n = n - 1

    find_missing_cards(suit_list)

Submission status: Accepted

Solution code:
#４ｘ１３の空のリストの作成
cards = [[False for i in range(13)] for j in range(4)]

n = int(input())#足りない数の入力
for i in range(n):
    ch,rank = input().split()
    rank = int(rank)
    if ch == 'S':
        cards[0][rank-1] = True
    elif ch == 'H':
        cards[1][rank-1] = True
    elif ch == 'C':
        cards[2][rank-1] = True
    elif ch == 'D':
        cards[3][rank-1] = True

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

Submission status: Accepted

Solution code:
n = int(input())
l = [0] * 52
pdic = {"S":0,"H":1,"C":2,"D":3}
ndic = "SHCD"
for i in range(n):
    p, num = input().split()
    num = int(num)
    l[pdic[p]*13-1 + num] = 1
for i in range(52):
    if l[i] == 0:
         print(ndic[i//13] + " " +  str(i % 13 + 1))

Submission status: Accepted

Solution code:
n=int(input())
d={'S':[0]*13,'H':[0]*13,'C':[0]*13,'D':[0]*13}
for i in range(n):
    suit,rank=input().split()
    d[suit][int(rank)-1]=1
for k,v in d.items():
    for i in range(13):
        if v[i]==0:
            print(k,i+1)

Submission status: Accepted

Solution code:
n=int(input())
cards=[[False for _ in range(13)] for _ in range(4)]
suits={"S":0,"H":1,"C":2,"D":3}
for i in range(n):
    s,c=input().split()
    cards[suits[s]][int(c)-1] = True

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

Submission status: Accepted

Solution code:
n = int(input())
l = [[0 for i in range(13)] for j in range(4)]
pattern = ['S', 'H', 'C', 'D']
for _ in range(n):
    m, num = input().split()
    l[pattern.index(m)][int(num)-1] = 1

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

Submission status: Accepted

Solution code:
n = int(input())
listS=[]
listH=[]
listC=[]
listD=[]
for i in range(n):
    list1 = input().split()
    a = str(list1[0])
    b = int(list1[1])
    if a=='S':
        listS.append(b)
    elif a=='H':
        listH.append(b)
    elif a=='C':
        listC.append(b)
    elif a=='D':
        listD.append(b)

list2 = ['S', 'H', 'C', 'D']
for j in list2:
    if j == 'S':
        for k in range(1, 14):
            if k not in listS:
                print(j, k)
    elif j == 'H':
        for k in range(1, 14):
            if k not in listH:
                print(j, k)
    elif j == 'C':
        for k in range(1, 14):
            if k not in listC:
                print(j, k)
    elif j == 'D':
        for k in range(1, 14):
            if k not in listD:
                print(j, k)

Submission status: Accepted

Solution code:
n = int(input())
cards = dict()

for i in range (n):
    card = input()
    cards[card] = True
    
for m in ["S", "H", "C", "D"]:
    for i in range(1, 14):
        key = m + " " + str(i)
        if not key in cards:
            print(key)

Submission status: Accepted

Solution code:
n = int(input())
l_s = []; l_h = []; l_c = []; l_d = []
for i in range(1,n+1):
    l_card = input().split()
    xTyp = l_card[0]
    xNum = int(l_card[1])
    if xTyp == "S": l_s.append(xNum);
    elif xTyp == "H": l_h.append(xNum);   
    elif xTyp == "C": l_c.append(xNum); 
    else: l_d.append(xNum);  

for i in range(1,4+1):
    if i==1: l_lp=l_s;xTyp="S"
    elif i==2: l_lp=l_h;xTyp="H"
    elif i==3: l_lp=l_c;xTyp="C"
    else: l_lp=l_d;xTyp="D"
    if not l_lp == False:
        for k in range(1,13+1):
            if l_lp.count(k)==0:
                print(xTyp,k)

Submission status: Accepted

Solution code:
x = input()
x = int(x)

Card = [[1 for i in range(13)] for j in range(4)]
Type = ['S','H','C','D']

for i in range(x):
    t = input().split()
    for j in range(4):
        if t[0] == Type[j]:
            break
    Card[j][int(t[1])-1]=0

for j in range(4):
    for i in range(13):
        if Card[j][i]==1:
            print(Type[j],i+1)

Submission status: Accepted

Solution code:
n = int(input())
card = [[0]*13 for _ in range(4)]
suits = ['S','H','C','D']

for _ in range(n):
    suit,num = input().split()
    suit = suits.index(suit)
    num = int(num)
    card[suit][num-1] = 1

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

Submission status: Accepted

Solution code:
number_of_cards = int(input())
suits_of_cards = [input().split(" ") for i in range(number_of_cards)]

spade = []
heart = []
club = []
diamond = []

for j in range(0, number_of_cards):
    suits_of_cards[j][1] = int(suits_of_cards[j][1])

for k in suits_of_cards:
    if "S" in k:
        spade.append(k)
    elif "H" in k:
        heart.append(k)
    elif "C" in k:
        club.append(k)
    else:
        diamond.append(k)

for l in range(1, 14):
    if ['S', l] not in spade:
        print("S", l)
for l2 in range(1, 14):
    if ['H', l2] not in heart:
        print("H", l2)
for l3 in range(1, 14):
    if ['C', l3] not in club:
        print("C", l3)
for l4 in range(1,14):
    if ['D', l4] not in diamond:
        print("D", l4)

Submission status: Accepted

Solution code:
a = []

for s in ['S', 'H', 'C', 'D']:
  for n in range(1, 14):
    a.append(f'{s} {n}')

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

for i in range(n):
  cards.append(input().strip())

res = set(a) ^ set(cards)

for s in ['S', 'H', 'C', 'D']:
  tmp = filter(lambda x:x[0] == s, res)
  for card in sorted(tmp, key=lambda x:int(x.split()[1])):
    print(card)

Submission status: Accepted

Solution code:
line = int(input())
list = []
for i in range(line):
    list.append(input())
for i in range(4):
    for j in range(13):
        if i == 0:
            mark = "S "
        elif i == 1:
            mark = "H "
        elif i == 2:
            mark = "C "
        else:
            mark = "D "
        if mark + str(j+1) in list:
            mark = mark
        else:
            print(mark + str(j+1))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

num = int(input())
cardlist = [[0 for i in range(13)]for j in range(4)]
for i in range(num):
    card = input().split()
    if(card[0]=="S"):
        cardlist[0][int(card[1])-1] = 1
    elif(card[0]=="H"):
        cardlist[1][int(card[1])-1] = 1
    elif(card[0]=="C"):
        cardlist[2][int(card[1])-1] = 1
    elif(card[0]=="D"):
        cardlist[3][int(card[1])-1] = 1
strsuit = "S"
for suit in range(len(cardlist)):
    for cmax in range(13):
        if(cardlist[suit][cmax] == 0):
            print("{0} {1}".format(strsuit,cmax+1))
    if(suit == 0):
        strsuit = "H"
    elif(suit == 1):
        strsuit = "C"
    elif(suit == 2):
        strsuit = "D"

Submission status: Accepted

Solution code:
#人のコードを参考にしたやつ
suits = ["S","H","C","D"]
check = [[False]*14 for _ in range(4)]

def getTrue(aSuit):
    for s in range(len(suits)):
        if aSuit == suits[s]:
            return s

numOfCards = int(input())
for i in range(numOfCards):
    aCard = input().split()
    check[getTrue(aCard[0])][int(aCard[1])] = True

for row in range(4):
    for col in range(1, 14):
        if check[row][col] == False:
            print("%s %d"%(suits[row],col))

Submission status: Accepted

Solution code:
from itertools import product
s = ['S', 'H', 'C', 'D']
n = [str(x) for x in range(1, 14)]
f = set(product(s, n))
N, *C = open(0).read().split()
g = set(zip(*[iter(C)]*2))
for p, q in sorted(f-g, key=lambda c: s.index(c[0])*13+n.index(c[1])):
    print(p + ' ' + q)

Submission status: Accepted

Solution code:
tbl = [[0 for i in range(13)] for j in range(4)]
mark = ["S", "H", "C", "D"]
n = int(input())
for i in range(n):
    m,n = input().split()
    n = int(n)
    tbl[mark.index(m)][n-1] = n
for i, row in enumerate(tbl):
    for j, elem in enumerate(row):
        if elem == 0:
            print(mark[i], j + 1)

Submission status: Accepted

Solution code:
tramp = set()
tramp_given = set()

for i in range(1, 14):
    for elem in ["H ", "S ", "C ", "D "]:
        tramp.add(elem+str(i))

n = int(input())
for i in range(n):
    tramp_given.add(input())

res = sorted(tramp-tramp_given)
res = sorted(res, key=len)
for elem in res:
    if elem[0]=="S":
        print(elem)

for elem in res:
    if elem[0]=="H":
        print(elem)

for elem in res:
    if elem[0]=="C":
        print(elem)

for elem in res:
    if elem[0]=="D":
        print(elem)

Submission status: Accepted

Solution code:
from collections import defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n=int(input())
    cards=defaultdict(set)
    for _ in range(n):
        m,a=input().split()
        cards[m].add(int(a))
    for m in ["S","H","C","D"]:
        for a in range(1,14):
            if a in cards[m]:continue
            print(m,a)
main()

Submission status: Accepted

Solution code:
cards = []
n = int(input())
for _ in range(n):
    cards.append(input())

# カードを全部用意する
suits = ('S', 'H', 'C', 'D')
res_cards = []
for suit in suits:
    for i in range(1, 14):
        res_cards.append(suit+' '+str(i))

for card in cards:
    res_cards.remove(card)

for card in res_cards:
    print(card)

Submission status: Accepted

Solution code:
cs = int(input())
l = list()
ar = ['S', 'H', 'C', 'D']
for c in range(cs):
    r,s = input().split()
    s = int(s)
    if r == 'S': l.append(s)
    if r == 'H': l.append(13 + s)
    if r == 'C': l.append(26 + s)
    if r == 'D': l.append(39 + s)

for k in range(1, 53):
    if not (k in l):
        print(ar[(k - 1) // 13],(k-1)%13 + 1)

Submission status: Accepted

Solution code:
suits=['S','H','C', 'D']
dic={'S':0,'H':1,'C':2, 'D':3}
orig_cards = set()
missing = set()

for i in range(52):
    orig_cards.add((i%4, i//4+1))

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

l = sorted(orig_cards-missing)

for s,r in l:
    print(suits[s],r)

Submission status: Accepted

Solution code:
import math
n = int(input())
s = []
mark = ""
number = 0
for i in range(1,53):
    s.append(i)
l = 0
for i in range(n):
  K = input().split()
  if K[0]== "S":
    l = int(K[1])
  elif K[0] == "H":
    l += 13
    l += int(K[1])
  elif K[0] == "C":
    l += 26
    l += int(K[1])
  elif K[0] == "D":
    l += 39
    l += int(K[1])
  s.remove(l)
  l = 0
for i in range(len(s)):
    T = math.ceil(s[i]/13)
    if T == 1:
        mark = "S"
        number = s[i]
    elif T == 2:
        mark = "H"
        number = s[i]-13
    elif T == 3:
        mark = "C"
        number = s[i]-26
    elif T == 4:
        mark = "D"
        number = s[i]-39
    print(mark,number)
    mark = ""
    number = 0

Submission status: Accepted

Solution code:
cards = []
for i in range(4):
    if i == 0:
        a = "S "
    elif i == 1:
        a = "H "
    elif i == 2:
        a = "C "
    else:
        a = "D "
    for j in range(13):
        cards.append(a+str(j+1))
N = int(input())
for z in range(N):
    card = input()
    cards.remove(card)
for lose in cards:
    print(lose)

Submission status: Accepted

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

for _ in range(n):
    x = input()
    cards.remove(x)
    
for c in cards:
    print(c)

Submission status: Accepted

Solution code:
cards = [(e, str(n)) for e in "SHCD" for n in range(1, 13+1)]

n = int(input())
for _ in range(n):
    card = tuple(input().split())
    cards.remove(card)
  
for card in cards:
    print(*card)

Submission status: Accepted

Solution code:
n = int(input())
lst = [[i+1 for i in range(13)] for j in range(4)]
for p in range(n):
    suit_num = list(input().split())
    suit, num = suit_num[0],int(suit_num[1])
    if suit =="S":
        lst[0].remove(num)
    elif suit == "H":
        lst[1].remove(num)
    elif suit == "C":
        lst[2].remove(num)
    else:
        lst[3].remove(num)

for q in range(4):
    if q == 0:
        suit = "S"
    elif q == 1:
        suit = "H"
    elif q == 2:
        suit = "C"
    else:
        suit ="D"
    for j in lst[q]:
        print(suit + " " + str(j))

Submission status: Accepted

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

if card!=[]:
    print(*card,sep='\n')

Submission status: Accepted

Solution code:
suits = "SHCD"
cards = [0] * 52

n = int(input())
for _ in range(n):
    l, r = input().split()
    i = suits.find(l)*13 + int(r)-1
    cards[i] = 1;

for i in range(52):
    if cards[i] == 0:
        print("{} {}".format(suits[i//13], i%13+1))

Submission status: Accepted

Solution code:
n=int(input())
suit=['S','H','C','D']
deck=[[],[],[],[]]
for i in range(n):
    arr=input().split()
    if arr[0]=='S':
        deck[0].append(int(arr[1]))
    elif arr[0]=='H':
        deck[1].append(int(arr[1]))
    elif arr[0]=='C':
        deck[2].append(int(arr[1]))
    else:
        deck[3].append(int(arr[1]))
for i,v in enumerate(deck):
    v.sort()
    curr=1
    for num in v:
        while num>curr:
            print(suit[i],curr)
            curr+=1
        curr+=1
    while curr<14:
        print(suit[i],curr)
        curr+=1

Submission status: Accepted

Solution code:
num=[i for i in range(1,14)]
pat=["S","H","C","D"]
pat_num=[]
for i in range(4):
    for j in range(13):
        card=[pat[i],str(num[j])]
        pat_num.append(card)
        
n=int(input())
l= [input().split() for i in range(n)]
pat_num = [x for x in pat_num if x not in l]            
for a in pat_num:
    print(*a)

Submission status: Accepted

Solution code:
n = int(input())

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

for c in ['S', 'H', 'C', 'D']:
    for num in range(1, 14):
        if not [c, num] in cards:
            print(c + ' ' + str(num))

Submission status: Accepted

Solution code:
cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]
n = int(input())
for i in range(n):
  ch, rank = input().split()
  rank = int(rank)
  cards[pattern.index(ch)][rank-1] = True
for i in range(4):
  for j in range(13):
    if cards[i][j] == False:
      print(pattern[i], j+1)

Submission status: Accepted

Solution code:
a=int(input())
l=list()

for i in range(a):
    k,n=input().split()
    n=int(n)
    if k=="S":
        n=n
    elif k=="H":
        n=n+13
    elif k=="C":
        n=n+26
    else:
        n=n+39
    l.append(n)

for j in range(1,14):
    if j not in l:
        print("S {}".format(j))
for j in range(14,27):
    if j not in l:
        print("H {}".format(j-13))
for j in range(27,40):
    if j not in l:
        print("C {}".format(j-26))
for j in range(40,53):
    if j not in l:
        print("D {}".format(j-39))

Submission status: Accepted

Solution code:
n = int(input())
s = "SHCD"
used = [[0] * 13 for i in range(4)]
for i in range(n):
  a, b = input().split()
  used[s.find(a)][int(b) - 1] = 1
for i in range(4):
  for j in range(13):
    if used[i][j] == 0:
      print(s[i], j + 1)

Submission status: Accepted

Solution code:
deck = [[False for i in range(13)] for j in range(4)]
suits = ['S', 'H', 'C', 'D']

card = int(input())
for i in range(card):
    pattern, number = input().split()
    number = int(number)
    deck[suits.index(pattern)][number-1] = True

[print(suits[i], j+1) for i in range(4) for j in range(13) if not deck[i][j]]

Submission status: Accepted

Solution code:
spade = list(range(1, 14))
heart = list(range(1, 14))
club = list(range(1, 14))
diamond = list(range(1, 14))

n = int(input())
for i in range(n):
    table = input().split(' ')
    mark = table[0]
    num = int(table[1])
    if mark == 'S':
        spade.remove(num)
    elif mark == 'H':
        heart.remove(num)
    elif mark == 'C':
        club.remove(num)
    else:
        diamond.remove(num)

def output_trump(mark, list):
    for num in list:
        print('{} {}'.format(mark, num))

output_trump('S', spade)
output_trump('H', heart)
output_trump('C', club)
output_trump('D', diamond)

Submission status: Accepted

Solution code:

n = int(input())
s = []
suit = ["S",'H',"C","D"]
for i in range(n):
    a,b = input().split()
    b = int(b)
    if a == "S":
        s.append(b)
    elif a == "H":
        s.append(b+13)
    elif a == "C":
        s.append(b+26)
    elif a == "D":   
        s.append(b+39)    

for i in range(1,53):
    if not (i in s):
        print(suit[(i-1)//13], (i-1)%13+1)

Submission status: Accepted

Solution code:
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


suits = ["S","H","C","D"]
check = [[False]*14 for _ in range(4)]


def get_row(arg_ch):
    for i in range(len(suits)):
        if arg_ch == suits[i]:
            return i


N = int(input())

for _ in range(N):
    tmp = input().split()
    check[get_row(tmp[0])][int(tmp[1])] = True


for row in range(4):
    for col in range(1,14):
        if check[row][col] == False:
            print("%s %d"%(suits[row],col))

Submission status: Accepted

Solution code:
cards= {}
n = int(input())
for i in range(0,n):
    mark, num = input().split()
    cards[mark+num] = 1

for m in ['S', 'H', 'C', 'D']:
    for n in range(1,14):
        card = m+str(n)
        if card in cards:
            pass
        else:
            print('{} {}'.format(m, n))

Submission status: Accepted

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

Submission status: Accepted

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

n = int(input())

for i in range(1, n + 1) :
    s, r = input().split()
    r = int(r)
    
    if s == "S" :
        cards.append(r + 0)
    elif s == "H" :
        cards.append(r + 13)
    elif s == "C" :
        cards.append(r + 26)
    elif s == "D" :
        cards.append(r + 39)
    
for j in range(1, 53) :
    if not (j in cards) :
        print(mark[(j - 1) // 13], (j - 1) % 13 + 1)

Submission status: Accepted

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

for x in 'SHCD':
    for y in range(1, 14):
        z = '{} {}'.format(x, y)
        if z not in a:
            print(z)

Submission status: Accepted

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

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

N = int(input())

for i in range(N):
    
    clab,num = input().split()
    num = int(num)
    
    if clab == "S":
        tables[0][num] = True
    elif clab == "H":
        tables[1][num] = True
    elif clab == "C":
        tables[2][num] = True
    else:
        tables[3][num] = True
        
for i in range(4):
    for k in range(1,14):
        if tables[i][k] == False:
            print("%s %d"% (suits[i],k))

Submission status: Accepted

Solution code:
n = int(input())
S = {"1":1, "2":2, "3":3, "4":4, "5":5, "6":6, 
     "7":7, "8":8, "9":9, "10":10, "11":11, "12":12, "13":13}
H = {"1":1, "2":2, "3":3, "4":4, "5":5, "6":6, 
     "7":7, "8":8, "9":9, "10":10, "11":11, "12":12, "13":13}
C = {"1":1, "2":2, "3":3, "4":4, "5":5, "6":6, 
     "7":7, "8":8, "9":9, "10":10, "11":11, "12":12, "13":13}
D = {"1":1, "2":2, "3":3, "4":4, "5":5, "6":6, 
     "7":7, "8":8, "9":9, "10":10, "11":11, "12":12, "13":13}
for i in range(n):
    pat, num = map(str, input().split(" "))
    if pat == "S":
        for i in range(1, 14):
            if int(num) == i:
                S.pop(num)
    elif pat == "H":
        for i in range(1, 14):
            if int(num) == i:
                H.pop(num)
    elif pat == "C":
        for i in range(1, 14):
            if int(num) == i:
                C.pop(num)
    elif pat == "D":
        for i in range(1, 14):
            if int(num) == i:
                D.pop(num)
for a in S.keys():
    print("S {}".format(S[a]))
for a in H.keys():
    print("H {}".format(H[a]))
for a in C.keys():
    print("C {}".format(C[a]))
for a in D.keys():
    print("D {}".format(D[a]))

Submission status: Accepted

Solution code:
n=int(input())
a=[[0 for i in range(13)]for j in range(4)]
cnt=0
pattern=["S","H","C","D"]


while True:
    u,v=input().split()
    a[pattern.index(u)][int(v)-1]=1
    cnt+=1
    if cnt==n:
        break

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

Submission status: Accepted

Solution code:
n=int(input())

l=([False]*53)

for i in range(n):
    pic,ran=input().split()
    ran=int(ran)

    if pic=='S':
        a=ran
        l[a]=True
    elif pic=='H':
        a=13+ran
        l[a]=True
    elif pic=='C':
        a=26+ran
        l[a]=True
    else :
        a=39+ran
        l[a]=True

for k in range(1,53):
    if l[k]==False:
        if k<14:
            print("S",k)
        elif k<27:
            print("H",k-13)
        elif k<40:
            print("C",k-26)
        else:
            print("D",k-39)

Submission status: Accepted

Solution code:
n = int(input())
pattern = ["S", "H", "C", "D"]
cards = [[False for i in range(14)] for j in range(4)]

for i in range(n):
    mark,num = input().split()
    num = int(num)
    cards[pattern.index(mark)][num] = True

for i in range(4):
    for k in range(1,14):
        if cards[i][k] == False:
            print("%s %d"%(pattern[i],k))

Submission status: Accepted

Solution code:
card_list = [y + " " + str(x) for y in ("SHCD") for x in range(1, 14)]

n = int(input())
if n != 52:
    for y in range(n):
        card_list.remove(input())

    print(*card_list, sep='\n')

Submission status: Accepted

Solution code:
n = int(input())
cards = [[0 for i in range(14)] for j in range(4)]
for i in range(n):
    suit, rank = list(map(str, input().split()))
    if suit == 'S':
        cards[0][int(rank)] = 1
    elif suit == 'H':
        cards[1][int(rank)] = 1
    elif suit == 'C':
        cards[2][int(rank)] = 1
    else:
        cards[3][int(rank)] = 1

for i in range(4):
    for j in range(1,14):
        if cards[i][j] == 0:
            if i == 0:
                print("S",end = " ")
            elif i == 1:
                print("H",end = " ")
            elif i == 2:
                print("C",end = " ")
            else:
                print("D",end = " ")
            print(j)

Submission status: Accepted

Solution code:
def appendnum(lis) :
    for i in range(1,14):
        lis.append(i)

def removenum(lis,num) :
    lis.remove(num)
    
def shownum(lis,S):
    for s in lis:
        print(S,s)
        
Slist = list()
Hlist = list()
Clist = list()
Dlist = list()

appendnum(Slist)
appendnum(Hlist)
appendnum(Clist)
appendnum(Dlist)

n = int(input())

for i in range(n):
    suit, num = input().split()
    suit = str(suit)
    num = int(num)
    if suit == "S":
        removenum(Slist,num)
    elif suit == "H":
        removenum(Hlist,num)
    elif suit == "C" :
        removenum(Clist,num)
    elif suit == "D" :
        removenum(Dlist,num)
        
shownum(Slist,"S")
shownum(Hlist,"H")
shownum(Clist,"C")
shownum(Dlist,"D")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S","H","C","D"]
n = int(input())
for i in range(n):
    ch,rank = input().split()
    rank = int(rank)
    cards[pattern.index(ch)][rank-1] = True
for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i], j+1)

Submission status: Accepted

Solution code:
cards = {}
n = int(input())

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

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

Submission status: Accepted

Solution code:
n = int(input())
table = [[False for i in range(13)] for j in range(4)]
marks = ['S', 'H', 'C', 'D']

for i in range(n):
    mark, num_s = input().split()
    num_index = int(num_s) - 1
    mark_index = marks.index(mark)
    table[mark_index][num_index] = True

for i in range(len(table)):
    for j in range(len(table[i])):
        if table[i][j] == False:
            print('%s %d' %(marks[i], j + 1))