TnT/CodeNet4Repair huggingface dataset:
Problem:
Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters.  Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be possible as is, so he will do the following operations some number of times **before** he does the cut:    * Choose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan).   * Choose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen.  Find the minimum amount of money needed before cutting the bar into two parts with the same length.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

Asum = sum(A)

s=0
t=0
for i,Ai in enumerate(A):
    s+=Ai
    if s == Asum/2:
        print(0)
        exit()
    if s >= Asum/2:
        s = i
        break
for i,Ai in enumerate(A[::-1]):
    t+=Ai
    if t >= Asum/2:
        t = i
        break

ans1 = sum(A[:s])-(Asum-sum(A[:s]))
ans2 = sum(A[:t])-(Asum-sum(A[:t]))

print(min(ans1,ans2))


Fixed, accepted submission:
N = int(input())
A = list(map(int, input().split()))

Asum = sum(A)

s=0
t=0
for i,Ai in enumerate(A):
    s+=Ai
    if s == Asum/2:
        print(0)
        exit()
    if s >= Asum/2:
        s = i
        break
for i,Ai in enumerate(A[::-1]):
    t+=Ai
    if t >= Asum/2:
        t = i
        break

ans1 = abs(sum(A[:s])-(Asum-sum(A[:s])))
ans2 = abs(sum(A[::-1][:t])-(Asum-sum(A[::-1][:t])))

print(min(ans1,ans2))
Problem:
Snuke has N strings. The i-th string is s_i.  Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.

Incorrect submission (verdict: Wrong Answer):
import sys
def input():
	return sys.stdin.readline()[:-1]
n = int(input())
xa, bx, bxa = 0, 0, 0
ans = 0
for _ in range(n):
	s = input()
	for i in range(len(s)-1):
		if s[i] == "A" and s[i+1] == "B":
			ans += 1
	if s[0] == "B":
		if s[-1] == "A":
			bxa += 1
		else:
			bx += 1
	elif s[-1] == "A":
		xa += 1
#print(xa, bx, bxa)
ans += bxa-1
if bxa > 0:
	if xa > 0:
		xa -= 1
		ans += 1
	if bx > 0:
		bx -= 1
		ans += 1
ans += min(xa, bx)
print(ans)

Fixed, accepted submission:
n = int(input())
xa, bx, bxa = 0, 0, 0
ans = 0
for _ in range(n):
	s = input()
	for i in range(len(s)-1):
		if s[i] == "A" and s[i+1] == "B":
			ans += 1
	if s[0] == "B":
		if s[-1] == "A":
			bxa += 1
		else:
			bx += 1
	elif s[-1] == "A":
		xa += 1

if xa == bx:
	if xa == 0:
		print(ans+max(0, bxa-1))
	else:
		print(ans+xa+bxa)
else:
	print(ans+bxa+min(xa, bx))
Problem:
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.

Incorrect submission (verdict: Wrong Answer):
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if c>=a:
  if c<=b:
    print('Yes')
  else:
    print('No')
print('No')

Fixed, accepted submission:
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if c>=a:
  if c<=b:
    print('Yes')
  else:
    print('No')
else:
  print('No')
Problem:
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes:    * Hit his pocket, which magically increases the number of biscuits by one.   * Exchange A biscuits to 1 yen.   * Exchange 1 yen to B biscuits.  Find the maximum possible number of biscuits in Snuke's pocket after K operations.

Incorrect submission (verdict: Wrong Answer):
k,a,b = map(int,input().split())
dif = b-a
if b<=2:
  print(k)
else:
  ans = dif*(k//2)
  ans += (k%2==1)
  print(ans)

Fixed, accepted submission:
k,a,b = map(int,input().split())
dif = b-a
if dif<=2:
  print(k+1)
else:
  ans = a
  k -= (a-1)
  ans += dif*(k//2)
  ans += (k%2==1)
  print(ans)
Problem:
Takahashi loves numbers divisible by 2.  You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.  Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.  For example,    * 6 can be divided by 2 once: 6 -> 3.   * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.   * 3 can be divided by 2 zero times.

Incorrect submission (verdict: Wrong Answer):
n = int(input())

result = 0
while n % 2 == 0:
    n //= 2
    result += 1

print(result)


Fixed, accepted submission:
def calculate_dived_by_two(n):
    count = 0
    while n % 2 == 0:
        count += 1

        n //= 2

    return count


n = int(input())

result = 1
max_count = 0
for i in range(1, n + 1):
    count = calculate_dived_by_two(i)
    if count > max_count:
        max_count = count
        result = i

print(result)
Problem:
Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.  You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise.

Incorrect submission (verdict: Wrong Answer):
sumeke=input()
sumeke=int(sumeke)
sumeke=1200
if sumeke >= 1200:
	print("ARC")
else:
	print("ABC")

Fixed, accepted submission:
sumeke=input()
sumeke=int(sumeke)
if sumeke < 1200:
	print("ABC")
else:
	print("ARC")
Problem:
We will buy a product for N yen (the currency of Japan) at a shop.  If we use only 1000-yen bills to pay the price, how much change will we receive?  Assume we use the minimum number of bills required.

Incorrect submission (verdict: Wrong Answer):
dash  =int(input())
otsuri=dash%1000
print(otsuri)

Fixed, accepted submission:
dash  =int(input())
otsuri1=dash%1000
if otsuri1==0:
  print(0)
else:
     otsuri2=1000-otsuri1
     print(otsuri2)
Problem:
We have a grid with N rows and M columns of squares. Initially, all the squares are white.  There is a button attached to each row and each column. When a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa. When a button attached to a column is pressed, the colors of all the squares in that column are inverted.  Takahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid.

Incorrect submission (verdict: Wrong Answer):
n,m,k = list(map(int, input().split()))
for i in range(n+1):
    for j in range(m+1):
        print(i, j, i*m+j*n-2*i*j)
        if i*m+j*n-2*i*j==k:
            print('Yes')
            exit()

print('No')

Fixed, accepted submission:
n,m,k = list(map(int, input().split()))
for i in range(n+1):
    for j in range(m+1):
        if i*m+j*n-2*i*j==k:
            print('Yes')
            exit()

print('No')
Problem:
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`.  Consider doing the following operation:    * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.  You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.

Incorrect submission (verdict: Wrong Answer):
import itertools
import copy
h, w, k = map(int, input().split())

cs = []
for i in range(h):
    cs.append(list(input()))

# print(cs)

hpatterns = []
for i in range(h + 1):
    hpatterns += list(itertools.combinations(range(h), i))
wpatterns = []
for i in range(w + 1):
    wpatterns += list(itertools.combinations(range(w), i))

# print(hpatterns)
# print(wpatterns)

c = 0
for hpattern in hpatterns:
    for wpattern in wpatterns:
        black = 0
        cs2 = copy.deepcopy(cs)
        for pi in range(len(hpattern)):
            cs2[pi] = ['' for k in range(w)]

        for pj in range(len(wpattern)):
            for s in range(len(cs2)):
                
                cs2[s][pj] = ''
        # print(hpattern, wpattern, cs2)
        for s in cs2:
            black += s.count('#')

        if black == k:
            c += 1

print(c)


Fixed, accepted submission:
import itertools
import copy
h, w, k = map(int, input().split())

cs = []
for i in range(h):
    cs.append(list(input()))

# print(cs)

hpatterns = []
for i in range(h + 1):
    hpatterns += list(itertools.combinations(range(h), i))
wpatterns = []
for i in range(w + 1):
    wpatterns += list(itertools.combinations(range(w), i))

# print(hpatterns)
# print(wpatterns)

c = 0
for hpattern in hpatterns:
    for wpattern in wpatterns:
        black = 0
        cs2 = copy.deepcopy(cs)
        for pi in hpattern:
            cs2[pi] = ['' for k in range(w)]

        for pj in wpattern:
            for s in range(len(cs2)):
                
                cs2[s][pj] = ''
        # print(wpattern, hpattern, cs2)
        for s in cs2:
            black += s.count('#')

        if black == k:
            c += 1

print(c)
Problem:
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
num = input()
list = num.split()
print(list[1])
max = sum = min = int(list[0])
for x in range(N - 1):
    a = int(list[x + 1])
    if a > max: max = a
    elif a < min: min = a
    sum += a
print(min, max, sum)
    


Fixed, accepted submission:
N = int(input())
num = input()
list = num.split()
max = sum = min = int(list[0])
for x in range(N - 1):
    a = int(list[x + 1])
    if a > max: max = a
    elif a < min: min = a
    sum += a
print(min, max, sum)
Problem:
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
txy = [list(map(int, input().split())) for _ in range(n)]
t, x, y = 0, 0, 0
flag = True
for nt, nx, ny in txy:
    dt = nt - t
    dx = nx - x
    dy = ny - y
    if (dt < dx + dy) or ((dx + dy) % 2 != dt % 2):
        flag = False
        break
    else:
        t = nx
        x = nx
        y = ny
if flag:
    print('YES')
else:
    print('NO')

Fixed, accepted submission:
n = int(input())
txy = [list(map(int, input().split())) for _ in range(n)]
t, x, y = 0, 0, 0
flag = True
for nt, nx, ny in txy:
    dt = nt - t
    dx = nx - x
    dy = ny - y
    if (dt < dx + dy) or ((dx + dy) % 2 != dt % 2):
        flag = False
        break
    t = nt
    x = nx
    y = ny
if flag:
    print('Yes')
else:
    print('No')
Problem:
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.    An example of a trapezoid  Find the area of this trapezoid.

Incorrect submission (verdict: Wrong Answer):
a = int(input())
b = int(input())
h = int(input())

print((a + b)*h/2)

Fixed, accepted submission:
a = int(input())
b = int(input())
h = int(input())
 
print(int((a + b)*h/2))
Problem:
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**.  You are given a 4-digit integer N. Answer the question: Is N **good**?

Incorrect submission (verdict: Wrong Answer):
n = int(input())
s = []
for i in range(4):
	s.append(n//(10**i)-(n//(10**(i+1)))*10)
s.reverse()
if s[0]+s[1]+s[2]+s[3]==7:
	print(s[0],"+",s[1],"+",s[2],"+",s[3],"=7",sep="")
elif s[0]+s[1]+s[2]-s[3]==7:
	print(s[0],"+",[1],"+",s[2],"-",s[3],"=7",sep="")
elif s[0]+s[1]-s[2]+s[3]==7:
	print(s[0],"+",s[1],"-",s[2],"+",s[3],"=7",sep="")
elif s[0]+s[1]-s[2]-s[3]==7:
	print(s[0],"+",s[1],"-",s[2],"-",s[3],"=7",sep="")
elif s[0]-s[1]+s[2]+s[3]==7:
	print(s[0],"-",s[1],"+",s[2],"+",s[3],"=7",sep="")
elif s[0]-s[1]+s[2]-s[3]==7:
	print(s[0],"-",s[1],"+",s[2],"-",s[3],"=7",sep="")
elif s[0]-s[1]-s[2]+s[3]==7:
	print(s[0],"-",s[1],"-",s[2],"+",s[3],"=7",sep="")
elif s[0]-s[1]-s[2]-s[3]==7:
	print(s[0],"-",s[1],"-",s[2],"-",s[3],"=7",sep="")




Fixed, accepted submission:
n = list(input())

if n[0]==n[1]==n[2] or n[1]==n[2]==n[3]:
	print("Yes")
else:
	print("No")
Problem:
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not.  You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.

Incorrect submission (verdict: Wrong Answer):
S = list(input())
answer = 0
while True:
    if len(S) >= 1:
        S.pop(-1)
        print(S[0:len(S)//2])
        print(S[len(S)//2+1:-1])
        if S[0:len(S)//2] == S[len(S)//2:-1]:
            answer = len(S)-1
            break
    else:
        break
    # print(S)
print(answer)

Fixed, accepted submission:
S = list(input())
answer = 0
while True:
    if len(S) >= 1:
        S.pop(-1)
        # print(S[0:len(S)//2])
        # print(S[len(S)//2+1:-1])
        if S[0:len(S)//2] == S[len(S)//2:-1]:
            answer = len(S)-1
            break
    else:
        break
    # print(S)
print(answer)
Problem:
You are parking at a parking lot. You can choose from the following two fee plans:    * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.   * Plan 2: The fee will be B yen, regardless of the duration.  Find the minimum fee when you park for N hours.

Incorrect submission (verdict: Wrong Answer):
def ABC_80_A():
    N,A,B = map(int, input().split())
    
    if A*N >= B:
        print(A*N)
    else:
        print(B)

if __name__ == '__main__':

    ABC_80_A()

Fixed, accepted submission:
def ABC_80_A():
    N,A,B = map(int, input().split())
    
    if A*N <= B:
        print(A*N)
    else:
        print(B)

if __name__ == '__main__':

    ABC_80_A()
Problem:
We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j).   Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares.   Before Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game.   When the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares.  The color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is `.`; if square (i, j) is initially painted by black, s_{i, j} is `#`.

Incorrect submission (verdict: Wrong Answer):
import queue

H,W = map(int,input().split())

temp = [[-1 for j in range(W+2)]]
B = temp+[[] for i in range(H)]+temp

dot = 0
for i in range(1,H+1):
    S = input()
    B[i].append(-1)
    for s in S:
        if s==".":
            B[i].append(H*W)
            dot += 1
        else:
            B[i].append(-1)
    B[i].append(-1)
    
Q = queue.Queue()
Q.put((1,1))
B[1][1]=1

min_root = dot
while(not Q.empty()):
    x,y = Q.get()
    L = [[x-1,y],[x+1,y],[x,y-1],[x,y+1]]
    move = B[x][y]+1
    for dx,dy in L:
        if move < B[dx][dy]:
            Q.put((dx,dy))
            B[dx][dy] = move
    
            
print(B,dot-B[H][W])

Fixed, accepted submission:
import queue

H,W = map(int,input().split())

temp = [[-1 for j in range(W+2)]]
B = temp+[[] for i in range(H)]+temp

dot = 0
for i in range(1,H+1):
    S = input()
    B[i].append(-1)
    for s in S:
        if s==".":
            B[i].append(H*W)
            dot += 1
        else:
            B[i].append(-1)
    B[i].append(-1)
    
Q = queue.Queue()
Q.put((1,1))
B[1][1]=1

min_root = dot
isok = False
while(not Q.empty()):
    y,x = Q.get()
    L = [[y-1,x],[y+1,x],[y,x-1],[y,x+1]]
    move = B[y][x]+1
    for dy,dx in L:
        if move < B[dy][dx]:
            Q.put((dy,dx))
            B[dy][dx] = move
            if dy==H and dx==W: isok=True
    

if isok:
    print(dot-B[H][W])
else:
    print(-1)
Problem:
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
time_space = [(int(x) for x in input().split()) for i in range(n)]
pos = [0,0]
for t, x, y in time_space:
    if (t - abs(x - pos[0]))%2 != abs(y-pos[1]):
        print('No')
        exit()
    else:
        pos = [x, y]
print('Yes')

Fixed, accepted submission:
n = int(input())
for i in range(n):
    t, x, y = [int(x) for x in input().split()]
    if (x+y) > t or (x+y+t)%2:
        print('No')
        exit()
print('Yes')
Problem:
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:                 for i = 1 to A.length-1     key = A[i]     /* insert A[i] into the sorted sequence A[0,...,j-1] */     j = i - 1     while j >= 0 and A[j] > key         A[j+1] = A[j]         j--     A[j+1] = key   Note that, indices for array elements are based on 0-origin.  To illustrate the algorithms, your program should trace intermediate result for each step.

Incorrect submission (verdict: Wrong Answer):

def insertion_sort(args):
    results = []
    for i in range(0, len(args)):
        v = args[i]
        j = i - 1
        while (j >= 0 and args[j] > v):
            args[j+1] = args[j]
            j -= 1
        args[j+1] = v
        results.append(args[:])
    return results

if __name__ == '__main__':
    n = int(input())
    args = list(map(int, input().split()))[0:n]
    results = insertion_sort(args)
    for result in results:
        print(result)



Fixed, accepted submission:

def insertion_sort(args):
    results = []
    for i in range(0, len(args)):
        v = args[i]
        j = i - 1
        while (j >= 0 and args[j] > v):
            args[j+1] = args[j]
            j -= 1
        args[j+1] = v
        results.append(args[:])
    return results

if __name__ == '__main__':
    n = int(input())
    args = list(map(int, input().split()))[0:n]
    results = insertion_sort(args)
    for result in results:
        print(' '.join(map(str, result)))
Problem:
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:                 for i = 1 to A.length-1     key = A[i]     /* insert A[i] into the sorted sequence A[0,...,j-1] */     j = i - 1     while j >= 0 and A[j] > key         A[j+1] = A[j]         j--     A[j+1] = key   Note that, indices for array elements are based on 0-origin.  To illustrate the algorithms, your program should trace intermediate result for each step.

Incorrect submission (verdict: Wrong Answer):
import sys

ERROR_INPUT = 'input is invalid'


def main():
    n = get_length()
    arr = get_array(length=n)
    print(arr)

    insetionSort(li=arr, length=n)
    return 0


def get_length():
    n = int(input())
    if n < 0 or n > 100:
        print(ERROR_INPUT)
        sys.exit(1)
    else:
        return n


def get_array(length):
    nums = input().split(' ')
    return [str2int(string=n) for n in nums]


def str2int(string):
    n = int(string)
    if n < 0 or n > 1000:
        print(ERROR_INPUT)
        sys.exit(1)
    else:
        return n


def insetionSort(li, length):
    for i in range(1, length):
        v = li[i]
        j = i - 1
        while j >= 0 and li[j] > v:
            li[j + 1] = li[j]
            j -= 1

        li[j + 1] = v
        print(li)


main()

Fixed, accepted submission:
import sys

ERROR_INPUT = 'input is invalid'


def main():
    n = get_length()
    arr = get_array(length=n)

    insetionSort(li=arr, length=n)
    return 0


def get_length():
    n = int(input())
    if n < 0 or n > 100:
        print(ERROR_INPUT)
        sys.exit(1)
    else:
        return n


def get_array(length):
    nums = input().split(' ')
    return [str2int(string=n) for n in nums]


def str2int(string):
    n = int(string)
    if n < 0 or n > 1000:
        print(ERROR_INPUT)
        sys.exit(1)
    else:
        return n


def insetionSort(li, length):
    for n in range(0, length):
        print(*(sorted(li[0:n + 1]) + li[n + 1:length]))


main()
Problem:
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.

Incorrect submission (verdict: Wrong Answer):
a,b,c = map(int, input().split())
if (b > a and b < c) or (b < a and b > c):
  print('Yes')
else:
  print('No')

Fixed, accepted submission:
a,b,c = map(int, input().split())
if (c > a and b > c) or (c < a and b < c):
  print('Yes')
else:
  print('No')
Problem:
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:    * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.  What is the largest possible sum of the integers written on the blackboard after K operations?

Incorrect submission (verdict: Wrong Answer):
abc = map(int, input().split())
k = int(input())
print(max(abc) * (2 ** k - 1) + sum(abc))

Fixed, accepted submission:
x = tuple(map(int, input().split()))
k = int(input())
# max(x) * (2 ** k) + sum(x) - max(x)
print(sum(x) + max(x) * ((1 << k) - 1))
Problem:
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.

Incorrect submission (verdict: Wrong Answer):
epochs = int(input())
patterns = ['S', 'H', 'C', 'D']
checker = {pattern: [True]*13 for pattern in patterns}
for i in range(epochs):
    pattern, num = input().split()
    num = int(num)
    checker[pattern][num-1] = False

for pattern in patterns:
    for i in range(13):
        if checker[pattern][i]:
            print(pattern, i)

Fixed, accepted submission:
epochs = int(input())
patterns = ['S', 'H', 'C', 'D']
checker = {pattern: [True]*13 for pattern in patterns}
for i in range(epochs):
    pattern, num = input().split()
    num = int(num)
    checker[pattern][num-1] = False
 
for pattern in patterns:
    for i in range(13):
        if checker[pattern][i]:
            print(pattern, i+1)