#include<iostream>
using namespace std;intmain(){int c[3], m[3];for(int i =0; i <3; i ++) cin >> c[i]>> m[i];for(int i =0; i <100; i ++){int x = i %3;int y =(i+1)%3;if(m[x]>= c[y]-m[y]) m[x]-= c[y]-m[y], m[y]= c[y];else m[y]+= m[x], m[x]=0;}for(int i =0; i <3; i ++) cout << m[i]<< endl;return0;}
T2 The Bucket List
#include<iostream>
using namespace std;constint N =1005;int n, a[N], sum[N];intmain(){
cin >> n;for(int i =1; i <= n; i ++){int s, t, b;
cin >> s >> t >> b;
a[s]+= b;
a[t+1]-= b;}int ans =0;for(int i =1; i <=1000; i ++){
sum[i]= sum[i-1]+ a[i];
ans =max(ans, sum[i]);}
cout << ans << endl;return0;}
T3 Back and Forth
#include<iostream>
using namespace std;int a[30], ttl =1000;
bool b[30], mt[2010];voiddfs(int x){if(x ==6){
mt[ttl]= true;return;}for(int i =1; i <=20; i ++){if(x%2==0&&!b[i]){
ttl -= a[i];
b[i]= true;dfs(x+1);
b[i]= false;
ttl += a[i];}elseif(x%2==1&& b[i]){
ttl += a[i];
b[i]= false;dfs(x+1);
b[i]= true;
ttl -= a[i];}}}intmain(){for(int i =1; i <=10; i ++){
cin >> a[i];
b[i]= false;}for(int i =11; i <=20; i ++){
cin >> a[i];
b[i]= true;}dfs(2);int cnt =0;for(int i =0; i <=2000; i ++){if(mt[i]) cnt ++;}
cout << cnt;return0;}
T1 Mixing Milk#include <iostream>using namespace std;int main() { int c[3], m[3]; for (int i = 0; i < 3; i ++) cin >> c[i] >> m[i]; for (int i = 0; i < 100; i ++) { int x = i % 3; int y = (i+1) % 3; if (m[x] >=