#include "aplusb.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> smallest_sums(int N, vector<int> A, vector<int> B) {
vector<int> ans;
priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>> pq;
pq.push({A[0]+B[0],{0,0}});
for(int i = 1 ; i<=N ; ++i) {
auto get = pq.top();pq.pop();
ans.push_back(get.first);
if(i== N) break;
pq.push({A[get.second.first+1]+B[get.second.second],{get.second.first+1,get.second.second}});
pq.push({A[get.second.first]+B[get.second.second+1],{get.second.first,get.second.second+1}});
}
return ans;
}