akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_num(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int w, h, n;
int maxnum[101010];

int main() {
	cin >> w >> h >> n;
	REP(i, n) {
		int x, y;
		cin >> x >> y;
		if (maxnum[x] < y)maxnum[x] = y;
	}
	int ans = w - 1;
	int y = 0;
	for (int i = w - 2; i >= 0; i--) {
		if (y < maxnum[i + 1])y = maxnum[i + 1];
		if (ans > i + y)ans = i + y;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3464
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	if (a < b)cout << a;
	if (a > b)cout << b;
	if (a == b)cout << a;
	if ((a + b) - n <= 0)cout << " " << "0" << endl;
	if ((a + b) - n > 0)cout << " " << (a + b) - n << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 2e3 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, m, up[maxn][maxn], down[maxn][maxn], lft[maxn][maxn], rgt[maxn][maxn];
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		string s; cin >> s;
		for(int j = 1; j <= m; j++)
		{
			if(s[j - 1] == '.')
				up[i][j] = down[i][j] = i, lft[i][j] = rgt[i][j] = j;
		}
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
			if(lft[i][j - 1] != 0 && lft[i][j] != 0)
				lft[i][j] = lft[i][j - 1];
		for(int j = m; j >= 1; j--)
			if(rgt[i][j + 1] !=0 && rgt[i][j] != 0)
				rgt[i][j] = rgt[i][j + 1];
	}
	for(int j = 1; j <= m; j++)
	{
		for(int i = 1; i <= n; i++)
			if(up[i - 1][j] != 0 && up[i][j] != 0)
				up[i][j] = up[i - 1][j];
		for(int i = n; i >= 1; i--)
			if(down[i + 1][j] != 0 && down[i][j] != 0)
				down[i][j] = down[i + 1][j];
	}
	int ans = 1;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			if(up[i][j] != 0)
				ans = max(ans, down[i][j] - up[i][j] + rgt[i][j] - lft[i][j] + 1);
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 68352
/* ex4_3
  key_tree */

#include <stdio.h>
 // プロトタイプ宣言
int snow_depth(int west_height, int east_height);

int main(void){
    // プロトタイプ宣言
    int snow_depth(int west_height, int east_height);
    //埋もれていない高さを西側はwest_height、東側はeast_height
    int west_height, east_height;
    scanf("%d %d ",&west_height, &east_height);

    printf("%d\n", snow_depth(west_height, east_height));

    return 0;
}

int snow_depth(int west_height, int east_height){
    int dif, ans;
    dif = east_height - west_height;
    ans =(1 + dif) * dif /2 - east_height;

    return ans;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int A, B;
	cin >> A >> B;

	if ((A % 3 == 0)
		|| (B % 3 == 0)
		|| ((A + B) % 3 == 0)) cout << "Possible" << endl;
	else cout << "Impossible" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <math.h>
#include <unordered_map>
#include <numeric>
#include <sstream>
using namespace std;

vector< vector<int> > vvi;

int isEven(int a){
  return (a%2 == 0)? 1:0;
}

int main()
{
	int n=0;
	int ans,nm,rm,nt,rt;

	cin >> n;
	n++;
	vvi = vector< vector<int> >(n, vector<int>(3, 0));

	vvi[0][0] = 0;
	vvi[0][1] = 0;
	vvi[0][2] = 0;

	for (int i = 1; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			std::cin >> vvi[i][j];
		}
	}

	for (int i = 1; i < vvi.size(); i++) {
		if(0 == abs(((vvi[i-1][1] + vvi[i-1][2]) - (vvi[i][1] + vvi[i][2])))){
			if(0 == isEven(vvi[i][0] - vvi[i-1][0])){
				printf("No\n");
				return 0;
			}
		}

		ans = (vvi[i][0] - vvi[i-1][0]) - abs(((vvi[i-1][1] + vvi[i-1][2]) - (vvi[i][1] + vvi[i][2])));
		if(ans < 0){
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");

	return 0;
}


Measured memory_bytes: 5760
//
// Created by yuu on 2019-04-27.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>

using namespace std;

long long dp[2][100100]={};

long A[1000100];
int main(void){
    int N;
    cin>>N;
    for (int i = 0; i < N; ++i) {
        cin>>A[i];
    }

    for (int i = 0; i < N-1; ++i) {
            if(i==0){
                dp[0][i] = A[i] + A[i+1];
                dp[1][i] = -1 * A[i] + -1*A[i+1];
                continue;
            }

            dp[0][i] = max(dp[0][i-1] + A[i+1], dp[1][i-1] + A[i+1]);
            dp[1][i] = max(dp[0][i-1] + -1*A[i+1] + -1*2*A[i], dp[1][i-1] + -1*A[i+1] + 1*2*A[i]);
//            cout<<"-1*A[i] ="<<-1*A[i]<<endl;
    }

//    for (int j = 0; j < N; ++j) {
//        cout<<dp[0][j]<<",,"<<dp[1][j]<<endl;
//    }

    cout<<max(dp[0][N-2],dp[1][N-2])<<endl;


    return 0;
}

Measured memory_bytes: 4224
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    string s;cin>>s;
    cout<<(s[2]==s[3]&&s[4]==s[5]?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
import itertools
from collections import Counter
H, W = map(int, input().split())
cost = []
for i in range(10):
    cost.append(list(map(int, input().split())))
wall = []
for i in range(H):
    wall.append(list(map(int, input().split())))

for k in range(10):
    for i in range(10):
        for j in range(10):
            cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])

wc = Counter(itertools.chain(*wall))
del wc[-1]
del wc[1]

ans = 0
for k, v in wc.items():
    ans += cost[k][1] * v
print(ans)

Measured memory_bytes: 40284
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

char mp[11][11];

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

	ll h, w, k;cin >> h >> w >> k;
	REP(i, h)REP(j, w)cin >> mp[i][j];

	ll ans = 0;

	REP(y, (1<<h))REP(x, (1<<w)){
		ll cou = 0;
		REP(i, h)REP(j, w){
			if(mp[i][j] == '.')continue;
			if((y >> i) & 1)continue;
			if((x >> j) & 1)continue;
			cou++;
		}
		if(cou == k){
			ans++;
			//cout << bitset<8>(y) << " " << bitset<8>(x) << endl;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3648
from collections import deque

n, m = map(int, input().split())
eg = [[] for _ in range(n + 1)]

al = [0] * m
bl = [0] * m

for i in range(m):
    a, b = map(int, input().split())
    eg[a].append(b)
    eg[b].append(a)
    al[i], bl[i] = a, b

ans = 0
for i in range(m):
    x, y = al[i], bl[i]
    q = deque()
    q.append(1)
    seen = {1}
    while len(q) > 0:
        v = q.pop()
        for t in eg[v]:
            if t in seen:
                continue
            elif (v == x and t == y) or (v == y and t == x):
                continue
            q.append(t)
            seen.add(t)
    if len(seen) != n:
        ans += 1
print(ans)


Measured memory_bytes: 70960
import math

X = int(input())
x = int(round(math.sqrt(X), 0))
flag = 0

for i in range(100):
    for j in range(2, x):
        if X % j == 0:
            flag = 1
            break
    if flag == 0:
        break
    else:
        flag = 0
        X += 1
print(X)

Measured memory_bytes: 3064
n = int(input())
s = [1 if si == 'o' else 0 for si in list(input())]
t0 = [[1, 1], [1, 0], [0, 1], [0, 0]]
for ti in t0:
    flag = True
    for i in range(1, n - 1):
        if ti[i] * (1 - s[i]) or (1 - ti[i]) * s[i]:
            ti.append(1 - ti[i - 1])
        else:
            ti.append(ti[i - 1])
    for i in range(2):
        if ti[i - 1]:
            if (s[i - 1] and not ti[i - 2] == ti[i]) or (1 - s[i - 1] and ti[i - 2] == ti[i]):
                flag = False
        else:
            if (s[i - 1] and ti[i - 2] == ti[i]) or (1 - s[i - 1] and not ti[i - 2] == ti[i]):
                flag = False
    if flag:
        ans = ['S' if x else 'W' for x in ti]
        print(''.join(ans))
        exit()
print(-1)


Measured memory_bytes: 8084
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;

int num[52];

int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1,now=1;
    long long int a,a1,a2,a3,a4;
    //float f,g,h;
    //char now,pre;
    string s,s1;
    cin>>a1>>a2>>a3>>a4;
    if(a3>a2||a1>a4) cout<<0;
    else if(a1<a3)
    {
        if(a4>=a2) cout<<a2-a3;
        else cout<<a4-a3;
    }
    else if(a1>=a3)
    {
        if(a4>=a2) cout<<a2-a1;
        else cout<<a4-a1;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,f[100005];
int root(int x){
	if(x==f[x]){
		return x;
	}else{
		return f[x]=root(f[x]);
	}
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		f[i]=i;
	}
	int ans=n,t1,t2,t3;
	for(int i=1;i<=m;i++){
		cin>>t1>>t2>>t3;
		t1=root(t1);
		t2=root(t2);
		if(t1!=t2){
			ans--;
			f[t1]=t2;
		}
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>
// using namespace std;
int N;
int i = 2;
int num;
char buf[8], out[20];
char k;
s;
size_t ii;
int main()
{
  s = read(0, buf, 8);
  for (;;)

  {
    k = buf[ii++];
    if (k < '0')
      break;
    N = N * 10 + k - '0';
  }
  // printf("%d\n", N);
  long long ans = (long long)N * (N + 1) - 1;

  for (; i * i <= N; i++)
  {
    num = N / i;
    // ans += (long long)(num - i + 1) * i * (i + num) - i * i;
    ans += (long long)i * ((long long)num * num - i * i + num);
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 1584
N=int(input())
a=[]
for i in range(N):
    s=list(str(input()))
    a.append(tuple(sorted(s)))

a=sorted(a)

ans=[]
count=0
for i in range(1,N):
    if a[i]==a[i-1]:
        count +=1
    elif a[i]!=a[i-1] and count >=1:
        ans.append(count)
        count=0

if count>=1:
    ans.append(count)


ans2=0
for i in ans:
    ans2 += (i+1)*i//2

print(ans2)


Measured memory_bytes: 18024
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long double ld;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000 //14
#define N 1000000
#define L 100100

ll M = 512;
vector<vector<ll>> dp(M,vector<ll>(L,0));
vector<ll> val(N);
vector<ll> wei(N);

int main(){
    ll n, v, l, q; cin >> n;
    REP(i,n) cin >> val[i+1] >> wei[i+1];
    cin >> q;
    FOR(i,1,min(M-1,n)){
        REP(j,L){
            if (j-wei[i]>=0) dp[i][j]=max(dp[i/2][j],dp[i/2][j-wei[i]]+val[i]);
            else dp[i][j]=dp[i/2][j];
            if (j>=1) dp[i][j]=max(dp[i][j],dp[i][j-1]);
        }
    }
        REP(i,q){
        cin >> v >> l;
        if (v<M){
            cout << dp[v][l] << endl;
        }
        else{
            ll ans = 0;
            vector<ll> jelv;
            vector<ll> jelw;
            while(v>=M){
                jelv.pb(val[v]);
                jelw.pb(wei[v]);
                v/=2;
            }
            ll len = jelv.size();
            REP(j,(1ll<<len)){
                ll twei = 0; ll tval = 0;
                REP(p,len){
                    if ((j>>p)%2){
                        tval+=jelv[p];
                        twei+=jelw[p];
                        if (twei>l){
                            break;
                        }
                    }
                }
                if (twei<=l) ans = max(ans,dp[v][l-twei]+tval);
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 211544
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long int ll;
#define MOD (1000000007);
#define INF (2e9)


int check_p(int n){
	int p=2;
	while(p*p<=n){
		if(n%p==0){
			return 0;
		}
		p++;
	}
	return 1;
}

int main(void){
	ll n,a,b;
	cin>>n>>a>>b;
	ll x1,x2;
	cin>>x1;
	ll ans=0;
	for(int i=1;i<n;i++){
		cin>>x2;
		ans+=min((x2-x1)*a,b);
		x1=x2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>			//std::cout, std::cin
#include <string>			//std::string,std::to_string(C++11)
#include <vector>			//std::vector
#include <valarray>			//std::valarray
#include <algorithm>		//std::sort
#include <ctime>			//localtime_s
#include <cstdlib>			//abs
#include <cmath>			//abs,std::pow,sqrt,sin,cos,round,floor,ceil
#include <fstream>			//std::ifstream,std::ofstream
#include <iomanip>			//std::setprecision,std::setw,std::setfill
#include <random>			//std::random(C++11)
#include <numeric>			//std::accumulate
#include <functional>		//std::greater
#include <chrono>			//std::chrono(C++11)
#include <bitset>			//std::bitset
#include <queue>			//std::queue

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;

bool Judge_PrimeNumber(const int a) {

	if (a < 2) {	return false;	}
	if (a == 2) {	return true;	}
	if (a % 2 == 0) {	return false;	}

	for (int i = 3; i <= a / i; i += 2) {
		if (a%i == 0) {
			return false;
		}
	}
	return true;
}

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());
	//std::ofstream ofs("456.csv");
	//std::chrono::system_clock::time_point t_st = std::chrono::system_clock::now();

	int N = 0, ans = 0;
	std::cin >> N;

	for (int i = 0; i < N; i++) {
		int temp = 0;
		std::cin >> temp;
		if (Judge_PrimeNumber((temp))) {
			ans++;
		}
	}

	std::cout << ans << std::endl;

	//std::chrono::system_clock::time_point t_ed = std::chrono::system_clock::now();
	//std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(t_ed - t_st).count() << "ms" << std::endl;

}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

static const ll MOD = 998244353;

ll modPow(ll a, ll b) {
  ll res = 1;
  rep(i, b) {
    res = res * a % MOD;
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) {
    int dd;
    cin >> dd;
    if (i == 0 && dd != 0) {
      cout << 0 << endl;
      return 0;
    }
    if (i != 0 && dd == 0) {
      cout << 0 << endl;
      return 0;
    }
    d.at(i) = dd;
  }
  map<int, int> mp;
  for (int dd : d) {
    mp[dd]++;
  }
  ll res = 1;
  rep(i, mp.size()) {
    ll tmp = (ll) mp[i];
    // 途中が0なら成立しない
    if (tmp == 0) {
      cout << 0 << endl;
      return 0;
    }
    if (i == 0) {
      continue;
    }
    ll tmp2 = (ll) mp[i - 1];
    res = res * modPow(tmp2, tmp) % MOD;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 8140
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

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

    size_t N; cin >> N;

    vector<intmax_t> a(N);
    for (auto &ai: a) cin >> ai;

    if (N == 2) {
        return cout << a[0] << " " << a[1] << "\n", 0;
    }

    sort(a.rbegin(), a.rend());

    intmax_t target = a[0] / 2;
    intmax_t valid1 = *lower_bound(a.rbegin(), a.rend(), target);
    intmax_t valid2 = *(lower_bound(a.rbegin(), a.rend(), target) - 1);

    cout << a[0] << " " << (llabs(target - valid2) < llabs(target - valid1) ? valid2 : valid1) << "\n";

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  vector<uint64_t> v(n+1);
  v.at(0) =2;
  v.at(1)=1;
  for(int i=2;i<=n;i++){
    v.at(i)= v.at(i-1)+v.at(i-2);
  }
  
  cout << v.at(n) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
using ll = long long;

ll n,m,k;
string s,t;

int main() {
  cin >> n;
  ll m=100,ans=0;
  while(m<n) m=ll(1.01*m), ans++;
  cout << ans << endl;
}

Measured memory_bytes: 3612
def main():
    A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())
    
    ans = 0

    for i in range(A+1):
        for j in range(B+1):
            for h in range(C+1):
                if 500*i + 100*j + 50*h == X:
                    ans += 1    
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import java.util.*;

public class Main{

    public static List<Integer> P;
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        int even = N/2;
        int odd = N - even;

        System.out.println((double)odd / (double)N);

    }
}


Measured memory_bytes: 21972
n=int(input())
a=[int(input())  for i in range(n)]
ans=0
for i in range(n)[::-1]:
    if i<n-1:
        x=min(a[i+1],a[i])
        ans+=x
        a[i]-=x
    ans+=a[i]//2
    a[i]-=2*(a[i]//2)
print(ans) 

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

int main()
{
  int H1, M1, H2, M2, K ; 
  cin >> H1 >> M1 >> H2 >> M2 >> K ; 
  
  cout << ((H2*60+M2) - (H1*60+M1) - K) << "\n" ; 
  
	return 0 ; 
}


Measured memory_bytes: 3164
#include <iostream>

using namespace std;

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

	int a, pa;
	cin >> a;
	pa = a;
	int ans = 0;
	for (int i = 1; i < n; i++) {
		cin >> a;
		ans += (a - pa > t) ? t : a - pa;
		pa = a;
	}
	cout << ans + t << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

int main()
{
    int m, n;
    while(cin >> m >> n && m)
    {
        int ans = 0, t, a = 0;
        REP(m)
        {
            a = 0;
            rep(j,n){ cin >> t; a += t;}
            ans = max(ans, a);
        }

        cout << ans << endl;
    }
    
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 2e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

int n;
int a[MAX_N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    int wanted = 1;
    for (int i = 1; i <= n; i++) {
        if (a[i] == wanted) wanted++;
    }

    if (wanted == 1) {
        cout << -1;
    } else {
        cout << n - wanted + 1;
    }



    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
ll dp[100001];
int q(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int main(void) {
  int e,y;
  scanf("%d %d",&e,&y);
  if(e==0){
    if(y<1912){
      PRC('M');
      y-=1867;
    }else if(y<1926){
      PRC('T');
      y-=1911;
    }else if(y<1989){
      PRC('S');
      y-=1925;
    }else{
      PRC('H');
      y-=1988;
    }
  }else if(e==1){
    y+=1867;
  }else if(e==2){
    y+=1911;
  }else if(e==3){
    y+=1925;
  }else{
    y+=1988;
  }
  PRN(y);
  return 0;
}


Measured memory_bytes: 2076
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int N;
  cin>>N;
  string *s = new string[N];
  int *p = new int[N];
  ll int ans=0;
  vector<string> o(N);
  vector<char> cha(10);
  rep(i,0,N){
    cin>>s[i];
    rep(j,0,10) cha[j]=s[i][j];
    asort(cha);
    rep(j,0,10) s[i][j]=cha[j];
    o[i]=s[i];
  }
  asort(o);
  int i=0;
  int j=0;
//  rep(i,0,N) cout<<o[i]<<endl;
  while(1){
    while(1){
      j++;
      if(j==N) break;
      if(o[i]!=o[j]) break;
    }

    if(j!=N){
    rep(k,1,j-i){
      ans=ans+k;
 //   cout<<"k"<<k<<" ";
    }
    i=j;
     
      
    }
 //  cout<<ans<<" ";
    if(j==N){
      rep(k,1,j-i){
        ans=ans+k;   
 //          cout<<"k"<<k<<" ";
    }
      break;
    }
  }
  cout<<ans;
      
          
  
  
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	int a, count = 0;;

	cin >> a;

	if(a == 4 || a == 2 || a == 1){
		cout << '4';
		goto end;
	}

	while(a != 4){
		if (a % 2 == 0) {
			a = a / 2;
		}
		else {
			a = 3 * a + 1;
		}
		count += 1;
	}

	cout << count + 4;

	end:
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef vector<int>     Vi;
typedef vector<ll>      Vl;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD1    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define psb push_back
#define epb emplace_back
#define psf push_front
#define mkp make_pair
#define fst first
#define scd second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(bit, n)  for(int bit = 0; (bit) < (1 << (n)); ++(bit))
#define ifbit(bit, i)   if((bit) & (1 << (i)))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    vector<long double> v(n); rep(i, n) cin >> v[i];

    sort(all(v));
    for(int i = 1; i < n; ++i){
        v[i] = (v[i] + v[i-1]) / 2.0;
    }

    fcout(7) << v[n-1] << endl;

return 0;
}

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

using namespace std;
bool ip(string s) {
  for (int i = 0; i < s.length() / 2; ++i) {
    if (s[i] != s[s.length() - i - 1]) return false;
  }
  return true;
}
  
int main() {
  string s;
  cin >> s;
  int n(s.length());
  cout << (ip(s) && ip(s.substr(0, n / 2)) && ip(s.substr(n/2+1)) ? "Yes" : "No") << '\n';
  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
l=0
r=10000000000000
for i in range(m):
  a,b=map(int,input().split())
  l=max(l,a)
  r=min(r,b)
if r-l+1 >0:
  print(r-l+1)
else:
  print(0)

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

int main() {
  vector<int> V(5);
  for (int i = 0; i < 5; i++)
    cin >> V.at(i);
  sort(V.begin(),V.end());
  int K;
  cin >> K;
  if (V.at(4) - V.at(0) > K)
    cout << ":(" << endl;
  else 
    cout << "Yay!" << endl;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>

int main(){
  int n,a[101],i,j,kari,kazu=0;

  scanf("%d",&n);

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

  for(i=1;i<n;i++){
    for(j=n-1;j>i-1;j--){
      if(a[j]<a[j-1]){
	kari=a[j];
	a[j]=a[j-1];
	a[j-1]=kari;
	kazu++;
      }
      
    }
  }

  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n");
  
  printf("%d\n",kazu);
  return 0;
}
  



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

int main()
{
    string s1;
    cin>>s1;
    if(s1[0] == 'S'){
     cout<<"Cloudy";
    }else if(s1[0] == 'C'){
        cout<<"Rainy";
   }else if(s1[0] == 'R'){
     cout<<"Sunny";
   }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

ll ans=0, ansc=INF;
//あとiだけ入る.今のスコア. どこまで見たか
ll solve(int i, int j, int k, vector<pl> a){
	if(i==0){
		return j;
	}else if(i<0||k>=a.size()){
		return INF;
	}else if(ans<j){
		return INF;
	}else{
		ans = min(ans,min(solve(i,j,k+1,a),solve(i-a[k].fi,j+a[k].se,k+1,a)));
		return ans;
	}
}

int main(){
	ll n, ma, mb, temp1, temp2, temp3;
	cin>>n>>ma>>mb;
	//ans=0,INFになるならエラー
	vector<pl> a,b;
	vector<pl> total;
	vector<ll> c;
	rep(i,n){
		cin>>temp1>>temp2>>temp3;
		//数学的考察から式を単純に
		temp1=mb*temp1-ma*temp2;
		if(temp1>0){
			a.pb(mp(temp1,temp3));
		}else if(temp1<0){
			b.pb(mp(-1*temp1,temp3));
		}else{
			c.pb(temp3);
		}
	}
	if(c.size()!=0){
		sort(all(c));
		ansc=min(ansc,c[0]);
	}
	//2つに分けれた.
	if(a.size()==0||b.size()==0){
		if(ans==0){
			cout<<-1<<endl;
		}else{
			cout<<ans<<endl;
		}
	}else{
		ans=INF;
		sort(all(a));
		sort(all(b));
		if(a.size()<b.size()){
			//これで2^20まで落とせたのでループで全探索できる.
			total.pb(mp(0,0));
			rep(i,a.size()){
				temp1=total.size();
				rep(j,temp1){
					temp2=total[j].fi+a[i].fi;
					temp3=total[j].se+a[i].se;
					total.pb(mp(temp2,temp3));
				}
			}
			//全状態を列挙したらナップサック問題.
			FOR(i,1,total.size()){
				//total[i].fiになる詰め込み方.
				solve(total[i].fi,total[i].se,0,b);
			}
		}else{
			total.pb(mp(0,0));
			rep(i,b.size()){
				temp1=total.size();
				rep(j,temp1){
					temp2=total[j].fi+b[i].fi;
					temp3=total[j].se+b[i].se;
					total.pb(mp(temp2,temp3));
				}
			}
			FOR(i,1,total.size()){
				//total[i].fiになる詰め込み方.
				// dbg(ans);
				// dbg(solve(total[i].fi,total[i].se,0,a));
				solve(total[i].fi,total[i].se,0,a);
			}
		}
		ans=min(ansc,ans);
		if(ans==0||ans==INF){
			cout<<-1<<endl;
		}else{
			cout<<ans<<endl;
		}
	}
	return 0;
}














Measured memory_bytes: 8816
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int H = scan.nextInt();
    int A = scan.nextInt();
    int ans=0;
    for(;H>0;H-=A){
      ans+=1;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
import collections

n,m=map(int,input().split())
g=[[] for _ in range(n+1)]
cand1=set()
cand2=set()
for _ in range(m):
  a,b=map(int,input().split())
  g[a].append(b)
  cand1.add(a)
  cand2.add(b)
cand=cand1&cand2
ans=-1
for i in range(1,n+1):
  if i not in cand:
    continue
  else:
    q=collections.deque()
    q.append((i,[i]))
    checked=[0]*(n+1)
    while len(q)!=0:
      v,chain=q.popleft()
      if v==i and len(chain)!=1:
        ans=chain[:-1]
      for u in g[v]:
        if u not in cand:
          continue
        elif checked[u]==0:
          checked[u]=1
          q.append((u,chain+[u]))
    cand.discard(i)
if ans==-1:
  print(ans)
else:
  print(len(ans))
  for v in ans:
    print(v)

Measured memory_bytes: 3828
#include<stdio.h>
int main()
{
	int a,b,c,d;
	int m,n,i;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	m=d-b;n=c-a;
	for(i=0;i<m;i++)
	  printf("U");
	for(i=0;i<n;i++)
	  printf("R");
	for(i=0;i<m;i++)
	  printf("D");
	for(i=0;i<n;i++)
	  printf("L");
	int a1=a-1;
	int d1=d+1;
	printf("L");
	m=d1-b;n=c-a1;
	for(i=0;i<m;i++)
	  printf("U");
	for(i=0;i<n;i++)
	  printf("R");
	
	printf("D");
	printf("R");
	int c1=c+1;
	int b1=b-1;
	m=d-b1;n=c1-a;
	
	for(i=0;i<m;i++)
	  printf("D");
	for(i=0;i<n;i++)
	  printf("L");
	printf("U");
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	// 2点間を通る直線の傾きを求める
	public static double getA (double x1, double y1, double x2, double y2) {
		if (x1 == x2) return Double.MAX_VALUE;
		return (y1 - y2) / (x1 - x2);
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		for (int i = 0; i < n; i++) {
			double x1 = sc.nextDouble();
			double y1 = sc.nextDouble();
			double x2 = sc.nextDouble();
			double y2 = sc.nextDouble();
			double x3 = sc.nextDouble();
			double y3 = sc.nextDouble();
			double x4 = sc.nextDouble();
			double y4 = sc.nextDouble();
			double a = getA(x1,y1,x2,y2);
			double b = getA(x3,y3,x4,y4);
			System.out.println(Math.abs(a - b) < 0.0000001 ? "YES" : "NO");
		}

	}

}

Measured memory_bytes: 23228
#include<iostream>
using namespace std;
int main() {
	unsigned short int l[30] = { 0 };
	for (int i = 0; i < 28; i++){
		int a;
		cin >> a;
		l[a - 1] = 1;
	}
	for (int i = 0; i < 30; i++){
		if (l[i] == 0){
			cout << i + 1 << endl;
		}
	}
	char c;
	cin >> c;
}

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

int main () {
  int n;
  cin >> n;
  bool cards[4][14] = {};
  for (int i = 0; i < n; i++) {
    char mark;
    int num;
    cin >> mark >> num;
    if (mark == 'S') {
      cards[0][num] = true;
    }
    else if (mark == 'H') {
      cards[1][num] = true;
    }
    else if (mark == 'C') {
      cards[2][num] = true;
    }
    else {
      cards[3][num] = true;
    }
  }

  for (int i = 0; i <= 3; i++) {
    for (int j = 1; j <= 13; j++) {
      if (!cards[i][j]) {
        if (i == 0) {
          cout << "S ";
        }
        else if (i == 1) {
          cout << "H ";
        }
        else if (i == 2) {
          cout << "C ";
        }
        else if (i == 3) {
          cout << "D ";
        }
        cout << j << endl;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

#define INF (INT32_MAX)

using namespace std;

int match[9] = {2,5,5,4,5,6,3,7,6};

int main()
{
	int N,M;
	cin >> N >>  M;

	vector<int> input(M);
	for (int i = 0; i < M; i++){
		cin >> input[i];
	}
	sort(input.begin(),input.end(),greater<int>()); //降順ソート	

	//dynamic programing
	//dp[i]:ちょうどi本のマッチ棒を使って整数を作るときの最大桁数。
	std::vector<int> dp(N+1,-INF);
	dp[0] = 0;

	for (int i = 1; i <= N; i++){
		//i本のマッチ棒を使って条件を満たす整数の最上位の桁Ajを全探索
		for (int j = 0; j < M; j++){
			int a = input[j]-1;
			int n = match[a];
			if(i >= n){
				dp[i] = max( dp[i] , dp[i-n]+1 );
			}
		}
	}

	int d = dp[N];
	std::vector<int> ans;

	for (int i = 0; i < d; i++){
		for (int j = 0; j < M; j++){
			int a = input[j]-1;
			int n = match[a];

			if( N-n >=0 && dp[N-n] == dp[N] -1){
				ans.push_back(input[j]);
				N -= n;
				break;
			}
		}	
	}

	for (int i = 0; i < d; i++){
		cout << ans[i];
	}

	cout << "\n";

	return 0;
}

Measured memory_bytes: 384
n = int(input())
points = []
for i in range(n):
    x, y = list(map(int, input().split(' ')))
    points.append([x, y])

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

for x, y in points:
    print(x, y)


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

public class Main {

    public static class SegmentTree {

        int[] tree;
        int n, rawLen;

        public SegmentTree(int rawLen) {
            n = 1;
            while (n < rawLen) {
                n <<= 1;
            }
            tree = new int[2 * n - 1];
            this.rawLen = rawLen;
            Arrays.fill(tree, Integer.MAX_VALUE);
        }

        public int query(int left, int right) {
            return query(0, 0, n - 1, left, right);
        }

        public void update(int idx, int newValue) {
            idx += n - 1;
            tree[idx] = newValue;
            while (idx > 0) {
                idx = (idx - 1) / 2;
                tree[idx] = Math.min(tree[idx * 2 + 1], tree[idx * 2 + 2]);
            }
        }

        /**
         * Invariant: rangeBegin <= left <= right <= rangeEnd
         */
        private int query(int idx, int rangeBegin, int rangeEnd, int left, int right) {
            int leftResult = Integer.MAX_VALUE;
            int rightResult = Integer.MAX_VALUE;
            if (rangeBegin == rangeEnd) {
                return tree[idx];
            }
            if (left == rangeBegin && right == rangeEnd) {
                return tree[idx];
            }
            int rangeMid = (rangeBegin + rangeEnd) / 2;
            if (left <= rangeMid) {
                leftResult = query(idx * 2 + 1, rangeBegin, rangeMid, left, Math.min(right, rangeMid));
            }
            if (rangeMid + 1 <= right) {
                rightResult = query(idx * 2 + 2, rangeMid + 1, rangeEnd, Math.max(left, rangeMid + 1), right);
            }

            return Math.min(leftResult, rightResult);

        }

    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        SegmentTree segTree = new SegmentTree(n);
        int q = scanner.nextInt();
        while (q-- > 0) {
            int cmd = scanner.nextInt();
            int x = scanner.nextInt();
            int y = scanner.nextInt();

            if (cmd == 0) { // update
                segTree.update(x, y);
            } else { // query
                System.out.println(segTree.query(x, y));
            }
        }
    }
}

Measured memory_bytes: 103764
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	int X;
	cin >> X;
	if( X >= 30){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int h, a;
    cin >> h >> a;
    if (a >= h) cout << "1\n";
    else cout << ceil(1.0*h/a) << '\n';
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int W,H;
    cin>>W>>H;
    vector<pint>vec;
    rep(i,W){
        int p;
        cin>>p;
        vec.pb(pint(p,0));
    }
    rep(i,H){
        int q;
        cin>>q;
        vec.pb(pint(q,1));
    }
    sort(all(vec));
    H++;W++;
    int ans=0;
    rep(i,vec.size()){
        if(vec[i].se==0){
            ans+=H*vec[i].fi;
            W--;
        }
        else{
            ans+=W*vec[i].fi;
            H--;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main(){
    int N,A,B,C,D,ren=0,sharp=0,cant=0,over=0;
    string S;
    cin >> N >> A >> B >> C >> D;
    cin >> S;

    for(int i=A;i<=max(C,D);i++){
            if(S[i] == '#'){
                sharp++;
            }else{
                cant = max(cant,sharp);
                sharp = 0;
            }
        }
        cant = max(cant,sharp);

    if(C<D){

        if(1<cant){
            cout << "No";
        }else{
            cout << "Yes";
        }

    }else{
        for(int i=B-2;i<=D;i++){
            if(S[i] == '#'){
                over = max(ren,over);
                ren = 0;
            }else{
                ren++;
            }
        }
        over = max(ren,over);
        if(1<cant || over<3){
            cout << "No";
        }else{
            cout << "Yes";
        }
    }
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int h, w;
vector<string> s;

int dy[] = {0, 1};
int dx[] = {1, 0};

bool inside(int y, int x){
    if(y < 0 || h <= y){ return false;}
    if(x < 0 || w <= x){ return false;}
    return true;
}

int main(){
    cin >> h >> w;
    s = vector<string>(h);
    for(int i = 0; i < h; i++){
        cin >> s[i];
    }
    vector<vector<int>> c(h, vector<int>(w, INF));
    if(s[0][0] == '.'){
        c[0][0] = 0;
    }else{
        c[0][0] = 1;
    }
    queue<tuple<int, int, int>> q;
    q.emplace(0, 0, c[0][0]);
    while(!q.empty()){
        auto p = q.front();
        q.pop();
        int t, u, v;
        tie(t, u, v) = p;
        if(c[t][u] < v){
            continue;
        }
        for(int i = 0; i < 2; i++){
            int dh = dy[i], dw = dx[i];
            int ny = t + dh, nx = u + dw;
            if(inside(ny, nx)){
                int co = ((s[t][u] != s[ny][nx] && s[t][u] == '.')? 1 : 0);
                if(c[t][u] + co < c[ny][nx]){
                    c[ny][nx] = c[t][u] + co;
                    q.emplace(ny, nx, c[ny][nx]);
                }
            }
        }
    }
    cout << c[h - 1][w - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
#include <tuple>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> score;
  map<int, int> ads;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    --a[i];
  }
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    score[i] = x;
  }
  for (int i = 1; i < n; ++i) {
    int x;
    cin >> x;
    ads[i] = x;
  }
  int res = 0;
  for (int i = 0; i < n; ++i) {
    res += score[a[i]];
    if (i > 0 && a[i] == a[i - 1] + 1) {
      res += ads[a[i]];
    }
  }
  cout << res << '\n';
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

int main() {
  int H, N; cin >> H >> N;

  int sum = 0;
  rep( i, 0, N ) {
    int A;
    cin >> A;
    sum += A;
  }
  cout << ( H <= sum ? "Yes" : "No" ) << endl;
}


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

using namespace std;

const int mod = 1e9 + 7;

void add (int& a, int b) {
  a += b;
  if (a >= mod)
    a -= mod;
}

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int N, x;
  cin >> N;
  vector < int > adj(N);
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < N; ++j) {
      cin >> x;
      adj[i] = (adj[i] << 1) + x;
    }
  vector < int > dp(1 << N);
  dp[0] = 1;
  for (int mask = 0; mask < (1 << N) - 1; ++mask) {
    int a = __builtin_popcount(mask);
    for (int b = 0; b < N; ++b)
      if ((adj[a] & (1 << b)) && !(mask & (1 << b))) {
        int aux = mask ^ (1 << b);
        add (dp[aux], dp[mask]);
      }
  }
  cout << dp[(1 << N) - 1];
}


Measured memory_bytes: 11308
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define mp make_pair
#define inf 200000000000000l
#define swap(a,b) {a=a^b;b=a^b;a=a^b;}
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define debug(x) cout<<#x<<": "<<x<<endl;
#define mod 1000000007
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)

bool isPrime(ll n){
    if(n<2) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i == 0){
            return false;
        }
    }
    return true;
}
ll power[101];
int main()
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    ll t = 1;
    // cin>>t;
    while(t--){
        ll n; cin>>n;
        for(ll i=0;i<=n;i++){
            if(isPrime(i)){
                ll temp = i;
                while(n/temp > 0){
                    power[i] += (n/temp);
                    temp*=i;
                }
            }
            else{
                power[i] = 0;
            }
        }
        ll ans = 0;
        ll a74=0,a24=0, a14=0, a4=0, a2=0;
        rep(i,n+1){
            if(power[i] >= 74){
                a74++;
            }
            if(power[i]>=24){
                a24++;
            }
            if(power[i]>=14){
                a14++;
            }
            if(power[i]>=4){
                a4++;
            }
            if(power[i]>=2){
                a2++;
            }
        }
        ans += a24*(a2-1);
        ans += a14*(a4-1);
        if(a4>=2){
            ans += ((a4*(a4-1))/2)*(a2-2);
        }
        ans += a74;
        cout<<ans<<"\n";
    }
}


Measured memory_bytes: 256