fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. #define be begin()
  4. #define ed end()
  5. using namespace std;
  6.  
  7. int main(){
  8. ios_base::sync_with_stdio(0); cin.tie(NULL);
  9. //freopen("CAU1.INP", "r", stdin);
  10. //freopen("CAU1.OUT", "w", stduot);
  11.  
  12. string s; cin >> s;
  13.  
  14. for(int i=0; i<s.size(); i++){
  15. if(!isdigit(s[i])) s[i] = ' ';
  16. }
  17. // lay max
  18. vector<ll>sz;
  19. stringstream ss(s);
  20. string digit;
  21. bool ok = 0;
  22. ll MAX = -1e5;
  23. while(ss >> digit){
  24. sz.push_back(digit.size());
  25. }
  26. for(auto it : sz){
  27. if(it > MAX) MAX = it;
  28. }
  29. vector<string>ans;
  30. stringstream sss(s);
  31. string digit1;
  32. while(sss >> digit1){
  33. if(digit1.size() == MAX){
  34. ok = 1; ans.push_back(digit1);
  35. cout << digit1;
  36. break;
  37. }
  38. }
  39. cout << "\n";
  40. ll sum = 0;
  41. for(auto it : ans){
  42. ll temp = stoll(it);
  43. while(temp > 0){
  44. ll digit = temp % 10;
  45. sum+=digit;
  46. temp /= 10;
  47. }
  48. }
  49. cout << sum;
  50. if(!ok) cout << "\n" << 0;
  51.  
  52. return 0;
  53. }
  54.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
0
0