#include <iostream>
#include <list>
#include <string>
using namespace std;

struct Student {
    string lastname;
    int course;
    int mathAn;
    int mathAl;
};

void printList( list<Student> lst) {
    for (list<Student>::iterator it = lst.begin(); it != lst.end(); it++)
    {
    cout << (*it).lastname <<" " << (*it).course << " " << (*it).mathAn << " "<< (*it).mathAl << endl;
    }
}

bool compare (const Student& first, const Student& second) {
    return first.lastname < second.lastname;
}

bool compare_course (const Student& first, const Student& second) {
    return first.course < second.course;
}
bool digit (const Student& value) { return (value.mathAn < 60 || value.mathAl < 60); }
int main() {
    Student student1;
    list<Student> students;
    for( int i = 3; i > 0; i--) {
        cout << "Enter student lastname: ";
        cin >> student1.lastname;
        cout << "Enter student course: ";
        cin >> student1.course;
        cout << "Enter student mathAn: ";
        cin >> student1.mathAn;
        cout << "Enter student mathAl: ";
        cin >> student1.mathAl;
        students.push_back(student1);
    }
    printList(students);
    students.sort(compare);
    printList(students);
    students.sort(compare_course);
    printList(students);

    for (list<Student>::iterator it = students.begin(); it != students.end(); it++)
    {
        if((*it).mathAn > 60 && (*it).mathAl > 60){
            (*it).course++;
        }
    }
    printList(students);

    for (list<Student>::iterator it = students.begin(); it != students.end(); it++)
    {
        if((*it).mathAn > 60 && (*it).mathAl > 60){
            (*it).course++;
        }
    }
    printList(students);
    students.remove_if(digit);
    cout << "After remove students with mathAn < 60 or mathAl < 60: " << endl;
    printList(students);
    return 0;
}