akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

struct unionfind {
    vector<int> par;
    unionfind(int n)
        : par(n, -1) {}

    int find(int x) {
        if (par[x] < 0)
            return x;
        else
            return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (par[x] > par[y])
            swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }

    int size(int x) {
        return -par[find(x)];
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<int>> x(n + 1), y(n + 1);
    unionfind ff(n + 1);
    rep(i, 0, m) {
        int a, b;
        cin >> a >> b;
        ff.unite(a, b);
        x[a].emplace_back(b);
        x[b].emplace_back(a);
    }
    rep(i, 0, k) {
        int c, d;
        cin >> c >> d;
        y[c].emplace_back(d);
        y[d].emplace_back(c);
    }
    vector<int> ans(n + 1);
    rep(i, 1, n + 1) {
        int mx = ff.size(i) - x[i].size() - 1;
        sort(x[i].begin(), x[i].end());
        for (int e : y[i]) {
            if (ff.find(e) == ff.find(i) && !binary_search(x[i].begin(), x[i].end(), e)) mx--;
        }
        ans[i] = mx;
    }
    rep(i, 1, n + 1) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 12664
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))

S = input()
L_ = [[] for _ in range(26)]

for i, s in enumerate(S):
    L_[ord(s)-97].append(i+1)

for L in L_:
    for i in range(len(L)-1):
        if L[i+1] - L[i] <= 2:
            print(*L[i:i+2])
            break
    else:
        continue
    break
else:
    print(-1, -1)

Measured memory_bytes: 7412
from copy import deepcopy

N, K = map(int, input().split())
V = tuple(map(int, input().split()))
max_score = -1000000000
for i in range(K+1):
    for j in range(K - i + 1):
        if i + j > N:
            continue
        # 左からi個取る
        hand = list(V[:i])
        # 右からj個取る
        hand.extend(V[N-j:])
        # 最大(K - i - j)個戻せる
        # print(i, j, hand)
        score = sum(hand)
        counter = 0
        for h in sorted(hand):
            counter += 1
            if K - i - j - counter < 0:
                break
            if h < 0:
                score -= h
        if max_score < score:
            max_score = score
print(max_score)

Measured memory_bytes: 3572
#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 ll long long
#define INF 999999999
using namespace std;

int main() {
  ll N;
  ll sum = 0;
  std::cin >> N;
  for (ll i = 1; i < N+1; i++) {
    if (i%3 == 0 || i%5 == 0) {
      continue;
    }
    else{
      sum += i;
    }
  }
  std::cout << sum << '\n';
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

ll n,x,y;
vi adj[N];
ll dp[N][2];
void dfs(ll nod,ll par)
{
    ll b=1,w=1;
    for(auto u:adj[nod])
    {
        if(u!=par)
        {
            dfs(u,nod);
            b=(b*dp[u][0])%hell;
            w=(w*((dp[u][0]+dp[u][1])%hell))%hell;
        }
    }
    dp[nod][0]=w;
    dp[nod][1]=b;
}
void solve()
{
    cin>>n;
    rep(i,0,n-1)
    {
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    dfs(1,0);
    cout<<(dp[1][0]+dp[1][1])%hell<<endl;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

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

using namespace std;
typedef long long int lld;
#define rep(i,a,b) for(int i=a;i<b;i++)
/*bool solve(vector<lld> V){
  rep(i,0,V.size())cout<<V[i]<<" ";
  cout<<endl;
  if(V.size()==1)return true;
  int n=V.size();
  vector<lld> V1,V2;
  int mid=V[n/2];
  if(mid==V[0]){
    return false;
  }
  
  rep(i,0,n/2){
    V1.push_back(V[i]);
  }
  rep(i,n/2,n){
    V2.push_back(V[i]);
  }
  return (solve(V1)&solve(V2));
}*/
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  vector<lld> V;
  V.resize((1<<n));
  rep(i,0,(1<<n)){
    cin>>V[i];
  }
  sort(V.begin(),V.end());
  reverse(V.begin(),V.end());
  /*if(solve(V)){
    cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;*/
  bool used[(1<<n)];
  bool next_round[(1<<n)];
  rep(i,0,(1<<n))used[i]=false;
  used[0]=true;
  
  int ptr=0;
  int parent[(1<<n)];
  rep(r,0,n){
    ptr=0;
  rep(i,0,(1<<n))next_round[i]=used[i];
  rep(i,0,(1<<n)){
    if(used[i]){
      while(ptr<(1<<n) && (used[ptr] || V[ptr]>=V[i])){
	ptr++;
      }
      if(ptr==(1<<n)){
	cout<<"No"<<endl;
	return 0;
      }else{
	next_round[ptr]=true;
	//cout<<i<<" "<<ptr<<endl;
	parent[ptr]=i;
	ptr++;
      }
    }
  }
  rep(i,0,(1<<n)){
    used[i]=next_round[i];
    //cout<<used[i]<<" ";
  }//cout<<endl;
  }
  cout<<"Yes"<<endl;
  /*rep(i,0,(1<<n)){
    cout<<V[i]<<" ";
  }cout<<endl;
  rep(i,0,(1<<n)){
    cout<<parent[i]<<" ";
  }cout<<endl;*/
  return 0;
}

Measured memory_bytes: 3840
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = LLONG_MAX, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
    cin >> K;
    cout << 50 << endl;
    //数列全体に対して、一回ずつ減算を行うと全体で-1となる。
    //各数列に対して減算を行い値を等しくするとして操作を考える。
    
    //減算処理を多くする数列
    rep(i, K%50){
        cout << K/50+100-K%50 << " ";
    }
    //逆
    rep(i, 50 - K%50){
        cout << K/50+49-K%50 << " ";
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std ; 

typedef long long ll ; 

ll a[2222] ;
ll st[4444][12] ; 

void initTable() {
    for(int i = 0 ; i != 2048 ; i++)
        st[i][0] = a[i] ; 
    for(int step = 1 ; step <= 11 ; step++)
        for(int i = 0 ; i != 2048 ; i++)
            st[i][step] = min(st[i][step-1], st[i+(1<<(step-1))][step-1]) ; 
}

ll query(int l, int r) {
    r++ ; 
    int d = r-l ; 
    int s = 0 ; 
    while((1<<(s+1)) <= d)
        s++ ; 
    return min(st[l][s], st[r-(1<<s)][s]) ; 
}

int main()
{
    int N ;
    ll x ; 
    scanf("%d%lld", &N, &x) ; 
    memset(a, 0x7F, sizeof(a)) ; 
    for(int i = 0 ; i != N ; i++)
        scanf("%lld", a+i) ; 
    initTable() ; 
    ll ans = 2e+18 ; 
    for(int spell = 0 ; spell != N ; spell++) {
        ll now = spell*x ; 
        for(int i = 0 ; i != N ; i++) {
            if(i >= spell)
                now += query(i-spell, i) ;
            else
                now += min(query(0, i), query((i-spell+N)%N, (-1+N)%N)) ; 
        }
        ans = min(ans, now) ; 
    }
    printf("%lld\n", ans) ; 
    return 0 ; 
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int M, D;
  cin >> M >> D;
  int ans = 0;
  auto judge = [](int m, int d){
    int d1 = d%10;
    int d10 = d/10;
    return d1>=2 && d10>=2 && d1*d10==m;
  };
  for(int i=1; i<=M; i++){
    for(int j=1; j<=D; j++){
      if(judge(i, j)) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3576
n,m = map(int,input().split())
ans_list = [False for _ in range(n+1)]
pe_list = [0 for _ in range(n+1)]
ac=0
pe=0
for _ in range(m):
    p,s = input().split()
    if not ans_list[int(p)]:
        if s == 'AC':
            ac+=1
            pe+=pe_list[int(p)]
            ans_list[int(p)]=True
        else:
            pe_list[int(p)]+=1
            
print(ac,pe)

Measured memory_bytes: 10764
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int N, K;
    cin >> N >> K;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    int sum = 0;
    FOR(i, 0, N){
        int x = A[i];
        int move_len = min(x, abs(x - K));
        sum += 2 * move_len;
    }

    p(sum);
    
    return 0;
}

Measured memory_bytes: 256
class Dice(object):

    def __init__(self, n):
        self.n = n
        self.pos = ['12431', '03520', '01540', '04510', '02530', '13421']

    def face(self, x1, x2):
        s = '{0}{1}'.format(self.n.index(x1),self.n.index(x2))
        for i, p in enumerate(self.pos):
            if s in p:
                return self.n[i]
dice = Dice([int(i) for i in input().split()])
n = int(input())
for _ in range(n):
    x1, x2 = map(int, input().split())
    print(dice.face(x1, x2))




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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Vertex {
    vector<pll> node;
};

Vertex V[55];
pll T[25];
vector<ll> E[25];
bool U[25];
ll S[25];

int main() {
    ll N;
    cin >> N;
    REP(i, N - 1) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        V[a].node.push_back(pll(b, i));
        V[b].node.push_back(pll(a, i));
    }
    ll M;
    cin >> M;
    REP(i, M) {
        cin >> T[i].first >> T[i].second;
        T[i].first--;
        T[i].second--;
        U[i] = true;
    }

    REP(i, M) {
        ll s = T[i].first;
        ll g = T[i].second;
        vector<ll> C(N, INF);
        C[s] = 0;
        queue<pll> q;
        q.push(pll(s, 0));
        while (!q.empty()) {
            pll t = q.front();
            q.pop();
            ll cost = t.second + 1;
            REP(j, V[t.first].node.size()) {
                ll n = V[t.first].node[j].first;
                if (C[n] <= cost)
                    continue;
                C[n] = cost;
                q.push(pll(n, cost));
            }
        }
        while (g != s) {
            REP(j, V[g].node.size()) {
                pll n = V[g].node[j];
                if (C[n.first] == C[g] - 1) {
                    g = n.first;
                    E[i].push_back(n.second);
                    break;
                }
            }
        }
    }

    //! 被覆区間の解消
    REP(i, M) {
        vector<bool> u(N - 1, false);
        REP(j, E[i].size()) {
            u[E[i][j]] = true;
        }
        REP(j, M) {
            if (i == j)
                continue;
            if (!U[j])
                continue;
            bool cover = true;
            REP(k, E[j].size()) {
                cover &= u[E[j][k]];
            }
            if (cover) {
                U[i] = false;
                break;
            }
        }
    }

    vector<ll> e;
    REP(i, M) {
        if (U[i])
            e.push_back(i);
    }

    REP(i, pow(2, e.size())) {
        ll m = 0;
        vector<bool> u(N - 1, true);
        REP(j, e.size()) {
            if ((i >> j) & 1) {
                m++;
                REP(k, E[e[j]].size()) {
                    u[E[e[j]][k]] = false;
                }
            }
        }
        ll t = 0;
        REP(j, N - 1) {
            if (u[j])
                t++;
        }
        S[m] += pow(2LL, t);
    }

    ll ans = 0;
    REP(i, e.size() + 1) {
        ll s = S[i];
        if (i % 2 == 1)
            s *= -1LL;
        ans += s;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long a = scan.nextLong();
        long b = scan.nextLong();

        long diff = b-a;

        if(diff >= 2019){
            System.out.println(0);
        }else{
            long min = Integer.MAX_VALUE;

            HashMap<Long,Integer> ab = new HashMap();
            for (long i = a; i <= b; i++) {
                ab.putIfAbsent(i % 2019,1);
            }

            ArrayList<Long> list = new ArrayList<>(ab.keySet());
            for (int i = 0; i < list.size(); i++) {
                for (int j = i + 1; j < list.size(); j++) {
                    min = Math.min((list.get(i) * list.get(j)) % 2019, min);
                }
            }

            System.out.println(min);
        }
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
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 INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    vector<int> A(n);
    rep(i, n) cin >> A[i];
    sort(all(A));
    reverse(all(A));
    ll ans = 0;
    rep(i, n) {
        if(i == 0) continue;
        ans += A[i / 2];
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 4000
// I look at my watch
// it say nine twenty-five
// And I think oh God
// I'm still alive
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(int i = int(a); i < int(b); ++i)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
typedef long double ld;




int main(){	
	int n,k;cin>>n>>k;
	string s;cin>>s;
	s[k-1]=s[k-1]-'A'+'a';
	cout<<s<<endl;
	return 0;
}


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

int main(){
  int N;
  cin>>N;
  
  if(N%4 == 3){
    vector<int> a{},b{};
    for(int i=1;i<(N+1)/4+1;i++){
      a.push_back(i);
      a.push_back(N-i);
    }
    for(int i=(N+1)/4+1;i<N-(N+1)/4;i++){
      b.push_back(i);
    }
    b.push_back(N);
    
    int al=a.size(),bl=b.size();
    cout<<al*bl<<endl;
    for(int i=0;i<al;i++){
      for(int j=0;j<bl;j++){
        cout << a.at(i) << " " << b.at(j) << endl;
      }
    }
  }
  
  if(N%4 == 0){
    vector<int> a{},b{};
    for(int i=1;i<N/4+1;i++){
      a.push_back(i);
      a.push_back(N+1-i);
    }
    for(int i=N/4+1;i<N/4*3+1;i++){
      b.push_back(i);
    }
    
    int al=a.size(),bl=b.size();
    cout<<al*bl<<endl;
    for(int i=0;i<al;i++){
      for(int j=0;j<bl;j++){
        cout << a.at(i) << " " << b.at(j) << endl;
      }
    }
  }
  
  
  if(N%4 == 2){
    cout<<N*(N-2)/2<<endl;
    for(int i=1;i<N/2;i++){
      for(int j=i+1;j<N/2+1;j++){
        cout << i << " " << j << endl;
        cout << i << " " << N+1-j << endl;
        cout << N+1-i << " " << j << endl;
        cout << N+1-i << " " << N+1-j << endl;
      }
    }
  }
  if(N%4 == 1){
    cout<<(N-1)*(N-1)/2<<endl;
    for(int i=1;i<N;i++){
      cout << N << " " << i << endl;
    }
    for(int i=1;i<N/2;i++){
      for(int j=i+1;j<N/2+1;j++){
        cout << i << " " << j << endl;
        cout << i << " " << N-j << endl;
        cout << N-i << " " << j << endl;
        cout << N-i << " " << N-j << endl;
      }
    }
  }
  
}
    

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;

int main()
{
   ll N, X, M;
   cin >> N >> X >> M;
   vector<ll> val(M + 1);
   vector<ll> sum(M + 1);
   vector<ll> ind(M, -1);
   sum[0] = 0;
   sum[1] = X;
   val[0] = X;
   ind[X] = 0;
   int loopStart = -1;
   int loopEnd = -1;
   for (int i = 1; i < M + 1; i++)
   {
      val[i] = (val[i - 1] * val[i - 1]) % M;
      //cout << i << "," << val[i] << endl;
      sum[i + 1] = sum[i] + val[i];
      if (ind[val[i]] != -1)
      {
         loopStart = ind[val[i]];
         loopEnd = i;
         break;
      }
      else
      {
         ind[val[i]] = i;
      }
   }
   if (N - 1 <= loopEnd)
   {
      cout << sum[N] << endl;
      return 0;
   }
   else
   {
      long long ans = sum[loopEnd];
      long long loopSum = sum[loopEnd] - sum[loopStart];
      long long loopLen = loopEnd - loopStart;
      long long time = (N - loopEnd) / loopLen;
      ans += time * loopSum;
      long long rest = (N - loopEnd) % loopLen;
      ans += sum[loopStart + rest] - sum[loopStart];
      cout << ans << endl;
   }
   return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    int ans = 0;
    for (int i = 1; i * i <= m; i++) {
        if (m % i == 0) {
            if (n <= i) ans = max(ans, m / i);
            if (n <= m / i) ans = max(ans, i);
        }
    }
    cout << ans << '\n';
}


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

int main(){
  int n,k;
  cin >> n >> k;
  if(n%2==0){
    if(n/2>=k){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }else{
    if((n+1)/2>=k){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine();
            var zero = N.Count(c => c == '0');
            var one = N.Count(c => c == '1');
            if(zero<one)
            {
                Console.WriteLine(zero * 2);
                return;
            }
            Console.WriteLine(one * 2);
        }}

Measured memory_bytes: 13268
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AGC007
{
    public class B
    {
        private void Run()
        {
            var N = int.Parse(Console.ReadLine().Trim());
            var P = Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();

            var dx = new int[N];

            for (int i = 0; i < P.Length; i++)
            {
                dx[P[i] - 1] = i;
            }
            var A = new int[N];
            var B = new int[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = 1 + N * i + dx[i];
                B[i] = 1000000000 - N * i;
            }
            Console.WriteLine(string.Join(" ", A));
            Console.WriteLine(string.Join(" ", B));
        }

        public static void Main()
        {
            var old = Console.Out;
            using (var writer = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Console.SetOut(writer);
                new B().Run();
                Console.Out.Flush();
                Console.SetOut(old);
            }
        }
    }
}


Measured memory_bytes: 9432
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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; }

string bad = "zyxwvutsrqponmlkjihgfedcba";

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

    string s; cin >> s;
    string org(s);
    vector<int> mozi(26, 0);

    if(s.size() != 26){
        rep(i, s.size()) {
            mozi[s[i] - 'a']++;
        }
        rep(i, 26) {
            if(mozi[i])continue;
            s += (char)i + 'a';
            break;
        }
    }

    if(s.size() == 26) {
        if(!next_permutation(ALL(s))) {
            cout << -1 << endl;
            return 0;
        }
        for(int i = 0; i < s.size(); i++) {
            if(s[i] == org[i]) continue;
            s.erase(s.begin()+i+1, s.end());
            break;
        }
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <tuple>
#include <queue>
#include <algorithm>
#include <string>
#include <fstream>
#include <math.h>
#include <iomanip>
#include <time.h>
#include <assert.h>
#include <stack>
#include <deque>
#include <bits/stdc++.h>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <sstream>  // istringstream buffer(myString);
// #include <boost/functional/hash.hpp>

using namespace std;

#define endl "\n";
#define bit(x, i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x; example: x=12;  1100 => 100 => 4
#define LL long long
#define ULL unsigned long long
LL inf = 1e9+7;
LL mod = 1e9+7;
#define PII pair<int, int>
#define V vector
#define VI vector<int>
#define VS vector<string>
#define ALL(x) x.begin(), x.end() //handy for function like "sort()"
#define pi 3.14159265358979323846
// set a to the maximum of a and b
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
// conversion
string removeZeros(string str) { return str.erase(0, min(str.find_first_not_of('0'), str.size()-1)); } // remove leading zeros
#define char2int(c) (c-'0')
#define int2char(i) (static_cast<char>(i))
#define bin2int(bin) (bitset< 1001 >(bin).to_ulong())
#define int2bin(i) removeZeros(bitset< 1001 >( i ).to_string())
// str.erase(0, min(str.find_first_not_of('0'), str.size()-1)); // remove leading zeros

void reverseStr(string& str) { 
    int n = str.length(); 
    for (int i = 0; i < n / 2; i++) swap(str[i], str[n - i - 1]); 
} 

// works for unordered_set, unordered_map..
#define HMAP unordered_map
#define SET unordered_set
#define HAS(umap, key) (umap.find(key) != umap.end())
#define COUNTER(m, j) if (HAS(m, j)) { m[j]++; } else { m[j] = 1; }
// loop
#define FOREACH(vec, i) for (auto i = vec.begin(); i!= vec.end(); i++)
// read line
#define READ_INTS(vec, n) vector<LL> vec(n); for (LL i=0; i<n; i++) { cin >> vec[i]; }; cin.ignore();
#define READ_DOUBLES(vec, n) vector<double> vec (n); FOREACH(vec, i) { cin >> *i; }; cin.ignore();
#define READ_STRING(vec) string vec; getline(cin, vec);
#define READ_INT(i) LL i; cin >> i; cin.ignore();
// #define SPLIT_STRINGS(vec, str) istringstream iss(str); vector<string> vec((istream_iterator<string>(iss)), istream_iterator<string>());
// debug
#define dd(var) cerr << #var << "=" << (var) << " | "
#define ddv(vec) FOREACH(vec, i) { cout << *i << " "; } cout << endl;
#define ddvv(vec) for(auto& i:vec) { for(auto& j:i) { cout <<  j << " "; }; cout << endl };

void solve() {
    READ_INT(n);
    LL cmax, cnt, curr;
    cin >> cmax;
    cnt = 1;
    for (LL i = 1; i < n; i++) {
        cin >> curr;
        if (curr >= cmax) {
            cnt++;
            cmax = curr;
        }
    }
    cout << cnt << endl;
}


int main()
{  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
//   READ_INT(t);
//   for (LL i = 0; i < t; i++) {
    solve();
//   }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

vector<int> a;

void Search(int n, vector<int> ok) {
	int i, fin = true;
	rep(i, ok.size()) {
		if (ok[i]) {
			fin = false;
			ok[i] = false;
			Search(10 * n + i + 1, ok);
			ok[i] = true;
		}
	}
	if (fin) {
		a.push_back(n);
	}
	return;
}

int main(void) {
	int num, i, b, x = 0, y = 0;
	cin >> num;
	vector<int> l(num);
	rep(i, num)
		l[i] = i + 1;
	rep(i, num) {
		cin >> b;
		x = 10 * x + b;
	}
	rep(i, num) {
		cin >> b;
		y = 10 * y + b;
	}
	Search(0, l);
	sort(a.begin(), a.end());
	rep(i, a.size()) {
		if (a[i] == x) {
			x = i;
			break;
		}
	}
	rep(i, a.size()) {
		if (a[i] == y) {
			y = i;
			break;
		}
	}
	cout << abs(x - y) << "\n";
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long lli;
int main()
{
	lli a, b; cin >> a >> b;
	string str; cin >> str;
	lli ans = 0;
	if(b == 2)
	{
		for(int i=0; i<str.size(); i++)
		{
			if((str[i] - '0') % 2 == 0)
			{
				ans += i + 1;
			}
		}
	}
	else if(b == 5)
	{
		for(int i=0; i<str.size(); i++)
		{
			if((str[i] - '0') % 5 == 0)
			{
				ans += i + 1;
			}
		}
	}
	else
	{
		map<lli, lli> M;
		M[0] = 1;
		lli sum = 0, now = 1;
		for(int i=str.size() - 1; i >= 0; i--)
		{
			sum = (sum + (str[i] - '0') * now) % b;
			ans += M[sum];
			M[sum] ++;
			now = now * 10 % b;
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 1028
n = int(raw_input())
x = [0 for i in range(n)]
pf = -1
pb = 0

li = []
for i in range(n):
    s = (raw_input().split())
    if s[0] == 'insert':
        pf += 1
        x[pf]=int(s[1])
    elif s[0] == 'delete':
        try:
            p = x[pf::-1].index(int(s[1]))
            x[pf-p] = 0
            while x[pf]==0:
                pf -= 1
            while x[pb]==0:
                pb += 1
        except:
            pass
    elif s[0] == 'deleteFirst':
        x[pf]=0
        pf -= 1
    elif s[0] == 'deleteLast':
        x[pb] = 0
        pb += 1
for e in x[pb:pf+1][::-1]:
    if e != 0:
        print e,

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

int main(){
  int N, K;
  cin >> N >> K ;
  vector<int> v(N, 0);
  int d=0;
  for (int i = 0; i < K; i++) {
    cin >> d;
    for (int j = 0; j < d; j++) {
        int indx=0;
        cin >> indx;
        v.at(indx-1) += 1;
    }
    
  }
  //cout the 0
  size_t n_count = std::count(v.begin(), v.end(), 0);
  std::cout << n_count << std::endl;
  
}

Measured memory_bytes: 3644
/*input

*/

#include<bits/stdc++.h>
using namespace std;
//#define int 					ll
#define ios	    				ios_base::sync_with_stdio(false); cin.tie(0)
#define hell 					1000000007
#define inf 					9e18

// Data Structures //
#define ull 					unsigned long long
#define ll 						long long
#define p_q 					priority_queue
#define pii         			pair<ll,ll>
#define vi          			vector<ll>
#define vii         			vector<pii>
#define mi          			map<ll,ll>
#define mii         			map<pii,ll>
// Functions //
#define pb 						push_back
#define ppb						pop_back
#define all(a)      			(a).begin(),(a).end()
#define gcd(a,b)    			__gcd((a),(b))
#define lcm(a,b)    			((a)*(b)) / gcd((a),(b))
#define mp 						make_pair
#define bs						binary_search
#define lb 						lower_bound
#define ub						upper_bound
#define F						first
#define S						second
#define take(a,n)				for(ll i=0;i<n;i++) cin>>a[i];
#define dbg(x) 					cout << #x << " = " << x << '\n'
#define endl					"\n"
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());

#define N  1000005

ll dp[100][100002];

void solve()
{
	ll n,w=0,t,cnt=0;
	cin>>n>>w;
	vi wt(n),val(n);
	for(int i=0;i<n;i++)
	{
		cin>>wt[i]>>val[i];
	}
	
	for(int i=0;i<100;i++)
	{
		for(int j=0;j<=100000;j++)
		{
			dp[i][j] = hell;
		}
	}
	
	dp[0][0]=0; 
	dp[0][val[0]] = wt[0];
	
	for(int i=1;i<n;i++)
	{
		dp[i][0]=0;
		for(int j=1;j<=100000;j++)
		{
			dp[i][j] = dp[i-1][j];
			if(j>=val[i])
			{
				dp[i][j] = min(dp[i][j], dp[i-1][j-val[i]] + wt[i]);
			}
			
		}
	}
	ll ans = hell;
	
	for(int i = 100000;i>=0;i--)
	{
		if(dp[n-1][i] <= w)
		{
			ans = i;
			break;
		}
	}
	
	cout<<ans<<endl;
	return;
}


signed main()
{
	ios;
	ll n,tests=1,prev=0,i=0;

	//cin>>tests;
	while(tests--)
	{
		solve();
	}
	time
	return 0;
}


Measured memory_bytes: 81776
#include<iostream>
using namespace std;
int main(){
  int n,a[10];
  cin >>n;
  while(n--){
    int lot[50][2],r = 0,l = 0,x = 0;
    for(int i=0; i<10; i++) cin >>a[i];
    for(int i=0; i<10; i++){
      if(l<a[i] && r<a[i]){
	lot[x][0] = l;
	lot[x][1] = i;
	x++;
	l = a[i];
      }
      else if(l<a[i]) l = a[i];
      else if(r<a[i]) r = a[i];
      else{
	if(x == 0){cout <<"NO"<<endl;break;}
	x--;
	l = lot[x][0];
	i = lot[x][1];
	r = a[i];
      }
      if(i == 9) cout <<"YES"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    long long n;
    cin >> n;
    vector<long long> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    long long ans=223372036854775807;
    vector<long long> length(n+1,0);
    for(int i=1; i<=n; i++){
        length[i]=length[i-1]+a[i-1];
    }
    for(int i=0; i<n; i++){
        ans=min(abs(length[n]-length[i]-length[i]),ans);
    }
    cout << ans << endl;
    return 0;
}

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

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

    int p, q, r, menor = 201;
    cin >> p >> q >> r;

    if((p + q) < menor)
        menor = p+q;
    if((q+r) < menor)
        menor = q+r;
    if((p+r) < menor)
        menor = p+r;
    
    cout << menor << endl;
    
    
}

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

int n;
string s[55],x;
int t[55];

int main(){

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

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i]>>t[i];
    }
    cin>>x;
    bool f=false;
    int ans=0;
    for(int i=0;i<n;i++){
        if(f)ans+=t[i];
        if(s[i]==x)f=true;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <cmath>
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;

#define rep(i, m) for(ll i=0;i<(m);i++)
#define rep1(i, m) for(ll i=1;i<=(m);i++)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int N;
int dp[100010];

int main() {
   cin >> N;
   rep1(i, N) {
      int dpable = 1 * i; // それはそう
      for (int j=6;j<=i;j*=6) {
         dpable = min({dpable, dp[i-j] + 1});
      }
      for (int j=9;j<=i;j*=9) {
         dpable = min({dpable, dp[i-j] + 1});
      }
      dp[i] = dpable;
   }
   cout << dp[N] << endl;
}

Measured memory_bytes: 768
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64)::n,i,j,ans
    
    read*, n
    
    ans=0
    do i=1,n
        if (mod(i,3) /= 0 .and. mod(i,5) /= 0)then
            ans=ans+i
        end if
    end do

    print*, ans
end program name

Measured memory_bytes: 2796
import bisect
n, k = map(int, input().split())
x = list(map(int, input().split()))
z = bisect.bisect_left(x, 0)
a = sorted(map(abs, x[:z]))
b = x[z:]
ans = float("inf")
if a and b:
    for i in range(min(k, len(a))):
        if k - i - 2 >= len(b):
            continue
        ans = min(ans, min(a[i], b[k - i - 2]) * 2 + max(a[i], b[k - i - 2]))
    print(ans)
elif a:
    print(a[k - 1])
else:
    print(b[k - 1])

Measured memory_bytes: 14548
#include <iostream>
using namespace std;
int A[30]={0};

int main(){
  int i,K,N,M,k,a,cnt=0;
  cin>>N>>M;
  for(i=0;i<N;i++){
    cin>>K;
    for(k=0;k<K;k++){
      cin>>a;
      A[a-1]++;
    }
  }
  for(i=0;i<M;i++)if(A[i]==N)cnt++;
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

long long int fac(int n)
{
    int i;
    long long int f=1;
    for(i=2;i<=n;i++)
    {
        f*=i;
    }
    
    return f;
}

int main(void)
{
    int n;
    
    scanf("%d",&n);
    printf("%lld\n",fac(n));
    
    return 0;
}



Measured memory_bytes: 2036
/******Author : c0d3rpr0********/
#include <bits/stdc++.h>
using namespace std;

const auto start_time = std::chrono::high_resolution_clock::now();

typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef long double ld;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;
typedef vector<ll>::iterator vit;

const ll INF = 1LL<<18;
const ll MOD = 1e9 + 7;
const ll EPS = 1e-6;

#define      each(it,s)        for(vit it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<ll>())
#define      fill(a)           memset(a, 0, sizeof (a))
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i < (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define 	 pq(x)			   priority_queue<x,std::vector<x>,compare>
#define 	 rpq(x)			   priority_queue<x,std::vector<x>,compare>
#define      F                 first
#define      S                 second
#define      mp                make_pair
#define      pb                push_back
#define      vin(a,n)          vll a;rep(i,n){ll in;cin>>in;a.pb(in);}
#define      arrin(arr,n)      rep(i,n){cin>>arr[i];}
#define      fastio            ios_base::sync_with_stdio(false);cin.tie(NULL);
#define      ignore            cin.ignore(256,'\n');

ll gcd(ll x,ll y)              {if(x==0) return y;return gcd(y%x,x);}
ll powM(ll x,ll y,ll m)        {ll ans=1,r=1;x%=m;while(r>0&&r<=y){if(r&y){ans*=x;ans%=m;}r<<=1;x*=x;x%=m;}return ans;}
ll modI(ll a, ll m)            {ll m0=m,y=0,x=1;if(m==1) return 0;while(a>1){ll q=a/m;ll t=m;m=a%m;a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}
ll max(ll a,ll b,ll c)         {return max(max(a,b),c);}
ll power(ll x,ll y)            {ll z=1;while(y>0){if(y%2)z=(z*x);x =(x*x) ;y/=2;}return z;}
void solve()
{
    ll x;
    cin>>x;
    ll n=100;
    ll ans=0;
    while(n<x)
    {
        n*=1.01;
        ans++;
    }
    cout<<ans;
}
int main()
{
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("/home/naman/Desktop/CP/input.txt","r",stdin);
    freopen("/home/naman/Desktop/CP/output.txt","w",stdout);
    #endif
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time - start_time;
    #ifndef ONLINE_JUDGE
    cerr << "Time Taken : " << diff.count() << "s\n";
    #endif
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define _for(i, a, b) for (int i = (a); i < (b); ++i)
#define _rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define ll long long
using namespace std;

ll datas[(int)2e5 + 1];
int main(){
    ios::sync_with_stdio(0);	//解决c++输入输出流被卡问题
    ll n;

    cin >> n;
    ll record = n;
    _for(i,0,n){cin >> datas[i];}
    sort(datas,datas+n);

    ll res = 0;
    res += datas[n-1];
    n-=2;
    if(n >= 2){
        res += datas[record-2]*2;
        n-=2;
    }else
    {
        if(n == 1){
            res += datas[record-2];
            n-=1;
        }
    }

    ll index = 3;
    while (n > 0)
    {
        if(n >= 2){
            res += datas[record-index]*2;
            n -= 2;
            index ++;
        }else
        {
            if(n == 1){
                res += datas[record-index];
                n-=1;
                index++;
            }
        }
        
    }
    
    cout << res << endl;
    

    return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}


ll f(ll b, ll n){
    if(n < b) return n;
    else return f(b, n/b) + n%b;
}

signed main(){
    ll n, s;
    cin >> n >> s;

    if(s == n){
        cout << n + 1 << endl;
        return 0;
    }
    
    for(ll i=2; i*i<=n; i++){
        if(f(i, n) == s){
            cout << i << endl;
            return 0;
        }
    }

    ll ans = INF;

    for(ll p=1; p*p<n; p++){
        ll b = (n - s)/p + 1;
        if(b < 2) continue;
        if(f(b, n) == s) chmin(ans, b);
    }

    cout << (ans == INF ? -1 : ans) << endl;
    return 0;
}


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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N =nextInt();
		int M =nextInt();
		int X =nextInt();
		long[] C = new long[N];
		long[][] A  = new long[N][M];
		for(int i=0;i<N;i++){
			C[i]=nextLong();
			for(int k=0;k<M;k++){
				A[i][k]=nextLong();
			}
		}
		long ans =Long.MAX_VALUE;
		for(int i=1;i<(1<<N);i++){
			int[] p = new int[N];

			for(int k=0;k<N;k++){
				p[k]=(i>>k)&1;
			}
			long[] s = new long[M];
			Arrays.fill(s, 0);
			long cnt = 0;
			for(int k=0;k<N;k++){
				if(p[k]==0){
					continue;
				}
				cnt+=C[k];
				for(int m=0;m<M;m++){
					s[m]+=A[k][m];
				}
			}
			boolean flg=true;
			for(int k=0;k<M;k++){
				if(s[k]<X){
					flg=false;
					break;
				}
			}
			if(flg){
				ans=Math.min(ans, cnt);
			}
		}

		if(ans==Long.MAX_VALUE){
			ans=-1;
		}
		System.out.println(ans);
	}


	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 28232
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

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

    #ifndef ONLINE_JUDGE 
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        freopen ("OUTPUT_ERROR.txt" , "w" , stderr);
    #endif

    //start from here

    read(n)

    n = n % 10;

    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9) print("hon")
    else if(n == 0 || n == 1 || n == 6 || n == 8) print("pon")
    else print("bon")

    return 0;
}


Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int[] num = new int[5];
    int ans = 0;
    int min = 10;
    for(int i=0; i<5; i++){
      num[i] = Integer.parseInt(in.readLine());
      if(num[i]%10==0)
        ans += num[i];
      else
        ans += (num[i]/10)*10+10;
      
      if(num[i]%10!=0)
       min = Math.min(num[i]%10,min);
    }
    System.out.println(ans-10+min);
  }
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)

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

    int w, h;
    cin >> w >> h;
    vector<ll> p(w), q(h), s(h + 2);
    ll ans = 0;
    rep(i, 0, w) {
        cin >> p[i];
        ans += p[i];
    }
    rep(i, 0, h) {
        cin >> q[i];
        ans += q[i];
    }

    sort(q.begin(), q.end());
    rep(i, 1, h + 1) s[i] = s[i - 1] + q[i - 1];

    for (auto x : p) {
        int i = lower_bound(q.begin(), q.end(), x) - q.begin() - 1;
        ans += s[i + 1] + (h - i - 1) * x;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int M, D;
    cin >> M >> D;

    int d10, d1, m, ans = 0; 
    for(int i=1;i<=M;i++){
        for(int j=1;j<=D;j++){
            m = i;
            d10 = j/10;
            d1 = j%10;
            if(d1 >= 2 && d10 >= 2 && d1*d10 == m)
                ans++;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <utility>
#include <vector>
#include <map>
#include <numeric>
#include <algorithm>
#include <set>
using std::vector;
using namespace std;

int main(){
  int N,Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> r(Q);
  vector<int> l(Q);
  vector<int> sum(N);
  
  sum.push_back(int(0));
  int cnt = 0;
  
  for(int i = 1; i < N; ++i){
    if(S[i] == 'C' && S[i-1] == 'A'){
      ++cnt;
    }
    sum[i] = cnt;
  }
  
  for(int i = 0; i < Q; ++i){
    cin >> l[i] >> r[i];
  }
  //for(int i = 0; i < N; ++i)cout << sum[i] << endl;
  
  for(int i = 0; i < Q; ++i){
    //cout << r[i] << l[i] << endl;
    int ans = sum[r[i]-1] - sum[l[i]-1];
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 2232