Max Sixers
Source: codechef
Difficulty: 216

Max Sixers
Your favourite cricket player played very well today. He made$X (100 \le X \le 200)$runs from exactly$100$balls. Each ball he scored either$0$,$1$,$2$,$3$,$4$or$6$runs.
Unfortunately you missed the match. So now, you are wondering what is the maximum number of sixers he could have hit? A sixer is a ball where you score$6$runs.
Input Format
The first and only line of input contains$X$, the total number of runs scored.
Output Format
For each test case, output on a new line the maximum number of$6$s.
Constraints$100 \le X \le 200$Sample 1:
Explanation:
The player could have scored$6$s on$16$balls,$4$on$1$ball and then$0$on the remaining$83$balls.
Sample 2:
Input
Output
150
25
Explanation:
The player could have scored$6$on$25$balls, and then$0$on$75$balls.

Sample Input:
100

Sample Output:
16

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

int main()
{
    int a;
    cin >> a;
    cout << (a / 6) << endl;
    return 0;
}

Go solution:
package main

import (
    "fmt"
)

func main() {
    var mangoes int // Total runs scored
    fmt.Scan(&mangoes)

    apples := 100          // Total balls played
    bananas := 6           // Each six gives 6 runs
    grapes := mangoes / 6  // Initial max possible sixes

    for grapes >= 0 {
        cherries := apples - grapes           // Remaining balls
        oranges := mangoes - grapes*bananas   // Runs to be covered by remaining balls

        // Check if remaining runs can be made using the remaining balls
        // Minimum runs per ball = 0, maximum = 4 => total max possible = cherries * 4
        if oranges <= cherries*4 {
            fmt.Println(grapes)
            return
        }
        grapes--
    }
}

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 n=sc.nextInt();
        int res=n/6;
        System.out.println(res);
    }
}

JavaScript solution:
// your code goes here
let stdInput = "";
process.stdin.on("data", input => stdInput += input);
process.stdin.on("end", () => {
    const X = parseInt(stdInput.trim());

    let maxSixes = 0;

    for (let s = 0; s <= 100; s++) {
        let sixRuns = s * 6;
        let remainingRuns = X - sixRuns;
        let remainingBalls = 100 - s;

        if (remainingRuns >= 0 && remainingRuns <= 4 * remainingBalls) {
            maxSixes = s;
        }
    }

    console.log(maxSixes);
});

Python solution:
# cook your dish here
x=int(input())
print(x//6)

Ruby solution:
# Read input and convert to integer
x = gets.to_i

# Calculate maximum number of sixers (6-run hits)
max_sixers = x / 6

# Output the result
puts max_sixers