Problem p03760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using llpair = pair<ll, ll>;
using llvec = vector<ll>;
using llmat = vector<vector<ll>>;
#define llmattp(name, a, b, num) name(a, vector<ll>(b, num))
#define LLINF 1LL << 60
#define ABS(x) ((x) > 0 ? (x) : -(x))

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0)
    return 0;
  if (a < b)
    swap(a, b);
  ll tmp = a % b;
  while (tmp != 0) {
    a = b;
    b = tmp;
    tmp = a % b;
  }
  return b;
}

ll factorial(ll x) {
  ll f = 1;
  for (ll i = 2; i < x; i++) {
    f *= i;
  }
  return f;
}

ll nPr(ll n, ll r) {
  ll result = 1;
  for (ll i = r + 1; i <= n; i++)
    result *= i;
  return result;
}

ll nCr(ll n, ll r) {

  if (n == 0) {
    return 0;
  }
  if (r == 0) {
    return 1;
  }
  if (r == 1) {
    return n;
  }
  if (n == r) {
    return 1;
  }

  if (r > n / 2) {
    r = n / 2;
  }

  double result = 1;
  for (double i = 1; i <= r; i++) {
    result *= (n - i + 1) / i;
  }

  return (ll)result;
}

bool IsPrime(ll num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false; // 偶数はあらかじめ除く

  double sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      // 素数ではない
      return false;
    }
  }

  // 素数である
  return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
  if (array[max] < array[min]) {
    return NULL;
  } else {
    ll mid = max + (min - max) / 2;
    if (array[mid] < key) {
      return GreaterBinarySearch(array, key, max, mid - 1);
    }
    if (array[mid] > key) {
      return GreaterBinarySearch(array, key, mid + 1, min);
    } else {
      return mid;
    }
  }
}

int main() {
  string o, e;
  cin >> o >> e;

  int i;
  for (i = 0; i < e.length(); i++) {
    cout << o.at(i) << e.at(i);
  }
  if (o.length() != e.length())
    cout << o.at(o.at(i));
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using llpair = pair<ll, ll>;
using llvec = vector<ll>;
using llmat = vector<vector<ll>>;
#define llmattp(name, a, b, num) name(a, vector<ll>(b, num))
#define LLINF 1LL << 60
#define ABS(x) ((x) > 0 ? (x) : -(x))

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0)
    return 0;
  if (a < b)
    swap(a, b);
  ll tmp = a % b;
  while (tmp != 0) {
    a = b;
    b = tmp;
    tmp = a % b;
  }
  return b;
}

ll factorial(ll x) {
  ll f = 1;
  for (ll i = 2; i < x; i++) {
    f *= i;
  }
  return f;
}

ll nPr(ll n, ll r) {
  ll result = 1;
  for (ll i = r + 1; i <= n; i++)
    result *= i;
  return result;
}

ll nCr(ll n, ll r) {

  if (n == 0) {
    return 0;
  }
  if (r == 0) {
    return 1;
  }
  if (r == 1) {
    return n;
  }
  if (n == r) {
    return 1;
  }

  if (r > n / 2) {
    r = n / 2;
  }

  double result = 1;
  for (double i = 1; i <= r; i++) {
    result *= (n - i + 1) / i;
  }

  return (ll)result;
}

bool IsPrime(ll num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false; // 偶数はあらかじめ除く

  double sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      // 素数ではない
      return false;
    }
  }

  // 素数である
  return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
  if (array[max] < array[min]) {
    return NULL;
  } else {
    ll mid = max + (min - max) / 2;
    if (array[mid] < key) {
      return GreaterBinarySearch(array, key, max, mid - 1);
    }
    if (array[mid] > key) {
      return GreaterBinarySearch(array, key, mid + 1, min);
    } else {
      return mid;
    }
  }
}

int main() {
  string o, e;
  cin >> o >> e;

  int i;
  for (i = 0; i < e.length(); i++) {
    cout << o.at(i) << e.at(i);
  }
  if (o.length() != e.length())
    cout << o.at(i);
}