text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
int test, a, b, c;
int main() {
cin >> test;
while (test--) {
cin >> a >> b >> c;
int res = 0;
for (int i = 0; i <= 100; i++) {
if (a >= i && b >= i * 2) res = max(res, i + min((b - i * 2), c / 2));
}
cout << res * 3 << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int a, b, c;
cin >> a >> b >> c;
int cnt = 0;
while (b > 0 && c >= 2) {
cnt += 3;
b--;
c -= 2;
}
while (a > 0 && b >= 2) {
cnt += 3;
a--;
b -= 2;
}
cout << cnt << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 20;
const long long MOD2 = 998244353;
const long long MOD = 1e9 + 7;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
;
int ttt;
cin >> ttt;
while (ttt--) {
int a, b, c;
cin >> a >> b >> c;
int ans = min(b, c / 2) * 3;
b -= min(b, c / 2);
ans += min(a, b / 2) * 3;
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10, modd = 1e9 + 7, SIZE = 100000, inf = 0x3f3f3f3f,
INF = 0x7fffffff, hmod1 = 0x48E2DCE7, hmod2 = 0x60000005;
const int dir[4][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};
const double eps = 1e-8;
template <class T>
inline void sc(T &x) {
char c;
x = 0;
while ((c = getchar()) < '0')
;
while (c >= '0' && c <= '9') x = x * 10 + (c - 48), c = getchar();
}
inline long long min(long long a, long long b) { return a < b ? a : b; }
inline long long max(long long a, long long b) { return a > b ? a : b; }
inline long long gcd(long long a, long long b) {
return b == 0 ? a : gcd(b, a % b);
}
inline long long exgcd(long long a, long long b, long long &x, long long &y) {
long long d;
(b == 0 ? (x = 1, y = 0, d = a)
: (d = exgcd(b, a % b, y, x), y -= a / b * x));
return d;
}
inline long long qpow(long long a, long long n) {
long long sum = 1;
while (n) {
if (n & 1) sum = sum * a % modd;
a = a * a % modd;
n >>= 1;
}
return sum;
}
inline long long qmul(long long a, long long n) {
long long sum = 0;
while (n) {
if (n & 1) sum = (sum + a) % modd;
a = (a + a) % modd;
n >>= 1;
}
return sum;
}
inline long long inv(long long a) { return qpow(a, modd - 2); }
inline long long madd(long long a, long long b) {
return (a % modd + b % modd) % modd;
}
inline long long mmul(long long a, long long b) { return a % modd * b % modd; }
inline void uadd(long long &a, long long b) { a = madd(a, b); }
inline void umul(long long &a, long long b) { a = mmul(a, b); }
inline void umin(long long &a, long long b) { a = min(a, b); }
inline void umax(long long &a, long long b) { a = max(a, b); }
long long a, b, c, ans;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int kase;
cin >> kase;
while (kase--) {
ans = 0;
cin >> a >> b >> c;
ans += min(b, c / 2);
b -= min(b, c / 2), c -= 2 * min(b, c / 2);
ans += min(a, b / 2);
cout << 3 * ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
while (n--) {
int a, b, c;
int sum = 0;
cin >> a >> b >> c;
if (c > 1) {
int d = c / 2;
int y = b - d;
if (y <= 0) {
sum += 3 * b;
b = 0;
} else if (y > 0) {
sum += 3 * d;
b -= d;
}
}
if (b > 1) {
int e = b / 2;
int t = a - e;
if (t <= 0) {
sum += 3 * a;
a = 0;
} else if (t > 0) {
sum += 3 * e;
a -= e;
}
}
cout << sum << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int t, a, b, c;
cin >> t;
while (t--) {
long long int count = 0;
cin >> a >> b >> c;
while (b != 0 && c >= 2) {
count += 3;
b -= 1;
c -= 2;
}
while (a != 0 && b >= 2) {
count += 3;
b -= 2;
a -= 1;
}
cout << count << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int one;
cin >> one;
int two;
cin >> two;
int three;
cin >> three;
int num_a = min(one, two / 2) + min(two % 2, three / 2);
int num_b = min(two, three / 2) + min((two - min(two, three / 2)) / 2, one);
cout << max(num_a, num_b) * 3 << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int tc;
int a, b, c;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> tc;
while (tc--) {
cin >> a >> b >> c;
int ans = 0;
while (c > 1 && b > 0) {
ans += 3;
c -= 2;
b--;
}
while (a > 0 && b > 1) {
ans += 3;
b -= 2;
a--;
}
cout << ans << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int t, x, y, z, ans;
int main() {
scanf("%d", &t);
while (t--) {
ans = 0;
scanf("%d%d%d", &x, &y, &z);
if (y >= 1 && z >= 2) {
ans += min(z / 2, y) * 3;
y = max(y - z / 2, 0);
}
if (x >= 1 && y >= 2) {
ans += min(y / 2, x) * 3;
}
printf("%d\n", ans);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
scanf("%d", &t);
while (t--) {
int a, b, c;
int cnt = 0;
cin >> a >> b >> c;
while (b && c > 1) {
cnt += 3;
b--;
c -= 2;
}
while (a && b > 1) {
cnt += 3;
a--;
b -= 2;
}
printf("%d", cnt);
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, a, b, c;
scanf("%d", &t);
while (t--) {
scanf("%d%d%d", &a, &b, &c);
int d = 0;
while (b >= 1 && c >= 2) {
b -= 1;
c -= 2;
d += 3;
}
while (a >= 1 && b >= 2) {
a -= 1;
b -= 2;
d += 3;
}
printf("%d\n", d);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long Z = 1e9 + 7;
int main() {
long long t;
cin >> t;
while (t--) {
long long a, b, c;
cin >> a >> b >> c;
long long ans = 0;
{
ans += (min((c / 2), b) * 3);
b = b - c / 2;
}
if (b > 0) {
ans += min(a, b / 2) * 3;
}
cout << ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, a, b, c, x;
cin >> t;
while (t--) {
x = 0;
cin >> a >> b >> c;
if (b >= (c / 2)) {
x = 3 * (c / 2);
b = b - (c / 2);
if (a >= (b / 2)) {
x = x + 3 * (b / 2);
} else
x = x + (3 * a);
} else {
x = b * 3;
b = 0;
}
cout << x << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int i, n, m, t, k = 0, a, b, c;
cin >> t;
while (t--) {
cin >> a >> b >> c;
while (c > 1 && b > 0) {
c -= 2;
b -= 1;
k += 3;
}
while (a > 0 && b > 1) {
a -= 1;
b -= 2;
k += 3;
}
cout << k << endl;
k = 0;
}
return 0;
}
|
#include <bits/stdc++.h>
int main() {
int t, a, b, c, sum = 0;
scanf("%d", &t);
while (t--) {
sum = 0;
scanf("%d %d %d", &a, &b, &c);
while (c >= 2 && b >= 1) {
sum += 3;
c = c - 2;
b--;
}
while (b >= 2 && a >= 1) {
sum += 3;
b -= 2;
a--;
}
printf("%d\n", sum);
}
return 0;
}
|
#include <bits/stdc++.h>
int main() {
int ans = 0;
int t, a, b, c;
std::cin >> t;
for (int i = 0; i < t; i++) {
std::cin >> a >> b >> c;
int interm1 = c / 2;
if (b >= interm1)
b -= interm1;
else {
interm1 = b;
b = 0;
}
int interm2 = b / 2;
if (a < interm2) interm2 = a;
std::cout << 3 * (interm1 + interm2) << std::endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, ts;
scanf("%d", &ts);
while (ts--) {
scanf("%d %d %d", &a, &b, &c);
int tot = 0, m;
m = min(b, c >> 1);
tot += (m * 3);
b -= m;
tot += (min(a, (b >> 1)) * 3);
printf("%d\n", tot);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int a, b, c;
int main() {
int T;
cin >> T;
while (T--) {
cin >> a >> b >> c;
int ans = 0;
int x = min(c / 2, b);
ans += x * 3;
b -= x;
x = min(b / 2, a);
ans += x * 3;
cout << ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int t, a, b, c;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
scanf("%d", &t);
while (t--) {
scanf("%d", &a);
scanf("%d", &b);
scanf("%d", &c);
int ans = min(b, c / 2);
b -= ans;
ans *= 3;
ans += 3 * min(a, b / 2);
printf("%d\n", ans);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
int a, b, c;
cin >> a >> b >> c;
int c1 = min(c / 2, b);
int ans = c1 * 3;
c -= c1 * 2;
b -= c1;
int c2 = min(a, b / 2);
ans += c2 * 3;
cout << ans << endl;
}
int main() {
int t;
cin >> t;
while (t--) solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void fastio() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
void input() {}
int dp[101][101][101];
int f(int a, int b, int c) {
if (dp[a][b][c] != -1) return dp[a][b][c];
int& ans = dp[a][b][c];
ans = 0;
if (a >= 1 && b >= 2) ans = max(ans, 3 + f(a - 1, b - 2, c));
if (b >= 1 && c >= 2) ans = max(ans, 3 + f(a, b - 1, c - 2));
return ans;
}
int main() {
fastio();
input();
int a, b, c, i, j, t;
cin >> t;
while (t--) {
memset(dp, -1, sizeof dp);
cin >> a >> b >> c;
cout << f(a, b, c) << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void faster() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int MAXN = 3e5 + 10;
const long long INF = 1e18;
const long long MOD = 1e8;
long long T, a, b, c, ans;
int main() {
faster();
cin >> T;
while (T--) {
cin >> a >> b >> c;
ans += min(b, (c / 2)) * 3;
b -= min(b, (c / 2));
ans += min(a, b / 2) * 3;
cout << ans << '\n';
ans = 0;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--) {
int a, b, c;
cin >> a >> b >> c;
int stones = 0;
int auxc = c;
int auxb = b;
if (c >= 2 && b) {
stones += 3 * min(auxb, auxc / 2);
c -= 2 * min(auxc / 2, auxb);
b -= min(auxc / 2, auxb);
}
if (a && b >= 2) {
stones += 3 * min(a, b / 2);
a -= min(b / 2, a);
}
cout << stones << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
int t;
cin >> t;
while (t--) {
int a, b, c;
cin >> a >> b >> c;
int t = 0, r1 = min(b, c / 2);
b -= r1;
c -= 2 * r1;
t = 3 * r1;
t += 3 * (min(a, b / 2));
cout << t << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
#pragma comment(linker, "/STACK: 20000000005")
bool tc = 1;
void run_case() {
long long a, b, c;
cin >> a >> b >> c;
long long count{0};
for (long long i = 0;; i++) {
if (b != 0 && c != 0 && c >= 2) {
b = b - 1;
c = c - 2;
count = count + 3;
} else if (a != 0 && b != 0 && b >= 2) {
a = a - 1;
b = b - 2;
count = count + 3;
} else {
break;
}
}
cout << count << endl;
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if (tc) {
long long t;
cin >> t;
while (t--) run_case();
} else
run_case();
return 0;
}
|
#include <bits/stdc++.h>
const int INF = 0x3f3f3f3f;
const long long INF_LL = 9223372036854775807LL;
const double E = exp(1.0);
const double PI = acos(-1.0);
long long gcd(long long a, long long b) {
while (b ^= a ^= b ^= a %= b)
;
return a;
}
long long lcd(long long a, long long b) { return a * b / gcd(a, b); }
int read() {
char ch = getchar();
int x = 0, f = 1;
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while ('0' <= ch && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
inline void write(long long x) {
if (x < 0) {
putchar('-');
x = -x;
}
if (x > 9) write(x / 10);
putchar(x % 10 + '0');
}
void init_cin() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
}
using namespace std;
int main() {
init_cin();
int n;
cin >> n;
while (n--) {
int a, b, c;
cin >> a >> b >> c;
int ans = 0;
int one = min(c / 2, b);
b -= one;
ans += 3 * one;
one = min(a, b / 2);
ans += 3 * one;
cout << ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long heap(long long h1, long long h2, long long h3) {
if (h2 == 0) return 0;
long long stones = 0;
if (h3 >= 2 * h2 && h3 != 0) {
stones += 3 * h2;
h3 = h3 - 2 * h2;
h2 = 0;
return stones;
} else if (h3 < 2 * h2 && h3 != 0) {
stones += 3 * (h3 / 2);
h2 -= (h3 / 2);
}
if (h2 >= 2 * h1 && h1 != 0 && h2 != 0) {
stones += 3 * h1;
h2 = h2 - 2 * h1;
h1 = 0;
} else if (h2 < 2 * h1 && h1 != 0 && h2 != 0) {
stones += 3 * (h2 / 2);
h2 %= 2;
}
return stones;
}
int32_t main() {
long long t;
cin >> t;
while (t--) {
long long h1, h2, h3;
cin >> h1 >> h2 >> h3;
cout << heap(h1, h2, h3) << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long int a[100005];
int main() {
int t, a, b, c, x, y;
cin >> t;
while (t--) {
cin >> a >> b >> c;
y = min(c / 2, b);
b -= y;
x = min(b / 2, a);
cout << 3 * x + 3 * y << '\n';
}
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
for (; t; --t) {
int a, b, c;
cin >> a >> b >> c;
int a2, b2, c2;
a2 = a, b2 = b, c2 = c;
int mx1 = min(a, b / 2) * 3;
b -= 2 * min(a, b / 2);
mx1 += min(b, c / 2) * 3;
a = a2, b = b2, c = c2;
int mx2 = min(b, c / 2) * 3;
b -= min(b, c / 2);
mx2 += min(a, b / 2) * 3;
cout << max(mx1, mx2) << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
inline int read() {
int sum = 0, ff = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') ff = -1;
ch = getchar();
}
while (isdigit(ch)) sum = sum * 10 + (ch ^ 48), ch = getchar();
return sum * ff;
}
int Q, a, b, c;
int main() {
Q = read();
for (; Q--;) {
a = read();
b = read();
c = read();
int ans = 0;
ans += min(b, c / 2) * 3;
b = max(0, b - c / 2);
ans += min(a, b / 2) * 3;
printf("%d\n", ans);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int a, b, c, sum = 0;
cin >> a >> b >> c;
while (c - 2 >= 0 && b - 1 >= 0) {
c -= 2;
b -= 1;
sum += 3;
}
while (a - 1 >= 0 && b - 2 >= 0) {
b -= 2;
a -= 1;
sum += 3;
}
cout << sum << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int a, b, c;
int sum1 = 0, sum2 = 0;
cin >> a >> b >> c;
int b1 = b;
int x1 = min(a, b / 2);
sum1 = 3 * x1;
b -= x1 * 2;
if (b != 0) {
int x2 = min(b, c / 2);
sum1 += 3 * x2;
}
x1 = min(b1, c / 2);
sum2 = 3 * x1;
b1 -= x1;
if (b1 > 0) {
int x2 = min(a, b1 / 2);
sum2 += 3 * x2;
}
cout << max(sum2, sum1) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int a, b, c;
cin >> a >> b >> c;
int ans = 0;
while (c >= 2 && b >= 1) {
c -= 2;
b -= 1;
ans += 3;
}
while (a >= 1 && b >= 2) {
a -= 1;
b -= 2;
ans += 3;
}
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 1000 + 10;
int a[MAXN];
long long int mod = 1000 * 1000 * 1000 + 7;
int main() {
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int q;
cin >> q;
for (int i = 0; i < q; i++) {
int a, b, c;
cin >> a >> b >> c;
int ans = min(c / 2, b);
b -= ans;
ans += min(b / 2, a);
cout << ans * 3 << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int i, j, n, m, t, p, x, k, ans, a, b, c;
cin >> t;
while (t--) {
cin >> a >> b >> c;
ans = 0;
x = c / 2;
if (b >= x) {
ans += (3 * x);
b = b - x;
} else {
ans += 3 * b;
b = 0;
}
x = b / 2;
if (a >= x) {
ans += (3 * x);
} else {
ans += 3 * a;
}
cout << ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
int t;
cin >> t;
while (t--) {
int a, b, c, ans = 0, ans1 = 0, a1, b1, c1;
cin >> a >> b >> c;
a1 = a;
b1 = b;
c1 = c;
while (a >= 1 && b >= 2) {
ans += 3;
a--;
b -= 2;
}
while (b >= 1 && c >= 2) {
ans += 3;
b--;
c -= 2;
}
while (b1 >= 1 && c1 >= 2) {
ans1 += 3;
b1--;
c1 -= 2;
}
while (a1 >= 1 && b1 >= 2) {
ans1 += 3;
a1--;
b1 -= 2;
}
cout << max(ans, ans1) << endl;
}
}
|
#include <bits/stdc++.h>
const int maxn = 1000;
using namespace std;
int main() {
int t;
scanf("%d", &t);
while (t--) {
int a, b, c;
int ans = 0;
scanf("%d%d%d", &a, &b, &c);
ans = ans + min(b, c / 2) * 3;
b -= ans / 3;
ans = ans + min(a, b / 2) * 3;
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
while (n--) {
int a;
int b;
int c;
cin >> a >> b >> c;
int min1;
int max1 = 0;
min1 = min(a, b / 2);
int min2 = b - 2 * min1;
max1 = min1 + min1 * 2 + min(min2, c / 2) + 2 * min(min2, c / 2);
int min3 = min(b, c / 2);
int min4 = min(a, (b - min3) / 2);
int max2 = min3 + min3 * 2 + 3 * min(a, (b - min3) / 2);
cout << max(max1, max2) << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int a, b, c;
int k = 0;
cin >> a >> b >> c;
while (b > 0 && c > 1) {
k += 3;
b--;
c--;
c--;
}
while (a > 0 && b > 1) {
k += 3;
a--;
b--;
b--;
}
cout << k << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int a, b, c;
int count = 0;
cin >> a >> b >> c;
while (b >= 1 and c >= 2) {
count += 3;
b = b - 1;
c = c - 2;
}
while (a >= 1 and b >= 2) {
count += 3;
a = a - 1;
b = b - 2;
}
cout << count << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t, a, b, c;
cin >> t;
while (t--) {
int ans = 0;
cin >> a >> b >> c;
if (b >= 1 && c >= 2) {
int mn = min(c / 2, b);
ans += 3 * mn;
if (mn == b) {
b -= mn;
c -= 2 * mn;
} else {
b -= mn;
c -= mn;
}
}
if (a >= 1 && b >= 2) {
int mn = min(b / 2, a);
ans += 3 * mn;
if (mn == a) {
a -= mn;
b -= 2 * mn;
} else {
a -= b / 2;
b -= b / 2;
}
}
cout << ans << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t;
while (t--) {
int a, b, c;
cin >> a >> b >> c;
int res = 0;
for (int i = 0; i <= min(a, b / 2); i++) {
res = max(3 * i + 3 * min(b - 2 * i, c / 2), res);
}
cout << res << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int a, b, c, res = 0;
cin >> a >> b >> c;
while (b > 0 && c >= 2) {
res += 3;
b--;
c -= 2;
}
while (a > 0 && b >= 2) {
res += 3;
a--;
b -= 2;
}
cout << res << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while (T--) {
int a, b, c;
cin >> a >> b >> c;
int ans = 0;
while (b >= 1 && c >= 2) {
ans += 3;
b--;
c -= 2;
}
while (a >= 1 && b >= 2) {
ans += 3;
a--;
b -= 2;
}
cout << ans << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int t;
cin >> t;
while (t--) {
long long int a, b, c;
cin >> a >> b >> c;
long long int x = min(b, c / 2);
long long int ans = 3 * x;
long long int y = min((b - x) / 2, a);
ans += 3 * y;
cout << ans << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, a, b, c, q = 0;
cin >> t;
for (int i = 0; i < t; i++) {
q = 0;
cin >> a >> b >> c;
while (b >= 1 && c > 1) {
b--;
c = c - 2;
q++;
}
if (b >= 2) {
while (a >= 1 && b > 1) {
a--;
b = b - 2;
q++;
}
}
cout << 3 * q << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int MX = 2e5 + 7;
int main() {
int t;
cin >> t;
while (t--) {
long long a, b, c;
cin >> a >> b >> c;
long long ans = 3 * min(b, c / 2);
b -= ans / 3;
ans += 3 * min(a, b / 2);
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
while (n--) {
int a, b, c, ans = 0;
cin >> a >> b >> c;
ans += min(c / 2, b) * 3;
b -= min(c / 2, b);
ans += min(a, b / 2) * 3;
cout << ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int a, b, c;
cin >> a >> b >> c;
int op2 = min(b, c / 2);
b -= op2;
c -= op2 * 2;
int op1 = min(a, b / 2);
int res = (op1 + op2) * 3;
cout << res << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int a, b, c;
cin >> a >> b >> c;
int sum = 0;
int cnt = 0;
int s = 0;
while (c >= 2 & b >= 1) {
c -= 2;
b--;
cnt++;
}
while (b >= 2 and a >= 1) {
b -= 2;
a--;
s++;
}
cout << cnt * 2 + cnt * 1 + s * 2 + s * 1 << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
int t, n, i, j, k, answer = 0;
cin >> t;
while (t--) {
cin >> i >> j >> k;
answer = 0;
while (k > 1 && j > 0) {
k -= 2;
j--;
answer += 3;
}
while (j > 1 && i > 0) {
j -= 2;
i--;
answer += 3;
}
cout << answer << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
void c_p_c() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
bool isPrime(long long n) {
if (n <= 1) return false;
if (n <= 3) return true;
if (n % 2 == 0 || n % 3 == 0) return false;
for (long long i = 5; i * i <= n; i += 6) {
if (n % i == 0 || n % (i + 2) == 0) return false;
}
return true;
}
vector<bool> Sieve(long long n) {
bool prime[n + 1];
memset(prime, true, sizeof(prime));
for (long long i = 2; i * i <= n; i++) {
if (prime[i]) {
for (long long j = i * i; j <= n; j += i) {
prime[j] = false;
}
}
}
vector<bool> primes(n + 1);
primes[0] = false;
primes[1] = false;
for (long long i = 2; i <= n; i++) {
if (prime[i]) primes[i] = true;
}
return primes;
}
set<long long> primeFactors(long long n) {
set<long long> factors;
while (n % 2 == 0) {
n /= 2;
factors.insert(2);
}
for (long long i = 3; i <= sqrt(n); i += 2) {
while (n % i == 0) {
factors.insert(i);
n /= i;
}
}
if (n > 2) factors.insert(n);
return factors;
}
long long func(long long n) {
long long digit = 0;
while (n > 0) {
digit = max(digit, n % 10);
n /= 10;
}
return digit;
}
int32_t main() {
c_p_c();
long long t;
cin >> t;
while (t--) {
long long a, b, c;
cin >> a >> b >> c;
long long ans = 0;
while (c >= 2 && b >= 1) {
ans += 3;
b--;
c -= 2;
}
while (b >= 2 && a >= 1) {
ans += 3;
a--;
b -= 2;
}
cout << ans << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int K;
cin >> K;
while (K--) {
int a, b, c;
cin >> a >> b >> c;
int ans = 0;
if (c / 2 <= b) {
ans += (c / 2) * 3;
b -= ans / 3;
} else {
ans += b * 3;
b = 0;
}
if (b / 2 <= a) {
ans += (b / 2) * 3;
} else
ans += a * 3;
cout << ans << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, b, c, a1, b1, c1, p1 = 0, p2 = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a >> b >> c;
a1 = a;
b1 = b;
c1 = c;
p1 = 0;
while (a1 > 0 && b1 > 1) {
a1--;
b1 = b1 - 2;
p1++;
}
while (c1 > 1 && b1 > 0) {
c1 = c1 - 2;
b1--;
p1++;
}
p2 = 0;
while (c > 1 && b > 0) {
c = c - 2;
b--;
p2++;
}
while (a > 0 && b > 1) {
a--;
b = b - 2;
p2++;
}
if (p1 > p2)
cout << 3 * p1 << "\n";
else
cout << 3 * p2 << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, a, b, c, d, s, sum;
cin >> t;
while (t--) {
sum = 0;
cin >> a >> b >> c;
b = b / 1;
c = c / 2;
s = min(b, c);
sum = sum + 1 * s + 2 * s;
b = b - s * 1;
b = b / 2;
a = a / 1;
d = min(b, a);
sum = sum + 1 * d + 2 * d;
cout << sum << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int a, b, c;
cin >> a >> b >> c;
int ans = 0;
while (b > 0 && c > 1) {
b--;
c -= 2;
ans += 3;
}
while (a > 0 && b > 1) {
a--;
b -= 2;
ans += 3;
}
cout << ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int N = 1e5 + 5;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
int a, b, c;
cin >> a >> b >> c;
int res = 0;
res += min(b, c / 2);
b -= min(b, c / 2);
res += min(a, b / 2);
cout << res * 3 << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int beat(string s);
int main() {
int t;
cin >> t;
vector<int> a(t), b(t), c(t), score(t, 0);
for (int i = 0; i < t; i++) cin >> a[i] >> b[i] >> c[i];
for (int i = 0; i < t; i++) {
while ((b[i] >= 1 && c[i] >= 2) || (a[i] >= 1 && b[i] >= 2)) {
while (b[i] >= 1 && c[i] >= 2) {
score[i] += 3;
b[i]--;
c[i] -= 2;
}
while (a[i] >= 1 && b[i] >= 2) {
score[i] += 3;
a[i]--;
b[i] -= 2;
}
}
}
for (int i = 0; i < t; i++) {
cout << score[i] << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
inline int read() {
int x = 0, w = 0;
char ch = 0;
while (!isdigit(ch)) w |= ch == '-', ch = getchar();
while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
return w ? -x : x;
}
int t;
int main() {
t = read();
while (t--) {
int a = read(), b = read(), c = read(), ans = 0;
int tmp = c / 2;
ans += min(b, tmp) * 2 + min(b, tmp);
b -= min(b, tmp);
tmp = b / 2;
ans += min(a, tmp) * 2 + min(a, tmp);
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int T, a, b, c;
cin >> T;
for (int t = 0; t < T; t++) {
cin >> a >> b >> c;
cout << (min(c / 2, b) * 3) + min(a, (b - min(c / 2, b)) / 2) * 3 << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, b, c, t;
cin >> t;
while (t--) {
cin >> a >> b >> c;
n = 0;
int na = 0, nb = 0;
if (b == 0)
cout << 0 << endl;
else {
if (b >= 1 && c >= 2) {
c = c / 2;
if (c <= b) {
na = (c * 2) + c;
b = b - c;
} else {
na = (b * 2) + b;
b = 0;
}
}
if (b >= 2 && a > 0) {
b = b / 2;
if (b <= a) {
nb = (b * 2) + b;
} else {
nb = (a * 2) + a;
}
}
n = na + nb;
cout << n << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
int ctoi(const char c) {
if ('0' <= c && c <= '9') return (c - '0');
return -1;
}
ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
constexpr ll MOD = 1000000007;
constexpr ll INF = 1000000011;
constexpr ll MOD2 = 998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS = 10e-8;
template <class T>
bool chmax(T& a, const T& b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
for (auto&& x : v) is >> x;
return is;
}
template <typename T, typename U>
istream& operator>>(istream& is, pair<T, U>& p) {
is >> p.first;
is >> p.second;
return is;
}
template <typename T, typename U>
ostream& operator>>(ostream& os, const pair<T, U>& p) {
os << p.first << ' ' << p.second;
return os;
}
template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
for (auto i = begin(v); i != end(v); ++i) {
if (i != begin(v)) os << ' ';
os << *i;
}
return os;
}
int main() {
ll T, A, B, C, ans = 0;
cin >> T;
for (ll i = 0; i < (T); ++i) {
ans = 0;
cin >> A >> B >> C;
ans += min(B, C / 2) * 3;
B -= min(B, C / 2);
ans += min(A, B / 2) * 3;
cout << ans << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, a, b, c;
cin >> t;
while (t--) {
cin >> a >> b >> c;
int ans = 3 * min(b, c / 2);
b -= ans / 3;
ans += 3 * min(a, b / 2);
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6, NEG = -1e5, M = 4e5 + 9;
long long arr[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t, x, y, z;
cin >> t;
while (t--) {
int counter = 0;
cin >> x >> y >> z;
if (y != 0) {
if (z > 0) {
(z / 2 > y) ? counter += y* 3 : counter += (z / 2) * 2 + z / 2;
y -= z / 2;
}
if (y > 0 && x > 0) {
(y / 2 > x) ? counter += x* 3 : counter += (y / 2) * 2 + y / 2;
}
}
cout << counter;
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int a, b, c;
cin >> a >> b >> c;
int res = 0;
while ((a >= 1 && b >= 2) || (b >= 1 && c >= 2)) {
if ((b > c) && a != 0) {
a--;
b = b - 2;
res += 3;
} else {
b--;
c -= 2;
res = res + 3;
}
}
cout << res << endl;
}
}
|
#include <bits/stdc++.h>
int main(void) {
int t, k, count, a, b, c, pick_from_a, pick_from_b;
scanf("%d", &t);
while (t) {
scanf("%d %d %d", &a, &b, &c);
count = 0;
if (b < 2 * a) {
pick_from_a = b / 2;
} else {
pick_from_a = a;
}
if (c < 2 * b) {
pick_from_b = c / 2;
} else {
pick_from_b = b;
}
int count1 = 0, count2 = 0;
count1 = pick_from_a * 3;
k = b - 2 * pick_from_a;
if (2 * k > c)
count1 = count1 + 3 * (c / 2);
else
count1 = count1 + 3 * k;
count2 = pick_from_b * 3;
k = b - pick_from_b;
if (2 * a > k)
count2 = count2 + 3 * (k / 2);
else
count2 = count2 + 3 * a;
if (count2 > count1)
count = count2;
else
count = count1;
printf("%d\n", count);
t--;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
const long long int INF = 1e9;
long long int gcd(long long int a, long long int b) {
return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
int t;
cin >> t;
for (int i = 0; i < (t); ++i) {
int a, b, c;
cin >> a >> b >> c;
int ans = 0;
while (b > 0 && c > 1) {
ans += 3;
b--;
c -= 2;
}
while (a > 0 && b > 1) {
ans += 3;
a--;
b -= 2;
}
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
int t, a, b, c, M, k, A, B, C;
cin >> t;
for (int i = 0; i < t; i++) {
cin >> a >> b >> c;
M = 0;
for (int y = 0; y <= 100; y++) {
if (a < y || b < 2 * y) {
break;
}
B = b - 2 * y;
k = min(B, c / 2);
M = max(M, k + y);
}
cout << 3 * M << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int tc;
cin >> tc;
while (tc--) {
long long int a, b, c, ans;
cin >> a >> b >> c;
long long int kop = min(b, c / 2);
ans = kop * 3;
b -= kop;
b /= 2;
long long int joss = min(a, b);
cout << ans + (joss * 3) << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int n, a, b, c;
int main() {
scanf("%d", &n);
while (n--) {
scanf("%d%d%d", &a, &b, &c);
int ans = 0;
if (!b) {
printf("0\n");
continue;
}
while (c) {
if (b >= 1 && c >= 2)
ans += 3;
else
break;
b--;
c -= 2;
}
while (a) {
if (b >= 2 && a >= 1)
ans += 3;
else
break;
a--;
b -= 2;
}
printf("%d\n", ans);
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, d;
cin >> a;
for (int i = 0; i < a; i++) {
int cnt = 0;
cin >> b >> c >> d;
while (true) {
if (d - 2 < 0) {
break;
}
if (c - 1 < 0) {
break;
}
c--;
d -= 2;
cnt += 3;
}
while (true) {
if (c - 2 < 0) {
break;
}
if (b - 1 < 0) {
break;
}
c -= 2;
b--;
cnt += 3;
}
cout << cnt << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000000 + 7;
inline int add(int a, int b) {
a += b;
if (a >= MOD) a -= MOD;
return a;
}
inline int sub(int a, int b) {
a -= b;
if (a < 0) a += MOD;
return a;
}
inline int mul(int a, int b) { return (int)((long long)a * b % MOD); }
inline int binpow(int a, int b) {
int res = 1;
while (b > 0) {
if (b & 1) res = mul(res, a);
a = mul(a, a);
b /= 2;
}
return res;
}
inline int inv(int a) { return binpow(a, MOD - 2); }
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
int t;
cin >> t;
while (t--) {
int a, b, c;
cin >> a >> b >> c;
int res = 0;
if (c <= 2 * b) {
int tmp = c / 2;
res += (tmp * 3);
b -= tmp;
if (b <= 2 * a) {
tmp = b / 2;
res += tmp * 3;
} else {
res += 3 * a;
}
} else {
res += 3 * b;
}
cout << res << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
pair<long long int, long long int> dxy[] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
long long int months[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const long long MAXN = 55, MOD = 1000000007, INF = ((1ll << 60) - 1) * 2 + 1;
mt19937 Umer(1337228);
long long int n;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
long long int a, b, c;
for (long long int i = 0; i < (n); ++i) {
cin >> a >> b >> c;
long long int ans = 0;
for (long long int j = 0; j < (a + 1); ++j) {
if (b - 2 * j < 0) break;
ans = max(ans, j * 3 + min(b - 2 * j, c / 2) * 3);
}
cout << ans << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int a, b, c, res, A, B, C, T;
void inp() { scanf("%d %d %d", &a, &b, &c); }
void proc() {
A = a, B = b, C = c;
c -= min(b, c / 2) * 2;
b -= min(b, C / 2);
a -= min(a, b / 2);
b -= min(A, b / 2) * 2;
res = A - a + B - b + C - c;
printf("%d\n", res);
}
int main() {
scanf("%d", &T);
while (T--) {
inp();
proc();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int a, b, c, ma = 0;
cin >> a >> b >> c;
if (a >= b && b >= c) {
ma = (c / 2) * 3 + ((b - ((c / 2))) / 2) * 3;
} else if (b <= c) {
if (b <= c / 2) {
ma = 3 * b;
} else {
if (a <= (b - c / 2) / 2)
ma = 3 * (c / 2) + a * 3;
else {
ma = 3 * (c / 2) + ((b - c / 2) / 2) * 3;
}
}
} else if (b > c && a < b) {
if ((b - c / 2) / 2 > a)
ma = (c / 2) * 3 + a * 3;
else
ma = (c / 2) * 3 + ((b - c / 2) / 2) * 3;
}
cout << ma << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t;
while (t--) {
int a, b, c;
cin >> a >> b >> c;
int stones = 0;
while (b > 0 && c >= 2) {
b--;
c -= 2;
stones += 3;
}
while (a > 0 && b >= 2) {
a--;
b -= 2;
stones += 3;
}
cout << stones << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
signed main() {
long long q;
cin >> q;
while (q--) {
long long a, b, c;
cin >> a >> b >> c;
long long ans = 0;
for (long long i = 0; b > 0 && c > 1; i++) {
ans += 3;
b--;
c -= 2;
}
for (long long i = 0; a > 0 && b > 1; i++) {
ans += 3;
a--;
b -= 2;
}
cout << ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long long BASE = 1e9 + 7;
const long double EPS = 1e-9;
const long long EPS_INT = 1e12;
inline long long gcd(long long a, long long b) {
long long r;
while (b) {
r = a % b;
a = b;
b = r;
}
return a;
}
inline long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
inline long long fpow(long long a, long long n, long long p = BASE) {
long long r = 1;
for (; n; n >>= 1) {
if (n & 1) r = r * a % p;
a = a * a % p;
}
return r;
}
inline long long addmod(long long a, long long b, long long p = BASE) {
a = (a + b);
if (a > p) a -= p;
return a;
}
inline long long submod(long long a, long long b, long long p = BASE) {
a = (a - b);
if (a < 0) a += p;
return a;
}
inline long long multi(long long a, long long b, long long p = BASE) {
return a * b % p;
}
inline long long inverse(long long a, long long p = BASE) {
return fpow(a, p - 2, p);
}
inline long long maximize(long long& a, long long b) {
if (a < b) a = b;
return a;
}
inline long long minimize(long long& a, long long b) {
if (a > b) a = b;
return a;
}
const int MAX = (long long)1e6;
struct Point {
long long x, y, z;
long long id;
long long distance(Point t) {
long long k = (t.x - this->x) * (t.x - this->x) +
(t.y - this->y) * (t.y - this->y) +
(t.z - this->z) * (t.z - this->z);
return k;
}
};
struct Dis {
long long id, distance, idMin;
};
bool cmp(Dis a, Dis b) { return a.distance < b.distance; }
Point arrA[MAX + 1];
Dis arrB[MAX + 1];
void solves();
int main() {
if (fopen("output.out", "w")) {
}
if (fopen("input.inp", "r")) {
freopen("input.inp", "r", stdin);
} else {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
solves();
return 0;
}
void solves() {
long long t;
long long a, b, c;
cin >> t;
while (t--) {
long long res = 0;
long long res2 = 0;
cin >> a >> b >> c;
long long a1, b1, c1;
a1 = a;
b1 = b;
c1 = c;
res += min(a, b / 2) * 3;
if (a * 2 >= b)
b = 0;
else
b -= a * 2;
res += min(b, c / 2) * 3;
res2 += min(b1, c1 / 2) * 3;
if (b1 >= c1 / 2)
b1 -= c1 / 2;
else
b1 = 0;
res2 += min(a1, b1 / 2) * 3;
cout << max(res, res2) << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int MX = 1e5;
int t, a, b, c;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> t;
while (t--) {
cin >> a >> b >> c;
int ans = 0;
while (b > 0 && c > 1) {
ans += 3;
b -= 1;
c -= 2;
}
while (a > 0 && b > 1) {
ans += 3;
b -= 2;
a -= 1;
}
cout << ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int x;
cin >> x;
int a[x][3], b[x];
for (int i = 0; i < x; i++) {
for (int j = 0; j < 3; j++) {
cin >> a[i][j];
}
}
for (int i = 0; i < x; i++) {
int count = 0;
if (a[i][1] == 0) {
cout << "0" << endl;
continue;
} else {
for (int k = a[i][1]; k > 0; k--) {
if ((k * 2) <= a[i][2]) {
count = count + 3 * k;
a[i][1] -= k;
break;
}
}
for (int k = a[i][0]; k > 0; k--) {
if (a[i][1] == 0) {
break;
} else if ((k * 2) <= a[i][1]) {
count = count + 3 * k;
break;
}
}
}
cout << count << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
namespace patch {
template <typename T>
std::string to_string(const T& n) {
std::ostringstream stm;
stm << n;
return stm.str();
}
} // namespace patch
long long gcd(long long a, long long b) { return a == 0 ? b : gcd(b % a, a); }
bool isAPrime(long long m) {
for (long long p = 2; p * p <= m; p++) {
if (m % p == 0) {
return false;
}
}
return true;
}
bool cmp(int a, int b) { return a > b; }
int main() {
int n;
cin >> n;
while (n--) {
int a, b, c;
cin >> a >> b >> c;
int sum = 0;
while ((a >= 1 && b >= 2) || (b >= 1 && c >= 2)) {
sum += 3;
int k1 = min(b, c / 2);
int k2 = min(a, b / 2);
if (k1 > k2) {
b--;
c -= 2;
} else {
a--;
b -= 2;
}
}
cout << sum << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int t, a, b, c, ans, t1;
int main() {
scanf("%d", &t);
while (t--) {
scanf("%d%d%d", &a, &b, &c);
ans = 0;
t1 = c / 2;
t1 = min(t1, b);
ans += t1 * 3;
b -= t1;
t1 = b / 2;
t1 = min(t1, a);
ans += t1 * 3;
printf("%d\n", ans);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int t;
int main() {
scanf("%d", &t);
while (t--) {
int a, b, c, ans = 0;
scanf("%d%d%d", &a, &b, &c);
for (int i = 0; i <= a; i++)
if (b >= i * 2) {
int cur = i * 3;
int lb = b - i * 2;
cur += min(lb, c / 2) * 3;
ans = max(ans, cur);
}
printf("%d\n", ans);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int a, b, c;
cin >> a >> b >> c;
int a1 = a, b1 = b, c1 = c;
int v = 0, h = 0;
while (a1 > 0 && b1 > 1) {
v += 3;
--a1;
b1 -= 2;
}
while (b1 > 0 && c1 > 1) {
v += 3;
--b1;
c1 -= 2;
}
while (b > 0 && c > 1) {
h += 3;
--b;
c -= 2;
}
while (a > 0 && b > 1) {
h += 3;
--a;
b -= 2;
}
cout << max(v, h) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int t, a, b, c, ans;
int main() {
cin >> t;
while (t--) {
ans = 0;
cin >> a >> b >> c;
ans += min(b, c / 2) * 3;
b -= min(b, c / 2);
ans += min(b / 2, a) * 3;
cout << ans << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int a, b, c, x, y, t;
cin >> t;
while (t--) {
cin >> a >> b >> c;
y = min(b, c / 2);
b -= y;
x = min(a, b / 2);
cout << (x + y) * 3 << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
for (auto i : v) os << i << " ";
return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
for (auto i : v) os << i << " ";
return os;
}
int main() {
int T;
scanf("%d", &T);
while (T--) {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
int ans = 0;
for (int i = 0; i < 100; ++i)
for (int j = 0; j < 100; ++j) {
if (i <= a && i * 2 + j <= b && j * 2 <= c)
ans = max(ans, i * 3 + j * 3);
}
printf("%d\n", ans);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--) {
int a, b, c;
cin >> a >> b >> c;
int n = 0;
if (b < c / 2) {
n += 3 * b;
b = 0;
} else {
n += c / 2 + c - ((c % 2 == 0) ? 0 : 1);
b -= c / 2;
}
if (a < b / 2) {
n += 3 * a;
} else {
n += b / 2 + b - ((b % 2 == 0) ? 0 : 1);
}
cout << n;
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int a, b, c;
cin >> a >> b >> c;
int ans = 0;
if (c >= 2 * b) {
ans += b * 3;
b = 0;
} else {
ans += c / 2 * 3;
b -= c / 2;
}
if (b >= 2 * a)
ans += a * 3;
else
ans += b / 2 * 3;
cout << ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, a, b, c, k = 0, q = 0, w = 0;
cin >> t;
for (int i = 0; i < t; i++) {
cin >> a >> b >> c;
while (c >= 2 and b >= 1) {
if ((b - c / 2) >= 0) {
q = b - c / 2;
k = k + 3 * (b - q);
c = c - 2 * (b - q);
b = q;
}
c -= 2;
}
while (b >= 2 and a >= 1) {
if ((a - b / 2) >= 0) {
q = a - b / 2;
w = w + 3 * (a - q);
b = b - 2 * (a - q);
a = w;
}
b -= 2;
}
cout << k + w << "\n";
k = 0;
w = 0;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int a, b, c, cnt = 0;
cin >> a >> b >> c;
if (b == 0)
cout << 0 << endl;
else {
if (c != 0 && b != 0) {
int m = c / 2;
if (b >= m)
b = b - m;
else {
m = b;
b = 0;
}
c = c - m;
cnt += m;
cnt += m * 2;
}
if (b > 1 && a != 0) {
int n = b / 2;
if (a >= n) {
a = a - n;
} else {
n = a;
}
cnt += n;
cnt += n * 2;
}
cout << cnt << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
vector<bool> prime(1000000000 + 1, 1);
void SieveOfEratosthenes(int n) {
prime[0] = 0;
prime[1] = 0;
for (long long unsigned int p = 2; p * p <= n; p++) {
if (prime[p] == true) {
for (long long unsigned int i = p * p; i <= n; i += p) prime[i] = false;
}
}
}
long long unsigned int countDivisors(long long unsigned int n) {
long long unsigned int cnt = 0;
for (long long unsigned int i = 1; i <= sqrt(n); i++) {
if (n % i == 0) {
if (n / i == i)
++cnt;
else
cnt += 2;
}
}
return cnt;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
;
int t;
cin >> t;
while (t--) {
int a, b, c, ans = 0, ans1 = 0;
cin >> a >> b >> c;
int a1 = a, b1 = b, c1 = c;
int temp = min(b / 2, a);
ans += temp * 3;
a -= temp;
b -= temp * 2;
int temp1 = min(b, c / 2);
ans += temp1 * 3;
b -= temp1;
c -= temp1 * 2;
int temp_ = min(b1, c1 / 2);
ans1 += temp_ * 3;
b1 -= temp_;
c1 -= temp_ * 2;
int temp1_ = min(b1 / 2, a1);
ans1 += temp1_ * 3;
a1 -= temp1_;
b1 -= temp1_ * 2;
cout << max(ans, ans1) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--) {
int a, b, c, ans = 0;
cin >> a >> b >> c;
int t1 = min(a, b / 2);
int a1 = t1 + 2 * t1;
int t2 = min(b - 2 * t1, c / 2);
a1 += t2 + 2 * t2;
t1 = min(b, c / 2);
int a2 = t1 + 2 * t1;
t2 = min(a, (b - t1) / 2);
a2 += t2 + 2 * t2;
cout << max(a1, a2) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, a, b, c, sum, val;
cin >> t;
while (t--) {
cin >> a >> b >> c;
val = a + b + c;
while (b >= 1 && c >= 2) {
if (b - 1 >= 0 && c - 2 >= 0) {
b -= 1;
c -= 2;
}
}
while (a >= 1 && b >= 2) {
if (a - 1 >= 0 && b - 2 >= 0) {
a -= 1;
b -= 2;
}
}
sum = a + b + c;
cout << val - sum << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
int T;
cin >> T;
while (T--) {
int a, b, c;
cin >> a >> b >> c;
int res = 0;
int q = min(b, c / 2);
res += (q + q * 2);
q = min(a, (b - q) / 2);
res += (q + q * 2);
cout << res << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int a, b, c;
cin >> a >> b >> c;
int count = 0;
while (b >= 1 && c >= 2) {
b--;
c -= 2;
count++;
}
while (b >= 2 && a >= 1) {
b -= 2;
a--;
count++;
}
cout << count * 3 << endl;
}
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
return (a.first - a.second) > (b.first - b.second);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t;
while (t--) {
int a, b, c;
cin >> a >> b >> c;
int cnt1 = 0, cnt2 = 0;
int t1 = 2 * a;
t1 = min(t1, b - b % 2);
cnt1 += (t1 * 3) / 2;
int t2 = b - t1;
int t3 = min(2 * t2, c - c % 2);
cnt1 += (t3 * 3) / 2;
t1 = 2 * b;
t1 = min(t1, c - c % 2);
cnt2 += (t1 * 3) / 2;
b = b - t1 / 2;
t3 = min(2 * a, b - b % 2);
cnt2 += (t3 * 3) / 2;
cout << max(cnt1, cnt2) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
vector<long> a(10005, 0);
int main() {
int t;
cin >> t;
while (t--) {
int a, b, c, ans = 0;
cin >> a >> b >> c;
while (c > 1 && b > 0) {
c -= 2;
b--;
ans += 3;
}
while (a > 0 && b > 1) {
b -= 2;
a -= 1;
ans += 3;
}
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, a, b, c, n, s = 0;
cin >> t;
while (t--) {
cin >> a >> b >> c;
n = (b - c / 2);
if (n <= 0)
s += b * 2, s += b;
else {
s += c / 2 * 2, s += c / 2;
b -= c / 2;
n = a - b / 2;
if (n <= 0)
s += a * 2, s += a;
else {
s += b / 2 * 2, s += b / 2;
a -= b / 2;
}
}
cout << s << endl;
s = 0;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
long long t;
cin >> t;
while (t--) {
long long x, y;
long long a, b, c;
cin >> a >> b >> c;
long long maxm = 0;
for (x = 0; x <= 100; ++x) {
for (y = 0; y <= 100; ++y) {
if (b < x + 2 * y) continue;
if (a < y) continue;
if (c < 2 * x) continue;
maxm = max(maxm, 3 * (x + y));
}
}
cout << maxm << endl;
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.