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(map(str, input().split())) for _ in range(n)]

a.sort()


check = 0
#print(a)
cC = 0
cD = 0
cH = 0
cS = 0
lc = []
ld = []
lh = []
ls = []

count = 0

#print(len(a))




while True:
    while 'C' == a[cC][0]:
        lc.append(a[cC][1])#no exist
        cC += 1
    cD = cC
    while 'D' == a[cD][0]:
        ld.append(a[cD][1])#no exist
        cD += 1
    cH = cD
    while 'H' == a[cH][0]:
        lh.append(a[cH][1])#no exist
        cH += 1
    cS =cH
    while cS < n:
        ls.append(a[cS][1])#no exist
        cS += 1
    break


ans = ["1","2","3","4","5","6","7","8","9","10","11","12","13"]
lc_a = set(ans) ^ set(lc)
ld_a = set(ans) ^ set(ld)
lh_a = set(ans) ^ set(lh)
ls_a = set(ans) ^ set(ls)

#print(lc_a)
#print(ld_a)
#print(lh_a)
#print(ls_a)

lc_al = list(lc_a)
ld_al = list(ld_a)
lh_al = list(lh_a)
ls_al = list(ls_a)

lc_al.sort(key=int)
ld_al.sort(key=int)
lh_al.sort(key=int)
ls_al.sort(key=int)

#print(ls_al)
#print(lh_al)
#print(lc_al)
#print(ld_al)



for i in range(len(ls_a)):
   # ls_al.append(ls_a)
    print("S %s"%(ls_al[i]))
          
for i in range(len(lh_a)):
    #lh_al.append(lh_a)
    print("H %s"%(lh_al[i]))
          
for i in range(len(lc_a)):
    #lc_al.append(lc_a)
    print("C %s"%(lc_al[i]))
          
for i in range(len(ld_a)):
   # ld_al.append(ld_a)
    print("D %s"%(ld_al[i]))

Submission status: Accepted

Solution code:
def main(inputs):
    outputs = ''
    dict = {}
    pics = ['S', 'H', 'C', 'D']
    for p in pics:
        dict[p] = list(map(int, range(1, 14)))
    for input in inputs:
        parsed = input.split()
        pic = str(parsed[0])
        num = int(parsed[1])
        dict[pic].remove(num)
    for p in pics:
        for n in dict[p]:
            outputs += '{} {}\n'.format(p, n)
    return outputs


if __name__ == "__main__":
    n = int(input())
    inputs = [input() for i in range(n)]
    print(main(inputs), end='')

Submission status: Accepted

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

Submission status: Accepted

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

n = int(input())
counter = {t: [0] * 13 for t in ['S', 'H', 'C', 'D']}
for _ in range(n):
    tp, num = input().split()
    num = int(num)
    counter[tp][num - 1] += 1

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

Submission status: Accepted

Solution code:
card_lst = []
card_type = ['S', 'H', 'C', 'D']
#make table
for tp in card_type:
    for i in range(13):
        card_lst.append(tp + ' ' + str(i + 1))

#remove
cnt = int(input())
for i in range(cnt):
   card_lst.remove(input())

[print(c) for c in card_lst]

Submission status: Accepted

Solution code:
n = int(input())
card_dict = {}
for symbol in ["S", "H", "C", "D"]:
    card_dict[symbol] = []
for i in range(n):
    symbol, number = input().split(" ")
    card_dict[symbol].append(number)
for symbol in ["S", "H", "C", "D"]:
    for number in range(1, 14):
        if str(number) not in card_dict[symbol]:
            print("{} {}".format(symbol, number))

Submission status: Accepted

Solution code:
N = int(input())

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

for i in range(N) :
    suit, num = input().split()
    if suit == "S" :
        cards[0][int(num) - 1] = 1
    elif suit == "H" :
        cards[1][int(num) - 1] = 1
    elif suit == "C" :
        cards[2][int(num) - 1] = 1
    elif suit == "D" :
        cards[3][int(num) - 1] = 1

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

Submission status: Accepted

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

n= int(input())
#tmp= float(input())

s=[]
h=[]
c=[]
d=[]

for i in range(13):
    s.append(0)
    h.append(0)
    c.append(0)
    d.append(0)

for i in range(n):
    tmp = input().split()
    #suits,num = list(map(lambda a: int(a), tmp))
    suits=tmp[0]
    num=int(tmp[1])
    if(suits=="S"):
        s[num-1]+=1
    if(suits=="H"):
        h[num-1]+=1
    if(suits=="C"):
        c[num-1]+=1
    if(suits=="D"):
        d[num-1]+=1


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

Submission status: Accepted

Solution code:
n = int(input())
cardsS = []
cardsH = []
cardsC = []
cardsD = []
for i in range(0, 13):
    cardsS.append(False)
    cardsH.append(False)
    cardsC.append(False)
    cardsD.append(False)
for i in range(0, n):
    mark, num = input().split()
    if mark == "S":   cardsS[int(num) - 1] = True
    elif mark == "H": cardsH[int(num) - 1] = True
    elif mark == "C": cardsC[int(num) - 1] = True
    elif mark == "D": cardsD[int(num) - 1] = True
for i in range(0, 13):
    if not cardsS[i]: print("S", (i + 1))
for i in range(0, 13):
    if not cardsH[i]: print("H", (i + 1)) 
for i in range(0, 13):
    if not cardsC[i]: print("C", (i + 1)) 
for i in range(0, 13):
    if not cardsD[i]: print("D", (i + 1))

Submission status: Accepted

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

n = int(input())

for i in range(n):
    s, c = input().split()
    c = int(c)
    if s == 'S':
        cards.append(0 + c)
    elif s == 'H':
        cards.append(13 + c)
    elif s == 'C':
        cards.append(26 + c)
    elif s == 'D':
        cards.append(39 + c)
        
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())
cards = [[s+ " "+str(n) for n in range(1,14)]for s in ["S","H","C","D"]]
for i 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:
from collections import defaultdict

KINDS = ['S','H','C','D']
NUM = 13

n = int(input())

cards = defaultdict(bool)
for _ in range(n):
    cards[input()] = True

for mark in KINDS:
    for num in range(1,NUM+1):
        if not cards[f'{mark} {num}']:
            print(f'{mark} {num}')

Submission status: Accepted

Solution code:
card_dict = {'S':[],'H':[],'C':[],'D':[]}
s_key = ['S','H','C','D']
number = input()
for i in range(int(number)):
    card = input()
    card = card.split()
    s, n = card
    card_dict[s].append(int(n))
else:
    ori = set(list(range(1,14)))
    for key in s_key:
        c = set(card_dict[key])
        d = list(ori - c)
        d.sort()
        for i in d:
            print('{} {}'.format(key,i))

Submission status: Accepted

Solution code:
cards = [[False for i in range(13)] for j in range(4)]
mark = ["S", "H", "C", "D"]

n = int(input())
for i in range(n):
    m, x = input().split()
    x = int(x)
    cards[mark.index(m)][x-1] = True
    
for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(mark[i], j+1)

Submission status: Accepted

Solution code:
n = int(input())

list = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
characters = {'S':0, 'H':1, 'C':2, 'D':3}
characters_rev = {0:'S', 1:'H', 2:'C', 3:'D'}

for i in range(n):
    character, integer = [x for x in input().split()]
    
    integer = int(integer)
    
    for c in characters:
        if c == character: character = characters[c]
    
    list[character][integer - 1] = 1
    
for c in range(len(characters)):
    for i in range(13):
        if list[c][i] == 0:
            print(characters_rev[c], i+1)

Submission status: Accepted

Solution code:
# init
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"]
numbers = 13
n = int(input())

for loop in range(n):
    i = input()
    card = list(map(str, i.split()))
    ch = card[0]
    rank = card[1]
    if ch =='' or rank =='': break
    cards[pattern.index(ch)][int(rank)-1] = True
    
# lst = list(map(str,input().split('\n')))
# pattern = ["S", "H", "C", "D"]

# for elm in lst:
#     card = elm.split()
#     print(card)
#     ch = card[0]
#     rank = card[1]
    
#     # S x  ==> card[0][x-1]
#     cards[pattern.index(ch)][rank-1] = True
    
# output
for i in range(len(pattern)):
    for j in range(numbers):
        if cards[i][j] == False:
            print(pattern[i], j+1)

Submission status: Accepted

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

for i in suits:
    for j in range(1, 14):
        card = (i + " " + str(j))
        card_list.append(card)

for k in range(n):
    cards = input()
    if cards in card_list:
        card_list.remove(cards)

for l in card_list:
    print(l)

Submission status: Accepted

Solution code:
c = int(input())
d = {}
e = {}
for i in range(c):
    k, v = input().split()
    d.setdefault(k, []).append(int(v))
for k,v in d.items():
    for i in range(1,14):
        if not i in v:
            e.setdefault(k, []).append(int(i))
if e:
    for k in ['S','H','C','D']:
        for i in e[k]:
            print("{} {}".format(k, i))

Submission status: Accepted

Solution code:
n = int(input())
c = {"S":[], "H":[], "C":[], "D":[]}
for _ in range(n):
    p, r = map(str, input().split())
    c[p].append(int(r))

for p in ["S", "H", "C", "D"]:
    c[p].sort()
    for r in sorted(set(list(range(1, 14)))-set(c[p])):
        print(p, r)

Submission status: Accepted

Solution code:
n = int(input())
s = []
h = []
c = []
d = []
for _ in range(n):
    a, b = input().split()
    if a == 'S':
        s.append(int(b))
    elif a == 'H':
        h.append(int(b))
    elif a == 'C':
        c.append(int(b))
    else:
        d.append(int(b))

for i in range(1, 14):
    if s.count(i) != 1:
        print('S', i)

for i in range(1, 14):
    if h.count(i) != 1:
        print('H', i)

for i in range(1, 14):
    if c.count(i) != 1:
        print('C', i)

for i in range(1, 14):
    if d.count(i) != 1:
        print('D', i)

Submission status: Accepted

Solution code:

n=int(input())
cnt=0
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(cnt<n):
    a,b=map(str,input().split())
    b=int(b)
    if a=="S":
        s.remove(b)
    elif a=="H":
        h.remove(b)
    elif a=="C":
        c.remove(b)
    elif a=="D":
        d.remove(b)
    cnt+=1

for i in range(len(s)):
    print("S"+" "+str(s[i]))

for i in range(len(h)):
    print("H"+" "+str(h[i]))

for i in range(len(c)):
    print("C" + " " + str(c[i]))

for i in range(len(d)):
    print("D" + " " + str(d[i]))

Submission status: Accepted

Solution code:
x = int(input())
bs = [input() for i in range(x)]
bt = []
for q in ["S ","H ","C ","D "]:
    for qq in range(13):
        bt.append(q+str(qq+1))
aaa = list(set(bt) - set(bs))
aaa.sort(key=lambda x: (int(x[2:])))
for ii in ["S","H","C","D"]:
    for i in aaa:
        if (i.find(ii) != -1):
            print(i)

Submission status: Accepted

Solution code:
kards = [[0]*13 for i in range(4)]
maping = dict(zip(['S', 'H','C', 'D'], range(4)))
map_inv = dict(zip(range(4), ['S', 'H','C', 'D']))

n = int(input())
for i in range(n):
    m, num = input().split()
    num = int(num)
    m_int = maping[m]
    kards[m_int][num-1] = 1

for i in range(4):
    for j in range(13):
        if kards[i][j]==0:
            print(map_inv[i] + ' ' + str(j+1))

Submission status: Accepted

Solution code:
count = int(input())

c = {}

for s in (["S", "H", "C", "D"]):
    c[s] = {}

for s in c:
    for n in range(1, 14):
        c[s][str(n)] = False

for i in range(count):
    s, n = input().split()
    
    c[s][n] = True
    #print(i, s, n, c[s][str(n)])

for s in c:
    for n in c[s]:
        if not c[s][n]:
            print(f'{s} {n}')
    #print(f'{s} {n} {c[s][n]}')

Submission status: Accepted

Solution code:
n=int(input())
a=[[0 for x in range(14)] for y in range(4)]
for i in range(n):
    lis=input().split()
    if lis[0]=="S":
        a[0][int(lis[1])]=1
    elif lis[0]=="H":
        a[1][int(lis[1])]=1
    elif lis[0]=="C":
        a[2][int(lis[1])]=1
    else:
        a[3][int(lis[1])]=1

for i in range(4):
    for j in range(1,14):
        if a[i][j]==0:
            if i==0:
                print("S {}".format(j))
            elif i==1:
                print("H {}".format(j))
            elif i==2:
                print("C {}".format(j))
            elif i==3:
                print("D {}".format(j))

Submission status: Accepted

Solution code:
N = int(input())
S_list = []
H_list=[]
C_list=[]
D_list=[]



for i in range(N):
    cards = input().split()
    if cards[0] == "S":
        S_list.append(cards[1])
    if cards[0] == "H":
        H_list.append(cards[1])
    if cards[0] == "C":
        C_list.append(cards[1])
    if cards[0] == "D":
        D_list.append(cards[1])

for i in range(1,14):
    if str(i) not in S_list:
        print("S" + " " + str(i))
for i in range(1,14):
    if str(i) not in H_list:
        print("H" + " " + str(i))
for i in range(1,14):
    if str(i) not in C_list:
        print("C" + " " + str(i))
for i in range(1,14):
    if str(i) not in D_list:
        print("D" + " " + str(i))

Submission status: Accepted

Solution code:
N = int(input())

card = [[True for i in range(13)] for j in range(4)]
for i in range(N):
    S,n = input().split()
    n = int(n)
    if S == 'S':
        card[0][n-1] = False
    elif S == 'H':
        card[1][n-1] = False
    elif S == 'C':
        card[2][n-1] = False
    else:
        card[3][n-1] = False
for i in range(4):
    for j in range(13):
        if card[i][j]:
            if i == 0:
                print('S',j+1)
            elif i == 1:
                print('H',j+1)
            elif i == 2:
                print('C',j+1)
            else:
                print('D',j+1)

Submission status: Accepted

Solution code:
n = int(input())
card_list = [input().split() for _ in range(n)]
for i in range(len(card_list)):
    card_list[i][1] = int(card_list[i][1])

sort_key = ["S", "H", "C", "D"]
answer = []

# 絵柄毎に処理
for i in range(len(sort_key)):
    target = []
    # 各絵柄のカード番号を収集
    for j in range(len(card_list)):
        if card_list[j][0] == sort_key[i]:
            target.append(card_list[j][1])

    # 持っていない番号を収集
    for j in range(1, 13 + 1):
        if j not in target:
            answer.append([sort_key[i], j])

[print(*answer[i]) for i in range(len(answer))]

Submission status: Accepted

Solution code:
n = int(input())

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


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

for i in range(n):
	li = list(input().split())
	m = li[0]
	num = int(li[1])

	cards[mark.index(m)][num - 1] = True
	
for i in range(4):
	for j in range(13):
		if not cards[i][j]:
			print(mark[i], j+1)

Submission status: Accepted

Solution code:
n=int(input())
a=[0]*n
b=[0]*n
for i in range(n):
    a[i],b[i]=input().split()
    b[i]=int(b[i])
for char in 'SHCD':
    for i in range(1,14):
        flag=0
        for j in range(n):
            if a[j]==char and b[j]==i:
                flag=1
                break
        if flag==0:
            print(char,i)

Submission status: Accepted

Solution code:
S = list(range(1,14))
H,C,D = S[::],S[::],S[::]
N = int(input())
for n in range(N):
    img,num = input().split(' ')
    num = int(num)
    if img == 'S':
        S.remove(num)
    if img == 'H':
        H.remove(num)
    if img == 'C':
        C.remove(num)
    if img == 'D':
        D.remove(num)
for s in S:
    print(f'S {s}')
for h in H:
    print(f'H {h}')
for c in C:
    print(f'C {c}')
for d in D:
    print(f'D {d}')

Submission status: Accepted

Solution code:
a=['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=int(input())
count=0
for i in range(x):
  a.remove(input())
for i in range(52-x):
  print(a[count])
  count+=1

Submission status: Accepted

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

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

for mk in mark_list:
	for i in range(1,14):
		chk_trump = str.format("{0} {1}",mk,str(i))
		istrump = False
		for j in trumplist:
			if j == chk_trump:
				istrump = True
				break
		if istrump == False:
			print(chk_trump)

Submission status: Accepted

Solution code:
check_list_S = [0] * 13
check_list_H = [0] * 13
check_list_C = [0] * 13
check_list_D = [0] * 13
input_number = int(input())

for i in range(input_number):
    input_data = list(input().split())
    check_mark = str(input_data[0])
    check_number = int(input_data[1])
    if check_mark == "S":
        check_list_S[check_number-1] += 1
    elif check_mark == "H":
        check_list_H[check_number-1] += 1
    elif check_mark == "C":
        check_list_C[check_number-1] += 1
    elif check_mark == "D":
        check_list_D[check_number-1] += 1

for i in range(13):
    if check_list_S[i] == 0:
        print(f"S {i+1}")
for i in range(13):
    if check_list_H[i] == 0:
        print(f"H {i+1}")
for i in range(13):
    if check_list_C[i] == 0:
        print(f"C {i+1}")
for i in range(13):
    if check_list_D[i] == 0:
        print(f"D {i+1}")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def main():
    N = int(input())

    mark_to_num = {"S":0, "H":1, "C":2, "D":3}
    num_to_mark = {0:"S", 1:"H", 2:"C", 3:"D"}

    check = [[False for i in range(13)] for j in range(4)]
    
    for i in range(N):
        mark, num = input().split()
        check[mark_to_num[mark]][int(num)-1] = True
    # print(check)
    for i in range(4):
        for j in range(13):
            if not check[i][j]:
                print(num_to_mark[i], j+1)




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
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)
    if mark == 'S':
        S[num-1] = 1
    elif mark == 'H':
        H[num-1] = 1
    elif mark == 'C':
        C[num-1] = 1
    elif mark == 'D':
        D[num-1] = 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:


spades = [i for i in range(1, 14)]
hearts = [i for i in range(1, 14)]
clubs = [i for i in range(1, 14)]
diamonds = [i for i in range(1, 14)]


n = int(input())
for i in range(n):
    suits, ranks = (input()).split(' ')
    ranks = int(ranks)
    if suits == 'S':
        spades.remove(ranks)
    if suits == 'H':
        hearts.remove(ranks)
    if suits == 'C':
        clubs.remove(ranks)
    if suits == 'D':
        diamonds.remove(ranks)

for s in spades:
    print('S', s)
for h in hearts:
    print('H', h)
for c in clubs:
    print('C', c)
for d in diamonds:
    print('D', d)

Submission status: Accepted

Solution code:
n=int(input())
cards=[]
for i in range(n):
    m,n=input().split()
    cards.append((m,int(n)))
for m in ['S','H','C','D']:
    for n in range(1,13+1):
        if (m,n) not in cards:
            print(m,n)

Submission status: Accepted

Solution code:
card={'S':'','H':'','C':'','D':''}
for i in card.keys():
	card[i]=list(range(1,14))
num=int(input())
for c in range(num):
	key,val=input().split()
	card[key].remove(int(val))

for c in list(['S','H','C','D']):
	for i in range(len(card[c])):
		print('%s %d'%(c,card[c][i]))

Submission status: Accepted

Solution code:
num = int(input())

Slist = [False] * 13
Hlist = [False] * 13
Clist = [False] * 13
Dlist = [False] * 13

for i in range(num):
    l = input().split()
    suit = l[0]
    num = int(l[1]) - 1

    if   suit == 'S':
        Slist[num] = True
    elif suit == 'H':
        Hlist[num] = True
    elif suit == 'C':
        Clist[num] = True
    elif suit == 'D':
        Dlist[num] = True

for i,exists in enumerate(Slist):
    if not exists:
        print(f'S {i+1}')

for i,exists in enumerate(Hlist):
    if not exists:
        print(f'H {i+1}')

for i,exists in enumerate(Clist):
    if not exists:
        print(f'C {i+1}')

for i,exists in enumerate(Dlist):
    if not exists:
        print(f'D {i+1}')

Submission status: Accepted

Solution code:
num = int(input())
S = list(range(1,14))
H = list(range(1,14))
C = list(range(1,14))
D = list(range(1,14))
for i in range(1,num+1):
    a,b = input().split()
    b=int(b)
    if a == 'S':
        S[b-1]=0
    elif a == 'H':
        H[b-1]=0
    elif a == 'D':
        D[b-1]=0
    else:
        C[b-1]=0
    
Slist = [i for i in S if i != 0]
Hlist = [i for i in H if i != 0]
Dlist = [i for i in D if i != 0]
Clist = [i for i in C if i != 0]

for i in range(len(Slist)) :
    print("S "+ str(Slist[i]))
for i in range(len(Hlist)) :
    print("H "+ str(Hlist[i]))
for i in range(len(Clist)) :
    print("C "+ str(Clist[i]))
for i in range(len(Dlist)) :
    print("D "+ str(Dlist[i]))

Submission status: Accepted

Solution code:
full = set([i for i in range(1, 14)])
t = ['S', 'H', 'C', 'D']
c = [set() for i in range(4)]
N = int(input())
for i in range(N):
    card = input().split()
    if card[0] == 'S':
        c[0].add(int(card[1]))
    elif card[0] == 'H':
        c[1].add(int(card[1]))
    elif card[0] == 'C':
        c[2].add(int(card[1]))
    elif card[0] == 'D':
        c[3].add(int(card[1]))
for i, ca in enumerate(c):
    for f in sorted(list(full - ca)):
        print(t[i] + ' ' + str(f))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(range(1,14))
h = s[:]
c = s[:]
d = s[:]

n = int(input())

for i in range(n):
    type_k,num = map(str,input().split())
    if type_k == "S":
        s.remove(int(num))
    elif type_k == "H":
        h.remove(int(num))
    elif type_k == "C":
        c.remove(int(num))
    elif type_k == "D":
        d.remove(int(num))

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())
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:
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 = input().split()
    rank = int(rank)
    
    cards[pattern.index(ch)][rank-1] = True

for ch in pattern:
    for rank in range(13):
        if cards[pattern.index(ch)][rank]:
            pass
        else:
            print(f"{ch} {rank+1}")

Submission status: Accepted

Solution code:
l = []
for x in ["S", "H", "C", "D"]:
	for y in range(1,14):
		l.append("{} {}".format(x, y))

for _ in range(int(input())):
	l.remove(input())

[print(x) for x in l]

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):
    pat, rank = input().split()
    rank = int(rank)
    cards[pattern.index(pat)][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:
lst = []
count= 1
for i in range(52):
    lst.append(count)
    count += 1
n = int(input())
for j in range(int(n)):
    a, b = map(str, input().split())
    b = int(b)
    if str(a) == "S":
        b += 0
    elif str(a) == "H":
        b += 13
    elif str(a) == "C":
        b += 26
    else:
        b += 39
    lst.remove(b)
count2 = 0
for j in range(len(lst)):
    suit = None
    value = 0
    compare13value = int(1)
    comparevalue = int(lst[count2] - 1)
    if int(comparevalue / 13) == 0:
        suit = 'S'
    elif int(comparevalue / 13) == 1:
        suit = 'H'
    elif int(comparevalue / 13) == 2:
        suit = 'C'
    else:
        suit = 'D'
    comparevalue += 1
    for y in range(13):
        if int(comparevalue) % 13 == 0:
            value = 13
            break
        elif int(comparevalue) % 13 == compare13value:
            value = compare13value
            break
        compare13value += 1
    print(suit, value)
    n -= 1
    count2 += 1

Submission status: Accepted

Solution code:
n = int(input())
S = []
H = []
C = []
D = []
for i in range(n):
    a, b = input().split()
    if a == "S":
        S.append(int(b))
    if a == "H":
        H.append(int(b))
    if a == "C":
        C.append(int(b))
    if a == "D":
        D.append(int(b))
S.sort()
C.sort()
H.sort()
D.sort()

check = [0 for i in range(14)]

for i in S:
    check[i] = 1

for i in range(1, 14):
    if (check[i] == 0):
        print("S ", end = "")
        print(i)

check = [0 for i in range(14)]

for i in H:
    check[i] = 1

for i in range(1, 14):
    if (check[i] == 0):
        print("H ", end = "")
        print(i)

check = [0 for i in range(14)]

for i in C:
    check[i] = 1

for i in range(1, 14):
    if (check[i] == 0):
        print("C ", end = "")
        print(i)

check = [0 for i in range(14)]

for i in D:
    check[i] = 1

for i in range(1, 14):
    if (check[i] == 0):
        print("D ", end = "")
        print(i)

Submission status: Accepted

Solution code:
n=int(input())
a=[input().split() for i in range(n)]
l=[]
for j in range(13):
    ll=[]
    ll.append("S")
    ll.append(str(j+1))
    l.append(ll)
for j in range(13):
    ll=[]
    ll.append("H")
    ll.append(str(j+1))
    l.append(ll)
for j in range(13):
    ll=[]
    ll.append("C")
    ll.append(str(j+1))
    l.append(ll)
for j in range(13):
    ll=[]
    ll.append("D")
    ll.append(str(j+1))
    l.append(ll)
for k in range(len(l)):
    if l[k] not in a:
        o=" ".join(l[k])
        print(o)

Submission status: Accepted

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

for i in range (n):
    a,b=input().split()
    b=int(b)
    if a=='S':
        v.append(b+0)
    elif a=='H':
        v.append(b+13)
    elif a=='C':
        v.append(b+26)
    elif a=='D':
        v.append(b+39)
for i in range(1,53):
    if not (i in v):
        if i<14:
            print(f"S {i-0}")
        elif i<27:
            print(f"H {i-13}")
        elif i<40:
            print(f"C {i-26}")
        else:
            print(f"D {i-39}")

Submission status: Accepted

Solution code:
# カードの枚数を受け取る
n = int(input())

# インプットのカードをリストに入れる
input_list = [input() for i in range(n)]

# カードの辞書
card = {
    "S": [str(i) for i in range(1, 14)],
    "H": [str(i) for i in range(1, 14)],
    "C": [str(i) for i in range(1, 14)],
    "D": [str(i) for i in range(1, 14)]
}

# 辞書からインプットの値を削除
for j in input_list:
    suit, number = j.split()
    card[suit].remove(number)

# 処理実行
for key, value in card.items():
    for v in value:
        print(f"{key} {v}")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=int(input())
b=[]
d=0
e=[]
m=['S','H','C','D']
for i in range(a):
    c=input()
    b.append(c.split(" "))
for w in range(4):
    for n in range(13):
        if b.count([m[w],str(n+1)])==0:
            d+=1
            e.append([m[w],str(n+1)])

for g in range(d):
    print(e[g][0],e[g][1])