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:
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:
cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S","H","C","D"]
n = int(input())
for m in range(n):
    card = input().split()
    ch = card[0]
    rank = int(card[1])
    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], str(j+1))

Submission status: Accepted

Solution code:
x = int(input())

data =[]
data_dict ={}
data_dict['S'] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ,11, 12, 13]
data_dict['H'] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ,11, 12, 13]
data_dict['C'] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ,11, 12, 13]
data_dict['D'] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ,11, 12, 13]

for i in range(x):
    a, b = input().split()
    
    for i in data_dict[a]:
        if i == int(b):
            data_dict[a].remove(i)
       
for n in data_dict['S']:
    print('S',n)
    
for m in data_dict['H']:
    print('H', m)

for l in data_dict['C']:
    print('C', l)

for k in data_dict['D']:
    print('D', k)

Submission status: Accepted

Solution code:

cards = [[False for i in range(13)] for j in range(4)]
pattern = {"S": 0,  "H": 1,  "C": 2,  "D": 3}
Mark = ["S", "H", "C", "D"]


L = int(input())
for N in range(L):
    a = list(input().split())

    cards[pattern[a[0]]][int(a[1])-1] = True

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
cards = list()
suit = ['S', 'H', 'C', 'D']
N = int(input())
for i in range(N):
    m,n = input().split()
    n = int(n)
    if m == "S": cards.append(0 + n)
    elif m == "H": cards.append(13 + n)
    elif m == "C": cards.append(26 + n)
    elif m == "D": cards.append(39 + n)
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())

S = []
H = []
C = []
D = []

matome = []
all_number = list(range(1, 14))

for _ in range(n):
    g, num = map(str, input().split())
    if g == "H":
        H.append(int(num))
    elif g == "S":
        S.append(int(num))
    elif g == "D":
        D.append(int(num))
    else:
        C.append(int(num))
        
matome = [S, H, C, D]

resultS = list(filter(lambda x: x not in S,all_number ))
resultH = list(filter(lambda x: x not in H,all_number ))
resultC = list(filter(lambda x: x not in C,all_number ))
resultD = list(filter(lambda x: x not in D,all_number ))

if resultS:
    for i in resultS:
        print("S", i)
if resultH:
    for i in resultH:
        print("H", i)
if resultC:
    for i in resultC:
        print("C", i)
if resultD:
    for i in resultD:
        print("D", i)

Submission status: Accepted

Solution code:
n = int(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",
        ]

for i in range(n):
    c = input()
    Cards.remove(c)
for c in Cards:
    print(c)

Submission status: Accepted

Solution code:
N = int(input())
card = []
d = {'S' : 0,'H' : 1,'C' : 2,'D' : 3}
dd = {0 : 'S',1 : 'H',2 : 'C',3 : 'D'}
flag = [[1 for j in range(13)] for i in range(4)]

for i in range(N):
    a = input().split()
    card.append(a)

for s,rank in card:
    flag[d[s]][int(rank)-1] = 0

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

Submission status: Accepted

Solution code:
n = int(input())
suits = ['S', 'H', 'C', 'D']
cards= []
for suit in suits:
    for i in range(1,14):
        cards.append([suit,str(i)])
for i in range(n):
    cards.remove(input().split())
for i in range(52-n):
    print(cards[i][0],cards[i][1])

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)
    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('S {}'.format(i))
        elif 13 < i <= 26:
            print('H {}'.format(i-13))
        elif 26 < i <=39:
            print('C {}'.format(i-26))
        else:
            print('D {}'.format(i-39))

Submission status: Accepted

Solution code:
m = int(input())
deck = [(suit, num) for suit in ['S', 'H', 'C', 'D'] for num in range(1, 14)]
for _ in range(m):
    s, n = input().split()
    if (s, int(n)) in deck:
        deck.remove((s, int(n)))
for item in deck:
    print(item[0], str(item[1]))

Submission status: Accepted

Solution code:
n = int(input())
all = {key:[i for i in range(1, 14)] for key in ("S", "H", "C", "D")}

for _ in range(n):
    mark, num = iter(input().split())
    all[mark].remove(int(num))
    
for key in all:
    for num in all[key]:
        print("{} {}".format(key, num))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

def print_missingcard(pattern, cardlist):
    for i in range(1,14):
        if i not in cardlist:
            print(str(pattern) +' '+ str(i))

s_cards = []
h_cards = []
c_cards = []
d_cards = []

for i in range(N):
    pattern, num = (x for x in input().split())
    num = int(num)
    if pattern == 'S':
        s_cards.append(num)
    elif pattern == 'H':
        h_cards.append(num)
    elif pattern == 'C':
        c_cards.append(num)
    elif pattern == 'D':
        d_cards.append(num)
    else:
        None

print_missingcard('S', s_cards)
print_missingcard('H', h_cards)
print_missingcard('C', c_cards)
print_missingcard('D', d_cards)

Submission status: Accepted

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

if n != 52:
    for _ in range(n):
        x,y = map(str,input().split())
        if x == 'S':
            S.append(int(y))
        elif x == 'H':
            H.append(int(y))
        elif x == 'C':
            C.append(int(y))
        elif x == 'D':
            D.append(int(y))

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

    ans = []

    for i in range(13):
        if S.count(i+1) == 0:
            ans.append(['S', i+1])
    for i in range(13):
        if H.count(i+1) == 0:
            ans.append(['H', i+1])
    for i in range(13):
        if C.count(i+1) == 0:
            ans.append(['C', i+1])
    for i in range(13):
        if D.count(i+1) == 0:
            ans.append(['D', i+1])

    for v in ans:
        print(' '.join(map(str,v)))

Submission status: Accepted

Solution code:
n = int(input())
S = [str(a+1) for a in range(13)]
H = S.copy()
C = S.copy()
D = S.copy()
while n != 0:
    design, rank = input().split()
    if design == 'S':
        S.remove(rank)
    if design == 'H':
        H.remove(rank)
    if design == 'C':
        C.remove(rank)
    if design == 'D':
        D.remove(rank)
    n -= 1

for a in S:
    print('S {}'.format(a))
for a in H:
    print('H {}'.format(a))
for a in C:
    print('C {}'.format(a))
for a in D:
    print('D {}'.format(a))

Submission status: Accepted

Solution code:
class my_card:
    list_s = [i for i in range(1,14)]
    list_h = [i for i in range(1,14)]
    list_c = [i for i in range(1,14)]
    list_d = [i for i in range(1,14)]
    
    def remove_card(self, pattern, number):
        if pattern == 'S':
            self.list_s.remove(number)
        elif pattern == 'H':
            self.list_h.remove(number)
        elif pattern == 'C':
            self.list_c.remove(number)
        else:
            self.list_d.remove(number)
    
    def print_card_sep(self, list_card, name):
        for card in list_card:
            print('{} {}'.format(name, card))
    
    def print_card(self):
        self.print_card_sep(self.list_s, 'S')
        self.print_card_sep(self.list_h, 'H')
        self.print_card_sep(self.list_c, 'C')
        self.print_card_sep(self.list_d, 'D')
    
input_num = int(input())
my_card = my_card()
for i in range(input_num):
    s, n = input().split()
    n = int(n)
    my_card.remove_card(s, n)
    
my_card.print_card()

Submission status: Accepted

Solution code:
n = int(input())

cards = [[False for i in range(13)] for j in range(4)]
# 0: S
# 1: H
# 2: C
# 3: D
pattern = ["S","H","C","D"]
i = 1
while i <= n:    
    mark, rank = input().split()
    rank = int(rank)
    cards[pattern.index(mark)][rank-1] = True
    i+=1
for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(f"{pattern[i]} {j+1}")

Submission status: Accepted

Solution code:
n = int(input())
c = {
    'S': [0]*13,
    'H': [0]*13,
    'C': [0]*13,
    'D': [0]*13
}
for i in range(n):
    s, num = input().split()
    c[s][int(num)-1] = 1

for i in ["S", 'H', 'C', 'D']:
    for j in range(13):
        if c[i][j] == 0:
            print(i, j+1)

Submission status: Accepted

Solution code:
num = int(input())
tranp = [[ i + 1 for i in range(13)] for j in range(4)]
while num > 0:
  cards = input().split()
  cards[0] = 0 * (cards[0] == 'S') + 1 * (cards[0] == 'H') + 2 * (cards[0] == 'C') + 3 * (cards[0] == 'D')
  cards[1] = int(cards[1]) - 1
  tranp[cards[0]][cards[1]] = 0
  num -= 1
s = list(set(tranp[0]))
s.sort()
if len(s) > 1:
  s = s[1:]
  [print(f"S {i}") for i in s]
h = list(set(tranp[1]))
h.sort()
if len(h) > 1:
  h = h[1:]
  [print(f"H {i}") for i in h]

c = list(set(tranp[2]))
c.sort()
if len(c) > 1:
  c = c[1:]
  [print(f"C {i}") for i in c]

d = list(set(tranp[3]))
d.sort()
if len(d) > 1:
  d = d[1:]
  [print(f"D {i}") for i in d]

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
import copy

def output(string, lis):
    for num in lis:
        print(string, num)

n = int(stdin.readline())

#ナンバーリスト作成
slist = []
for i in range(1,14):
    slist.append(i)

hlist = copy.copy(slist)
clist = copy.copy(slist)
dlist = copy.copy(slist)

for _ in range(n):
    mark, number = map(str, stdin.readline().split())
    if mark == 'S':
        slist.remove(int(number))
    elif mark == 'H':
        hlist.remove(int(number))
    elif mark == 'C':
        clist.remove(int(number))
    elif mark == 'D':
        dlist.remove(int(number))

output('S', slist)
output('H', hlist)
output('C', clist)
output('D', dlist)

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 + 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(f"S {i-0}")
        elif i <= 26:
            print(f"H {i-13}")   
        elif i <= 39:
            print(f"C {i-26}")
        else:
            print(f"D {i-39}")

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    pattern = ["S", "H", "C", "D"]
    cards = [[False for i in range(13)] for j in range(4)]
    for _ in range(n):
        card = input().split()
        char = card[0]
        num = int(card[1])
        cards[pattern.index(char)][num - 1] = True
    for i in range(4):
        for j in range(13):
            if cards[i][j] == False:
                print(f"{pattern[i]} {j+1}")
    return 0


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

H = []
S = []
D = []
C = []

for x in range(1,13+1):
  H.append(x)
  S.append(x)
  D.append(x)
  C.append(x)

for x in range(n):
  a,b = input().split()
  if a == "H":
    H.remove(int(b))
  elif a == "S":
    S.remove(int(b))
  elif a == "D":
    D.remove(int(b))
  elif a == "C":
    C.remove(int(b))

for x in range(len(S)):
  print("S",S[x])
for x in range(len(H)):
  print("H",H[x])
for x in range(len(C)):
  print("C",C[x])
for x in range(len(D)):
  print("D",D[x])

Submission status: Accepted

Solution code:
suit = ('S', 'H', 'C', 'D')
cards = [f'{s} {n}' for s in suit for n in range(1, 14)]
n = int(input())
for _ in range(n):
    card = input()
    cards.remove(card)

for card in cards:
    print(card)

Submission status: Accepted

Solution code:
n = int(input())
have_s = []
have_h = []
have_c = []
have_d = []

for _ in range(n):
    item = input().split()
    if item[0]=="S":
        have_s.append(int(item[1]))
    if item[0]=="H":
        have_h.append(int(item[1]))
    if item[0]=="C":
        have_c.append(int(item[1]))
    if item[0]=="D":
        have_d.append(int(item[1]))

missing_s = [num for num in range(1, 14) if not num in have_s]
missing_h = [num for num in range(1, 14) if not num in have_h]
missing_c = [num for num in range(1, 14) if not num in have_c]
missing_d = [num for num in range(1, 14) if not num in have_d]

for rank in missing_s:
    print(f"S {rank}")
for rank in missing_h:
    print(f"H {rank}")
for rank in missing_c:
    print(f"C {rank}")
for rank in missing_d:
    print(f"D {rank}")

Submission status: Accepted

Solution code:
cards = ['{} {}'.format(s, r) for s in ('S', 'H', 'C', 'D') for r in range (1, 13 + 1)]
x = int(input())
for n in range(x):
    card = input()
    cards.remove(card)
for n in cards:
    print(n)

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 number in range(1,14):
        if not [c,number] in cards:
            print(c+' '+str(number))

Submission status: Accepted

Solution code:
from functools import reduce

n = int(input())

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

for i in range(n):
    mark, num = input().split()
    num = int(num) - 1
    if mark == 'S':
        S[num] = 1
    elif mark == 'H':
        H[num] = 1
    elif mark == 'C':
        C[num] = 1
    elif mark == 'D':
        D[num] = 1

for s in range(len(S)):
    if S[s] == 0:
        print('S ' + str(s + 1))

for h in range(len(H)):
    if H[h] == 0:
        print('H ' + str(h + 1))

for c in range(len(C)):
    if C[c] == 0:
        print('C ' + str(c + 1))

for d in range(len(D)):
    if D[d] == 0:
        print('D ' + str(d + 1))

Submission status: Accepted

Solution code:
N=int(input())

sooted =['S','H','C','D']
list_soot=[]
list_num=[]
for i in range(N):
    a,b=map(str,input().split())
    list_soot.append(a)
    list_num.append(int(b))
    
ans_soot=[]
ans_num=[] 
for j in sooted:
    for k in range(1,14):
        flag =0
        for l,m in zip(list_soot,list_num):
            if j==l and k==m:
                flag=1
                break
        if flag==1:
            continue
        else:
            ans_soot.append(j)
            ans_num.append(k)
            
            
                

for n ,o in zip(ans_soot,ans_num):
    print(n, o)

Submission status: Accepted

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

for i in range(n):
    val = list(input().split())
    Inlist.append(val)
    
CKlist = []
for mark in ['S', 'H', 'C', 'D']:
    for num in range(1, 14):
        num = str(num)
        CKlist.append(list((mark, num)))
        
reslist = [res for res in CKlist if res not in Inlist ]
for p in reslist:
    print('{} {}'.format(p[0], p[1]))

Submission status: Accepted

Solution code:
n = int(input())
S = list(range(1,14))
H = list(range(1,14))
D = list(range(1,14))
C = list(range(1,14))
marks = ['S','H','C','D']

for i in range(n):
    mark,num = input().split()
    eval(mark+'.remove(int(num))')

for m in marks:
    #print(m, eval(m))
    for i in eval(m):
        print(m, i)

Submission status: Accepted

Solution code:
table = [[0 for i in range(13)] for j in range(4)]
cardTypes = ['S', 'H', 'C', 'D']
total = int(input())
card_num = 0

for i in range(total):
    x, y = list(input().split())
    y = int(y)
    if x == 'S':
        table[0][y - 1] = y
    if x == 'H':
        table[1][y -1] = y
    if x == 'C':
        table[2][y -1] = y
    if x == 'D':
        table[3][y -1] = y

for i, row in enumerate(table):
    for j, element in enumerate(row):
        if element == 0:
            print(f"{cardTypes[i]} {j + 1}")

Submission status: Accepted

Solution code:
n=int(input())
taro=[]
for _ in range(n):
    taro.append(list(map(str,input().split())))
s=list(range(1,14))
h=list(range(1,14))
c=list(range(1,14))
d=list(range(1,14))
for i in range(n):
    if taro[i][0]=='S':
        num=int(taro[i][1])
        s[num-1]=0
    elif taro[i][0]=='H':
        num=int(taro[i][1])
        h[num-1]=0
    elif taro[i][0]=='C':
        num=int(taro[i][1])
        c[num-1]=0
    else:
        num=int(taro[i][1])
        d[num-1]=0

new_s=[i for i in s if i !=0]
new_h=[i for i in h if i !=0]
new_c=[i for i in c if i !=0]
new_d=[i for i in d if i !=0]

for i in new_s:
    print('S {0}'.format(i))
for i in new_h:
    print('H {0}'.format(i))
for i in new_c:
    print('C {0}'.format(i))
for i in new_d:
    print('D {0}'.format(i))

Submission status: Accepted

Solution code:
N = int(input())
cards = {"S":list(range(1,14)),"H":list(range(1,14)),"C":list(range(1,14)),"D":list(range(1,14))}
# print(cards)
for n in range(N):
    a,b=input().split()
    cards[a].remove(int(b))
# print(cards)

for k in cards.keys():
    for v in cards[k]:
        print(k,v)

Submission status: Accepted

Solution code:
s = []
h = []
c = []
d = []
num = int(input())
for num1 in range(num):
    a,b = input().split(" ")
    b = int(b)
    if a == "S":
        s.append(b)
    elif a == "H":
        h.append(b)
    elif a == "D":
        d.append(b)
    else:
        c.append(b)
s.sort()
h.sort()
c.sort()
d.sort()
for num2 in range(1,14):
    if num2 in s:
        continue
    else:
        print("S " + str(num2))
        continue
for num3 in range(1,14):
    if num3 in h:
        continue
    else:
        print("H " + str(num3))
        continue
for num4 in range(1,14):
    if num4 in c:
        continue
    else:
        print("C " + str(num4))
        continue
for num5 in range(1,14):
    if num5 in d:
        continue
    else:
        print("D " + str(num5))
        continue

Submission status: Accepted

Solution code:
N = int(input())
cards = list()
suit = ['S', 'H', 'C', 'D']
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 i not in cards:
        print(suit[int((i-1)/13)], (i-1)%13 + 1)

Submission status: Accepted

Solution code:
n = int(input())

card = list()

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

for mark in marks:
  for i in range(13):
    card.append([mark,i+1])

def f(s):
  lst = s.split();
  return lst[0], int(lst[1])

for i in range(n):
  had_mark, had_num = f(input())
  card.remove([had_mark, had_num])

for i in range(len(card)):
  print(str(card[i][0]) + " " + str(card[i][1]))

Submission status: Accepted

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

for i in range(1, 14):
    for j in ['S', 'H', 'C', 'D']:
        perfect_cards.append(j + ' ' + str(i))

r_cards = list(set(perfect_cards) - set(cards))
S_cards = sorted([i for i in r_cards if 'S' in i], key=lambda x: int(x[2:]))
H_cards = sorted([i for i in r_cards if 'H' in i], key=lambda x: int(x[2:]))
C_cards = sorted([i for i in r_cards if 'C' in i], key=lambda x: int(x[2:]))
D_cards = sorted([i for i in r_cards if 'D' in i], key=lambda x: int(x[2:]))
r_cards = S_cards + H_cards + C_cards + D_cards

for i in r_cards:
    print(i)

Submission status: Accepted

Solution code:
cards = [[False for i in range(13)] for j in range(4)]

pattern = ["S", "H", "C", "D"]
z = int(input())

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

for j in range(4):
    for i in range(13):
        if cards[j][i] is False:
            print(pattern[j], i+1)

Submission status: Accepted

Solution code:
n2 = int(input())

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]

while True:
    try:
        c, n = map(str, input().split())
        n = int(n)
        if c == 'S':
            S.remove(n)
        elif c == 'H':
            H.remove(n)
        elif c == 'C':
            C.remove(n)
        elif c == 'D':
            D.remove(n)
    except:
        break

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

Submission status: Accepted

Solution code:
n=int(input())
card=[] 
all_=[[0]*13 for i in range(4)]
#print(all_)
case=["S","H","C","D"]
for i in range(n):
    a,b=input().split()
    all_[case.index(a)][int(b)-1]=1
#print(all_)
for i in range(4):
    for j in range(13):
        if all_[i][j]==0:
            print(case[i]+" "+str(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):
    a,b=list(input().split())
    cards[pattern.index(a)][int(b)-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:
tramp = [[i for i in range(1,14)],
        [i for i in range(1,14)],
        [i for i in range(1,14)],
        [i for i in range(1,14)]]
mark = {"S": 0,"H": 1, "C": 2, "D":3}
itomark = {0: "S", 1:"H",2:"C", 3:"D"}
n = int(input())
for i in range(n):
    m, num = input().split()
    num = int(num)-1
    tramp[mark[m]][num] = 0
for i in range(4):
    for j in range(13):
        if tramp[i][j] != 0:
            print(itomark[i],tramp[i][j])

Submission status: Accepted

Solution code:
a=int(input())
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]
for j in range(a):
    x,n = input().split()
    n = int(n)
    if x == 'S':
        S.remove(n)
    elif x == 'H':
        H.remove(n)
    elif x == 'C':
        C.remove(n)
    else:
        D.remove(n)
if len(S)!=0:
    for i in S:
        print('S',str(i))
if len(H)!=0:
    for i in H:
        print('H',str(i))
if len(C)!=0:
    for i in C:
        print('C',str(i))
if len(D)!=0:
    for i in D:
        print('D',str(i))

Submission status: Accepted

Solution code:

all_cards=[]
for i in range(1,52+1):
    if i<=13:
        all_cards.append('S {}'.format(i))
    elif i <=26:
        all_cards.append('H {}'.format(i-13))
    elif i <=39:
        all_cards.append('C {}'.format(i-26))
    else:
        all_cards.append('D {}'.format(i - 39))


my_cards_sum=int(input())


for i in range(0,my_cards_sum):
    del_cards=input()
    if del_cards in all_cards:
        all_cards.remove(del_cards)

[print(i) for i in all_cards]

Submission status: Accepted

Solution code:
cards = list()
suits = ["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)
    elif s == "H":
        cards.append(r + 13)
    elif s == "C":
        cards.append(r + 26)
    elif s == "D":
        cards.append(r + 39)

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:
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)]

for i in range(n) :
    m, r = map(str, input().split())
    
    if m == "S" :
        S.remove(int(r))
    elif m == "H" :
        H.remove(int(r))
    elif m == "C" :
        C.remove(int(r))
    else :
        D.remove(int(r))
        
if len(S) > 0 :
    for i in range(len(S)) :
        print("S", S[i])
if len(H) > 0 :
    for i in range(len(H)) :
        print("H", H[i])
if len(C) > 0 :
    for i in range(len(C)) :
        print("C", C[i])
if len(D) > 0 :
    for i in range(len(D)) :
        print("D", D[i])

Submission status: Accepted

Solution code:
E = ["S", "H", "C", "D"]
n = int(input())
A = [[0 for j in range(14)] for i in range(4)]
for j in range(n):
    a, b = input().split()
    a = E.index(a)
    b = int(b)
    A[a][b] = 1

for z in range(4):
    for c in range(1, 14):
        if A[z][c] == 0:
            print(f"{E[z]} {c}")

Submission status: Accepted

Solution code:
n = int(input())
i = 0
j = 0
tbl = [[1+i for i in range(13)] for j in range(4)]
# print(tbl)
while i < n:
    a = input()
    z = list(map(str, a.split()))
    if z[0] == "S":
        j = int(z[1]) - 1
        tbl[0][j] = 0
    elif z[0] == "H":
        j = int(z[1]) - 1
        tbl[1][j] = 0
    elif z[0] == "C":
        j = int(z[1]) - 1
        tbl[2][j] = 0
    elif z[0] == "D":
        j = int(z[1]) - 1
        tbl[3][j] = 0
    i += 1
# print(tbl)
i = 0 
for x in tbl:
    j = 0
    for y in x:
        if tbl[i][j] != 0:
            if i == 0:
                list = ["S",str(tbl[i][j])]
                print(" ".join(map(str, list)))
            elif i == 1:
                list = ["H",str(tbl[i][j])]
                print(" ".join(map(str, list)))
            elif i == 2:
                list = ["C",str(tbl[i][j])]
                print(" ".join(map(str, list)))
            elif i == 3:
                list = ["D",str(tbl[i][j])]
                print(" ".join(map(str, list)))
        j += 1
    i += 1

Submission status: Accepted

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

n = int(input())
for _ in range(n):
    suit,num = input().split()
    if   suit=='S': cards[0][int(num)-1] = 0
    elif suit=='H': cards[1][int(num)-1] = 0
    elif suit=='C': cards[2][int(num)-1] = 0
    elif suit=='D': cards[3][int(num)-1] = 0
for s in cards:
    for n in s:
        if n!=0: print(n)

Submission status: Accepted

Solution code:
n=int(input())
card_list=[input() for i in range(n)]
for suit in ["S","H","C","D"]:
    for number in range(1, 14):
        card_c=suit+" "+str(number)
        if not(card_c in card_list):print(card_c)

Submission status: Accepted

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

cards = []
for _ in range(m):
    cards.append(input())
    
for mark in marks:
    for number in range(1, 14):
        if f'{mark} {number}' not in cards:
            print(f'{mark} {number}')

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(1,n+1):
    param,value = input().split()
    cards[pattern.index(param)][int(value)-1]  = True

for i in pattern:

    for indexj,j in enumerate(cards[pattern.index(i)]):

        if j== False:
            print("%s %d" % (i,indexj+1))

Submission status: Accepted

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

for i in range(1,14):
    if str(i) not in s:
        print("S {}".format(i))
for i in range(1,14):
    if str(i) not in h:
        print("H {}".format(i))
for i in range(1,14):
    if str(i) not in c:
        print("C {}".format(i))
for i in range(1,14):
    if str(i) not in d:
        print("D {}".format(i))

Submission status: Accepted

Solution code:
#各行はスペード（S）、ハート（H）、クラブ（C）、ダイヤ（D）を表すとする
tbl = [[0 for i in range(13)] for j in range(4)]

#カードの枚数を格納する
n = int(input())

#ループカウンタの初期化
i = 0

#n組のカードを入力する
while i < n:
    card = input().split()
    #スペード
    if card[0] == 'S':
        tbl[0][int(card[1])-1] = 1
    #ハート
    elif card[0] == 'H':
        tbl[1][int(card[1])-1] = 1
    #クラブ
    elif card[0] == 'C':
        tbl[2][int(card[1])-1] = 1
    #ダイヤ
    else:
        tbl[3][int(card[1])-1] = 1
    i += 1

#絵柄のリスト
pattern = ['S', 'H', 'C', 'D']

#持っていないカードを出力する
for i in range(4):
    for j in range(13):
        if tbl[i][j] == 0:
            print(pattern[i], j+1)