collections.namedtuple()

Basically, namedtuples are easy to create, lightweight object types. 

They turn tuples into convenient containers for simple tasks. 

With namedtuples, you don’t have to use integer indices for accessing members of a tuple.

Example

Code 01

>>> from collections import namedtuple
>>> Point = namedtuple('Point','x,y')
>>> pt1 = Point(1,2)
>>> pt2 = Point(3,4)
>>> dot_product = ( pt1.x * pt2.x ) +( pt1.y * pt2.y )
>>> print dot_product
11

Code 02

>>> from collections import namedtuple
>>> Car = namedtuple('Car','Price Mileage Colour Class')
>>> xyz = Car(Price = 100000, Mileage = 30, Colour = 'Cyan', Class = 'Y')
>>> print xyz
Car(Price=100000, Mileage=30, Colour='Cyan', Class='Y')
>>> print xyz.Class
Y

Task

Dr. John Wesley has a spreadsheet containing a list of student's $\textit{IDs}$, $marks$, $class$ and $name$.  

Your task is to help Dr. Wesley calculate the average marks of the students.

$\textit{Average}=\dfrac{\textit{Sum of all marks}}{\textit{Total students}}$

Note: 

1. Columns can be in any order. IDs, marks, class and name can be written in any order in the spreadsheet. 

2. Column names are ID, MARKS, CLASS and NAME. (The spelling and case type of these names won't change.)

Input Format

The first line contains an integer $N$, the total number of students. 

The second line contains the names of the columns in any order. 

The next $N$ lines contains the $marks$, $\textit{IDs}$, $name$ and $class$, under their respective column names.

Constraints

$0<N\leq100$

Output Format

Print the average marks of the list corrected to 2 decimal places.

Sample Input

TESTCASE 01

5
ID         MARKS      NAME       CLASS     
1          97         Raymond    7         
2          50         Steven     4         
3          91         Adrian     9         
4          72         Stewart    5         
5          80         Peter      6   

TESTCASE 02    

5
MARKS      CLASS      NAME       ID        
92         2          Calum      1         
82         5          Scott      2         
94         2          Jason      3         
55         8          Glenn      4         
82         2          Fergus     5

Sample Output

TESTCASE 01

78.00

TESTCASE 02

81.00

Explanation

TESTCASE 01

Average = $(97+50+91+72+80)/5$

Can you solve this challenge in 4 lines of code or less? 

NOTE: There is no penalty for solutions that are correct but have more than 4 lines.

Source: hackerrank | Difficulty: EASY


Solutions:
(marks, n, idx) = (0, int(input()), input().split().index('MARKS'))
for k in range(0, n):
	marks += int(input().split()[idx])
print(marks / n)


(N, m, avg) = (int(input()), input().split().index('MARKS'), 0)
for i in range(N):
	avg += float(input().split()[m])
print('{0:.2f}'.format(avg / N))


N = int(input())
pos = input().split().index('MARKS')
sums = list()
for _ in range(N):
	sums.append(int(input().split()[pos]))
print('%.2f' % (sum(sums) / len(sums)))


from collections import namedtuple

def main():
	n = int(input())
	Test = namedtuple('Test', input().split())
	s = 0
	for _ in range(n):
		k = Test(*input().split())
		s += int(k.MARKS)
	print(s / n)
main()


from collections import namedtuple
(a, student, b) = (int(input()), list(filter(None, [x for x in input().strip().split(' ')])), 0)
for x in range(0, a):
	b += int(list(filter(None, [x for x in input().strip().split(' ')]))[student.index('MARKS')]) / a
print(b)


from collections import namedtuple
from functools import reduce
size = int(input())
rs = []
record = namedtuple('record', input())
for _ in range(0, size):
	rs.append(record(*list(input().split())))
s = reduce(lambda x, y: x + y, [float(row.MARKS) for row in rs])
print('{0:.2f}'.format(s / size))


from collections import namedtuple
n = int(input())
S = namedtuple('S', input().split())
s = []
for _ in range(n):
	s.append(S(*input().split()))
print(sum([int(x.MARKS) for x in s]) / len(s))


student_no = int(input())
m_index = input().split().index('MARKS')
print(sum([int(input().split()[m_index]) for _ in range(student_no)]) / student_no)


from collections import namedtuple
N = int(input())
Student = namedtuple('Student', input())
print('%.2f' % (sum((int(Student(*input().split()).MARKS) for _ in range(N))) / N))


import collections, statistics
N = int(input())
Student = collections.namedtuple('Student', input().split())
print('{0:.2f}'.format(statistics.mean(map(lambda student: float(student.MARKS), [Student._make(input().split()) for _ in range(N)]))))


from collections import namedtuple
n = int(input())
x = input()
P = namedtuple('P', x)
s = 0.0
for i in range(0, n):
	a = input().split()
	x = P(a[0], a[1], a[2], a[3])
	s = s + int(x.MARKS)
print(s / n)


from collections import namedtuple
n = int(input())
keys = input().split()
Student = namedtuple('Student', ','.join(keys))
students = []
for i in range(0, n):
	(val1, val2, val3, val4) = input().split()
	students.append(Student(val1, val2, val3, val4))
total = 0
for student in students:
	total += int(student.MARKS)
print(1.0 * total / n)


(nips, ip, avg) = (int(input()), list(map(str, input().split())), 0)
for i in range(0, nips):
	avg = avg + int(list(map(str, input().split()))[ip.index('MARKS')])
print('{0:.2f}'.format(round(avg / nips, 2)))


N = int(input())
columns = list(input().split())
sum = 0
for n in range(N):
	sum += int(input().split()[columns.index('MARKS')])
print('{:.2f}'.format(sum / N))


from collections import namedtuple
n = int(input())
Student = namedtuple('Student', ','.join(list(input().split())))
total = 0.0
for i in range(n):
	stu = Student(*input().strip().split())
	total = total + float(stu.MARKS)
print(total / n)


from collections import namedtuple
N = int(input())
Student = namedtuple('Student', input())
average = 0
for i in range(N):
	row = input().split()
	student = Student(row[0], row[1], row[2], row[3])
	average += int(student.MARKS)
print(average / N)


from collections import namedtuple
N = int(input())
Person = namedtuple('Person', 'ID MARKS CLASS NAME')
indexCol = input().split().index('MARKS')
res = 0
for _ in range(N):
	res += int(input().split()[indexCol])
print(res / N)


(N, headers, total) = (int(input()), list(input().split()), 0)
for _ in range(N):
	total += int(list(input().split())[headers.index('MARKS')])
print(total / N)


from collections import namedtuple
x = int(input())
stu = namedtuple('Student', input())
s = 0
for i in range(0, x):
	inp = input().split()
	tu = stu(inp[0], inp[1], inp[2], inp[3])
	s += int(tu.MARKS)
print('%.2f' % (s / x))


from collections import namedtuple
(n, student) = (int(input()), namedtuple('student', input().split()))
print(sum((int(student._make(input().split()).MARKS) for _ in range(n))) / n)


x = int(input())
L = input().split()
Students = []
marks = L.index('MARKS')
for _ in range(x):
	Student = input().split()
	Students.append(int(Student[marks]))
print('{:.2f}'.format(sum(Students) / x))


(n, s, h) = (int(input()), 0, input().split().index('MARKS'))
print(sum([int(input().strip().split()[h]) for i in range(n)]) / n)


from collections import namedtuple
n = int(input())
sp = namedtuple('sp', input().split())
l = []
for i in range(n):
	new = input().split()
	l.append(sp(new[0], new[1], new[2], new[3]))
s = 0
for el in l:
	s += int(el.MARKS)
print(s / n)


from collections import namedtuple
N = int(input())
Student = namedtuple('Student', input())
m = 0
for i in range(N):
	m += int(Student(*input().split()).MARKS)
print('{:.2f}'.format(m / N))


from collections import namedtuple
n = int(input())
p = input()
data = namedtuple('Lole', p)
avg = 0
for i in range(n):
	lol = input().split()
	lel = data(lol[0], lol[1], lol[2], lol[3])
	avg += int(lel.MARKS) / float(n)
print(format(avg, '0.2f'))


from collections import namedtuple

def main():
	n = int(input())
	student = namedtuple('student', input())
	a = []
	for _ in range(n):
		a.append(student._make(input().split()))
	print(sum([int(i.MARKS) for i in a]) / len(a))
main()


from collections import namedtuple

def create_array(text):
	columns_names = list(text.replace(' ', ',').split(','))
	columns_names = [x for x in columns_names if x != '' and x != '\r']
	return columns_names
x = int(input())
columns_names = create_array(input())
marks_sum = 0
Student = namedtuple('Student', columns_names[0] + ' ' + columns_names[1] + ' ' + columns_names[2] + ' ' + columns_names[3])
for i in range(x):
	data = create_array(input())
	student = Student(data[0], data[1], data[2], data[3])
	marks_sum += int(student.MARKS)
print('%.2f' % float(marks_sum / x))


(n, im) = (int(input()), input().split().index('marks'.upper()))
print(__import__('statistics').mean((int(input().split()[im]) for line in range(n))))


from collections import namedtuple
number = int(input())
Students = []
columns = input()
Student = namedtuple('Student', columns)
for _ in range(0, number):
	theInput = input().split()
	Students.append(Student(theInput[0], theInput[1], theInput[2], theInput[3]))
sum = 0
for i in range(0, number):
	sum += float(Students[i].MARKS)
print(round(sum / number, 2))


from collections import namedtuple
n = int(input())
Record = namedtuple('Record', input().split())
records = [Record(*input().split()) for _ in range(n)]
print('{:.2f}'.format(sum([int(x.MARKS) for x in records]) / n))


from functools import reduce
N = int(input())
List = []
index = input().split().index('MARKS')
for i in range(N):
	List.append(int(input().split()[index]))
print(reduce(lambda x, y: x + y, List) / len(List))


from collections import namedtuple
N = int(input())
t = namedtuple('Student', input().split())
l = [t(*input().split()) for _ in range(N)]
print(sum((int(g.MARKS) for g in l)) / N)


n = int(input())
t = __import__('collections').namedtuple('t', input().split())
a = [t(*input().split()) for _ in range(n)]
print(sum((float(e.MARKS) for e in a)) / n)


(stu, marks) = (int(input()), input().split().index('MARKS'))
print(sum([int(input().split()[marks]) for _ in range(stu)]) / stu)


from collections import namedtuple
N = int(input())
Student = namedtuple('Student', input().split())
students = []
for _ in range(N):
	students.append(Student(*input().split()))
print(sum((int(s.MARKS) for s in students)) / len(students))


from collections import namedtuple
students = int(input())
Student = namedtuple('Student', 'ID, MARKS, CLASS, NAME')
s = 0
columns = input().split()
for each in range(students):
	row = input().split()
	for j in range(4):
		if columns[j] == 'ID':
			id = row[j]
		elif columns[j] == 'MARKS':
			mark = row[j]
		elif columns[j] == 'CLASS':
			classname = row[j]
		elif columns[j] == 'NAME':
			name = row[j]
	stdnt = Student(ID=id, MARKS=mark, CLASS=classname, NAME=name)
	s += int(stdnt.MARKS)
print('{0:.2f}'.format(s / students))


from collections import namedtuple
count = int(input())
Student = namedtuple('Student', input().split())
Students = [Student(*input().split()) for _ in range(count)]
print(sum([int(s.MARKS) for s in Students]) / len(Students))


from collections import namedtuple
n = int(input())
orden = input()
Stu = namedtuple('Stu', orden)
s = list()
for _ in range(n):
	s.append(Stu(*input().split()))
print(sum(map(lambda x: int(x.MARKS), s)) / n)


from collections import namedtuple
n = int(input())
headers = input().split()
Marks = namedtuple('Marks', headers)
s = []
for i in range(n):
	m = Marks._make(input().split())
	s.append(m)
print('{0:.2f}'.format(sum([int(e.MARKS) for e in s]) / n))


from collections import namedtuple
n = int(input())
Grade = namedtuple('Grade', ','.join(input().split()))
print('{:.2f}'.format(sum([int(Grade(*input().split()).MARKS) for _ in range(n)]) / n))


n = int(input())
header = input().split()
marks_column = header.index('MARKS')
total = 0
for _ in range(n):
	line = input().split()
	total += int(line[marks_column])
print(total / n)


stu = int(input())
marks = input().split().index('MARKS')
print(sum([int(input().split()[marks]) for _ in range(stu)]) / stu)


n = int(input())
k = input().strip().split().index('MARKS')
total = sum((int(input().strip().split()[k]) for _ in range(n)))
print(total / n)


def main():
	import collections, statistics
	N = int(input())
	Student = collections.namedtuple('Student', input().split())
	print('{0:.2f}'.format(statistics.mean(map(lambda student: float(student.MARKS), [Student._make(input().split()) for _ in range(N)]))))
main()


from collections import namedtuple
n = int(input())
Type = namedtuple('Type', input().split())
s = 0
for _ in range(n):
	data = Type(*input().split())
	s += int(data.MARKS)
print('{:.2f}'.format(s / n))


from collections import namedtuple
n = int(input())
(c1, c2, c3, c4) = input().split()
Student = namedtuple('Student', '{}, {}, {}, {}'.format(c1, c2, c3, c4))
marks = []
for _ in range(n):
	(d1, d2, d3, d4) = input().split()
	s = Student(d1, d2, d3, d4)
	marks.append(int(s.MARKS))
print('{:.2f}'.format(sum(marks) / len(marks)))


from collections import namedtuple
Student = namedtuple('Student', 'ID MARKS CLASS NAME')
n = int(input())
sumMarks = 0
line = input().split()
if line[0] == 'MARKS':
	idx = 0
elif line[1] == 'MARKS':
	idx = 1
elif line[2] == 'MARKS':
	idx = 2
elif line[3] == 'MARKS':
	idx = 3
for i in range(n):
	line = input().split()
	sumMarks += int(line[idx])
print(sumMarks / n)


(N, cols) = (int(input()), input().split())
print(sum([int(input().split()[cols.index('MARKS')]) for _ in range(N)]) / N)


from collections import namedtuple
n = int(input())
students = namedtuple('students', tuple(input().split()))
avg = 0
for i in range(n):
	student = students._make(input().split())
	student = student._asdict()
	avg += int(student['MARKS'])
print(avg / n)


import collections
N = int(input())
Student = collections.namedtuple('Student', input())
print(sum([int(s.MARKS) for s in [Student(*input().split()) for n in range(N)]]) / N)


n = int(input())
m_idx = input().split().index('MARKS')
print(sum([int(input().split()[m_idx]) for _ in range(n)]) / n)


from collections import namedtuple
(n, st) = (int(input()), namedtuple('st', input()))
print(sum([float(x.MARKS) for x in [st(*input().split()) for _ in range(n)]]) / n)


from collections import namedtuple
n = int(input())
cols = input()
Student = namedtuple('Student', cols)
total = 0
for i in range(0, n):
	s = Student(*input().split())
	total += int(s.MARKS)
print(total / n)


from collections import namedtuple
n = int(input())
Student = namedtuple('Student', input().split())
l = [Student._make(input().split()) for _ in range(n)]
print('{0:0.2f}'.format(round(sum([float(s.MARKS) for s in l]) / n, 2)))


from collections import namedtuple
N = int(input())
sum = 0
Student = namedtuple('Student', input().split())
for i in range(N):
	stdnt = Student._make(input().split())
	sum = sum + int(stdnt.MARKS)
print('{0:.2f}'.format(sum / N))


from collections import namedtuple
count = int(input())
Student = namedtuple('Student', input().split())
totalMark = 0
for i in range(count):
	data = input().strip().split()
	st = Student(data[0], data[1], data[2], data[3])
	totalMark += int(st.MARKS)
print(totalMark / count)


import collections
(nstudents, columns) = (int(input()), input().split())
Record = collections.namedtuple('Record', columns)
print(sum((int(record.MARKS) for record in (Record(**dict(zip(columns, input().split()))) for _ in range(nstudents)))) / nstudents)


from collections import namedtuple
N = int(input())
Student = namedtuple('Student', input())
print(sum([int(Student(*input().split()).MARKS) for _ in range(N)]) / N)


from collections import namedtuple

def __starting_point():
	s_num = int(input().strip())
	tuple_fields = input().strip().split()
	student = namedtuple('student', tuple_fields)
	library = []
	res = 0
	for _ in range(s_num):
		st_info = input().strip().split()
		library.append(student(st_info[0], st_info[1], st_info[2], st_info[3]))
	for el in library:
		res += int(el.MARKS)
	print(res / s_num)
__starting_point()


from collections import namedtuple
n = int(input())
marks = namedtuple('marks', input().split())
print('{:.2f}'.format(sum(map(int, (marks(*input().split()).MARKS for _ in range(n)))) / n))


n = int(input())
col_list = list(input().split())
marks_col = col_list.index('MARKS')
marks_list = []
for i in range(n):
	info_list = list(input().split())
	marks_list.append(float(info_list[marks_col]))
print(sum(marks_list) / n)


(n, i) = (int(input()), input().split().index('MARKS'))
print('%.2f' % (sum([int(input().split()[i]) for _ in range(n)]) / n))


from collections import namedtuple
N = int(input())
StudentMarks = namedtuple('StudentMarks', ','.join(input().split()))
result = []
for student in range(N):
	s = input().split()
	a = StudentMarks(s[0], s[1], s[2], s[3])
	result.append(a.MARKS)
result = map(int, result)
print(sum(result) / N)


N = int(input())
idx = [x for x in input().split()].index('MARKS')
suma = 0
for n in range(N):
	suma += int([x for x in input().split()][idx])
print(suma / N)


from collections import namedtuple
n = int(input())
Student = namedtuple('Student', input().strip().split())
print(sum((int(Student(*input().strip().split()).MARKS) for x in range(n))) / n)


n = int(input())
ind = input().strip().split().index('MARKS')
print('{:.2f}'.format(sum(map(int, [input().strip().split()[ind] for _ in range(n)])) / n))


from collections import namedtuple
n = int(input())
l = []
Record = namedtuple('Record', input().split())
for i in range(n):
	x = input().split()
	r = Record(x[0], x[1], x[2], x[3])
	l.append(r.MARKS)
print(sum(map(int, l)) / n)


from collections import namedtuple
(n, cn) = (int(input()), input().split())
Data = namedtuple('Data', ' '.join(cn))
print('%.2f' % (sum([int(Data(*input().split()).MARKS) for _ in range(n)]) / n))


(N, cols) = (int(input()), input().split())
index = cols.index('MARKS')
print(sum([int(input().split()[index]) for _ in range(N)]) / N)


import collections
import sys
N = int(sys.stdin.readline())
C = sys.stdin.readline().strip().split()
Student = collections.namedtuple('Student', ','.join(C))
X = [Student(*sys.stdin.readline().split()) for _ in range(N)]
print(sum((int(x.MARKS) for x in X)) / len(X))


from collections import namedtuple
N = int(input())
titles = ['ID', 'MARKS', 'CLASS', 'NAME']
Student = namedtuple('Student', 'ID MARKS CLASS NAME')
ts = input().split(' ')
ts = [t.strip() for t in ts if t != '']
idndx = ts.index('ID')
mndx = ts.index('MARKS')
cndx = ts.index('CLASS')
nndx = ts.index('NAME')
tot = 0
for i in range(0, N):
	line = input().split(' ')
	line = [f.strip() for f in line if f != '']
	a = int(line[idndx])
	b = int(line[mndx])
	c = int(line[cndx])
	d = line[idndx]
	stu = Student(ID=a, MARKS=b, CLASS=c, NAME=d)
	tot += stu.MARKS
print(tot / N)


from collections import namedtuple
c = int(input())
D = namedtuple('D', input().split())
print(sum([int(D(*input().split()).MARKS) for i in range(c)]) / c)


from collections import namedtuple
n = int(input())
t = namedtuple('Student', input())
s = []
sum = 0
for _ in range(n):
	tmp = input().split()
	tmp = t(tmp[0], tmp[1], tmp[2], tmp[3])
	sum += int(tmp.MARKS)
print(float(float(sum) / float(n)))


from collections import namedtuple
n = int(input().strip())
students = namedtuple('students', input().strip())
arr = []
for i in range(n):
	arr.append(students(*input().strip().split()))
print(str(sum([int(s.MARKS) for s in arr]) / n))


from collections import namedtuple
from collections import Counter
student_count = int(input())
student_hoard = []
Student = namedtuple('Student', ', '.join(input().split()))
for x in range(0, student_count):
	student_hoard.append(Student(*input().split()))
print(sum([int(x.MARKS) for x in student_hoard]) / student_count)


import collections
N = int(input())
columns = ','.join(input().split())
Student = collections.namedtuple('Student', columns)
sum = 0
for i in range(N):
	line = input().split()
	student = Student(*line)
	sum += int(student.MARKS)
print(sum / N)


from collections import namedtuple
N = int(input())
student = namedtuple('student', ' '.join(input().split()))
students = [student(*input().split()) for x in range(N)]
print('{0:.2f}'.format(sum([float(s.MARKS) for s in students]) / len(students)))


from collections import namedtuple
num_students = int(input())
Student = namedtuple('Student', input())
total = 0.0
for i in range(num_students):
	s = Student(*input().strip().split())
	total += float(s.MARKS)
print(total / num_students)


from collections import namedtuple
student_count = int(input())
StudentData = namedtuple('StudentData', input().split())
my_avg = 0
for _ in range(student_count):
	my_avg += int(StudentData(*[str(x) for x in input().split()]).MARKS)
print(my_avg / student_count)


from collections import namedtuple
n = int(input())
Student = namedtuple('Student', input())
total = 0
for i in range(n):
	std = input().split()
	s = Student(std[0], std[1], std[2], std[3])
	total += int(s.MARKS)
print('{0:.2f}'.format(total / n))


from collections import namedtuple
n = int(input())
total = 0
record = namedtuple('record', ','.join(input().split()))
for i in range(n):
	r = record(*input().split())
	total += int(r.MARKS)
print(float(total) / n)


from collections import namedtuple
N = int(input())
Student = namedtuple('Student', ','.join(input().split()))
students = [Student(*input().split()) for _ in range(N)]
avg = sum((float(student.MARKS) for student in students)) / len(students)
print(avg)


from collections import namedtuple
student_count = int(input())
Student = namedtuple('Student', input())
print(sum((int(Student(*input().split()).MARKS) for _ in range(student_count))) / student_count)


N = int(input())
index = input().split().index('MARKS')
scores = [int(input().split()[index]) for _ in range(N)]
print('%.2f' % (sum(scores) / N))


import sys
if sys.version_info[0] >= 3:
	raw_input = input
n = int(input())
t = __import__('collections').namedtuple('t', input().split())
a = [t(*input().split()) for _ in range(n)]
print(sum((float(e.MARKS) for e in a)) / n)


from collections import namedtuple
nr_lines = int(input())
Student = namedtuple('Student', input())
sum_ = 0
for i in range(nr_lines):
	student = Student(*input().split())
	sum_ += int(student.MARKS)
print('{:.2f}'.format(sum_ / nr_lines))


(nb, k) = (int(input()) if 0 == i else input().split().index('MARKS') for i in range(2))
val = [int(input().split()[k]) for i in range(nb)]
print(sum(val) / nb)


from collections import namedtuple
Student = namedtuple('Student', 'ID MARKS NAME CLASS')
students = int(input())
headers = input().split()
headers_index = headers.index('MARKS')
total = 0
for student in range(students):
	total += int(input().split()[headers_index])
print(total / students)


getmarksIndex = -1
sum = 0
count = 0
for i in range(0, int(input()) + 1):
	count += 1
	if i == 0:
		getmarksIndex = int(input().split().index('MARKS'))
	else:
		getInput = input().split()[getmarksIndex]
		sum += int(getInput)
print(sum / (count - 1))


from collections import namedtuple
n = int(input())
Student = namedtuple('Student', input().split())
print(sum((int(Student(*input().split()).MARKS) for _ in range(n))) / n)


from collections import namedtuple
n = int(input())
names = input().split()
m = -1
for i in range(4):
	if names[i] == 'MARKS':
		m = i
sum = 0
for i in range(n):
	str = input().split()
	sum += int(str[m])
print('%.2f' % (sum / n))


N = int(input())
header = input()
I = header.index('MARKS')
marks = [int(input()[I:I + 3]) for _ in range(N)]
print(sum(marks) / len(marks))


from collections import namedtuple
(n, columns) = (int(input()), input())
c = namedtuple('Column', columns)(0, 1, 2, 3)
print('{:.2f}'.format(sum([int(input().split()[c.MARKS]) for _ in range(n)]) / float(n)))


from collections import namedtuple
N = int(input())
Student = namedtuple('Student', list(input().split()))
lst = list()
total = 0
for x in range(N):
	s = list(input().split())
	s1 = Student._make(s)
	total = int(s1.MARKS) + total
print(float(total / N))


from collections import namedtuple
N = int(input())
student = namedtuple('student', input().strip().split())
print(sum((float(student(*input().strip().split()).MARKS) for _ in range(N))) / N)


from collections import namedtuple
i = int(input())
student = namedtuple('student', input())
suma = 0
for j in range(i):
	temp = student(*input().split())
	suma += int(temp.MARKS)
print(suma / i)


n = int(input())
i = input().split().index('MARKS')
marks = [int(input().split()[i]) for _ in range(n)]
print(sum(marks) / len(marks))


n = int(input())
s = input().split()
if s[0] == 'MARKS':
	index = 0
elif s[1] == 'MARKS':
	index = 1
elif s[2] == 'MARKS':
	index = 2
else:
	index = 3
sum = 0
for i in range(n):
	s = input().split()
	sum += float(s[index])
sum = sum / (i + 1)
print('{0:.2f}'.format(sum))