Icecream and Cone
Source: codechef
Difficulty: 226

Icecream and Cone
Chef has$X$cones and$Y$scoops of ice cream. Each ice cream cone requires exactly one cone and one scoop of ice cream.
Your task is to determine the
maximum
number of ice cream cones Chef can make with the available ingredients.
Input Format
Input will contain two integers$X$and$Y$- the number of cones and ice cream scoops, respectively.
Output Format
Output the maximum number of ice cream cones Chef can make.
Constraints$1 \leq X \leq 100$$1 \leq Y \leq 100$Sample 1:
Explanation:
Chef has 10 cones and 5 scoops of ice cream. Chef can make a maximum of 5 ice cream cones.

Sample Input:
10 5

Sample Output:
5

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

int main() {
    // your code goes here
    int x,y;
    cin>>x>>y;
    if(x>y){
        cout<<y<<endl;
    }
    else{
        cout<<x<<endl;
    }
}

Go solution:
package main
import "fmt"

func main(){
    // your code goes here
    var X,Y int
//  fmt.Println("Enter the number of cones")
    fmt.Scan(&X)
//  fmt.Println("Enter the number of ice cream")
    fmt.Scan(&Y)
    if X==Y{
        fmt.Println(X)
    }else if X<Y{
        fmt.Println(X)
    }else {
        fmt.Println(Y)
    }
}

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 result = Math.min(a,b);
        System.out.println(result);
    }
}

JavaScript solution:
process.stdin.resume(),process.stdin.setEncoding("utf-8");let inputString="",currentLine=0,linesNumber=4;function getline(){return 
    inputString[currentLine++]}process.stdin.on("data",n=>{let t="\n";"win32"===process.platform&&(t="\r\n"),(inputString+=n).split(t).length
    >=linesNumber+1&&(inputString=inputString.split(t),process.stdin.pause(),main())});

linesNumber = 1;
function main() {
    let input = getline().split(' '); 

    let x = Number(input[0]);
    let y = Number(input[1]);

    console.log(x < y ? x : y);
}

Python solution:
# cook your dish here
x,y=map(int,input().split())
if x>y:
    print(y)
else:
    print(x)

Ruby solution:
# Read input safely with explicit error handling
begin
  input = gets
  if input.nil? || input.strip.empty?
    puts 0
    exit
  end

  x, y = input.strip.split.map(&:to_i)
  x = 0 if x.nil?
  y = 0 if y.nil?

  puts [x, y].min
rescue StandardError
  puts 0
end