akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double h = sc.nextDouble();
		double m = sc.nextDouble();
		
		// 計算
		double result = 0;
		double theta = (PI/180) * (h*360/12 + m*30/60 - m*360/60);
		//double theta = PI * (h/6 - m/30);
		result = a*a + b*b - 2*a*b*cos(theta);
		result = sqrt(result);
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}



Measured memory_bytes: 25516
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define all(v) v.begin(),v.end()
#define itr(r,v) for(auto r=v.begin();r!=v.end();r++)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfr(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define ctime auto sttart = high_resolution_clock::now()
#define etime auto sttop = high_resolution_clock::now()
#define go_t ll testcases; cin>>testcases; for(ll caseno= 1 ;caseno <= testcases; caseno++)
#define ptime auto z1z = duration_cast<microseconds>(sttop-sttart); cout<<"\nTime taken : "<<z1z.count()<<" microseconds\n"
#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';

using namespace std;
using namespace std::chrono;

const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
const ll maxN = 2e5 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

ll powerM(ll x, ll y, ll M = MOD) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

ll power(ll x, ll y) {
	ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	FIO
	ll n, w; cin >> n >> w;
	ll wt[n], val[n];
	FOR(i, n) cin >> wt[i] >> val[i];
	// dp[i][j] represents max sum that we can make using i elements if weight was j
	ll dp[2][w + 1];
	for (ll i = 0; i <= w; i++) {
		dp[0][i] = 0, dp[1][i] = 0;
	}
	for (ll i = 1; i <= n; i++) {
		for (ll j = 1; j <= w; j++) {
			if (wt[i - 1] <= j) {
				dp[1][j] = max(dp[0][j], val[i - 1] + dp[0][j - wt[i - 1]]);
			}
			else {
				dp[1][j] = dp[0][j];
			}
		}
		for (ll j = 0; j <= w; j++) {
			dp[0][j] = dp[1][j];
		}
	}
	cout << dp[0][w];
	return 0;
}


Measured memory_bytes: 5220
n = int(input())
list_shop = []

for i in range(n):
  t = []
  a, b = input().split()
  t.append(a)
  t.append(b)
  t.append(str(i + 1))
  list_shop.append(t)

check = 0
c = []

list_shop = sorted(list_shop, key=lambda x: x[0])

for i in range(len(list_shop) - 1):
  if(list_shop[i][0] == list_shop[i + 1][0]):
    check = 1
  else:
    check = 0

  c.append(list(map(int, list_shop[i][1:3])))
  if(check == 1):
    continue
  else:
    c.sort(key=lambda x:x[0], reverse=True)
    for j in c:
      print(int(j[1]))
    c = []

if(check == 1):
  c.append(list(map(int, list_shop[n - 1][1:3])))
  c.sort(key=lambda x:x[0], reverse=True)
  for i in c:
    print(i[1])
else:
  print(int(list_shop[n - 1][2]))


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
 
int main(){
  int S;

  cin >> S;
  int h = S/3600;
  int m = (S-h*3600)/60;
  int s = S-h*3600-m*60;
  cout << h<<":"<<m<<":"<<s << endl;

  return 0;		 
}
		   



Measured memory_bytes: 3100
object Main {
  def main(args: Array[String]): Unit = {

    val x = io.StdIn.readLine().toLong

    for{
      a <- 1L until 1000L
      b <- -1000L until 1000L
     } {
      val t = a*a*a*a*a - b*b*b*b*b
      if(t == x) {
        println(s"${a} ${b}")
        return
      }
    }
  }

}

Measured memory_bytes: 57048
N = int(input())
A = list(map(int,input().split()))

if A.count(0) > 0:
    print(0)
    exit()

ans = 1
for i in range(N):
    if(ans > 1e18 // A[i]):
        print(-1)
        exit()
    ans *= A[i]

print(ans)

Measured memory_bytes: 21472
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

struct Node{
    int left, right;
    int m;
}nodes[1200000];

void build(int u, int l, int r){
    nodes[u].left = l;
    nodes[u].right = r;
    nodes[u].m = 0;
    if(l == r)
        return;
    build(u*2, l, (l+r)/2);
    build(u*2+1, (l+r)/2+1, r);
}

int query(int u, int l, int r){
    if(nodes[u].left == l && nodes[u].right == r){
        return nodes[u].m;
    }
    if(r <= nodes[u*2].right)return query(u*2, l, r);
    else if(l >= nodes[u*2+1].left)return query(u*2+1, l, r);
    else{
        int x = query(u*2, l, nodes[u*2].right);
        int y = query(u*2+1, nodes[u*2+1].left, r);
        return x < y ? y : x;
    }
}

void update(int u, int x, int k){
    if(nodes[u].left == nodes[u].right){
        if(nodes[u].m < k)
            nodes[u].m = k;
        return;
    }
    if(x <= nodes[u*2].right)update(u*2, x, k);
    else update(u*2+1, x, k);
    nodes[u].m = nodes[u*2].m > nodes[u*2+1].m ? nodes[u*2].m : nodes[u*2+1].m;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    build(1, 0, 300000);
    int ans = 0;
    while(n--){
        int x;
        cin >> x;
        int l = x - m;
        int r = x + m;
        if(l < 0)
            l = 0;
        if(r > 300000)
            r = 300000;
        int k = query(1, l, r);
        if(k + 1 > ans)
            ans = k + 1;
        update(1, x, k + 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15944
let () =
  let s = Scanf.scanf "%s " (fun a -> a) in
  let k = Scanf.scanf "%d " (fun a -> a) in

  let length = String.length s in

  let rec f str fst fnl res = 
    if fst = length then res else (
      let res = (String.sub str fst fnl) :: res in
      if (fst + fnl = length || fnl = k) then
        f str (fst+1) 1 res
      else
        f str fst (fnl+1) res
    )

  in
  let lst = f s 0 1 [] in
  let lst = List.sort_uniq compare lst in

  print_endline (List.nth lst (k-1))



Measured memory_bytes: 6144
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import Counter 
def main():
    N = int(input())
    s = []
    for _ in range(N):
        s.append(input())
    dd = Counter(s)
    print('AC x ' + str(dd['AC']))
    print('WA x ' + str(dd['WA']))
    print('TLE x ' + str(dd['TLE']))
    print('RE x ' + str(dd['RE']))
if __name__ == '__main__':
    main()


Measured memory_bytes: 78688
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
h = LIST()
ans = 0
while sum(h) > 0:
	flg = False
	for i in range(N):
		if flg and h[i] == 0:
			flg = False
			ans += 1
		elif h[i] != 0:
			flg = True
			h[i] -= 1
	if flg:
		ans += 1
print(ans)


Measured memory_bytes: 5400
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

void solve() {
  ll N;
  cin >> N;
  vector<ll> v;
  map<ll, ll> mp;
  for (int i = 0; i < N; i++) {
    ll a;
    cin >> a;
    v.push_back(a);
    mp[a] = 0;
  }
  for (int i = 0; i < N; i++) {
    mp[v[i]]++;
  }
  ll res = 0;
  for (map<ll, ll>::iterator itr = mp.begin(); itr != mp.end(); ++itr) {
    if ((itr->second) % 2 == 1) {
      res++;
    }
  }
  cout << res << endl;
}


int main() {
  solve();
}

Measured memory_bytes: 7284
#include<bits/stdc++.h>
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
using Graph = vector<vector<int>>;
queue<int> quex,quey;

int main(){
    long long a,b,c,d,k;    cin >> a >> b >> k;


    if(a+b-k<=0) cout <<'0'<<' '<<'0'<< endl;
    else if(a-k<=0) cout << 0 << ' ' << a+b-k << endl;
    else cout << a-k << ' ' << b << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
int main() {
int A, B, C; cin >> A >> B >> C;
cout << B+C-max((C-1)-(A+B), 0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int N, A, B, C;
	std::string s;
	cin >> N >> A >> B >> C;
	std::vector<int>L(N);
	for (int n = 0; n < N; n++) {
		cin >> L[n];
	}
	int minMP = INT_MAX;
	int nRep = std::pow(4, N) + 0.5;
	for (int i = 0; i < nRep; ++i) {
		int lA = 0, lB = 0, lC = 0;
		int nA = 0, nB = 0, nC = 0;
		int ii = i;
		for (int n = 0; n < N; ++n) {
			switch (ii % 4) {
			case 0:
				lA += L[n];
				++nA;
				break;
			case 1:
				lB += L[n];
				++nB;
				break;
			case 2:
				lC += L[n];
				++nC;
				break;
			}
			ii /= 4;
		}
		int MP = 0;
		if (nA*nB*nC == 0)continue;
		MP += std::abs(A - lA) + 10 * (nA - 1);
		MP += std::abs(B - lB) + 10 * (nB - 1);
		MP += std::abs(C - lC) + 10 * (nC - 1);
		if (MP < minMP) {
			minMP = MP;
		}
	}
	cout << minMP;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main()
{
    vector<int> rate = {400, 800, 1200, 1600, 2000, 2400, 2800, 3200};
    vector<bool> c(8, false);
    int over = 0;

    int n;
    cin >> n;
    int ai;
    for (int i = 0; i < n; i++)
    {
        cin >> ai;
        for (int j = 0; j < 8; j++)
        {
            if (ai < rate.at(j))
            {
                c.at(j) = true;
                break;
            }
        }
        if (ai > 3199)
        {
            over++;
        }
    }

    int res = 0;
    for (int i = 0; i < 8; i++)
    {
        if (c.at(i))
        {
            res++;
        }
    }
    cout << max(res, 1) << " " << res + over << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

long long d, n;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> d >> n;
	if(n == 100) ++n;
	for(int i=0; i<d; ++i) n *= 100;
	cout << n << "\n";
}

Measured memory_bytes: 256
import bisect

n, m, k = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))

acA = [0]
for i in range(n):
  acA.append(acA[i] + A[i])

acB = [0]
for i in range(m):
  acB.append(acB[i] + B[i])

ans = 0
for a in range(n+1):
  if k-acA[a] < 0: break
  b = bisect.bisect(acB, k-acA[a]) - 1
  ans = max(ans, a+b)
    
print(ans)

Measured memory_bytes: 47476
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	int a = 0;

	while (1) {
		int n, w, l, d;
		vector<string> name(10);

		cin >> n;
		if (n == 0) break;
		if (a == 1) cout << endl;
		vector< pair<int, int> > vp(n);

		for (int i = 0; i < n; i++) {
			cin >> name[i];
			cin >> w >> l >> d;
			
			int p = 3 * w + d;

			vp[i].first = p;
			vp[i].second = (-1) * i;
		}
		sort(vp.begin(), vp.end());
		for (int i = n - 1; i >= 0; i--) {
			cout << name[vp[i].second * (-1)] << "," << vp[i].first << endl;
		}
		a = 1;
	}
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;


int main() {
    string a, b, c;
    cin >> a >> b >> c;
    cout << a.front() << b.front() << c.front() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    int n;
    string s,ans = {};
    cin >> n;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        int tmp = s[i] - '0';
        tmp += n;
        if(tmp >= 43) tmp -= 26;
        //char c = char(tmp)-'0';
        if(tmp == 17) ans += 'A';
        else if(tmp == 18) ans += 'B';
        else if(tmp == 19) ans += 'C';
        else if(tmp == 20) ans += 'D';
        else if(tmp == 21) ans += 'E';
        else if(tmp == 22) ans += 'F';
        else if(tmp == 23) ans += 'G';
        else if(tmp == 24) ans += 'H';
        else if(tmp == 25) ans += 'I';
        else if(tmp == 26) ans += 'J';
        else if(tmp == 27) ans += 'K';
        else if(tmp == 28) ans += 'L';
        else if(tmp == 29) ans += 'M';
        else if(tmp == 30) ans += 'N';
        else if(tmp == 31) ans += 'O';
        else if(tmp == 32) ans += 'P';
        else if(tmp == 33) ans += 'Q';
        else if(tmp == 34) ans += 'R';
        else if(tmp == 35) ans += 'S';
        else if(tmp == 36) ans += 'T';
        else if(tmp == 37) ans += 'U';
        else if(tmp == 38) ans += 'V';
        else if(tmp == 39) ans += 'W';
        else if(tmp == 40) ans += 'X';
        else if(tmp == 41) ans += 'Y';
        else if(tmp == 42) ans += 'Z';
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef long long  ll;

int main()
{
	int N;
	
	cin>>N;
	rep(i, N) {
		int a, b, c;
		cin >> a >> b >> c;
		if (a*a == b*b + c*c ||
			b*b == a*a + c*c ||
			c*c == a*a + b*b)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> vll;
typedef pair<int, int> vii;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define asd cout << "ok" << endl;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define trav(it, m) for(auto it = m.begin(); it!= m.end(); it++)

const char nl = '\n';
const int MX = 2e5 +5;
const int MOD = 1e9 +7;
const int inf = 1e9;
const ll INF = 1e18;
const ld PI = acos((ld)-1);

int fenwick[MX] = {};




int main(){
   ios_base::sync_with_stdio(0); cin.tie(0);
   ll x, k, d;
   cin >> x >> k >> d;
   if(x < 0) x = -x;
   if(k <= x/d){
    cout << (x - d*k) <<nl;
    return 0;
   }

   ll tmp = x/d;
   k -= tmp;
   if(k%2) cout << abs(d-x%d) << nl;
   else cout << abs(x%d) << nl;

}


Measured memory_bytes: 3660
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<string> s(n);
  REP(i, n) cin >> s[i];

  int ret = 0;
  REP(i, n) {
    vector<string> t(n);
    REP(j, n) t[j] = s[j].substr(i+1) + s[j].substr(0, i+1);

    bool flag = true;
    REP(j, n) REP(k, n) {
      if(t[j][k] != t[k][j]) {
        flag = false;
      }
    }

    if(flag) ret += n;
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 600
import java.util.Arrays;
import java.util.Scanner;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = scanner.nextInt();
        int Q = scanner.nextInt();
        scanner.nextLine();

        SegTree segTree = new SegTree(N, new Sum());
        for (int i = 0; i < Q; i++) {
            int[] q = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            if (q[0] == 0) {
                segTree.update(q[1] - 1, q[2], false);
            } else {
                System.out.println(segTree.query(q[1] - 1, q[2] - 1));
            }
        }
    }

}

class SegTree {

    class Node {
        long val;
    }

    int size;
    Operation op;
    Node[] nodes;

    public SegTree(int size, Operation op) {
        this.size = Integer.highestOneBit(size);
        if (size > this.size) {
            this.size <<= 1;
        }
        this.op = op;
        nodes = new Node[this.size * 2];
        for (int i = 1; i < this.size * 2; i++) {
            nodes[i] = new Node();
            nodes[i].val = op.getInit();
        }
    }

    public void update(int index, int val) {
        update(index, val, true);
    }

    public void update(int index, int val, boolean overwrite) {
        index += size;
        nodes[index].val = overwrite ? val : op.calc(nodes[index].val, val);
        while ((index >>= 1) > 0) {
            nodes[index].val = op.calc(nodes[2 * index].val, nodes[2 * index + 1].val);
        }
    }

    public long query(int fromInc, int toInc) {
        fromInc += size;
        toInc += size;
        long left = op.getInit();
        long right = op.getInit();
        while (fromInc <= toInc) {
            if ((fromInc & 1) > 0)
                left = op.calc(left, nodes[fromInc++].val);
            if ((toInc & 1) == 0)
                right = op.calc(right, nodes[toInc--].val);
            fromInc >>= 1;
            toInc >>= 1;
        }
        return op.calc(left, right);
    }
}

abstract class Operation {
    abstract public long getInit();

    abstract public long calc(long x, long y);
}

class Sum extends Operation {

    @Override
    public long getInit() {
        return 0;
    }

    @Override
    public long calc(long x, long y) {
        return x + y;
    }
}




Measured memory_bytes: 182116
# include <iostream>
using namespace std;

int main() {
    long long n, m, l; cin >> n >> m >> l;
    long long a[n][m] = {}, b[m][l] = {}, c[n][l] = {};
    
    for (int row = 0; row < n; ++row) {
        for (int col = 0; col < m; ++col) cin >> a[row][col];
    }
    for (int row = 0; row < m; ++row) {
        for (int col = 0; col < l; ++col) cin >> b[row][col];
    }
    
    for (int a_row = 0; a_row < n; ++a_row) {
        for (int b_col = 0; b_col < l; ++b_col) {
            long long sum = 0;
            for (int ab_rowcol = 0; ab_rowcol < m; ++ab_rowcol) {
                sum += a[a_row][ab_rowcol] * b[ab_rowcol][b_col];
            }
            c[a_row][b_col] = sum;
        }
    }
    
    for (int row = 0; row < n; ++row) {
        for (int col = 0; col < l - 1; ++col) cout << c[row][col] << " ";
        cout << c[row][l - 1] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include <algorithm>
#include <stdlib.h>
using namespace std;

int main(void) {
	string s;
	cin >> s;
	bool flag = true;
	bool dream = false;
	int i = 0;
	while (i + 4< s.size()) {
		if (s[i] == 'd' && s[i + 1] == 'r' && s[i + 2] == 'e' &&
			s[i + 3] == 'a' && s[i + 4] == 'm') {
			dream = true;
		}
		else if (s[i] == 'e' && s[i + 1] == 'r' && s[i + 2] == 'a' &&
			s[i + 3] == 's' && s[i + 4] == 'e')dream = false;
		else {
			flag = false;
			break;
		}
		i += 5;
		if (dream == true && s[i] == 'e' && s[i + 1] == 'r' && s[i + 2] != 'a') {
			i+=2;
		}
		else if (dream == false && s[i] == 'r')i++;
		

	}
	if (s[i] != '\0')flag = false;
	if(flag)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("outp.txt","w",stdout);
    #endif
    ll n,i;
    cin>>n;
    vector<ll> a(n);
    for(i=0;i<n;i++)
        cin>>a[i];
    ll sum=0;
    for(i=1;i<n;i++)
    {
        if(a[i-1]>a[i])
        {
            sum=sum+a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    cout<<sum;
}

    


Measured memory_bytes: 4788
import java.util.Scanner;

public class Main{

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int ab = scan.nextInt();
		int bc = scan.nextInt();
		int ca = scan.nextInt();
		
		int s = (ab * bc) / 2;
		
		System.out.println(s);
	}
	
}


Measured memory_bytes: 23508
#include "bits/stdc++.h"

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)


#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
 
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
 
typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*1000 + 11;

int arr[NMAX];
int n,m,p,q,k,a,b,c,ans;
string s,str;
char ch;
vector<int> v;

void solve()
{
    cin>>a>>b;
    cout<<a*b;
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>

#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define rep1(i, n) for(int i=1; i<=(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

typedef uint64_t ulint;
typedef int64_t lint;
using namespace std;

lint a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
bool flagdebug = false;

int main(){
//////////////////////////////////////////////////////
    // flagdebug = true;

    cin >> n;



    cout << (n - 1) / 2 << endl;

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main()
{
    ll L;
    ll R;

    cin >> L >> R;

    if(R-L > 2019){
        cout << 0 << endl;
        return 0;
    }
    ll ans = INF;
    for(ll i=L; i<=R-1; i++){
        for(ll j=i+1; j<=R; j++){
            ll temp;
            temp = ((i%2019) * (j%2019)) % 2019;
            ans = min(ans,temp);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%s", $S);
$ans = "Yes";
foreach (str_split($S) as $k => $v) {
    if ($k % 2 === 0 && $v === "L") {
        $ans = "No";
    }
    if ($k % 2 === 1 && $v === "R") {
        $ans = "No";
    }
}
echo $ans;


Measured memory_bytes: 4856
#include<stdio.h>
int main(void)
{
	int a, b, menseki, syuu;
	scanf("%d %d", &a, &b);
	menseki = a * b;
	syuu = a * 2 + b * 2;
	printf("%d %d\n", menseki, syuu);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){
    int K; cin >> K;

    cout << (K/2) * (K-K/2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

bool check_max(int n, vector<ll> a){
	ll ma = -1;
	for(int i=0; i<n; i++){
		ma = max(ma, a[i]);
	}
	if(ma <= n-1) return false;
	else return true;
}

/*
ll solve(int n, vector<ll> a){
	ll ans = 0;
	while(check_max(n, a)){
		ll ma = -1;
		int id = -1;
		for(int i=0; i<n; i++){
			if(ma < a[i]){
				ma = a[i];
				id = i;
			}
		}
		a[id] -= a.size();

		for(int i=0; i<n; i++){
			if(i != id){
				a[i]++;
			}
			//printf("%d ", a[i]);
		}
		//puts("");
		ans++;
	}
	return ans;
}
*/

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	//cout << solve(n, a) << endl;

	
	/*
	int n;
	n = 2;
	vector<ll> a;
	a.pb(1 + ((k+1)/2));
	a.pb(k/2);

	cout << n << endl;
	for(int i=0; i<n; i++){
		if(i != n-1) printf("%lld ", a[i]);
		else printf("%lld\n", a[i]);
	}
	*/

	int n;
	cin >> n;
	vector<ll> a;
	for(int i=0; i<n; i++){
		ll t;
		cin >> t;
		a.pb(t);
	}

	//cout << "exact:" << solve(n, a) << endl;

	ll ans = 0;
	ll cnt = 0;
	while(check_max(n, a)){
		/*
		cnt++;
		if(cnt > 10000){
			break;
		}
		*/
		sort(a.begin(), a.end(), greater<ll>());

		ll mi = INF; 
		for(int i=0; i<n; i++){
			mi = min(mi, a[i]);
		}
		ll sub = max(mi - (n-1), 0ll);
		for(int i=0; i<n; i++){
			a[i] -= sub;
		}
		ans += (long long)sub*(long long)n;
		//cout << "phase1:" << sub << endl;
		//cout << "ans1:" << ans << endl;

		/*
		for(int i=0; i<n; i++){
			printf("%lld ", a[i]);
		}
		puts("");
		*/

		ll m2 = (a[0] - (n-1) + n - 1) / n;
		//cout << m1 << endl;
		//cout << m2 << endl;
		//sub = max(m1, m2);
		sub = m2;
		if(sub == 0) continue;

		a[0] -= (long long)n*sub;
		if(a[0] < 0){
			a[0] += n;
			sub--;
		}
		for(int i=1; i<n; i++){
			a[i] += sub;
		}
		ans += sub;
		/*
		for(int i=0; i<n; i++){
			printf("%lld ", a[i]);
		}
		puts("");
		*/
		//cout << ans << endl;
	}
	cout << ans << endl;

	/*
	for(int i=0; i<20; i++){
		for(int j=0; j<20; j++){
			for(int k=0; k<20; k++){
				vector<int> a;
				a.pb(i);
				a.pb(j);
				a.pb(k);

				printf("%3lld ", solve(3, a));
			}
			puts("");
		}
		puts("\n");
	}
	*/



	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   int n;
   cin >> n;

   int a = 1;
   while(n >= 2*a){
      a *= 2;
   }

   cout << a << endl;

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    int h, n; cin >> h >> n;
    int moves = 0;
    rep(i,n){
        cin >> moves;
        h -= moves;
    }
    if(h <= 0)cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = []
for _ in range(N):
    A.append(list(map(int, input().split())))

ans = 0

for n in range(N):
    count = 0
    for m in range(M):
        count += A[n][m] * B[m]
    if count + C > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
 
template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
 
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

 
int main() {
    int N; cin >> N;
    int F[100][10];
    rep(i,N) {
        rep(j,10) {
            cin >> F[i][j];
        }
    }
    int P[100][11];
    rep(i,N) {
        rep(j,11) {
            cin >> P[i][j];
        }
    }

    ll res = -INF;
    repr(bit,1,pow(2,10)) {
        int C[100];
        rep(i,N) C[i] = 0;

        rep(i,10) {
            if (bit & (1 << i)) {
                rep(k,N) C[k] += F[k][i];
            }
        }

        ll tmp = 0;
        rep(i,N) tmp += P[i][C[i]];
        res = max(res, tmp);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back

void solve()
{
    double a,b,h,m;cin>>a>>b>>h>>m;
    double ah=(30*(h+(m/60.0)));
    double am=(360*(h+(m/60.0)));
    double diff=abs(ah-am);
    double ans=sqrtl(a*a+b*b-2*a*b*cos(diff*pi/180));
    cout<<fixed<<setprecision(12)<<ans<<nl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 4244
#include <iostream>
#include <cstdio>
#define rep(i,n) for(int i = 0 ; i < n ; i++ )
using namespace std;
int block[10000];

bool judje(int n){
  for(int i = 0;i < n;i++)if(block[i] != i+1)return false;
  return true;
}
int main(){
  int n;
  while(scanf("%d",&n),n){
    int ans = 0;
    rep(i,n)cin >> block[i];
    while(1){

      if(judje(n))break;
      if(ans > 10000){
	ans = -1;
	break;
      }
      ans++;

      int at = 0;
      rep(i,n){
	block[i]--;
      }
      rep(i,n)if(block[i])block[at++] = block[i];
      block[at++] = n;
      n = at;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1252
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

class BIT
{
public:
    vector<int> bit;
    int M;

    BIT(int M):
        bit(vector<int>(M+1, 0)), M(M) {}

    int sum(int i) {
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, int x) {
        if (i > M) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};

int main(){
	int n,a[101010]={};
	cin>>n;
	FOR(i,0,n)cin>>a[i];
	int l=1,r=mod,m=(l+r)/2,idx=0;
	cerr<<"test"<<endl;
	while(l!=m){
		idx++;
		int b[101010]={};
		LL ans=0;
		BIT t(2*n+3);
		t.add(n+1,1);

		FOR(i,0,n){
			if(m<=a[i])b[i+1]=1;
			else b[i+1]=-1;
			b[i+1]+=b[i];
			ans+=t.sum(b[i+1]+n+1);
			t.add(b[i+1]+n+1,1);
		}
		//cerr<<idx<<" l:"<<l<<" r:"<<r<<" ans:"<<ans<<endl;
		if(ans>=(1LL*n*(n+1)/2+1)/2){
			l=m;
		}else{
			r=m;
		}
		m=(l+r)/2;
	}

	cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 1420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define SZ(x) (int)((x).size())
#define xx first
#define yy second
#define pii pair<int, int>

const int N = 1e6 + 1;

int a[N], f[N];
bool isp[N];
vector<int> prf[N];

int gcd(int x, int y) {
    while (x && y)
        swap(x %= y, y);
    return x + y;
}

void solve() {
    fill(isp, isp + N, 1);
    for (int i = 2; i < N; i++)
        if (isp[i])
            for (int j = i; j < N; j += i) {
                prf[j].push_back(i);
                isp[j] = 0;
            }

    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];

    int g = a[0];
    for (int i = 1; i < n; i++)
        g = gcd(g, a[i]);
    bool w = g == 1;
    
    bool D = 1;
    fill(f, f + N, 0);
    for (int i = n - 1; i >= 0; i--) {
        bool d = 0;
        for (int p : prf[a[i]])
            d |= f[p];
        for (int p : prf[a[i]])
            f[p]++;
        D &= !d;
    }
    cout << (D ? "pairwise coprime" : (w ? "setwise coprime" : "not coprime")) << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


Measured memory_bytes: 67752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll dp[2][100010];
int weight[110],value[110];

int main()
{

    int n,w; cin>>n>>w;

    for(int i=1;i<=n;i++)
        cin>>weight[i]>>value[i];

    for(int i=0;i<=w;i++)
        dp[0][i]=dp[1][i]=0;

    int flag=1;
    for(int i=1;i<=n;i++)

    {
        for(int j=1;j<=w;j++)
        {
            dp[flag][j]=dp[1-flag][j];
            if(weight[i]<=j)
                dp[flag][j]=max(dp[flag][j],dp[1-flag][j-weight[i]]+value[i]);
        }
        flag=1-flag;
    }
    cout<<dp[1-flag][w];
    return 0;
}



Measured memory_bytes: 1792
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.sqrt

fun main(args: Array<String>) {

    // IO Templates
    val br = BufferedReader(InputStreamReader(System.`in`))
    val out = PrintWriter(System.out)

    val n = br.readLine()!!.toInt()

    val points = mutableListOf<MyVector>()

    for (i in 1..n) {
        val (x, y) = br.readLine()!!.split(' ').map { it.toInt() }
        points.add(MyVector(x, y))
    }

    var ru = points.first()
    var lu = points.first()
    var ld = points.first()
    var rd = points.first()

    for (i in 1 until n) {
        val point = points[i]
        if ((point.x - ru.x) + (point.y - ru.y) > 0) ru = point
        if ((-point.x + lu.x) + (point.y - lu.y) > 0) lu = point
        if ((-point.x + ld.x) + (-point.y + ld.y) > 0) ld = point
        if ((point.x - rd.x) + (-point.y + rd.y) > 0) rd = point
    }

    out.println(
        max(
            abs(ru.x - ld.x) + abs(ru.y - ld.y),
            abs(lu.x - rd.x) + abs(lu.y - rd.y)
        )
    )

    out.flush()
}

data class MyVector(
    var x: Long,
    var y: Long
) {

    constructor(x: Int, y: Int) : this(x = x.toLong(), y = y.toLong())

    fun plus(x: Long, y: Long) {
        this.x += x
        this.y += y
    }

    operator fun plus(v: MyVector) {
        plus(v.x, v.y)
    }

    fun minus(x: Long, y: Long) {
        this.x -= x
        this.y -= y
    }

    operator fun minus(v: MyVector) {
        minus(v.x, v.y)
    }

    fun scalarTimes(m: Long) {
        x *= m
        y *= m
    }

    operator fun times(v: MyVector): Long = x * v.x + y * v.y

    fun squareMagnitude(): Long = this.times(this)

    fun magnitude(): Double = sqrt(squareMagnitude().toDouble())
}


Measured memory_bytes: 64760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//--<for debugging>
#define whatis(x) cout << #x << " is " << x<<" ";
#define whatisl(x) cout << #x << " is " << x<<"\n";
#define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
#define lline cout<<"\n";
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
    
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a <<" , ";
    err(++it, args...);
}
//--</for debugging> 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define testcase ll tt; cin >> tt; while(tt--)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
#define vll vector<ll>
#define pll pair<ll,ll>
#define sll set<ll>
#define pint pair<int,int>
const ll INF=1e9+7;
const ll MOD=1e9+7;
int main()
{
    boost vars
    cin>>a>>b>>h;
    cout<<a*h+((b-a)*(h))/2;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

def main():
    n,k = inpl()
    xary = []; yary = []
    a = []
    x_append = xary.append
    y_append = yary.append
    a_append = a.append
    for i in range(n):
        x,y = inpl()
        xary.append(x)
        yary.append(y)
        a.append((x,y))
    xary.sort(); yary.sort()
    res = INF
    for xi in range(n-1):
        for xj in range(xi+1,n):
            for yi in range(n-1):
                for yj in range(yi+1,n):
                    cnt = 0
                    l = xary[xi]; r = xary[xj]
                    d = yary[yi]; u = yary[yj]
                    # print(l,r,d,u)
                    for i in range(n):
                        x,y = a[i]
                        if l<=x<=r and d<=y<=u:
                            cnt += 1
                    if cnt >= k:
                        res = min(res, (r-l)*(u-d))
    print(res)
if __name__ == "__main__":
    main()


Measured memory_bytes: 73176
#include<stdio.h>
#include<math.h>

int main (){
  int n,v[10000],count=0,i,j,flag;

  scanf("%d",&n);
  
    for(i=0;i<n;i++){
      scanf("%d",&v[i]);

      flag=1;

      if(v[i]==2)flag=1;

      else if((v[i]<2)||(v[i]%2==0))flag=0;
	
      else{
	for(j=3;j<=sqrt(v[i]);j=j+2){
	  if(v[i]%j==0){
	    flag=0;
	    break;
	  }
	}
      }
	
      if(flag==1)
	count++;
    }

  printf("%d\n",count);
  
  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
  int n, t;
  vector<pair<int,int>> time;
  cin >> n >> t;
  int ans = 0;

  REP(i,n){
      int cn,tn;
      cin >> cn >> tn;
      time.pb(make_pair(cn, tn));
    }

    sort(time.begin(), time.end());
    REP(i, n){
        if(time[i].second <= t){
            cout << time[i].first << endl;
            return 0;
          }
      }
      cout << "TLE" << endl;
      return 0;

}

Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.{NumericRange, Queue}
import scala.collection.mutable
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    println(if (sc.nextInt + sc.nextInt >= sc.nextInt) ("Yes") else ("No"))
  }

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 27340
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

int main()
{
    char s[10],t[10];
    scanf("%s",s);
    scanf("%s",t);
    int a,b;
    scanf("%d %d",&a,&b);
    char u[10];
    scanf("%s",u);
    if(strcmp(s,u)==0)
        a--;
    else
        b--;
    printf("%d %d",a,b);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int a,b;
    string s;
    cin>>a>>s>>b;
    while(s!="?"){
        int ans;
        if(s=="+"){
            ans=a+b;
        }else if(s=="-"){
            ans=a-b;
        }else if(s=="*"){
            ans=a*b;
        }else{
            ans=a/b;
        }
        cout<<ans<<endl;
        cin>>a>>s>>b;
    } 
    return 0;
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1e9+7;
ll const maxn=4e5+5;
ll const inf=1e18;
ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll powm(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   ll n;
   cin>>n;
   vector<pair<ll,ll> >v;
   for(int i=0;i<n;i++){
    ll x;
    cin>>x;
    v.push_back({x,i+1});
   }
   sort(v.begin(),v.end());
   for(int i=0;i<v.size();i++){
    cout<<v[i].second<<" ";
   }
    return 0;
}


Measured memory_bytes: 2544
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int[] d = new int[n];
		if(s.charAt(0)=='E')d[0] = 1;
		for(int i=1; i<n; i++){
			if(s.charAt(i)=='E')d[i] += d[i-1] + 1;
			else d[i] = d[i-1];
		}
		int min = d[n-1] - d[0];
		for(int i=1; i<n; i++){
			min = Math.min(min, i-d[i-1]+d[n-1]-d[i]);
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 29400
#include <stdio.h>
int main (void){
    int L,A,B,C,D,i,koku,suu,ans;
    scanf("%d%d%d%d%d",&L,&A,&B,&C,&D);
    if(A%C!=0){
        koku=A/C+1;
    }
    else if(A%C==0){
        koku=A/C;
    }
    if(B%D!=0){
        suu=B/D+1;
    }
    else if(B%D==0){
        suu=B/D;
    }
    if(koku>suu){
        ans=L-koku;
    }
    else if(koku<=suu){
        ans=L-suu;
    }
    printf("%d\n",ans);
return 0;
}

Measured memory_bytes: 596