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:
suits = ['S','H','C','D']

n = int(input())
cards = set() 
for _ in range(n):
    cards.add(input())

for suit in suits:
    for i in range(1,14):
        s = "{} {}".format(suit, i)
        if s not in cards:
            print(s)

Submission status: Accepted

Solution code:
# すべてのカードを用意
list_mark = ['S', 'H', 'C', 'D']
num_card_max = 13
set_card_all = {f"{mark} {str(i + 1)}" for mark in list_mark  for i in range(num_card_max)}

# 保有するカードを取得
N_card = int(input())
set_card_have = {input() for _ in range(N_card)}

# 持っていないカードの計算
set_card_not_have = set_card_all - set_card_have
list_card_not_have = list(set_card_not_have)
# print(list_card_not_have)

"""
絵柄がスペード、ハート、クラブ、ダイヤの順番で優先的に出力する。
絵柄が同じ場合は、ランクが小さい順に出力する。
"""

list_s = []
list_h = []
list_c = []
list_d = []

for mark_num in list_card_not_have:
    if mark_num[0] == 'S':
        num = int(mark_num[2:])
        list_s.append(num)
    elif mark_num[0] == 'H':
        num = int(mark_num[2:])
        list_h.append(num)
    elif mark_num[0] == 'C':
        num = int(mark_num[2:])
        list_c.append(num)
    else:
        num = int(mark_num[2:])
        list_d.append(num)

list_s.sort()
list_h.sort()
list_c.sort()
list_d.sort()

if len(list_s) != 0:
    for i in list_s:
        print(f"S {i}")
        
if len(list_h) != 0:
    for i in list_h:
        print(f"H {i}")
        
if len(list_c) != 0:
    for i in list_c:
        print(f"C {i}")
        
if len(list_d) != 0:
    for i in list_d:
        print(f"D {i}")

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

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 _ in range(n):
    egara,num = input().split()
    if egara == "S":
        cards[0][int(num) - 1] = 0
    elif egara == "H":
        cards[1][int(num) - 1] = 0
    elif egara == "C":
        cards[2][int(num) - 1] = 0
    elif egara == "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:
# coding: utf-8
#68

n = int(input())
C=[]
for i in range(n):
    C.append(input())
#print(C)
S=["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"]

#A= set(C)^set(S)
#a=[A]
a=sorted(set(C)^set(S),key=S.index)
#a.split()
#a.replase('{','}',',')
for j in range(len(a)):
    print(a[j])

Submission status: Accepted

Solution code:
n=int(input())
s=[]
h=[]
c=[]
d=[]
for i in range(n):
    a,b=map(str,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))
for i in range(1,14):
    if i in s:
        pass
    else:
        print("S",i)
for i in range(1,14):
    if i in h:
        pass
    else:
        print("H",i)
for i in range(1,14):
    if i in c:
        pass
    else:
        print("C",i)
for i in range(1,14):
    if i in d:
        pass
    else:
        print("D",i)

Submission status: Accepted

Solution code:
val = ["S", "H", "C", "D"]
cards = []
for i in val:
    cards.extend([str(i) + " " + str(j) for j in range(1, 14)])

n = int(input())
curr_cards = [input() for i in range(n)]

diff_cards = [x for x in cards if x not in curr_cards]

if diff_cards != []:
    print("\r\n".join(diff_cards))

Submission status: Accepted

Solution code:
acdic = {"S":[0]*13,"H":[0]*13,"C":[0]*13,"D":[0]*13}
n = int(input())
marklist = ["S","H","C","D"]
for i in range(n):
    m,l=input().split() 
    acdic[m][int(l)-1] = 1

for _ in marklist:
    for i in range(13):
        if acdic[_][i] == 0:
            print(_ + " "+ str(i+1))

Submission status: Accepted

Solution code:
N = int(input())

s_sub = list()
for j in range(N):
    s_sub.append(input())

S_all = ["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"]

#ans = list()
for i in range(52):
    if S_all[i] in s_sub:
        pass
    else:
        print(S_all[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
tbl = [[0 for i in range(13)] for j in range(4)]

for n in range(n):
    suit, i = input().split()
    i = int(i)
    if suit == 'S':
        tbl[0][i-1] = i
    elif suit == 'H':
        tbl[1][i-1] = i
    elif suit == 'C':
        tbl[2][i-1] = i
    elif suit == 'D':
        tbl[3][i-1] = i

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

Submission status: Accepted

Solution code:

pattern = ["S","H","C","D"]
cards = [[0 for i in range(13)]for j in range(4)]

n = int(input())
for i in range(n):
    ch,rank = input().split()
    rank = int(rank)
    cards[pattern.index(ch)][rank-1]=1

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

Submission status: Accepted

Solution code:
cards = []
for suit in ['S', 'H', 'C', 'D']:
  for i in range(13):
    cards.append(' '.join([suit, str(i + 1)]))

N = int(input())
for _ in range(N):
  cards.remove(input())

for card in cards:
  print(card)

Submission status: Accepted

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

for c in "SHCD":
    for i in range(1, 14):
        card = f'{c} {i}'
        if card not in cards:
           missings.append(card)

if n != 52:
    print('\n'.join(missings))

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())
S = [str(_) for _ in range(1,14)]
H = [str(_) for _ in range(1,14)]
C = [str(_) for _ in range(1,14)]
D = [str(_) for _ in range(1,14)]
for _ in range(n):
    a,b = input().split()
    if a=="S":
        S.remove(b)
    elif a=="H":
        H.remove(b)
    elif a=="C":
        C.remove(b)
    else:
        D.remove(b)
for s in S:
    print("S "+s)
for h in H:
    print("H "+h)
for c in C:
    print("C "+c)
for d in D:
    print("D "+d)

Submission status: Accepted

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

for mark in marks:
    for i in range(13):
        search_card = mark + " " + str(i + 1)
        if not(search_card in a):
            print(search_card)

Submission status: Accepted

Solution code:
n = int(input())
cards = [[False]*13 for _ in range(4)]
suits = ["S", "H", "C", "D"]
for i in range(n):
    suit, rank = input().split()
    rank = int(rank)
    if suit == "S":
        suit_num = 0
    elif suit == "H":
        suit_num = 1
    elif suit == "C":
        suit_num = 2
    elif suit == "D":
        suit_num = 3
    cards[suit_num][rank-1] = True

for suit in range(4):
    for rank in range(13):
        if cards[suit][rank] is False:
            print("{} {}".format(suits[suit], rank + 1))

Submission status: Accepted

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

for i in range(a):
    all = input().split() 
    char = all[0]
    num = int(all[1])
    if 'S' == char[0]:
        cards[0][num-1] = True;
    if 'H' == char[0]:
        cards[1][num-1] = True;
    if 'C' == char[0]:
        cards[2][num-1] = True;
    if 'D' == char[0]:
        cards[3][num-1] = True;

for j in range(4):
    for k in range(13):
        if cards[j][k] == False:
            print('{} {}'.format(mark[j], k+1))

Submission status: Accepted

Solution code:
N = int(input())
card = [[0 for i in range(13)] for i in range(4)]

for _ in range(N):
    a, b = map(str, input().split())
    if a == "S":
      card[0][int(b)-1] = 1
    elif a == "H":
      card[1][int(b)-1] = 1
    elif a == "C":
      card[2][int(b)-1] = 1
    elif a == "D":
      card[3][int(b)-1] = 1 
for i in range(4):
  for j in range(13):
    if card[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:
import sys

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:
n = int(input())
card = list()
typ = ['S', 'H', 'C', 'D']

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

    if s == "S":
        card.append(0 + 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 not (i in card):
        print(typ[(i-1)//13], (i-1) % 13+1)

Submission status: Accepted

Solution code:
n = int(input())
sl = [i+1 for i in range(13)]
hl = list(sl)
cl = list(sl)
dl = list(sl)
for i in range(n):
    mark,num = input().split()
    if mark == 'S':
        sl.remove(int(num))
    elif mark == 'H':
        hl.remove(int(num))
    elif mark == 'C':
        cl.remove(int(num))
    else:
        dl.remove(int(num))
for i in range(len(sl)):
    print('S',sl[i])
for i in range(len(hl)):
    print('H',hl[i])
for i in range(len(cl)):
    print('C',cl[i])
for i in range(len(dl)):
    print('D',dl[i])

Submission status: Accepted

Solution code:
n=int(input())
s=list(range(1,14))
h=list(range(1,14))
c=list(range(1,14))
d=list(range(1,14))
for _ in range(n):
    x,y=input().split()
    if x=="S":
        s.remove(int(y))
    elif x=="H":
        h.remove(int(y))
    elif x=="C":
        c.remove(int(y))
    elif x=="D":
        d.remove(int(y))
for i in range(len(s)):
    print("S",s[i])
for i in range(len(h)):
    print("H",h[i])
for i in range(len(c)):
    print("C",c[i])
for i in range(len(d)):
    print("D",d[i])

Submission status: Accepted

Solution code:
n = int(input())
cards = list()
pattern = ["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 not (i in cards):
        print(pattern[(i-1)//13], (i-1)%13+1)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

def main():
    card_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]
        ]
        
    n = int(input())
    for i in range(n):
        s, k = input().split()
        if s == "S":
            card_list[0][int(k)-1] = 1
        elif s == "H":
            card_list[1][int(k)-1] = 1
        elif s == "C":
            card_list[2][int(k)-1] = 1
        elif s == "D":
            card_list[3][int(k)-1] = 1
    
    for i in range(4):
        for k in range(13):
            if card_list[i][int(k)] == 0:
                if i == 0:
                    print("S " + str(k+1))
                elif i == 1:
                    print("H " + str(k+1))
                elif i == 2:
                    print("C " + str(k+1))
                elif i == 3:
                    print("D " + str(k+1))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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

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

t = 'SHCD'
dic = {t[i]: a[i] for i in range(4)}

for i in range(n):
    k, no = input().split()
    no = int(no)
    dic[k][no] = True

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

Submission status: Accepted

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



cllist=list(range(1,53))


for i in inp:
	cl,rank= i[0],int(i[1])
	if cl=="S":
		cllist.remove(rank)
	elif cl=="H":
		cllist.remove(rank+13)
	elif cl=="C":
		cllist.remove(rank+26)
	elif cl=="D":
		cllist.remove(rank+39)

for i in cllist:
	if 0< i and i < 14:
		print(f"S {i}")
	elif 13 < i and i< 27:
		print(f"H {i-13}")
	elif 26 < i and i< 40:
		print(f"C {i-26}")
	elif 39 < i:
		print(f"D {i-39}")

Submission status: Accepted

Solution code:
n = int(input())
card = [[False for i in range(13)] for j in range(4)]

for i in range(n) :
    mark, suit = input().split()
    if mark == "S" :
        mark_num = 0
    elif mark == "H" :
        mark_num = 1
    elif mark == "C" :
        mark_num = 2
    elif mark == "D" :
        mark_num = 3
    card[mark_num][int(suit)-1] = True

for j in range(4) :
    for i in range(13) :
        if card[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:
n = int(input())

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


for i in range(n):
    c, d= input().split()
    x = int(d)

    if c == 'S':
        S[x-1] = 1

    elif c == 'H':
        H[x-1] = 1

    elif c == 'C':
        C[x-1] = 1

    elif c == 'D':
        D[x-1] = 1

for i in range(13):
    if S[i] == 0:
        print("S", i+1)

for i in range(13):
    if H[i] == 0:
        print("H", i+1)

for i in range(13):
    if C[i] == 0:
        print("C", i+1)

for i in range(13):
    if D[i] == 0:
        print("D", i+1)

Submission status: Accepted

Solution code:
a = {'S': [0 for i in range(13)],'H': [0 for i in range(13)],'C': [0 for i in range(13)],'D': [0 for i in range(13)]}



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

Submission status: Accepted

Solution code:
def create_card_set():
    card_types=["S","H","C","D"]
    cart_nums=[i+1 for i in range(13)]
    
    card_set=set()
    
    for ct in card_types:
        for cn in cart_nums:
            card_set = card_set | {(ct,cn)}
    
    return card_set
    
def read_card():
    n=int(input())
    init_card_set=set()
    
    for i in range(n):
        ct,cn_s=tuple(input().split())
        cn = int(cn_s)
        init_card_set = init_card_set | {(ct,cn)}
        
    return init_card_set
    

def sort_card(left_card):
    #card typeをバケットソート
    spade_ls=[]
    heart_ls=[]
    club_ls=[]
    diamond_ls=[]
    
    for card in left_card:
        ct=card[0]
        if ct=="S":
            spade_ls.append(card)
        elif ct == "H":
            heart_ls.append(card)
        elif ct=="C":
            club_ls.append(card)
        elif ct=="D":
            diamond_ls.append(card)
            
    #カード毎の数字を昇順ソート
    spade_ls=sorted(spade_ls,key=lambda x:x[1])
    heart_ls=sorted(heart_ls,key=lambda x:x[1])
    club_ls=sorted(club_ls,key=lambda x:x[1])
    diamond_ls=sorted(diamond_ls,key=lambda x:x[1])
    
    return spade_ls+heart_ls+club_ls+diamond_ls


def find_miss_card():

    init_card_set=read_card()
    
    all_card=create_card_set()
    
    left_card=all_card - init_card_set
    
    result=sort_card(left_card)


    for ct,cn in result:
        print(f"{ct} {cn}")

find_miss_card()

Submission status: Accepted

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

for i in range(n):
    suit, rank = input().split()
    rank = int(rank)
    cards[suits.index(suit)][rank-1] = True

for i in range(4):
    for j in range(13):
        if not cards[i][j]:
            print(suits[i], j+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))

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:
n = int(input())
if n != 52:
    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):
        A = input().split()
        if A[0] == "S":
            s.remove(int(A[1]))
        elif A[0] == "H":
            h.remove(int(A[1]))
        elif A[0] == "C":
            c.remove(int(A[1]))
        elif A[0] == "D":
            d.remove(int(A[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:

cards = [[False for i in range(14)] for j in range(4)]
pattern = ["S", "H", "C", "D"]

n = int(input())

for i in range(n):
    x = list(map(str,input().split()))
    cards[pattern.index(x[0])][int(x[1])] = True

for i2 in range(4):
    for j in range(1,14):
        if cards[i2][j] == False:
            print(pattern[i2],j)

Submission status: Accepted

Solution code:
n = int(input())
S = [input().split() for i in range(n)]
S = [''.join(s) for s in S]

for p in ['S','H','C','D']:
    for i in range(1,13+1):
        if p+str(i) not in S:
            print(p+' '+str(i))

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:
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:
# coding: utf-8
# Your code here!

n = int(input())
cards = [0] * 74

for i in range(1, n + 1):
   marks ,num = map(str, input().split())
   num = int(num)
   

   if marks == "S":
      cards[num + 0] += 1
   elif marks == "H":
      cards[num + 20] += 1
   elif marks == "C":
      cards[num + 40] += 1
   else:
      cards[num + 60] += 1
   
for i in range(1, 14):
   if cards[i] == 0:
      print("S", i)
for i in range(21, 34):
   if cards[i] == 0:
      print("H", i - 20)
for i in range(41, 54):
   if cards[i] == 0:
      print("C", i - 40)   
for i in range(61, 74):
   if cards[i] == 0:
      print("D", i - 60)

Submission status: Accepted

Solution code:
N=int(input())
suits=["S","H","C","D"]
cards=[]
for _ 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:
cards=[[False for j in range(13)]for i in range(4)]
pattern=["S","H","C","D"]
n=int(input())
for elem in range(n):
    ch,rank=input().split()
    rank=int(rank)
    cards[pattern.index(ch)][rank-1]=True

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

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

cnt = 1

while cnt <= n:
    e = input().split()
    idx = int(e[1]) - 1
    if e[0] == "S":
        S[idx] = 1
    elif e[0] == "H":
        H[idx] = 1
    elif e[0] == "C":
        C[idx] = 1
    elif e[0] == "D":
        D[idx] = 1
    cnt += 1

for idxs in range(13):
    if S[idxs] == 0:
        print("S {}".format(idxs + 1))

for idxs in range(13):
    if H[idxs] == 0:
        print("H {}".format(idxs + 1))

for idxs in range(13):
    if C[idxs] == 0:
        print("C {}".format(idxs + 1))

for idxs in range(13):
    if D[idxs] == 0:
        print("D {}".format(idxs + 1))

Submission status: Accepted

Solution code:
c={
    'S':[0]*13,
    'H':[0]*13,
    'C':[0]*13,
    'D':[0]*13
}
n=int(input())
for _ 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:
N=int(input())
suits=['S','H','C','D']
cards=[]

for _ 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:
l=[[True for i in range(13)] for i in range(4)]
d=['S','H','C','D']
n=int(input())
for i in range(n):
    a,b=input().split()
    a=d.index(a)
    l[a][int(b)-1]=False
for i in range(4):
    for j in range(13):
        if l[i][j]:
            print(d[i],j+1)

Submission status: Accepted

Solution code:
def card_print(mark, cards):
    for i in range(1, 14):
        pair = [mark, str(i)]
        if not pair in cards:
            print(" ".join(pair))

n = int(input())
cards = []
while True:
    if n <= 0:
        break
    cards.append(input().split())
    n -= 1
card_print("S", cards)
card_print("H", cards)
card_print("C", cards)
card_print("D", cards)

Submission status: Accepted

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

for i in range(n):
    card = input()
    cards.remove(card)

for i in cards:
    print(i)

Submission status: Accepted

Solution code:
s = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
h = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
c = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
d = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

n = int(input())

for i in range(n):
    suit, rank = input().split()
    if suit=="S":
        s[int(rank)-1] = 1
    elif suit=="H":
        h[int(rank)-1] = 1
    elif suit=="C":
        c[int(rank)-1] = 1
    else:
        d[int(rank) - 1] = 1


for i in range(0, 13, 1):
    if s[i] == 0:
        print("S ",end="")
        print(i+1)

for i in range(0, 13, 1):
    if h[i] == 0:
        print("H ",end="")
        print(i+1)

for i in range(0, 13, 1):
    if c[i] == 0:
        print("C ",end="")
        print(i+1)

for i in range(0, 13, 1):
    if d[i] == 0:
        print("D ",end="")
        print(i+1)

Submission status: Accepted

Solution code:
s = ['S', 'H', 'C', 'D']
d = {}
for c in s:
  d[c] = [i for i in range(1, 14)]

n = int(input())
for i in range(n):
  s, j = input().split()
  d[s].remove(int(j))

for s in d:
    for i in d[s]:
        print('{} {}'.format(s, i))

Submission status: Accepted

Solution code:
suits = ('S', 'H', 'C', 'D')
cards = dict()
for s in suits:
    cards[s] = [False] * 13

n = int(input())
for i in range(n):
    suit, rank = input().split()
    cards[suit][int(rank) - 1] = True

for s in suits:
    for i in range(13):
        if cards[s][i] == False:
            print(s, i+1)

Submission status: Accepted

Solution code:
num = int(input())

a = [ [0 for x in range(14)] for y in range(4)]

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

for i in range(num):
    m,t = input().split()
    n = int(t)
    if m == "S":
        a[0][n] =1
    elif m == "H":
        a[1][n] =1
    elif m == "C":
        a[2][n] =1
    elif m == "D":
        a[3][n] =1

for i in range(4):
    for j in range(1,14):
        if a[i][j] ==0:
            print(mark[i], j)

Submission status: Accepted

Solution code:
n = int(input())

S = []
H = []
C = []
D = []
Slist = []
Hlist = []
Clist = []
Dlist = []

for i in range(n):
    mark, number = map(str, input().split())
    
    if mark=='S':
        S.append(int(number))
    if mark=='H':
        H.append(int(number))
    if mark=='C':
        C.append(int(number))
    if mark=='D':
        D.append(int(number))

if S==[]:
    Slist.append(1,2,3,4,5,6,7,8,9,10,11,12,13)
if H==[]:
    Hlist.append(1,2,3,4,5,6,7,8,9,10,11,12,13)
if C==[]:
    Clist.append(1,2,3,4,5,6,7,8,9,10,11,12,13)
if D==[]:
    Dlist.append(1,2,3,4,5,6,7,8,9,10,11,12,13)

else:
    
    Slen = len(S)
    Hlen = len(H)
    Clen = len(C)
    Dlen = len(D)

    for i in range(Slen):
        for j in range(Slen-1,0,-1):
            if S[j-1]>S[j]:
                S[j-1],S[j] = S[j],S[j-1]

    for i in range(Hlen):
        for j in range(Hlen-1,0,-1):
            if H[j-1]>H[j]:
                H[j-1],H[j] = H[j],H[j-1]

    for i in range(Clen):
        for j in range(Clen-1,0,-1):
            if C[j-1]>C[j]:
                C[j-1],C[j] = C[j],C[j-1]

    for i in range(Dlen):
        for j in range(Dlen-1,0,-1):
            if D[j-1]>D[j]:
                D[j-1],D[j] = D[j],D[j-1]
    
    if S[Slen-1]<13:
        S.append(0)
    if H[Hlen-1]<13:
        H.append(0)
    if C[Clen-1]<13:
        C.append(0)
    if D[Dlen-1]<13:
        D.append(0)

    for i in range(13):
        if S[i]==i+1:
            pass
        else:
            S.insert(i,0)
            Slist.append(i+1)

    for i in range(13):
        if H[i]==i+1:
            pass
        else:
            H.insert(i,0)
            Hlist.append(i+1)

    for i in range(13):
        if C[i]==i+1:
            pass
        else:
            C.insert(i,0)
            Clist.append(i+1)

    for i in range(13):
        if D[i]==i+1:
            pass
        else:
            D.insert(i,0)
            Dlist.append(i+1)

if Slist==[]:
    print('',end='')
if Hlist==[]:
    print('',end='')
if Clist==[]:
    print('',end='')
if Dlist==[]:
    print('',end='')

else:
    Sll = len(Slist)
    Hll = len(Hlist)
    Cll = len(Clist)
    Dll = len(Dlist)

    for i in range(Sll):
        print('S',Slist[i])
    for i in range(Hll):
        print('H',Hlist[i])
    for i in range(Cll):
        print('C',Clist[i])
    for i in range(Dll):
        print('D',Dlist[i])

Submission status: Accepted

Solution code:
n = int(input())

card = [[0 for i in range(14)]for j in range(4)]
        #S:0, H:1, C:2, D:3

dic1 = {'S': 0, 'H': 1, 'C': 2, 'D': 3}

for a in range(n):
    mark, num = map(str, input().split())
    card[dic1[mark]][int(num)] = 1

for b in dic1:
    for c in range(1, 13+1):
        if card[dic1[b]][c] == 0:
            print(b, c)

Submission status: Accepted

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

for i in range(num):
    card = input()
    cards[card] = True

#print(cards)

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