Three Pairwise Maximums (Codeforces 1385A)
Tags: Math, math

You are given three positive (i.e. strictly greater than zero) integers $$$x$$$, $$$y$$$ and $$$z$$$.Your task is to find positive integers $$$a$$$, $$$b$$$ and $$$c$$$ such that $$$x = \max(a, b)$$$, $$$y = \max(a, c)$$$ and $$$z = \max(b, c)$$$, or determine that it is impossible to find such $$$a$$$, $$$b$$$ and $$$c$$$.You have to answer $$$t$$$ independent test cases. Print required $$$a$$$, $$$b$$$ and $$$c$$$ in any (arbitrary) order.

Input: The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow.The only line of the test case contains three integers $$$x$$$, $$$y$$$, and $$$z$$$ ($$$1 \le x, y, z \le 10^9$$$).

Output: For each test case, print the answer:  "NO" in the only line of the output if a solution doesn't exist;  or "YES" in the first line and any valid triple of positive integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^9$$$) in the second line. You can print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. 


Sample Inputs:
5
3 2 3
100 100 100
50 49 49
10 30 20
1 1000000000 1000000000

Sample Outputs:
YES
3 2 1
YES
100 100 100
NO
NO
YES
1 1 1000000000

Solution (Python):
ans = []
t = int(input())
for _ in range(t):
    (x, y, z) = sorted(map(int, input().split()))
    if x == y == z:
        ans.append('YES\n{} {} {}'.format(x, x, x))
    elif y != z:
        ans.append('NO')
    else:
        ans.append('YES\n{} {} {}'.format(x, x, z))
print(*ans, sep='\n')

Solution (Python):
ans = []
for _ in range(int(input())):
    xyz = sorted([*map(int, input().split())])
    x = xyz[0]
    z = xyz[2]
    if xyz.count(z) > 1:
        ans.extend(['YES', '%d %d %d' % (x, x, z)])
    else:
        ans.append('NO')
print('\n'.join(ans))

Solution (Python):
import os
import sys
from io import BytesIO, IOBase
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
sys.setrecursionlimit(100000000)
mod = 1000000007

def inp():
    return int(input())

def strng():
    return input().strip()

def jn(x, l):
    return x.join(map(str, l))

def strl():
    return list(input().strip())

def mul():
    return map(int, input().strip().split())

def mulf():
    return map(float, input().strip().split())

def arr():
    return list(map(int, input().strip().split()))

def lis():
    return list(input().split(' '))

def ceil(x):
    return int(x) if x == int(x) else int(x) + 1

def ceildiv(x, d):
    return x // d if x % d == 0 else x // d + 1

def out(y):
    return print(y)

def flush():
    return stdout.flush()

def stdstr():
    return stdin.readline()

def stdint():
    return int(stdin.readline())

def stdpr(x):
    return stdout.write(str(x))

def IO():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')

def code():
    loop_solve()

def loop_solve():
    for _ in range(int(input())):
        work()

def solve():
    work()

def work():
    li = map(int, input().strip().split())
    li = sorted(li)
    if li[2] == li[1]:
        print('YES')
        print(li[0], li[0], li[2])
    else:
        print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = 'x' in file.mode or 'r' not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            (self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b'\n') + (not b)
            ptr = self.buffer.tell()
            (self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            (self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode('ascii'))
        self.read = lambda : self.buffer.read().decode('ascii')
        self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
    return sys.stdin.readline().rstrip('\r\n')
if __name__ == '__main__':
    code()