/**
 * This function takes in a list of grades for each student and calculates the average grade
 * for each student. It also calculates the overall average grade for all the students.
 *
 * @param gradesList a list of lists, where each inner list contains the grades of a student
 * @return Pair<List<Float>, Float> a pair where the first element is a list of floats representing
 * the average grade of each student, and the second element is a float representing the overall
 * average grade of all the students
 */
fun calculateAverageGrades(gradesList: List<List<Int>>): Pair<List<Float>, Float> {

    var totalGrades = 0
    var studentCount = 0
    val averageGrades = mutableListOf<Float>()

    while (studentCount < gradesList.size) {
        val grades = gradesList[studentCount]
        var gradeCount = 0
        var sumGrades = 0

        while (gradeCount < grades.size) {
            sumGrades += grades[gradeCount]
            gradeCount++
        }

        val averageGrade = sumGrades.toFloat() / grades.size
        averageGrades.add(averageGrade)
        totalGrades += sumGrades
        studentCount++
    }

    val overallAverage = totalGrades.toFloat() / gradesList.size
    return Pair(averageGrades, overallAverage)
}
/**
 * This function takes in a list of grades for each student and calculates the average grade
 * for each student. It also calculates the overall average grade for all the students.
 *
 * @param gradesList a list of lists, where each inner list contains the grades of a student
 * @return Pair<List<Float>, Float> a pair where the first element is a list of floats representing
 * the average grade of each student, and the second element is a float representing the overall
 * average grade of all the students
 */
fun calculateAverageGrades(gradesList: List<List<Int>>): Pair<List<Float>, Float> {
/**
 * This function takes in a list of grades for each student and calculates the average grade
 * for each student. It also calculates the overall average grade for all the students.
 *
 * @param gradesList a list of lists, where each inner list contains the grades of a student
 * @return Pair<List<Float>, Float> a pair where the first element is a list of floats representing
 * the average grade of each student, and the second element is a float representing the overall
 * average grade of all the students
 */
fun calculateAverageGrades(gradesList: List<List<Int>>): Pair<List<Float>, Float> {

    var totalGrades = 0
    var studentCount = 0
    val averageGrades = mutableListOf<Float>()

    while (studentCount < gradesList.size) {
        val grades = gradesList[studentCount]
        var gradeCount = 0
        var sumGrades = 0

        while (gradeCount < grades.size) {
            sumGrades += grades[gradeCount]
            gradeCount++
        }

        val averageGrade = sumGrades.toFloat() / grades.size
        averageGrades.add(averageGrade)
        totalGrades += sumGrades
        studentCount++
    }

    val overallAverage = totalGrades.toFloat() / gradesList.size
    return Pair(averageGrades, overallAverage)
}