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: Wrong Answer

Solution code:
{
   "source": [
    "d = {\"S\":[1,2,3,4,5,6,7,8,9,10,11,12,13],\n",
    "     \"H\":[1,2,3,4,5,6,7,8,9,10,11,12,13],\n",
    "     \"D\":[1,2,3,4,5,6,7,8,9,10,11,12,13],\n",
    "     \"C\":[1,2,3,4,5,6,7,8,9,10,11,12,13]}\n",
    "n = int(input())\n",
    "for i in range(n):\n",
    "    N, M = map(str,input().split())\n",
    "    d[N][int(M)-1] =\"None\"\n",
    "print(\"Answer\")\n",
    "for j in range(len(d)):\n",
    "    if j==1:\n",
    "        list_d = d[\"S\"]\n",
    "        c = \"S\"\n",
    "    elif j == 2:\n",
    "        list_d = d[\"H\"]\n",
    "        c = \"H\"\n",
    "    elif j == 3:\n",
    "        list_d = d[\"C\"]\n",
    "        c = \"C\"\n",
    "    else:\n",
    "        list_d = d[\"D\"]\n",
    "        c = \"D\"\n",
    "    for i in range(len(list_d)):\n",
    "        if(list_d[i] != \"None\"):\n",
    "            print(c , list_d[i])"
   ]
}

Submission status: Wrong Answer

Solution code:
d = {"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],
     "D":[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]}
n = int(input())
for i in range(n):
    N, M = map(str,input().split())
    d[N][int(M)-1] ="None"
print("Answer")
for j in range(len(d)):
    if j==1:
        list_d = d["S"]
        c = "S"
    elif j == 2:
        list_d = d["H"]
        c = "H"
    elif j == 3:
        list_d = d["C"]
        c = "C"
    else:
        list_d = d["D"]
        c = "D"
    for i in range(len(list_d)):
        if(list_d[i] != "None"):
            print(c , list_d[i])

Submission status: Wrong Answer

Solution code:
d = {"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],
     "D":[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]}
n = int(input())
for i in range(n):
    N, M = map(str,input().split())
    d[N][int(M)-1] ="None"

for j in range(len(d)):
    if j==1:
        list_d = d["S"]
        c = "S"
    elif j == 2:
        list_d = d["H"]
        c = "H"
    elif j == 3:
        list_d = d["C"]
        c = "C"
    else:
        list_d = d["D"]
        c = "D"
    for i in range(len(list_d)):
        if(list_d[i] != "None"):
            print(c , list_d[i])

Submission status: Wrong Answer

Solution code:
d = {"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],
     "D":[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]}
n = int(input())
for i in range(n):
    N, M = map(str,input().split())
    d[N][int(M)-1] ="None"

for j in range(len(d)):
    if j==1:
        list_d = d["S"]
        c = "S"
    elif j == 2:
        list_d = d["H"]
        c = "H"
    elif j == 3:
        list_d = d["D"]
        c = "D"
    else:
        list_d = d["C"]
        c = "C"
    for i in range(len(list_d)):
        if(list_d[i] != "None"):
            print(c , list_d[i])

Submission status: Wrong Answer

Solution code:
d = {"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],
     "D":[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]}
n = int(input())
for i in range(n):
    N, M = map(str,input().split())
    d[N][int(M)-1] ="None"
for j in range(len(d)):
    if j==1:
        list_d = d["S"]
        c = "S"
    elif j == 2:
        list_d = d["H"]
        c = "H"
    elif j == 3:
        list_d = d["D"]
        c = "D"
    else:
        list_d = d["C"]
        c = "C"
    for i in range(len(list_d)):
        if(list_d[i] != "None"):
            print(c , list_d[i])

Submission status: Wrong Answer

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

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

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

for j in range(n):
    x = list(input().split())
    if x[0] is 'S':
        s.remove(int(x[1]))
    elif x[0] is 'H':
        h.remove(int(x[1]))
    elif x[0] is 'C':
        c.remove(int(x[1]))
    elif x[0] is 'D':
        d.remove(int(x[1]))

while len(s) != 0:
    for i in range(len(s)):
        print('{0} {1}'.format(s[0], s[1]))
    break

while len(h) != 0:
    for i in range(len(h)):
        print('{0} {1}'.format(h[0], h[1]))
    break

while len(c) != 0:
    for i in range(len(c)):
        print('{0} {1}'.format(c[0], c[1]))
    break

while len(d) != 0:
    for i in range(len(d)):
        print('{0} {1}'.format(d[0], d[1]))
    break

Submission status: Wrong Answer

Solution code:
from collections import OrderedDict as od
a = {n for n in range(1,14)}
dic = od({"S":[],"H":[], "C":[], "D":[]})
N = int(input())
for n in range(N):
    card, num = tuple(input().split())
    dic[card].append(int(num))

dic["S"] = list(a - set(dic["S"]))
dic["H"] = list(a - set(dic["H"]))
dic["C"] = list(a - set(dic["C"]))
dic["D"] = list(a - set(dic["D"]))

for card,num in dic.items():
    for n in num:
        print("{0} {1}".format(card,n))

Submission status: Wrong Answer

Solution code:
from collections import OrderedDict as od
a = {n for n in range(1,14)}
dic = od({"S":[],"H":[], "C":[], "D":[]})
N = int(input())
for n in range(N):
    card, num = tuple(input().split())
    dic[card].append(int(num))

dic["S"] = list(a - set(dic["S"]))
dic["H"] = list(a - set(dic["H"]))
dic["C"] = list(a - set(dic["C"]))
dic["D"] = list(a - set(dic["D"]))

for card,num in dic.items():
    for n in num:
        print("{0} {1}".format(card,str(n)))

Submission status: Wrong Answer

Solution code:
N = int(input())
card = []
for x in range(52):
    card.append(0)
for x in range(N):
    a, b = map(str, input().split())
    if a == 'S':
        card[13 * 0 + int(b) - 1] = 1
    elif a == 'H':
        card[13 * 1 + int(b) - 1] = 1
    elif a == 'C':
        card[13 * 2 + int(b) - 1] = 1
    elif a == 'D':
        card[13 * 3 + int(b) - 1] = 1
for x in range(52):
    if card[x] == 0:
        if x < 13: print("S " + str(x + 1))
        elif x < 26: print("H " + str(( x + 1) % 13 ))
        elif x < 39: print("C " + str(( x + 1) % 26 ))
        else: print("D " + str(( x + 1) % 39))

Submission status: Wrong Answer

Solution code:
a = int(input())
cards = [[False for x in range(13)] for y in range(4)]
for i in range(a):
    s, v = map(str, input().split())
    u = int(v)
    if s == 'S':
        cards[0][u-1] = True
    elif s == 'H':
        cards[1][u-1] = True
    elif s == 'C':
        cards[2][u-1] = True
    else:
        cards[3][u-1] = True

for j in range(13):
    if cards[0][j]:
        continue
    else:
        print("S ", j+1)

for j in range(13):
    if cards[1][j]:
        continue
    else:
        print("H ", j+1)

for j in range(13):
    if cards[2][j]:
        continue
    else:
        print("D ", j+1)

for j in range(13):
    if cards[3][j]:
        continue
    else:
        print("C ", j+1)

Submission status: Wrong Answer

Solution code:
a = int(input())
cards = [[False for x in range(13)] for y in range(4)]
for i in range(a):
    s, v = map(str, input().split())
    u = int(v)
    if s == 'S':
        cards[0][u-1] = True
    elif s == 'H':
        cards[1][u-1] = True
    elif s == 'D':
        cards[2][u-1] = True
    elif s == 'C':
        cards[3][u-1] = True
    else:
        pass

for j in range(13):
    if cards[0][j]:
        continue
    else:
        print("S ", j+1)

for j in range(13):
    if cards[1][j]:
        continue
    else:
        print("H ", j+1)

for j in range(13):
    if cards[2][j]:
        continue
    else:
        print("D ", j+1)

for j in range(13):
    if cards[3][j]:
        continue
    else:
        print("C ", j+1)

Submission status: Wrong Answer

Solution code:
c=[f'{s} {i}'for s in'SHCD'for i in range(1,14)]
for _ in[0]*int(input()):c.remove(input())
for a in c:print(c)

Submission status: Wrong Answer

Solution code:
S = [0,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,0]
C = [0,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,0]
for i in range(int(input())):
	a,b = input().split()
	b = int(b) 
	if   a == 'S':
			S[b] = 1
	elif a == 'H' :
			H[b] = 1
	elif a == 'C':
			C[b] = 1
	elif a == 'D':
			D[b] = 1
for k in range(1,13):
	if not S[k] :
		print('S',k)
for k in range(1,13):
	if not H[k] :
		print('H',k)
for k in range(1,13):
	if not C[k] :
		print('C',k)
for k in range(1,13):
	if not D[k] :
		print('D',k)

Submission status: Wrong Answer

Solution code:
S = [0,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,0]
C = [0,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,0]
l=int(input())
for i in range(l):
	a,b = input().split()
	b = int(b) 
	if   a == 'S':
			S[b] = 1
	elif a == 'H' :
			H[b] = 1
	elif a == 'C':
			C[b] = 1
	elif a == 'D':
			D[b] = 1
for k in range(1,13):
	if not S[k] :
		print('S',k)
for k in range(1,13):
	if not H[k] :
		print('H',k)
for k in range(1,13):
	if not C[k] :
		print('C',k)
for k in range(1,13):
	if not D[k] :
		print('D',k)

Submission status: Wrong Answer

Solution code:
n=int(input())
x={0:'S',1:'H',2:'C',3:'D'}
c=[[0]*13,[0]*13,[0]*13,[0]*13]
for i in range(n):
    a,b=input().split()
    b=int(b)
    if a=='S':
        c[0].insert(b,b)
    elif a=='H':
        c[1].insert(b,b)
    elif a=='C':
        c[2].insert(b,b)
    else:
        c[3].insert(b,b)
for i in range(4):
    for j in range(13):
        if c[i][j]==0:
            print(x[i],j)

Submission status: Wrong Answer

Solution code:
n=int(input())
x={0:'S',1:'H',2:'C',3:'D'}
c=[[0]*13,[0]*13,[0]*13,[0]*13]
for i in range(n):
    a,b=input().split()
    b=int(b)
    if a=='S':
        c[0].insert(b,b)
    elif a=='H':
        c[1].insert(b,b)
    elif a=='C':
        c[2].insert(b,b)
    else:
        c[3].insert(b,b)
for i in range(4):
    for j in range(13):
        if c[i][j]==0:
            print(x[i],j+1)

Submission status: Wrong Answer

Solution code:
n=int(input())
x={0:'S',1:'H',2:'C',3:'D'}
c=[[0]*13,[0]*13,[0]*13,[0]*13]
for r in range(n):
    a,b=input().split()
    b=int(b)-1
    if a=='S':
        c[0][b]=b
    elif a=='H':
        c[1][b]=b
    elif a=='C':
        c[2][b]=b
    else:
        c[3][b]=b
for i in range(4):
    for j in range(13):
        if c[i][j]==0:
            print(x[i],j+1)

Submission status: Wrong Answer

Solution code:
def tonum(suit):
    if suit == 'S': return 0
    if suit == 'H': return 1
    if suit == 'C': return 2
    if suit == 'D': return 3
  
def tosuit(num):
    suits = ['S', 'H', 'C', 'D']
    return suits[num]
  
def main():
    n = int(input())
    cards = [i for i in range(52)]
    for i in range(n):
        a = input().split()
        cards.remove(tonum(a[0]) * 13 + int(a[1]))
    cards.reverse()
    for i in cards:
        print(tosuit(i // 13) + " " + str(i % 13))
  
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def tonum(suit):
    if suit == 'S': return 0
    if suit == 'H': return 1
    if suit == 'C': return 2
    if suit == 'D': return 3
   
def tosuit(num):
    suits = ['S', 'H', 'C', 'D']
    return suits[num]
   
def main():
    n = int(input())
    cards = [i for i in range(52)]
    for i in range(n):
        a = input().split()
        cards.remove(tonum(a[0]) * 13 + int(a[1]))
    cards.sort()
    for i in cards:
        print(tosuit(i // 13) + " " + str(i % 13))
   
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

all_card = {"S": [], "H": [], "C": [], "D": []}
number = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]

for k in n:
    all_card[k[0]].append(int(k[1]))

for c in ["S", "H", "C", "D"]:
    res = set(number) - set(all_card[c])
    for n in list(res):
        print("{} {}".format(c, n))

Submission status: Wrong Answer

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

all_card = {"S": [], "H": [], "C": [], "D": []}
number = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]

for k in n:
    all_card[k[0]].append(int(k[1]))

for c in ["S", "H", "C", "D"]:
    res = set(number) - set(all_card[c])
    for n in list(res):
        print("{} {}".format(c, n))

Submission status: Wrong Answer

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

all_card = {"S": [], "H": [], "C": [], "D": []}
number = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]

for k in n:
    all_card[k[0]].append(int(k[1]))

for c in ["S", "H", "C", "D"]:
    res = set(number) - set(all_card[c])
    for n in list(res):
        print(c, n)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [] #手持ちのカード
for i in range(n):
    x, y = input().split()
    a.append([x, y])

trump = [] #トランプ全体
for i in range(1,14):
    trump.append(['S', str(i)])
    trump.append(['H', str(i)])
    trump.append(['C', str(i)])
    trump.append(['D', str(i)])

miss = [] #不足カード
for i in range(len(trump)):
    for j in range(len(a)):
        if trump[i] != a[j]:
            miss.append(trump[i])
miss.sort() #並べ替え

for i in range(len(miss)):
    x = miss[i]
    if x[0] == "S":
        print(x[0] + ' '+ str(x[1]))
for i in range(len(miss)):
    x = miss[i]
    if x[0] == "H":
        print(x[0] + ' '+ str(x[1]))
for i in range(len(miss)):
    x = miss[i]
    if x[0] == "C":
        print(x[0] + ' '+ str(x[1]))
for i in range(len(miss)):
    x = miss[i]
    if x[0] == "D":
        print(x[0] + ' '+ str(x[1]))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [] #手持ちのカード
for i in range(n):
    x, y = input().split()
    a.append([x, y])

trump = [] #トランプ全体
for i in range(1,14):
    trump.append(['S', str(i)])
    trump.append(['H', str(i)])
    trump.append(['C', str(i)])
    trump.append(['D', str(i)])

#手持ちを引く #ここがわからん
dif = []
for i in range(len(trump)):
    for j in range(len(a)):
        if trump[i] != a[j]:
            dif.append(trump[i])

for i in range(len(dif)):
    x = dif[i]
    if x[0] == "S":
        print(x[0] +' '+ x[1])
for i in range(len(dif)):
    x = dif[i]
    if x[0] == "H":
        print(x[0] + ' '+ x[1])
for i in range(len(dif)):
    x = dif[i]
    if x[0] == "C":
        print(x[0] + ' '+ x[1])
for i in range(len(dif)):
    x = dif[i]
    if x[0] == "D":
        print(x[0] + ' '+ x[1])

Submission status: Wrong Answer

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

n = int(input())
bs = []
bh = []
bc = []
bd = []

for i in range(n):    
    a = input().split()
    if a[0] == 'S':
        bs.append(int(a[1]))  
    if a[0] == 'H':
        bh.append(int(a[1]))  
    if a[0] == 'C':
        bc.append(int(a[1]))  
    if a[0] == 'D':
        bd.append(int(a[1]))

for ks in range(1,13):
    if ks not in bs:
        print('S '+str(ks))

for kh in range(1,13):
    if kh not in bh:
        print('H '+str(kh))
        
for kc in range(1,13):
    if kc not in bc:
        print('C '+str(kc))
        
for kd in range(1,13):
    if kd not in bd:
        print('D '+str(kd))

Submission status: Wrong Answer

Solution code:
n = int(input())
cards = []
for i in range(1, n):
	s, r = input().split()
	cards.append((s, int(r)))
for s in "SHCD":
	for r in range(1, 14):
		if (s, r)not in cards:
			print(s, r)

Submission status: Wrong Answer

Solution code:
n=int(input())
S="SHCD"
A=[]
for i in range(4):
    B=[0 for i in range(13)]
    A.append(B)
print(A)
for i in range(n):
    a,b=[j for j in input().split()]
    b=int(b)
    b-=1
    if a=="S":
        a=0
    elif a=="H":
        a=1
    elif a=="C":
        a=2
    else: 
        a=3
    A[a][b]=1
for i in range(4):
    for j in range(13):
        if A[i][j]==0:
            print(S[i],end=" ")
            print(j+1)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    d = {"S":[None]*13, "H":[None]*13, "C":[None]*13, "D":[None]*13}

    for i in range(n):
        x, y = raw_input().split()
        d[x][int(y)-1] = True

    for k in d.keys():
        for i in d[k]:
            print("%s %d" % (k, i+1))

if __name__ == "main":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    d = {"S":[None]*13, "H":[None]*13, "C":[None]*13, "D":[None]*13}

    for i in range(n):
        x, y = raw_input().split()
        d[x][int(y)-1] = True

    for k in ["S", "H", "C", "D"]:
        for i in d[k]:
            print("%s %d" % (k, i+1))

if __name__ == "main":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    d = {"S":[None]*13, "H":[None]*13, "C":[None]*13, "D":[None]*13}

    for i in range(n):
        x, y = raw_input().split()
        d[x][int(y)-1] = True

    for k in ["S", "H", "C", "D"]:
        for i in d[k]:
            if d[k][i]:
                continue
            print("%s %d" % (k, i+1))

if __name__ == "main":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    d = {"S":[None]*13, "H":[None]*13, "C":[None]*13, "D":[None]*13}

    for i in range(n):
        x, y = raw_input().split()
        d[x][int(y)-1] = True

    for k in ["S", "H", "C", "D"]:
        for i in range(13):
            if d[k][i]:
                continue
            print("%s %d" % (k, i+1))

if __name__ == "main":
    main()

Submission status: Wrong Answer

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

n = input()
for i in range(n):
    s1, s2 = raw_input().split()
    s1 = 'SHCD'.index(s1)
    s2 = int(s2)-1
    print s1,s2
    cards[s1][s2] = 1

for j in r4:
    for i in r13:
        if cards[j][i]==0:
            print 'SHCD'[j],i+1

Submission status: Wrong Answer

Solution code:
n = input()
x = {'S':[], 'H':[], 'C':[], 'D':[]}
for i in range(n):
    a = raw_input().split()
    x[a[0]].append(int(a[1]))
for key in x.keys():
    for i in range(13):
        for j in x[key]:
            if i+1 == j: break
        else: print key, i+1

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
hanako = 0
taro = 0
for i in range(n):
    t,h = raw_input().split()
    if h == t:
        hanako += 1
        taro += 1
    elif h < t:
        taro += 3
    else:
        hanako += 3
print " ".join(map(str,[taro, hanako]))

Submission status: Time Limit Exceeded

Solution code:
#16Bmissing
def mn(li):
    if li[0]== "S":
        c[0]=0
    elif li[0]== "H":
        li[0]=1
    elif li[0]== "C":
        li[0]=2
    elif li[0]== "D":
        li[0]=3
    li[1]=int(li[1])
    return li
def nm(nu):
    if nu==0:
        co="S"
    elif nu==1:
        co="H"
    elif nu==2:
        co="C"
    elif nu==3:
        co="D"
#    co+=??? ???+str(li[1])
    return co
N=int(input())
m=[[]]
for i in range(N-1):
    c=[j for j in input().split()]
    c=mn(c)
    for j in range(2):
        m[i].append(c[j])
    m.append([])
c=[j for j in input().split()]
c=mn(c)
for j in range(2):
    m[N-1].append(c[j])
m.sort()
i=0
j=0
l=1
#print(m)
while i < N:
    while m[i][0]!=j:
        for k in range(1,14):
            print(nm(m[i][0])+" "+str(k))
        j+=1
  #  print(i)
    while m[i][1]!=l:
        print(nm(m[i][0])+" "+str(l))
        l+=1
    l+=1
    if l>13:
        l=1
        j+=1
    i+=1

Submission status: Time Limit Exceeded

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

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

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

for j in range(n):
    x = list(input().split())
    if x[0] is 'S':
        s.remove(int(x[1]))
    elif x[0] is 'H':
        h.remove(int(x[1]))
    elif x[0] is 'C':
        c.remove(int(x[1]))
    elif x[0] is 'D':
        d.remove(int(x[1]))

if len(s) != 0:
    for i in range(len(s)):
        print('{0} {1}'.format('S', s[i]))

if len(h) != 0:
    for i in range(len(h)):
        print('{0} {1}'.format('H', h[i]))

if len(c) != 0:
    for i in range(len(c)):
        print('{0} {1}'.format('C', c[i]))

while len(d) != 0:
    for i in range(len(d)):
        print('{0} {1}'.format('D', d[i]))

Submission status: Accepted

Solution code:
import sys
from copy import copy


def main():
    length = int(sys.stdin.readline())
    given_cards = []
    for i in range(length):
        given_cards.append(sys.stdin.readline().strip())
    cards = []
    for i in ('S ', 'H ', 'C ', 'D '):
        for j in range(13):
            cards.append(i + str(j + 1))
    for card in copy(cards):
        if card in given_cards:
            del cards[cards.index(card)]
    for card in cards:
        print(card)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
card=[]
for suit in ["S","H","C","D"]:
    for rank in list(map(str,range(1,14))):
        card.append(suit+" "+rank)
for i in range(n):
    card.remove(input())
for c in card:
    print(c)

Submission status: Accepted

Solution code:
card_dk = int(input())
block = ['S','H','C','D']
no = [1,2,3,4,5,6,7,8,9,10,11,12,13]
card_st =[]
not_card =[]
for i in range(card_dk):    
    card = input().split()
    card[1] = int(card[1])
    card_st.append(card)


for ch_block in block:
    for ch_no in no:
        flag = 0
        for card in card_st:
            if card == [ch_block,ch_no]:
                flag = 1
        if flag == 0:
            card = [ch_block,ch_no]
            not_card.append(card)

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

Submission status: Accepted

Solution code:
import sys

def make_all_cards():
    mark = ['S', 'H', 'C', 'D']
    cards = []
    
    for i in mark:
        for n in range(1, 14):
            cards.append(i + ' ' + str(n))

    return cards

if __name__ == '__main__':
    all_cards = make_all_cards()
    n = int(sys.stdin.readline().strip())

    for _ in range(n):
        card = sys.stdin.readline().strip()
        all_cards.remove(card)

    for i in all_cards:
        print(i)

Submission status: Accepted

Solution code:
a = int(input())
b = []
S = []
H = []
C = []
D = []
check = [1,2,3,4,5,6,7,8,9,10,11,12,13]
for i in range(a):
    b.append(input().split())
for i in range(len(b)):
    if b[i][0] == "S":
        S.append(int(b[i][1]))
    elif b[i][0] == "H":
        H.append(int(b[i][1]))
    elif b[i][0] == "C":
        C.append(int(b[i][1]))
    else:
        D.append(int(b[i][1]))

set_S = list(set(check)-set(S))
set_S.sort()
set_H = list(set(check)-set(H))
set_H.sort()
set_C = list(set(check)-set(C))
set_C.sort()
set_D = list(set(check)-set(D))
set_D.sort()
for i in set_S:
    print("S",i)
for i in set_H:
    print("H",i)
for i in set_C:
    print("C",i)
for i in set_D:
    print("D",i)

Submission status: Accepted

Solution code:
# coding: utf-8

'''
S 1
H 3
H 7
C 12
D 8
'''

cards = ['S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'S8', 'S9', 'S10', 'S11', 'S12', 'S13',
'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'H8', 'H9', 'H10', 'H11', 'H12', 'H13',
'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10', 'C11', 'C12', 'C13',
'D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'D8', 'D9', 'D10', 'D11', 'D12', 'D13']

for _ in range(int(input())):
    # suit, number = input().split()
    suit, number = map(str, input().split())
    cards.remove(suit + number)

for trump in cards:
    print(trump[0], trump[1:])

Submission status: Accepted

Solution code:
# coding: utf-8

'''
S 1
H 3
H 7
C 12
D 8
'''

cards = ['S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'S8', 'S9', 'S10', 'S11', 'S12', 'S13',
'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'H8', 'H9', 'H10', 'H11', 'H12', 'H13',
'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10', 'C11', 'C12', 'C13',
'D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'D8', 'D9', 'D10', 'D11', 'D12', 'D13']

for _ in range(int(input())):
    suit, number = input().split()
    cards.remove(suit + number)

for trump in cards:
    print(trump[0], trump[1:])

Submission status: Accepted

Solution code:
# coding: utf-8
suits = ['S', 'H', 'C', 'D']
cards = [(suit + str(i)) for suit in suits for i in range(1, 14)]

for _ in range(int(input())):
    cards.remove(''.join(input().split()))

for trump in cards:
    print(trump[0], trump[1:])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
lst = [True for i in range(52)]
n = int(input())
for i in range (n):
    suit, rank = input().split()
    rankn = int(rank)
    if suit == 'S':
        lst[rankn-1] = False
    elif suit == 'H':
        lst[rankn+12] = False
    elif suit == 'C':
        lst[rankn+25] = False
    else:
        lst[rankn+38] = False
for i in range(52):
    tf = lst[i]
    if i <= 12 and tf:
        print ('S %d' % (i+1))
    elif 12 < i <= 25 and tf:
        print ('H %d' % (i-12))
    elif 25 < i <= 38 and tf:
        print ('C %d' % (i-25))
    elif tf:
        print ('D %d' % (i-38))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(raw_input())
card = [i+" "+str(j) for i in "SHCD" for j in range(1,14)]
for i in range(n):
    card.remove(raw_input())
    pass
for i in  card:
    print i

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ans = []
for i in range(4):
    for j in range(13):
        ans.append("SHCD"[i] + " " + str(j + 1))

n = int(input())
for i in range(n):
    a = input()
    ans.remove(a)

if len(ans) > 0:
    print("\n".join(ans))

Submission status: Accepted

Solution code:
ans = [f'{x} {y + 1}' for x in "SHCD" for y in range(13)]

n = int(input())
for i in range(n):
    a = input()
    ans.remove(a)

for v in ans:
    print(v)

Submission status: Accepted

Solution code:
n = int(input())
cards, suits = [], ["S", "H", "C", "D"]
for suit in suits:
    for x in range(1, 14):
        cards.append('{} {}'.format(suit, x))

for _ in range(n):
    target = ' '.join(input().split())
    if target in cards:
        cards.remove(target)

[print(c) for c in cards]

Submission status: Accepted

Solution code:
# ２次元配列バージョン
# かつ、内包表記バージョン
n = int(input())
suits = ["S", "H", "C", "D"]
cards = [[s, n] for s in suits for n in range(1, 14)]
for i in range(n):
    target = list(map(
        lambda a: int(a) if a.isnumeric() else a, input().split()
    ))
    if target in cards:
        cards.remove(target)
[print("{} {}".format(c[0], c[1])) for c in cards]

Submission status: Accepted

Solution code:
# ２次元配列バージョン
# あらかじめ空の配列を用意しておくバージョン
n = int(input())
suits = ["S", "H", "C", "D"]
cards = []
for s in suits:
    for x in range(1, 14):
        cards.append([s, x])
for i in range(n):
    e = [int(l) if l.isnumeric() else l for l in input().split()]
    if e in cards:
        cards.remove(e)

for c in cards:
    print("{} {}".format(c[0], c[1]))

Submission status: Accepted

Solution code:
n = int(input())
a = list()
for i in range(n):
	x, y = input().split()
	y = int(y)
	if x == "S":
		a.append(y + 0)
	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())
cards = [input() for _ in range(n)]
for suit in "SHCD":
    for rank in range(1, 14):
        if f'{suit} {rank}' not in cards:
            print(suit, rank)

Submission status: Accepted

Solution code:
all = [suit + ' ' + str(rank) for suit in 'SHCD' for rank in range(1, 14)]
for _ in range(int(input())):
    all.remove(input())
for card in all:
    print(card)

Submission status: Accepted

Solution code:
from itertools import *
c = [f'{x} {y}' for x, y in product('SHCD', range(1, 14))]
for _ in range(int(input())):
    c.remove(input())
if c: print(*c, sep='\n')

Submission status: Accepted

Solution code:
from itertools import*
c=[f'{x} {y}'for x,y in product('SHCD',range(1,14))]
exec('c.remove(input());'*int(input()))
if c:print(*c,sep='\n')

Submission status: Accepted

Solution code:
N=int(input())
s=[input() for i in range(N)]
lost_list=[]
taro_card=[]
card_list=[]
for i in s:
    taro_card.append(i.split())
for i in range(1,14):
    card_list.append(["S",str(i)])
for i in range(1,14):
    card_list.append(["H",str(i)])
for i in range(1,14):    
    card_list.append(["C",str(i)])
for i in range(1,14):    
    card_list.append(["D",str(i)])
for i in card_list:
    if i not in taro_card:
        lost_list.append(i)
for i in lost_list:
    print(i[0]+" "+i[1])

Submission status: Accepted

Solution code:
_, *C = open(0).readlines()
C = set(C)
xs = [" %d\n" % i for i in range(1, 14)]
ans = []
for s in "SHCD":
    for x in xs:
        card = s+x
        if card not in C:
            ans.append(card)
open(1, 'w').writelines(ans)

Submission status: Accepted

Solution code:
N = int(input())
CardList = [0 for i in range(53)]
for i in range(1, N + 1):
    Mark, Rank = map(str, input().split())
    if Mark == 'S':
        CardList[int(Rank) ] = 1
    elif Mark == 'H':
        CardList[int(Rank) + 13] = 1
    elif Mark == 'C':
        CardList[int(Rank) + 26] = 1
    else:
        CardList[int(Rank) + 39] = 1
for j in range(1, 53):
    if CardList[j] == 0:
        if 1 <= j <14:
            print('S', j)
        elif 14 <= j < 27:
            print('H', j - 13)
        elif 27 <= j <40:
            print('C', j - 26)
        else:
            print('D', j - 39)

Submission status: Accepted

Solution code:
n = int(input())
a = set([])
for _ in range(n):
    a.add(input())
for suit in ('S', 'H', 'C', 'D'):
    for i in range(1,14):
        card = suit + ' ' + str(i)
        if card not in a:
            print(card)