#include using namespace std; int main() { long long int n, m, i, alb, negru, as=0, ns=0; cin>>n>>m; for(i=0; i>alb>>negru; if(alb>m/2) as+=alb; else ns+=negru; } cout<