Triangle Checking
Source: codechef
Difficulty: 165

Triangle Checking
You are given$3$sticks of length$A$,$B$and$C$.
Please check if they can be the side lengths of a valid non-degenerate triangle.
Recall that$A, B$and$C$can be the side-lengths of a non-degenerate triangle if and only if each of the following$3$conditions hold:$A + B > C$$B + C > A$$A + C > B$Input Format
The first and only line of input contains$3$integers -$A, B$and$C$.
Output Format
For each test case, output on a new line$\text{Yes}$if the side lengths form a valid triangle, and else$\text{No}$.
It is allowed to print each character in either case. For example,$\text{YES}$,$\text{yes}$and$\text{yEs}$will all be accepted as positive responses.
Constraints$1 \le A, B, C \le 10$Sample 1:
Explanation:
All the conditions are satisfied and so it is a valid triangle.
Sample 2:
Input
Output
4 6 2
No
Explanation:
The condition$A + C > B$is not true here, hence it is not valid.
Sample 3:
Input
Output
9 9 9
Yes

Sample Input:
2 3 4

Sample Output:
Yes

C++ solution:
#include <bits/stdc++.h>
using namespace std;

int main() {
    // your code goes here
int a,b,c;
cin >> a>>b>>c;
if (a+b>c && b+c>a && a+c>b) cout<< "Yes";
else cout<< "No";
}

Go solution:
package main
import "fmt"

func main(){
    // your code goes here
    var a, b, c int
    fmt.Scan(&a, &b, &c);
    if(a+b > c && b+c>a && a+c>b){
        fmt.Println("YES")
    }else{
        fmt.Println("NO")
    }
}

Java solution:
import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        if(a+b > c && b+c>a && a+c >b)
        {
            System.out.println("YES");
        }
        else
        {
            System.out.println("NO");
        }
    }
}

JavaScript solution:
process.stdin.setEncoding('utf-8');
let input = '';

process.stdin.on('data', function (Prachi) {
    input += Prachi;
});

process.stdin.on('end', function () {
    let values = input.trim().replace(/\s+/g, ' ').split(' ').map(Number);

    if (values.length !== 3 || values.some(isNaN)) {
        console.log("Invalid Input");
        return;
    }

    let [A, B, C] = values;

    if (A > 0 && B > 0 && C > 0) {
        if (A + B > C && B + C > A && A + C > B) {
            console.log("YES");
        } else {
            console.log("NO");
        }
    } else {
        console.log("Invalid Triangle");
    }
});

Python solution:
# cook your dish here
A,B,C=map(int,input().split())
if (A+B>C and B+C>A and A+C>B):
    print("YES")
else:
    print("NO")

Ruby solution:
begin
  # Read input and validate
  input = gets.to_s.chomp
  a, b, c = input.split.map(&:to_i)

  # Validate input constraints
  if [a, b, c].any? { |x| x < 1 || x > 10 }
    puts "No"
    exit
  end

  # Check triangle inequality conditions
  if a + b > c && b + c > a && a + c > b
    puts "Yes"
  else
    puts "No"
  end
rescue => e
  puts "No"
end