akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

int N, K; 
vector<vector<int>> graph;

int ans = 1;
void dfs(int p, int c){
  int k;
  if(p == -1) k = K-1;
  else k = K-2;

  for(auto v : graph[c]){
    if(v == p) continue;
    (ans *= k--) %= MOD;
  }
  for(auto v : graph[c]){
    if(v == p) continue;
    dfs(c, v);
  }
}

signed main() {
  cin >> N >> K;

  graph.resize(N);
  REP(i, N-1){
    int u, v;
    cin >> u >> v;
    u--; v--;
    graph[u].emplace_back(v);
    graph[v].emplace_back(u);
  }

  dfs(-1, 0);

  cout << (ans*K)%MOD << endl;

  return 0;
}

Measured memory_bytes: 9216
#include <iostream>
using namespace std;
 
int main()
{
   int a,b,c,x, y, z,n;
 
   // read in n 
   cin>>n;

   // for n set of data, read into 3 sides 
   
   for(int i=1;i<=n;i++)
   {
      cin>>a>>b>>c;          
      x=a*a; y=b*b; z=c*c;
      
      // check if they are triangle
      if(x+y==z||x+z==y||y+z==x)
          cout<<"YES"<<endl;
      else
          cout<<"NO"<<endl;
    }   
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
ll bigpow(ll base,ll pw,ll M)
{
	if(pw==0) return 1;
	if(pw%2==0)
	{
		ll ret=bigpow(base,pw/2,M);
		return ((ret%M)*(ret%M))%M;
	}
	else return ((base%M)*(bigpow(base,pw-1,M)))%M;

}
ll maxi(ll a,ll b)
{
    if(a>b)return a;
    return b;
}
ll mini(ll a,ll b)
{
    if(a<b)return a;
    return b;
}
ll abse(ll a)
{
    if(a<0)return -a;
    return a;
}
ll ceili(ll a,ll div)
{
    return (a+div-1)/div;
}
int h,w;
ll dp[1002][1002];
bool v[1002][1002];
ll f(int i,int j)
{
    if(i>h||j>w) return 0;
    if(v[i][j])return 0;
    if(dp[i][j]!=-1)return dp[i][j];
    if(i==h&&j==w) return 1;
    return dp[i][j]=(f(i+1,j)+f(i,j+1))%MOD;
}
int main(void)
{
   // io;
    int T=1,cas=0,i,j;
    char c;
    //cin>>T;
    while(T--)
    {
        cin>>h>>w;
        for(i=0;i<h;i++)
        {
            for(j=0;j<w;j++)
            {
                scanf(" %c",&c);
                //cout<<c<<endl;
                v[i][j]=(c=='#')?1:0;
            }
        }

       memset(dp,-1,sizeof dp);
        h--;w--;
        dp[h][w]=1;
    cout<<f(0,0);

    }
}



Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>A(N);
    vector<int>B(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
    int ans = 0;
    for(int i = N-1; i >= 0; i--) {
        if((ans+A[i])%B[i]) {
            ans+=B[i]-(A[i]+ans)%B[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4820
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
using namespace std;

int x, y, z, cnt;

int main(){
	while(~scanf("%d %d %d", &x, &y, &z)){
		cnt = 0;
		x -= z;
		while(x >= y + z){
			x = x - (y + z);
			cnt++;
		}
		printf("%d\n", cnt);
	}
	return 0;
}

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

int main(){
    using namespace std;
    unsigned long N, M;
    while((cin >> N >> M) && N && M){
        vector<unsigned long> h(N), w(M);
        for(auto& i : h)cin >> i;
        for(auto& i : w)cin >> i;
        h.push_back(0);
        w.push_back(0);
        partial_sum(h.rbegin(), h.rend(), h.rbegin());
        partial_sum(w.rbegin(), w.rend(), w.rbegin());
        vector<unsigned long> mm(h.front() + w.front() + 1);
        unsigned long offset{w.front()}, ans{0};
        for(const auto i : h)for(const auto j : w)ans += mm[i - j + offset]++;
        cout << ans << endl;
    }
}


Measured memory_bytes: 12060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> ac(n), pena(n);
    rep(i, m) {
        int p;
        string s;
        cin >> p >> s;
        --p;
        if (ac[p]) continue;
        if (s == "AC") {
            ac[p] = 1;
        } else {
            pena[p]++;
        }
    }
    int AC = 0, PENA = 0;
    rep(i, n) {
        AC += ac[i];
        if (ac[i]) PENA += pena[i];
    }
    cout << AC << " " << PENA << endl;
    return 0;
}

Measured memory_bytes: 3900
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

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

	map<int, int> city_to_pref;
	map<int, int> city_to_order;
	map<int, vector<pair<int, int>>> pref_to_cities;
	for (int i = 1; i <= M; ++i) {
		int P, Y;
		cin >> P >> Y;
		city_to_pref[i] = P;
		pref_to_cities[P].emplace_back(Y, i);
	}

	for (auto &e : pref_to_cities) {
		auto &cities = e.second;
		sort(cities.begin(), cities.end());
		for (auto i = 0u; i < cities.size(); ++i) {
			int year = cities[i].first;
			int city = cities[i].second;
			city_to_order[city] = i + 1;
		}
	}

	for (int i = 1; i <= M; ++i) {
		printf("%06d%06d\n", city_to_pref[i], city_to_order[i]);
	}
}


Measured memory_bytes: 21760
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int k, l;
	if(b < c){
		cout << 0 << endl;
		return 0; 
	}
	if(a < c) k = c;
	else k = a;
	if(b < d) l = b; 
	else l = d;
	if((l - k) <= 0){
		cout << 0 << endl;
		return 0;
	}
	cout << l - k << endl;
	return 0;
} 

Measured memory_bytes: 256
N, K = map(int, input().split())

if K == 1:
    print(0)
    exit(0)

if N >= K:
    N = N - (N // K) * K

minimum = N
previous_value = 1000000000000000001
while True:
    N = abs(N - K)

    if N < minimum:
        minimum = N

    if N >= previous_value:
        break

    previous_value = N

print(minimum)

Measured memory_bytes: 3064
#111b
N = int(input())

#ABC は第 N 回です． 100≤N≤999
#黒橋君は，初めて参加する ABC を第 x 回としたときに，xの十進法表記でのすべての桁の数字が同じであるようにしたいです．
#黒橋君が初めて参加する ABC としてふさわしいもののうち，最も早いものは第何回でしょうか？

for i in range(N,1000):
    if i%111==0:
        print(i)
        break

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

const int Nmax = 100010;
int N;
int A[Nmax], B[Nmax], C[Nmax];
int cnt[Nmax];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];
	for (int i = 0; i < N; i++) cin >> C[i];

	sort(A, A + N); 
	sort(B, B + N); 
	sort(C, C + N);
	
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ll a = lower_bound(A, A + N, B[i]) - A;
		ll b = N - (upper_bound(C, C + N, B[i]) - C);
		ans += a*b;
	}

	cout << ans << endl;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N, M, K;
string S, T;
vector<int> A;
int dp[111111] = {};
int a,b;
//=============================
void input()
{
    cin>>a>>b;
}
//=============================
void func() {}
//=============================
void solve()
{
    int ans;
    // ans+a + x = ans+b
    // b-a = index

    int ind = b-a;
    ind--;
    ans = (ind)*(ind+1)/2 - a;
    cout<<ans<<endl;

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
A, B, M = map(int, input().split(" "))
a = list(map(int,input().split(" ")))
b = list(map(int,input().split(" ")))
ans = min(a) + min(b)
for _ in range(M):
  x, y, c = map(int, input().split(" "))
  ans = min(a[x-1] + b[y-1] - c, ans)
print(ans)

Measured memory_bytes: 18736
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

using bs = bitset<17>;

int64_t count1(int64_t k) {
    int64_t ret = 0;
    while (k > 0) {
        if ((k & 1) > 0) {
            ++ret;
        }
        k /= 2;
    }

    return ret;
}

void exec(bs& x, const bs& y, vector<bool>& active, int64_t n) {
    int64_t pos = 0;
    while (pos < n && !(active[pos] && x[pos] != y[pos])) {
        ++pos;
    }

    assert(pos != n);

    active[pos] = false;
    int64_t next_pos = 0;
    while (next_pos < n && !active[next_pos]) {
        ++next_pos;
    }

    if (next_pos == n) {
        x.flip(pos);
        cout << " " << x.to_ullong();
        active[pos] = true;
        return;
    }

    auto z = x;
    z.flip(next_pos);
    exec(x, z, active, n);
    x.flip(pos);
    cout << " " << x.to_ullong();
    exec(x, y, active, n);

    active[pos] = true;
}

main(){
    int64_t n, a, b;
    cin >> n >> a >> b;

    auto ca1 = count1(a);
    auto cb1 = count1(b);
    if ((ca1 % 2) == (cb1 % 2)) {
        cout << "NO" << endl;
        return 0;
    }

    cout << "YES" << endl;

    bitset<17> x(a), y(b);
    vector<bool> active(n, true);
    cout << a;
    exec(x, y, active, n);
    cout << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main() {
  int n, k, ans=0, i;
  scanf("%d %d", &n, &k);
  char s[n+2];
  scanf("%s", s+1);
  s[0]='R'; s[n+1]='L';
  for (i=1; i<n+1; i++) {
    if (s[i]=='R') ans = (s[i+1]=='R') ? ans+1 : ans;
    else ans = (s[i-1]=='L') ? ans+1 : ans;
  }
  for (i=1; i<n+1; i++) {
    if (s[i]=='R' && s[i+1]=='L') {
      ans += 2;
      k--;
      if (k==0) break;
    }
  }
  if (i==n+1 || i==n) {
    if (s[1]=='R' && s[n]=='R') ans -= 2;
    else if (s[1]=='L' && s[n]=='R') ans--;
    else if (s[1]=='R' && s[n]=='L') ans--;
  }
  printf("%d\n", ans);
  return 0;
}


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

using namespace std;
#define INF 100001


int napZack01(  const vector<int> &val, 
                const vector<int> &weight, 
                vector<vector<bool> > &state_mat,
                vector<vector<int> > &sum_val){
    int N = (int)sum_val.size() - 1;
    int W = (int)sum_val[0].size() - 1;
    for(int i = 1;i <= N;i++){
        for(int j = 1;j <= W;j++){
            sum_val[i][j] = sum_val[i-1][j];
            if(j - weight[i] >= 0 && sum_val[i][j] < sum_val[i-1][j-weight[i]] + val[i]){
                sum_val[i][j] = sum_val[i-1][j-weight[i]]+ val[i];
                state_mat[i][j] = true;
            }
        }
    }
    return sum_val[N][W];
}

int main()
{
    int N,W;
    int v_temp,w_temp;
    scanf("%d %d",&N,&W);
    vector<int> val(N+1,0);
    vector<int> weight(N+1,0);
    vector<vector<int> > sum_val(N+1,vector<int>(W+1,0) );
    vector<vector<bool> > state_mat(N+1,vector<bool>(W+1,false) );
    
    for(int i = 0;i < N;i++){
        scanf("%d %d",&v_temp,&w_temp);
        val[i+1] = v_temp;
        weight[i+1] = w_temp;
    }
    int max_val = napZack01(val,weight,state_mat,sum_val);
    printf("%d\n",max_val);
    return 0;
}



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

using namespace std;

int main(){
	
	int a,b,c,k;
	
	cin >> a >> b >> c >> k;
	
	int m=max(a,max(b,c));

	if(m ==  a) a=a*pow(2,k);
	else if(m ==  b) b=b*pow(2,k);
	else c=c*pow(2,k);
	
	cout << a+b+c ;
	
	return 0;
}

Measured memory_bytes: 640
N = int(input())
S = input()

if (N % 2 == 0):
    c = int(N / 2)

    n = 0
    for x in range(c):
        if S[x] == S[x + c]:
            n += 1 

    if n == c:
        print('Yes')  
    else: 
        print('No')
        
else:
    print('No')


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
#include <list>
#include <deque>
#include <queue>
typedef long long ll;
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; }
const int MOD = 1000000007;
const ll INF = 1LL << 60;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) {return a / GCD(a, b) * b;}

int main()
{
	int x1, x2, x3, x4, x5;
	cin >> x1 >> x2 >> x3 >> x4 >> x5;
	if(x1 == 0) cout << 1 << endl;
	if(x2 == 0) cout << 2 << endl;
	if(x3 == 0) cout << 3 << endl;
	if(x4 == 0) cout << 4 << endl;
	if(x5 == 0) cout << 5 << endl;
}

Measured memory_bytes: 3164
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<time.h>
#include<list>
#include<iomanip>
#include<cstring>
#include<sstream>
#define h 100
#define ll  long long
#define pb push_back
using namespace std;
int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll int n, k, i, j;
  cin>>n>>k;
  vector<ll int>a(n);
  for(i=0;i<n;i++) 
  cin>>a[i];
  for(i=0,j=k;j<n;i++,j++) 
  {
  	if(a[j]>a[i]) cout<<"Yes"<<endl;
  	else cout<<"No"<<endl;
  } 
  return 0;
} 


Measured memory_bytes: 4780
#include <iostream> 
using namespace std;
int main() {
    long long int n, dp[90];
    dp[0] = 2; dp[1] = 1;
    cin >> n;
    for(int i = 2;i <= n;i++) {
        dp[i] = dp[i - 1] + dp[i - 2];
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 256
l = ["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"]

s = input()
print(l[l.index(s) + 1])




Measured memory_bytes: 2940
#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;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    vector<int> id[3];
    for(int i = 0; i < n; i++) {
        if(s[i] == 'R') {
            id[0].push_back(i);
        } else if(s[i] == 'G') {
            id[1].push_back(i);
        } else {
            id[2].push_back(i);
        }
    }
    ll ans = 0;
    vector<int> v = {0, 1, 2};
    do {
        // for(auto i : v) {
        //     cout << i << " ";
        // }
        // cout << endl;
        for(auto i : id[v[0]]) {
            for(auto j : id[v[1]]) {
                if(id[v[2]].empty()) {
                    continue;
                }
                if(i < j) {
                    // cout << id[v[2]].end() - id[v[2]].begin() << endl;
                    int cnt = id[v[2]].end() - upper_bound(ALL(id[v[2]]), j);
                    // cout << i << " " << j << " " << cnt << endl;
                    auto it = lower_bound(ALL(id[v[2]]), j + (j - i));
                    if(*it == 2 * j - i) {
                        cnt--;
                    }
                    ans += cnt;
                }
            }
        }
    } while(next_permutation(ALL(v)));
    cout << ans << endl;
}

Measured memory_bytes: 3660
#include "bits/stdc++.h"
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INF 100000000
typedef long long ll;

using namespace std;

int main()
{
    int n,a, b;
    int ans = 0;
    cin >> n >>a >> b;
    REP(i,n+1){
        int sum = 0;
        int number = i;
        while (true) {
            sum += number % 10;
            number /= 10;
            if (number == 0)break;
        }
        if (a <= sum && sum <= b) {
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(k,m,n) for(int(k)=(m);(k)<(n);(k)++)
#define REP(k,n) FOR((k),0,(n))
using namespace std;
typedef long long ll;
typedef vector<ll> VLL;
const int MOD=1000000007;

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

    long double A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    long double W, S;
    vector<long double> patW, patS;
    patW.reserve(F * F);
    patS.reserve(F * F);
    REP(i, 31){
        REP(j, 31){
            if(i == 0 && j == 0){
                continue;
            }
            W = 100 * A * i + 100 * B * j;
            if(W <= F){
                patW.push_back(W);
            }
        }
    }
    REP(i, F+1){
        REP(j, F+1){
            S = C * i + D * j;
            if(S <= F){
                patS.push_back(S);
            }
        }
    }

    long double N, max = -1.0;
    long double resA = 100.0, resB = 0.0;
    REP(i, patW.size()){
        REP(j, patS.size()){
            if(patS[j] * 100.0 <= patW[i] * E && patW[i] + patS[j] <= F){
                N = (100.0 * patS[j]) / (patW[i] + patS[j]);
                if ((100.0 * patS[j]) > max * (patW[i] + patS[j])){
                    max = N;
                    resA = patW[i] + patS[j];
                    resB = patS[j];
                }
            }
        }
    }

    cout << resA << " " << resB << endl;

    return 0;
}

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

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  int n;
  cin >> n;

  auto ans = 0;
  if (1 <= n && n < 10)
  {
    ans += n - 1 + 1;
    goto finished;
  }
  else
  {
    ans += 10 - 1;
  }
  if (10 <= n && n < 100)
  {
    goto finished;
  }
  if (100 <= n && n < 1000)
  {
    ans += n - 100 + 1;
    goto finished;
  }
  else
  {
    ans += 1000 - 100;
  }
  if (1000 <= n && n < 10000)
  {
    goto finished;
  }
  if (10000 <= n && n < 100000)
  {
    ans += n - 10000 + 1;
    goto finished;
  }
  else
  {
    ans += 100000 - 10000;
  }

finished:
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
using namespace std;
const int INF = numeric_limits<int>::max();

template<typename Monoid>
struct SegmentTree {
    using F = function<Monoid(Monoid, Monoid)>;
    const F f;
    const Monoid M1;
    int sz;
    vector<Monoid> dat;
    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
        sz = 1;
        while (sz < n) sz <<= 1;
        dat.assign(sz * 2, M1);
    }
    void set(int k, const Monoid &x) { dat[k + sz] = x; }
    void build() {
        for (int k = sz - 1; k > 0; k--) {
            dat[k] = f(dat[2 * k], dat[2 * k + 1]);
        }
    }
    void update(int k, const Monoid &x) {
        dat[k += sz] = x;
        while (k >>= 1) dat[k] = f(dat[2 * k], dat[2 * k + 1]);
    }
    Monoid get(int a, int b) {  // [a, b)
        Monoid L = M1, R = M1;
        for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if (a & 1) L = f(L, dat[a++]);
            if (b & 1) R = f(dat[--b], R);
        }
        return f(L, R);
    }
    Monoid operator[](const int &k) const { return dat[k + sz]; }
    friend ostream& operator<<(ostream& os, SegmentTree<Monoid> &seg) {
        for (int i = 0; i < seg.sz; i++) os << seg[i] << " ";
        return os;
    }
};

int main() {
    int n, q; cin >> n >> q;
    SegmentTree<int> seg(n, [](int a, int b) { return min(a, b); }, INF);
    while (q--) {
        int com; cin >> com;
        if (com == 0) {
            int k, x; cin >> k >> x;
            seg.update(k, x);
        } else {
            int l, r; cin >> l >> r; r++;
            cout << seg.get(l, r) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3900
/*
Author: Xjrjyy
LANG: C++
PROG: abc177_b.cpp
Mail: admin@xjrjyy.com
Blog: https://blog.xjrjyy.cn/
*/

#include <cstdio>
#include <cctype>
#include <string>
#include <vector>
#include <iostream>

#define MAXN ()

std::string s, t;
int ans = 0x7fffffff, tmp;

int main()
{
    std::cin >> s >> t;
    for (size_t i = 0, maxlen = s.size() - t.size() + 1; i < maxlen; ++i)
    {
    	tmp = 0;
    	for (size_t j = 0, maxlen2 = t.size(); j < maxlen2; ++j)
	    {
	    	if (s[i + j] != t[j]) ++tmp;
	    }
	    ans = std::min(ans, tmp);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
	string s;
	rep(i,3){
		cin >> s;
		cout << s[i];
	}
	cout << endl;
	//cin >> a >> b >> c;
	//cout << ans << endl;
	return 0;
}


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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))
//#define int long long

signed main(){
    int n; cin >> n;
    int d = 0;
    for(char c : to_string(n)){
        d += c - '0';
    }
    cout << (n % d == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import math
import sys

A, B = list(map(int, input().split()))
for i in range(1001):
  priceA = math.floor(i*1.08)
  priceB = math.floor(i*1.10)
  taxA = priceA - i 
  taxB = priceB - i 
  if taxA == A and taxB == B:
    print(i)
    sys.exit()
print("-1")  

Measured memory_bytes: 9004
#include <stdio.h>
#include <queue>
using namespace std;
int h, w, t, x, y, z, ans;
char s[22][22];
char p[22][22];
int g[22][22];
int dx[4] = { -1,0,0,1 };
int dy[4] = { 0,1,-1,0 };
queue<int>q;
int main() {
	scanf("%d%d", &h, &w);
	for (int i = 1; i <= h; i++) {
		scanf(" %s", &s[i][1]);
	}
	for (int i = 0; i < h + 2; i++) {
		s[i][0] = '#';
		s[i][w + 1] = '#';
	}
	for (int i = 0; i < w + 2; i++) {
		s[0][i] = '#';
		s[h + 1][i] = '#';
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			for (int k = 0; k <= h + 1; k++) {
				for (int l = 0; l <= w + 1; l++) {
					g[k][l] = 0;
					p[k][l] = s[k][l];
				}
			}
			if (s[i][j] == '.') {
				t = i * 100000 + j * 1000;
				q.push(t);
				while (q.empty() == 0) {
					t = q.front();
					q.pop();
					z = t % 1000;
					t /= 1000;
					y = t % 100;
					x = t / 100;
					if (p[x][y] == '.') {
						p[x][y] = '#';
						g[x][y] = z;
						for (int k = 0; k < 4; k++) {
							if (p[x + dx[k]][y + dy[k]] == '.') {
								t = (x + dx[k]) * 100000;
								t += (y + dy[k]) * 1000;
								t += z + 1;
								q.push(t);
							}
						}
					}
				}
			}
			for (int k = 0; k <= h + 1; k++) {
				for (int l = 0; l <= w + 1; l++) {
					if (g[k][l] > ans)ans = g[k][l];
				}
			}
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define rrng(obj) (obj).rbegin(), (obj).rend()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<pii>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,v.size())i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(v.size())o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
bool comp(pii a,pii b){
  return a.se<b.se;
}
//----------------------------------------------------------------

#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------
void Main(){
  ll a,b,c;
  cin>>a>>b>>c;
  ll cnt=0;
  while(true){
    if(a%2==0 and b%2==0 and c%2==0){
      cnt++;
      ll aa = a;
      ll bb = b;
      ll cc = c;
      a = (aa+bb)/2;
      b = (bb+cc)/2;
      c = (cc+aa)/2;
    }else{
      cout<<cnt<<endl;
      return;
    }
    if(a==b or b==c or c==a){
      cout<<-1<<endl;
      return;
    }
  }
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
//#include<Hatsune_Miku>
char s[40];
int l;
int main(){
    scanf("%s",s);l=strlen(s);
    for(int i=0;i<l;++i){
    	if(s[i]==',')s[i]=' ';
    }
    puts(s);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include "stdio.h"
using namespace std;

int func(int x,int y);
int func1(int x,int y);

int main()
{
	int x, y;
  scanf("%d%d",&x,&y );
  cout << func1(x,y) << " " <<func(x,y) << endl;
  return 0;
}

int func1(int x,int y)
{
  return x*y;
}

int func(int x,int y)
{
  return x*2 + y*2;
}




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

typedef long long ll;

class dice
{
    public:
        int men[6];
        void N();
        void S();
        void W();
        void E();
        void circle();
};

void dice::N()
{
    int tmp;
    tmp = men[0];
    men[0] = men[1];
    men[1] = men[5];
    men[5] = men[4];
    men[4] = tmp;
}

void dice::S()
{
    int tmp;
    tmp = men[0];
    men[0] = men[4];
    men[4] = men[5];
    men[5] = men[1];
    men[1] = tmp;
}
void dice::W()
{
    int tmp;
    tmp = men[0];
    men[0] = men[2];
    men[2] = men[5];
    men[5] = men[3];
    men[3] = tmp;
}

void dice::E()
{
    int tmp;
    tmp = men[0];
    men[0] = men[3];
    men[3] = men[5];
    men[5] = men[2];
    men[2] = tmp;
}

void dice::circle()
{
    int tmp;
    tmp = men[1];
    men[1] = men[2];
    men[2] = men[4];
    men[4] = men[3];
    men[3] = tmp;
}

int main()
{
    int i,j,k;
    dice dice_first;
    for(i = 0;i < 6;++i){
        cin >> dice_first.men[i];
    }
    int n;
    cin >> n;
    for(i = 0;i < n;++i){
        bool flag = false;
        dice dice_tmp = dice_first;
        int a,b;
        cin >> a >> b;
        for(j = 0;j < 4;++j){
            for(k = 0;k < 4;++k){
                if(dice_tmp.men[0] == a && dice_tmp.men[1] == b){
                    cout << dice_tmp.men[2] << endl;
                    flag = true;
                    break;
                }
                dice_tmp.circle();
            }
            if(flag){
                break;
            }
            dice_tmp.S();
        }
        if(flag){
            continue;
        }
        dice_tmp.W();
        for(k = 0;k < 4;++k){
            if(dice_tmp.men[0] == a && dice_tmp.men[1] == b){
                cout << dice_tmp.men[2] << endl;
                flag = true;
                break;
            }
            dice_tmp.circle();        
        }
        if(flag){
            continue;
        }
        dice_tmp.E();
        dice_tmp.E();
        for(k = 0;k < 4;++k){
            if(dice_tmp.men[0] == a && dice_tmp.men[1] == b){
                cout << dice_tmp.men[2] << endl;
                flag = true;
                break;
            }
            dice_tmp.circle();        
        }
    }
    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <string>

using namespace std;
int main() {
	//coffeeに似ている文字列
	string Resumble_coffee;
	
	cin >> Resumble_coffee;

	if (Resumble_coffee[2] == Resumble_coffee[3]) {
		if (Resumble_coffee[4] == Resumble_coffee[5]) {
			cout << "Yes\n";
		}
		else {
			cout << "No\n";
		}
	}
	else {
		cout << "No\n";
	}
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define E 0
#define W 1
#define N 2
#define S 3
#define X 4

int main(){
	
	int h,w;
	int **field;
	char *s;
	int x,y;
	int **log;


	while(scanf("%d %d",&h,&w)){
		if(h==0 && w==0){break;}

		x=0,y=0;
		log=(int**)malloc(sizeof(int*)*h);
		for(int i=0;i<h;i++){
			log[i]=(int*)malloc(sizeof(int)*w);
			for(int j=0;j<w;j++){
				log[i][j]=0;
			}
		}

		field=(int**)malloc(sizeof(int*)*h);
		s=(char*)malloc(sizeof(char)*w);
		for(int i=0;i<h;i++){
			field[i]=(int*)malloc(sizeof(int)*w);
			scanf("%s",s);
			for(int j=0;j<w;j++){
				if(s[j]=='>'){
					field[i][j]=E;
				}else if(s[j]=='<'){
					field[i][j]=W;
				}else if(s[j]=='^'){
					field[i][j]=N;
				}else if(s[j]=='v'){
					field[i][j]=S;
				}else{
					field[i][j]=X;
				}
			}
		}


		while(1){
			if(log[y][x]==1){
				printf("LOOP\n");
				break;
			}			
			log[y][x]=1;
			if(field[y][x]==E){
				x++;
			}else if(field[y][x]==W){
				x--;
			}else if(field[y][x]==N){
				y--;
			}else if(field[y][x]==S){
				y++;
			}else{
				printf("%d %d\n",x,y);
				break;
			}
		}

		for(int i=0;i<h;i++){
			free(field[i]);
		}free(field);
	}

	return 0;
}


Measured memory_bytes: 2040
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            long ans = 0;
            if (n == 2) { WriteLine(1); return; }
            for (int i = 1; i <= n; i++)
            {
                ans++;
                if (n - i <= n/2)
                {
                    WriteLine(ans-1);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 11092
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		String split[] = input.split("");
		int n = input.length();
		int in[] = new int[n];
		int count1 =0;
		int count2 =0;
		for(int i =0;i<n;i++) {
			in[i] = Integer.parseInt(split[i]);
		}

		for(int j =0;j<n;j++) {
			if(j%2==0) {
				if(in[j]==1) {
					count1++;
				}
			}else {
				if(in[j]==0) {
					count1++;
				}
			}
		}

		for(int k =0;k<n;k++) {
			if(k%2==0) {
				if(in[k]==0) {
					count2++;
				}
			}else {
				if(in[k]==1) {
					count2++;
				}
			}
		}
		if(count2>=count1) {
			System.out.println(count1);
		}else {
			System.out.println(count2);
		}
	}

}


Measured memory_bytes: 34284
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
}
	
int main(){
	init();
	ll N,T;cin>>N>>T;
	vector<ll>t(N);
	for(int i=0;i<N;i++)cin>>t[i];
	
	t.push_back(INF);
	ll ans=0;
	for(int i=0;i<N;i++){
		ans+=min(t[i+1]-t[i],T);
	}
	cout<<ans<<endl;
}


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


int selectionSort(int A[], int N) {
	int sw = 0;
	for (int i = 0;i < N;i++) {
		int minj = i;
		for (int j = i;j < N;j++) {
			if (A[j] < A[minj])
				minj = j;
		}
		if (i != minj) {
			swap(A[i], A[minj]);
			sw++;
		}
	}

	return sw;
}

int main() {
	int A[100];
	int N;
	cin >> N;
	for (int i = 0;i < N;i++) cin >> A[i];

	int sw=selectionSort(A, N);

	for (int i = 0;i < N;i++) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;

	return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int INF = 1e9 + 7;
int main()
{
	SPEED
	int n;
	cin >> n;
	int ht[n];
	for (int i = 0; i < n; ++i)
		cin >> ht[i];
	int dp[n];		//keeps track of cost
	for (int i = 1; i < n; ++i)
		dp[i] = INF;
	dp[0] = 0;
	for (int i = 0; i < n; ++i)
	{
		if (i+1<n)
			dp[i+1] = min(dp[i+1], dp[i] + abs(ht[i]-ht[i+1]));
		if (i+2<n)
			dp[i+2] = min(dp[i+2], dp[i] + abs(ht[i]-ht[i+2]));
	}
	cout << dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>

int main(void) {

	int n, m;
	int p;
	int ans[100001] = {};
	int wa[100001] = {};
	int ac = 0;
	int sum = 0;
	char s[3];

	scanf("%d %d", &n, &m);

	for (int i = 1; i <= m; i++) {
		scanf("%d %s", &p, s);
		if (strcmp(s, "WA") == 0 && ans[p] == 0)wa[p]++;
		if (strcmp(s, "AC") == 0 && ans[p] == 0) {
			ac++;
			ans[p] = 1;
			sum += wa[p];
		}
	}

	printf("%d %d\n", ac, sum);

	return 0;
}

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

using namespace std;

int main(){
    int N, A;
    cin >> N >> A;
    
    while(N >= 500){
        N -= 500;
    }
    if(A >= N){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

const int maxn = 200200;
struct DSU {
    int col[maxn];

    void init(int n) {
        iota(col, col + n, 0);
    }

    int get(int u) {
        if (col[u] == u)
            return u;
        return col[u] = get(col[u]);
    }

    bool join(int u, int v) {
        u = get(u), v = get(v);
        if (u == v)
            return false;
        col[u] = v;
        return true;
    }
} dsu;

int main() {
    #ifdef LOCAL
    assert(freopen("c.in", "r", stdin));
    #else
    #endif
    int n, m;
    cin >> n >> m;
    dsu.init(n + m);
    forn (i, n) {
        int k;
        cin >> k;
        forn (j, k) {
            int to;
            cin >> to;
            --to;
            dsu.join(i, to + n);
        }
    }
    forn (i, n - 1) {
        if (dsu.get(i) != dsu.get(i + 1)) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int A[N];
  vector<pair<int,int> > Ap;
  for(int i=0;i<N;i++){
    cin >> A[i];
    pair<int,int> Ain;
    Ain.first=A[i];
    Ain.second=i;
    Ap.push_back(Ain);
  }
  sort(Ap.begin(),Ap.end());
  for(vector<pair<int,int> >::iterator e=Ap.begin();e!=Ap.end();e++){
    cout << (e->second)+1 << " ";
  }
}


Measured memory_bytes: 2164
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
    int n,k;
    char s[20];
    scanf("%d",&n);
    scanf("%s",s);
    scanf("%d",&k);
    for(int i=0;s[i]!='\0';i++){
        if(s[i]!=s[k-1]){s[i]='*';}
    }
    printf("%s",s);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
 //     freopen("q.in","r",stdin);
 //     freopen("q.out","w",stdout);
      int n,m,v,p;
      cin>>n>>m>>v>>p;
      vector<int>arr(n);
      for(int i=0;i<n;i++)cin>>arr[i];
      sort(all(arr),greater<int>());
      int ans=p;
      int data=m-arr[p-1];
      for(int i=p;i<n&&arr[p-1]-arr[i]<=m;i++){
            int w=p+n-i-1;
            if(w>=v)ans++;
            else{
                  int q=v-w;
                  if(q*m<=data+(i-p+1)*arr[i])ans++;
            }
            data+=m-arr[i];
      }
      cout<<ans;
}


Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var N, A, B int
	fmt.Scan(&N, &A, &B)
	total := 0
	for i := range make([]int, N) {
		number := i + 1
		sum := visit(number/10) + number%10
		if sum >= A && sum <= B {
			total += number
		}
	}
	fmt.Println(total)
}

func visit(x int) int {
	if x == 0 {
		return 0
	}
	return visit(x/10) + x%10
}


Measured memory_bytes: 512
<?php
$N = intval(trim(fgets(STDIN)));
$A = array_map("intval", explode(" ", trim(fgets(STDIN))));
$B = array_map("intval", explode(" ", trim(fgets(STDIN))));
$dp = array_fill(0, 1<<$N, array_fill(0,51,PHP_INT_MAX));
$dp[0][0] = 0;
for($bit = 0, $NN = 1<<$N; $bit < $NN; ++$bit){
    $con = countBits($bit);
    $ords = [];
    $iter = $con;
    for($i = 0; $i < $N; ++$i)
        if(!($bit & (1<<$i)))
            $ords[$i] = $iter++;
    for($s = 0; $s <= 50; ++$s){
        if($dp[$bit][$s] == PHP_INT_MAX)continue;
        foreach($ords as $p0 => $p1){
            $ns = ($p0-$con) & 1 ? $B[$p0] : $A[$p0];
            if($ns >= $s){
                $nb = $bit | (1<<$p0);
                $dp[$nb][$ns] = min($dp[$nb][$ns], $dp[$bit][$s] + abs($p1 - $con));
            }
        }
    }
}
$min = min($dp[(1<<$N)-1]);
if($min == PHP_INT_MAX){
    echo -1;
}else{
    echo $min;
}

function countBits($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}

Measured memory_bytes: 682488
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        aa: [i64; n]
    }
    let mut aa = aa;
    aa.sort();
    aa.reverse();
    let mut sides = [0; 2];
    let mut side_index = 0;
    let mut prev = aa[0];
    for i in 1..n {
        if aa[i] == prev {
            sides[side_index] = aa[i];
            side_index += 1;
            prev = -1;
            if side_index == 2 { break };
        } else {
            prev = aa[i];
        }
    }
    println!("{}", sides[0] * sides[1]);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF (long long)1 << 61
#define MOD 10007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

typedef vector<llong> LV;

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

int main(){
    int N,M; cin >> N >> M;
    LV dp((1<<N),-1);LV a(M),bit(M);
    REP(i,M){
        int b; cin >> a[i] >> b;
        int c = 0;
        REP(j,b){
            int k;cin >> k;
            c = c | (1 << (k-1)); 
        }
        bit[i]=c;
    }
    dp[0]=0;
    REP(i,M){
        REP(j,1<<N){
            int to = j | bit[i];
            if(dp[j]>-1){
                if((a[i]+dp[j] < dp[to]) || dp[to]<0){
                    dp[to]=a[i]+dp[j];
                }
            }
        }
    }
    int ansj = (1<<N)-1;
    llong ans = (dp[ansj]<INF) ? dp[ansj] : -1;
    cout << ans << endl;


    return 0;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


int main() {
	string h;
	cin >> h;
	for (int i = 1; i < h.length(); ++i) {
		if (h[i] == h[i - 1]) {
			cout << i << " " << i + 1 << endl;
			return 0;
		}
	}

	for (int i = 2; i < h.length(); ++i) {
		if (h[i] == h[i - 2]) {
			cout << i - 1 << " " << i + 1 << endl;
			return 0;
		}
	}

	cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
from fractions import gcd


a, b, c, d = map(int, input().split(' '))

cd = c * d // gcd(c, d)

div_by_c = b // c - (a-1) // c
div_by_d = b // d - (a-1) // d
div_both = b // cd - (a-1) // cd

dividable = div_by_c + div_by_d - div_both
non_dividable = (b - a + 1) - dividable

print(non_dividable)


Measured memory_bytes: 5052
function main()
  
  A = parse(Int,readline())
  B = parse(Int,readline())
  C = parse(Int,readline())
  D = parse(Int,readline())
  E = parse(Int,readline())
  
  save = 0
  
  for i in [1,2,3,4,5,6,7,8,9,0],j in [A,B,C,D,E]

    if j % 10 == i
      save = j
      break
    end
    
  end

  ans = 0
  check = false
  
  for i in [A,B,C,D,E]
    
    if i == save && check == false
      check = true
      continue
    end
    
    ans += i
    
    if i % 10 != 0
      ans += (10-(i%10))
    end
    
  end
  
  ans += save
  
  println(ans)
  
end

main()

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

int main(){
  int n;
  cin>>n;
  vector<int> d(n);
  for(int i=0;i<n;i++) cin >> d.at(i);
  sort(d.begin(),d.end());
  int ans=d.at(d.size()/2)-d.at(d.size()/2-1);
  cout<<ans<<endl;
}


Measured memory_bytes: 640
use std::cmp::min;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let k:usize = read();
    let v:Vec<i64> = (0..n).map(|_| read()).collect();
    let mut dp = vec![std::i64::MAX; n+1];
    dp[0] = 0;
    for i in 0..n {
        for j in i+1..min(i+k+1, n) {
            dp[j] = min(dp[j], dp[i] + (v[i] - v[j]).abs());
        }
    }
    println!("{}", dp[n-1]);
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N,M;
  cin >> N >> M;
  int sum=0;
  vector<long long>dataX(N);
  vector<long long>dataY(N);
  for(int i=0; i<N; i++) {
    cin >> dataX.at(i) >> dataY.at(i);
  }
  for(int i=0; i<N; i++) {
    if((dataX.at(i) * dataX.at(i)) + (dataY.at(i) * dataY.at(i)) <= M * M) {
      sum++;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 6432
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    int n,k;
    cin>>n>>k;
    int ans=0;
    while(n>0){
        n/=k;
        ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n;
    while(cin>>n){
        ll ans=ceil(n/1.08);
        if(floor(ans*1.08)==n){
            cout<<ans<<endl;
        }
        else{
            cout<<":("<<endl;
        }
    }
  return 0;
}




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

int main(){
  char tid[60],buf[1030];
  int tidi,n,bi;

  cin >> n;

  for (int i=0;i<n;i++){
    for (int j=0;j<60;j++)tid[j]=0;
    bi=0;
    tidi=30;
    cin >> buf;
    tid[tidi]=buf[bi++];
    while (buf[bi]!='\0'){
      if (buf[bi]=='-')tidi++;
      else tidi--;
      bi+=2;
      tid[tidi]=buf[bi];
      bi++;
    }
    for (tidi=0;tid[tidi]=='\0';tidi++);
    cout << &tid[tidi]<< endl;
  }
  return 0;
}

Measured memory_bytes: 3004