https://www.acmicpc.net/problem/1292
using System;
class Program
{
static void Main() {
string[] s=Console.ReadLine().Split(' ');
int n=int.Parse(s[0]);
int m=int.Parse(s[1]);
int num=0;
int a=0;
int count=0;
for(int i=1;;i++){
count+=i;
a+=i*i;
if(n-count-1<=i && n!=1){
num-=a;
num-=(n-count-1)*(i+1);
n=10000;
}
if(m-count-1<=i){
num+=a;
num+=(m-count)*(i+1);
break;
}
}
Console.Write(num);
}
}