Grades#8696

Grades (Editorial)

Let’s count the number of fives and twos in the string.

Algorithm implementation

Read the input string.

cin >> s;

Compute the number of fives and twos in the string .

fives = twos = 0;
for (i = 0; i < s.size(); i++)
  if (s[i] == '2') twos++; else fives++;

Print the answer.

if (fives > twos) cout << "5"; else
  if (fives < twos) cout << "2"; 
  else cout << "=";
cout << endl;

Python implementation

Read the input string.

s = input()

Compute the number of fives and twos in the string .

fives = s.count('5')
twos = s.count('2')

Print the answer.

if fives > twos:
  print("5")
elif fives < twos:
  print("2")
else:
  print("=")