Masala A.

//C++ tilida yechim
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long Q, B, K;
    cin >> Q >> B >> K;
    long long cnt = min(Q/2, B);
    K -= (Q - cnt*2);
    K -= (B - cnt);
    if(K < 0) K = 0;
    cnt -= K/3;
    if(K%3 != 0) cnt --;
    cout << cnt;
}
#Python tilida yechim
Q, B, K = map(int, input().split())
cnt = min(Q//2, B)
K -= (Q - cnt*2)
K -= (B - cnt)
if K < 0:
    K = 0
cnt -= K//3
if K%3 != 0:
    cnt -= 1
print(cnt)

 

Masala B.

C++ tilida yechim
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        long long a;
        cin >> a;
        if(a <= 4 || a == 6){
            cout << -1;
        }
        else {
        	long long i = 3;
            while(a%i == 0){
                i += 2;
            }
            cout << a-i << ' ' << i;
        }
        cout << endl;
    }
}
#Python tilida yechim
t = int(input())
for _ in range(t):
    a = int(input())
    if a <= 4 or a == 6:
        print(-1)
    else:
        i = 3
        while a % i == 0:
            i += 2
        print(a - i, i)

 

Masala C.

//C++ tilida yechim
#include <bits/stdc++.h>
using namespace std;
    
int c, l, v0, v1, a;
    
int main()
{
    cin >> c >> v0 >> v1 >> a >> l;
    int pos = v0;
    int t = 1;
    
    int add = v0;
    
    while (pos < c)
    {
        add = min(v1, add + a);
    
        pos += add - l;
        t++;
    }
    
    cout << t << endl;
}
#Python tilida yechim
c, v0, v1, a, l = map(int, input().split())
pos = v0
t = 1
add = v0

while pos < c:
    add = min(v1, add + a)
    pos += add - l
    t += 1

print(t)

Masala D.

//C++ tilida yechim

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll f(ll x){
	return x*(x+1)/2;
}
int main() {
	int m,b;
	cin >> m >> b;
	ll ans = 0;
	for(int k = b; k >=0; --k){
		ll x = m*(b-k);
		ll t = 0;
		t+=(x+1)*f(k)+(k+1)*f(x);
		ans = max(ans,t);
	}
	cout << ans << endl;
}
m,b = map(int,input().split())
def f(x):
    return x*(x+1)//2
ans = 0
for k in range(b,-1,-1):
    x = m*(b-k)
    t = 0
    t+=(x+1)*f(k)+(k+1)*f(x)
    ans = max(ans,t)
print(ans)

Masala E.

//C++ tilida yechim
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
  int n, m, q;
  cin >> n >> m >> q;
  vector<vector<int>> imos(n, vector<int>(n + 1));
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    imos[l][r]++;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      imos[i][j + 1] += imos[i][j];
    }
  }
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    int ans = 0;
    for (int j = l; j <= r; j++) {
      ans += imos[j][r];
    }
    cout << ans << endl;
  }
}
# PyPy da yechim
n, m, q = map(int, input().split())
imos = [[0] * (n + 1) for _ in range(n)]

for _ in range(m):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    imos[l][r] += 1

for i in range(n):
    for j in range(1, n + 1):
        imos[i][j] += imos[i][j - 1]

for _ in range(q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    ans = 0
    for j in range(l, r + 1):
        ans += imos[j][r]
    print(ans)