akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <iostream>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
void renew(int b,int e,int k,int l,int r,int x,
vector<int> &seg,const int &L,const int &K){
    if (e<0 || b>=L){
        return;
    }
    if (k>0){
        seg[k] = min(seg[k], seg[(k - 1) / 2]);
    }
    if (r<b || e<l){
        return;
    }
    if (b<=l && r<=e){
        seg[k] = min(seg[k], x);
        return;
    }
    else if (k<K-L){
        renew(b, e, 2 * k + 1, l, (l + r) / 2, x, seg, L, K);
        renew(b, e, 2 * k + 2, (l + r) / 2, r, x, seg, L, K);
        return;
    }
    return;

}
int main()
{
  int N,Q;
  cin >> N >> Q;
  vector<vector<int>> stop(N, vector<int>(3, 0));
  FOR(i, 0, N){
      int s, t, x;
      cin >> s >> t >> x;
      stop[i][0] = s - x;
      stop[i][1] = t - x;
      stop[i][2] = x;
  }
  vector<int> D(Q, 0);
  FOR(i,0,Q){
      cin >> D[i];
  }
  long int inf = 1000000007;
  int L=1;
  while (Q>L){
      L*=2;
  }
  int K=2*L-1;
  vector<int> seg(K,inf);
  FOR(i,0,N){
      int b = lower_bound(D.begin(), D.end(), stop[i][0]) - D.begin();
      int e = lower_bound(D.begin(), D.end(), stop[i][1]) - D.begin();
      renew(b, e, 0, 0, L, stop[i][2], seg, L, K);
  }
  FOR(k,0,K-L){
      seg[2 * k + 1] = min(seg[2 * k + 1], seg[k]);
      seg[2 * k + 2] = min(seg[2 * k + 2], seg[k]);
  }
  FOR(i,0,Q){
      if(seg[K - L + i] >= inf){
          cout << -1 << endl;
      }
      else {
          cout << seg[K - L + i] << endl;
      }
  }
}


Measured memory_bytes: 15616
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
string s;
cin>>s;
int n=s.length();
rep(i,0,n-2)
{
	if(s[i]==s[i+1])
	{
		o2(i+1,i+2);
		return 0;
	}
}

rep(i,0,n-3)
{
	if(s[i]==s[i+2])
	{
		o2(i+1,i+3);
		return 0;
	}
}
ol("-1 -1");
return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
typedef long long int ll;
typedef unsigned long long int ull;
int asc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}

int main(){
    int n;scanf("%d",&n);
    printf("%d\n",(int)pow((int)sqrt((double)n),2.0));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define fi first
#define se second
#define pb push_back
#define read(type, ...)type __VA_ARGS__; macro_scan(__VA_ARGS__);
#define debug(...)cerr<<"["<<#__VA_ARGS__<<"] : ",deb(__VA_ARGS__);

using namespace std;

template<typename T> void macro_scan(T& t){cin>>t;};
template<typename F, typename ...R>void macro_scan(F& f , R& ...r){
  cin>>f;macro_scan(r...);
}

void deb(){
    cerr<<endl;
}
template<typename T , typename... t>
void deb(T a , t...b){
    cerr<<a<<",";
    deb(b...);
}
template<typename T>
void dev(vector<T>v){
    int c = 0;
    for(auto i : v){
        cerr<<i<<" ";
        c++;
    }
    cerr<<endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //int t; cin>>t;for(;t--;)done();
    read(int , k);
    read(string , s);
    if(k >= s.size()){
        cout<<s<<"\n";
        return 0;
    }
   // debug(s.size());
    for(int i = 0 ; i < k; ++i){
        cout<<s[i];
    }
    cout<<"...\n";
}
//@01928419790ar epic games ar7iq r7e

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

int main(){
int N,d,num,a,b;
long long ans = 0;
string S;
cin >> N >> S;
int blue = 0;
for(int i =0; i < N; i++){
    if(S[i] == 'B'){
        blue += 1;
    }
}

for(int i = 0; i < N; i++){
    if(S[i] == 'R'){
        for(int j = 0; j < N; j++){
            if(S[j] == 'G'){
                num = blue;
                d = abs(j - i);
                a = max(i,j) + d;
                b = min(i,j) - d; 
                if(a < N && S[a] == 'B'){
                    num -= 1;
                }
                if(b >= 0 && S[b] == 'B'){
                    num -= 1;
                }
                if(d % 2 == 0 && S[(i + j) / 2] == 'B'){
                    num -= 1;
                }
                ans += num;
            }
    }
}
}
cout << ans << endl;
}

Measured memory_bytes: 3636
n = gets.to_i

def f(n, m, k, s)
  if n == m
    puts s.join.tr!("0-9", "a-z")
  else
    (0...k).each { |i| f(n, m + 1, k, s << i) }
    f(n, m + 1, k + 1, s << k)
  end
  s.pop
end

f(n, 0, 0, [])


Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int a, b, x; cin >> a >> b >> x;
    
    if(a <= x && x <= a + b)
        cout << "YES";
    else
        cout << "NO";
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;

struct Edge{
    ll from;
    ll to;
    ll cost;
    Edge(ll u, ll v, ll c) : from(u), to(v), cost(c){}
};

ostream &operator<<(ostream &s, Edge e){
    s << "<" << e.from << ", " << e.to << ", " << e.cost << " >";
    return s;
}

vector<vector<Edge>> G;
vector<ll> dist;
vector<ll> used;
void init(ll n){
    G.resize(3*n);
    dist.resize(3*n, INF);
    used.resize(3*n, 0);
}

void dijkstra(ll s){
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push(P(0, s));
    while(pq.size()){
        P p = pq.top(); pq.pop();
        ll d = p.first;
        ll v = p.second;
        if(used[v] or d>dist[v]) continue;
        used[v] = 1;
        for(ll i=0; i<G[v].size(); i++){
            Edge edge = G[v][i];
            if(used[edge.to])continue;
            if(dist[edge.to]>dist[v]+edge.cost){
                dist[edge.to] = dist[v]+edge.cost;
                pq.push(P(dist[edge.to], edge.to));
            }
        }
    }
}

signed main(){
    ll N, M;
    ll r;
    cin>>N>>M;
    cin >> r;
    init(N);
    REP(i, M){
        ll u, v, c;
        cin >> u >> v >> c;
        G[u].emplace_back(Edge(u, v, c));
    }
    dist[r] = 0;
    dijkstra(r);
    REP(i, N){
        if(dist[i]!=INF)cout << dist[i] << endl;
        else cout << "INF" << endl;
    } 
    return 0;
}


Measured memory_bytes: 32580
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

constexpr int INFI = 1145141919;

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

    int N;
    std::cin >> N;

    int ans=N;
    int count=0;
    for(int i=1; i<N+1; i++){
        int r=i;
        int buf=0;
        while(r%2==0){
            r = r/2;
            buf++;
        }
        if(count<buf){
            count = buf;
            ans = i;
        }
    }

    std::cout << ans;

    return 0;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict
from math import gcd

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline
MOD = 10 ** 9 + 7


def solve():
    N = int(rl())
    AB = tuple(tuple(map(int, rl().split())) for _ in range(N))
    
    zero_pare = 0
    zero_a, zero_b = 0, 0
    counter = defaultdict(int)
    for a, b in AB:
        if a == b == 0:
            zero_pare += 1
        elif a == 0:
            zero_a += 1
        elif b == 0:
            zero_b += 1
        else:
            cd = gcd(a, b)
            a, b = a // cd, b // cd
            if b < 0:
                a, b = -a, -b
            counter[(a, b)] += 1
    
    ans = pow(2, zero_a, MOD) + pow(2, zero_b, MOD) - 1
    memo = set()
    for a, b in list(counter):
        if (a, b) in memo:
            continue
        pa, pb = -b, a
        if pb < 0:
            pa, pb = -pa, -pb
        memo.add((a, b))
        memo.add((pa, pb))
        ans *= pow(2, counter[(a, b)], MOD) + pow(2, counter[(pa, pb)], MOD) - 1
        ans %= MOD
    
    ans = (ans + zero_pare - 1) % MOD
    print(ans)


if __name__ == '__main__':
    solve()


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

using namespace std;

int N = 128;
const int S = 62;
const char C[62] = { 
'0','1','2','3','4','5','6','7','8','9','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','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'};

string q , ans;
vector<string> vec;

int s , num[S];

int qry( void ) {
  cout << "? " << q << endl;
  int t;
  cin >> t;
  return t;
}

void Sort( void ) {
  sort( vec.begin() , vec.end() , []( string a , string b ) { return a.length() > b.length(); } );
}

string merge( string A , string B ) {
  auto a = A.begin() , b = B.begin();
  string res;
  while( a != A.end() && b != B.end() ) {
    q = res + *a;
    for( auto i = b ; i != B.end() ; ++i ) q += *i;
    if( qry() + q.length() == N )
      res += *a++;
    else res += *b++;
  }
  while( a != A.end() ) res += *a++;
  while( b != B.end() ) res += *b++;
  return res;
}

int main( void ) {
  for( int i = 0 , x ; i < S ; ++i ) {
    q = string( N , C[i] );
    x = N - qry();
    s += x;
    if( x ) vec.push_back( string( x , C[i] ) );
  }
  N = s;
  Sort();
  while( vec.size() > 1 ) {
    string a = vec.back();
    vec.pop_back();
    string b = vec.back();
    vec.pop_back();
    vec.push_back( merge( a , b ) );
    Sort();
  }
  cout << "! " << vec[0] << endl;
  return 0;
}


Measured memory_bytes: 3784
#include<iostream>
using namespace std;
int main(){
  char f,t,s;
  int b[3]={1},i;
  while(cin>>f>>t>>s){
    i=b[f-'A'];
    b[f-'A']=b[s-'A'];
    b[s-'A']=i;
  }
  for(i=0;b[i]==0;i++);
  s='A'+i;
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 1132
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll MOD=1e9+7;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    rep(i,n){
        cin >> s.at(i);
        cin >> t.at(i);
    }
    string x;
    cin >> x;

    int answer = 0;
    bool is_sleep = false;
    rep(i, n)
    {
        if(is_sleep)
            answer += t.at(i);
        if (s.at(i) == x)
        {
            is_sleep = true;
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 764
#include <stdio.h>

int main(void) {
int input;
int hour, min, sec;

scanf("%d", &input);
hour = input / 3600;
min = (input - (hour * 3600)) / 60;
sec = input - (hour * 3600) - (min * 60);
printf("%d:%d:%d\n", hour, min, sec);

return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <cstdio>
#include <algorithm>
typedef long long ll;
#define N 100005
#define PII pair<ll, ll>
#define T second
#define D first
using namespace std;

ll n, k, sum, mx, v[N], x[N], y[N], xi, yi;
PII a[N];
int main() {
	ll i;
	scanf("%lld%lld", &n, &k);
	for(i=0; i<n; i++) scanf("%lld%lld", &a[i].T, &a[i].D);
	sort(a, a+n, greater<PII>());
	for(i=0; i<n; i++) {
		if(!v[a[i].T]) {
			v[a[i].T] = 1;
			x[xi] = a[i].D + xi*2+1;
			xi++;
			if(xi<=k) sum += x[xi-1];
		} else y[yi++] = a[i].D;
	}
	mx = sum;
	for(i=0; i<k; i++) {
		sum += y[i] - x[k-1-i];
		mx = max(mx, sum);
	}
	cout<<mx;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<61;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vl l,r;
vpll a;

int main(){
	cin>>n;
	l=r=vl(n);
	a=vpll(n);
	for(int i=0;i<n;i++){
		cin>>l[i]>>r[i];
		a[i]={l[i]+r[i],i};
	}
	sort(a.begin(),a.end());
	int N=n/2;
	vvl dp(n+1,vl(N+1)),DP(n+1,vl(N+1));
	for(int i=1;i<=n;i++){
		ll A=a[i-1].first,I=a[i-1].second;
		for(int j=0;j<=min(i,N);j++) if(i-N<=j){
			ll res=INF;
			if(j) res=dp[i-1][j-1]+r[I]+A*(N-j);
			if(i!=j) res=min(res,dp[i-1][j]+l[I]+A*(N-i+j));
			dp[i][j]=res;
		}
	}
	for(int i=n-1;i>=0;i--){
		ll A=a[i].first,I=a[i].second;
		for(int j=0;j<=min(n-i,N);j++) if(n-i-N<=j){
			ll res=INF;
			if(j) res=DP[i+1][j-1]+r[I]+A*(j-1);
			if(n-i!=j) res=min(res,DP[i+1][j]+l[I]+A*(n-i-j-1));
			DP[i][j]=res;
		}
	}
	if(n%2==0) cout<<dp[n][N]<<endl;
	else{
		ll res=INF;
		for(int i=0;i<n;i++) for(int j=max(0,N-n+i+1);j<=min(i,N);j++){
			res=min(res,dp[i][j]+DP[i+1][N-j]+a[i].first*N);
		}
		cout<<res<<endl;
	}
}

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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n; cin>>n;
    vector<int> a(10);
    for(int i=0; i<4; i++){
        a[i]=(n%10);
        n/=10;
    }

    vector<int> b(10);
    for(int i=0; i<2; i++){
        for(int j=0; j<2; j++){
            for(int k=0; k<2; k++){
                for(int l=0; l<4; l++){
                    b[l]=a[l];
                }

                if(i==1) b[2]=-b[2];
                if(j==1) b[1]=-b[1];
                if(k==1) b[0]=-b[0];

                if(b[3]+b[2]+b[1]+b[0]==7){
                    cout << b[3];
                    for(int l=2; l>=0; l--){
                        if(b[l]>=0) cout << "+";
                        cout << b[l];
                    }
                    cout << "=7" << endl;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 256
// /*
// power code taken from geeks for geeks
// */
// cout << setprecision (2) << fixed << 1.2;

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;

const ll INF = 1e18 + 5;
const ll MAX_N = 410 + 5;
const ll MODD = 1e9 + 7;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return (a + MODD) % MODD; }

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}


struct p_str {
    ll a, b;
};



void solve() {
    ll n, d;
    cin >> n >> d;
    ll x[n], y[n];
    for(ll i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    ll ans = 0;
    for(ll i = 0; i < n; i++) {
        ll t = x[i] * x[i];
        t += y[i] * y[i];
        if(t <= d * d) {
            ans++;
        }
    }
    cout << ans << endl;
}



int main(){


  


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    



    ll t=1;


    // cin>>t;
    


    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 6640
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int left = 0, right = 0;
		for(int i = 0; i < S.length(); i++){
			if(S.charAt(i) == '.') right++;
		}
		int ans = left + right;
		for(int i = 0; i < N; i++) {
			if(S.charAt(i) == '#') left++;
			else right--;
			ans = Math.min(ans, left + right);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 28744
#include <iostream>

using namespace std;

int main(){
	long long N,M;

	cin >> N >> M;

	long long left,right;
	left = 0;
	right = M;

	while(right-left > 1) {
		long long c = M;
		long long mid = (left+right)/2;
		long long moreS = mid-N;
		if (moreS >0) {
			c -= moreS * 2;
		}
		if (c<mid*2) {
			// unable
			right = mid;
		}
		else {
			left = mid;
		}
	}
	cout << left << endl;
		

	return 0;
}


Measured memory_bytes: 256
ans xw =
  let t = foldr (\[x,w] a -> a + x * w) 0 xw
      i = if t > 0 then -1 else 1
      r = (abs t) `mod` 30
      m = (abs t) `div` 30
      n'= if r == 0 then m else m+1
      xw'= (take m $ repeat [i,30]) ++ (take (n'-m) [[i,r]])
  in
    ([n']:xw')

main = do
  _ <- getLine
  _ <- getLine
  c <- getContents
  let i = map (map read) $ map words $ lines c
      o = ans i
  mapM_ putStrLn $ map unwords $ map (map show) o



Measured memory_bytes: 4104
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> x(N);
  for(int i=0; i<N; i++){
    cin >> x[i];
  }
  int ans = 1e9;
  for(int i=0; i<N-K+1; i++){
    int temp = 0;
    if(x[i+K-1] <= 0){
      temp += abs(x[i+K-1]);
    }else if(0<=x[i]){
      temp += abs(x[i]);
    }else{
      temp += min(abs(x[i+K-1]),abs(x[i]));
    }
    temp += x[i+K-1] - x[i];
    chmin(ans,temp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
typedef pair<int64_t, int64_t> P;

int main(){
    int H, A;
    cin >> H >> A;
    int ans = (H + (A - 1)) / A;
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque
def main():
    n,m=map(int,input().split())
    root=[[] for i in range(n)]
    for i in range(m):
        a,b=map(int,input().split())
        root[a-1].append(b-1)
        root[b-1].append(a-1)
    dict={}
    for i in range(n):
        dict[i]=-1

    start=0
    check=[False]*n
    toVis=deque()
    check[start]=True
    for v in root[start]:
        toVis.append(v)
        dict[v]=start
    #   print(i,":",start)
        check[v]=True
    while len(toVis)>0:
        now=toVis.popleft()
        #print(now)
        check[now]=True
        for v in root[now]:
            if check[v]==False:
                toVis.append(v)
                dict[v]=now
            # print(i,":",now)
                check[v]=True
    #print(dict)  
    for i in range(1,n):
        if dict[i]==-1:
            print("No")
            return 0
    print("Yes")
    for i in range(1,n):
        print(dict[i]+1)         


if __name__=="__main__":
    main()

Measured memory_bytes: 103764
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int q;
    cin>>q;
    while(q--){
        string x,y;
        cin>>x>>y;
        int n=x.length(),m=y.length();
        int dp[n+1][m+1];
        MEMSET(dp);
        REP(i,1,n){
            REP(j,1,m){
                if(x[i-1]==y[j-1]){
                    dp[i][j]=dp[i-1][j-1]+1;
                }
                else{
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                }
            }
        }
        cout<<dp[n][m]<<endl;
    }
}


Measured memory_bytes: 11056
#include<iostream>
using namespace std;
int d[200001]={};
int main(){
	int n,ans=0;
	while(cin>>n,n){
		for(int i=1;i<=n;i++){
			d[i]=d[i-1]+i;
		}
		ans=0;
		int l=0,r=1;
		while(r!=n || d[r]-d[l]<n){
			if(d[r]-d[l]==n)
			ans++;
			if(d[r]-d[l]<n)
			r++;
			else
			l++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial

sys.setrecursionlimit(10**7)
N, K, S = map(int, input().split())

nS = 10**9 - 1
nnS = 10**9 - 2

A = [S]*K
if S != nS:
    AA = [nS]*(N-K)
else:
    AA = [nnS]*(N-K)

A = A + AA
print(*A)



Measured memory_bytes: 7708
def main():
  import sys
  from scipy.sparse.csgraph import floyd_warshall
  n,m,l,*t=map(int,sys.stdin.buffer.read().split())
  d=[[0]*(n+1)for _ in range(n+1)]
  for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=c
  d=floyd_warshall(floyd_warshall(d,0)<=l)-1
  d[d>n]=-1
  print('\n'.join([str(int(d[i]))for i in zip(*[iter(t[m*3+1:])]*2)]))
main()

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

int main(){
  int a[3],minv=9999999;
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  do{
    int temp=0;
    temp+=abs(a[0]-a[1]);
    temp+=abs(a[1]-a[2]);
    minv=min(temp, minv);
  }while(next_permutation(a,a+3));

  cout<<minv<<endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)

n,m = map(int,input().split())
g = [[] for i in range(n)]

# xは始点、yは次点
for i in range(m):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    g[x].append(y)
    
dp = [-1]*n
 
def solve(i): # 始点iから行ける場所を探索
    # すでに計算されているなら、後の距離は計算できている
    if dp[i] != -1:
        return dp[i]
    # 初期は長さ0
    tmp = 0
    # 始点iから次点にDFS
    for j in g[i]:
        #今までの距離と比較
        tmp = max(tmp, solve(j) + 1)
    # dp[i]はiからスタートして最長距離が記録される
    # 空のリスト（もう次点が存在しない）にたどり着いたらDFS終わり
    dp[i] = tmp
    return tmp
 
for i in range(n):
    solve(i)

print(max(dp))

Measured memory_bytes: 135244
#include <iostream>
#include <stdio.h>
#include <cmath>
#define EPS 1e-10
using namespace std;
int gcd(int a,int b){
  if(b == 0)return a;
  return gcd(b,a%b);
}
int lcm(int a,int b){
  return (a/gcd(a,b))*b;
}
int main(){
  int a,b;
  while(cin >> a >> b){
    if(a < b)swap(a,b);
    cout << gcd(a,b) << ' ' << lcm(a,b) << endl;

  }
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define Yes "Yes"
#define No "No"
#define DEFAULT LL ans=solve();\
 	if(ans==NONE){\
 	}else{\
 		cout << ans << endl;\
 	}
#define YESNO three(solve(),(OUT(YES),1),(OUT(NO),0))
#define YesNo three(solve(),OUT(Yes),OUT(No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b-1);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<pr, Vpr > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p998 = 998244353;
const LL p107 = 1000000007;
const LL p = p107;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
const LL NONE=-2;
#define endl "\n"
ut N, M,K,  Q, D, H, W;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
//LL A[SIZE],B[SIZE],C[SIZE];
LL solve2(int a,int b){
	return (b-a+1)/2;
}
LL solve(){

	LL a,b;
	cin >> N >> a >> b;
	if((b-a)%2==0){
		return (b-a)/2;
	}else{
		LL mn=INF;
		MN(mn,solve2(1,b-a+1)+a-1);
		MN(mn,solve2(a+(N-b),N)+(N-b));
		return mn;
	}
	return NONE;
}
 signed main() {
 
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	LL T=1;

	REP(i,T){
		DEFAULT;

	}
	
//	YesNo;
//	YESNO;
//	three(solve(),OUT("First"),OUT("Second"));
	//cin >> N;
	return 0;
 
}


Measured memory_bytes: 13824
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <utility>
#include <ctime>
#include <map>
#include <set>
#include <unordered_set>

using namespace std;

#define endl "\n"
#define X first
#define Y second
#define Z third
#define mp make_pair
#define mt make_triple

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.141592653589793;
const ld E = 2.71828182845904523;
const ll LLINF = 4000000009000000099;
const ll INF = 1009000099;
const ll MOD7 = 1000000007;
const ll MOD9 = 1000000009;

template<class A, class B, class C> struct triple { A first; B second; C third; triple(A, B, C); triple(); };
template<class A, class B, class C> triple<A, B, C>::triple(A a, B b, C c) { first = a; second = b; third = c; }
template<class A, class B, class C> triple<A, B, C>::triple() { }
template<class A, class B, class C> triple<A, B, C> make_triple(A a, B b, C c) { triple<A, B, C> t(a, b, c); return t; }
template<class A, class B, class C> bool operator<(triple<A, B, C> a, triple<A, B, C> b) { if (a.first != b.first) return a.first < b.first; if (a.second != b.second) return a.second < b.second; if (a.third != b.third) return a.third < b.third; }
template<class T> T inline sqr(T a) { return a * a; }

ll bpow(ll a, ll d, ll mod) { if (d == 0) return 1; ll t = bpow(a, d / 2, mod); t = (t * t) % mod; if (d & 1) t = (t * a) % mod; return t; }
ll bpow(ll a, ll d) { if (d == 0) return 1; ll t = bpow(a, d / 2); t = (t * t); if (d & 1) t = (t * a); return t; }
ll gcd(ll a, ll b) { while (a && b) if (a > b) a %= b; else b %= a; return a + b; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll C(ll n, ll k) { ll res = 1; for (int i = 1; i <= k; ++i) res = res * (n - k + i) / i; return res; }
ll C(ll n, ll k, ll mod) { ll u = 1, d = 1; for (int i = 2; i <= n; ++i) u = (u * i) % mod; int x = max(k, n - k), z = min(k, n - k); for (int i = 2; i <= x; ++i) { d = (d * i) % mod; if (i <= z) d = (d * i) % mod; } d = bpow(d, mod - 2, mod); ll res = (u * d) % mod; return res; }

using namespace std;

vector<ll> fact;
vector<ll> invf;

ll n_path(ll x, ll y)
{
	return fact[x + y] * invf[x] % MOD7 * invf[y] % MOD7;
}

void solve()
{
	int n; cin >> n;
	string s; cin >> s;
	vector<int> prefs(n);
	vector<int> sufd(n);
	prefs[0] = s[0] == '#';
	sufd.back() = s.back() == '.';
	for (int i = 1; i < n; ++i)
	{
		prefs[i] = prefs[i - 1] + (s[i] == '#');
		sufd[n - i - 1] = sufd[n - i] + (s[n - i - 1] == '.');
	}
	int ans = prefs.back();
	for (int i = 0; i < n; ++i)
		if (s[i] == '#')
			ans = min(ans, prefs[i] - 1 + sufd[i]);

	cout << ans;
}

int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(0);
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
#else
#endif
	solve();
	return 0;
}

Measured memory_bytes: 2708
#include<iostream>
#include<stdio.h>
#include<cmath>
#define INF 9999999
using namespace std;
long long a,b,c,n;
int main(){
	while(1){
		cin>>n;
		if(n==0)break;
		if(n==1){
			cout<<"deficient number"<<endl;
			continue;
		}
		c=1;
		for(long long i=2;i*i<=n;i++){
			if(n%i==0){
				c+=i;
				if(i!=n/i)c+=n/i;
			}
		}
		if(c<n){
			cout<<"deficient number"<<endl;
		}else if(c==n){
			cout<<"perfect number"<<endl;
		}else{
			cout<<"abundant number"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1156
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)
l, r = -1, 10 ** 12


def func(x):  # a, x, kは全て整数ということに注意(//またはint())
    k = 0  # 修行回数初期化
    for a, f in zip(A, F):  # O(N)
        e = x // f
        if a <= e:  # (Ai-Ki)*Fi<=x Ki=0なら次 (a*f<=xの変形)
            continue
        k += a - e
        # else (Ai-Ki)*Fi<=x を満たすようにKiを設定。つまり修行回数にKiを加算。
    if k <= K:
        return 1
    return 0


while (r - l > 1):  # O(logx)
    mid = (l + r) // 2
    if func(mid):
        r = mid
    else:
        l = mid


print(r)


Measured memory_bytes: 33940
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;
typedef vector<ll> vel;
typedef vector<string> ves;
typedef vector<int> vei;
typedef vector<vector<ll>> vvel;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main() {
    string s;
    cin>>s;
    int cou=0;
    int ans=-1;
    rep(i,3) {
        if(s[i]=='R') {
            cou++;
            ans = max(cou,ans);
        } else {
            cou=0;
            ans = max(cou,ans);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3620
def culc(a, plus):
    sum = 0
    ans = 0
    for i in range(len(a)):
        sum += a[i]
        if plus:
            if sum <= 0:
                ans += abs(sum) + 1
                sum = 1
        else:
            if sum >= 0:
                ans += abs(sum) + 1
                sum = -1
        plus = not(plus)
    return ans

n = int(input())
a = list(map(int, input().split()))

plus = None
if a[0] >= 0:
    plus = True
else:
    plus = False

ans1 = culc(a, plus)
ans2 = culc(a, not(plus))

print(min(ans1, ans2))

Measured memory_bytes: 14468
/*  
    Come feed the rain
	Cos I'm thirsty for your love
	Dancing underneath the skies of lust
	Yeah feed the rain...
	Cos without your love my life
	Ain't nothing but this carnival of rust
    _________________________
    _________________________
    816 Hours of Solitude
    Quarantine_Day : 34
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef pair<int, int>      pii;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<int>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 50005

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

	int n, m;
	cin>>n>>m;

	string s1[n];
	string s2[m];

	REP(i, n) cin>>s1[i];
	REP(i, m) cin>>s2[i];

	for(int i = 0; i + m - 1 < n; i++){
		for(int j = 0; j + m - 1 < n; j++){
			bool flag = false;
			if(s1[i][j] == s2[0][0]){
				flag = true;
				REP(ii, m){
					REP(jj, m){
						if(s1[i + ii][j + jj] != s2[ii][jj]){
							flag = false;
						}
					}
				}
			}
			if(flag){
				cout<<"Yes\n";
				return 0;
			}
		}
	}
	cout<<"No\n";

	return 0;
}


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

int main(void){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i=0; i<n; i++){
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    int ans=0;
    if(n%2==0){
        ans=d[n/2]-d[n/2-1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


#a=[int(x) for x in input().split()]
#n=int(input())

def main():
    a,b,c,k=[int(x) for x in input().split()]
    ans=0
    
    m=min(a,k)
    ans+=m
    a-=m
    k-=m

    m=min(b,k)
    b-=m
    k-=m

    m=min(c,k)
    ans-=m
    c-=m
    k-=m

    print(ans)

# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 62752
#include <iostream>
using namespace std;
int main() {
	int N, Y;
	int i, j, k;
	bool flg = false;

	cin >> N >> Y;

	for  (i = 0; i <=N&&flg==false ; i++)
	{
		for (j = 0;j + i <= N;j++) {
			k = N - i - j;
			if (i * 10000 + 5000 * j + 1000 * k == Y) {
				flg = true;
				break;
			}
		}
	}

	if (flg)
		cout << i-1 << " " << j << " " << k << endl;
	else
		cout << -1 << " " << -1 << " " << -1 << endl;

	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    ll H, W, N;
    cin >> W >> H >> N;
    struct P {
        ll x;
        ll y;
    };
    vector<P> pts(N);
    rep(i,0,N) {
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        pts[i] = {x, y};
    }
    vector<set<ll>> pts_y(H);
    for (P p : pts) {
        pts_y[p.y].insert(p.x);
    }
    rep(y,0,H) {
        pts_y[y].insert(W);
    }
    ll ans = numeric_limits<ll>::max();
    ll left = 0;
    rep(y,0,H) {
        while (pts_y[y].find(left) != pts_y[y].end()) {
            left++;
        }
        if (left >= W) {
            break;
        }
        auto it = pts_y[y].upper_bound(left);
        ll ans_loc = *it;
        ans = min(ans, ans_loc);
        left++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 26880
#include<stdio.h>
int main(void)
{
    int n,r,a;
    scanf("%d %d",&n,&r);
    if(n<=10){
        a = (100 * (10-n));
        printf("%d",r + a);
    }
    else{
        printf("%d",r);
    }
    return 0;

}



Measured memory_bytes: 1736
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True


def main():
    s = S()
    n = int(s[-1])
    if n in [2, 4, 5, 7, 9]:
        print('hon')
    elif n in [0, 1, 6, 8]:
        print('pon')
    else:
        print('bon')



if __name__ == '__main__':
    main()


Measured memory_bytes: 68388
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

ll gcd(ll a, ll b) {
  if (a < b) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}

void solve() {
  ll k; cin >> k;
  ll sum = 0;
  for (int a = 1; a <= k; a++)
  for (int b = 1; b <= k; b++)
  for (int c = 1; c <= k; c++) {
    sum += gcd(gcd(a, b), c);
  }
  outl(sum);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 3200
#include<iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#define fi(p) for(int i=0;i<(p);i++)
using namespace std;
int N;
int L;
int P;
const int MAX_N = 100000;
const int MAX_W = 100000;


int A[MAX_N+1];
int B[MAX_N+1];

void solve() {
	int N;
	cin >> N;

	for(int i=1;i<10;i++) {
		int temp = i * 111;
		if (temp >= N) {
			cout << temp << endl;
			break;
		}
	}
}

int main()
{
	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 256
#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, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

  int result = INT_MAX;
  sort(h.begin(), h.end(), greater<>());
  for (int i = 0; i < n - (k - 1); i++) {
    result = min(result, h[i] - h[i + k - 1]);
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 640