TnT/CodeNet4Repair huggingface dataset:
Problem:
You are given an H × W grid.   The squares in the grid are described by H strings, S_1,...,S_H.   The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W).   `.` stands for an empty square, and `#` stands for a square containing a bomb.  Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square.   (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.)   He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square.  Print the strings after the process.

Incorrect submission (verdict: Wrong Answer):
h,w = map(int,input().split())
s = []
def calc(i,j,k,l):
    if k==0 and l==0:
        return 0
    elif i+k==-1 or j+l==-1 or i+k==h or j+l==w:
        return 0
    elif s[i+k][j+l] == '#':
        count[i][j] = count[i][j] + 1
for i in range(h):
    s += [input()]
count = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        for k in range(3):
            for l in range(3):
                calc(i,j,k-1,l-1)
for i in range(h):
    s_tmp=''
    for j in range(w):
        if s[i][j]=='#':
            s_tmp += '#'
        else:
            s_tmp += str(count[i][j])
    s[i]=s_tmp
print(s)

Fixed, accepted submission:
h,w = map(int,input().split())
s = []
def calc(i,j,k,l):
    if k==0 and l==0:
        return 0
    elif i+k==-1 or j+l==-1 or i+k==h or j+l==w:
        return 0
    elif s[i+k][j+l] == '#':
        count[i][j] = count[i][j] + 1
for i in range(h):
    s += [input()]
count = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        for k in range(3):
            for l in range(3):
                calc(i,j,k-1,l-1)
for i in range(h):
    s_tmp=''
    for j in range(w):
        if s[i][j]=='#':
            s_tmp += '#'
        else:
            s_tmp += str(count[i][j])
    s[i]=s_tmp
for i in range(h):
    print(s[i])
Problem:
As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below:    * A consists of integers between X and Y (inclusive).   * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.  Find the maximum possible length of the sequence.

Incorrect submission (verdict: Wrong Answer):
X, Y = map(int, input().split())
a, b = 0, 0
while True:
    X = X//2
    if X < 2:
        break
    a += 1
while True:
    Y = Y//2
    if Y < 2:
        break
    b += 1
print(b-a+1)


Fixed, accepted submission:
X, Y = map(int, input().split())
b = 0
while True:
    Y = Y//2
    if Y < X:
        b += 1
        break
    b += 1
print(b)
Problem:
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.

Incorrect submission (verdict: Time Limit Exceeded):
n =int(input())

ans =[]
for i in range(10**9):
  if (i ** 0.5).is_integer() and i <= n:
    ans.append(i)
    
    
print(ans[-1])
    
    

    

Fixed, accepted submission:
n = int(input())
m = 1
for i in range(1, n):
    if i ** 2 > n:
        break
    m = i ** 2
print(m)
Problem:
We ask you to select some number of positive integers, and calculate the sum of them.  It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.  Your objective is to make the sum congruent to C modulo B. Determine whether this is possible.  If the objective is achievable, print `YES`. Otherwise, print `NO`.

Incorrect submission (verdict: Wrong Answer):
a, b, c = map(int, input().split())
i = a % b
init_i = i
i_list = []
while True:
    print(i)
    if i%b ==  c:
        print('YES')
        exit()
    if i in i_list:
        print('NO')
        exit()
    i_list.append(i)
    i = (i+init_i) % b

Fixed, accepted submission:
a, b, c = map(int, input().split())
for i in range(1, 101):
    if i*a % b == c:
        print('YES')
        exit()
print('NO')
Problem:
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i.  Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.

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

ans = 0

if s%10==1:
  ans += 1

s = s//10
if s%10==1:
  ans += 1

s = s//10
if s==1:
  ans += 1
  
print(ans+1)

Fixed, accepted submission:
s = int(input())

ans = 0

if s%10==1:
  ans += 1

s = s//10
if s%10==1:
  ans += 1

s = s//10
if s==1:
  ans += 1
  
print(ans)
Problem:
For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3.  We have a string T consisting of `P`, `D`, and `?`.  Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.

Incorrect submission (verdict: Wrong Answer):
t = list(input())
a = 0
b = 0

for i in range(len(t)):
    if i == 0 and t[i] == '?':
        t[i] == 'D'
    
    if i > 0 and t[i] == '?':
        if t[i-1] == 'P':
            t[i] == 'D'
        else:
            t[i] == 'P'

a = t.count('PD')
b = t.count('D')

print(a + b)

Fixed, accepted submission:
t = list(input())
a = 0
b = 0

for i in range(len(t)):
    if i == 0 and t[i] == '?':
        t[i] = 'D'
    
    if 0 < i < len(t) - 1 and t[i] == '?':
        if t[i-1] == 'P':
            t[i] = 'D'
        elif t[i+1] == 'P':
            t[i] = 'D'
        else:
            t[i] = 'P'

    if i == len(t) -1 and t[i] == '?':
        t[i] = 'D'

print(''.join(t))
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 = input()
if(N[0] == N[1] == N[2] and N[1] == N[2] == N[3]):
  print("Yes")
else:
  print("No")

Fixed, accepted submission:
N = input()
ans = "No"
if(N[0] == N[1] == N[2] or N[1] == N[2] == N[3]):
  ans = "Yes"
print(ans)
Problem:
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i.  Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.  Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)  At most how much can he earn on balance?  Note that the same string may be written on multiple cards.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
le = set(s)
for i in le:
    count = max(0,s.count(i)-t.count(i))
print(count)

Fixed, accepted submission:
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
le = list(set(s))
count = max(s.count(le[i]) - t.count(le[i]) for i in range(len(le)))
print(max(0,count))
Problem:
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year.   For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.  In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi.   How many days from 2018-1-1 through 2018-a-b are Takahashi?

Incorrect submission (verdict: Wrong Answer):
a,b = map(int, input().split())
if a < b:
  print(a)
else:
  print(a-1)

Fixed, accepted submission:
a,b = map(int, input().split())
if a <= b:
  print(a)
else:
  print(a-1)
Problem:
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.  Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.

Incorrect submission (verdict: Wrong Answer):
for i in range(10000):
    x = input()
    
    if x=="0":
        break
    
    else:
        print ("Case " + str(i) + ": " + str(x))

Fixed, accepted submission:
for i in range(20000):
    x = input()
    
    if x=="0":
        break
    
    else:
        print ("Case " + str(i+1) + ": " + str(x))
Problem:
For an integer n not less than 0, let us define f(n) as follows:    * f(n) = 1 (if n < 2)   * f(n) = n f(n-2) (if n \geq 2)  Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).

Incorrect submission (verdict: Wrong Answer):
import sys
stdin = sys.stdin
import copy

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n = ni()
if n % 2 != 0:
    print(0)
else:
    n2 = copy.copy(n)
    n5 = copy.copy(n)
    c2, c5 = 0, 0
    while n2 > 1:
        n2 //= 2
        c2 += n2
    while n5 > 1:
        n5 //= 5
        c5 += n5//2
    print(c2, c5)
    print(min(c2, c5))




Fixed, accepted submission:
import sys
stdin = sys.stdin
import copy

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n = ni()
if n % 2 != 0:
    print(0)
else:
    n2 = copy.copy(n)
    n5 = copy.copy(n)
    c2, c5 = 0, 0
    while n2 > 1:
        n2 //= 2
        c2 += n2
    while n5 > 1:
        n5 //= 5
        c5 += n5//2
    print(min(c2, c5))
Problem:
You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive). You cannot assign the same integer to multiple playing fields. The competition consists of N rounds, each of which proceeds as follows:    * For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.   * Then, each player adds 1 to its integer. If it becomes N+1, change it to 1.  You want to ensure that no player fights the same opponent more than once during the N rounds. Print an assignment of integers to the playing fields satisfying this condition. It can be proved that such an assignment always exists under the constraints given.

Incorrect submission (verdict: Wrong Answer):
#E
import numpy as np
n, m = list(map(int, input().split()))
lists = list(np.arange(1, n+1))
list1 = lists[:n//2]
list2 = lists[n//2:]
num = m
for i in range(m//2 +1):
    if num == 0:
        break
    print(list2[i],list2[len(list2)-1-i])
    num -= 1
    if num == 0:
        break
    print(list1[i],list1[len(list1)-1-i])
    num -= 1

Fixed, accepted submission:
#E
import numpy as np
n, m = list(map(int, input().split()))
lists = list(np.arange(1, n+1))
list1 = lists[:m]
list2 = lists[m:]
num = m
for i in range(m//2 +1):
    if num == 0:
        break
    print(list2[i],list2[m+1-i-1])
    num -= 1
    if num == 0:
        break
    print(list1[i],list1[m-i-1])
    num -= 1
Problem:
E869120 found a chest which is likely to contain treasure.   However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.   He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`.  One more thing he found is a sheet of paper with the following facts written on it:    * Condition 1: The string S contains a string T as a contiguous substring.   * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.  Print the string S.   If such a string does not exist, print `UNRESTORABLE`.

Incorrect submission (verdict: Wrong Answer):
if __name__ == '__main__':
	S = input()
	T = input()

	T_length = len(T)
	head = -1
	for i in range(len(S)-T_length+1):
		counter = 0
		for j in range(T_length):
			if(S[i+j]==T[j] or S[i+j]=='?'):
				counter += 1
		if(counter == T_length):
			head = i
				
	print(head)
	ans = ''
	i=0
	if(head == -1):
		print("UNRESTORABLE")
	else :
		while i < len(S):
			if(i!=head and S[i]=='?'):
				ans += 'a'
				i += 1
			elif(i==head):
				ans += T
				i += T_length
			else :
				ans += S[i]
				i+=1

		print(ans)

Fixed, accepted submission:
if __name__ == '__main__':
	S = input()
	T = input()

	T_length = len(T)
	head = -1
	for i in range(len(S)-T_length+1):
		counter = 0
		for j in range(T_length):
			if(S[i+j]==T[j] or S[i+j]=='?'):
				counter += 1
		if(counter == T_length):
			head = i
				
	ans = ''
	i=0
	if(head == -1):
		print("UNRESTORABLE")
	else :
		while i < len(S):
			if(i!=head and S[i]=='?'):
				ans += 'a'
				i += 1
			elif(i==head):
				ans += T
				i += T_length
			else :
				ans += S[i]
				i+=1

		print(ans)
Problem:
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes:    * Red boxes, each containing R red balls   * Green boxes, each containing G green balls   * Blue boxes, each containing B blue balls  Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?

Incorrect submission (verdict: Wrong Answer):
R,G,B,N = map(int,input().split())
ans = 0
for i in range(N):
    for e in range(N-R*i):
        if (N-i*i-e*G)%B == 0:
            ans += 1

print(ans)


Fixed, accepted submission:
R,G,B,N = map(int,input().split())
ans=0
for i in range(N//R+1):
    for e in range((N-R*i)//G+1):
        if (N-i*R-e*G)%B==0:
            ans+=1
print(ans)
Problem:
Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied:    * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds.  Find all favorite numbers and print the sum of those.

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

ans = 0
while N > 2:
    if N % 2 == 1:
        ans += N-1
        break
    ans += N - 1
    N = N / 2
print(ans)

Fixed, accepted submission:
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

ans = 0
for i in make_divisors(N):
    if i > 1 and N // (i - 1)  == N % (i - 1):
        ans += i - 1

print(ans)
Problem:
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room.  For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left.  Assume that initially no person lives in the building.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
a =[[[0 for i in range(10)]for j in range(3)]for k in range(4)]

for i in range(n):
    b, f, r, v = map(int, input().split())

    a[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" ", a[i][j][k], end='')
        print()
    print("#" * 20) 

Fixed, accepted submission:
n = int(input())
a =[[[0 for i in range(10)]for j in range(3)]for k in range(4)]

for i in range(n):
    b, f, r, v = map(int, input().split())

    a[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print("", a[i][j][k], end='')
        print()
    if i != 3:
        print("#" * 20)
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())

def ans(n):
    r=0
    while n%2==0:
        n=n//2
        r+=1
    return r

a=0
for i in range(1,n+1):
    a=max(a,ans(i))
print(a)

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

def ans(n):
    r=0
    while n%2==0:
        n=n//2
        r+=1
    return r

a=0
for i in range(1,n+1):
    a=max(a,ans(i))
print(2**a)
Problem:
Ringo is giving a present to Snuke.  Ringo has found out that Snuke loves _yakiniku_ (a Japanese term meaning grilled meat. _yaki_ : grilled, _niku_ : meat). He supposes that Snuke likes grilled things starting with `YAKI` in Japanese, and does not like other things.  You are given a string S representing the Japanese name of Ringo's present to Snuke. Determine whether S starts with `YAKI`.

Incorrect submission (verdict: Wrong Answer):
s = input()
if s[:4] == 'YAKi':
    print('Yes')
else:
    print('No')



Fixed, accepted submission:
s = input()
if s[:4] == 'YAKI':
    print('Yes')
else:
    print('No')
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):
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]))


Fixed, accepted submission:
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(1,14):
    dif.append(['S', str(i)])
    dif.append(['H', str(i)])
    dif.append(['C', str(i)])
    dif.append(['D', str(i)])
for i in range(len(trump)):
    for j in range(len(a)):
        if trump[i] == a[j]:
            dif.remove(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])
Problem:
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.

Incorrect submission (verdict: Wrong Answer):
str = input()
a = int(str.split()[0])
b = int(str.split()[1])

print(int((a+b)/2 + 1))


Fixed, accepted submission:
str = input()
a = int(str.split()[0])
b = int(str.split()[1])

print(int((a+b)/2 + 0.5))
Problem:
There is a string s of length 3 or greater. No two neighboring characters in s are equal.  Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first:    * Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.  The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.

Incorrect submission (verdict: Wrong Answer):
s = str(input())
if ((len(s)%2) ^ (s[0] == s[-1])):
  print("Second")
else:
  print("First")

Fixed, accepted submission:
s = str(input())
if ((len(s)%2) ^ (s[0] == s[-1])):print("First")
else:print("Second")
Problem:
You went shopping to buy cakes and donuts with X yen (the currency of Japan).  First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop.  How much do you have left after shopping?

Incorrect submission (verdict: Wrong Answer):

def resolve():
    X = int(input())
    A = int(input())
    B = int(input())

    print((X-A)%B)

Fixed, accepted submission:

def resolve():
    X = int(input())
    A = int(input())
    B = int(input())

    print((X-A)%B)

if __name__ == "__main__":
    resolve()
Problem:
We ask you to select some number of positive integers, and calculate the sum of them.  It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.  Your objective is to make the sum congruent to C modulo B. Determine whether this is possible.  If the objective is achievable, print `YES`. Otherwise, print `NO`.

Incorrect submission (verdict: Wrong Answer):
import sys

A, B, C = map(int, input().split())
i = 1
while (A*i)%B != C:
    i += 1
    if i > 100:
        print('NO')
        sys.exit()
print(i)
print('YES')


Fixed, accepted submission:
import sys

A, B, C = map(int, input().split())
i = 1
while (A*i)%B != C:
    i += 1
    if i > 100:
        print('NO')
        sys.exit()
print('YES')
Problem:
Write a program which calculates the area and perimeter of a given rectangle.

Incorrect submission (verdict: Wrong Answer):
a, b = input().strip().split(' ')
a, b = [int(a), int(b)]

men = a * b
syu = 2 * (a + b)

print(men)
print(syu)



Fixed, accepted submission:
a, b = input().strip().split(' ')
a, b = [int(a), int(b)]

men = a * b
syu = 2 * (a + b)

print(str(men) + ' ' + str(syu))
Problem:
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.  The problem has N test cases.  For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.  See the Output section for the output format.

Incorrect submission (verdict: Wrong Answer):
def main():
    N = int(input())
    di = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}

    for _ in range(N):
        di[input()] += 1

    for k, v in di.items():
        print(f"{k} × {v}")


if __name__ == "__main__":
    main()


Fixed, accepted submission:
import sys


def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    di = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}

    for _ in range(N):
        di[input()] += 1

    for k, v in di.items():
        print(f"{k} x {v}")


if __name__ == "__main__":
    main()