#include #include #include #include #include #include #define pb push_back #define all(x) begin(x),end(x) #define ll long long #define P pair #define lP pait using namespace std; int main() { int a,b,n,sum=0; cin>>a>>b>>n; vector

c(n); for(int i=0;i>c[i].first; } sort(all(c)); for(int i=0;i1) { sum+=(c[i].second-1)*(a+b); i+=c[i].second-1; } } cout<