output
stringlengths 52
181k
| instruction
stringlengths 296
182k
|
---|---|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t, p, r, ans, i, n, m, x, y, s;
cin >> n >> m >> x;
s = max(n, max(m, x));
r = (n + m + x) - s;
if (r > s)
cout << 0 << endl;
else
cout << s - r + 1 << endl;
}
| ### Prompt
Please provide a CPP coded solution to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t, p, r, ans, i, n, m, x, y, s;
cin >> n >> m >> x;
s = max(n, max(m, x));
r = (n + m + x) - s;
if (r > s)
cout << 0 << endl;
else
cout << s - r + 1 << endl;
}
``` |
#include <bits/stdc++.h>
int a[3];
int main() {
scanf("%d%d%d", a, a + 1, a + 2);
std::sort(a, a + 3);
printf("%d", std::max(a[2] + 1 - a[1] - a[0], 0));
return 0;
}
| ### Prompt
Construct a CPP code solution to the problem outlined:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int a[3];
int main() {
scanf("%d%d%d", a, a + 1, a + 2);
std::sort(a, a + 3);
printf("%d", std::max(a[2] + 1 - a[1] - a[0], 0));
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int arr[3];
for (int i = 0; i < 3; i++) {
cin >> arr[i];
}
sort(arr, arr + 3);
int answer = arr[2] - (arr[1] + arr[0]) + 1;
if (answer < 0) answer = 0;
cout << answer << endl;
return 0;
}
| ### Prompt
Please create a solution in cpp to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int arr[3];
for (int i = 0; i < 3; i++) {
cin >> arr[i];
}
sort(arr, arr + 3);
int answer = arr[2] - (arr[1] + arr[0]) + 1;
if (answer < 0) answer = 0;
cout << answer << endl;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
std::ios::sync_with_stdio(false);
int a, b, c;
cin >> a >> b >> c;
long long int sum_1 = a + b;
long long int sum_2 = b + c;
long long int sum_3 = c + a;
if (sum_1 > c && sum_2 > a && sum_3 > b) {
cout << 0 << endl;
return 0;
}
if (sum_1 <= c) {
cout << c - sum_1 + 1 << endl;
return 0;
}
if (sum_2 <= a) {
cout << a - sum_2 + 1 << endl;
return 0;
}
if (sum_3 <= b) {
cout << b - sum_3 + 1 << endl;
return 0;
}
return 0;
}
| ### Prompt
Please formulate a CPP solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
std::ios::sync_with_stdio(false);
int a, b, c;
cin >> a >> b >> c;
long long int sum_1 = a + b;
long long int sum_2 = b + c;
long long int sum_3 = c + a;
if (sum_1 > c && sum_2 > a && sum_3 > b) {
cout << 0 << endl;
return 0;
}
if (sum_1 <= c) {
cout << c - sum_1 + 1 << endl;
return 0;
}
if (sum_2 <= a) {
cout << a - sum_2 + 1 << endl;
return 0;
}
if (sum_3 <= b) {
cout << b - sum_3 + 1 << endl;
return 0;
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
vector<int> a;
int main() {
int x;
for (int i = 0; i < 3; i++) cin >> x, a.push_back(x);
sort(a.begin(), a.end());
int dif = a[2] - a[1] - a[0] + 1;
printf("%d\n", max(dif, 0));
return 0;
}
| ### Prompt
Generate a CPP solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
vector<int> a;
int main() {
int x;
for (int i = 0; i < 3; i++) cin >> x, a.push_back(x);
sort(a.begin(), a.end());
int dif = a[2] - a[1] - a[0] + 1;
printf("%d\n", max(dif, 0));
return 0;
}
``` |
#include <bits/stdc++.h>
int main() {
int a, b, c;
std::cin >> a >> b >> c;
int big, x, y;
if (a > b && a > c) {
big = a;
x = b;
y = c;
} else if (b > a && b > c) {
big = b;
x = a;
y = c;
} else if (c > a && c > b) {
big = c;
x = b;
y = a;
}
if (x + y > big)
std::cout << 0;
else {
std::cout << big + 1 - x - y;
}
}
| ### Prompt
Construct a cpp code solution to the problem outlined:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int main() {
int a, b, c;
std::cin >> a >> b >> c;
int big, x, y;
if (a > b && a > c) {
big = a;
x = b;
y = c;
} else if (b > a && b > c) {
big = b;
x = a;
y = c;
} else if (c > a && c > b) {
big = c;
x = b;
y = a;
}
if (x + y > big)
std::cout << 0;
else {
std::cout << big + 1 - x - y;
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[3];
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr + 3);
cout << max(0, arr[2] - arr[1] - arr[0] + 1) << endl;
}
| ### Prompt
In CPP, your task is to solve the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[3];
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr + 3);
cout << max(0, arr[2] - arr[1] - arr[0] + 1) << endl;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, mx;
cin >> a >> b >> c;
mx = max(max(a, b), c);
if (a == mx) {
if (a - (b + c) >= 0)
cout << a - (b + c) + 1;
else
cout << 0;
} else if (b == mx) {
if (b - (a + c) >= 0)
cout << b - (a + c) + 1;
else
cout << 0;
} else {
if (c - (a + b) >= 0)
cout << c - (a + b) + 1;
else
cout << 0;
}
}
| ### Prompt
Please create a solution in Cpp to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, mx;
cin >> a >> b >> c;
mx = max(max(a, b), c);
if (a == mx) {
if (a - (b + c) >= 0)
cout << a - (b + c) + 1;
else
cout << 0;
} else if (b == mx) {
if (b - (a + c) >= 0)
cout << b - (a + c) + 1;
else
cout << 0;
} else {
if (c - (a + b) >= 0)
cout << c - (a + b) + 1;
else
cout << 0;
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
for (int i = 0; i < 3; i++) {
cin >> a[i];
}
sort(a, a + 3);
int ans = 0;
ans = a[2] - (a[0] + a[1]) + 1;
ans = max(0, ans);
cout << ans;
}
| ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
for (int i = 0; i < 3; i++) {
cin >> a[i];
}
sort(a, a + 3);
int ans = 0;
ans = a[2] - (a[0] + a[1]) + 1;
ans = max(0, ans);
cout << ans;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long arr[10];
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr + 3);
if (arr[2] < arr[1] + arr[0]) {
cout << 0;
} else {
cout << arr[2] - (arr[1] + arr[0]) + 1;
}
return 0;
}
| ### Prompt
Please provide a Cpp coded solution to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long arr[10];
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr + 3);
if (arr[2] < arr[1] + arr[0]) {
cout << 0;
} else {
cout << arr[2] - (arr[1] + arr[0]) + 1;
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
T load() {
T r;
cin >> r;
return r;
}
template <typename T>
vector<T> loadMany(int n) {
vector<T> rs(n);
generate(rs.begin(), rs.end(), &load<T>);
return rs;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
auto ls = loadMany<int>(3);
sort(ls.begin(), ls.end());
auto answer = max(ls[2] - ls[1] - ls[0] + 1, 0);
cout << answer << '\n';
}
| ### Prompt
Your challenge is to write a CPP solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
T load() {
T r;
cin >> r;
return r;
}
template <typename T>
vector<T> loadMany(int n) {
vector<T> rs(n);
generate(rs.begin(), rs.end(), &load<T>);
return rs;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
auto ls = loadMany<int>(3);
sort(ls.begin(), ls.end());
auto answer = max(ls[2] - ls[1] - ls[0] + 1, 0);
cout << answer << '\n';
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int a, b, c, temp;
cin >> a >> b >> c;
temp = max(a, max(b, c));
if (temp >= ((a + b + c) - temp))
cout << temp + 1 - ((a + b + c) - temp);
else
cout << 0;
}
| ### Prompt
Your challenge is to write a CPP solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int a, b, c, temp;
cin >> a >> b >> c;
temp = max(a, max(b, c));
if (temp >= ((a + b + c) - temp))
cout << temp + 1 - ((a + b + c) - temp);
else
cout << 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int a[3];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[0] + a[1] > a[2]) {
cout << 0 << endl;
return 0;
}
cout << a[2] - a[1] - a[0] + 1;
return 0;
}
| ### Prompt
Construct a cpp code solution to the problem outlined:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int a[3];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[0] + a[1] > a[2]) {
cout << 0 << endl;
return 0;
}
cout << a[2] - a[1] - a[0] + 1;
return 0;
}
``` |
#include <bits/stdc++.h>
int main() {
int a, b, c, x, y, z;
scanf("%d%d%d", &a, &b, &c);
if ((a + b) <= c) {
x = c - a - b + 1;
printf("%d", x);
} else if ((b + c) <= a) {
y = a - b - c + 1;
printf("%d", y);
} else if ((a + c) <= b) {
z = b - a - c + 1;
printf("%d", z);
} else {
printf("0");
}
}
| ### Prompt
Construct a CPP code solution to the problem outlined:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int main() {
int a, b, c, x, y, z;
scanf("%d%d%d", &a, &b, &c);
if ((a + b) <= c) {
x = c - a - b + 1;
printf("%d", x);
} else if ((b + c) <= a) {
y = a - b - c + 1;
printf("%d", y);
} else if ((a + c) <= b) {
z = b - a - c + 1;
printf("%d", z);
} else {
printf("0");
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
int Max(int x, int y, int z) {
int max;
if (x >= y)
max = x;
else
max = y;
if (max >= z)
return max;
else
return z;
}
int Min(int x, int y, int z) {
int min;
if (x <= y)
min = x;
else
min = y;
if (min <= z)
return min;
else
return z;
}
int main() {
int a, b, c, count, sr;
cin >> a >> b >> c;
sr = a + b + c - Max(a, b, c) - Min(a, b, c);
if ((a + b > c) && (a + c > b) && (b + c > a)) {
cout << 0;
return 0;
} else {
count = Max(a, b, c) + 1 - (Min(a, b, c) + sr);
cout << count;
}
return 0;
}
| ### Prompt
Create a solution in cpp for the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int Max(int x, int y, int z) {
int max;
if (x >= y)
max = x;
else
max = y;
if (max >= z)
return max;
else
return z;
}
int Min(int x, int y, int z) {
int min;
if (x <= y)
min = x;
else
min = y;
if (min <= z)
return min;
else
return z;
}
int main() {
int a, b, c, count, sr;
cin >> a >> b >> c;
sr = a + b + c - Max(a, b, c) - Min(a, b, c);
if ((a + b > c) && (a + c > b) && (b + c > a)) {
cout << 0;
return 0;
} else {
count = Max(a, b, c) + 1 - (Min(a, b, c) + sr);
cout << count;
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
while (cin >> a >> b >> c) {
int buf = a;
if (buf < b) {
buf = b;
} else {
a = b;
b = buf;
}
if (buf < c)
buf = c;
else {
b = c;
c = buf;
}
buf = c - (a + b) + 1;
if (buf < 0) buf = 0;
cout << buf << endl;
}
}
| ### Prompt
Develop a solution in CPP to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
while (cin >> a >> b >> c) {
int buf = a;
if (buf < b) {
buf = b;
} else {
a = b;
b = buf;
}
if (buf < c)
buf = c;
else {
b = c;
c = buf;
}
buf = c - (a + b) + 1;
if (buf < 0) buf = 0;
cout << buf << endl;
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, s = 0, d = 0, p;
cin >> a >> b >> c;
if (a > b && a > c) {
s = a;
d = b + c;
} else if (b > a && b > c) {
s = b;
d = a + c;
} else if (c > a && c > b) {
s = c;
d = a + b;
} else {
s = 1;
d = 3;
}
p = (s - d) + 1;
if (p >= 0) {
cout << p;
} else {
cout << 0;
}
}
| ### Prompt
Create a solution in cpp for the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, s = 0, d = 0, p;
cin >> a >> b >> c;
if (a > b && a > c) {
s = a;
d = b + c;
} else if (b > a && b > c) {
s = b;
d = a + c;
} else if (c > a && c > b) {
s = c;
d = a + b;
} else {
s = 1;
d = 3;
}
p = (s - d) + 1;
if (p >= 0) {
cout << p;
} else {
cout << 0;
}
}
``` |
#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
int main() {
std::ios_base::sync_with_stdio(false);
int arr[3];
std::cin >> arr[0] >> arr[1] >> arr[2];
std::sort(arr, arr + 3);
int sol = 0;
while (arr[2] >= arr[0] + arr[1]) {
arr[1]++;
sol++;
}
std::cout << sol;
return 0;
}
| ### Prompt
Construct a cpp code solution to the problem outlined:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
int main() {
std::ios_base::sync_with_stdio(false);
int arr[3];
std::cin >> arr[0] >> arr[1] >> arr[2];
std::sort(arr, arr + 3);
int sol = 0;
while (arr[2] >= arr[0] + arr[1]) {
arr[1]++;
sol++;
}
std::cout << sol;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
bool isPrime(long long int num) {
bool flag = true;
for (long long int i = 2; i <= num / 2; i++) {
if (num % i == 0) {
flag = false;
break;
}
}
return flag;
}
bool isPowerOfTwo(int n) {
if (n == 0) return false;
return (ceil(log2(n)) == floor(log2(n)));
}
long long int OcD(long long int n) {
long long int x = 0;
long long int base = 1;
long long int t = n;
while (t != 0) {
long long int xp = t % 10;
t = t / 10;
x += xp * base;
base = base * 8;
}
return x;
}
long long int DcO(long long int n) {
int remainder;
long octal = 0, i = 1;
while (n != 0) {
remainder = n % 8;
n = n / 8;
octal = octal + (remainder * i);
i = i * 10;
}
return octal;
}
long long int DropLeadingDigit(long long int number) {
return (number %
(long long int)pow((long double)10,
(long double)floor(log((long double)number) /
log((long double)10))));
}
long long int remove_leftmost_digit(long long int n) {
static char temp[11];
sprintf(temp, "%d", n);
return atoi(temp + 1);
}
void Remove(char str[], long long int n) {
set<char> s(str, str + n - 1);
for (set<char>::iterator it = s.begin(); it != s.end(); it++) {
cout << *it;
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int a, b, c, d, e = 0, f = 0, n = 0, i, k = 0, j = 0, l;
long long int x[1000], y[1000];
string s, p, t;
cin >> a >> b >> c;
n = max(a, max(b, c));
i = (a + b + c) - n;
if (n < i)
cout << 0 << endl;
else {
j = n - i;
cout << j + 1 << endl;
}
return 0;
}
| ### Prompt
Construct a cpp code solution to the problem outlined:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
bool isPrime(long long int num) {
bool flag = true;
for (long long int i = 2; i <= num / 2; i++) {
if (num % i == 0) {
flag = false;
break;
}
}
return flag;
}
bool isPowerOfTwo(int n) {
if (n == 0) return false;
return (ceil(log2(n)) == floor(log2(n)));
}
long long int OcD(long long int n) {
long long int x = 0;
long long int base = 1;
long long int t = n;
while (t != 0) {
long long int xp = t % 10;
t = t / 10;
x += xp * base;
base = base * 8;
}
return x;
}
long long int DcO(long long int n) {
int remainder;
long octal = 0, i = 1;
while (n != 0) {
remainder = n % 8;
n = n / 8;
octal = octal + (remainder * i);
i = i * 10;
}
return octal;
}
long long int DropLeadingDigit(long long int number) {
return (number %
(long long int)pow((long double)10,
(long double)floor(log((long double)number) /
log((long double)10))));
}
long long int remove_leftmost_digit(long long int n) {
static char temp[11];
sprintf(temp, "%d", n);
return atoi(temp + 1);
}
void Remove(char str[], long long int n) {
set<char> s(str, str + n - 1);
for (set<char>::iterator it = s.begin(); it != s.end(); it++) {
cout << *it;
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int a, b, c, d, e = 0, f = 0, n = 0, i, k = 0, j = 0, l;
long long int x[1000], y[1000];
string s, p, t;
cin >> a >> b >> c;
n = max(a, max(b, c));
i = (a + b + c) - n;
if (n < i)
cout << 0 << endl;
else {
j = n - i;
cout << j + 1 << endl;
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int a[3];
int main() {
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
cout << max(0, a[2] - a[1] - a[0] + 1) << endl;
}
| ### Prompt
Please provide a CPP coded solution to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int a[3];
int main() {
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
cout << max(0, a[2] - a[1] - a[0] + 1) << endl;
}
``` |
#include <bits/stdc++.h>
int INF = 10000000;
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
int ans = 0;
bool t = false;
if (a + b <= c) {
ans += c - (a + b);
b += ans;
if (!t) {
ans++;
b++;
t = 1;
}
}
if (a + c <= b) {
ans += b - (a + c);
a += b - (a + c);
if (!t) {
ans++;
a++;
t = 1;
}
}
if (b + c <= a) {
ans += a - (b + c);
c += a - (b + c);
if (!t) {
ans++;
c++;
t = 1;
}
}
cout << ans << endl;
return 0;
}
| ### Prompt
Please provide a Cpp coded solution to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int INF = 10000000;
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
int ans = 0;
bool t = false;
if (a + b <= c) {
ans += c - (a + b);
b += ans;
if (!t) {
ans++;
b++;
t = 1;
}
}
if (a + c <= b) {
ans += b - (a + c);
a += b - (a + c);
if (!t) {
ans++;
a++;
t = 1;
}
}
if (b + c <= a) {
ans += a - (b + c);
c += a - (b + c);
if (!t) {
ans++;
c++;
t = 1;
}
}
cout << ans << endl;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) {
if (a > b)
return a;
else
return b;
}
long long min(long long a, long long b) {
if (a < b)
return a;
else
return b;
}
long long pow(long long B, long long P) {
long long S = 1;
for (long long i = 1; i <= P; i++) S = S * B;
return S;
}
long long fx4[] = {1, -1, 0, 0};
long long fy4[] = {0, 0, 1, -1};
bool check(int a, int b, int c) {
if (a + b > c || b + c > a || a + c > b)
return true;
else
return false;
}
int main() {
long long T, N, M, X, Y, Z, W;
int A[20];
for (int i = 1; i <= 3; i++) cin >> A[i];
sort(A + 1, A + 4);
X = A[3] - A[2];
if (A[1] <= X)
cout << X - A[1] + 1 << endl;
else
cout << 0 << endl;
return 0;
}
| ### Prompt
Develop a solution in cpp to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) {
if (a > b)
return a;
else
return b;
}
long long min(long long a, long long b) {
if (a < b)
return a;
else
return b;
}
long long pow(long long B, long long P) {
long long S = 1;
for (long long i = 1; i <= P; i++) S = S * B;
return S;
}
long long fx4[] = {1, -1, 0, 0};
long long fy4[] = {0, 0, 1, -1};
bool check(int a, int b, int c) {
if (a + b > c || b + c > a || a + c > b)
return true;
else
return false;
}
int main() {
long long T, N, M, X, Y, Z, W;
int A[20];
for (int i = 1; i <= 3; i++) cin >> A[i];
sort(A + 1, A + 4);
X = A[3] - A[2];
if (A[1] <= X)
cout << X - A[1] + 1 << endl;
else
cout << 0 << endl;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
void fastio() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int main() {
fastio();
int T = 1;
while (T--) {
long long int a, b, c;
cin >> a >> b >> c;
if (((a + b) > c) && ((c + b) > a) && ((a + c) > b)) {
cout << 0;
return 0;
}
long long int m = max(a, max(b, c));
if (m == a)
cout << m - b - c + 1;
else if (m == b)
cout << m - a - c + 1;
else
cout << m - b - a + 1;
}
return 0;
}
| ### Prompt
Please formulate a Cpp solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
void fastio() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int main() {
fastio();
int T = 1;
while (T--) {
long long int a, b, c;
cin >> a >> b >> c;
if (((a + b) > c) && ((c + b) > a) && ((a + c) > b)) {
cout << 0;
return 0;
}
long long int m = max(a, max(b, c));
if (m == a)
cout << m - b - c + 1;
else if (m == b)
cout << m - a - c + 1;
else
cout << m - b - a + 1;
}
return 0;
}
``` |
#include <bits/stdc++.h>
int main() {
int a, b, c, x, y, z, t;
scanf("%d %d %d", &a, &b, &c);
if (a >= b && a >= c) {
z = a;
y = b;
x = c;
} else if (b >= a && b >= c) {
z = b;
y = a;
x = c;
} else {
z = c;
y = a;
x = b;
}
if (z < x + y)
printf("0");
else {
t = z - x - y + 1;
printf("%d", t);
}
return 0;
}
| ### Prompt
Develop a solution in CPP to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int main() {
int a, b, c, x, y, z, t;
scanf("%d %d %d", &a, &b, &c);
if (a >= b && a >= c) {
z = a;
y = b;
x = c;
} else if (b >= a && b >= c) {
z = b;
y = a;
x = c;
} else {
z = c;
y = a;
x = b;
}
if (z < x + y)
printf("0");
else {
t = z - x - y + 1;
printf("%d", t);
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e6, MOD = 1e9 + 7;
long long a[3];
int32_t main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[0] + a[1] <= a[2])
cout << a[2] - (a[0] + a[1]) + 1;
else
cout << "0";
return 0;
}
| ### Prompt
Please formulate a CPP solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e6, MOD = 1e9 + 7;
long long a[3];
int32_t main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[0] + a[1] <= a[2])
cout << a[2] - (a[0] + a[1]) + 1;
else
cout << "0";
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int a, b, c;
cin >> a >> b >> c;
if (a >= b && a >= c) {
cout << max(a - b - c + 1, 0) << endl;
} else if (b >= a && b >= c) {
cout << max(b - a - c + 1, 0) << endl;
} else
cout << max(c - a - b + 1, 0) << endl;
}
| ### Prompt
In CPP, your task is to solve the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int a, b, c;
cin >> a >> b >> c;
if (a >= b && a >= c) {
cout << max(a - b - c + 1, 0) << endl;
} else if (b >= a && b >= c) {
cout << max(b - a - c + 1, 0) << endl;
} else
cout << max(c - a - b + 1, 0) << endl;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
while (1) {
cin >> a[0] >> a[1] >> a[2];
if (cin.eof()) break;
sort(a, a + 3);
if (a[2] < a[0] + a[1])
cout << 0 << endl;
else
cout << a[2] - (a[0] + a[1]) + 1 << endl;
}
}
| ### Prompt
Please formulate a cpp solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
while (1) {
cin >> a[0] >> a[1] >> a[2];
if (cin.eof()) break;
sort(a, a + 3);
if (a[2] < a[0] + a[1])
cout << 0 << endl;
else
cout << a[2] - (a[0] + a[1]) + 1 << endl;
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
int a[4];
int main() {
cin >> a[1] >> a[2] >> a[3];
sort(a + 1, a + 4);
if (a[1] + a[2] > a[3]) {
puts("0");
return 0;
}
cout << a[3] - a[2] - a[1] + 1;
return 0;
}
| ### Prompt
Generate a cpp solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int a[4];
int main() {
cin >> a[1] >> a[2] >> a[3];
sort(a + 1, a + 4);
if (a[1] + a[2] > a[3]) {
puts("0");
return 0;
}
cout << a[3] - a[2] - a[1] + 1;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
long int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[0] + a[1] > a[2])
cout << 0;
else
cout << (a[2] - (a[0] + a[1])) + 1;
return 0;
}
| ### Prompt
Generate a CPP solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
long int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[0] + a[1] > a[2])
cout << 0;
else
cout << (a[2] - (a[0] + a[1])) + 1;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if (a + b <= c) {
cout << c - (a + b) + 1 << endl;
} else if (a + c <= b) {
cout << b - (a + c) + 1 << endl;
} else if (b + c <= a) {
cout << a - (b + c) + 1 << endl;
} else {
cout << 0 << endl;
}
}
| ### Prompt
Please create a solution in CPP to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if (a + b <= c) {
cout << c - (a + b) + 1 << endl;
} else if (a + c <= b) {
cout << b - (a + c) + 1 << endl;
} else if (b + c <= a) {
cout << a - (b + c) + 1 << endl;
} else {
cout << 0 << endl;
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t[3];
for (int i = 0; i < 3; i++) {
cin >> t[i];
}
sort(t, t + 3);
if (t[0] + t[1] > t[2])
cout << "0\n";
else {
int c = t[2] + 1 - t[1] - t[0];
cout << c << '\n';
}
}
| ### Prompt
Please create a solution in cpp to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int t[3];
for (int i = 0; i < 3; i++) {
cin >> t[i];
}
sort(t, t + 3);
if (t[0] + t[1] > t[2])
cout << "0\n";
else {
int c = t[2] + 1 - t[1] - t[0];
cout << c << '\n';
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
int diff;
void check_and_update(int& a, int& b, int& c, int& time) {
if (a + b <= c) {
diff = abs(a + b - c) + 1;
a += diff;
time += diff;
}
return;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int a, b, c, time = 0;
for (int i = 0; i < 3; i++) {
cin >> a >> b >> c;
}
check_and_update(a, b, c, time);
check_and_update(b, c, a, time);
check_and_update(c, a, b, time);
cout << time << "\n";
return 0;
}
| ### Prompt
Construct a CPP code solution to the problem outlined:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int diff;
void check_and_update(int& a, int& b, int& c, int& time) {
if (a + b <= c) {
diff = abs(a + b - c) + 1;
a += diff;
time += diff;
}
return;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int a, b, c, time = 0;
for (int i = 0; i < 3; i++) {
cin >> a >> b >> c;
}
check_and_update(a, b, c, time);
check_and_update(b, c, a, time);
check_and_update(c, a, b, time);
cout << time << "\n";
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int ax[4];
cin >> ax[0] >> ax[1] >> ax[2];
sort(ax, ax + 3);
if (ax[0] + ax[1] > ax[2])
cout << "0" << endl;
else
cout << ax[2] - ax[1] - ax[0] + 1 << endl;
}
| ### Prompt
Please provide a CPP coded solution to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int ax[4];
cin >> ax[0] >> ax[1] >> ax[2];
sort(ax, ax + 3);
if (ax[0] + ax[1] > ax[2])
cout << "0" << endl;
else
cout << ax[2] - ax[1] - ax[0] + 1 << endl;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[3];
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr + 3);
cout << ((arr[0] + arr[1] > arr[2]) ? 0 : (arr[2] - arr[0] - arr[1] + 1))
<< "\n";
}
| ### Prompt
Develop a solution in cpp to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[3];
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr + 3);
cout << ((arr[0] + arr[1] > arr[2]) ? 0 : (arr[2] - arr[0] - arr[1] + 1))
<< "\n";
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
vector<int> s;
int a, b, c;
cin >> a >> b >> c;
s.push_back(a);
s.push_back(b);
s.push_back(c);
sort(s.rbegin(), s.rend());
if (s[0] < s[1] + s[2]) {
cout << 0 << '\n';
} else {
cout << s[0] - s[1] - s[2] + 1 << '\n';
}
return 0;
}
| ### Prompt
Please provide a Cpp coded solution to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
vector<int> s;
int a, b, c;
cin >> a >> b >> c;
s.push_back(a);
s.push_back(b);
s.push_back(c);
sort(s.rbegin(), s.rend());
if (s[0] < s[1] + s[2]) {
cout << 0 << '\n';
} else {
cout << s[0] - s[1] - s[2] + 1 << '\n';
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
const int MX = 2e5 + 22;
int N, M, k;
const double PI = acos(-1), eps = 1e-7;
double ToDegree(double teta) { return (teta * 180.0) / PI; }
bool Zero(double n) { return fabs(n) <= eps; }
bool Isnan(double val) { return isnan(val); }
struct point {
double x, y, th;
point() {
this->x = 0;
this->y = 0;
}
point(double x, double y) {
this->x = x;
this->y = y;
}
point operator+(const point &p) const { return point(x + p.x, y + p.y); }
point operator-(const point &p) const { return point(x - p.x, y - p.y); }
point operator*(double second) const { return point(x * second, y * second); }
point operator/(double second) const { return point(x / second, y / second); }
bool operator<(const point &p) const { return th < p.th; }
};
double Dot(point p1, point p2) { return p1.x * p2.x + p1.y * p2.y; }
double Cross(point p1, point p2) { return p1.x * p2.y - p1.y * p2.x; }
double VectorNorm(point v) { return sqrt(v.x * v.x + v.y * v.y); }
double VectorAngle(point v) {
double th = atan2(v.y, v.x);
if (th < 0) th += 2.0 * PI;
return th;
}
double AngleBetweenVectors(point a, point b) {
return VectorAngle(b) - VectorAngle(a);
}
long double Dist(point p1, point p2) { return VectorNorm(p2 - p1); }
long double AreaofTriangle(point a, point b, point c) {
long double cur = Cross((b - a), (c - a));
return abs(cur / 2.0);
}
long double AreaOfPolygon(vector<point> &p) {
long double area = 0;
for (int i = 2; i < p.size(); i++) {
area += Cross((p[i - 1] - p[0]), (p[i] - p[0]));
}
return abs(area / 2.0);
}
bool Collinear(point a, point b, point c) {
return Zero(AreaofTriangle(a, b, c));
}
bool LinesParallel(point a, point b, point c, point d) {
return Zero(Cross(b - a, d - c));
}
bool LinesCollinear(point a, point b, point c, point d) {
return Collinear(a, b, c) && Collinear(a, b, c);
}
bool SegmentsIntersect(point a, point b, point c, point d) {
if (LinesCollinear(a, b, c, d)) {
if (Zero(Dist(a, c)) || Zero(Dist(a, d)) || Zero(Dist(b, c)) ||
Zero(Dist(b, d)))
return true;
if (Dot(c - a, c - b) > 0 && Dot(d - a, d - b) > 0 && Dot(c - b, d - b) > 0)
return false;
return true;
}
if (Cross(d - a, b - a) * Cross(c - a, b - a) > 0) return false;
if (Cross(a - c, d - c) * Cross(b - c, d - c) > 0) return false;
return true;
}
point RotateCCW90(point p) { return point(-p.y, p.x); }
point RotateCW90(point p) { return point(p.y, -p.x); }
point RotateCCW(point p, double t) {
return point(p.x * cos(t) - p.y * sin(t), p.x * sin(t) + p.y * cos(t));
}
vector<point> v;
void solve() {
int pt[3];
for (int i = 0; i < 3; i++) cin >> pt[i];
sort(pt, pt + 3);
int ans = 0;
if (pt[0] + pt[1] <= pt[2]) {
ans = pt[2] - pt[0] - pt[1] + 1;
}
cout << ans << '\n';
}
int main() {
int T = 1;
while (T--) solve();
return 0;
}
| ### Prompt
Develop a solution in Cpp to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
const int MX = 2e5 + 22;
int N, M, k;
const double PI = acos(-1), eps = 1e-7;
double ToDegree(double teta) { return (teta * 180.0) / PI; }
bool Zero(double n) { return fabs(n) <= eps; }
bool Isnan(double val) { return isnan(val); }
struct point {
double x, y, th;
point() {
this->x = 0;
this->y = 0;
}
point(double x, double y) {
this->x = x;
this->y = y;
}
point operator+(const point &p) const { return point(x + p.x, y + p.y); }
point operator-(const point &p) const { return point(x - p.x, y - p.y); }
point operator*(double second) const { return point(x * second, y * second); }
point operator/(double second) const { return point(x / second, y / second); }
bool operator<(const point &p) const { return th < p.th; }
};
double Dot(point p1, point p2) { return p1.x * p2.x + p1.y * p2.y; }
double Cross(point p1, point p2) { return p1.x * p2.y - p1.y * p2.x; }
double VectorNorm(point v) { return sqrt(v.x * v.x + v.y * v.y); }
double VectorAngle(point v) {
double th = atan2(v.y, v.x);
if (th < 0) th += 2.0 * PI;
return th;
}
double AngleBetweenVectors(point a, point b) {
return VectorAngle(b) - VectorAngle(a);
}
long double Dist(point p1, point p2) { return VectorNorm(p2 - p1); }
long double AreaofTriangle(point a, point b, point c) {
long double cur = Cross((b - a), (c - a));
return abs(cur / 2.0);
}
long double AreaOfPolygon(vector<point> &p) {
long double area = 0;
for (int i = 2; i < p.size(); i++) {
area += Cross((p[i - 1] - p[0]), (p[i] - p[0]));
}
return abs(area / 2.0);
}
bool Collinear(point a, point b, point c) {
return Zero(AreaofTriangle(a, b, c));
}
bool LinesParallel(point a, point b, point c, point d) {
return Zero(Cross(b - a, d - c));
}
bool LinesCollinear(point a, point b, point c, point d) {
return Collinear(a, b, c) && Collinear(a, b, c);
}
bool SegmentsIntersect(point a, point b, point c, point d) {
if (LinesCollinear(a, b, c, d)) {
if (Zero(Dist(a, c)) || Zero(Dist(a, d)) || Zero(Dist(b, c)) ||
Zero(Dist(b, d)))
return true;
if (Dot(c - a, c - b) > 0 && Dot(d - a, d - b) > 0 && Dot(c - b, d - b) > 0)
return false;
return true;
}
if (Cross(d - a, b - a) * Cross(c - a, b - a) > 0) return false;
if (Cross(a - c, d - c) * Cross(b - c, d - c) > 0) return false;
return true;
}
point RotateCCW90(point p) { return point(-p.y, p.x); }
point RotateCW90(point p) { return point(p.y, -p.x); }
point RotateCCW(point p, double t) {
return point(p.x * cos(t) - p.y * sin(t), p.x * sin(t) + p.y * cos(t));
}
vector<point> v;
void solve() {
int pt[3];
for (int i = 0; i < 3; i++) cin >> pt[i];
sort(pt, pt + 3);
int ans = 0;
if (pt[0] + pt[1] <= pt[2]) {
ans = pt[2] - pt[0] - pt[1] + 1;
}
cout << ans << '\n';
}
int main() {
int T = 1;
while (T--) solve();
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
int f1 = 0, f2 = 0, f3 = 0, dif = 0;
scanf("%d %d %d", &a, &b, &c);
if (a + b > c) {
f1 = 1;
}
if (b + c > a) {
f2 = 1;
}
if (a + c > b) {
f3 = 1;
}
if (f1 == 1 && f2 == 1 && f3 == 1) {
printf("0");
return 0;
}
if ((a + b) <= c) {
dif = fabs(c - (a + b)) + 1;
printf("%d", dif);
return 0;
}
if ((c + b) <= a) {
dif = fabs(a - (c + b)) + 1;
printf("%d", dif);
return 0;
}
if ((a + c) <= b) {
dif = fabs(b - (a + c)) + 1;
printf("%d", dif);
return 0;
}
}
| ### Prompt
Please create a solution in cpp to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
int f1 = 0, f2 = 0, f3 = 0, dif = 0;
scanf("%d %d %d", &a, &b, &c);
if (a + b > c) {
f1 = 1;
}
if (b + c > a) {
f2 = 1;
}
if (a + c > b) {
f3 = 1;
}
if (f1 == 1 && f2 == 1 && f3 == 1) {
printf("0");
return 0;
}
if ((a + b) <= c) {
dif = fabs(c - (a + b)) + 1;
printf("%d", dif);
return 0;
}
if ((c + b) <= a) {
dif = fabs(a - (c + b)) + 1;
printf("%d", dif);
return 0;
}
if ((a + c) <= b) {
dif = fabs(b - (a + c)) + 1;
printf("%d", dif);
return 0;
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
typedef unordered_set<int> USI;
typedef priority_queue<int> PQ;
int main() {
int arr[3];
scanf("%d%d%d", &arr[0], &arr[1], &arr[2]);
sort(arr, arr + 3);
if (arr[0] + arr[1] > arr[2]) {
printf("%d\n", (0));
return 0;
}
printf("%d\n", (arr[2] - arr[0] - arr[1] + 1));
return 0;
}
| ### Prompt
Develop a solution in CPP to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
typedef unordered_set<int> USI;
typedef priority_queue<int> PQ;
int main() {
int arr[3];
scanf("%d%d%d", &arr[0], &arr[1], &arr[2]);
sort(arr, arr + 3);
if (arr[0] + arr[1] > arr[2]) {
printf("%d\n", (0));
return 0;
}
printf("%d\n", (arr[2] - arr[0] - arr[1] + 1));
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if ((a == b) && (a == c)) {
cout << "0";
} else {
if (((a == b) && (a = max(max(a, c), b))) ||
((a == c) && (a == max(max(a, c), b))) ||
((b == c) && (b == max(max(c, b), a)))) {
cout << "0";
} else {
if ((a == max(a, b)) && (a == max(a, c))) {
if (b + c > a) {
cout << "0";
} else {
cout << ((a + 1) - (b + c));
}
}
if ((b == max(a, b)) && (b == max(b, c))) {
if (a + c > b) {
cout << "0";
} else {
cout << ((b + 1) - (a + c));
}
}
if ((c == max(c, b)) && (c == max(a, c))) {
if (b + a > c) {
cout << "0";
} else {
cout << ((c + 1) - (a + b));
}
}
}
}
return 0;
}
| ### Prompt
In CPP, your task is to solve the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if ((a == b) && (a == c)) {
cout << "0";
} else {
if (((a == b) && (a = max(max(a, c), b))) ||
((a == c) && (a == max(max(a, c), b))) ||
((b == c) && (b == max(max(c, b), a)))) {
cout << "0";
} else {
if ((a == max(a, b)) && (a == max(a, c))) {
if (b + c > a) {
cout << "0";
} else {
cout << ((a + 1) - (b + c));
}
}
if ((b == max(a, b)) && (b == max(b, c))) {
if (a + c > b) {
cout << "0";
} else {
cout << ((b + 1) - (a + c));
}
}
if ((c == max(c, b)) && (c == max(a, c))) {
if (b + a > c) {
cout << "0";
} else {
cout << ((c + 1) - (a + b));
}
}
}
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[5];
for (int i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
if (a[0] + a[1] > a[2])
cout << 0;
else
cout << a[2] + 1 - a[0] - a[1];
}
| ### Prompt
Develop a solution in cpp to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[5];
for (int i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
if (a[0] + a[1] > a[2])
cout << 0;
else
cout << a[2] + 1 - a[0] - a[1];
}
``` |
#include <bits/stdc++.h>
using namespace std;
int a[100];
int main() {
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[2] < a[0] + a[1])
cout << 0 << "\n";
else
cout << a[2] - a[0] - a[1] + 1 << "\n";
}
| ### Prompt
Please formulate a Cpp solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int a[100];
int main() {
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[2] < a[0] + a[1])
cout << 0 << "\n";
else
cout << a[2] - a[0] - a[1] + 1 << "\n";
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if (a + b > c && b + c > a && a + c > b) {
cout << "0";
return 0;
}
int A = c - (a + b) + 1, B = a - (b + c) + 1, C = b - (a + c) + 1;
if (A < 1) A = 1;
if (B < 1) B = 1;
if (C < 1) C = 1;
cout << max(A, max(B, C));
}
| ### Prompt
Please formulate a Cpp solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if (a + b > c && b + c > a && a + c > b) {
cout << "0";
return 0;
}
int A = c - (a + b) + 1, B = a - (b + c) + 1, C = b - (a + c) + 1;
if (A < 1) A = 1;
if (B < 1) B = 1;
if (C < 1) C = 1;
cout << max(A, max(B, C));
}
``` |
#include <bits/stdc++.h>
int main() {
int a, b, c, d;
scanf("%d%d%d", &a, &b, &c);
int max;
if (a > b)
max = a;
else
max = b;
if (max > c)
;
else
max = c;
int sum = 0;
if (max == a)
sum = b + c;
else if (max == b)
sum = a + c;
else if (max == c)
sum = b + a;
d = max - sum;
if (d >= 0)
printf("%d", ++d);
else
printf("0");
return 0;
}
| ### Prompt
Please create a solution in cpp to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int main() {
int a, b, c, d;
scanf("%d%d%d", &a, &b, &c);
int max;
if (a > b)
max = a;
else
max = b;
if (max > c)
;
else
max = c;
int sum = 0;
if (max == a)
sum = b + c;
else if (max == b)
sum = a + c;
else if (max == c)
sum = b + a;
d = max - sum;
if (d >= 0)
printf("%d", ++d);
else
printf("0");
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, x, y;
cin >> a >> b >> c;
if (a + b <= c)
cout << c - (a + b) + 1 << endl;
else if (a + c <= b)
cout << b - (a + c) + 1 << endl;
else if (b + c <= a)
cout << a - (b + c) + 1 << endl;
else
cout << 0 << endl;
return 0;
}
| ### Prompt
Please provide a cpp coded solution to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, x, y;
cin >> a >> b >> c;
if (a + b <= c)
cout << c - (a + b) + 1 << endl;
else if (a + c <= b)
cout << b - (a + c) + 1 << endl;
else if (b + c <= a)
cout << a - (b + c) + 1 << endl;
else
cout << 0 << endl;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b) {
if (b == 0) return 1;
if (b == 1) return a;
long long int r = power(a, b / 2) % 1000000007;
if (b % 2 == 0)
return (r * r) % 1000000007;
else
return (((r * r) % 1000000007) * a) % 1000000007;
}
bool comp(const pair<long long int, long long int> &a,
const pair<long long int, long long int> &b) {
return (a.second < b.second);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int a, b, c;
cin >> a >> b >> c;
if (((a + b) > c) && ((b + c) > a) && ((c + a) > b)) {
cout << "0";
return 0;
}
int m = max(a, b);
int ma = max(m, c);
if (ma == c) {
cout << (c - a - b + 1);
} else if (ma == b) {
cout << (b - a - c + 1);
} else if (ma == a) {
cout << (a - b - c + 1);
}
return 0;
}
| ### Prompt
Your challenge is to write a cpp solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b) {
if (b == 0) return 1;
if (b == 1) return a;
long long int r = power(a, b / 2) % 1000000007;
if (b % 2 == 0)
return (r * r) % 1000000007;
else
return (((r * r) % 1000000007) * a) % 1000000007;
}
bool comp(const pair<long long int, long long int> &a,
const pair<long long int, long long int> &b) {
return (a.second < b.second);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int a, b, c;
cin >> a >> b >> c;
if (((a + b) > c) && ((b + c) > a) && ((c + a) > b)) {
cout << "0";
return 0;
}
int m = max(a, b);
int ma = max(m, c);
if (ma == c) {
cout << (c - a - b + 1);
} else if (ma == b) {
cout << (b - a - c + 1);
} else if (ma == a) {
cout << (a - b - c + 1);
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, r;
int res = 0;
cin >> a >> b >> c;
if ((a + b) <= c) {
r = c - (a + b);
for (int i = 0; i <= r; i++) {
res++;
}
}
if ((a + c) <= b) {
r = b - (a + c);
for (int i = 0; i <= r; i++) {
res++;
}
}
if ((c + b) <= a) {
r = a - (c + b);
for (int i = 0; i <= r; i++) {
res++;
}
}
cout << res;
return 0;
}
| ### Prompt
Develop a solution in cpp to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, r;
int res = 0;
cin >> a >> b >> c;
if ((a + b) <= c) {
r = c - (a + b);
for (int i = 0; i <= r; i++) {
res++;
}
}
if ((a + c) <= b) {
r = b - (a + c);
for (int i = 0; i <= r; i++) {
res++;
}
}
if ((c + b) <= a) {
r = a - (c + b);
for (int i = 0; i <= r; i++) {
res++;
}
}
cout << res;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, x = 0, y = 0, z = 0, count;
cin >> a >> b >> c;
while (a + b <= c) {
a++;
x++;
}
while (b + c <= a) {
b++;
y++;
}
while (a + c <= b) {
c++;
z++;
}
count = x + y + z;
cout << count;
return 0;
}
| ### Prompt
Generate a CPP solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, x = 0, y = 0, z = 0, count;
cin >> a >> b >> c;
while (a + b <= c) {
a++;
x++;
}
while (b + c <= a) {
b++;
y++;
}
while (a + c <= b) {
c++;
z++;
}
count = x + y + z;
cout << count;
return 0;
}
``` |
#include <bits/stdc++.h>
int main() {
unsigned short int a, b, c;
std::cin >> a >> b >> c;
if (2 * std::max(std::max(a, b), c) >= a + b + c) {
std::cout << 1 + 2 * std::max(std::max(a, b), c) - a - b - c << '\n';
} else {
std::cout << 0 << '\n';
}
return 0;
}
| ### Prompt
Create a solution in CPP for the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int main() {
unsigned short int a, b, c;
std::cin >> a >> b >> c;
if (2 * std::max(std::max(a, b), c) >= a + b + c) {
std::cout << 1 + 2 * std::max(std::max(a, b), c) - a - b - c << '\n';
} else {
std::cout << 0 << '\n';
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
const long long mx = 2e5 + 5;
long long n, a, b, c;
int main() {
cin >> a >> b >> c;
int maxx;
maxx = max(a, b);
int maxxx = maxx;
if (c > maxx) {
maxx = c;
}
int sum = a + b + c - maxx;
if (sum > maxx) {
cout << 0;
} else {
cout << abs(sum - maxx) + 1;
}
return 0;
}
| ### Prompt
Please provide a Cpp coded solution to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mx = 2e5 + 5;
long long n, a, b, c;
int main() {
cin >> a >> b >> c;
int maxx;
maxx = max(a, b);
int maxxx = maxx;
if (c > maxx) {
maxx = c;
}
int sum = a + b + c - maxx;
if (sum > maxx) {
cout << 0;
} else {
cout << abs(sum - maxx) + 1;
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[5];
for (int i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
int ans;
if (a[0] + a[1] > a[2])
ans = 0;
else {
ans = a[2] - a[0] - a[1] + 1;
}
cout << ans;
return 0;
}
| ### Prompt
Generate a CPP solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[5];
for (int i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
int ans;
if (a[0] + a[1] > a[2])
ans = 0;
else {
ans = a[2] - a[0] - a[1] + 1;
}
cout << ans;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int k[999], a, b, c, d;
cin >> a >> b >> c;
d = max(a, max(b, c));
if (a + b + c - d > d)
cout << "0";
else
cout << d - (a + b + c - d) + 1;
int e = 0;
int w = 0;
}
| ### Prompt
Please provide a cpp coded solution to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int k[999], a, b, c, d;
cin >> a >> b >> c;
d = max(a, max(b, c));
if (a + b + c - d > d)
cout << "0";
else
cout << d - (a + b + c - d) + 1;
int e = 0;
int w = 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
long long int MOD = 1e9 + 7;
long long int gcd(long long int a, long long int b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
void solver() {
long long int a, b, c;
cin >> a >> b >> c;
long long int ans = 0;
if (a + b <= c) {
ans += (c - a - b + 1);
} else if (a + c <= b) {
ans += (b - a - c + 1);
} else if (b + c <= a) {
ans += (a - b - c + 1);
}
cout << ans << "\n";
}
int main() {
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
long long int t;
t = 1;
while (t--) {
solver();
}
return 0;
}
| ### Prompt
In CPP, your task is to solve the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
long long int MOD = 1e9 + 7;
long long int gcd(long long int a, long long int b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
void solver() {
long long int a, b, c;
cin >> a >> b >> c;
long long int ans = 0;
if (a + b <= c) {
ans += (c - a - b + 1);
} else if (a + c <= b) {
ans += (b - a - c + 1);
} else if (b + c <= a) {
ans += (a - b - c + 1);
}
cout << ans << "\n";
}
int main() {
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
long long int t;
t = 1;
while (t--) {
solver();
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[3];
int ans = 0;
for (int i = 0; i < 3; i++) {
cin >> arr[i];
}
sort(arr, arr + 3);
if (arr[2] >= arr[0] + arr[1]) ans = arr[2] - (arr[0] + arr[1]) + 1;
cout << ans;
return 0;
}
| ### Prompt
Develop a solution in Cpp to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[3];
int ans = 0;
for (int i = 0; i < 3; i++) {
cin >> arr[i];
}
sort(arr, arr + 3);
if (arr[2] >= arr[0] + arr[1]) ans = arr[2] - (arr[0] + arr[1]) + 1;
cout << ans;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
std::ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
int a[3];
for (int i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
if (a[0] + a[1] > a[2]) return cout << 0 << endl, 0;
int r = a[2] - a[1];
cout << min(r + 1, r - a[0] + 1) << endl;
}
| ### Prompt
Develop a solution in cpp to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
std::ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
int a[3];
for (int i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
if (a[0] + a[1] > a[2]) return cout << 0 << endl, 0;
int r = a[2] - a[1];
cout << min(r + 1, r - a[0] + 1) << endl;
}
``` |
#include <bits/stdc++.h>
using namespace std;
const int INF = int(2e9) + 99;
int n, x, y, d;
int dist(int x, int y) { return (abs(x - y) + (d - 1)) / d; }
int a[3];
int main() {
cin >> a[0] >> a[1] >> a[2];
sort(&a[0], &a[3]);
float mini = a[0], middle = a[1], maxi = a[2];
if (sqrt(mini * mini + middle * middle) < maxi)
printf("%d", (int)(maxi - mini - middle + 1) < 0
? 0
: (int)(maxi - mini - middle + 1));
else {
printf("0");
}
return 0;
}
| ### Prompt
Develop a solution in Cpp to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = int(2e9) + 99;
int n, x, y, d;
int dist(int x, int y) { return (abs(x - y) + (d - 1)) / d; }
int a[3];
int main() {
cin >> a[0] >> a[1] >> a[2];
sort(&a[0], &a[3]);
float mini = a[0], middle = a[1], maxi = a[2];
if (sqrt(mini * mini + middle * middle) < maxi)
printf("%d", (int)(maxi - mini - middle + 1) < 0
? 0
: (int)(maxi - mini - middle + 1));
else {
printf("0");
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a;
cin >> b;
cin >> c;
int m, n;
m = max(a, max(b, c));
n = a + b + c - m;
if (m - n >= 0) {
cout << m - n + 1 << "\n";
} else {
cout << 0 << "\n";
}
}
| ### Prompt
Your challenge is to write a cpp solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a;
cin >> b;
cin >> c;
int m, n;
m = max(a, max(b, c));
n = a + b + c - m;
if (m - n >= 0) {
cout << m - n + 1 << "\n";
} else {
cout << 0 << "\n";
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if (a + b > c && b + c > a && c + a > b) {
cout << "0" << endl;
} else if (a + b <= c) {
cout << c - (a + b) + 1 << endl;
} else if (b + c <= a) {
cout << a - (c + b) + 1 << endl;
} else if (a + c <= b) {
cout << b - (a + c) + 1 << endl;
}
return 0;
}
| ### Prompt
Please provide a CPP coded solution to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if (a + b > c && b + c > a && c + a > b) {
cout << "0" << endl;
} else if (a + b <= c) {
cout << c - (a + b) + 1 << endl;
} else if (b + c <= a) {
cout << a - (c + b) + 1 << endl;
} else if (a + c <= b) {
cout << b - (a + c) + 1 << endl;
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
void online() {}
int code() {
online();
long long int a, b, c;
cin >> a >> b >> c;
long long int aa = max(a, b);
aa = max(aa, c);
long long int sum = a + b + c - aa;
long long int ans = ((sum - aa <= 0) ? aa - sum + 1 : 0);
cout << ans << endl;
return 0;
}
signed main() {
ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
long long int tests;
code();
}
| ### Prompt
Please create a solution in Cpp to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
void online() {}
int code() {
online();
long long int a, b, c;
cin >> a >> b >> c;
long long int aa = max(a, b);
aa = max(aa, c);
long long int sum = a + b + c - aa;
long long int ans = ((sum - aa <= 0) ? aa - sum + 1 : 0);
cout << ans << endl;
return 0;
}
signed main() {
ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
long long int tests;
code();
}
``` |
#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793238462643383;
long long Ceil(long long a, long long b) {
if (a % b == 0)
return a / b;
else
return a / b + 1;
}
long long p = 998244353;
long long power(long long i) {
if (i == 0) {
return 1;
}
long long q = (power(i / 2)) % p;
if (i % 2 == 0) return (q * q) % p;
return (q * q * 2) % p;
}
int main() {
cin.sync_with_stdio(0);
cin.tie(0);
cin.exceptions(cin.failbit);
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
int ans = a[0] + a[1] - a[2] - 1;
if (ans >= 0) {
cout << "0";
return 0;
}
cout << -ans;
return 0;
}
| ### Prompt
Please formulate a cpp solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793238462643383;
long long Ceil(long long a, long long b) {
if (a % b == 0)
return a / b;
else
return a / b + 1;
}
long long p = 998244353;
long long power(long long i) {
if (i == 0) {
return 1;
}
long long q = (power(i / 2)) % p;
if (i % 2 == 0) return (q * q) % p;
return (q * q * 2) % p;
}
int main() {
cin.sync_with_stdio(0);
cin.tie(0);
cin.exceptions(cin.failbit);
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
int ans = a[0] + a[1] - a[2] - 1;
if (ans >= 0) {
cout << "0";
return 0;
}
cout << -ans;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long a, b, c;
cin >> a >> b >> c;
long long ans = 0;
if (a + b <= c) {
if (a + b == c) {
ans += 1;
a += 1;
} else {
ans += c - (a + b) + 1;
a += 1;
}
}
if (c + b <= a) {
if (c + b == a) {
ans += 1;
b += 1;
} else {
ans += a - (c + b) + 1;
b += 1;
}
}
if (a + c <= b) {
if (a + c == b) {
ans += 1;
a += 1;
} else {
ans += b - (a + c) + 1;
a += 1;
}
}
cout << ans;
}
int main() {
solve();
return 0;
}
| ### Prompt
In CPP, your task is to solve the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long a, b, c;
cin >> a >> b >> c;
long long ans = 0;
if (a + b <= c) {
if (a + b == c) {
ans += 1;
a += 1;
} else {
ans += c - (a + b) + 1;
a += 1;
}
}
if (c + b <= a) {
if (c + b == a) {
ans += 1;
b += 1;
} else {
ans += a - (c + b) + 1;
b += 1;
}
}
if (a + c <= b) {
if (a + c == b) {
ans += 1;
a += 1;
} else {
ans += b - (a + c) + 1;
a += 1;
}
}
cout << ans;
}
int main() {
solve();
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c, maxi1, maxi2, maxi3;
cin >> a >> b >> c;
maxi1 = max(a, max(b, c));
if (maxi1 == a) {
maxi2 = max(b, c);
if (maxi2 == b)
maxi3 = c;
else
maxi3 = b;
} else if (maxi1 == b) {
maxi2 = max(a, c);
if (maxi2 == a)
maxi3 = c;
else
maxi3 = a;
} else if (maxi1 == c) {
maxi2 = max(b, a);
if (maxi2 == b)
maxi3 = a;
else
maxi3 = b;
}
long long sum = maxi2 + maxi3;
if (sum <= maxi1)
cout << maxi1 - sum + 1 << endl;
else
cout << 0 << endl;
return 0;
}
| ### Prompt
Your task is to create a CPP solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c, maxi1, maxi2, maxi3;
cin >> a >> b >> c;
maxi1 = max(a, max(b, c));
if (maxi1 == a) {
maxi2 = max(b, c);
if (maxi2 == b)
maxi3 = c;
else
maxi3 = b;
} else if (maxi1 == b) {
maxi2 = max(a, c);
if (maxi2 == a)
maxi3 = c;
else
maxi3 = a;
} else if (maxi1 == c) {
maxi2 = max(b, a);
if (maxi2 == b)
maxi3 = a;
else
maxi3 = b;
}
long long sum = maxi2 + maxi3;
if (sum <= maxi1)
cout << maxi1 - sum + 1 << endl;
else
cout << 0 << endl;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[3];
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr + 3);
if (arr[0] + arr[1] > arr[2])
cout << "0\n";
else {
int x = arr[2] + 1 - arr[0] - arr[1];
cout << x << endl;
}
return 0;
}
| ### Prompt
In Cpp, your task is to solve the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[3];
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr + 3);
if (arr[0] + arr[1] > arr[2])
cout << "0\n";
else {
int x = arr[2] + 1 - arr[0] - arr[1];
cout << x << endl;
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, s = 0;
cin >> a >> b >> c;
while (a + b <= c) {
if (a < b)
a++;
else
b++;
s++;
}
while (a + c <= b) {
if (a < c)
a++;
else
c++;
s++;
}
while (c + b <= a) {
if (c < b)
c++;
else
b++;
s++;
}
cout << s;
}
| ### Prompt
Construct a CPP code solution to the problem outlined:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, s = 0;
cin >> a >> b >> c;
while (a + b <= c) {
if (a < b)
a++;
else
b++;
s++;
}
while (a + c <= b) {
if (a < c)
a++;
else
c++;
s++;
}
while (c + b <= a) {
if (c < b)
c++;
else
b++;
s++;
}
cout << s;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
bool tick = false;
int i, a, b, c, t, time = 0, mini = 100000;
cin >> a >> b >> c;
int tri[3] = {a, b, c};
if (a + b > c && a + c > b && b + c > a) {
tick = true;
}
while (tick == false) {
mini = 10000;
for (i = 0; i < 3; i++) {
if (tri[i] < mini) {
mini = tri[i];
t = i;
}
}
if (t == 0) {
a++;
} else if (t == 1) {
b++;
} else {
c++;
}
time++;
if (a + b > c && a + c > b && b + c > a) {
tick = true;
}
}
cout << time;
}
| ### Prompt
Your challenge is to write a cpp solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
bool tick = false;
int i, a, b, c, t, time = 0, mini = 100000;
cin >> a >> b >> c;
int tri[3] = {a, b, c};
if (a + b > c && a + c > b && b + c > a) {
tick = true;
}
while (tick == false) {
mini = 10000;
for (i = 0; i < 3; i++) {
if (tri[i] < mini) {
mini = tri[i];
t = i;
}
}
if (t == 0) {
a++;
} else if (t == 1) {
b++;
} else {
c++;
}
time++;
if (a + b > c && a + c > b && b + c > a) {
tick = true;
}
}
cout << time;
}
``` |
#include <bits/stdc++.h>
using namespace std;
const long long M = 1e5 + 5;
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
vector<long long> si(3);
cin >> si[0] >> si[1] >> si[2];
sort(si.begin(), si.end());
if (si[0] + si[1] > si[2])
cout << "0\n";
else {
cout << si[2] + 1 - si[0] - si[1] << '\n';
}
return 0;
}
| ### Prompt
Please formulate a CPP solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
const long long M = 1e5 + 5;
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
vector<long long> si(3);
cin >> si[0] >> si[1] >> si[2];
sort(si.begin(), si.end());
if (si[0] + si[1] > si[2])
cout << "0\n";
else {
cout << si[2] + 1 - si[0] - si[1] << '\n';
}
return 0;
}
``` |
#include <bits/stdc++.h>
int main() {
int a, b, c, k, m;
scanf("%d %d %d", &a, &b, &c);
if (a > b && a > c) {
k = a;
m = b + c;
} else if (b > a && b > c) {
k = b;
m = a + c;
} else {
k = c;
m = a + b;
}
if (k < m) {
printf("%d", 0);
} else {
printf("%d", k - m + 1);
}
return 0;
}
| ### Prompt
Develop a solution in cpp to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int main() {
int a, b, c, k, m;
scanf("%d %d %d", &a, &b, &c);
if (a > b && a > c) {
k = a;
m = b + c;
} else if (b > a && b > c) {
k = b;
m = a + c;
} else {
k = c;
m = a + b;
}
if (k < m) {
printf("%d", 0);
} else {
printf("%d", k - m + 1);
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int minn = 1000000, maxx = 0;
vector<int> v(3);
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
for (int i = 0; i < 3; i++) cin >> v[i];
sort(v.begin(), v.end());
if (v[0] + v[1] > v[2]) {
cout << 0;
return 0;
}
if (2 * v[1] > v[2])
cout << min(v[1] - v[0], v[2] + 1 - v[1] - v[0]);
else {
int t = v[2] + 1;
int a = t / 2;
int b = t - a;
cout << a - v[0] + b - v[1];
}
return 0;
}
| ### Prompt
Please provide a cpp coded solution to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int minn = 1000000, maxx = 0;
vector<int> v(3);
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
for (int i = 0; i < 3; i++) cin >> v[i];
sort(v.begin(), v.end());
if (v[0] + v[1] > v[2]) {
cout << 0;
return 0;
}
if (2 * v[1] > v[2])
cout << min(v[1] - v[0], v[2] + 1 - v[1] - v[0]);
else {
int t = v[2] + 1;
int a = t / 2;
int b = t - a;
cout << a - v[0] + b - v[1];
}
return 0;
}
``` |
#include <bits/stdc++.h>
int a[100001];
int main() {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
int max = 0;
if (a + b > c && b + c > a && a + c > b) {
printf("0");
} else {
if (a + b <= c) {
max = c - (a + b) + 1;
printf("%d", max);
} else {
if (c + b <= a) {
max = a - (c + b) + 1;
printf("%d", max);
} else {
if (a + c <= b) {
max = b - (a + c) + 1;
printf("%d", max);
}
}
}
}
return 0;
}
| ### Prompt
In Cpp, your task is to solve the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int a[100001];
int main() {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
int max = 0;
if (a + b > c && b + c > a && a + c > b) {
printf("0");
} else {
if (a + b <= c) {
max = c - (a + b) + 1;
printf("%d", max);
} else {
if (c + b <= a) {
max = a - (c + b) + 1;
printf("%d", max);
} else {
if (a + c <= b) {
max = b - (a + c) + 1;
printf("%d", max);
}
}
}
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[5], ans;
for (int i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
int x = a[0] + a[1] - a[2];
if (x > 0)
ans = 0;
else {
ans = -x + 1;
}
cout << ans << endl;
return 0;
}
| ### Prompt
Construct a Cpp code solution to the problem outlined:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[5], ans;
for (int i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
int x = a[0] + a[1] - a[2];
if (x > 0)
ans = 0;
else {
ans = -x + 1;
}
cout << ans << endl;
return 0;
}
``` |
#include <bits/stdc++.h>
int main() {
int a, b, c, t;
scanf(
"%d"
"%d"
"%d",
&a, &b, &c);
if (a >= b + c)
t = a - b - c + 1;
else if (b >= a + c)
t = b - a - c + 1;
else if (c >= b + a)
t = c - a - b + 1;
else
t = 0;
printf("%d", t);
return 0;
}
| ### Prompt
Your task is to create a CPP solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int main() {
int a, b, c, t;
scanf(
"%d"
"%d"
"%d",
&a, &b, &c);
if (a >= b + c)
t = a - b - c + 1;
else if (b >= a + c)
t = b - a - c + 1;
else if (c >= b + a)
t = c - a - b + 1;
else
t = 0;
printf("%d", t);
return 0;
}
``` |
#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
using std::string;
int main() {
ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(10);
long long t, n, k, m, a, b, c;
cin >> a >> b >> c;
if (a >= b + c) {
cout << a - b - c + 1;
} else if (b >= a + c) {
cout << b - a - c + 1;
} else if (c >= a + b) {
cout << c - a - b + 1;
} else {
cout << 0;
}
return 0;
}
| ### Prompt
Generate a Cpp solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
using std::string;
int main() {
ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(10);
long long t, n, k, m, a, b, c;
cin >> a >> b >> c;
if (a >= b + c) {
cout << a - b - c + 1;
} else if (b >= a + c) {
cout << b - a - c + 1;
} else if (c >= a + b) {
cout << c - a - b + 1;
} else {
cout << 0;
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
int mx = max(max(a, b), c);
int mn = min(min(a, b), c);
int md = (a + b + c) - (mx + mn);
int res = 0;
if (mx < (mn + md))
cout << res;
else {
res = mx - (mn + md);
cout << res + 1;
}
return 0;
}
| ### Prompt
Generate a cpp solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
int mx = max(max(a, b), c);
int mn = min(min(a, b), c);
int md = (a + b + c) - (mx + mn);
int res = 0;
if (mx < (mn + md))
cout << res;
else {
res = mx - (mn + md);
cout << res + 1;
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int a, b, c;
int answer = 1e9 + 7;
void read() { cin >> a >> b >> c; }
int main() {
read();
if (b > a && b > c) swap(b, c);
if (c > a && c > b) swap(a, c);
for (int i = a; i <= 400; i++)
for (int j = b; j <= i; j++)
for (int k = c; k <= i; k++) {
if (i < j + k) answer = min(answer, i - a + j - b + k - c);
}
cout << answer;
}
| ### Prompt
Your task is to create a cpp solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int a, b, c;
int answer = 1e9 + 7;
void read() { cin >> a >> b >> c; }
int main() {
read();
if (b > a && b > c) swap(b, c);
if (c > a && c > b) swap(a, c);
for (int i = a; i <= 400; i++)
for (int j = b; j <= i; j++)
for (int k = c; k <= i; k++) {
if (i < j + k) answer = min(answer, i - a + j - b + k - c);
}
cout << answer;
}
``` |
#include <bits/stdc++.h>
using namespace std;
const int inf = (int)2e9 + 10;
int arr[3];
int main(int argc, const char* argv[]) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cerr.tie(nullptr);
int tmp;
for (int i = 0; i < 3; i++) {
cin >> arr[i];
}
sort(arr, arr + 3);
tmp = arr[0];
while (arr[2] - arr[1] >= arr[0]) {
++arr[0];
}
cout << arr[0] - tmp << '\n';
}
| ### Prompt
Please create a solution in Cpp to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = (int)2e9 + 10;
int arr[3];
int main(int argc, const char* argv[]) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cerr.tie(nullptr);
int tmp;
for (int i = 0; i < 3; i++) {
cin >> arr[i];
}
sort(arr, arr + 3);
tmp = arr[0];
while (arr[2] - arr[1] >= arr[0]) {
++arr[0];
}
cout << arr[0] - tmp << '\n';
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> V(3);
for (int i = 0; i < 3; i++) cin >> V[i];
sort(V.begin(), V.end());
if (V[0] > V[2] - V[1] && V[0] < V[2] + V[1])
cout << 0;
else
cout << V[2] - V[1] - V[0] + 1 << endl;
return 0;
}
| ### Prompt
Develop a solution in Cpp to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> V(3);
for (int i = 0; i < 3; i++) cin >> V[i];
sort(V.begin(), V.end());
if (V[0] > V[2] - V[1] && V[0] < V[2] + V[1])
cout << 0;
else
cout << V[2] - V[1] - V[0] + 1 << endl;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3], steps = 0;
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
while (a[0] + a[1] <= a[2]) {
steps++;
a[0]++;
}
cout << steps;
}
| ### Prompt
Develop a solution in Cpp to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3], steps = 0;
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
while (a[0] + a[1] <= a[2]) {
steps++;
a[0]++;
}
cout << steps;
}
``` |
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
const int mxN = 1000005;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
int kx[8] = {2, 1, -1, -2, -2, -1, 1, 2};
int ky[8] = {1, 2, 2, 1, -1, -2, -2, -1};
long long int qpow(unsigned long long x, int y, int p) {
long long int res = 1;
x = x % p;
while (y > 0) {
if (y % 2 == 1) res = (res * x) % p;
y = y / 2;
x = (x * x) % p;
}
return res;
}
long long int modInverse(unsigned long long x, int p) {
return qpow(x, p - 2, p);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int arr[3];
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr + 3);
if (arr[2] <= arr[1] + arr[0] - 1) {
cout << 0 << endl;
} else {
cout << arr[2] - (arr[1] + arr[0] - 1) << endl;
}
}
| ### Prompt
Your task is to create a CPP solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
const int mxN = 1000005;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
int kx[8] = {2, 1, -1, -2, -2, -1, 1, 2};
int ky[8] = {1, 2, 2, 1, -1, -2, -2, -1};
long long int qpow(unsigned long long x, int y, int p) {
long long int res = 1;
x = x % p;
while (y > 0) {
if (y % 2 == 1) res = (res * x) % p;
y = y / 2;
x = (x * x) % p;
}
return res;
}
long long int modInverse(unsigned long long x, int p) {
return qpow(x, p - 2, p);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int arr[3];
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr + 3);
if (arr[2] <= arr[1] + arr[0] - 1) {
cout << 0 << endl;
} else {
cout << arr[2] - (arr[1] + arr[0] - 1) << endl;
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long a, b, c;
cin >> a >> b >> c;
long long mx;
mx = max(a, b);
mx = max(mx, c);
if ((mx - (a + b + c - mx) + 1) > 0)
cout << (mx - (a + b + c - mx) + 1);
else
cout << "0";
}
| ### Prompt
Develop a solution in cpp to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long a, b, c;
cin >> a >> b >> c;
long long mx;
mx = max(a, b);
mx = max(mx, c);
if ((mx - (a + b + c - mx) + 1) > 0)
cout << (mx - (a + b + c - mx) + 1);
else
cout << "0";
}
``` |
#include <bits/stdc++.h>
using namespace std;
void online() {}
int code() {
online();
long long int a, b, c;
cin >> a >> b >> c;
long long int aa = max(a, b);
aa = max(aa, c);
long long int sum = a + b + c - aa;
cout << ((sum - aa <= 0) ? aa - sum + 1 : 0) << endl;
return 0;
}
signed main() {
ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
long long int tests;
code();
}
| ### Prompt
In Cpp, your task is to solve the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
void online() {}
int code() {
online();
long long int a, b, c;
cin >> a >> b >> c;
long long int aa = max(a, b);
aa = max(aa, c);
long long int sum = a + b + c - aa;
cout << ((sum - aa <= 0) ? aa - sum + 1 : 0) << endl;
return 0;
}
signed main() {
ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
long long int tests;
code();
}
``` |
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long a, b, c;
cin >> a >> b >> c;
long long mx = max(a, max(b, c));
long long ans = mx + 1 - (a + b + c - mx);
cout << max(0LL, ans) << '\n';
}
int main() {
ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
long long TESTS;
TESTS = 1;
while (TESTS--) {
solve();
}
return 0;
}
| ### Prompt
Your task is to create a CPP solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long a, b, c;
cin >> a >> b >> c;
long long mx = max(a, max(b, c));
long long ans = mx + 1 - (a + b + c - mx);
cout << max(0LL, ans) << '\n';
}
int main() {
ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
long long TESTS;
TESTS = 1;
while (TESTS--) {
solve();
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int v[4];
cin >> v[0] >> v[1] >> v[2];
sort(v, v + 3);
cout << max(v[2] - v[1] - v[0] + 1, 0);
return 0;
}
| ### Prompt
Please provide a cpp coded solution to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int v[4];
cin >> v[0] >> v[1] >> v[2];
sort(v, v + 3);
cout << max(v[2] - v[1] - v[0] + 1, 0);
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using umap = unordered_map<T, U>;
template <typename T>
using uset = unordered_set<T>;
template <typename T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using max_heap = priority_queue<T>;
int main() {
ios::sync_with_stdio(0);
V<int> a(3);
for (int i = 0; i < (3); ++i) cin >> a[i];
sort(a.begin(), a.end());
cout << max(0, a[2] - a[1] - a[0] + 1) << '\n';
}
| ### Prompt
Create a solution in CPP for the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using umap = unordered_map<T, U>;
template <typename T>
using uset = unordered_set<T>;
template <typename T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using max_heap = priority_queue<T>;
int main() {
ios::sync_with_stdio(0);
V<int> a(3);
for (int i = 0; i < (3); ++i) cin >> a[i];
sort(a.begin(), a.end());
cout << max(0, a[2] - a[1] - a[0] + 1) << '\n';
}
``` |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
using namespace std;
template <class T>
inline void sort(T &a) {
sort((a).begin(), (a).end());
}
template <class T>
inline void rsort(T &a) {
sort((a).rbegin(), (a).rend());
}
template <class T>
inline void reverse(T &a) {
reverse((a).begin(), (a).end());
}
template <class T, class U>
inline void checkmin(T &x, U y) {
if (x > y) x = y;
}
template <class T, class U>
inline void checkmax(T &x, U y) {
if (x < y) x = y;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cout << fixed << setprecision(20);
srand(time(NULL));
long long a, b, c;
cin >> a >> b >> c;
long long ans = -1000000000000000007ll;
checkmax(ans, c - (a + b - 1));
checkmax(ans, a - (c + b - 1));
checkmax(ans, b - (a + c - 1));
checkmax(ans, 0);
cout << ans;
return 0;
}
| ### Prompt
Generate a Cpp solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
using namespace std;
template <class T>
inline void sort(T &a) {
sort((a).begin(), (a).end());
}
template <class T>
inline void rsort(T &a) {
sort((a).rbegin(), (a).rend());
}
template <class T>
inline void reverse(T &a) {
reverse((a).begin(), (a).end());
}
template <class T, class U>
inline void checkmin(T &x, U y) {
if (x > y) x = y;
}
template <class T, class U>
inline void checkmax(T &x, U y) {
if (x < y) x = y;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cout << fixed << setprecision(20);
srand(time(NULL));
long long a, b, c;
cin >> a >> b >> c;
long long ans = -1000000000000000007ll;
checkmax(ans, c - (a + b - 1));
checkmax(ans, a - (c + b - 1));
checkmax(ans, b - (a + c - 1));
checkmax(ans, 0);
cout << ans;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long ar(long long n) { return (1 + n) * n / 2; }
const long double PI = 3.1415926;
const long long INF_LL = 1e18 + 7;
const long long Mod = 1e9 + 7;
int32_t main() {
cout << fixed << setprecision(15);
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
long long a, b, c;
cin >> a >> b >> c;
cout << max(0ll, max(a, max(b, c)) * 2 - a - b - c + 1) << '\n';
}
| ### Prompt
Generate a CPP solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long ar(long long n) { return (1 + n) * n / 2; }
const long double PI = 3.1415926;
const long long INF_LL = 1e18 + 7;
const long long Mod = 1e9 + 7;
int32_t main() {
cout << fixed << setprecision(15);
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
long long a, b, c;
cin >> a >> b >> c;
cout << max(0ll, max(a, max(b, c)) * 2 - a - b - c + 1) << '\n';
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
while (cin >> a >> b >> c) {
int max = a;
if (max < b) max = b;
if (max < c) max = c;
if (max == a) {
if (b + c > max)
cout << 0 << endl;
else
cout << max - b - c + 1 << endl;
} else if (max == b) {
if (a + c > max)
cout << 0 << endl;
else
cout << max - a - c + 1 << endl;
} else {
if (a + b > max)
cout << 0 << endl;
else
cout << max - a - b + 1 << endl;
}
}
return 0;
}
| ### Prompt
Generate a Cpp solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
while (cin >> a >> b >> c) {
int max = a;
if (max < b) max = b;
if (max < c) max = c;
if (max == a) {
if (b + c > max)
cout << 0 << endl;
else
cout << max - b - c + 1 << endl;
} else if (max == b) {
if (a + c > max)
cout << 0 << endl;
else
cout << max - a - c + 1 << endl;
} else {
if (a + b > max)
cout << 0 << endl;
else
cout << max - a - b + 1 << endl;
}
}
return 0;
}
``` |
#include <bits/stdc++.h>
int main() {
int a, b, c, x, y, z;
scanf("%d%d%d", &a, &b, &c);
if (a >= b && a >= c) {
x = a;
y = b;
z = c;
}
if (c >= b && a <= c) {
x = c;
y = b;
z = a;
}
if (a <= b && b >= c) {
x = b;
y = a;
z = c;
}
if (x < (y + z))
printf("0");
else
printf("%d", x - y - z + 1);
}
| ### Prompt
Your challenge is to write a cpp solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int main() {
int a, b, c, x, y, z;
scanf("%d%d%d", &a, &b, &c);
if (a >= b && a >= c) {
x = a;
y = b;
z = c;
}
if (c >= b && a <= c) {
x = c;
y = b;
z = a;
}
if (a <= b && b >= c) {
x = b;
y = a;
z = c;
}
if (x < (y + z))
printf("0");
else
printf("%d", x - y - z + 1);
}
``` |
#include <bits/stdc++.h>
using namespace std;
int a, b, c;
int main() {
while (scanf("%d %d %d", &a, &b, &c) != EOF) {
if (a + b > c && a + c > b && b + c > a) {
printf("0\n");
continue;
}
int minx = 200;
if (a + b <= c) {
minx = min(c - a - b + 1, minx);
}
if (a + c <= b) {
minx = min(b - a - c + 1, minx);
}
if (b + c <= a) {
minx = min(a - b - c + 1, minx);
}
printf("%d\n", minx);
}
return 0;
}
| ### Prompt
Develop a solution in CPP to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int a, b, c;
int main() {
while (scanf("%d %d %d", &a, &b, &c) != EOF) {
if (a + b > c && a + c > b && b + c > a) {
printf("0\n");
continue;
}
int minx = 200;
if (a + b <= c) {
minx = min(c - a - b + 1, minx);
}
if (a + c <= b) {
minx = min(b - a - c + 1, minx);
}
if (b + c <= a) {
minx = min(a - b - c + 1, minx);
}
printf("%d\n", minx);
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[0] + a[1] > a[2])
cout << 0 << endl;
else
cout << ((a[2] + 1) - (a[0] + a[1])) << endl;
}
| ### Prompt
Your task is to create a Cpp solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[0] + a[1] > a[2])
cout << 0 << endl;
else
cout << ((a[2] + 1) - (a[0] + a[1])) << endl;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long arr[3];
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr + 3);
if (arr[1] + arr[0] > arr[2]) {
cout << 0 << endl;
} else {
cout << arr[2] + 1 - arr[1] - arr[0] << endl;
}
return 0;
}
| ### Prompt
In CPP, your task is to solve the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
long long arr[3];
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr + 3);
if (arr[1] + arr[0] > arr[2]) {
cout << 0 << endl;
} else {
cout << arr[2] + 1 - arr[1] - arr[0] << endl;
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, x, ans;
cin >> a >> b >> c;
x = max(a, max(b, c));
if (x == a) {
if (a - b - c < 0)
ans = 0;
else
ans = (a + 1 - b - c);
} else if (x == b) {
if (b - a - c < 0)
ans = 0;
else
ans = (b + 1 - a - c);
} else if (x == c) {
if (c - a - b < 0)
ans = 0;
else
ans = (c + 1 - a - b);
}
cout << ans;
}
| ### Prompt
Please provide a Cpp coded solution to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, x, ans;
cin >> a >> b >> c;
x = max(a, max(b, c));
if (x == a) {
if (a - b - c < 0)
ans = 0;
else
ans = (a + 1 - b - c);
} else if (x == b) {
if (b - a - c < 0)
ans = 0;
else
ans = (b + 1 - a - c);
} else if (x == c) {
if (c - a - b < 0)
ans = 0;
else
ans = (c + 1 - a - b);
}
cout << ans;
}
``` |
#include <bits/stdc++.h>
using namespace std;
bool isPrime(int x) {
if (x <= 4 || x % 2 == 0 || x % 3 == 0) return x == 2 || x == 3;
for (int i = 5; i * i <= x; i += 6)
if (x % i == 0 || x % (i + 2) == 0) return 0;
return 1;
}
int NumDigits(int x) {
return (
x < 10
? 1
: (x < 100
? 2
: (x < 1000
? 3
: (x < 10000
? 4
: (x < 100000
? 5
: (x < 1000000
? 6
: (x < 10000000
? 7
: (x < 100000000
? 8
: (x < 1000000000
? 9
: 10)))))))));
}
inline void boostIO() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
inline long long int Pow10(int x) {
if (x == 0) return 1;
if (x == 1) return 10;
if (x == 2) return 100;
if (x == 3) return 1000;
if (x == 4) return 10000;
if (x == 5) return 100000;
if (x == 6) return 1000000;
if (x == 7) return 10000000;
if (x == 8) return 100000000;
if (x == 9) return 1000000000;
if (x == 10) return 10000000000;
}
long long int gcd(long long int a, long long int b) {
return b ? gcd(b, a % b) : a;
}
long long int lcm(long long int a, long long int b) {
return a * b / gcd(a, b);
}
int main() {
boostIO();
int a, b, c;
cin >> a >> b >> c;
if (a > c) {
swap(a, c);
}
if (b > c) {
swap(b, c);
}
int Answ = 0;
while (a + b <= c) {
if (a < b) {
++a;
} else {
++b;
}
Answ++;
}
cout << Answ << '\n';
return 0;
}
| ### Prompt
Create a solution in Cpp for the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
bool isPrime(int x) {
if (x <= 4 || x % 2 == 0 || x % 3 == 0) return x == 2 || x == 3;
for (int i = 5; i * i <= x; i += 6)
if (x % i == 0 || x % (i + 2) == 0) return 0;
return 1;
}
int NumDigits(int x) {
return (
x < 10
? 1
: (x < 100
? 2
: (x < 1000
? 3
: (x < 10000
? 4
: (x < 100000
? 5
: (x < 1000000
? 6
: (x < 10000000
? 7
: (x < 100000000
? 8
: (x < 1000000000
? 9
: 10)))))))));
}
inline void boostIO() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
inline long long int Pow10(int x) {
if (x == 0) return 1;
if (x == 1) return 10;
if (x == 2) return 100;
if (x == 3) return 1000;
if (x == 4) return 10000;
if (x == 5) return 100000;
if (x == 6) return 1000000;
if (x == 7) return 10000000;
if (x == 8) return 100000000;
if (x == 9) return 1000000000;
if (x == 10) return 10000000000;
}
long long int gcd(long long int a, long long int b) {
return b ? gcd(b, a % b) : a;
}
long long int lcm(long long int a, long long int b) {
return a * b / gcd(a, b);
}
int main() {
boostIO();
int a, b, c;
cin >> a >> b >> c;
if (a > c) {
swap(a, c);
}
if (b > c) {
swap(b, c);
}
int Answ = 0;
while (a + b <= c) {
if (a < b) {
++a;
} else {
++b;
}
Answ++;
}
cout << Answ << '\n';
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base ::sync_with_stdio(false), cin.tie(NULL), cout.tie(0);
long long int a[3];
for (int i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
if (a[2] < a[1] + a[0])
cout << 0;
else
cout << (a[2] - a[1] - a[0] + 1);
return 0;
}
| ### Prompt
Your task is to create a cpp solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base ::sync_with_stdio(false), cin.tie(NULL), cout.tie(0);
long long int a[3];
for (int i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
if (a[2] < a[1] + a[0])
cout << 0;
else
cout << (a[2] - a[1] - a[0] + 1);
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 123;
const int M = 1e7 + 123;
const int inf = 1e9 + 1;
const int mod = 1e9 + 7;
int a[3];
int main() {
cin.tie(0);
cout.tie(0);
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
cout << max(0, a[2] - a[0] - a[1] + 1);
return 0;
}
| ### Prompt
Generate a CPP solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 123;
const int M = 1e7 + 123;
const int inf = 1e9 + 1;
const int mod = 1e9 + 7;
int a[3];
int main() {
cin.tie(0);
cout.tie(0);
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
cout << max(0, a[2] - a[0] - a[1] + 1);
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, s = 0;
cin >> a >> b >> c;
if (a + b <= c)
s = (c - (a + b)) + 1;
else if (b + c <= a)
s = (a - (c + b)) + 1;
else if (a + c <= b)
s = (b - (c + a)) + 1;
cout << s;
}
| ### Prompt
Develop a solution in CPP to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, s = 0;
cin >> a >> b >> c;
if (a + b <= c)
s = (c - (a + b)) + 1;
else if (b + c <= a)
s = (a - (c + b)) + 1;
else if (a + c <= b)
s = (b - (c + a)) + 1;
cout << s;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, largest, s1, s2;
cin >> a >> b >> c;
if (a >= b && a >= c) {
largest = a;
s1 = b;
s2 = c;
}
if (b >= a && b >= c) {
largest = b;
s1 = a;
s2 = c;
}
if (c >= b && c >= a) {
largest = c;
s1 = b;
s2 = a;
}
int res = 0;
if (s1 + s2 > largest) {
cout << res;
} else {
res = 1 + largest - s1 - s2;
cout << res;
}
}
| ### Prompt
Your task is to create a cpp solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, largest, s1, s2;
cin >> a >> b >> c;
if (a >= b && a >= c) {
largest = a;
s1 = b;
s2 = c;
}
if (b >= a && b >= c) {
largest = b;
s1 = a;
s2 = c;
}
if (c >= b && c >= a) {
largest = c;
s1 = b;
s2 = a;
}
int res = 0;
if (s1 + s2 > largest) {
cout << res;
} else {
res = 1 + largest - s1 - s2;
cout << res;
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
vector<int> v;
v.push_back(a);
v.push_back(b);
v.push_back(c);
sort(v.begin(), v.end());
cout << max(0, v[2] - v[1] - v[0] + 1);
return 0;
}
| ### Prompt
Please formulate a CPP solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
vector<int> v;
v.push_back(a);
v.push_back(b);
v.push_back(c);
sort(v.begin(), v.end());
cout << max(0, v[2] - v[1] - v[0] + 1);
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int a, b, c;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> a >> b >> c;
cout << max(2 * max(max(a, b), c) - a - b - c + 1, 0);
return 0;
}
| ### Prompt
Please create a solution in Cpp to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int a, b, c;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> a >> b >> c;
cout << max(2 * max(max(a, b), c) - a - b - c + 1, 0);
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
int a, b;
int r;
scanf("%d%d%d", &n, &b, &a);
if (n > b && n > a) {
if (b + a > n) {
printf("0");
return 0;
} else
r = n - b - a;
} else if (b > n && b > a) {
if (a + n > b) {
printf("0");
return 0;
} else
r = b - a - n;
} else {
if (b + n > a) {
printf("0");
return 0;
} else
r = a - b - n;
}
if (r >= 0) printf("%d", r + 1);
return 0;
}
| ### Prompt
Create a solution in CPP for the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
int a, b;
int r;
scanf("%d%d%d", &n, &b, &a);
if (n > b && n > a) {
if (b + a > n) {
printf("0");
return 0;
} else
r = n - b - a;
} else if (b > n && b > a) {
if (a + n > b) {
printf("0");
return 0;
} else
r = b - a - n;
} else {
if (b + n > a) {
printf("0");
return 0;
} else
r = a - b - n;
}
if (r >= 0) printf("%d", r + 1);
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
static long long gcd(long long x, long long y) {
return y == 0 ? x : gcd(y, x % y);
}
int solve() {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
int ans = 1000000009;
for (int i = 0; i < 256; ++i)
for (int j = 0; j < 256; ++j)
for (int k = 0; k < 256; ++k) {
if ((a + i) < (b + j) + (c + k) && (b + j) < (a + i) + (c + k) &&
(c + k) < (a + i) + (b + j)) {
ans = std::min(ans, i + j + k);
}
}
printf("%d\n", ans);
return 0;
}
int main() {
::std::ios::sync_with_stdio(false);
::std::cin.tie(0);
::std::cout.tie(0);
int t = 1;
while (t--) solve();
}
| ### Prompt
Generate a Cpp solution to the following problem:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
static long long gcd(long long x, long long y) {
return y == 0 ? x : gcd(y, x % y);
}
int solve() {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
int ans = 1000000009;
for (int i = 0; i < 256; ++i)
for (int j = 0; j < 256; ++j)
for (int k = 0; k < 256; ++k) {
if ((a + i) < (b + j) + (c + k) && (b + j) < (a + i) + (c + k) &&
(c + k) < (a + i) + (b + j)) {
ans = std::min(ans, i + j + k);
}
}
printf("%d\n", ans);
return 0;
}
int main() {
::std::ios::sync_with_stdio(false);
::std::cin.tie(0);
::std::cout.tie(0);
int t = 1;
while (t--) solve();
}
``` |
#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y);
long long mpower(long long x, long long y, long long p);
long long modInv(long long a, long long m);
long long gcdExtended(long long a, long long b, long long *x, long long *y);
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long t, i, j, k, l, p, q, r, x, y, z, a, b, c, d, f, n, m,
M = 1000000007;
string s;
vector<long long> v, w;
vector<long long>::iterator itrv, it;
unordered_map<long long, long long> N;
set<long long> S;
set<long long>::iterator itr;
long long A[3];
for (i = 0; i < 3; i++) {
cin >> A[i];
}
sort(A, A + 3);
p = A[0] + A[1];
x = 0;
while (p <= A[2]) {
x++;
p++;
}
cout << x << endl;
return 0;
}
long long modInv(long long a, long long m) {
long long x, y;
long long g = gcdExtended(a, m, &x, &y);
long long res = (x % m + m) % m;
return res;
}
long long gcdExtended(long long a, long long b, long long *x, long long *y) {
if (a == 0) {
*x = 0, *y = 1;
return b;
}
long long x1, y1;
long long gcd = gcdExtended(b % a, a, &x1, &y1);
*x = y1 - (b / a) * x1;
*y = x1;
return gcd;
}
long long mpower(long long x, long long y, long long p) {
long long res = 1;
x = x % p;
while (y > 0) {
if (y & 1) {
res = (res * x) % p;
}
y = y >> 1;
x = (x * x) % p;
}
return res;
}
long long power(long long x, long long y) {
long long res = 1;
while (y > 0) {
if (y & 1) res = res * x;
y = y >> 1;
x = x * x;
}
return res;
}
| ### Prompt
Construct a CPP code solution to the problem outlined:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.
Input
The only line contains tree integers a, b and c (1 β€ a, b, c β€ 100) β the lengths of sticks Masha possesses.
Output
Print a single integer β the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.
In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y);
long long mpower(long long x, long long y, long long p);
long long modInv(long long a, long long m);
long long gcdExtended(long long a, long long b, long long *x, long long *y);
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long t, i, j, k, l, p, q, r, x, y, z, a, b, c, d, f, n, m,
M = 1000000007;
string s;
vector<long long> v, w;
vector<long long>::iterator itrv, it;
unordered_map<long long, long long> N;
set<long long> S;
set<long long>::iterator itr;
long long A[3];
for (i = 0; i < 3; i++) {
cin >> A[i];
}
sort(A, A + 3);
p = A[0] + A[1];
x = 0;
while (p <= A[2]) {
x++;
p++;
}
cout << x << endl;
return 0;
}
long long modInv(long long a, long long m) {
long long x, y;
long long g = gcdExtended(a, m, &x, &y);
long long res = (x % m + m) % m;
return res;
}
long long gcdExtended(long long a, long long b, long long *x, long long *y) {
if (a == 0) {
*x = 0, *y = 1;
return b;
}
long long x1, y1;
long long gcd = gcdExtended(b % a, a, &x1, &y1);
*x = y1 - (b / a) * x1;
*y = x1;
return gcd;
}
long long mpower(long long x, long long y, long long p) {
long long res = 1;
x = x % p;
while (y > 0) {
if (y & 1) {
res = (res * x) % p;
}
y = y >> 1;
x = (x * x) % p;
}
return res;
}
long long power(long long x, long long y) {
long long res = 1;
while (y > 0) {
if (y & 1) res = res * x;
y = y >> 1;
x = x * x;
}
return res;
}
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.