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=['S','H','C','D']
C=[[0 for i in range(13)]for j in range(4)]

for i in range(n):
      ch,B=input().split()
      B=int(B)
      C[A.index(ch)][B-1]=1
for i in range(4):
    for j in range(13):
        if C[i][j]==0:
            print(A[i],j+1)

Submission status: Accepted

Solution code:
n=int(input())
suits=["S","H","C","D"]
cards=[]
for t in range(n):
    s,t=input().split()
    if s=="S":
        cards.append(int(t))  
    elif s=="H":
        cards.append(13+int(t))
    elif s=="C":
        cards.append(26+int(t))
    else:
        cards.append(39+int(t))

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

Submission status: Accepted

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

c=int(input())
for i in range(0,c):
    m,r=input().split()
    r=int(r)
    if m=="S":
        S.remove(r)
    elif m=="H":
        H.remove(r)
    elif m=="C":
        C.remove(r)
    elif m=="D":
        D.remove(r)

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:
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:
# coding: utf-8
# Your code here!
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:
cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]
n = int(input())
for k in range(n):
    mark, num = input().split()
    num = int(num)
    cards[pattern.index(mark)][num-1] = True
for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i], end=" ")
            print(j+1)

Submission status: Accepted

Solution code:
n = int(input());

S = [];
H = [];
C = [];
D = [];
for i in range(0,n):
    a = list(map(str, input().split()));
    if a[0] == 'S':
        S.append(a[1]);
    if a[0] == 'H':
        H.append(a[1]);
    if a[0] == 'C':
        C.append(a[1]);
    if a[0] == 'D':
        D.append(a[1]);
s = [int(s) for s in S];
h = [int(s) for s in H];
c = [int(s) for s in C];
d = [int(s) for s in D];

s.sort();
h.sort();
c.sort();
d.sort();
s.append(0);
h.append(0);
c.append(0);
d.append(0);

q = 0;
for j in range(1,14):
    if s[q] != j:
        print('S', j);
    if s[q] == j:
        q += 1;
    
q = 0;
for k in range(1,14):
    if h[q] != k:
        print('H', k);
    if h[q] == k:
        q += 1;
    
q = 0;
for m in range(1,14):
    if c[q] != m:
        print('C', m);
    if c[q] == m:
        q += 1;
    
q = 0;
for o in range(1,14):
    if d[q] != o:
        print('D', o);
    if d[q] == o:
        q += 1;

Submission status: Accepted

Solution code:
n = int(input())

S = [i for i in range(1, 14)]
H = [i for i in range(1, 14)]
C = [i for i in range(1, 14)]
D = [i for i in range(1, 14)]

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

Submission status: Accepted

Solution code:
S=[]
H=[]
C=[]
D=[]
count=0
for i in range(1,14):
    S.append(i)
    H.append(i)
    C.append(i)
    D.append(i)

n=(int)(input())
while True:
    if count==n:
        break
    k,num=(input().split())
    num=int(num)
    if k=='S':
        S.remove(num)
    elif k=='H':
        H.remove(num)
    elif k=='C':
        C.remove(num)
    elif k=='D':
        D.remove(num)
    count=count+1

if len(S)!=0:
    for j in range(len(S)):
        print("S {0}".format(S[j]))
if len(H)!=0:
    for j in range(len(H)):
        print("H {0}".format(H[j]))
if len(C)!=0:
    for j in range(len(C)):
        print("C {0}".format(C[j]))
if len(D)!=0:
    for j in range(len(D)):
        print("D {0}".format(D[j]))

Submission status: Accepted

Solution code:
n = int(input())

S = [i for i in range(1, 14)]
H = [i for i in range(1, 14)]
C = [i for i in range(1, 14)]
D = [i for i in range(1, 14)]

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

Submission status: Accepted

Solution code:
n=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(n):
    nyuuryoku=list(input())
    egara=nyuuryoku[0]
    if len(nyuuryoku)==4:
        suuji=nyuuryoku[2]+nyuuryoku[3]
    else:
        suuji=nyuuryoku[2]
    if egara=='S':
        for i in s:
            if int(suuji)==i:
                s.remove(i)
    if egara=='H':
        for i in h:
            if int(suuji)==i:
                h.remove(i) 
    if egara=='C':
        for i in c:
            if int(suuji)==i:
                c.remove(i) 
    if egara=='D':
        for i in d:
            if int(suuji)==i:
                d.remove(i) 
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())
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:
c=list(range(1,53))
n=int(input())
d=[]
for i in range(n):
    a,b=input().split()
    b=int(b)
    if a=="S":
        d.append(b)
    elif a=="H":
        d.append(b+13)
    elif a=="C":
        d.append(b+26)
    else:
        d.append(b+39)
        
for i in range(52):
    
    if c[i] in d:
        continue
    else:
        if c[i]<=13:
            print('S {}'.format(c[i]))
        elif c[i]<=26:
            print('H {}'.format(c[i]-13))
        elif c[i]<=39:
            print('C {}'.format(c[i]-26))
        else:
            print('D {}'.format(c[i]-39))

Submission status: Accepted

Solution code:
import itertools
n = int(input())
mark = ['S', 'H', 'C', 'D']
nums = [str(i) for i in range(1, 14)]
cards = []

for i in mark:
    for j in nums:
        cards.append("{0} {1}".format(i, j))


for i in range(1, n+1):
    pair = input()
    cards.remove(pair)


for i in cards:
    print(i)

Submission status: Accepted

Solution code:
cards=[]
for i in ["S","H","C","D"]:
    for j in range(13):
        cards.append("{0} {1}".format(i,j+1))


n = int(input())
array=[]
for i in range(n):
    array.append(input())
#print(array[1~~~][1or0])

for j in range(n):
   cards.remove(array[j])

for l in range(len(cards)):
    print(cards[l])

Submission status: Accepted

Solution code:
n=int(input())
S=[0]*14
H=[0]*14
C=[0]*14
D=[0]*14
for i in range(n):
    a=input().split()
    b=int(a[1])
    if a[0]=="S":
        S[b]=1
    if a[0]=="H":
        H[b]=1
    if a[0]=="C":
        C[b]=1
    if a[0]=="D":
        D[b]=1
for i in range(1,14):
    if S[i]==0:
        print("S "+str(i))
for i in range(1,14):
    if H[i]==0:
        print("H "+str(i))
for i in range(1,14):
    if C[i]==0:
        print("C "+str(i))
for i in range(1,14):
    if D[i]==0:
        print("D "+str(i))

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):
    suit, num = input().split()
    if suit == 'S':
        cards[0][int(num)-1] = 0
    elif suit == 'H':
        cards[1][int(num)-1] = 0
    elif suit == 'C':
        cards[2][int(num)-1] = 0
    elif suit == 'D':
        cards[3][int(num)-1] = 0
for s in cards:
    for n in s:
        if n != 0:
            print(n)

Submission status: Accepted

Solution code:
n=int(input())
H=[]
S=[]
C=[]
D=[]
list=[]
cards=[0]*52
cards=[]
for i in range(n):
    n,a=input().split()
    a=int(a)
    if n=="S":
        S.append(a)
    elif n=="H":
        H.append(a)
    elif n=="C":
        C.append(a)
    else:
        D.append(a)
for i in range(1,14):
    if i in S:
        x=0
    else:
        print("S",i)
for i in range(1,14):
    if i in H:
        x=0
    else:
        print("H",i)
for i in range(1,14):
    if i in C:
        x=0
    else:
        print("C",i)
for i in range(1,14):
    if i in D:
        x=0
    else:
        print("D",i)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

n=int(input())
a=list()
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))
        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:
My_s=[]
My_h=[]
My_c=[]
My_d=[]
s=[]
h=[]
c=[]
d=[]
for i in range(int(input())):
    x=input().split()
    if x[0]=='S':
        My_s.append(int(x[1]))
    elif x[0]=='H':
        My_h.append(int(x[1]))
    elif x[0]=='C':
        My_c.append(int(x[1]))
    elif x[0]=='D':
        My_d.append(int(x[1]))

for i in range(1,14):
    if i not in My_s:
        s.append(str(i))
    if i not in My_h:
        h.append(str(i))
    if i not in My_c:
        c.append(str(i))
    if i not in My_d:
        d.append(str(i))
for w in s:
    print('S '+w)
for w in h:
    print('H '+w)
for w in c:
    print('C '+w)
for w in d:
    print('D '+w)

Submission status: Accepted

Solution code:
S,H,C,D = 0,1,2,3
table = [[0 for _ in range(14)] for _ in range(4)]

n = int(input())
for _ in range(n):
    a,b = input().split()
    table[eval(a)][int(b)] = 1

for i in ['S','H','C','D']:
    for j in range(1,14):
        if table[eval(i)][j] == 0:
            print(i,j)

Submission status: Accepted

Solution code:
used = [[False for i in range(13)] for i in range(4)]
mark = ["S", "H", "C", "D"]
n = int(input())
for i in range(n):
    row = input().split()
    m = row[0]
    j = int(row[1])
    used[mark.index(m)][j - 1] = True
    
for i in range(4):
    for j in range(13):
        if used[i][j] == False:
            print(mark[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))
	elif a == "H":
		H.append(int(b))
	elif a == "C":
		C.append(int(b))
	else:
		D.append(int(b))
for s in range(13):
	if s+1 not in S:
		print("S",(s+1))
for h in range(13):
	if h+1 not in H:
		print("H",(h+1))
for c in range(13):
	if c+1 not in C:
		print("C",(c+1))
for d in range(13):
	if d+1 not in D:
		print("D",(d+1))

Submission status: Accepted

Solution code:
Sc = [0]*13
Hc = [0]*13
Cc = [0]*13
Dc = [0]*13
x = int(input())
for i in range(x):
  a,b = map(str, input().split())
  if a == "S":
    Sc[int(b)-1] = 1
  elif a == "H":
    Hc[int(b)-1] = 1
  elif a == "C":
    Cc[int(b)-1] = 1
  else:
    Dc[int(b)-1] = 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
X = [[0] * 13 for i in range(4)]
table = {'S': 0, 'H': 1, 'C': 2, 'D': 3}
for i in range(n):
    pattern, num = input().split()
    num = int(num) - 1
    X[table[pattern]][num] = 1

table = {0: 'S', 1: 'H', 2: 'C', 3: 'D'}
for i in range(4):
    for j in range(13):
        if X[i][j] == 0:
            print('{} {}'.format(table[i], j + 1))

Submission status: Accepted

Solution code:
n=int(input())
count=0
lst=[]
while count<n:
    value=input().split()
    for i in value:
        if i.isdecimal():
            lst.append(int(i))
            continue
        lst.append(i)
    count+=1
S_lst=[]
H_lst=[]
C_lst=[]
D_lst=[]
for s in range(2*n):
    if lst[s]=='S':
        S_lst.append(lst[s])
        S_lst.append(lst[s+1])
for h in range(2*n):
    if lst[h]=='H':
        H_lst.append(lst[h])
        H_lst.append(lst[h+1])
for c in range(2*n):
    if lst[c]=='C':
        C_lst.append(lst[c])
        C_lst.append(lst[c+1])
for d in range(2*n):
    if lst[d]=='D':
        D_lst.append(lst[d])
        D_lst.append(lst[d+1])
if 1 not in S_lst:
    print('S',1)
if 2 not in S_lst:
    print('S',2)
if 3 not in S_lst:
    print('S',3)
if 4 not in S_lst:
    print('S',4)
if 5 not in S_lst:
    print('S',5)
if 6 not in S_lst:
    print('S',6)
if 7 not in S_lst:
    print('S',7)
if 8 not in S_lst:
    print('S',8)
if 9 not in S_lst:
    print('S',9)
if 10 not in S_lst:
    print('S',10)
if 11 not in S_lst:
    print('S',11)
if 12 not in S_lst:
    print('S',12)
if 13 not in S_lst:
    print('S',13)
if 1 not in H_lst:
    print('H',1)
if 2 not in H_lst:
    print('H',2)
if 3 not in H_lst:
    print('H',3)
if 4 not in H_lst:
    print('H',4)
if 5 not in H_lst:
    print('H',5)
if 6 not in H_lst:
    print('H',6)
if 7 not in H_lst:
    print('H',7)
if 8 not in H_lst:
    print('H',8)
if 9 not in H_lst:
    print('H',9)
if 10 not in H_lst:
    print('H',10)
if 11 not in H_lst:
    print('H',11)
if 12 not in H_lst:
    print('H',12)
if 13 not in H_lst:
    print('H',13)
if 1 not in C_lst:
    print('C',1)
if 2 not in C_lst:
    print('C',2)
if 3 not in C_lst:
    print('C',3)
if 4 not in C_lst:
    print('C',4)
if 5 not in C_lst:
    print('C',5)
if 6 not in C_lst:
    print('C',6)
if 7 not in C_lst:
    print('C',7)
if 8 not in C_lst:
    print('C',8)
if 9 not in C_lst:
    print('C',9)
if 10 not in C_lst:
    print('C',10)
if 11 not in C_lst:
    print('C',11)
if 12 not in C_lst:
    print('C',12)
if 13 not in C_lst:
    print('C',13)
if 1 not in D_lst:
    print('D',1)
if 2 not in D_lst:
    print('D',2)
if 3 not in D_lst:
    print('D',3)
if 4 not in D_lst:
    print('D',4)
if 5 not in D_lst:
    print('D',5)
if 6 not in D_lst:
    print('D',6)
if 7 not in D_lst:
    print('D',7)
if 8 not in D_lst:
    print('D',8)
if 9 not in D_lst:
    print('D',9)
if 10 not in D_lst:
    print('D',10)
if 11 not in D_lst:
    print('D',11)
if 12 not in D_lst:
    print('D',12)
if 13 not in D_lst:
    print('D',13)

Submission status: Accepted

Solution code:
def show_lost_card(cards,mark):
    i = 1
    for num in range(13):
        if i in cards:
            i += 1
        else:
            print(mark,i)
            i += 1
    
N = int(input())
S = []
H = []
C = []
D = []

for n in range(N):
    card = input().split()
    if card[0] == 'S':
        S.append(int(card[1]))
    elif card[0] == 'H':
        H.append(int(card[1]))
    elif card[0] == 'C':
        C.append(int(card[1]))
    else:
        D.append(int(card[1]))

show_lost_card(S,'S')
show_lost_card(H,'H')
show_lost_card(C,'C')
show_lost_card(D,'D')

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

ct = int(input())
card_list = [False for x in range(1,54)]

# 絵柄を数字に変換
def mark_num(m):
    if m == "S":
        return 0
    elif m == "H":
        return 13
    elif m == "C":
        return 26
    elif m == "D":
        return 39

def num_mark(n):
    ret = n % 13
    if ret == 0:
        ret = 13

    if n <= 13:
        return "S " + str(n)
    elif n <= 26:
        return "H " + str(ret)
    elif n <= 39:
        return "C " + str(ret)
    else:
        return "D " + str(ret)


for i in range(ct):
    mark,num = map(str,input().split())
    num = int(num)
    card_list[mark_num(mark) + num] = True
    
for i in range(1,53):
    if card_list[i] == False:
        print(num_mark(i))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
s=[0 for _ in range(52)]
M=["S","H","C","D"]
for _ in range(n):
    a,b=map(str,input().split())
    if a==M[0]:
        a=0
    elif a==M[1]:
        a=1
    elif a==M[2]:
        a=2
    else:
        a=3
    s[13*a+int(b)-1]=1

for i in range(len(s)):
    if s[i]==0:
        print("{} {}".format(M[i//13],i%13+1))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

n = int(input())

S = [i for i in range(1, 14)]
H = [i for i in range(1, 14)]
C = [i for i in range(1, 14)]
D = [i for i in range(1, 14)]

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

Submission status: Accepted

Solution code:
text={'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]}
lim=int(input())
j=1
while(j<=lim):
  p=input().split(" ")  
  i=0
  for key in text:
      
      if key==p[i]:
          for k in range(13):
              if int(p[i+1])==text[key][k]:
                  del text[key][k]
                  break
  j+=1
for e in [k for k,v in text.items() if len(v) == 0]: text.pop(e)
for key in text:
    for t in range(0,len(text[key]),1):
        print(key,text[key][t])

Submission status: Accepted

Solution code:
n = int(input())
a= []
result = []
for i in range(0,n):
	a.append(list(input().split()))
#print(n)
#print(a)

for j in ('S','H','C','D'):
	for k in range(1,14):
		if [j, str(k)] not in a:
			result.append([j, str(k)])

for l in result:
	print('{0} {1}'.format(l[0], l[1]))

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

Solution code:
n=int(input())
H=[]
S=[]
C=[]
D=[]
list=[]
cards=[0]*52
cards=[]
for i in range(n):
    n,a=input().split()
    a=int(a)
    if n=="S":
        S.append(a)
    elif n=="H":
        H.append(a)
    elif n=="C":
        C.append(a)
    else:
        D.append(a)
for i in range(1,14):
    if i in S:
        x=0
    else:
        print("S",i)
for i in range(1,14):
    if i in H:
        x=0
    else:
        print("H",i)
for i in range(1,14):
    if i in C:
        x=0
    else:
        print("C",i)
for i in range(1,14):
    if i in D:
        x=0
    else:
        print("D",i)

Submission status: Accepted

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

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:
N = int(input())
tbl = [[0 for i in range(13)] for j in range(4)]
suit_pattern = ["S","H","C","D"]

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

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

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:
from collections import OrderedDict

#カードを初期値をFalseとして全てリストに収納する
cards = OrderedDict()
pattern = ['S', 'H', 'C', 'D']
for cha in pattern:
    for num in range(1, 14):
        key = f'{cha} {num}'
        cards[key]= False
#標準入力を受け取る
n = int(input())
for i in range(n):
    i = input()
    #入力されたカードの真理値を反転させる
    cards[i] = not(cards[i])
    
#入力されていないカードは真理値がFalseであるので
for result , cards_bool in cards.items():
    if not cards_bool:
        print(result)

Submission status: Accepted

Solution code:
n = int(input())
l = [[False] * 13 for i in range(4)]
shcd = ["S", "H", "C", "D"]
for i in range(n):
    x, y = input().split()
    l[shcd.index(x)][int(y) - 1] = True
for i in range(4):
    for j in range(13):
        if not l[i][j]:
            print(shcd[i], j + 1)

Submission status: Accepted

Solution code:
n = int(input())
S = []
H = []
C = []
D = []
for i in range(n):
    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 i in range(1, 14):
    if not i in S:
        print('S',i)
for i in range(1,14):
    if not i in H:
        print('H',i)  
for i in range(1,14):
    if not i in C:
        print('C',i)
for i in range(1, 14):
    if not i in D:
        print('D',i)

Submission status: Accepted

Solution code:
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())
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:
'import sys'
c={
    'S':[0]*13,
    'H':[0]*13,
    'C':[0]*13,
    'D':[0]*13
}
n=int(input())
for i in range(n):
    s,num=input().split()
    c[s][int(num)-1]=1
for i in["S","H","C","D"]:
    for j in range(13):
        if c[i][j]==0:
            print(i,j+1)

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
ml = ['S', 'H', 'C', 'D']
s = [[i+1 for i in range(13)] for i in range(4)]
while cnt < n: 
    M, N = list(input().split())
    N = int(N)
    if M == ml[0]:
        s[0][N-1] = False
    elif M == ml[1]:
        s[1][N-1] = False
    elif M == ml[2]:
        s[2][N-1] = False
    elif M == ml[3]:
        s[3][N-1] = False
    cnt += 1
for i in range(len(ml)):
    for j in range(len(s[i])):
        if s[i][j] != False:
            print('{} {}'.format(ml[i], s[i][j]))

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 _ 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:
n = int(input())
cards = [[ s+' '+str(n) for n in range(1,14)] for s in ['S','H','C','D']]
#リストcardsの要素｢s n｣の形
#sにはS,H,C,D、nには1~13の値を入れる
for i in range(n):
    a , num = input().split()
    if a == 'S':
        cards[0][int(num)-1] = 0
    elif a == 'H':
        cards[1][int(num)-1] = 0
    elif a == 'C':
        cards[2][int(num)-1] = 0
    elif a == 'D':
        cards[3][int(num)-1] = 0
for s in cards:
    for n in s:
        if n != 0:
            print(n)

Submission status: Accepted

Solution code:
n = int(input())
a = list()
for i in range(n):
  x, y = input().split()
  y = int(y)
  if x == "S":
    a.append(y + 0)
  elif x =="H":
    a.append(y + 13)
  elif x == "C":
    a.append(y + 26)
  else:
    a.append(y + 39)

for i in range(1,53):
  if not (i in a):
    if i <= 13:
      print("S", i - 0)
    elif i <= 26:
      print("H", i - 13)
    elif i <= 39:
      print("C", i - 26)
    elif i <= 52:
      print("D", i - 39)

Submission status: Accepted

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

for i in range (n):
    p,f=input().split()
    #picture, figure
    if p=="S":
        p=0
    elif p=="H":
        p=1
    elif p=="C":
        p=2
    elif p=="D":
        p=3
    table[int(p)][int(f)-1]=1

j=0
for i in range (13):
    if table[0][j]==0:
        print("S "+str(j+1))
        j=j+1
    else:
        j=j+1
j=0
for i in range (13):
    if table[1][j]==0:
        print("H "+str(j+1))
        j=j+1
    else:
        j=j+1
j=0
for i in range (13):
    if table[2][j]==0:
        print("C "+str(j+1))
        j=j+1
    else:
        j=j+1
j=0
for i in range (13):
    if table[3][j]==0:
        print("D "+str(j+1))
        j=j+1
    else:
        j=j+1

Submission status: Accepted

Solution code:
c = {
    'S':[0]*13,
    'H':[0]*13,
    'C':[0]*13,
    'D':[0]*13
}

n = int(input())
for i in range(n):
    pic,number = input().split()
    c[pic][int(number)-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())
ans_len = 52 - n
ans = []
for i in range(4):
    for j in range(1,14):
        if i == 0:
            l = "S"
        elif i == 1:
            l = "H"
        elif i == 2:
            l = "C"
        elif i == 3:
            l = "D"
        q = "{} {}".format(l,j)
        ans.append(q)

for i in range(n):
    it = input()
    ans.pop(ans.index(it))
        
for i in range(ans_len):
    print(ans[i])