B - Heavy Snake
Source: atcoder
Difficulty: 200

Problem Statement
There are
N
snakes.
Initially, the thickness of the
i
-th snake is
T_i
, and its length is
L_i
.
The weight of a snake is defined as the product of its thickness and length.
For each integer
k
satisfying
1 \leq k \leq D
, find the weight of the heaviest snake when every snake's length has increased by
k
.
Constraints
1 \leq N, D \leq 100
1 \leq T_i, L_i \leq 100
All input values are integers.
Input
The input is given from Standard Input in the following format:
N
D
T_1
L_1
T_2
L_2
\vdots
T_N
L_N
Output
Print
D
lines. The
k
-th line should contain the weight of the heaviest snake when every snake's length has increased by
k
.
Sample Input 1
4 3
3 3
5 1
2 4
1 10
Sample Output 1
12
15
20
When every snake’s length has increased by
1
, the snakes' weights become
12, 10, 10, 11
, so print
12
on the first line.
When every snake’s length has increased by
2
, the snakes' weights become
15, 15, 12, 12
, so print
15
on the second line.
When every snake’s length has increased by
3
, the snakes' weights become
18, 20, 14, 13
, so print
20
on the third line.
Sample Input 2
1 4
100 100
Sample Output 2
10100
10200
10300
10400

C++ solution:
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

typedef int64_t ll;
 
int32_t main() {
	optimizar_io
	int n, d;
	array<int,100> t, l;

	cin >> n >> d;
	for (int i = 0; i < n; i++) cin >> t[i] >> l[i];	
	for (int k = 1; k <= d; k++) {
		int mx = 0;
		for (int i = 0; i < n; i++) {
			mx = max(mx, t[i] * (l[i] + k));
		}	
		cout << mx << "\n";
	}
	return 0;
}
/* stuff you should look for:
	* int overflow, array bounds
	* special cases (n=1?), even odd
	* DON'T GET STUCK ON ONE APPROACH
*/

Go solution:
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func outSlice[T any](s []T) {
	for i := 0; i < len(s)-1; i++ {
		fmt.Fprint(wr, s[i], " ")
	}
	fmt.Fprintln(wr, s[len(s)-1])
}

func getI() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

// min for n entry
func nmin(a ...int) int {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int) int {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

func chmin(a *int, b int) bool {
	if *a < b {
		return false
	}
	*a = b
	return true
}

func chmax(a *int, b int) bool {
	if *a > b {
		return false
	}
	*a = b
	return true
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt32)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()

	n, d := getI(), getI()
	tl := make([][]int, n)
	for i := 0; i < n; i++ {
		t, l := getI(), getI()
		tl[i] = []int{t, l}
	}

	for k := 1; k <= d; k++ {
		ans := 0
		for i := 0; i < n; i++ {
			t, l := tl[i][0], tl[i][1]
			l += k
			ans = max(ans, t*l)
		}
		out(ans)
	}
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();

        // simply just find the snake with the largest product and increment its length for each k and recalculate
        int n = sc.nextInt(), d = sc.nextInt();
        int[] T = new int[n], L = new int[n];

        for (int i=0;i<n;i++) {
            T[i] = sc.nextInt();
            L[i] = sc.nextInt();
        }

        for (int i=1;i<d+1;i++) {
            int maxT = 0, maxL = 0;

            for (int j=0;j<n;j++) {
                if (T[j]*(L[j]+i) > maxT*maxL) {
                    maxT = T[j];
                    maxL = L[j]+i;
                }
            }   

            System.out.println(maxT * maxL);
        }
    }

    public static class FastScanner {

        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

JavaScript solution:
function Main(input) {
  input = input.split('\n')
  const len = parseInt(input[0].split(' ')[0])
  const time = parseInt(input[0].split(' ')[1])

  let thickness = []
  let long = []

  for (let i = 1; i <= len; i++) {
    thickness.push(parseInt(input[i].split(' ')[0]))
    long.push(parseInt(input[i].split(' ')[1]))
  }

  for (let i = 1; i <= time; i++) {
    let temp = Number.MIN_SAFE_INTEGER
    for (let j = 0; j < len; j++) {
      const weight = thickness[j] * (long[j] + i)
      temp < weight && (temp = weight)
    }
    console.log(temp)
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Python solution:
n,d=map(int,input().split())
tl = [list(map(int,input().split())) for _ in range(n)]
for i in range(1,d+1):
    hev=[]
    for j in range(len(tl)):
        hev.append(tl[j][0]*(tl[j][1]+i))
    print(max(hev))

Ruby solution:
n, d, *info = readlines.map(&:chomp).map(&:split).flatten(nil).map(&:to_i)
snakes = info.each_slice(2).to_a

d.times do |i|
  new_info = snakes.map do |s|
    s[0] * (s[1] + (i+1))
  end
  
  puts new_info.max
end