alexjercan/bugnet huggingface dataset:
Problem p02265 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <list>

using namespace std;
typedef int lli;

list<lli> l;
lli n;

int main() {
  string c;
  lli x;
  list<lli>::iterator itr;
  cin >> n;
  for (lli i = 0; i < n; i++) {

    cin >> c;
    if (c == "insert") {
      cin >> x;
      l.push_front(x);
    } else if (c == "delete") {
      cin >> x;
      for (itr = l.begin(); itr != l.end(); itr++) {
        if (*itr == x) {
          l.erase(itr);
          break;
        }
      }
    } else if (c == "deleteFirst") {
      l.pop_front();
    } else if (c == "deleteLast") {
      l.pop_back();
    }
  }
  bool flag = false;
  for (itr = l.begin(); itr != l.end(); ++itr) {
    if (flag == false) {
      cout << *itr;
      flag = true;
    } else
      cout << " " << *itr;
  }
  cout << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <list>

using namespace std;
typedef int lli;

list<lli> l;
lli n;

int main() {
  string c;
  lli x;
  cin >> n;
  for (lli i = 0; i < n; i++) {

    cin >> c;
    if (c == "insert") {
      cin >> x;
      l.push_front(x);
    } else if (c == "delete") {
      cin >> x;
      for (auto itr = l.begin(); itr != l.end(); itr++) {
        if (*itr == x) {
          l.erase(itr);
          break;
        }
      }
    } else if (c == "deleteFirst") {
      l.pop_front();
    } else if (c == "deleteLast") {
      l.pop_back();
    }
  }
  bool flag = false;
  for (auto it = l.begin(); it != l.end(); ++it) {
    if (flag == false) {
      cout << *it;
      flag = true;
    } else
      cout << " " << *it;
  }
  cout << endl;
  return 0;
}
Problem p02265 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <list>
#include <string>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  list<int> L;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s == "deleteFirst") {
      L.pop_front();
      continue;
    }
    if (s == "deleteLast") {
      L.pop_back();
      continue;
    }
    int num;
    cin >> num;
    if (s == "insert") {
      L.push_front(num);
      continue;
    }
    if (s == "delete") {
      for (list<int>::iterator it = L.begin(); it != L.end(); it++) {
        if (*it == num) {
          L.erase(it);
          break;
        }
      }
    }
  }

  for (list<int>::iterator it = L.begin(); it != L.end();) {
    cout << *it;
    if (++it != L.end()) {
      cout << " ";
    } else {
      cout << endl;
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <list>
#include <string>
using namespace std;

int main() {
  list<int> L;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s == "deleteFirst") {
      L.pop_front();
      continue;
    }
    if (s == "deleteLast") {
      L.pop_back();
      continue;
    }
    int num;
    cin >> num;
    if (s == "insert") {
      L.push_front(num);
      continue;
    }
    if (s == "delete") {
      for (list<int>::iterator it = L.begin(); it != L.end(); it++) {
        if (*it == num) {
          L.erase(it);
          break;
        }
      }
    }
  }

  for (list<int>::iterator it = L.begin(); it != L.end();) {
    cout << *it;
    if (++it != L.end()) {
      cout << " ";
    } else {
      cout << endl;
    }
  }

  return 0;
}
Problem p02265 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>
using namespace std;

struct Node {
  int key;
  Node *prev;
  Node *next;
};

class List {
  Node *nil;
  void delete_node(Node *n) {
    n->prev->next = n->next;
    n->next->prev = n->prev;
    delete n;
  }

public:
  List() {
    nil = new Node;
    nil->prev = nil;
    nil->next = nil;
  }
  void insert_key(int key) {
    Node *n = new Node;
    n->key = key;
    nil->next->prev = n;
    n->next = nil->next;
    nil->next = n;
    n->prev = nil;
  }
  void delete_key(int key) {
    for (Node *n = nil->next; n != nil; n = n->next) {
      if (n->key == key) {
        delete_node(n);
        return;
      }
    }
  }
  void print_all() {
    for (Node *n = nil->next; n != nil; n = n->next) {
      if (n != nil->next)
        cout << " ";
      cout << n->key;
    }
    cout << endl;
  }
  void deleteFirst() { delete_node(nil->next); }
  void deleteLast() { delete_node(nil->prev); }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  List l;
  for (int i = 0; i < n; i++) {
    string command;
    cin >> command;
    if (command == "deleteFirst") {
      l.deleteFirst();
      continue;
    }
    if (command == "deleteLast") {
      l.deleteLast();
      continue;
    }
    int key;
    cin >> key;
    if (command == "insert") {
      l.insert_key(key);
      continue;
    }
    if (command == "delete") {
      l.delete_key(key);
      continue;
    }
  }
  l.print_all();
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>
using namespace std;

struct Node {
  int key;
  Node *prev;
  Node *next;
};

class List {
  Node *nil;
  void delete_node(Node *n) {
    n->prev->next = n->next;
    n->next->prev = n->prev;
    delete n;
  }

public:
  List() {
    nil = new Node;
    nil->prev = nil;
    nil->next = nil;
  }
  void insert_key(int key) {
    Node *n = new Node;
    n->key = key;
    nil->next->prev = n;
    n->next = nil->next;
    nil->next = n;
    n->prev = nil;
  }
  void delete_key(int key) {
    for (Node *n = nil->next; n != nil; n = n->next) {
      if (n->key == key) {
        delete_node(n);
        return;
      }
    }
  }
  void print_all() {
    for (Node *n = nil->next; n != nil; n = n->next) {
      if (n != nil->next)
        cout << " ";
      cout << n->key;
    }
    cout << endl;
  }
  void deleteFirst() { delete_node(nil->next); }
  void deleteLast() { delete_node(nil->prev); }
};

int main() {
  int n;
  cin >> n;
  List l;
  for (int i = 0; i < n; i++) {
    string command;
    cin >> command;
    if (command == "deleteFirst") {
      l.deleteFirst();
      continue;
    }
    if (command == "deleteLast") {
      l.deleteLast();
      continue;
    }
    int key;
    cin >> key;
    if (command == "insert") {
      l.insert_key(key);
      continue;
    }
    if (command == "delete") {
      l.delete_key(key);
      continue;
    }
  }
  l.print_all();
  return 0;
}
Problem p02265 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <list>
#include <string>
using namespace std;
int main(void) {
  int n;
  string c;
  list<int> l;
  list<int>::iterator it;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c;
    if (c == "insert") {
      int x;
      cin >> x;
      l.push_front(x);
    }
    if (c == "delete") {
      int x;
      cin >> x;
      for (it = l.begin(); it != l.end(); it++) {
        if (*it == x) {
          l.erase(it);
          break;
        }
      }
    }
    if (c == "deleteFirst")
      l.pop_front();
    if (c == "deleteLast")
      l.pop_back();
  }
  int f = 0;
  for (it = l.begin(); it != l.end(); it++) {
    if (f)
      cout << " ";
    cout << *it;
    f++;
  }
  cout << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <list>
#include <string>
using namespace std;
int main(void) {
  int n, x;
  list<int> l;
  list<int>::iterator it;
  string c;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c;
    if (c == "insert") {
      cin >> x;
      l.push_front(x);
    } else if (c == "delete") {
      cin >> x;
      for (it = l.begin(); it != l.end(); it++) {
        if (*it == x) {
          l.erase(it);
          break;
        }
      }
    } else if (c == "deleteFirst")
      l.pop_front();
    else
      l.pop_back();
  }
  while (!l.empty()) {
    cout << l.front();
    if (l.size() != 1)
      cout << " ";
    l.pop_front();
  }
  cout << endl;
  return 0;
}
Problem p02265 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <list>
int main() {
  int n;
  std::cin >> n;
  std::list<int> ls;
  std::string op;
  int x;
  while (n-- > 0) {
    std::cin >> op;
    if (op == "insert") {
      std::cin >> x;
      ls.push_front(x);
    } else if (op == "delete") {
      std::cin >> x;
      auto i = std::find(ls.begin(), ls.end(), x);
      if (i != ls.end()) {
        ls.erase(i);
      }
    } else if (op == "deleteFirst") {
      ls.pop_front();
    } else {
      ls.pop_back();
    }
  }
  for (auto i = ls.begin(); i != ls.end(); ++i) {
    std::cout << ((i == ls.begin()) ? "" : " ") << *i;
  }
  std::cout << std::endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <list>
int main() {
  int n;
  std::cin >> n;
  std::list<long> ls;
  while (n-- > 0) {
    std::string op;
    long x;
    std::cin >> op;
    if (op == "insert") {
      std::cin >> x;
      ls.push_front(x);
    } else if (op == "delete") {
      std::cin >> x;
      auto i = std::find(ls.begin(), ls.end(), x);
      if (i != ls.end()) {
        ls.erase(i);
      }
    } else if (op == "deleteFirst") {
      ls.pop_front();
    } else {
      ls.pop_back();
    }
  }
  for (auto i = ls.begin(); i != ls.end(); ++i) {
    std::cout << ((i == ls.begin()) ? "" : " ") << *i;
  }
  std::cout << std::endl;
}
Problem p02266 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;

int main() {
  stack<int> S1;
  stack<pair<int, int>> S2;
  char c_s;
  int sum;
  int a, i, j;
  for (i; cin >> c_s; i++) {
    if (c_s == '\\\\')
      S1.push(i);
    else if (c_s == '/' && S1.size() > 0) {
      j = S1.top();
      S1.pop();
      sum += i - j;
      a = i - j;
      while (S2.size() > 0 && S2.top().first > j) // This is important.
      {
        a += S2.top().second;
        S2.pop();
      }
      S2.push(make_pair(j, a));
    }
  }

  vector<int> ans;
  while (S2.size() > 0) {
    ans.push_back(S2.top().second);
    S2.pop();
  }
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for (int i = 0; i < ans.size(); i++) {
    cout << " ";
    cout << ans[i];
  }
  cout << endl;
  //	system("pause");
  return 0;
}


Error: WA

Fixed submission:

#include <algorithm>
#include <iostream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {
  stack<int> S1;
  stack<pair<int, int>> S2;
  char c_s;
  int sum;
  int a, i, j;
  for (i; cin >> c_s; i++) {
    if (c_s == '\\\\')
      S1.push(i);
    else if (c_s == '/') {
      j = S1.top();
      S1.pop();
      sum += i - j;
      a = i - j;
      while (S2.size() > 0 && S2.top().first > j) // This is important.
      {
        a += S2.top().second;
        S2.pop();
      }
      S2.push(make_pair(j, a));
    }
  }

  vector<int> ans;
  while (S2.size() > 0) {
    ans.push_back(S2.top().second);
    S2.pop();
  }
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for (int i = 0; i < ans.size(); i++) {
    cout << " ";
    cout << ans[i];
  }
  cout << endl;

  return 0;
}
Problem p02266 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef struct {
  int v, h;
  bool f;
} P;

stack<int> s;
vector<P> s2;
string str;

int main() {
  cin >> str;
  int ans = 0, h = 0, t;
  P v, u;
  for (int i = 0; i < str.size(); i++) {
    switch (str[i]) {
    case '\\\\':
      s.push(i);
      h--;
      break;
    case '/':
      if (!s.empty()) {
        t = i - s.top();
        ans += t;
        s.pop();
        s2.push_back({t, h, true});
        while (s2.size() >= 2) {
          v = s2.back();
          s2.pop_back();
          u = s2.back();
          s2.pop_back();
          if (v.h > u.h && u.f) {
            v.v += u.v;
            s2.push_back(v);
          } else {
            s2.push_back(u);
            s2.push_back(v);
            break;
          }
        }
      } else if (!s2.empty()) {
        s2.back().f = false;
      }
      h++;
      break;
    default:
      break;
    }
  }
  cout << ans << endl;
  cout << s2.size();
  for (int i = 0; i < s2.size(); i++) {
    cout << " " << s2[i].v;
  }
  cout << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef struct {
  int v, h;
  bool f;
} P;

stack<int> s;
vector<P> s2;
string str;

int main() {
  cin >> str;
  int ans = 0, h = 0, t;
  P v, u;
  for (int i = 0; i < str.size(); i++) {
    switch (str[i]) {
    case '\\\\':
      s.push(i);
      h--;
      break;
    case '/':
      if (!s.empty()) {
        t = i - s.top();
        ans += t;
        s.pop();
        s2.push_back({t, h, true});
        while (s2.size() >= 2) {
          v = s2.back();
          s2.pop_back();
          u = s2.back();
          s2.pop_back();
          if (v.h > u.h && u.f) {
            v.v += u.v;
            s2.push_back(v);
          } else {
            s2.push_back(u);
            s2.push_back(v);
            break;
          }
        }
      } else {
        s2.back().f = false;
      }
      h++;
      break;
    default:
      break;
    }
  }
  cout << ans << endl;
  cout << s2.size();
  for (int i = 0; i < s2.size(); i++) {
    cout << " " << s2[i].v;
  }
  cout << endl;

  return 0;
}
Problem p02266 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
  stack<int> s1;
  stack<pair<int, int>> s2;
  string s;
  int sum = 0;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '\\\\') {
      s1.push(i);
    } else if (s[i] == '/' && s1.size() > 0) {
      int j = s1.top();
      s1.pop();
      sum += i - j;
      int a = i - j;
      while (s2.size() > 0 && s2.top().first > j) {
        a += s2.top().second;
        s2.pop();
      }
      s2.push(make_pair(j, a));
    }
  }

  vector<int> ans;
  cout << sum << endl;
  while (s2.size() > 0) {
    ans.push_back(s2.top().second);
    s2.pop();
  }
  cout << ans.size();
  reverse(ans.begin(), ans.end());
  for (int i = 0; i < ans.size(); i++) {
    cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
  stack<int> s1;
  stack<pair<int, int>> s2;
  char ch;
  int sum = 0;
  for (int i = 0; cin >> ch; i++) {
    if (ch == '\\\\') {
      s1.push(i);
    } else if (ch == '/') {
      int j = s1.top();
      s1.pop();
      sum += i - j;
      int a = i - j;
      while (s2.size() > 0 && s2.top().first > j) {
        a += s2.top().second;
        s2.pop();
      }
      s2.push(make_pair(j, a));
    }
  }

  vector<int> ans;
  while (s2.size() > 0) {
    ans.push_back(s2.top().second);
    s2.pop();
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for (int i = 0; i < ans.size(); i++) {
      cout << " ";
      cout << ans[i];
    }
  }
  cout << endl;
  return 0;
}
Problem p02266 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
#include <string>

int top1 = 0, top2 = 0, S1[20000];
struct A {
  int first;
  int area;
};
struct A S2[20000];
void push1(int x) {
  S1[top1] = x;
  top1++;
}
void push2(int x, int y) {
  S2[top2].first = x;
  S2[top2].area = y;
  top2++;
}
int pop1() {
  top1--;
  return S1[top1];
}
struct A pop2() {
  top2--;
  return S2[top2];
}

int main() {
  string str;
  int sum = 0, j;
  struct A temp;
  cin >> str;
  for (int a = 0; a < str.length(); a++) {
    char d = str.at(a);
    if (d == '\\\\')
      push1(a);
    else if (top1 == 0)
      ;
    else if (d == '/') {
      j = pop1();
      sum += (a - j);
      temp.first = j;
      temp.area = a - j;
      for (int b = top2 - 1; b >= 0; b--) {
        if (S2[b].first < a && S2[b].first > j) {
          temp.area += pop2().area;
        }
      }
      push2(temp.first, temp.area);
    }
  }
  cout << sum << endl;
  cout << top2;
  for (int c = 0; c < top2; c++) {
    cout << " " << S2[c].area;
  }
  cout << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
using namespace std;
#include <string>

int top1 = 0, top2 = 0, S1[10000];
struct A {
  int first;
  int area;
};
struct A S2[10000];
void push1(int x) {
  S1[top1] = x;
  top1++;
}
void push2(int x, int y) {
  S2[top2].first = x;
  S2[top2].area = y;
  top2++;
}
int pop1() {
  top1--;
  return S1[top1];
}
struct A pop2() {
  top2--;
  return S2[top2];
}

int main() {
  string str;
  int sum = 0, j;
  struct A temp;
  cin >> str;
  for (int a = 0; a < str.length(); a++) {
    char d = str.at(a);
    if (d == '\\\\')
      push1(a);
    else if (top1 == 0)
      ;
    else if (d == '/') {
      j = pop1();
      sum += (a - j);
      temp.first = j;
      temp.area = a - j;
      for (int b = top2 - 1; b >= 0; b--) {
        if (S2[b].first < a && S2[b].first > j) {
          temp.area += pop2().area;
        }
      }
      push2(temp.first, temp.area);
    }
  }
  cout << sum << endl;
  cout << top2;
  for (int c = 0; c < top2; c++) {
    cout << " " << S2[c].area;
  }
  cout << endl;
  return 0;
}
Problem p02266 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <stack>
#include <vector>

using namespace std;

int main() {
  stack<int> S1;
  stack<pair<int, int>> S2;
  int *ans;
  char ch;
  int A = 0;

  int i = 0, j;
  while (cin >> ch) {
    if (ch == '_' || (ch == '/' && S1.empty() == true)) {
      ++i;
      continue;
    } else if (ch == '\\\\') {
      S1.push(i);
      ++i;
      continue;
    } else if (ch == '/') {
      j = S1.top();
      S1.pop();
      A += (i - j);
      if (S2.empty() == true) {
        S2.push(make_pair(j, i - j));
        ++i;
        continue;
      } else {
        int k = S2.top().first;

        if (k < j) {
          S2.push(make_pair(j, i - j));
          ++i;
          continue;
        } else if (j < k) {
          int tempArea = 0;
          while (j < k && S2.empty() != true) {
            tempArea += S2.top().second;
            S2.pop();
            if (S2.empty() != true) {
              k = S2.top().first;
            }
          }
          S2.push(make_pair(j, tempArea + (i - j)));
          ++i;
          continue;
        }
      }
    } else {
      ++i;
      continue;
    }
  }

  int size = S2.size();
  ans = new int[size];
  for (int i = 0; i < size; ++i) {
    ans[size - 1 - i] = S2.top().second;
    S2.pop();
  }

  cout << A << endl;
  cout << size;
  for (int i = 0; i < size; ++i) {
    cout << " " << ans[i];
  }
  cout << endl;

  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
#include <stack>
#include <vector>

using namespace std;

int main() {
  stack<int> S1;
  stack<pair<int, int>> S2;
  vector<int> ans;
  char ch;
  int A = 0;

  int i = 0, j;
  while (cin >> ch) {
    if (ch == '_' || (ch == '/' && S1.empty() == true)) {
      ++i;
      continue;
    } else if (ch == '\\\\') {
      S1.push(i);
      ++i;
      continue;
    } else if (ch == '/') {
      j = S1.top();
      S1.pop();
      A += (i - j);
      if (S2.empty() == true) {
        S2.push(make_pair(j, i - j));
        ++i;
        continue;
      } else {
        int k = S2.top().first;

        if (k < j) {
          S2.push(make_pair(j, i - j));
          ++i;
          continue;
        } else if (j < k) {
          int tempArea = 0;
          do {
            tempArea += S2.top().second;
            if (S2.empty() != true) {
              S2.pop();
              k = S2.top().first;
            } else {
              break;
            }
          } while (j < k);
          S2.push(make_pair(j, tempArea + (i - j)));
          ++i;
          continue;
        }
      }
    } else {
      ++i;
      continue;
    }
  }

  while (S2.empty() != true) {
    ans.push_back(S2.top().second);
    S2.pop();
  }

  cout << A << endl;
  cout << ans.size();
  for (unsigned int i = 0; i < ans.size(); ++i) {
    cout << " " << ans[i];
  }
  cout << endl;

  return 0;
}
Problem p02266 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
string s;
int main() {
  cin >> s;
  stack<int> s1;
  stack<pair<int, int>> s2;
  int sum = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '\\\\')
      s1.push(i);
    else if (s[i] == '/' && s1.size() > 0) {
      int j = s1.top();
      s1.pop();
      sum += (i - j);
      int a = i - j;
      while (s2.size() > 0 && s2.top().first > j) {
        a += s2.top().second;
        s2.pop();
      }
      s2.push(make_pair(j, a));
    }
  }
  vector<int> ans;
  int t = 0;
  while (s2.size() > 0) {
    ans.push_back(s2.top().second);
    s2.pop();
  }
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for (int i = 0; i < ans.size(); i++) {
    cout << " ";
    t += ans[i];
    cout << ans[i];
  }
  cout << endl;

  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
string s;
int sum;
int t = 0;
int main() {
  cin >> s;
  stack<int> s1;
  stack<pair<int, int>> s2;
  int sum = 0;
  for (int i = 0; s.length(); i++) {
    if (s[i] == '\\\\')
      s1.push(i);
    else if (s[i] == '/' && s1.size() > 0) {
      int j = s1.top();
      s1.pop();
      sum += (i - j);
      int a = j - i;
      while (s2.size() > 0 && s2.top().first > j) {
        a += s2.top().second;
        s2.pop();
      }
      s2.push(make_pair(j, a));
    }
  }
  vector<int> ans;
  int t = 0;
  while (s2.size() > 0) {
    ans.push_back(s2.top().second);
    s2.pop();
  }
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for (int i = 0; i < ans.size(); i++) {
    cout << " ";
    t += ans[i];
    cout << ans[i];
  }
  cout << endl;

  return 0;
}