#include #include #include #include #include #include //#include using namespace std; #define MAX(x,y) (x>y?x:y) #define MIN(x,y) (x0?x:-(x)) #define INF 1000000000 void swap(int* a, int* b) { int tmp; tmp = *a; *a = *b; *b = tmp; } void swap2(double* a, double* b) { double tmp; tmp = *a; *a = *b; *b = tmp; } int gcd(int a, int b) { if (a < b) swap(&a, &b); if (a % b == 0) return b; else return gcd(b, a % b); } int lcm(int a, int b) { return a * b / gcd(a, b); } int factorial(int n) { int a=1; if (n == 0) return 1; for (int i = 1; i <= n; i++) a *= i; return a; } int Con(int a, int b) { return factorial(a) / (factorial(b) * factorial(a - b)); } int a[20] = { 0 }; //int binary_search(int key) //{ // int low, high, middle; // // low = 0; // high = 20 - 1; // // // // while (low <= high) // { // middle = (low + high) / 2; // if (key == a[middle]) // return middle; // else if (key < a[middle]) // high = middle - 1; // else if (key > a[middle]) // low = middle + 1; // } // return INF; //} int binary_search(long long int key) { long long int low = 0, high = 2000000000, middle; long long int p; while (low <= high) { middle = (low + high) / 2; //printf("%d \n", middle); p = (middle * (middle + 1)); if (p == key*2) return 1; else if (p >key*2) high = middle - 1; else low = middle + 1; } return 0; } int main() { //for (int i = 0; i < 20; i++) // a[i] = rand() % 50; // //sort(a, a + 20); //for (int i = 0; i < 20; i++) // printf("%d\n", a[i]); //for (int i = 0; i < 20; i++) //{ // printf(" %d\n",binary_search(i)); //} long long int n; scanf("%lld", &n); if (binary_search(n) == 1) printf("YES"); else printf("NO"); }