Chef and Socks
Source: codechef
Difficulty: 212

Chef and Socks
Chef needs$A$dollars to buy himself a new pair of socks for Christmas.
If he has$X$dollars saved up and his parents give him an additional$Y$dollars, will Chef be able to buy new socks?
Input Format
The first and only line of input will contain$3$space-separated integers$A, X,$and$Y$— the cost of the socks, the amount of money Chef has saved up, and the additional money he received from his parents.
Output Format
Output a single string denoting the answer:
"YES"
if Chef can afford the socks, and
"NO"
otherwise (without quotes).
Each character of the output may be printed in either uppercase or lowercase, i.e., the strings
NO
,
No
,
nO
, and
no
will all be treated as equivalent.
Constraints$1 \leq A,X,Y \leq 100$Sample 1:
Explanation:
Chef has$40$dollars and his parents gave him$88$dollars. Now he has$40+88=128$dollars which allows him to buy socks which cost only$58$dollars.

Sample Input:
58 40 88

Sample Output:
YES

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

int main() {
    // your code goes here
    int A,X,Y ;
    cin>>A>>X>>Y;
    if(X+Y>=A){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;

}

Go solution:
package main
import "fmt"

func main(){
    var A,X,Y int
//  fmt.Println("Enter the cost of socks you want to purchase")
    fmt.Scan(&A)
//  fmt.Println("Enter the Total money saved")
    fmt.Scan(&X)
//  fmt.Println("Enter the total money recieved by parents")
    fmt.Scan(&Y)
    
    if (X+Y>=A) {
        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
    {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        if (X + Y >= A) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }
}

JavaScript solution:
// your code goes here
let stdInput = "";

process.stdin.on("data", input => stdInput += input);
process.stdin.on("end", () => {
    const[a, x, y] = stdInput.trim().split(" ").map(Number);
     let sum = (x + y);
      if(sum >= a){
       console.log("yes");
   }
   else{
       console.log("No")
   }
});

Python solution:
A, X, Y = map(int, input().split())
if A <= X + Y:
    print("YES")
else:
    print("NO")

Ruby solution:
# Read input and split into components
input = gets.to_s.strip.split

# Convert to integers
a = input[0].to_i
x = input[1].to_i
y = input[2].to_i

# Check if Chef can afford the socks
if a <= x + y
  puts "YES"
else
  puts "NO"
end