jiahuimbzuai/CoQuIR huggingface dataset:
//  [cpp]
//minamoto
#include<bits/stdc++.h>
#define R register
#define ll long long
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
int read(char *s){
    R int len=0;R char ch;while(((ch=getc())>'9'||ch<'0'));
    for(s[++len]=ch;(ch=getc())>='0'&&ch<='9';s[++len]=ch);
    return s[len+1]='\0',len;
}
double readdb()
{
    R double x=0,y=0.1,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(x=ch-'0';(ch=getc())>='0'&&ch<='9';x=x*10+ch-'0');
    for(ch=='.'&&(ch=getc());ch>='0'&&ch<='9';x+=(ch-'0')*y,y*=0.1,ch=getc());
    return x*f;
}
char sr[1<<21],z[20];int C=-1,Z=0;
inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(R int x){
    if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
const int N=1e5+5;
struct node{
    int x,y;
    inline bool operator <(const node &b)const{return x<b.x;}
}a[N];
int n,m,k;ll res;
int main(){
    n=read(),m=read();
    fp(i,1,n)a[i].x=read(),a[i].y=read();
    sort(a+1,a+1+n);
    fp(i,1,n)k=min(m,a[i].y),m-=k,a[i].y-=k,res+=1ll*k*a[i].x;
    printf("%lld\n",res);
    return 0;
}
//  [cpp]
#include <algorithm>
#include <iostream>
#include <vector>

struct StoreInfo {
	int price;
	int num;
};

int main() {
	int N, M;
	std::cin >> N >> M;

	std::vector<StoreInfo> list(N);
	for(auto &e : list) {
		std::cin >> e.price >> e.num;
	}

	// 値段でソート
	std::sort(list.begin(), list.end(), [](const auto &a, const auto &b) {
		return a.price < b.price;
	});

	long long result = 0;
	int rest = M;
	while(rest > 0) {
		// 不足分　または　在庫全部
		const int numBuy = std::min(rest, list.front().num);

		// 購入
		result += (long long)list.front().price * numBuy;
		list.front().num -= numBuy;
		rest -= numBuy;

		// もし在庫がなくなったら消去
		if(list.front().num == 0) {
			list.erase(list.begin());
		}
	}

	std::cout << result << std::endl;

	return 0;
}
//  [cpp]

#include <bits/stdc++.h>
using namespace std;

struct Shop {
    int A;
    int B;
};

bool cmp(const Shop &a, const Shop &b)
{
    return a.A < b.A;
}

int main(){
    int N,M;
    cin >> N >> M;

    long long ans = 0;
    vector<Shop> shop(N);

    for(int i=0; i<N; i++){
        cin >> shop[i].A >> shop[i].B;
    }

    sort(shop.begin(), shop.end(), cmp);

    while(M > 0){
        ans += shop[0].A;

        if(shop[0].B == 1)
            shop.erase(shop.begin());
        else
            shop[0].B -= 1;

        M--;
    }

    cout << ans << endl;
    return 0;
}
//  [c]
// AtCoder ABC121: C - Energy Drink Collector
// 2019.9.9 bal4u
// Template for Online Contest

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

typedef long long ll;

#define gc() getchar()
#define pc(c) putchar(c)

int in() {  // 整数の入力
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

ll inL() {  // long long 整数の入力
	ll n = 0; int c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n) { // 整数の表示
	int i; char b[30];
	if (!n) pc('0');
	else {
		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

void outL(ll n) { // 整数の表示
	int i; char b[30];
	if (!n) pc('0');
	else {
		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

int ins(char *s) { // 文字列の入力
	char *p = s--;
	do *++s = gc();
	while (*s > ' ');
	*s = 0;
	return s - p;
}

void outs(char *s) {  // 文字列の表示
	while (*s) pc(*s++);
}

#define MIN(a,b)  ((a)<=(b)?(a):(b))
#define MAX(a,b)  ((a)>=(b)?(a):(b))
#define ABS(a)    ((a)>=0?(a):-(a))
inline static int chmax(int *a, int b) { if (*a < b) *a = b; }
inline static ll  chmaxL(ll *a, int b) { if (*a < b) *a = b; }
inline static int chmin(int *a, int b) { if (*a > b) *a = b; }
inline static ll  chminL(ll *a, int b) { if (*a > b) *a = b; }

typedef struct { int a, b; } T;
T t[100005];
int N, M;
ll ans;

int cmp(const void *u, const void *v) {	return ((T *)u)->a - ((T *)v)->a; }

int main()
{
	int i, s;

	N = in(), M = in();
	for (i = 0; i < N; i++) t[i].a = in(), t[i].b = in();
	qsort(t, N, sizeof(T), cmp);
	s = 0; for (i = 0; i < N; i++) {
		if (s + t[i].b <= M) ans += (ll)t[i].a * t[i].b, s += t[i].b;
		else { ans += (ll)(M-s)*t[i].a; break; }
	}
	outL(ans);
	return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

long int a[100000][2];

void quick_sort(long int a[100000][2], int i, int j);
int partition(long int a[100000][2], int i, int j);

int main(void)
{
	
	int n, m;
	int i;
	long int sum = 0;
	long int money = 0;
	int count_i;
	
	scanf("%d%d", &n, &m);
	
	for(i = 0; i < n; i++) {
		scanf("%ld%ld", &a[i][0], &a[i][1]);
	}
	
	quick_sort(a, 0, n - 1);
	
	for(i = 0; i < n; i++) {
		sum += a[i][1];
		if(sum >= m) {
			count_i = i;
			break;
		}
	}
	
	sum = 0;
	
	for(i = 0; i < count_i; i++) {
		sum += a[i][1];
		money += a[i][0] * a[i][1];
	}
	
	money += a[count_i][0] * (m - sum);
	
	printf("%ld", money);
	
	return 0;
}

void quick_sort(long int a[100000][2], int i, int j)
{
	int k;
	
	if(i == j) {
		return;
	}
	
	if( (k = partition(a, i, j)) == -1) {
		return;
	}
	
	quick_sort(a, i, k - 1);
	quick_sort(a, k, j);
	
	return;
}

int partition(long int a[100000][2], int i, int j)
{
	int l = i, r = j;
	long int k;
	long int work;
	
	k = a[l][0];
	
	while(l <= r) {
		
		while(a[l][0] < k && l <= j) {
			l++;
		}
		
		while(a[r][0] > k && r >= i) {
			r--;
		}
		
		if(l > r) {
			break;
		}
		work = a[l][0];
		a[l][0] = a[r][0];
		a[r][0] = work;
		
		work = a[l][1];
		a[l][1] = a[r][1];
		a[r][1] = work;
		
		l++;
		r--;
		
	}
	
	return l;
}
//  [c]
#include <stdio.h>
void swap (long long int *x,long long int *y) {
  long long temp = *x;
  *x = *y;
  *y = temp;
}
int partition (long long int array[],long long int ary[],long long int left,long long int right) {
  long long int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;
  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    if (i < j) {
      swap(&array[i], &array[j]);
      swap(&ary[i], &ary[j]);
    }
  } while (i < j);
  swap(&array[pivot], &array[j]);
  swap(&ary[pivot], &ary[j]);
  return j;
}
void quick_sort (long long int array[],long long int ary[],long long int left,long long int right) {
  long long int pivot;
  if (left < right) {
    pivot = partition(array,ary,left,right);
    quick_sort(array,ary,left,pivot-1);
    quick_sort(array,ary,pivot+1,right);
  }
}
int main(){
  long long int n,m,cnt = 0,ans = 0;
  scanf("%lld %lld",&n,&m);
  long long int a[n],b[n];
  for(int i = 0;i < n;i++){
    scanf("%lld %lld",&a[i],&b[i]);
  }
  quick_sort(a,b,0,n - 1);
  for(long long int i = 0;i < n;i++){
    if(b[i] < m){
      m -= b[i];
      ans += a[i] * b[i];
    }else{
      printf("%lld\n",ans + a[i] * m);
      return 0;
    }
  }
}
//  [c]
#include <stdio.h>
#include <limits.h>
 
int main(void){
  long long int n,m;
  long long int i;
  long long int kei = 0;
  long long int a[100000];
  long long int b[100000];
  scanf("%lld %lld",&n,&m);
  for (i = 0; i<n; i++){
     scanf("%lld %lld", &a[i],&b[i]);  //ここまで配列の準備
  }
  
  int j, increment, temp, temp_b;
  increment = 4;
  int array_size = n;
  while (increment > 0){
    for (i=0; i < array_size; i++){
      j = i;
      temp = a[i];
      temp_b = b[i];
      while ((j >= increment) && (a[j-increment] > temp)){
        a[j] = a[j - increment];
        b[j] = b[j - increment];
        j = j - increment;
      }
      a[j] = temp;
      b[j] = temp_b;
    }
    if (increment/2 != 0)
      increment = increment/2;
    else if (increment == 1)
      increment = 0;
    else
      increment = 1;
  }
  for (i = 0; i<n; i++){
    if(m>=b[i]){
      kei = (a[i]*b[i]) + kei;
    }else if(m==0){
      break;
    }else{
      kei = kei + (a[i]*m);
      break;
    }
    m = m - b[i];
  }
  printf("%lld",kei);
  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int N, M;
    int *A, *B, *A2, *B2;
    char c;
    
    int i, j;
    int Ai, Bi;
    long long int cost;
    int cans;
    
    
    scanf("%d%c%d", &N, &c, &M);
    
    
    A = (int*)malloc(sizeof(int)*N/2);
    B = (int*)malloc(sizeof(int)*N/2);
    A2 = (int*)malloc(sizeof(int)*N/2);
    B2 = (int*)malloc(sizeof(int)*N/2);
    
    
    scanf("%d%c%d", &A[0], &c, &B[0]);
    
    if(N > 1)
        scanf("%d%c%d", &A2[0], &c, &B2[0]);
    
    
    for(i=2; i<N; i++)
    {
        scanf("%d%c%d", &Ai, &c, &Bi);
        
        if(i%2 == 0)
        {
            for(j=i/2-1; j>=0; j--)
            {
                if(A[j] < Ai)
                {
                    A[j+1] = A[j];
                    B[j+1] = B[j];
                }
                else
                    break;
            }
            A[j+1] = Ai;
            B[j+1] = Bi;
        }
        else
        {
            for(j=i/2-1; j>=0; j--)
            {
                if(A2[j] < Ai)
                {
                    A2[j+1] = A2[j];
                    B2[j+1] = B2[j];
                }
                else
                    break;
            }
            A2[j+1] = Ai;
            B2[j+1] = Bi;
        }
    }
    
    
    cost = 0;
    cans = M;
    
    i = N/2+N%2-1;
    j = N/2-1;
    
    
    while(cans > 0)
    {
        if(i >= 0 && j >= 0)
        {
            if(A[i] < A2[j])
            {
                if(B[i] < cans)
                {
                    cost += (long long int)A[i]*B[i];
                    cans -= B[i];
                }
                else
                {
                    cost += (long long int)A[i]*cans;
                  
                    break;
                }
                i--;
            }
            else
            {
                if(B2[j] < cans)
                {
                    cost += (long long int)A2[j]*B2[j];
                    cans -= B2[j];
                }
                else
                {
                    cost += (long long int)A2[j]*cans;
                  
                    break;
                }
                j--;
            }
        }
        else if(i >= 0)
        {
            if(B[i] < cans)
            {
                cost += (long long int)A[i]*B[i];
                cans -= B[i];
            }
            else
            {
                cost += (long long int)A[i]*cans;
                
                break;
            }
            i--;
        }
        else
        {
            if(B2[j] < cans)
            {
                cost += (long long int)A2[j]*B2[j];
                cans -= B2[j];
            }
            else
            {
                cost += (long long int)A2[j]*cans;
                
                break;
            }
            j--;
        }
    }
    
    
    printf("%lld\n", cost);
    
    
    free(A);
    free(B);
    free(A2);
    free(B2);
    
    
    //system("pause");
    
    
    return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000


void merge_sort(int *t1, int *s1, int left, int right);


int main(){
  char buf[1024];
  int N,M;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d %d", &N, &M);

  int *A=(int *)malloc(sizeof(int)*N);
  int *B=(int *)malloc(sizeof(int)*N);

  rep(i,N){
    fgets(buf,sizeof(buf),stdin);
    sscanf(buf, "%d %d", &A[i], &B[i]);
  }

  merge_sort(A, B, 0, N-1);

  long sum=0;
  long count=0;
  int number=0;

  while(number!=N && count+B[number]<=M){
    //printf("A[%d] = %d, B[%d] = %d\n", number, A[number], number, B[number]);
    //ここ、マジで重要。long型の変数を用意するのと、int*intの演算時点でlongにキャストすること。
    sum+=(long)A[number]*B[number];
    count+=B[number];
    number++;
    //printf("%ld\n", sum);
  }

  sum+=A[number]*(M-count);

  printf("%ld\n", sum);

  return 0;

}


void merge_sort(int *t1, int *s1, int left, int right){    //アドレスが渡される
    if(left==right){
        ;
    }
    else{
        int n2=(right-left+1)/2;
        int n3=right-left+1-n2;
        int i=0,j=0,k=0;

        // rep(p,n2+n3){
        //   printf("t1[%d] = %p, t1[%d][0] = %d, t1[%d][1] = %d\n", p, t1[p], p, t1[p][0], p, t1[p][1]);
        // }

        merge_sort(t1, s1, left, left+n2-1);
        merge_sort(t1, s1, left+n2, right);

        int *t2=(int *)malloc(sizeof(int)*n2);
        int *t3=(int *)malloc(sizeof(int)*n3);
        int *s2=(int *)malloc(sizeof(int)*n2);
        int *s3=(int *)malloc(sizeof(int)*n3);

        for(i=0;i<n2;i++){
          t2[i]=t1[left+i];
          s2[i]=s1[left+i];
        }
        for(i=0;i<n3;i++){
          t3[i]=t1[left+n2+i];
          s3[i]=s1[left+n2+i];
        }

        // printf("t2[0] = %d, t3[0] = %d\n", t2[0], t3[0]);
        // printf("s2[0] = %d, s3[0] = %d\n", s2[0], s3[0]);

        //ここの実装にn時間かかった。定義されていない領域にアクセスしないの重要。
        for(i=0;i<n2+n3;i++){
            if(k==n3 || (j<n2 && t2[j]<t3[k])){
                t1[left+i]=t2[j];
                s1[left+i]=s2[j];
                j++;
            }
            else{
                t1[left+i]=t3[k];
                s1[left+i]=s3[k];
                k++;
            }
        }
    }
}
//  [javascript]
const main = (input) => {
  const inputs = input.trim().split('\n');
  const N = Number.parseInt(inputs[0].split(" ")[0]);
  var M = Number.parseInt(inputs[0].split(" ")[1]);

  var shops = [];
  for(var i=1;i<=N;i++){
    var obj = {
      pri: Number(inputs[i].split(" ")[0]),
      num: Number(inputs[i].split(" ")[1]),
    };
    shops.push(obj);
  }
  shops = shops.sort(function(a,b){return a.pri-b.pri});
  var ans = 0;
  for(var i=0;M>0;i++){
    var num = Math.min(M, shops[i].num);
    ans += num*shops[i].pri;
    M -= num;
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));
//  [javascript]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.main = function (N, M, abList) {
    abList.sort(function (x, y) {
        if (x[0] < y[0])
            return -1;
        if (x[0] > y[0])
            return 1;
        return 0;
    });
    var res = 0;
    var remain = M;
    for (var i = 0; i < N; i++) {
        var _a = abList[i], a = _a[0], b = _a[1];
        if (b < remain) {
            res += a * b;
            remain -= b;
        }
        else {
            res += a * remain;
            break;
        }
    }
    return res;
};
var input = require('fs').readFileSync('/dev/stdin', 'UTF-8');
var lines = input.split('\n');
var _a = lines[0].split(' ').map(function (item) { return Number(item); }), N = _a[0], M = _a[1];
var abList = [];
for (var i = 0; i < N; i++) {
    abList.push(lines[i + 1].split(' ').map(function (l) { return Number(l); }));
}
var res = exports.main(N, M, abList);
console.log(res);
//  [javascript]
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let [n,m] = nextIntArray()
    let ab = []
    while(hasNext()){
        ab.push(nextIntArray())
    }
    ab.sort((a,b) => a[0]-b[0])
    let ans = 0
    let i = 0
    while(m>0){
        if(m > ab[i][1]){
            ans += ab[i][0]*ab[i][1]
            m -= ab[i][1]
        }else{
            ans += ab[i][0]*m
            m = 0
        }
        i++
    }
    console.log(ans)
}
Main()
//  [javascript]
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var a = o.m(n);
  a.sort((a,b)=>a[0]-b[0]);
  var ans = 0;
  var c = 0;
  for(var i = 0; i < n; i++){
    if(m-c <= a[i][1]){
      ans += (m-c) * a[i][0];
      break;
    }
    ans += a[i][0] * a[i][1];
    c += a[i][1];
  }
  return ans;
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// sort struct

// https://atcoder.jp/contests/abc121/submissions/4519585
func main() {
	var n, m int
	fmt.Scan(&n, &m)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	es := make(entries, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())

		sc.Scan()
		b, _ := strconv.Atoi(sc.Text())

		es[i].a = a
		es[i].b = b
	}
	sort.Sort(es)

	ans := 0
	num := 0
	for _, e := range es {
		if num+e.b < m {
			ans += e.a * e.b
			num += e.b
		} else {
			ans += (m - num) * e.a
			break
		}
	}
	fmt.Println(ans)
}

type entry struct {
	a, b int
}

type entries []entry

func (es entries) Len() int {
	return len(es)
}

func (es entries) Swap(i, j int) {
	es[i], es[j] = es[j], es[i]
}
func (es entries) Less(i, j int) bool {
	return es[i].a < es[j].a
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

type pair struct{ f, s int }

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}

func (p pairs) Less(i, j int) bool {
	return p[i].f < p[j].f
}

func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func parseProblem() int {
	n := scanInt(sc)
	m := scanInt(sc)
	ps := make([]pair, n)
	for i := 0; i < n; i++ {
		a := scanInt(sc)
		b := scanInt(sc)
		ps[i] = pair{f: a, s: b}
	}
	sort.Sort(pairs(ps))
	rest := m
	budget := 0
	for _, store := range ps {
		if store.s <= rest {
			budget += store.f * store.s
			rest -= store.s
		} else {
			budget += store.f * rest
			rest = 0
			break
		}
	}
	return budget
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n, m := scanInt(), scanInt()
	type shop struct{ p, s int }
	s := make([]shop, n)
	for i := 0; i < n; i++ {
		s[i].p, s[i].s = scanInt(), scanInt()
	}
	sort.Slice(s, func(i, j int) bool { return s[i].p < s[j].p })

	count := 0
	sum := 0
	for i := 0; i < n; i++ {
		if v := count + s[i].s; v >= m {
			sum += s[i].p * (m - count)
			break
		} else {
			count = v
			sum += s[i].p * s[i].s
		}
	}
	fmt.Println(sum)
}
//  [go]
package main

import (
	"fmt"
	"sort"
)

func main() {
	// Code for C - Energy Drink Collector
	var N, M int
	fmt.Scanf("%d %d", &N, &M)

	A := make(map[int]int, N)
	B := make([]int, 0)
	var a, b int
	for i := 0; i < N; i++ {
		fmt.Scanf("%d %d", &a, &b)
		if A[a] == 0 {
			B = append(B, a)
		}
		A[a] += b
	}

	var count int
	var cost int
	sort.Sort(sort.IntSlice(B))

	for i := 0; i < N; i++ {

		if M >= count+A[B[i]] {
			count += A[B[i]]
			cost += A[B[i]] * B[i]
		} else {
			cost += (M - count) * B[i]
			count = M
		}

		if count == M {
			break
		}
	}

	fmt.Println(cost)
}
//  [go]
package main

import (
        "fmt"
        "sort"
)

func solution(n, m int, matrix [][2]int) int {
        sort.SliceStable(matrix, func(i, j int) bool {
                if matrix[i][0] == matrix[j][0] {
                        return matrix[i][1] > matrix[j][1]
                }
                return matrix[i][0] < matrix[j][0]
        })

        out := 0
        for i := range matrix {
                if m >= matrix[i][1] {
                        m -= matrix[i][1]
                        out += matrix[i][0] * matrix[i][1]
                } else {
                        out += matrix[i][0] * m
                        m = 0
                }
                if m <= 0 {
                        break
                }
        }
        return out
}

func main() {
        var n, m int
        fmt.Scan(&n, &m)
        matrix := make([][2]int, n)
        for i := 0; i < n; i++ {
                fmt.Scan(&matrix[i][0], &matrix[i][1])
        }
        fmt.Println(solution(n, m, matrix))
}
//  [go]
package main

import (
	"fmt"
	"sort"
)

type pair struct {
	yen, num int
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	
	drinks := make([]pair, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&drinks[i].yen, &drinks[i].num)
	}
	
	sort.Slice(drinks, func(i, j int) bool {
		return drinks[i].yen < drinks[j].yen
	})
	
	ans := 0
	for _, v := range drinks {
		buy := min(v.num, m)
		ans += buy * v.yen
		m -= buy
		if m < 0 {
			break
		}
	} 
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
//  [ruby]
N,M = gets.chomp.split(" ").map(&:to_i)
arr = []
N.times do |i|
  a,b = gets.chomp.split(" ").map(&:to_i)
  arr << [a,b]
end
arr = arr.sort_by{|x| x[0]}
cnt = M
i = 0
money = 0
while cnt > 0
  if cnt >= arr[i][1]
    money += arr[i][0] * arr[i][1]
    cnt -= arr[i][1]
  else
    money += arr[i][0] * cnt
    cnt = 0
  end
  i += 1
end
puts money
//  [ruby]
io = STDIN
n,m=io.gets.split.map(&:to_i)
ar=n.times.map{io.gets.split.map(&:to_i)}
tot=0
ar.sort_by{|a,b|a}.each do|a,b|
  if m>b
    tot+=a*b
    m-=b
  else
    tot+=a*m
    m=0
  end
  break if m<=0
end
puts tot
//  [ruby]
(N, M), *ABs = readlines.map{|l| l.split.map(&:to_i)}

m, x = 0, 0
ABs.sort_by{|a, b| a}.each do |a, b|
  if m + b >= M
    x += a*(M - m)
    break
  else
    m += b
    x += a*b
  end
end
puts x
//  [ruby]
 n, m = gets.split.map(&:to_i)           
 ab = Hash.new(0)                        
 n.times do                              
   a, b = gets.split.map(&:to_i)         
   ab[a] += b                            
 end                                     
 price = ab.sort {|a, b| a[0] <=> b[0] } 
                                         
 ans = 0                                 
 while m > 0 do                          
   c = [m, price[0][1]].min              
   ans += price[0][0] * c                
   price.delete_at(0)                    
   m -= c                                
 end                                     
                                         
 puts ans
//  [ruby]
N,m = gets.split.map(&:to_i)
drinks = [] #値段、本数
N.times{|i|
	drinks << gets.split.map(&:to_i)
}

d = drinks.sort{|a,b| a[0] <=> b[0]}

sum = 0


while m > 0
  if d[0][1] < m
	sum += d[0][0]*d[0][1]
  else
    sum += d[0][0]*m
  end
  m -= d[0][1]
  d.delete_at(0)
end

puts sum
//  [ruby]
n,m = gets.chomp.split.map{|i|i = i.to_i}
a=[]
n.times do|i|
  arr = gets.chomp.split.map{|i|i = i.to_i}
	a << [arr[0],arr[1]]
end
#puts "n=#{n}, m=#{m}"
a.sort_by!{|i|i[0]}

#puts "a=#{a}"
drink_num=0
sum_money=0
while drink_num<m do
	if (m-drink_num) < a[0][1] then
		sum_money += (m - drink_num) * a[0][0]
		drink_num += (m - drink_num)
		break
	else
		drink_num += a[0][1]
		sum_money += a[0][1] * a[0][0]
		a.delete_at(0)
	end
	#puts "now a = #{a}, drink_num = #{drink_num}, sum_money = #{sum_money}"
end
#puts "final, drink_num=#{drink_num}, sum_money=#{sum_money}"
puts sum_money
//  [rust]
#![allow(unused_imports)]

#[macro_use]
mod _input {
    use std::fmt;
    use std::io::{self, Read};
    use std::str::{self, FromStr};

    macro_rules! input {
        ($($name:ident : $t:tt),*,) => {
            input!($($name: $t),*)
        };
        ($($name:ident : $t:tt),*) => {
            let mut _scanned = ::_input::Scanned::new(::std::io::stdin(), 1024);
            $(
                let $name = unsafe { _read_value!(_scanned, $t) };
            )*
        };
    }

    macro_rules! _read_value {
        ($scanned:expr, ($($t:tt),*)) => {
            ($(_read_value!($scanned, $t)),*)
        };
        ($scanned:expr, [$t:tt; $n:expr]) => {
            (0..$n).map(|_| _read_value!($scanned, $t)).collect::<Vec<_>>()
        };
        ($scanned:expr, _bytes) => {
            _read_value!($scanned, String).into_bytes()
        };
        ($scanned:expr, _1based) => {
            _read_value!($scanned, usize) - 1
        };
        ($scanned:expr, $t:ty) => {
            $scanned.next::<$t>()
        };
    }

    pub struct Scanned {
        buf: Vec<u8>,
        pos: usize,
    }

    impl Scanned {
        pub fn new<R: Read>(mut input: R, estimated: usize) -> Self {
            let mut buf_ = Vec::with_capacity(estimated);
            let _ = io::copy(&mut input, &mut buf_).unwrap();
            debug_assert!(str::from_utf8(&buf_).is_ok());
            debug_assert!(buf_.iter().all(|&c| u32::from(c) <= 0x7F));
            Scanned { buf: buf_, pos: 0 }
        }

        #[inline]
        pub unsafe fn next<T: FromStr>(&mut self) -> T
        where
            T::Err: fmt::Debug,
        {
            let mut start = None;
            loop {
                match (self.buf[self.pos], start.is_some()) {
                    (b' ', true) | (b'\n', true) => break,
                    (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                    (_, false) => start = Some(self.pos),
                }
            }
            let target = &self.buf[start.unwrap()..self.pos];
            str::from_utf8_unchecked(target).parse().unwrap()
        }
    }
}

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Stderr, StderrLock, Stdout, StdoutLock, Write};
use std::num::{ParseFloatError, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign,
};
use std::str::{self, FromStr};
use std::{char, cmp, f32, f64, fmt, i16, i32, i64, i8, mem, thread, u16, u32, u64, u8};

fn main() {
    input! {
        n: usize,
        m: u64,
        abs: [(u64, u64); n],
    }
    let mut abs = abs;
    abs.sort_by_key(|&(a, _)| a);
    let (mut r, mut m) = (0, m);
    for (a, b) in abs {
        if m <= b {
            r += a * m;
            println!("{}", r);
            return;
        } else {
            r += a * b;
            m -= b;
        }
    }
    unreachable!();
}
//  [rust]

fn func(input_str: &str) -> u64 {
    let mut iter = input_str.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: u64 = iter.next().unwrap().parse().unwrap();
    let mut ab_s = vec![(0, 0); n];
    for i in 0..n {
        let a: u64 = iter.next().unwrap().parse().unwrap();
        let b: u64 = iter.next().unwrap().parse().unwrap();
        ab_s[i] = (a, b);
    }
    ab_s.sort_by_key(|x| x.0);
    let mut ans = 0;
    let mut m_remain = m;
    for i in 0..n {
        let (a, b) = ab_s[i];
        if m_remain >= b {
            m_remain -= b;
            ans += a * b;
        } else {
            ans += a * m_remain;
            return ans;
        }
    }
    ans
}

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    println!("{}", func(&buf[..]));
}
//  [rust]
#[allow(dead_code)]
fn main() {
    let (n, m) = i::u2();
    let ab = i::uv2(n);
    let mut cost = Vec::new();
    let mut map: HashMap<usize, usize> = HashMap::new();
    for (a, b) in ab {
        if map.contains_key(&a.clone()) {
            *map.entry(a).or_insert(0) += b;
        } else {
            cost.push(a);
            map.insert(a.clone(), b);
        }
    }
    cost.sort();
    let mut ans = 0;
    let mut count = 0;
    for c in cost {
        let cc = map[&c];
        if count + cc < m {
            ans += cc * c;
            count += cc;
            continue;
        }
        ans += (m - count) * c;
        break;
    }
    println!("{}", ans);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}
//  [rust]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let n: usize = read!();
    let m: usize = read!();
    let mut shops = Vec::with_capacity(n);

    for _ in 0..n {
        let a: usize = read!();
        let b: usize = read!();
        shops.push((a, b));
    }

    shops.sort();

    let mut remaining_number = m;
    let mut sum_cost = 0;
    for (cost, limit) in shops {
        if limit <= remaining_number {
            remaining_number -= limit;
            sum_cost += cost * limit;
        } else {
            let amount_buy = remaining_number;
            sum_cost += cost * amount_buy;
            break;
        }
    }

    println!("{}", sum_cost);
}
//  [rust]
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    let n: usize = read!();
    let m: usize = read!();
    let mut zz = Vec::new();
    let mut mm = m;
    let mut sum = 0;
    for _ in 0..n {
        let a: usize = read!();
        let b: usize = read!();
        zz.push((a, b));
    }
    zz.sort();
    for (cost, lim) in zz {
        if lim <= mm {
            mm -= lim;
            sum += cost * lim;
        } else {
            sum += cost * mm;
            break;
        }
    }
    println!("{}", sum);
}
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}
///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let nm = readInts()
    let (n, m) = (nm[0], nm[1])
    var aryAB = [[Int]]()
    
    for _ in 0..<n {
        aryAB.append(readInts())
    }
    
    aryAB.sort { $0[0] < $1[0] }
    
    var value = 0
    var drinkCounter = 0
    var i = 0
    while drinkCounter <= m && i < n{
        value += aryAB[i][0] * aryAB[i][1]
        drinkCounter += aryAB[i][1]
        i += 1
    }
    value -= (drinkCounter - m) * aryAB[i - 1][0]
    print(value)
}
main()
//  [swift]
import Foundation

extension String {
    func split(separator: String) -> [Int] {
        return self.componentsSeparatedByString(separator).map { Int($0)! }
    }
}

let input = readLine()!.split(" ")
let N = input[0]
let M = input[1]

var AB = [[Int]]()
for _ in 0..<N {
    let input = readLine()!.split(" ")
    AB.append([input[0], input[1]])
}
AB.sortInPlace{$0[0] < $1[0]}

var ans = 0
var i = 0
var j = 0
for _ in 0..<M {
    if i+1 > AB[j][1] {
        j += 1
      	i = 0
    }
    ans += AB[j][0]
  	i += 1
}

print(ans)
//  [typescript]
import fs = require('fs');
if(process.argv[1].match(/Main.js$/)) { console.log(main(fs.readFileSync('/dev/stdin', 'utf8').trim().split(/[\r\n\t ]+/))); }

export function main(strings: string[]): string {
	const ret: any[] = [];
	const numbers = strings.map(Number);

	numbers.shift();
	const M = numbers.shift() as number;

	const shops: [number, number][] = [];

	for(let i=0; i<=numbers.length;) {
		if(numbers[i] == null || numbers[i+1] == null) {
			break;
		}
		shops.push([
			numbers[i],
			numbers[i+1],
		]);
		i += 2;
	}

	shops.sort((a, b) => a[0] - b[0]);

	let sum = 0;
	let m = 0;
	for(let shop of shops) {
		if(shop[1] + m > M) {
			sum += shop[0] * (M - m);
			break;
		} else {
			sum += shop[0] * shop[1];
			m += shop[1];
		}
	}

	ret.push(sum)
	return ret.join('\n') + '\n';
}
//  [typescript]
import { readFileSync } from 'fs'

function main(input: string) {
  const [[N, M], ...lines] = input.split('\n').map(v => v.split(' ').map(Number))

  const sorted = lines.slice().sort(([xa, _xb], [ya, _yb]) => xa - ya)

  let total = {
    amount: 0,
    qty: 0,
  }

  for (const [a, b] of sorted) {
    const qty = total.qty + b <= M ? b : M - total.qty
    const amount = a * qty

    total.amount += amount
    total.qty += qty

    if (total.qty >= M) break
  }

  console.log(total.amount)
}

main(readFileSync('/dev/stdin', 'utf8').trim())
//  [typescript]
function main(input) {
  input = input.trim().split("\n");
  const [n, m] = input[0].split(" ").map(n => Number(n));
  const ab = input.slice(1).map(l => l.split(" ").map(m => Number(m));
  ab.sort((l, m) => {
  	const [la, lb] = l;
    const [ma, mb] = m;
    return la-ma;
  });
  let cnt = 0;
  let result = 0;
  for (let i = 0; i < n; i++) {
    const [a, b] = ab[i];
    const min = Math.min(m-cnt, b);
    cnt += min;
    result += a*min;
    if (cnt === m) break;
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
export class Main {
  static main(input): string {
    const [one, ...list]: string[] = input.split("\n");
    const [n, m]: number[] = one.split(" ").map(Number);
    const ablist: number[][] = list.slice(0, n).map(l => l.split(" ").slice(0, 2).map(Number));
    ablist.sort(([a, b], [a2, b2]) => a - a2);
    let money: number = 0;
    let drink: number = 0;
    for (let i: number = 0, len: number = ablist.length; i < len; i++) {
      const [a, b]: number[] = ablist[i];
      if (drink + b >= m) {
        money += a * (m - drink);
        break;
      }
      money += a * b;
      drink += b;
    }
    return `${money}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));
//  [typescript]
const fs = require('fs')
const stdin = fs.readFileSync('/dev/stdin', 'utf8')

const [n_m, ...rest] = stdin.split('\n')

const [N, M] = n_m.split(' ').map(Number)

const ab = rest.filter(e => e).map(e => e.split(' ').map(Number))

const sortedAB = ab.sort((p, c) => p[0] - c[0])

let i = 0
let cost = 0
let reqCount = M

while(1){
  if(reqCount > sortedAB[i][1]){
    reqCount -= sortedAB[i][1]
    cost += sortedAB[i][0] * sortedAB[i][1]
  } else {
    cost += sortedAB[i][0] * reqCount
    break
  }
  i++
}

console.log(cost)
//  [python]
N = int(input())
H = int(input())
W = int(input())
print((N - W + 1) * (N - H + 1))
//  [python]
import math
n = int(input())
H = int(input())
W = int(input())

print((n-H+1)*(n-W+1))
//  [python]
N = int(input())
H = int(input())
W = int(input())
print((N - H + 1) * (N - W + 1))
//  [python]
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 12 20:43:41 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Dec 29 18:42:51 2018

@author: Owner
"""

import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter
import itertools
#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
"""
N, X = map(int, input().split())

x = [0]*N
x[:] = map(int, input().split())

P = [0]*M
Y = [0]*M
for m in range(M):
    P[m], Y[m] = map(int, input().split())
    
all(nstr.count(c) for c in '753')
"""


N = int(input())
H = int(input())
W = int(input())

num = (N-H+1)*(N-W+1)

print(num)
//  [python]
import sys

import numpy as np


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


N = ii()
H = ii()
W = ii()
print((N - H + 1) * (N - W + 1))
//  [python]
#      
import collections, atexit, math, sys, bisect 

sys.setrecursionlimit(1000000)
def getIntList():
    return list(map(int, input().split()))    

try :
    #raise ModuleNotFoundError
    import numpy
    def dprint(*args, **kwargs):
        #print(*args, **kwargs, file=sys.stderr)
        # in python 3.4 **kwargs is invalid???
        print(*args,  file=sys.stderr)
    dprint('debug mode')
except Exception:
    def dprint(*args, **kwargs):
        pass



inId = 0
outId = 0
if inId>0:
    dprint('use input', inId)
    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #标准输出重定向至文件
if outId>0:
    dprint('use output', outId)
    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #标准输出重定向至文件
    atexit.register(lambda :sys.stdout.close())     #idle 中不会执行 atexit
    
N, = getIntList()
H, = getIntList()
W, = getIntList()
#print(N)
r =0

r +=  (N-H+1) * (N-W+1)

print(r)
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) {

		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


			String line = br.readLine();
			int N = Integer.parseInt(line);
			line = br.readLine();
			int H = Integer.parseInt(line);
			line = br.readLine();
			int W = Integer.parseInt(line);

			int nh = N-H+1;
			int nw = N-W+1;

			System.out.println(nh*nw);
			//String[] strs = line.split(" ");//区切りで変える
			//int[] ia = new int[strs.length]; for(int i = 0;i<strs.length;i++){ia[i] = Integer.parseInt(strs[i]);}Integer.parseInt
			//Java8
			//int[] ia = Stream.of(strs).mapToInt(Integer::parseInt).toArray();


		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}

	}

}
//  [java]
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n = scanner.nextInt();
		int h=scanner.nextInt();
		int w=scanner.nextInt();
		System.out.println((n-h+1)*(n-w+1));
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
//  [java]
import java.io.*;
import java.util.*;
import java.util.Map.Entry;

public class Main {
		
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		int H = sc.nextInt();
		int W = sc.nextInt();
		int ans = 0;
		
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				if(i + H <= N && j + W <= N) ans++;
			}
		}
		
		System.out.println(ans);
		
	}//end main
	
}//end Main

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}
//  [java]
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        scanner.close();

        int ansOfHeight = n - h + 1;
        int ansOfWidth = n - w + 1;

        System.out.println(ansOfHeight * ansOfWidth);
    }

}