Problem:

Finding Missing Cards

  Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).

The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.

Input

  In the first line, the number of cards n (n ≤ 52) is given.

  In the following n lines, data of the n cards are given. Each card is given by a pair of a character and an integer which represent its suit and rank respectively. A suit is represented by 'S', 'H', 'C' and 'D' for spades, hearts, clubs and diamonds respectively. A rank is represented by an integer from 1 to 13.

Output

  Print the missing cards. The same as the input format, each card should be printed with a character and an integer separated by a space character in a line.
 Arrange the missing cards in the following priorities:

Print cards of spades, hearts, clubs and diamonds in this order.

If the suits are equal, print cards with lower ranks first.

Sample Input

47
S 10
S 11
S 12
S 13
H 1
H 2
S 6
S 7
S 8
S 9
H 6
H 8
H 9
H 10
H 11
H 4
H 5
S 2
S 3
S 4
S 5
H 12
H 13
C 1
C 2
D 1
D 2
D 3
D 4
D 5
D 6
D 7
C 3
C 4
C 5
C 6
C 7
C 8
C 9
C 10
C 11
C 13
D 9
D 10
D 11
D 12
D 13

Sample Output

S 1
H 3
H 7
C 12
D 8

Note

      解説      

	



Sample input:
47
S 10
S 11
S 12
S 13
H 1
H 2
S 6
S 7
S 8
S 9
H 6
H 8
H 9
H 10
H 11
H 4
H 5
S 2
S 3
S 4
S 5
H 12
H 13
C 1
C 2
D 1
D 2
D 3
D 4
D 5
D 6
D 7
C 3
C 4
C 5
C 6
C 7
C 8
C 9
C 10
C 11
C 13
D 9
D 10
D 11
D 12
D 13


Sample output:
S 1
H 3
H 7
C 12
D 8

Submission status: Accepted

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

for i in range(n):
	x, y = input().split()
	y = int(y)
	if x == "S":
		a.append(y + 0)
	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:
n = int(input())
mark = [0] * n
num = [0] * n
slist = list() ;s_out = list()
hlist = list() ;h_out = list()
clist = list() ;c_out = list()
dlist = list() ;d_out = list()

for i in range(n) :
	mark[i], num[i] = input().split()
	num[i] = int(num[i])
	if mark[i] == "S" :
		slist.append(num[i])
	if mark[i] == "H" :
		hlist.append(num[i])
	if mark[i] == "C" :
		clist.append(num[i])
	if mark[i] == "D" :
		dlist.append(num[i])

for i in range(1, 14) :
	if not i in slist :
		print("S", i)
for i in range(1, 14) :
	if not i in hlist :
		print("H", i)
for i in range(1, 14) :
	if not i in clist :
		print("C", i)
for i in range(1, 14) :
	if not i in dlist :
		print("D", i)

Submission status: Accepted

Solution code:
n = int(input())
s = []
h = []
c = []
d = []
for i in range(n):
    card, num = map(str, input().split())
    if card == 'S':
        s.append(int(num))
    elif card == 'H':
        h.append(int(num))
    elif card == 'C':
        c.append(int(num))
    else:
        d.append(int(num))      
for i in range(1, 14):
    if i not in s:
        print(f'S {i}')
for i in range(1, 14):
    if i not in h:
        print(f'H {i}')
for i in range(1, 14):
    if i not in c:
        print(f'C {i}')
for i in range(1, 14):
    if i not in d:
        print(f'D {i}')

Submission status: Accepted

Solution code:
cards = [[False for i in range(13)]for j in range(4)]
ptn = ['S','H','C','D']
n = int(input())
for i in range(n):
    a, b = map(str,input().split())
    b = int(b)
    cards[ptn.index(a)][b-1] = True
for j in range(4):
    for k in range(13):
        if cards[j][k] == False:
            print(ptn[j],k+1)

Submission status: Accepted

Solution code:
import sys

cards = {
    "S": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
    "H": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
    "C": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
    "D": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
}

patterns = ['S', 'H', 'C', 'D']


def resolve():
    n = int(input())
    for card in sys.stdin:
        p, n = map(str, card.split())
        cards[p].remove(int(n))
    for pattern in patterns:
        for card in cards[pattern]:
            print("{} {}".format(pattern, card))


resolve()

Submission status: Accepted

Solution code:
n = int(input())
s = []
h = []
c = []
d = []
for i in range(13):
    s.append(i+1)
    h.append(i+1)
    c.append(i+1)
    d.append(i+1)
for j in range(n):
    card, number = map(str, input().split())
    if card == 'S':
        s.remove(int(number))
    elif card == 'H':
        h.remove(int(number))
    elif card == 'C':
        c.remove(int(number))
    elif card == 'D':
        d.remove(int(number))
for k in range(len(s)):
    print('S ' + str(s[k]))
for l in range(len(h)):
    print('H ' + str(h[l]))
for m in range(len(c)):
    print('C ' + str(c[m]))
for n in range(len(d)):
    print('D ' + str(d[n]))

Submission status: Accepted

Solution code:
n=int(input())
l=[[0 for i in range(13)]for j in range(4)]
for k in range(n):
    s,r=map(str,input().split())
    r=int(r)-1
    if s=='S':
        l[0][r]+=1
    elif s=='H':
        l[1][r]+=1
    elif s=='C':
        l[2][r]+=1
    else:
        l[3][r]+=1
for S in range(4):
    for R in range(13):
        if l[S][R]==0:
            if S==0:
                print('S',R+1)
            elif S==1:
                print('H',R+1)
            elif S==2:
                print('C',R+1)
            else:
                print('D',R+1)
        else:
            pass

Submission status: Accepted

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

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

n = int(input())
for i in range(n):
    dataset = input().split(" ")
    card_type = dataset[0]
    card_number = int(dataset[1])

    if card_type == "S":
        S[card_number] = 0
    elif card_type == "H":
        H[card_number] = 0
    elif card_type == "C":
        C[card_number] = 0
    elif card_type == "D":
        D[card_number] = 0


for i in range(1, 14):
    if S[i] != 0:
        print("S %d" % S[i])

for i in range(1, 14):
    if H[i] != 0:
        print("H %d" % H[i])

for i in range(1, 14):
    if C[i] != 0:
        print("C %d" % C[i])

for i in range(1, 14):
    if D[i] != 0:
        print("D %d" % D[i])

Submission status: Accepted

Solution code:
all_cards = [x + " " + str(y) for x in ["S", "H", "C", "D"] for y in range(1, 14)]
N = int(input())
i = 0
while i < N:
    has_card = input()
    if has_card in all_cards:
        all_cards.remove(has_card)
    i += 1
for j in all_cards:
    print(j)

Submission status: Accepted

Solution code:
suits=['S','H','C','D']
cards=[]
for i in range(4):
  for j in range(1,14):
    cards.append([suits[i],j,0])

n=int(input())
for i in  range(n):
  s,r=input().split(' ')
  r=int(r)
  for j in range(len(cards)):
    if cards[j][0]==s and int(cards[j][1])==r:
      cards[j][2]=1

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

Submission status: Accepted

Solution code:
from collections import OrderedDict

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

n = int(input())
for _ in range(n):
    mark, num = input().strip().split()
    cards[mark].remove(int(num))

for mark,nums in cards.items():
    for num in nums:
        print(mark,num)

Submission status: Accepted

Solution code:
n = int(input())
A = {'S':[],'H':[],'C':[],'D':[]}
M = {'S':[],'H':[],'C':[],'D':[]}
for i in range(n):
  a, b = list(map(str, input().split(' ')))
  A[a].append(int(b))
for l in A:
  cnt = 0
  for ll in range(1, 13 + 1):
    if not ll in A[l]:
      M[l].append(ll)
  M[l].sort()
  if 0 < len(M[l]):
    for o in M[l]:
      print('{0} {1}'.format(l, o))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
lst = []
S_lst = []
H_lst = []
C_lst = []
D_lst = []
for i in range(n):
    m, r = input().split()
    r = int(r)
    lsts = []
    lsts.append(m)
    lsts.append(r)
    lst.append(lsts)
for i in range(len(lst)):
    if lst[i][0] == 'S':
        S_lst.append(lst[i][1])
    elif lst[i][0] == 'H':
        H_lst.append(lst[i][1])
    elif lst[i][0] == 'C':
        C_lst.append(lst[i][1])
    elif lst[i][0] == 'D':
        D_lst.append(lst[i][1])

for i in range(1,14):
    if i not in S_lst:
        print('S',i)
for i in range(1,14):
    if i not in H_lst:
        print('H',i)
for i in range(1,14):
    if i not in C_lst:
        print('C',i)
for i in range(1,14):        
    if i not in D_lst:
        print('D',i)

Submission status: Accepted

Solution code:
cards = list()
suit = ['S', 'H', 'C', 'D']
n = int(input())
for i in range(n):
    a, b = input().split()
    b = int(b)
    if a == 'S': cards.append(0 + b)
    elif a == 'H': cards.append(13 + b)
    elif a == 'C': cards.append(26 + b)
    elif a == 'D': cards.append(39 + b)
for i in range(1, 53):
    if not (i in cards):
        print(suit[(i - 1) // 13], (i - 1) % 13 + 1)

Submission status: Accepted

Solution code:
n = int(input())
a = list()
for i in range(n):
	x,y = map(str,input().split())
	y = int(y)
	if x == "S":
		a.append(y+0)
	elif x == "H":
		a.append(y+13)
	elif x == "C":
		a.append(y+26)
	elif 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:
n = int(input())
cards = [[0 for i in range(13)] for j in range(4)]

for x in range(n):
    a, b = input().split()
    if a == 'S':
        a_num = 0
    elif a == 'H':
        a_num = 1
    elif a == 'C':
        a_num = 2
    elif a == 'D':
        a_num = 3
    cards[a_num][int(b) - 1] = True

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

Submission status: Accepted

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

a=int(input())
for _ in range(a) :
    i = input().split()
    suit = i[0]
    num = int(i[1])
    if suit== "S":
        S.append(num)
    elif suit== "H":
        H.append(num)
    elif suit== "C":
        C.append(num)
    elif suit== "D":
        D.append(num)

S_nasi=[]
H_nasi=[]
C_nasi=[]
D_nasi=[]
    
for i in range(13):
    if not i+1 in S:
        S_nasi.append(i+1)
    
for i in range(13):
    if not i+1 in H:
        H_nasi.append(i+1)

for i in range(13):
    if not i+1 in C:
        C_nasi.append(i+1)

for i in range(13):
    if not i+1 in D:
        D_nasi.append(i+1)

   



for i in S_nasi:
    print("S",i)

for i in H_nasi:
    print("H",i)

for i in C_nasi:
    print("C",i)

for i in D_nasi:
    print("D",i)

Submission status: Accepted

Solution code:
cardNumAll = int(input())

cardNumbers = [i for i in range(1, 13+1)]

cards = {
    "S": cardNumbers.copy(),
    "H": cardNumbers.copy(),
    "C": cardNumbers.copy(),
    "D": cardNumbers.copy()
}

for _ in range(cardNumAll):
    p, num = input().split()
    num = int(num)
    cards[p].remove(num)

for k in cards:
    for n in cards[k]:
        print(k, n)

Submission status: Accepted

Solution code:
from collections import defaultdict

lens = int(input())
cards = defaultdict(set)
for index in range(lens):
    card, number = input().split()
    cards[card].add(int(number))

numbers = set(range(1, 14))
for design in "SHCD":
    remains = numbers - cards[design]
    for number in sorted(list(remains)):
        print(f"{design} {number}")

Submission status: Accepted

Solution code:
c=[f'{s} {i}'for s in'SHCD'for i in range(1,14)]
for _ in[0]*int(input()):
    c.remove(input())
for x in c:
    print(x)

Submission status: Accepted

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

for i in range(n):
    ch,rank = map(str,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:
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:
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:
a = []

s = [1,2,3,4,5,6,7,8,9,10,11,12,13]
h = [1,2,3,4,5,6,7,8,9,10,11,12,13]
c = [1,2,3,4,5,6,7,8,9,10,11,12,13]
d = [1,2,3,4,5,6,7,8,9,10,11,12,13]

counter = 0
n = int(input())

while counter < n:
    a.append(list(input().split()))
    counter += 1

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

for i in s:
    print("S %s" % i)
for i in h:
    print("H %s" % i)
for i in c:
    print("C %s" % i)
for i in d:
    print("D %s" % i)

Submission status: Accepted

Solution code:
N = int(input())
torump = [[0 for i in range(1,14)] for i in range(4)]
for _ in range(N):
  pattern,num = map(str,input().split())
  num = int(num)
  if pattern == "S":
    pattern = 0
    torump[pattern][num-1] = 1
  elif pattern == "H":
    pattern = 1
    torump[pattern][num-1] = 1    
  elif pattern == "C":
    pattern = 2
    torump[pattern][num-1] = 1
  elif pattern == "D":
    pattern = 3
    torump[pattern][num-1] = 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = []
c=[]

size = int(input())
for i in range(size):
    m,r=input().split()
    a.append((m,int(r)))


"""
一番目にマークで二番目に数字
a=[[m0,r0],[m1,r1]]

"""
mark =["S","H","C","D"]

#for文で全マークの全数字をそれぞれaに入ってるか調べて入ってないのをcに収めていく
for i in range(4):
    for j in range(1,14):
        if not (mark[i],j) in a:
            c = c + [[mark[i],j]]
        

for i in range(52-size):
    print(c[i][0],c[i][1])
"""
5
S 1
H 3
H 7
C 12
D 8
"""

Submission status: Accepted

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

for i in range(n):
    k,l=input().split()
    l=int(l)
    if k=="S":
        S.append(l)
    if k=="H":
        H.append(l)    
    if k=="C":
        C.append(l)
    if k=="D":
        D.append(l)

for i in range(1,14):
    if not i in S:
        print("S",i)
        
for i in range(1,14):
    if not i in H:
        print("H",i)
        
for i in range(1,14):
    if not i in C:
        print("C",i)

for i in range(1,14):
    if not i in D:
        print("D",i)

Submission status: Accepted

Solution code:
a = ['S','H','C','D']
b =[]
for i in range(4):
    for j in range(1,14):
        b.append(str(a[i])+' '+str(j))
n = int(input())
for i in range(n):
    c = input()
    b.remove(c)
for i in range(len(b)):
    print(b[i])

Submission status: Accepted

Solution code:
n = int(input())
an = [input() for _ in range(n)]
a =[]
for c in "SHCD":
    for i in range(1, 14):
        card = "{} {}".format(c, i)
        if card not in an:
            a.append(card)

if n != 52:
    print("\n".join(a))

Submission status: Accepted

Solution code:
import sys
card = []
array = []
rank = ["S","H","C","D"]
for i in rank:
    for j in range(1,14):
        card.append(i + " " + str(j))
        
n = int(input())
for line in sys.stdin.readlines():
    array.append(line.rstrip())

for cards in array:
    card.remove(cards)
for y in card:
    print(y)

Submission status: Accepted

Solution code:
n = int(input())

if n == 52:
    pass

else:
    s_list = list(range(1, 14))
    h_list = list(range(1, 14))
    c_list = list(range(1, 14))
    d_list = list(range(1, 14))
    
    for i in range(n):
        mark, number = input().split()
    
        if mark == 'S':
            s_list.remove(int(number))
        elif mark == 'H':
            h_list.remove(int(number))
        elif mark == 'C':
            c_list.remove(int(number))
        elif mark == 'D':
            d_list.remove(int(number))
    
    s_list = ['S ' + str(x) for x in s_list]
    h_list = ['H ' + str(x) for x in h_list]
    c_list = ['C ' + str(x) for x in c_list]
    d_list = ['D ' + str(x) for x in d_list]
    
    card_list = s_list + h_list + c_list + d_list
    
    card_list = '\n'.join(card_list)
    print(card_list)

Submission status: Accepted

Solution code:
n = int(input())
s = [[0] * 13 for i in range(4)]
for i in range(n):
	t = input().split()
	if t[0] == "S":
		u = 0
	elif t[0] == "H":
		u = 1
	elif t[0] == "C":
		u = 2
	elif t[0] == "D":
		u = 3
	s[u][int(t[1]) - 1] = 1
for i in range(4):
	for j in range(13):
		if s[i][j] != 1:
			if i == 0:
				st = 'S'
			elif i == 1:
				st = 'H'
			elif i == 2:
				st = 'C'
			elif i == 3:
				st = 'D'
			print(st, end=" ")
			print(j + 1)

Submission status: Accepted

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

def research_zero(cards:list):
    return [i for i, x in enumerate(cards) if x == 0]


def main():
    n = int(input())
    S_cards=[0]*13
    C_cards=[0]*13
    D_cards=[0]*13
    H_cards=[0]*13

    for i in range(n):
        t,n=input().split()
        if t=="S":
            S_cards[int(n)-1]=1
        elif t=="H":
            H_cards[int(n)-1]=1
        elif t=="C":
            C_cards[int(n)-1]=1
        elif t=="D":
            D_cards[int(n)-1]=1


    S_zero_list=research_zero(S_cards)
    H_zero_list=research_zero(H_cards)
    C_zero_list=research_zero(C_cards)
    D_zero_list=research_zero(D_cards)

    if len(S_zero_list):
        for i in S_zero_list:
            print("S {}".format(i+1))
    if len(H_zero_list):
        for i in H_zero_list:
            print("H {}".format(i+1))
    if len(C_zero_list):
        for i in C_zero_list:
            print("C {}".format(i+1))
    if len(D_zero_list):
        for i in D_zero_list:
            print("D {}".format(i+1))

if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:

suits = ["S", "H", "C", "D"]
card = {}
for s in suits:
    card[s] = list(range(1,14))


N = int(input())
for n in range(N):
    suit, rank = input().split()
    card[suit][int(rank) - 1] = 0

for s in card:
    for r in card[s]:
        if r != 0:
         print("{} {}".format(s, r))

Submission status: Accepted

Solution code:
n = int(input())
lis_s = ["S", "H", "C", "D"]
lis = [0 for i in range(n)]


for i in range(n):
    lis.append(input())
    
    
for i in lis_s :
    for j in range(1, 14) :
        
        
        if f"{i} {j}" not in lis :
            print(f"{i} {j}")

Submission status: Accepted

Solution code:
def num(a,b,d):
    if a[0] == b:
        c=int(a[1])
        d.append(c)
        
def printcard(d,b):
    for i in range(1,14):
        if (i in d) == False:
            print(b+str(i))
        
n=int(input())
d1=[]
d2=[]
d3=[]
d4=[]
for i in range (n):
    x=list(input().split())
    num(x,'S',d1)
    num(x,'H',d2)
    num(x,'C',d3)
    num(x,'D',d4)

printcard(d1,'S ')
printcard(d2,'H ')
printcard(d3,'C ')
printcard(d4,'D ')

Submission status: Accepted

Solution code:
n = int(input())
rc = list(input() for i in range(n))
for s in ["S","H","C","D"]:
    for num in range(1, 14):
        allc = "{} {}".format(s, str(num))
        if allc not in rc: print(allc)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
cards = [[False for i in range(14)] for j in range(4)]
marks = ['S', 'H', 'C', 'D']

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

for i in range(4):
    for j in range(1, 14):
        if not cards[i][j]:
            print(marks[i], j)

Submission status: Accepted

Solution code:
d = {
    'S': [i for i in range(13)],
    'H': [i for i in range(13)],
    'C': [i for i in range(13)],
    'D': [i for i in range(13)],
}
n = int(input())
for i in range(n):
    a, b = input().split()
    b = int(b)
    d[a][b - 1] = -1
for i in d.keys():
    for j in d[i]:
        if j != -1:
            print(i, str(j + 1))

Submission status: Accepted

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

def e(moji):
    for j in range(4):
        if moji==mark[j]:
            return j

for i in range(n):
    a=input().split()
    tbl[e(a[0])][int(a[1])-1]+=1
    
for i in range(4):
    for j in range(13):
        if tbl[i][j]==0:
            print(mark[i],j+1)

Submission status: Accepted

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

for i in range(n):
    k=input().split()
    
    if k[0]=="S":
        s.append(int(k[1]))
    if k[0]=="H":
        h.append(int(k[1]))
    if k[0]=="C":
        c.append(int(k[1]))
    if k[0]=="D":
        d.append(int(k[1]))

for i in range(1,14):
    if i not in s:
        print("S", i)

for i in range(1,14):
    if i not in h:
        print("H", i)
        
for i in range(1,14):
    if i not in c:
        print("C", i)
        
for i in range(1,14):
    if i not in d:
        print("D", i)

Submission status: Accepted

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

deck = []
for i in range(n):
  mark, num = map(str, input().split())
  deck.append([mark,int(num)])

for check in m:
  for i in range(13):
    if not([check,i+1] in deck) :
      print(check,i+1)

Submission status: Accepted

Solution code:
import sys

cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]
n = int(input())
lines = [line.split() for line in sys.stdin.readlines()]

for line in lines:
    cards[pattern.index(line[0])][int(line[1]) - 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:
import copy
n = int(input())
numS = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
numH = copy.copy(numS)
numC = copy.copy(numS)
numD = copy.copy(numS)
for i in range(n):
  sym, num = list(input().split())
  num = int(num)
  if sym == "S":
    numS.remove(num)
  elif sym == "H":
    numH.remove(num)
  elif sym == "C":
    numC.remove(num)
  else:
    numD.remove(num)
for s in range(len(numS)):
  print("S " + str(numS[s]))
for h in range(len(numH)):
  print("H " + str(numH[h]))
for c in range(len(numC)):
  print("C " + str(numC[c]))
for d in range(len(numD)):
  print("D " + str(numD[d]))

Submission status: Accepted

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

for i in range(n):
    ch,rank = map(str,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:
N=int(input())
suits=["S","H","C","D"]
cards=[]
for i in range(N):
    s,n=input().split()
    if s=="S":
        cards.append(int(n))
    elif s=="H":
        cards.append(13+int(n))
    elif s=="C":
        cards.append(26+int(n))
    else:
        cards.append(39+int(n))

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

Submission status: Accepted

Solution code:
def Z(): return int(input())

def main():
    S = [True] * 13
    H = [True] * 13
    C = [True] * 13
    D = [True] * 13
    n = Z()
    for _ in range(n):
        s, i = input().split()
        i = int(i) - 1
        if s == 'S': S[i] = False
        if s == 'H': H[i] = False
        if s == 'C': C[i] = False
        if s == 'D': D[i] = False
    for i in range(13):
        if S[i]: print('S', i+1)
    for i in range(13):
        if H[i]: print('H', i+1)
    for i in range(13):
        if C[i]: print('C', i+1)
    for i in range(13):
        if D[i]: print('D', i+1)

    return

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
l = []
for i in range(n):
    a,b =input().split()
    b = int(b)
    l.append([a,b])
for y in ["S","H","C","D"]:
    for x in range(1, 14):
        if [y,x] not in l:
            print(y,x)

Submission status: Accepted

Solution code:
num = int(input())
result =list()
illusts = ['S','H','C','D']

while True:
    try:
        a,b = input().split(' ')
        b = int(b)
        if a == 'S': result.append(b)
        elif a == 'H':result.append(b + 13)
        elif a == 'C': result.append(b + 26)
        else : result.append(b + 39)
    except EOFError:
        break

box = 0
for illust in illusts:
    for i in range(1,14):
        if i + box not in result:
            print(illust, i)
    box += 13

Submission status: Accepted

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

#pattern = ["S", "H", "C", "D"]

n = int(input())

for i in range(n):
    p, num = input().split()
    if p == 'S':
        s[int(num) - 1] = 0
    elif p == 'H':
        h[int(num) - 1] = 0
    elif p == 'C':
        c[int(num) - 1] = 0
    elif p == 'D':
        d[int(num) - 1] = 0

for i in range(13):
    if s[i] == 1:
        print('S',i+1)
for i in range(13):
    if h[i] == 1:
        print('H',i+1)
for i in range(13):
    if c[i] == 1:
        print('C',i+1)
for i in range(13):
    if d[i] == 1:
        print('D',i+1)

Submission status: Accepted

Solution code:
n = int(input())
card = [input().split() for _ in range(n)]
s = ["S", "H", "C", "D"]

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

Submission status: Accepted

Solution code:
a = []
for i in range(1,14):
    s = 'S {}'.format(i)
    a.append(s)

for i in range(1,14):
    h = 'H {}'.format(i)
    a.append(h)

for i in range(1,14):
    c = 'C {}'.format(i)
    a.append(c)
    
for i in range(1,14):
    d = 'D {}'.format(i)
    a.append(d)

#print(a)
k = []
amount = int(input())
for e in range(amount):
    taiga = input()
    k.append(taiga)
#print(k)
     
for i in a:
    if i not in k:
        print(i)

Submission status: Accepted

Solution code:
n = int(input())

l = [0 for i in range(52)]
# print(l)

for i in range(n):
    char, num = input().split()
    num = int(num)

    if char == "S":
        l[num - 1] = 1

    elif char == "H":
        l[num-1+13] = 1

    elif char == "C":
        l[num-1+26] = 1

    elif char == "D":
        l[num-1+39] = 1

for i in range(52):
    if l[i] == 0:
        if 0 <= i and i <= 12:
            print(f"S {i+1}")
        if 13 <= i and i <= 25:
            print(f"H {i+1-13}")
        if 26 <= i and i <= 38:
            print(f"C {i+1-26}")
        if 39 <= i and i <= 51:
            print(f"D {i+1-39}")

Submission status: Accepted

Solution code:
NUMS = {n for n in range(1, 14)}
P = ['S', 'H', 'C', 'D']
CARDS = {'S': set(), 'H': set(), 'C': set(), 'D': set()}

N = int(input())
for i in range(N):
    m, n = input().split()
    CARDS[m].add(int(n))
for p in P:
    ans = sorted(list(NUMS - CARDS[p]))
    for n in ans:
        print(p, n)

Submission status: Accepted

Solution code:
#1_6_B
l = []
n = int(input())
for k in range(n):
    l.append(input())
cards = ['S 1','S 2','S 3','S 4','S 5','S 6','S 7','S 8','S 9','S 10','S 11','S 12','S 13',
    'H 1','H 2','H 3','H 4','H 5','H 6','H 7','H 8','H 9','H 10','H 11','H 12','H 13',
    'C 1','C 2','C 3','C 4','C 5','C 6','C 7','C 8','C 9','C 10','C 11','C 12','C 13',
    'D 1','D 2','D 3','D 4','D 5','D 6','D 7','D 8','D 9','D 10','D 11','D 12','D 13']

x = sorted(set(l) ^ set(cards),key=cards.index)
for i in range(len(x)):
    print(x[i])

Submission status: Accepted

Solution code:
a = int(input())
b = []
for n in range(a):
    aa = input()
    b.append(aa)
head = ['S','H','C','D']
body = [1,2,3,4,5,6,7,8,9,10,11,12,13]
card = []
for i in head:
    for j in body:
        k = i + ' ' + str(j)
        if k not in b:
            card.append(k)
for m in card:
    print(m)

Submission status: Accepted

Solution code:
card = []

for i in range(int(input())):
  s,num = input().split()
  num = int(num)
  if s == "S":card.append(num)
  elif s == 'H':card.append(13 + num)
  elif s == 'C':card.append(26 + num)
  elif s == 'D':card.append(39 + num)

for i in range(1,53):
  if i not in card:
    print((1<=i<=13)*'S ',end='')
    print((14<=i<=26)*'H ',end='')
    print((27<=i<=39)*'C ',end='')
    print((40<=i<=52)*'D ',end='')
    print((i-1)%13+1)

Submission status: Accepted

Solution code:
n = int(input())

sp = []
he = []
di = []
cl = []
for i in range(13):
    sp.append(i+1)
    he.append(i+1)
    di.append(i+1)
    cl.append(i+1)
#print(sp)

for i in range(n):
    s, n = map(str,input().split())
    n = int(n)
    if s == "S":
        sp.remove(n)
    elif s == "H":
        he.remove(n)
    elif s == "D":
        di.remove(n)
    elif s == "C":
        cl.remove(n)
for i in range(len(sp)):
    print("S "+ str(sp[i]))
for i in range(len(he)):
    print("H "+ str(he[i]))
for i in range(len(cl)):
    print("C "+ str(cl[i]))
for i in range(len(di)):
    print("D "+ str(di[i]))

Submission status: Accepted

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