TnT/CodeNet4Repair huggingface dataset:
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):
s=input()
t=input()
u='UNRESTORABLE'
if len(s)>=len(t):
  for i in range(len(s)-len(t)+1):
    f=0
    for j in range(i,i+len(t)):
      if s[j]!='?' and s[j]!=t[j-i]:
        f=1
    if f==0:
      for j in range(i,i+len(t)):
        if s[j]!='?':
          s=s[:j]+t[j-i]+s[j+1:]
      s.replace('?','a')
      u=s
      break
print(u)

Fixed, accepted submission:
s=input()
t=input()
u='UNRESTORABLE'
a=[]
if len(s)>=len(t):
  for i in range(len(s)-len(t)+1):
    f=0
    for j in range(i,i+len(t)):
      if s[j]!='?' and s[j]!=t[j-i]:
        f=1
    if f==0:
      m=s[:i]+t+s[i+len(t):]
      m=m.replace('?','a',50)
      a.append(m)
if len(a)==0:
  print(u)
else:
  a.sort()
  print(a[0])
Problem:
Print the K-th element of the following sequence of length 32:                1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51

Incorrect submission (verdict: Wrong Answer):
M=[0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
M[K]

Fixed, accepted submission:
M=[0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(int(M[K]))
Problem:
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.

Incorrect submission (verdict: Wrong Answer):
a, b = map(int, input().split())

if a * b / 2 == 0:
    print('odd')
else:
    print('even')

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

if a * b % 2 == 0:
    print("Even")
else:
    print("Odd")
Problem:
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}.  Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).

Incorrect submission (verdict: Wrong Answer):
h,w=map(int,input().split())
list=[0]*(h*2)
for i in range(h):
	c=input()
	list[i]=c
	list[i+h]=c
for j in range(len(list)):
	print(list[j])

Fixed, accepted submission:
h,w=map(int,input().split())
for i in range(h):
	c=input()
	print(c)
	print(c)
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):
#ABC 173 C - H and V
import numpy as np

h,w,k = map(int,input().split())
c = np.zeros((h,w)).astype('str')
for i in range(h):
    s = input()
    for j,a in enumerate(s):
        c[i,j] = a
    
print(c)
cnt = 0
for o in range(2**h):
    for l in range(2**w):
        black = 0
        for m in range(h):
            for n in range(w):
                if ((o>>m)&1==0) and ((l>>n)&1==0) and (c[m,n]=='#'):
                    black += 1
        if black == k:
            cnt += 1
print(cnt)

Fixed, accepted submission:
#ABC 173 C - H and V
import numpy as np

h,w,k = map(int,input().split())
c = np.zeros((h,w)).astype('str')
for i in range(h):
    s = input()
    for j,a in enumerate(s):
        c[i,j] = a
        
cnt = 0
for o in range(2**h):
    for l in range(2**w):
        black = 0
        for m in range(h):
            for n in range(w):
                if ((o>>m)&1==0) and ((l>>n)&1==0) and (c[m,n]=='#'):
                    black += 1
        if black == k:
            cnt += 1
print(cnt)
Problem:
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R.  Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan.  Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.

Incorrect submission (verdict: Wrong Answer):
A,B,C,D = map(int,input().split())

r=A+B
l=C+D

if r>l:
    print("Right")
elif l>r:
    print("Left")
else:
    print("Balanced")

Fixed, accepted submission:
A,B,C,D = map(int,input().split())

l=A+B
r=C+D

if r>l:
    print("Right")
elif l>r:
    print("Left")
else:
    print("Balanced")
Problem:
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions:    * Question 1: Are you subscribing to Newspaper X?   * Question 2: Are you subscribing to Newspaper Y?  As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2.  What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y?  Write a program to answer this question.

Incorrect submission (verdict: Wrong Answer):
n,a,b=map(int,input().split())

ans1=min(a,b)
ans2=a+b-n
print(ans1,ans2)

Fixed, accepted submission:
n,a,b=map(int,input().split())

ans1=min(a,b)
ans2=max(0,a+b-n)
print(ans1,ans2)
Problem:
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament.  The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day.  Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.

Incorrect submission (verdict: Wrong Answer):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
	c = 0
	s = input()
	for t in s:
		if t == 'o':
			c += 1
		print(t, c)
	
	if c >= 8:
		print('YES')
	else:
		print('NO')


if __name__ == '__main__':
	import sys
	sys.exit(main())


Fixed, accepted submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
	c = 0
	s = input()
	for t in s:
		if t == 'o':
			c += 1
	
	c += 15 - len(s)
	
	if c >= 8:
		print('YES')
	else:
		print('NO')


if __name__ == '__main__':
	import sys
	sys.exit(main())
Problem:
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.

Incorrect submission (verdict: Wrong Answer):
import math
a,b=map(str,input().split())
ab=a+b
ab=int(ab)
if type(math.sqrt(ab))=='int':print('Yes')
else:print('No')

Fixed, accepted submission:
import math
a,b=map(str,input().split())
ab=a+b
ab=int(ab)
if math.sqrt(ab).is_integer()==True:print('Yes')
else:print('No')
Problem:
Write a program which computes the area of a shape represented by the following three lines:      $y = x^2$   $y = 0$   $x = 600$       It is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles in the shape as shown in the following figure:     $f(x) = x^2$       The approximative area $s$ where the width of the rectangles is $d$ is:      area of rectangle where its width is $d$ and height is $f(d)$ $+$   area of rectangle where its width is $d$ and height is $f(2d)$ $+$   area of rectangle where its width is $d$ and height is $f(3d)$ $+$   ...   area of rectangle where its width is $d$ and height is $f(600 - d)$    The more we decrease $d$, the higer-precision value which is close to $72000000$ we could obtain. Your program should read the integer $d$ which is a divisor of $600$, and print the area $s$.

Incorrect submission (verdict: Wrong Answer):
d = int(input())
print(sum(d * (i ** 2) for i in range(int(600/d))))

Fixed, accepted submission:
t = 0
while t == 0:
    try:
        d = int(input())
    except:
        break
    else:
        print(sum(d * ((i * d) ** 2) for i in range(int(600/d))))
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 = str(input())
for i in range(len(s)):
    s = s[:-1]
    print(s)
    if len(s) % 2 == 0:
        flag = 0
        for j in range(int(len(s)/2)):
            if s[j] == s[j+int((len(s)/2))]:
                flag += 1
        if flag == (int(len(s)/2)):
            print(len(s))
            break

Fixed, accepted submission:
s = str(input())
for i in range(len(s)):
    s = s[:-1]
    if len(s) % 2 == 0:
        flag = 0
        for j in range(int(len(s)/2)):
            if s[j] == s[j+int((len(s)/2))]:
                flag += 1
        if flag == (int(len(s)/2)):
            print(len(s))
            break
Problem:
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by IDs $1, 2, ... n$.

Incorrect submission (verdict: Wrong Answer):
# -*- coding: utf_8 -*-

level = True
def debug(v):
    if level:
        print(v)

NOT_FOUND = 0
ENQUEUED = 1
FOUND = 2

def bfs(graph, status, results):
    queue = []
    queue.append(1)
    while len(queue) != 0:
        node = queue.pop(0)
        status[node] = FOUND
        d = results[node]
        for edge in graph[node]:
            if status[edge] != NOT_FOUND:
                continue
            status[edge] = ENQUEUED
            queue.append(edge)
            results[edge] = d + 1

    return results

if __name__ == "__main__":
    n = int(input())
    status = [NOT_FOUND] * (n + 1)
    results = [0] * (n + 1)
    g = [[0]]

    for i in range(n):
        row = [int(x) for x in input().split()]
        row.pop(0)
        row.pop(0)
        g.append(row)

    bfs(g, status, results)
    results.pop(0)

    print(results)
    for idx, v in enumerate(results):
        print(idx + 1, v)
        

Fixed, accepted submission:
# -*- coding: utf_8 -*-

level = False
def debug(v):
    if level:
        print(v)

NOT_FOUND = 0
ENQUEUED = 1
FOUND = 2

def bfs(graph, status, results):
    queue = []
    queue.append(1)
    while len(queue) != 0:
        node = queue.pop(0)
        status[node] = FOUND
        d = results[node]
        for edge in graph[node]:
            if status[edge] != NOT_FOUND:
                continue
            status[edge] = ENQUEUED
            queue.append(edge)
            results[edge] = d + 1

    return results

if __name__ == "__main__":
    n = int(input())
    status = [NOT_FOUND] * (n + 1)
    results = [-1] * (n + 1)
    results[1] = 0
    g = [[0]]

    for i in range(n):
        row = [int(x) for x in input().split()]
        row.pop(0)
        row.pop(0)
        g.append(row)

    bfs(g, status, results)
    results.pop(0)

    for idx, v in enumerate(results):
        print(idx + 1, v)
Problem:
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total?  Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.

Incorrect submission (verdict: Wrong Answer):

a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for ai in range(a + 1):
    for bi in range(b + 1):
        for ci in range(c + 1):
            if 500 == 500 * ai + 100 * bi + 50 *ci:
                count += 1
print(count)

Fixed, accepted submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for ai in range(a + 1):
    for bi in range(b + 1):
        for ci in range(c + 1):
            if x == 500 * ai + 100 * bi + 50 *ci:
                count += 1
print(count)
Problem:
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.  Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?

Incorrect submission (verdict: Wrong Answer):
N=int(input())
D=[]
for i in range(N):
    D.append(input(int()))
set_D=set(D)
ans=len(set_D)
print(ans)

Fixed, accepted submission:
N=int(input())
D=[]
for i in range(N):
    D.append(int(input()))
set_D=set(D)
ans=len(set_D)
print(ans)
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):
def che(s):
    lens = len(s)
    if s[:lens//2] == s[lens//2:]:
        TF = True
    else:
        TF = False
    return TF

S = input()
TF = False
ind = 0

if len(S)%2 == 1:
    S2 = S[:-2]
else:
    S2 = S[:-2]
print(S2)

while True:
    TF = che(S2)
    if TF == False:
        S2 = S2[:-2]
    else:
        ans = len(S2)
        print(ans)
        exit()


Fixed, accepted submission:
def che(s):
    lens = len(s)
    if s[:lens//2] == s[lens//2:]:
        TF = True
    else:
        TF = False
    return TF

S = input()
TF = False
ind = 0

if len(S)%2 == 1:
    S2 = S[:-2]
else:
    S2 = S[:-2]
while True:
    TF = che(S2)
    if TF == False:
        S2 = S2[:-2]
    else:
        ans = len(S2)
        print(ans)
        exit()
Problem:
Given are N integers A_1,\ldots,A_N.  We will choose exactly K of these elements. Find the maximum possible product of the chosen elements.  Then, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).

Incorrect submission (verdict: Wrong Answer):
N,K=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7

if N==K: 
    ans=1
    for i in range(N):
        ans*=A[i]
        ans%=mod
    print(ans)
    exit()
if max(A)<0 and K%2==1: 
    A.sort(reverse=True)
    ans=1
    for i in range(K):
        ans*=A[i]
        ans%=mod
    print(ans)
    exit()

plus=[]
minus=[]
for i in range(N):
    if A[i]>=0:
        plus.append(A[i])
    else:
        minus.append(A[i])

plus.sort(reverse=True) #5,3,1
minus.sort() #-5,-3,-1




Fixed, accepted submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7

if N==K: 
    ans=1
    for i in range(N):
        ans*=A[i]
        ans%=mod
    print(ans)
    exit()
if max(A)<0 and K%2==1: 
    A.sort(reverse=True)
    ans=1
    for i in range(K):
        ans*=A[i]
        ans%=mod
    print(ans)
    exit()

plus=[]
minus=[]
for i in range(N):
    if A[i]>=0:
        plus.append(A[i])
    else:
        minus.append(A[i])
plus.sort(reverse=True) #5,3,1
minus.sort() #-5,-3,-1
plus_k=0
minus_k=0
if K%2==0:
    ans=1
else:
    ans=plus[0]
    plus_k=1

for _ in range(K):
    if plus_k+minus_k==K:
        break
    if plus_k>=len(plus)-1:
        ans*=minus[minus_k]*minus[minus_k+1]%mod
        ans%=mod
        minus_k+=2
        continue
    if minus_k>=len(minus)-1:
        ans*=plus[plus_k]*plus[plus_k+1]%mod
        ans%=mod
        plus_k+=2
        continue
    if plus[plus_k]*plus[plus_k+1]>minus[minus_k]*minus[minus_k+1]:
        ans*=plus[plus_k]*plus[plus_k+1]%mod
        ans%=mod
        plus_k+=2
        continue
    else:
        ans*=minus[minus_k]*minus[minus_k+1]%mod
        ans%=mod
        minus_k+=2
        continue
print(ans)
Problem:
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10.  Given an integer N, determine whether it is a Harshad number.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
print("Yes" if sum(map(int, str(N))) % N == 0 else "No")

Fixed, accepted submission:
N = int(input())
print("Yes" if N % sum(map(int, str(N))) == 0 else "No")
Problem:
E869120 has A 1-yen coins and infinitely many 500-yen coins.   Determine if he can pay exactly N yen using only these coins.

Incorrect submission (verdict: Wrong Answer):
N=int(input())
A=int(input())
if((N-A)%500==0 or N<=A):
  print("Yes")
else:
  print("No")
  

Fixed, accepted submission:
N=int(input())
A=int(input())
if(N%500<=A):
  print("Yes")
else:
  print("No")
Problem:
There is a game that involves three variables, denoted A, B, and C.  As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by a string s_i. If s_i is `AB`, you must add 1 to A or B then subtract 1 from the other; if s_i is `AC`, you must add 1 to A or C then subtract 1 from the other; if s_i is `BC`, you must add 1 to B or C then subtract 1 from the other.  After each choice, none of A, B, and C should be negative.  Determine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.

Incorrect submission (verdict: Wrong Answer):
print('No')

Fixed, accepted submission:
import sys
sys.setrecursionlimit(10**6)
N,A,B,C = map(int,input().split())
Q = []
ans = []
f = 0
def dfs(f,a,b,c):
    if f == N:return True
    if Q[f] == 'AB':
        if a+b == 0:return False
        if b>0 and dfs(f+1,a+1,b-1,c):
            ans.append('A')
            return True
        if a>0 and dfs(f+1,a-1,b+1,c):
            ans.append('B')
            return True
        
        return False
    if Q[f] == 'BC':
        if c+b == 0:return False
        if c>0 and dfs(f+1,a,b+1,c-1):
            ans.append('B')
            return True
        if b>0 and dfs(f+1,a,b-1,c+1):
            ans.append('C')
            return True
        
        return False
    if Q[f] == 'AC':
        if a+c == 0:return False
        if c>0 and dfs(f+1,a+1,b,c-1):
            ans.append('A')
            return True
        if a>0 and dfs(f+1,a-1,b,c+1):
            ans.append('C')
            return True
        
        return False
    

for i in range(N):
    s = input()
    Q.append(s)
dfs(0,A,B,C)
# print(ans)
if len(ans) == N:
    print('Yes')
    ans = ans[::-1]
    for i in ans:
        print(i)
else:
    print('No')
Problem:
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B.  The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y.  One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control.  If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out.    * X < Z \leq Y   * x_1, x_2, ..., x_N < Z   * y_1, y_2, ..., y_M \geq Z  Determine if war will break out.

Incorrect submission (verdict: Wrong Answer):
def main():
    n, m, x, y = list(map(int, input().split()))
    x_list = list(map(int, input().split()))
    y_list = list(map(int, input().split()))
    x_list.append(x)
    y_list.append(y)

    zx = max(x_list) + 1
    zy = min(y_list)

    if zx > zy :
        print('War')

    print('No war')


if __name__ == '__main__':
    main()



Fixed, accepted submission:
def main():
    n, m, x, y = list(map(int, input().split()))
    x_list = list(map(int, input().split()))
    y_list = list(map(int, input().split()))
    x_list.append(x)
    y_list.append(y)

    zx = max(x_list) + 1
    zy = min(y_list)

    if zx > zy :
        print('War')
    else:
        print('No War')


if __name__ == '__main__':
    main()
Problem:
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.

Incorrect submission (verdict: Wrong Answer):
import sys
s=input()
t=input()

sn=[ord(s[i]) for i in range(len(s))]
tn=[ord(t[i]) for i in range(len(t))]

sn.sort()
tn.sort()

for i in range(min(len(tn), len(sn))):
    if tn[i] > sn[i]:
        print('Yes')
        sys.exit()
    elif tn[i] < sn[i]:
        print('No')
        sys.exit()
print('Yes')

Fixed, accepted submission:
import sys
s=input()
t=input()

sn=[ord(s[i]) for i in range(len(s))]
tn=[ord(t[i]) for i in range(len(t))]

sn.sort()
tn.sort(reverse=True)

for i in range(min(len(tn), len(sn))):
    if tn[i] > sn[i]:
        print('Yes')
        sys.exit()
    elif tn[i] < sn[i]:
        print('No')
        sys.exit()

if len(tn) > len(sn):
    print('Yes')
else:
    print('No')
Problem:
Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions.  You are given two strings O and E. O contains the characters at the odd- numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order. Restore the original password.

Incorrect submission (verdict: Wrong Answer):
o = input()
e = input()
for i,a in enumerate(o):
    for j,b in enumerate(e):
        if(i == j):
            print(a + b, end = '')
    if i == len(o) - 1:
        print(a)


Fixed, accepted submission:
o = input()
e = input()
a = list(zip(range(0,len(o) * 2,2), list(o)))
b = list(zip(range(1,len(e) * 2,2),list(e)))
print(''.join(map(lambda x: x[1], sorted(a + b))))