# Problem - E - Codeforces

My code (C++17) fails on the fourth test case of the sorting problem linked. Thanks!

``````#include <iostream>
#include <algorithm>
using namespace std;

typedef long long ll;

ll d (ll i) {ll r {0}; while (i != 0) {i /= 10; ++r;} return r;}
ll o (ll i) {ll r {0}; while (i % 10 == 0) {i /= 10; ++r;} return r;}
bool s (pair<ll, ll> a, pair<ll, ll> b) {bool r {}; if (a.second < b.second) {r = {true};} else if (a.second == b.second) {r = {a.first < b.second};} else {r = {false};} return !r;}

int main() {
ll t {}; cin >> t;

while (t > 0) {
--t;

ll n {}, m {}; cin >> n >> m;

pair<ll, ll> a[n];
for (ll i {0}; i < n; ++i) {ll j {}; cin >> j; a[i] = {d(j), o(j)};}
sort(a, a + n, s);

if (n == 1) {if (a[0].first - a[0].second >= m + 1) {cout << "Sasha\n";} else {cout << "Anna\n";} continue;}

ll sasha {0};
for (ll i {0}; i < n; ++i) {sasha += a[i].first; if (i % 2 == 0) {sasha -= a[i].second;}}
if (sasha >= m + 1) {cout << "Sasha\n";} else {cout << "Anna\n";}
}
}``````