Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03608 (python)

Fixed submission:
import numpy as np
from scipy.sparse.csgraph import dijkstra

N,M,R = list(map(int,input().split()))
r = list(map(int,input().split()))
for i in range(R):
    r[i] -= 1

connections = np.zeros((N,N))
for i in range(M):
    A,B,C = list(map(int,input().split()))
    A,B = A-1,B-1
    
    connections[A][B] = C
    connections[B][A] = C

connections = dijkstra(connections)

def explore(unvisited,total,start):
    if unvisited:
        ret = float('inf')
        for town in unvisited:
            ret = min(ret,explore(unvisited-set([town]),
                total+connections[start][town],town))
        return ret
    else:
        return total

ans = float('inf')
targets = set(r)
for s in r:
    ans = min(ans,explore(targets-set([s]),0,s))
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
import numpy as np
from scipy.sparse.csgraph import dijkstra

N,M,R = list(map(int,input().split()))
r = list(map(int,input().split()))
for i in range(R):
    r[i] -= 1

connections = np.zeros((N,N))
for i in range(M):
    A,B,C = list(map(int,input().split()))
    A,B = A-1,B-1
    
    connections[A][B] = C
    connections[B][A] = C

connections = dijkstra(connections)

def explore(unvisited,total,start):
    if unvisited:
        ret = math.inf
        for town in unvisited:
            ret = min(ret,explore(unvisited-set([town]),
                total+connections[start][town],town))
        return ret
    else:
        return total

ans = math.inf
targets = set(r)
for s in r:
    ans = min(ans,explore(targets-set([s]),0,s))
print(int(ans))
Problem p03147 (python)

Fixed submission:
n = int(input())
heights = list(map(int, input().split()))

def nextgen(comb):
    lis = comb[0]
    j = comb[1]
    if len(lis) == 1 and lis[0] != 0:
        j += 1  
    for i in range(len(lis)-1):
        if (i != len(lis) and (lis[i] == 0 and lis[i+1] != 0)) or (i == 0 and lis[i] != 0):
            j += 1
        if lis[i] != 0:
            lis[i] -= 1
    if lis[len(lis)-1] != 0:
        lis[len(lis)-1] -= 1
    return [lis, j]

comb = [heights, 0]
while (comb[0].count(0) != len(comb[0])):
    comb = nextgen(comb)

print(comb[1])

Buggy submission (verdict: Runtime Error):
n = int(input())
heights = list(map(int, input().split()))

def nextgen(comb):
    lis = comb[0]
    j = comb[1]
    for i in range(len(lis)-1):
        if (i != len(lis) and (lis[i] == 0 and lis[i+1] != 0)) or (i == 0 and lis[i] != 0):
            j += 1
        if lis[i] != 0:
            lis[i] -= 1
    if lis[len(lis)-1] != 0:
        lis[len(lis)-1] -= 1
    return [lis, j]

comb = [heights, 0]
while (comb[0].count(0) != len(comb[0])):
    comb = test(comb)

print(comb[1])
Problem p03211 (python)

Fixed submission:
nums = input()
length = len(nums)

num = int(nums[:3])
dif = abs(num - 753)

for i in range(1, length - 2):
   num_ = int(nums[i:i+3])
   dif_ = abs(num_ - 753)
   if dif_ < dif:
       num = num_
       dif = dif_

print(dif)

Buggy submission (verdict: Runtime Error):
from IPython.utils.sysinfo import num_cpus
from site import abs_paths
nums = input()
length = len(nums)

num = int(nums[:3])
dif = abs(num - 753)

for i in range(1, length - 2):
   num_ = int(nums[i:i+3])
   dif_ = abs(num_ - 753)
   if dif_ < dif:
       num = num_
       dif = dif_

print(dif)
Problem p03238 (python)

Fixed submission:
n = int(input())

if n == 1:
    print("Hello World")

else:
    a = int(input())
    b = int(input())

    print(a+b)

Buggy submission (verdict: Runtime Error):
n = int(input())

hints = []
for i in range(n):
    x, y, h = map(int, input().split())
    hints.append([x, y, h])

def height(center , point):
    if point[2] == 0:
        return 0
    else:
        return point[2] + abs(point[0] - center[0]) + abs(point[1] - center[1])

for i in range(101):
    for j in range(101):
        cent = [i, j]
        hmax = height(cent, hints[0])
        k = 1
        while ((k < n) and (hmax == height(cent, hints[k]) or height(cent, hints[k]) == 0 or hmax == 0)):
            if (hmax == 0 and height(cent, hints[k]) != 0):
                hmax = height(cent, hints[k])
            k += 1
        #print(cent)
        #print(k)
        #print (hmax)
        if k == n:
            break
        else:
            continue
    if k == n:
        break

print("{} {} {}".format(cent[0], cent[1], hmax))
Problem p03239 (python)

Fixed submission:
n, tm = map(int, input().split())
ctl = []
for i in range(n):
    c, t = map(int, input().split())
    ctl.append([c, t])

filctl = []
for elm in ctl:
    if elm[1] <= tm:
        filctl.append(elm)
if len(filctl) != 0:
    filctl = sorted(filctl)
    print((filctl[0])[0])
else:
    print("TLE")

Buggy submission (verdict: Runtime Error):
n, tm = map(int, input().split())
ctl = []
for i in range(n):
    c, t = map(int, input().split())
    ctl.append([c, t])

filctl = []
for elm in ctl:
    if elm[1] <= tm:
        filctl.append(elm)

filctl = sorted(filctl)
print((filctl[0])[0])

Buggy submission (verdict: Runtime Error):
n, tm = map(int, input().split())
ctl = []
for i in range(n):
    c, t = map(int, input().split())
    ctl.append([c, t])

filctl = []
for elm in ctl:
    if elm[1] <= tm:
        filctl.append(elm)

filctl = sorted(filctl)
print(filctl[0])
Problem p03447 (python)

Fixed submission:
x = int(input())
a = int(input())
b = int(input())
print((x - a) % b)

Buggy submission (verdict: Runtime Error):
x, a, b = map(int, input().split())
print(x - a - b)
Problem p02717 (python)

Fixed submission:
a,b,c = map(int,input().split())
print(c,a,b)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input(),split())
print(c,a,b)
Problem p03043 (python)

Fixed submission:
a,b = map(int,input().split())
ans = 0
for i in range(1,a+1):
  c = 0
  bai = b/i
  while bai > 1:
    bai /= 2
    c += 1
  ans += 1/(2**c)
print(ans/a)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input()).split()
ans = 0
for i in range(1,a+1):
  c = 0
  bai = b/i
  while bai > 1:
    bai /= 2
    c += 1
  ans += 1/(2**c)
print(ans/a)
Problem p03068 (python)

Fixed submission:
a = int(input())
b = list(input())
c = int(input())
for i in range(a):
  if b[i] != b[c-1]:
    b[i] = "*"
print("".join(b))

Buggy submission (verdict: Runtime Error):
a = int(input())
b = list(input())
c = int(input())
for i in range(a):
  if b[i] != b[c]:
    b[i] = "*"
print("".join(b))

Buggy submission (verdict: Runtime Error):
a = int(input())
b = input()
c = int(input())
for i in range(a):
  if b[i] != b[c]:
    b[i] = "*"
print(b)
Problem p03303 (python)

Fixed submission:
a = list(input())
b = int(input())
print("".join(a[::b]))

Buggy submission (verdict: Runtime Error):
print(input()[::int(input())-1])
Problem p03449 (python)

Fixed submission:
n = int(input())
a = [list(map(int,input().split())) for i in range(2)]
ans = 0
for i in range(n):
  k = sum(a[1][i:])+sum(a[0][0:i+1])
  if k > ans:
    ans = k
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [list(map(int,input().split()))]
ans = 0
for i in range(n):
  k = sum(a[0][i:])+sum(a[1][0:i+1])
  if k > ans:
    ans = k
print(ans)
Problem p03457 (python)

Fixed submission:
n = int(input())
a = [list(map(int,input().split())) for i in range(n)]
a.insert(0,[0,0,0])
ans = True
for i in range(1,n+1):
  t = a[i][0]-a[i-1][0]
  xy = a[i][1]+a[i][2]-a[i-1][1]-a[i-1][2]
  if not (t >= xy and t%2 == xy%2):
    ans = False
    break
print("Yes" if ans else "No")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [list(map(int,input().split())) for i in range(n)]
a.insert([0,0,0])
ans = True
for i in range(1,n+1):
  t = a[i][0]-a[i-1][0]
  xy = a[i][1]+a[i][2]-a[i-1][1]-a[i-1][2]
  if not (t >= xy and t%2 == xy%2):
    ans = False
    break
print("Yes" if ans else "No")
Problem p03474 (python)

Fixed submission:
a,b = map(int,input().split())
c = list(input())
ans = True
for i in range(a+b+1):
  if not((i==a and c[i]=="-") or (i!=a and c[i]!="-")):
    ans = False
    break
print("Yes" if ans else "No")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
b = list(input())
ans = True
for i in range(a+b+1):
  if not((i==a and b[i]=="-") or (i!=a and b[i]!="-")):
    ans = False
    break
print("Yes" if ans else "No")
Problem p03547 (python)

Fixed submission:
a = list("ABCDEF")
x,y = input().split()
x = a.index(x)
y = a.index(y)
if x < y:
  print("<")
elif x > y:
  print(">")
else:
  print("=")

Buggy submission (verdict: Runtime Error):
a = list("ABCDEF")
x,y = map(int,input().split())
x = a.index(x)
y = a.index(y)
if x < y:
  print("<")
elif x > y:
  print(">")
else:
  print("=")
Problem p03563 (python)

Fixed submission:
a = int(input())
b = int(input())
print(a+(b-a)*2)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
print(a+(b-a)*2)
Problem p04031 (python)

Fixed submission:
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
n = int(input())
a = list(map(int,input().split()))
h = Decimal(str(sum(a)/n)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
a = list(map(lambda x:(x-h)**2,a))
print(sum(a))

Buggy submission (verdict: Runtime Error):
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
n = int(input())
a = list(map(int,input().split()))
h = Decimal(str(sum(a)/n).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
a = list(map(lambda x:(x-h)**2,a))
print(sum(a))
Problem p02536 (python)

Fixed submission:

class UnionFind:
    def __init__(self, N):
        self.root = list(range(N + 1))
        self.size = [1] * (N + 1)

    def __getitem__(self, x):
        root = self.root
        while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
        return x

    def merge(self, x, y):
        x = self[x]
        y = self[y]
        if x == y:
            return
        sx, sy = self.size[x], self.size[y]
        if sx < sy:
            x, y = y, x
            sx, sy = sy, sx
        self.root[y] = x
        self.size[x] += sy

    def same(self,x,y):
        return  self[x] == self[y]

    def find_max(self):
        return max(self.size)

N,M = map(int, input().split())

uf = UnionFind(N)
merge = uf.merge
same = uf.same

for i in range(M):
    a,b = map(int, input().split())
    merge(a,b)
count = -1
for ind,j in enumerate(uf.root):
    if ind == j:
        count += 1

print(count -1)

Buggy submission (verdict: Runtime Error):
import typing


class DSU:
    '''
    Implement (union by size) + (path compression)
    Reference:
    Zvi Galil and Giuseppe F. Italiano,
    Data structures and algorithms for disjoint set union problems
    '''

    def __init__(self, n: int = 0):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a: int, b: int) -> int:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        x = self.leader(a)
        y = self.leader(b)

        if x == y:
            return x

        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x

        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x

        return x

    def same(self, a: int, b: int) -> bool:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        return self.leader(a) == self.leader(b)

    def leader(self, a: int) -> int:
        assert 0 <= a < self._n

        if self.parent_or_size[a] < 0:
            return a

        self.parent_or_size[a] = self.leader(self.parent_or_size[a])
        return self.parent_or_size[a]

    def size(self, a: int) -> int:
        assert 0 <= a < self._n

        return -self.parent_or_size[self.leader(a)]

    def groups(self) -> typing.List[typing.List[int]]:
        leader_buf = [self.leader(i) for i in range(self._n)]

        result = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)

        return list(filter(lambda r: r, result))

N,M = map(int, input().split())

uf = DSU(N)
merge = uf.merge
same = uf.same

for i in range(M):
    a,b = map(int, input().split())
    merge(a,b)


print(len(uf.groups())-1)
Problem p02603 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
money = 1000
for i in range(N-2):
    today, tomorrow = A[i], A[i+1]
    if today < tomorrow:
        money = (money//today)*tomorrow + money%today
if A[N-2]< A[N-1]:
    money = (money//A[N-2]) * A[N-1] + money%A[N-2]

print(money)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
DP = [[-1 for _1 in range(10000)] for _ in range(N) ]

for i in range(1000//A[0]+1):
    DP[0][i] = 1000 - A[0]*i

max_stock = 1000//A[0]
for j in range(1, N):
    today = A[j]
    DP[j][0] = max(DP[j-1][0], DP[j-1][max_stock] + max_stock*today)
    max_stock = DP[j-1][0]//today
    DP[j][max_stock] =  DP[j-1][0] - max_stock*today




print(DP[N-1][0])
Problem p02608 (python)

Fixed submission:
N = int(input())
arr = [0]*(N)
lim = int(N**0.5 + 1)
for i in range(1,lim):
    for j in range(1,lim):
        for k in range(1,lim):
            num = i**2 + j**2 + k**2 + i*j + j*k + k*i - 1
            if num <= N-1:
                arr[num] += 1

print(*arr, sep='\n')

Buggy submission (verdict: Runtime Error):
N = int(input())
arr = [0]*(N)
lim = int(N**0.5 + 1)
for i in range(1,lim):
    for j in range(1,lim):
        for k in range(1,lim):
            num = i**2 + j**2 + k**2 + i*j + j*k + k*i - 1
            if num <= N:
                arr[num] += 1

print(*arr, sep='\n')
Problem p02645 (python)

Fixed submission:
def solve():
    S = input()
    print(S[:3])


if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
def solve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    
    for i in range(K):
        
        arr = [0] * (N + 1)

        for ind,j in enumerate(A):
            arr[max(ind-j,0)] += 1
            arr[min(ind+j+1, N)] -= 1

        A[0] = arr[0]
        for k in range(N-1):
            A[k+1] = A[k] + arr[k+1]

        if arr[0] ==N and arr[-1] == -N:
            return A
    return A


if __name__ == "__main__":
    ans = solve()
    print(*ans)
Problem p02658 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit()
lim = 10**18

ans = 1
for i in A:
    ans *= i
    if ans > lim:
        print(-1)
        exit()

else:
    if ans >10**18:
        print(-1)
    else:
        print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = list(map(int, input().split()))
B = np.array(A, dtype=np.int64)

lim = 10**18
if len(B[B==0]) >0:
    print(0)
elif N >59:
    print(-1)
else:
    ans = 1
    for i in A:
        ans *= i
        if ans > lim:
            print(-1)
            exit()
    else:
        if ans >10**18:
            print(-1)
        else:
            print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())),dtype=np.int64)


A = np.array(list(map(int, input().split())),dtype=np.int64)
ans = np.prod(A)
if ans > 10**18:
    print(-1)
elif ans< 0:
    print(-1)
else:
    print(ans)
Problem p02696 (python)

Fixed submission:
def solve():
    A,B,N = map(int, input().split())
    if N < B-1:
        print((A*N)//B - A * (N//B))
    else:
        print(((A*(B-1))//B) - A* ((B-1)//B))


if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
import math


def solve():
    A, B, N = map(float, input().split())

    ans = 0
    div_ab = A/B
    div_1b = 1/B
    init_1 = (max(1, int(N)-100000)*A)/B
    init_2 = max(1, int(N)-100000)/B
    start = max(1, int(N)-100000)

    for i in range(max(1, int(N)-100000), int(N) + 1):
        ans = max(math.floor(init_1+div_ab*(i-start)) - A*math.floor(init_2+div_1b*(i-start)),ans)
    if N > B:
        start = max(B-100000,1)
        init_1 = (max(1, int(B-100000)) * A) / B
        init_2 = max(1, int(B-100000)) / B
        for i in range(max(int(B)-100000,1), max(N,int(B)+1)):
            ans = max(math.floor(init_1 + div_ab * (i - start)) - A * math.floor(init_2 + div_1b * (i - start)), ans)

    print(int(ans))


if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
import math


def solve():
    A, B, N = map(float, input().split())

    ans = 0
    div_ab = A/B
    div_1b = 1/B
    init_1 = (max(1, int(N)-100000)*A)/B
    init_2 = max(1, int(N)-100000)/B
    start = max(1, int(N)-100000)

    for i in range(max(1, int(N)-100000), int(N) + 1):
        ans = max(math.floor(init_1+div_ab*(i-start)) - A*math.floor(init_2+div_1b*(i-start)),ans)
    start = max(B-1000,1)
    init_1 = (max(1, int(B-100000)) * A) / B
    init_2 = max(1, int(B-100000)) / B
    for i in range(max(int(B-100000),1), max(N,int(B)+1)):
        ans = max(math.floor(init_1 + div_ab * (i - start)) - A * math.floor(init_2 + div_1b * (i - start)), ans)

    print(int(ans))


if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
import math


def solve():
    A, B, N = map(float, input().split())

    ans = 0
    div_ab = A/B
    div_1b = 1/B
    init_1 = (max(1, int(N)-100000)*A)/B
    init_2 = max(1, int(N)-100000)/B
    start = max(1, int(N)-100000)

    for i in range(max(1, int(N)-100000), int(N) + 1):
        ans = max(math.floor(init_1+div_ab*(i-start)) - A*math.floor(init_2+div_1b*(i-start)),ans)
    start = max(B-1000,1)
    init_1 = (max(1, int(B-100000)) * A) / B
    init_2 = max(1, int(B-100000)) / B
    for i in range(max(B-100000,1), int(B)+1):
        ans = max(math.floor(init_1 + div_ab * (i - start)) - A * math.floor(init_2 + div_1b * (i - start)), ans)

    print(int(ans))


if __name__ == '__main__':
    solve()
Problem p02761 (python)

Fixed submission:
x,m = map(int, input().split())
s=[-1]*m
c=[-1]*m
for i in range(m):
    s[i], c[i] = map(int, input().split())
if x ==1:
    start = 0
else:
    start = 10**(x-1)

for j in range(start, 1000):
    num = str(j)
    for k1, k2 in zip(s, c):
        if num[k1-1] != str(k2):
            break
    else:  #すべて一致したとき
        print(j)
        break
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
#C - Guess The Number https://atcoder.jp/contests/abc157/tasks/abc157_c
x,m = map(int, input().split())
s=[-1]*m
c=[-1]*m
num = [-1]*3
ans = 0
for i in range(m):
    s[i], c[i] = map(int, input().split())

for j, l in zip(s, c):
    if num[j-1] == -1:
        num[j-1] = l
    elif num[j-1] != l:
        print(-1)
        break

    #num[j-1]とlが同じときは何もされない
else:
    num = list(map(lambda x: x*0 if x<0 else x, num))
    for k in num:
        ans = ans *10 + k
    if ans != 0 and num>1:
        print(ans)
    else:
        print(-1)
Problem p02844 (python)

Fixed submission:
def solve():
    N = int(input())
    S = input()
    count = 0
    for i in range(0,1000):
        num = str(i).zfill(3)
        digit = 0
        for j in range(N):
            if S[j] == num[digit]:
                digit += 1
            if digit == 3:
                break
        if digit ==3:
            count += 1

    print(count)

if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
N = int(input())
S = int(input())
count = 0
for i in range(0,1000):
    num = [i//100, (i//10)%10, i%10]
    digit = 0
    for j in range(N):
        if S[j] == num[digit]:
            digit += 1
        if digit == 3:
            break
    else:
        continue
    count += 1

print(count)
Problem p03087 (python)

Fixed submission:
n, q = map(int, input().split())
s = input()
ans = [0 for _ in range(n)]
for i in range(len(s) - 1):
    if s[i:i+2] == "AC":
        ans[i+1] = ans[i]+1
    else:
        ans[i+1] = ans[i]
    #1indexの累積和

for j in range(q):
    l, r = map(int, input().split())
    print(ans[r-1]-ans[l-1])

Buggy submission (verdict: Runtime Error):
n,q = map(int, input().split())
s = input()
ruiseki = [0]*(n+1)
for j in range(n):
    ruiseki[j+1] = ruiseki[j]
    if s[j] =="A" and s[j+1]=="C":
        ruiseki[j+1] += 1
for i in range(q):
    l, r = map(int, input().split())
    print(ruiseki[r-1] - ruiseki[l-1])
Problem p03836 (python)

Fixed submission:
sx, sy, tx, ty = map(int, input().split())
route = ""
dx, dy = tx - sx, ty - sy
path1 = "R" * dx + "U" * dy
path2 = "L" * dx + "D" * dy
dx, dy = dx + 1, dy + 1
path3 = "D" + "R" * dx + "U" * dy + "L"
path4 = "U" + "L" * dx + "D" * dy + "R"
ans =path1 + path2 + path3 + path4
print( ans)

Buggy submission (verdict: Runtime Error):
def routing(x, y, z = 0):
    route = ""
    for i in range(2):
        if z:
            if dy:
                route += "D"
            else:
                route += "U"
        if x:
            route += "R"*(dx+z)
            x = not x
        else:
            route += "L"+(dx+z)
            x = not x
        if y:
            route += "U"*(dy+z)
            y = not y
        elif y:
            route += "D"*(dy+z)
            y = not y
        if z:
            if dx:
                route += "L"
            else:
                route += "R"
    return route

sx, sy, tx, ty = map(int, input().split())
route =""
dx = tx-sx
dy = ty-sy
x = dx>0
y = dy>0
route += routing(dx,dy)
route += routing(dx,dy,1)
print(route)

Buggy submission (verdict: Runtime Error):
def routing(x, y, z = 0):
    route = ""
    for i in range(2):
        if z:
            if dy:
                route += "D"
            else:
                route += "U"
        if x:
            route += "R"*(dx+z)
            x = not x
        else:
            route += "L"+(dx+z)
            x = not x
        if y:
            route *= "U"*(dy+z)
            y = not y
        elif y:
            route *= "D"*(dy+z)
            y = not y
        if z:
            if dx:
                route += "L"
            else:
                route += "R"
    return route

sx, sy, tx, ty = map(int, input().split())
route =""
dx = tx-sx
dy = ty-sy
x = dx>0
y = dy>0
route += routing(dx,dy)
route += routing(dx,dy,1)
print(route)
Problem p04044 (python)

Fixed submission:
N, _ = [int(x) for x in input().split()]
S = sorted([input() for _ in range(N)])
print(''.join(S))

Buggy submission (verdict: Runtime Error):
l, n = map(int, input().split())
s = [input() for _ in range(n)]
s.sort()
print("".join(s))

Buggy submission (verdict: Runtime Error):
l, n = map(int, input().split())
s = sorted([input() for _ in range(n)])
print("".join(s))

Buggy submission (verdict: Runtime Error):
l, n = map(int, input().split())
s = sorted([str(input()) for _ in range(n)])
print("".join(s))