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())
d = {}

for i in range(n):
    d[i]=list(map(str,input().split()))

for mark in ['S','H','C','D']:
    for i in range(1,14):
        if not [mark,str(i)] in d.values():
            pass
            print (mark,i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def translate(a):
    x = ['S', 'H', 'C', 'D', 0, 1, 2, 3]
    num = x.index(a)
    if num < 4:
        return x[num + 4]
    else:
        return x[num - 4]

        
card = [[0 for i in range(13)] for j in range(4)]
n = int(input())

for row in range(n):
    card_input = list(input().split())
    card[translate(card_input[0])][int(card_input[1]) - 1] = 1

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

Submission status: Accepted

Solution code:
n = int(input())

mark = ["S", "H", "C", "D"]
number = [1,2,3,4,5,6,7,8,9,10,11,12,13]
pair = []

for i in mark:
    for j in number:
        pair.append(i+str(j))

for i in range(n):
    a,b = input().split()
    pair.remove(a+b)
    
for ans in pair:
    print(ans[0] + " " + ans[1:])

Submission status: Accepted

Solution code:
n=int(input())
l=[[] for x in range(4)]
list_=["S","H","C","D"]
set_=set([x for x in range(1,14)])
for i in range(n):
    a,b=input().split()
    l[list_.index(a)].append(int(b))
#print(l)
#for m in len(l):
for m in range(len(l)):
    l_=sorted(list(set_-set(l[m])))
    for n in l_:
        print(list_[m],n)

Submission status: Accepted

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

for _ in range(n):
    m,a = input().split()
    if m == 'S':s[int(a)-1] = True
    if m == 'H':h[int(a)-1] = True
    if m == 'C':c[int(a)-1] = True
    if m == 'D':d[int(a)-1] = True

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

Submission status: Accepted

Solution code:
n = int(input())
cards = {'S': [0 for _ in range(13)],
         'H': [0 for _ in range(13)],
         'C': [0 for _ in range(13)],
         'D': [0 for _ in range(13)]}
for i in range(n):
    suit, rank = input().split()
    rank = int(rank)
    cards[suit][rank-1] = 1

for s in ['S', 'H', 'C', 'D']:
    for r in range(1, 14):
        if cards[s][r-1] == 0:
            print(' '.join([s, str(r)]))

Submission status: Accepted

Solution code:
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = int(input())
def getSomeInputListIntn(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [str(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList
data = getSomeInputListIntn(n)

s = [int(i) for i in range(13)]
h = [int(i) for i in range(13)]
c = [int(i) for i in range(13)]
d = [int(i) for i in range(13)]

def checker(l, num):
    num = int(num)
    if l[num-1] == num-1:
        l[num-1] = -1

for suits, num in data:
    if suits == "S":
        checker(s, num)
    elif suits =="H":
        checker(h, num)
    elif suits =="C":
        checker(c, num)
    elif suits =="D":
        checker(d, num)

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

Submission status: Accepted

Solution code:
num = 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 i in range(num):
  t = input().rstrip().split(' ')
  a = int(t[1])
  b = str(t[0])
  if b == "S" and a in S:
      S.remove(a)
  elif b == "H" and a in H:
      H.remove(a)
  elif b == "C" and a in C:
      C.remove(a)
  elif b == "D" and a in D:
      D.remove(a)
lengthS = len(S)
lengthH = len(H)
lengthC = len(C)
lengthD = len(D)
S.sort()
H.sort()
C.sort()
D.sort()
for j in range(lengthS):
  ans = ""
  ans += "S" + " " + str(S[j])
  print(ans)
for k in range(lengthH):
  ans = ""
  ans += "H" + " " + str(H[k])
  print(ans)
for l in range(lengthC):
  ans = ""
  ans += "C" + " " + str(C[l])
  print(ans)
for m in range(lengthD):
  ans = ""
  ans += "D" + " " + str(D[m])
  print(ans)

Submission status: Accepted

Solution code:
cards = []
marks = ['S', 'H', 'C', 'D']
for mark in marks:
    for i in range(1,14):
        cards.append([mark, str(i)])

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

for card in cards:
    print(" ".join(card))

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 i in range(n):
	table =input().split()
	ch=table[0]
	rank=table[1]
	cards[pattern.index(ch)][int(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:
TRUMP = [[i+1 for i in range(13)] for j in range(4)]
Keep_card =[]
n = int(input())

for _ in range(n):
    Mark,No = input().split()
    No = int(No)
    if Mark == "S":
        TRUMP[0][No-1] = "Keep"

    if Mark == "H":
        TRUMP[1][No-1] = "Keep"    

    if Mark == "C":
        TRUMP[2][No-1] = "Keep"

    if Mark == "D":
        TRUMP[3][No-1] = "Keep"

for Mark_no in range(4):
    for level_no in range(13):
        if not TRUMP[Mark_no][level_no] == "Keep":
            if Mark_no == 0:
                print("S ",end="")
                print(str(TRUMP[Mark_no][level_no]))

            if Mark_no == 1:
                print("H ",end="")
                print(str(TRUMP[Mark_no][level_no]))

            if Mark_no == 2:
                print("C ",end="")
                print(str(TRUMP[Mark_no][level_no]))

            if Mark_no == 3:
                print("D ",end="")
                print(str(TRUMP[Mark_no][level_no]))

Submission status: Accepted

Solution code:
n = int(input())

suite = ['S', 'H', 'C', 'D']
ans = set()

for s in suite:
    for i in range(1, 14):
        ans.add('{} {}'.format(s, i))

for i in range(n):
    ll, nn = input().split()
    ans.remove('{} {}'.format(ll, nn))

ans = list(ans)
for i, j in enumerate(ans):
    ans[i] = ans[i].replace('S', 'A')
    ans[i] = ans[i].replace('H', 'B')
    ans[i] = ans[i].replace('10', 'K')
    ans[i] = ans[i].replace('11', 'L')
    ans[i] = ans[i].replace('12', 'M')
    ans[i] = ans[i].replace('13', 'N')


ans.sort()

for i, j in enumerate(ans):
    ans[i] = ans[i].replace('A', 'S')
    ans[i] = ans[i].replace('B', 'H')
    ans[i] = ans[i].replace('K', '10')
    ans[i] = ans[i].replace('L', '11')
    ans[i] = ans[i].replace('M', '12')
    ans[i] = ans[i].replace('N', '13')

if len(ans) != 0:
    print('\n'.join(ans))

Submission status: Accepted

Solution code:
#2020-03-19
cards = [['no' for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]

n =  int(input())
num = 0
for t in range(n):
    mark,number = input().split()
    if mark == 'S':
        num = 0
    elif mark == 'H':
        num = 1
    elif mark == 'C':
        num = 2
    elif mark == 'D':
        num = 3

    cards[num][int(number) - 1] = 'yes'

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

Submission status: Accepted

Solution code:
def make_dict_trump():
    t = {}
    for i in range(13):
        t[i+1] = 0
    return t

S = make_dict_trump()
H = make_dict_trump()
C = make_dict_trump()
D = make_dict_trump()

def countup_trump(trump, number):
    trump[number] += 1
    return trump

n = int(input())

for i in range(n):
    kind, number = input().split()
    number = int(number)
    if kind=="S":
        S = countup_trump(S, number)
    elif kind=="H":
        H = countup_trump(H, number)
    elif kind=="C":
        C = countup_trump(C, number)
    elif kind=="D":
        D = countup_trump(D, number)

def output(kind, trump):
    keys = [k for k, v in trump.items() if v == 0]
    for key in keys:
        print(kind, key)

output("S", S)
output("H", H)
output("C", C)
output("D", D)

Submission status: Accepted

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

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

    cards[egara.index(a)][b - 1] = True
for i in range(4):
    for j in range(13):
        if (not cards[i][j]):
            print("{0} {1}".format(egara[i], j+1))

Submission status: Accepted

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

sr = set()
for _ in range(N):
    s, r = input().split()
    sr.add(s+r)
for m in M:
    for i in range(1, 14):
        mi = m+str(i)
        if mi not in sr:
            print(m, i)

Submission status: Accepted

Solution code:
n=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 i in range(n):
	x=input().split()
	if x[0]=='S':
		s.remove(int(x[1]))
	elif x[0]=='H':
		h.remove(int(x[1]))
	elif x[0]=='C':
		c.remove(int(x[1]))
	elif x[0]=='D':
		d.remove(int(x[1]))
s=sorted(s)
h=sorted(h)
c=sorted(c)
d=sorted(d)
for i in s:
	print('S',i)
for i in h:
	print('H',i)
for i in c:
	print('C',i)
for i in d:
	print('D',i)

Submission status: Accepted

Solution code:
cards =[]
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(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:
import bisect,collections,copy,itertools,math,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def SI(): return list(input().split())
##################################################
def main(N,C):
    SHCD = 'SHCD'
    _52card = [[0]*13 for _ in range(4)]
    for x in C:
        x1,x2 = x[0],int(x[1])
        _52card[SHCD.index(x1)][x2-1] = 1
    for i,x in enumerate(_52card):
        for j in range(13):
            if x[j]==0:
                print(SHCD[i],j+1)
    
N = I()
C = [SI() for _ in range(N)]
main(N,C)

Submission status: Accepted

Solution code:
d = {0:"S", 1:"H", 2:"C", 3:"D"}
l = [[0 for _ in range(13)]for _ in range(4)]
n = int(input())
for _ in range(n):
  m, i = input().split()
  i = int(i)
  if m == "S":
    l[0][i-1] = 1
  elif m == "H":
    l[1][i-1] = 1
  elif m == "C":
    l[2][i-1] = 1
  elif m == "D":
    l[3][i-1] = 1
for m in range(4):
  for n in range(13):
    if l[m][n] == 0:
      print("{} {}".format(d[m], n+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):
    lst = input().split()
    cards[pattern.index(lst[0])][int(lst[1]) - 1] = True

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

Submission status: Accepted

Solution code:
cards = list()
suit = ['S', 'H', 'C', 'D']
n = int(input())
for i in range(n):
    s, m = input().split()
    m = int(m)
    if s == "S":
        cards.append(0 + m)
    elif s == "H":
        cards.append(13 + m)
    elif s == "C":
        cards.append(26 + m)
    elif s == "D":
        cards.append(39 + m)
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:
def show_missing_card(suit, rank_exists):
    for i in range(13):
        if not rank_exists[i]:
            print('{suit} {rank}'.format(suit=suit, rank=(i + 1)))


spades = 'S'
hearts = 'H'
clubs = 'C'
diamonds = 'D'

trump_exists_map = {
    spades: [False] * 13,
    hearts: [False] * 13,
    clubs: [False] * 13,
    diamonds: [False] * 13
}

num_cards = int(input())

inputs = []

for i in range(num_cards):
    inputs.append(input())

for input_value in inputs:
    suit, rank = input_value.split()

    rank = int(rank)

    trump_exists_map[suit][rank - 1] = True

show_missing_card(spades, trump_exists_map[spades])
show_missing_card(hearts, trump_exists_map[hearts])
show_missing_card(clubs, trump_exists_map[clubs])
show_missing_card(diamonds, trump_exists_map[diamonds])

Submission status: Accepted

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

n = int(input())
for _ in range(n):
    c, rank = input().split()
    rank = int(rank)
    dec[pattern.index(c)][rank-1] = True

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

cnt = 0
while True:
    if cnt >= n:
        break
    a, b = input().split()
    for i in range(4):
        if a == pattern[i]:
            cards[i][int(b) - 1] = True
    cnt += 1

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:
def my_index_multi(l, x):
  return [i for i, _x in enumerate(l) if _x == x]

n = int(input())
cards = [list(input().split()) for i in range(n)]
heart  = [0] * 14
diamond  = [0] * 14
club  = [0] * 14
spade = [0] * 14
heart[0] = diamond[0] = club[0] = spade[0] = -1
ans = []
for card in cards:
  if card[0] == "H":
    heart[(int(card[1]))] += 1
  elif card[0] == "D":
    diamond[(int(card[1]))] += 1
  elif card[0] == "C":
    club[(int(card[1]))] += 1
  elif card[0] == "S":
    spade[(int(card[1]))] += 1
for s in my_index_multi(spade, 0):
  ans += [["S", s]]
for h in my_index_multi(heart, 0):
  ans += [["H", h]]
for c in my_index_multi(club, 0):
  ans += [["C", c]]
for d in my_index_multi(diamond, 0):
  ans += [["D", d]]
for j in ans:
  print("{} {}".format(j[0], j[1]))

Submission status: Accepted

Solution code:
# 不足しているカードの発見

# input process
n = int(input())

# initialization
card_list = {}
card_type = ['S', 'H', 'C', 'D']
for c in card_type:
    card_list[c] = [0]*13

# remove process
for i in range(n):
    t, n = input().split()
    n = int(n)
    card_list[t][n-1] = 1

# output process
for c in card_list:
    for i in range(len(card_list[c])):
        if card_list[c][i]==0:
            print("%s %d"%(c, i+1))

Submission status: Accepted

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

n = int(input())
for i in range(n):
    g, t = map(str, input().split())
    if g == "S":
        s[int(t) - 1] = True
    elif g == "H":
        h[int(t) - 1] = True
    elif g == "C":
        c[int(t) - 1] = True
    elif g == "D":
        d[int(t) - 1] = True

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

Submission status: Accepted

Solution code:
n = int(input()) # 最初のカードの枚数
Scards = [] # 空のリスト  # appendメソッドで追加  
Hcards = [] # 空のリスト  # appendメソッドで追加  
Ccards = [] # 空のリスト  # appendメソッドで追加  
Dcards = [] # 空のリスト  # appendメソッドで追加  

for i in range(n):
    s,r = input().split() # n組の有るカード
    r = int(r)
    if s == 'S':
        Scards.append(r)
    elif s == 'H':
        Hcards.append(r)
    elif s == 'C':
        Ccards.append(r)
    elif s == 'D':
        Dcards.append(r)

for i in range(1,14):
    if not (i in Scards):
        print('S', i)
for i in range(1,14):
    if not (i in Hcards):
        print('H', i)
for i in range(1,14):
    if not (i in Ccards):
        print('C', i)
for i in range(1,14):
    if not (i in Dcards):
        print('D', 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):
    x, y = input().split()
    if x == "S":
        S[int(y)-1] = 1
    elif x == "H":
        H[int(y)-1] = 1
    elif x == "C":
        C[int(y)-1] = 1
    elif x == "D":
        D[int(y)-1] = 1
    else:
        pass

for m, val in enumerate(S):
    if val == 0:
        print("S", m+1)
for j, val in enumerate(H):
    if val == 0:
        print("H", j+1)
for k, val in enumerate(C):
    if val == 0:
        print("C", k+1)
for l, val in enumerate(D):
    if val == 0:
        print("D", l+1)

Submission status: Accepted

Solution code:
n = int(input())
n <= 52

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]


for i in range(n):
    x, y = input().split()
    if x == "S":
        S[int(y)-1] = 1
    elif x == "H":
        H[int(y)-1] = 1
    elif x == "C":
        C[int(y)-1] = 1
    elif x == "D":
        D[int(y)-1] = 1
    else:
        pass

for m, val in enumerate(S):
    if val == 0:
        print("S", m+1)
for j, val in enumerate(H):
    if val == 0:
        print("H", j+1)
for k, val in enumerate(C):
    if val == 0:
        print("C", k+1)
for l, val in enumerate(D):
    if val == 0:
        print("D", l+1)

Submission status: Accepted

Solution code:
pattern = ["S", "H", "C", "D"]
n = int(input())
cards = []
for i in range(n):
    x,y = input().split()
    cards.append(pattern.index(x) * 13 + int(y))
for i in range(1,53):
    if not (i in cards):
        print(pattern[(i - 1) // 13] + " " + str((i - 1)  % 13 + 1))

Submission status: Accepted

Solution code:
n = int(input())

cards = []
v = ["S", "H", "C", "D"]
number = list(range(1,14))

for i in v:
    for num in number:
        cards.append("{} {}".format(i, num))

my_cards = []
if n == 52:
    exit(0)
    
for i in range(n):
    my_cards.append(input())

# https://qiita.com/Toitu_Prince/items/222b50594b4bb7b189ee
result = [i for i in cards if i not in my_cards]
print("\n".join(map(str, result)))

Submission status: Accepted

Solution code:
import sys

def sa(Type= int):
  return [Type(x) for x in input().split()]

def solve():
  seen = set()
  n = int(input())

  for _ in range(n):
    line = input()
    seen.add(line)

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

  for t in types:
    for i in range(1, 14):
      card = '{} {}'.format(t, i)
      if card not in seen:
        print(card)



if __name__ == '__main__':
  # sys.stdin = open('input.txt', 'r')
  solve()

Submission status: Accepted

Solution code:
suit = ["S", "H", "C", "D"]
fig = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
trump = []
for j in range(4):
    for k in range(13):
        trump.append(suit[j]+" "+str(fig[k]))

taro = []        
n = int(input())
for i in range(n):
    taro.append(input())

for m in range(52):
    if trump[m] not in taro:
        print(trump[m])

Submission status: Accepted

Solution code:
cards = []
for a in range(1,14):
    cards += ["S "+str(a), "H "+str(a), "C "+str(a), "D "+str(a)]
n = int(input())
for a in range(n):
    cards.remove(input())
order = ["S","H","C","D"]
cards.sort(key = lambda x: order.index(x[0]))
if len(cards) != 0:
    print("\n".join(cards))

Submission status: Accepted

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

for i in range(n):
    SHCD,NUMBER = map(str,input().split())
    if SHCD == "S":
        a[0][int(NUMBER)-1] = True
    if SHCD == "H":
        a[1][int(NUMBER)-1] = True
    if SHCD == "C":
        a[2][int(NUMBER)-1] = True
    if SHCD == "D":
        a[3][int(NUMBER)-1] = True

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

Submission status: Accepted

Solution code:
a = int(input())
card = [input() for i in range(a)]
allcard = ["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 = [] 
for x in card:
    if x in allcard:
        allcard.remove(x)

for i in allcard:
    print(i)

Submission status: Accepted

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

for i in range(n):
    mark, num = input().split()
    mark = str(mark)
    num =int(num)
    if mark not in trump:
        trump[mark] = list()
    trump[mark].append(num)

for mark in trump:
    if mark == 'S':
        for i in range(1,14):
            if i not in trump[mark]:
                print(mark, i)

for mark in trump:
    if mark == 'H':
        for i in range(1,14):
            if i not in trump[mark]:
                print(mark, i)

for mark in trump:
    if mark == 'C':
        for i in range(1,14):
            if i not in trump[mark]:
                print(mark, i)

for mark in trump:
    if mark == 'D':
        for i in range(1,14):
            if i not in trump[mark]:
                print(mark, i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
count = int(input())
list = []
out_list = []

for i in range(count):
    e = input()
    list.append(e)
    
for s in range(1,14):
    a = "S "+ str(s)
    if (a in list) == False:
        out_list.append(a)
        
for h in range(1,14):
    a = "H "+ str(h)
    if (a in list) == False:
        out_list.append(a)
        
for c in range(1,14):
    a = "C "+ str(c)
    if (a in list) == False:
        out_list.append(a)
        
for d in range(1,14):
    a = "D "+ str(d)
    if (a in list) == False:
        out_list.append(a)
        
for i in range(len(out_list)):
    print(out_list[i])

Submission status: Accepted

Solution code:
n = int(input())

s = [-1]*14
h = [-1]*14
c = [-1]*14
d = [-1]*14

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

for i in range(1,14):
    if s[i]==-1:
        print("S " + str(i))

for i in range(1,14):
    if h[i]==-1:
        print("H " + str(i))

for i in range(1,14):
    if c[i]==-1:
        print("C " + str(i))

for i in range(1,14):
    if d[i]==-1:
        print("D " + str(i))

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())

lst_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']
lst_h = ['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']
lst_c = ['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']
lst_d = ['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']

lst_all = lst_s + lst_h + lst_c +lst_d

lst_ipt = []

for i in range (n):
     lst_ipt.append(input())

for j in range(n):
    lst_all.remove(lst_ipt[j])

for h in range(52-n):
    print(lst_all[h])

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(n):
    sc = input().split()
    if sc[0] == 'S':
        a.append(int(sc[1]) - 1)
    if sc[0] == 'H':
        a.append(12 + int(sc[1]))
    if sc[0] == 'C':
        a.append(25 + int(sc[1]))
    if sc[0] == 'D':
        a.append(38 + int(sc[1]))
a.sort()

for i in range(52):
    if not i in a:
        if i // 13 == 0:
            print('S', i % 13 + 1)
        if i // 13 == 1:
            print('H', i % 13 + 1)
        if i // 13 == 2:
            print('C', i % 13 + 1)
        if i // 13 == 3:
            print('D', i % 13 + 1)

Submission status: Accepted

Solution code:
n = int(input())
Cards = []
S = [0,1,2,3,4,5,6,7,8,9,10,11,12,13]
H = [0,1,2,3,4,5,6,7,8,9,10,11,12,13]
C = [0,1,2,3,4,5,6,7,8,9,10,11,12,13]
D = [0,1,2,3,4,5,6,7,8,9,10,11,12,13]
for i in range(n):
    Suit,Rank = map(str, input().split())
    Cards.append([Suit,Rank])
for j in range(len(Cards)):
    if Cards[j][0] == 'S':
        for k in range(1,13+1):
            if int(Cards[j][1]) == k:
                S[k] = 0
    elif Cards[j][0] == 'H':
        for k in range(1,13+1):
            if int(Cards[j][1]) == k:
                H[k] = 0
    elif Cards[j][0] == 'C':
        for k in range(1,13+1):
            if int(Cards[j][1]) == k:
                C[k] = 0
    elif Cards[j][0] == 'D':
        for k in range(1,13+1):
            if int(Cards[j][1]) == k:
                D[k] = 0
for a in S:
    if S[a] != 0:
        print('S',S[a])
for a in H:
    if H[a] != 0:
        print('H',H[a])
for a in C:
    if C[a] != 0:
        print('C',C[a])
for a in D:
    if D[a] != 0:
        print('D',D[a])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
l1=[]
for i in range(1,14):
    l1.append('S %d'%i)
for i in range(1,14):   
    l1.append('H %d'%i)
for i in range(1,14):
    l1.append('C %d'%i)
for i in range(1,14):
    l1.append('D %d'%i)

for i in range(1,n+1):
    s=str(input())
    if s in l1:
        l1.remove(s)

for i in l1:
    print(i)

Submission status: Accepted

Solution code:
import sys
# import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

tower = [[0] * 13 for i in range(4)]
Pattern = 'SHCD'
N = int(readline())
for _ in range(N):
    x = readline()
    P, num = x.split()[0].decode('utf8'), int(x.split()[1])
    tower[Pattern.index(P)][num - 1] += 1

for num, i in enumerate(tower):
    P = Pattern[num]
    for number,j in enumerate(i):
        if j == 0:
            print(P, number + 1)