You are provided with the marks of entire class in Data structures exam out of 100. You need to calculate the number of students having backlog (passing marks is >=31) and the average of the class. But this average is not a normal average, for this average marks of students having backlog are not considered but they will be considered in number of students. Also print the index of topper’s marks and print the difference of everyone’s marks with respect to the topper. 
In first line print the number of students having backlog and average of the class. In second line print indices of all the toppers(in case of more than 1 topper print index of all toppers in reverse order). Next N lines print the difference of everyone’s marks with respect to topper(s).
Note- if all students have backlog than average will be 0.
INPUT
The first line of the input contains an integer T denoting the number of test cases.
Next line contains N denoting the no of students in the class.
The line contains N space seprated integers A1,A2,A3….AN denoting the marks of each student in exam.
OUTPUT
First line contains the number of students having backlog and the special average of marks as described above. Average must have 2 decimal places.
Next line contains the indices of all the toppers in given array in reverse order.
Next N lines contain the difference of every student’s marks with respect to toppers.
Constraints
1<= T <= 100
1<= N <= 30
0<= Ai<= 100
Example
Input
1
9
56 42 94 25 74 99 27 52 83
Output
2 55.55
5 
43
57
5
74
25
0
72
47
16

Difficulty: interview

Starter code:

Solutions:
for j in range(int(input())):
 input()
 a = list(map(int,input().split()))
 marks = 0
 backlok = 0
 top_marks = max(a)
 topper = []
 for i in range(len(a)):
  if(a[i] >= 31):
   marks+=a[i]
  if(a[i]<31):
   backlok+=1
  if(a[i] == top_marks):
   topper.append(i)
 print(backlok, "{:0.2f}".format(marks/len(a),2))
 topper.sort(reverse=True)
 for i in topper:
  print(i," ")
 for i in a:
  print(top_marks-i)



t=int(input())
for i in range(t):
 n=int(input())
 l=list(map(int,input().strip().split()))
 bl=0
 jod=0
 big=0
 for j in l:
  if j<31:
   bl+=1
  else:
   jod+=j
  if j>big:
   big=j
 avg=jod/n
 dif=[0 for i in range(n)]
 top=[]
 for j in range(n):
  dif[j]=big-l[j]
  if l[j]==big:
   top.append(j)
 print(bl,end=' ')
 print('%.2f'%avg)
 for j in range(len(top)-1,-1,-1):
  print(top[j],end=' ')
 print()
 for j in range(n):
  print(dif[j])