AP posts profit after cost-cutting, but revenue declines