akhauriyash/Code-Regression huggingface dataset:
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(declaim (inline read-line-into))
(defun read-line-into (buffer-string &key (in *standard-input*) (terminate-char #\Space))
  (declare (simple-base-string buffer-string))
  (loop for c of-type base-char =
           #-swank (code-char (read-byte in nil #.(char-code #\Newline)))
           #+swank (read-char in nil #\Newline)
        for idx from 0
        until (char= c #\Newline)
        do (setf (schar buffer-string idx) c)
        finally (when (< idx (length buffer-string))
                  (setf (schar buffer-string idx) terminate-char))
                (return (values buffer-string idx))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((n (read))
         (s (make-string n :element-type 'base-char))
         (cumule (make-array (1+ n) :element-type 'uint32 :initial-element 0))
         (cumulw (make-array (1+ n) :element-type 'uint32 :initial-element 0)))
    (read-line-into s)
    (dotimes (i n)
      (if (char= #\E (aref s i))
          (progn (setf (aref cumule (1+ i)) (+ 1 (aref cumule i)))
                 (setf (aref cumulw (1+ i)) (aref cumulw i)))
          (progn (setf (aref cumule (1+ i)) (aref cumule i))
                 (setf (aref cumulw (1+ i)) (+ 1 (aref cumulw i))))))
    (println
     (loop for leader below n
           minimize (+ (aref cumulw leader)
                       (- (aref cumule n) (aref cumule (1+ leader))))))))

#-swank(main)


Measured memory_bytes: 25188
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "TASK"
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))

main(){
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    int m=in,n=in,a=in,b=in;
    forinc(i,1,m){
        forinc(j,1,n){
            if(i<=m-b && j<=n-a) cout<<1;
            else if(i>=m-b+1 && j>=n-a+1) cout<<1;
            else cout<<0;
        }
        cout<<"\n";
    }
}



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

int main() {
  int n, a, min, max;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (i == 0) min = max = a;
    else {
      if (a < min) min = a;
      if (max < a) max = a;
    }
  }
  cout << max - min << endl;
  return 0;
}


Measured memory_bytes: 256
/*input
1000000000 1000000000 1000000000 1000000000000000000
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii; 
typedef pair<int, pair<int, int> > piii;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FileIn(file) freopen(file, "r", stdin)
#define FileOut(file) freopen(file, "w", stdout)
#define syso(n) cout<<n<<endl;  
#define sysom(message, n) cout<<message<<n<<endl;
#define all(c) c.begin(), c.end() 
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define present(container, element) (container.find(element) != container.end() ) //map, set
#define cpresent(container, element) (find(all(container),element) != container.end()) //vector
#define what_is(x) cout << #x << " is " << x << endl; 

const ll MOD = 1e6 + 7;

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

ll lcm(ll fir, ll sec){
    return (fir*sec)/(gcd(fir, sec));
}

// (x^n)%M
// log(n) time, log(n) memor    y
ll modularExponentiation(ll x,ll n, ll mod = MOD){
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%mod,n/2,mod);
    else                             //n is odd
        return (x*modularExponentiation((x*x)%mod,(n-1)/2,mod))%mod;
}
ll mod(ll a){
    return ((a%MOD)+MOD)%MOD;
}

const string small_alphabets = "abcdefghijklmnopqrstuvwxyz";
const int month_days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
// --
// -- 
// -- 
// std::cout << std::fixed;
// std::cout << std::setprecision(5) << f << '\n';

// sort(arr, arr+n, greater<int>());
// string str = string() + fir + sec; // fir and sec are characters

int main(){

    ll a, b, c, k;
    cin>>a>>b>>c>>k;
    ll ans;
    if(k%2==0){
        ans = -1LL*b + a;
    }else{
        ans = -1LL*a + b;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    int n, a, b;
    cin >> n >> a >> b;
    if (a % 2 == b % 2) {
        cout << "Alice";
    } else {
        cout << "Borys";
    }

    return 0;
}

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

using namespace std;

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

    int cp = 0, cm = 0;
    vector <int> m(0), p(0);

    for (int i = 0; i < N; i++){
        int x;
        cin >> x;

        if (x < 0){
            cm += 1;
            m.push_back(-1 * x);
        }else if(x == 0){
            K -= 1;
        }else if(x > 0){
            cp += 1;
            p.push_back(x);
        }
    }

    if (cm > 0){
        sort(m.begin(), m.end());
    }
    if (cp > 0){
        sort(p.begin(), p.end());
    }
    
    
    int min = 1000000007;
    if (K == 0){
        min = 0;
    }else if(cm == 0){
        min = p[K-1];
    }else if (cp == 0){
        min = m[K-1];
    }else{
        int sum;
        if (cp >= K){
            sum = p[K-1];
            if (min > sum){
                min = sum;
            }
        }
        if (cm >= K){
            sum = m[K-1];
            if (min > sum){
                min = sum;
            }
        }
        if (K > 1){
            int count;
            if (0 <= K - 1 - cp){
                count = K - 1 - cp;
            }else{
                count = 0;
            }
            

            for (int i = count; i < cm && K - i - 1 > 0; i++){
                sum = m[i] * 2 + p[K - i - 2];
                if (min > sum){
                    min = sum;
                }
            }
            
            if (0 <= K - 1 - cm){
                count = K - 1 - cm;
            }else{
                count = 0;
            }
                        
            for (int i = count; i < cp && K - i - 1 > 0; i++){
                sum = p[i] * 2 + m[K - i - 2];
                if (min > sum){
                    min = sum;
                }
            }
        }   
    }
    
    cout << min << endl;

    return 0;
}

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

void hikaku(int *number, int total);

int main(void){
	int N, A[20], B[20], C[20], i, ans=0, D[19], k=0;
	scanf("%d", &N);
	for(i = 0; i < N; i++){
		scanf("%d,", &A[i]);
		if(i > 0){
			if(A[i] == (A[i-1] + 1)){
				D[k] = A[i-1] - 1;
				k++;
			}
		}
	}
	hikaku(D, k);
	k=0;
	for(i=0; i < N; i++){
		scanf("%d,", &B[i]);
		ans += B[i];
	}
	for(i=0; i < N-1; i++){
		scanf("%d,", &C[i]);
		if(D[k] == i){
			ans += C[i];
			k++;
		}
	}
	printf("%d", ans);
    return 0;
}

void hikaku(int *number, int total){
	int i, j, tmp;
	for (i=0; i<total; ++i) {
		for (j=i+1; j<total; ++j) {
			if (number[i] > number[j]) {
				tmp =  number[i];
				number[i] = number[j];
				number[j] = tmp;
			}
		}
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;
typedef long long int ll;

int main()
{
    int n;
    int x,y;

    while(scanf("%d",&n) != EOF)
    {
        x = n/10;
        y = n%10;
        if(x == 9 || y == 9)
            printf("Yes\n");
        else printf("No\n");
    }

    return 0;
}


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

int solve(int n){
    if (n == 1) return 1;
    return n + solve(n-1);
}
int main(){
    int a,b;
    cin >> a >> b;
    cout << solve(b-a) - b << endl;
    

    return 0;
}


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

using namespace std;

int main()
{
  vector<string> vs;
  vs.push_back("1111110");

  vs.push_back("0110000");
  vs.push_back("1101101");
  vs.push_back("1111001");
  vs.push_back("0110011");
  vs.push_back("1011011");

  vs.push_back("1011111");
  vs.push_back("1110010");
  vs.push_back("1111111");
  vs.push_back("1111011");

  while(true){
    int n;
    scanf("%d", &n);
    if(n==-1)break;
    string state = "0000000";
    for(int i = 0; i < n; ++i){
      int d;
      scanf("%d", &d);
      string signal;
      for(int j = 0; j < 7; ++j){
	if(state[j]!=vs[d][j]){
	  signal += '1';
	}else{
	  signal += '0';
	}
      }
      reverse(signal.begin(),signal.end());
      printf("%s\n", signal.c_str());
      state = vs[d];
    }

  }
  
  return 0;
}

Measured memory_bytes: 0
import heapq
N, M  = map(int, input().split())

T = []

for i in range(N):
  a, b = map(int, input().split())
  T.append((a, b))

T.sort()
heap = []
heapq.heapify(T)
i = 0
ans = 0

for limit in range(1, M+1):
  while (i < N) and (T[i][0] <= limit):
    cost, value = T[i]
    heapq.heappush(heap, -value)
    i += 1
  
  if heap:
    ans += -heapq.heappop(heap)

print(ans)

Measured memory_bytes: 20800
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vvi c;
  srep(x,1,101) {
    srep(y,1,101) {
      srep(z,1,101) {
        c.push_back(vi{x,y,z});
      }
    }
  }
  vi cnt(N+1,0);
  for(vi a:c) {
    int x=a[0],y=a[1],z=a[2];
    int r = x*x+y*y+z*z+x*y+y*z+z*x;
    if(r>N) continue;
    cnt[r]++;
  }
  srep(i,1,N+1) {
    cout << cnt[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 57784
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, M, Q;
	cin >> N >> M >> Q;

	vector<vector<Int>> range(N);
	Int L, R;
	for (Int i = 0; i < M; i++) {
		cin >> L >> R;
		L--;
		R--;
		range[L].push_back(R);
	}

	for (Int i = 0; i < N; i++) {
		sort(range[i].begin(), range[i].end());
	}

	//クエリ
	Int p, q;
	for (Int i = 0; i < Q; i++) {
		cin >> p >> q;
		p--;
		q--;

		Int ans = 0;
		for (Int j = p; j <=q; j++) {
			ans += lower_bound(range[j].begin(), range[j].end(), q + 1) - range[j].begin();
		}

		//cout << ans << "\n";
		printf("%lld\n", ans);
	}

}


Measured memory_bytes: 3456
#include<stdio.h>

int main(){

  int  c, e;

  scanf("%d %d",&c ,&e);

  if(c==e){
    printf("a == b\n");
  } else if(c>e){
    printf("a > b\n");
  } else if(c<e){
    printf("a < b\n");
  }

  return 0;

}
  



Measured memory_bytes: 2104
#include <iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    float t1,t2;
    while(cin>>t1>>t2){
        if(t1<35.50&&t2<71.00)cout<<"AAA"<<endl;
        else if(t1<37.50&&t2<77.00)cout<<"AA"<<endl;
        else if(t1<40.00&&t2<83.00)cout<<"A"<<endl;
        else if(t1<43.00&&t2<89.00)cout<<"B"<<endl;
        else if(t1<50.00&&t2<105.00)cout<<"C"<<endl;
        else if(t1<55.00&&t2<116.00)cout<<"D"<<endl;
        else if(t1<70.00&&t2<148.00)cout<<"E"<<endl;
        else cout<<"NA"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3140
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
using namespace std;

int main() {
    int a;
    int d=0;
    cin >> a;

    if (a/100==1){d++;}
    if (a>=100){
        if ((a-100)/10==1){d++;}
    }
    else{
        if (a/10==1){d++;}
    }
    if (a%2==1){d++;}
    cout << d << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

struct edge {
    int from, to;
    ll cost;
};

class BellmanFord {
    int V;
    int E;
    vector<edge> edges;
    vector<ll> dist;
    vector<bool> negative;

public:
    BellmanFord(int v, int e) : V(v), E(e), negative(v) {
        dist.resize(V, INF);
    }

    void add_edge(int from, int to, ll cost) {
        edges.push_back({from, to, cost});
    }

    ll get_total_cost(int v) {
        return dist[v];
    }

    // v に到達するまでに負ループがあるかを検出する
    bool is_negative(int v) {
        return negative[v];
    }

    // ベルマンフォード法の実行・全辺の負閉路を検出 trueを返す時に負閉路を含む
    bool exec() {
        bool updated = false;
        dist[0] = 0;
        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < E; ++j) {
                edge edge = edges[j];
                if (dist[edge.from] != INF && dist[edge.to] > dist[edge.from] + edge.cost) {
                    dist[edge.to] = dist[edge.from] + edge.cost;
                    if (i == V - 1) updated = true;
                }
            }
        }

        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < E; ++j) {
                edge edge = edges[j];
                if (dist[edge.from] != INF && dist[edge.to] > dist[edge.from] + edge.cost) {
                    negative[edge.to] = true;
                }
                if (negative[edge.from]) {
                    negative[edge.to] = true;
                }
            }
        }
        return updated;
    }
};

void Main() {
    int N, M, P;
    cin >> N >> M >> P;
    BellmanFord bellmanFord(N, M);
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        bellmanFord.add_edge(a, b, -c + P);
    }
    bellmanFord.exec();

    if (bellmanFord.is_negative(N - 1)) {
        cout << "-1" << '\n';
    } else {
        cout << max(-bellmanFord.get_total_cost(N - 1), 0LL) << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;


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

	

	int K;
	cin >> K;
	string S;
	cin >> S;

	if (S.size() <= K) {
		cout << S << endl;
	}else {
		rep(i, K) {
			cout << S[i];
		}
		cout << "..." << endl;
	}
	return 0;
}

Measured memory_bytes: 3648
/*===============================================================
*  Filename：b.cpp
*  Author：zhuyutian
*  Date：2016年11月06日
================================================================*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int N=100005;
int w,h,n,x,y,a;

int main()
{
	scanf("%d%d%d",&w,&h,&n);
	int l=0,r=w,low=0,he=h;
	for(int i=0;i<n;i++)
	{
		scanf("%d%d%d",&x,&y,&a);
		if(a==1)
			l=max(l,x);
		else if(a==2)
			r=min(r,x);
		else if(a==3)
			low=max(low,y);
		else
			he=min(he,y);
	}
	int ans=w*h;
	if(l<r&&low<he)
	{
		ans=l*h+(w-r)*h;
		int tmp=r-l;
		ans+=tmp*low+tmp*(h-he);
	}
	printf("%d\n",w*h-ans);
    return 0;
}


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

int main(){
	
	int x, a;
	
	scanf("%d %d", &x, &a);
	
	
	if(x < a)
		printf("0");
	else
		printf("10");
	
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n, m;
  cin >> n >> m;
  int a[3];
  for (int i = 0; i < n; ++i)
    a[i] = -1;
  for (int i = 0; i < m; ++i)
  {
    int s, c;
    cin >> s >> c;
    s--;
    if (a[s] == -1)
      a[s] = c;
    if (a[s] != c)
    {
      cout << -1 << endl;
      return 0;
    }
  }
  if (a[0] == 0)
  {
    if (n == 1)
      cout << 0 << endl;
    else
      cout << -1 << endl;
    return 0;
  }
  if (a[0] == -1 && n == 1)
  {
    cout << 0 << endl;
    return 0;
  }
  if (a[0] == -1)
    a[0] = 1;
  for (int i = 0; i < n; ++i)
    if (a[i] == -1)
      cout << 0;
    else
      cout << a[i];
  cout << endl;

  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        long n = Long.parseLong(sc.next());
        long num = n < b ? n : b - 1;
        System.out.println((long)(Math.floor(a * num * 1.0 / b) - (a * Math.floor(num * 1.0 / b))));
    }
}

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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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

string target = "AKIHABARA";

int main(){

  string s;
  cin >> s;
  if(s.size() > 9) cout << "NO" << endl;
  else{
    bool f = true;
    int pos = 0;
    rep(i, s.size()){
      if(pos < target.size() && s[i] == target[pos]) pos++;
      else if(pos+1 < target.size() && target[pos] == 'A' && s[i] == target[pos+1]) pos += 2;
      else f = false;
    }

    if(pos < target.size() - 1 ) f = false;

    cout << (f? "YES" : "NO") << endl;
  }

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define eps 1e-6
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=0, k=0, i, j,l=2e9+7;
  string s, r, y;
  cin>>n;
  ll ar[n];
  rep(i,0,n){ cin>>ar[i];k+=ar[i];}
  m=abs(k-ar[0]);
  rep(i,0,n)
  {
    b+=ar[i];
    ll z=k-b;
    m=min(m,abs(z-b));
  }
  //k=min(n+a,min(n+b,a+b));
  cout<<m;
  /*if(n<a) cout<<0;
  else cout<<10;*/
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
 //  cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3660
// Problem : B - Distance 
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// $%U%$
// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	ll n,d;
	cin >> n >> d;
	int ans=0;
	for(int i=0;i<n;++i)
	{
		ll a,b;
		cin >> a >> b;
		if(d*d>=(a*a)+(b*b))
		ans++;
	}
	cout << ans << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


Measured memory_bytes: 3648
N = int(input())

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

B = [0] * (N+1)

for i in range(N, 0, -1):
    
    x = 2
    _sum = 0
    for j in range(i+i, N+1, i):    
        _sum ^= B[j]

    B[i] = _sum ^ A[i-1]

ans = []
for i in range(1, len(B)):
    if B[i]:
        ans.append(i)

if ans:
    print(len(ans))
    print(' '.join(map(str, ans)))
else:
    print(0)


Measured memory_bytes: 19892
#include <iostream>

int main() {
  int x, a, b;
  std::cin >> x >> a >> b;
  if (a >= b) {
    std::cout << "delicious" << std::endl;
  } else if (a + x >= b) {
    std::cout << "safe" << std::endl;
  } else {
    std::cout << "dangerous" << std::endl;
  }
return 0;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main()
{
    int n,k,ans=0;
    cin>>n>>k;
    vector<int> a(n);
    int ls[200010];
    m0(ls);
    priority_queue<int, vector<int>, greater<int>> pq;

    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
        ls[a[i]]++;
    }
    
    for(int i = 0; i < 200010; i++)
    {
        if(ls[i]>0) pq.push(ls[i]);
    }
    
    int erase = pq.size()-k;
    
    for(int i = 0; i < erase; i++)
    {
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
int main()
{
    ll n,k,d,a;
    set<ll> s;
    cin>>n>>k;
    rep(i,k)
    {
        cin>>d;
        rep(j,d)
        {
            cin>>a;
            s.insert(a);
        }
    }
    cout<<n-s.size();
}


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

#define pii              pair <int,int>
#define pll              pair <long long,long long>
#define sc               scanf
#define pf               printf
#define Pi               2*acos(0.0)
#define ms(a,b)          memset(a, b, sizeof(a))
#define pb(a)            push_back(a)
#define MP               make_pair
#define db               double
#define ll               long long
#define EPS              10E-10
#define ff               first
#define ss               second
#define sqr(x)           (x)*(x)
#define D(x)             cout<<#x " = "<<(x)<<endl
#define VI               vector <int>
#define DBG              pf("Hi\n")
#define MOD              1000000007
#define CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define SZ(a)            (int)a.size()
#define sf(a)            scanf("%d",&a)
#define sfl(a)           scanf("%lld",&a)
#define sff(a,b)         scanf("%d %d",&a,&b)
#define sffl(a,b)        scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)      scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)
#define stlloop(v)       for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define REP(i,a,b)       for(int i=a;i<b;i++)
#define RREP(i,a,b)      for(int i=a;i>=b;i--)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
#define PRINT_CASE       printf("Case %d: ",z)
#define LINE_PRINT_CASE  printf("Case %d:\n",z)
#define CASE_PRINT       cout<<"Case "<<z<<": "
#define all(a)           a.begin(),a.end()
#define intlim           2147483648
#define infinity         (1<<28)
#define ull              unsigned long long
#define gcd(a, b)        __gcd(a, b)
#define lcm(a, b)        ((a)*((b)/gcd(a,b)))

using namespace std;


/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/

ll n,c,k;
vector<ll>v;
int main()
{
    CIN;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    cin>>n>>c>>k;

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

    int cnt=0;

    sort(all(v));

    int i=0,j=0;

    int ans=0;

    while(i<SZ(v))
    {
        j=v[i]+k;
        while(v[i]<=j && i<SZ(v) && cnt<c)
        {
            cnt++;
            i++;
        }
        cnt=0;
        ans++;
    }

    cout<<ans<<endl;




    return 0;
}


Measured memory_bytes: 1400
//package beg_165;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner a = new Scanner(System.in);
		String b = a.nextLine();
		String[] l = b.split(" ");
		
		long[] list = new long[3];
		for (int i=0;i<l.length;i++) {
			list[i]=Long.parseLong(l[i]);
		}
		long x = Math.min(list[1]-1, list[2]);
		
		long A = list[0];
		long B = list[1];
		
		long d = A*x/B;
		long e = x/B;
		e=e*A;
		System.out.println(d-e);
	}

}


Measured memory_bytes: 35744
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef pair<ll, pair<int, int>> P;
typedef pair<ll,pair<ll,ll>> T;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
int INFM =100000000;
ll MOD  = 1000000007;


int main(){
    string S;
    cin >> S;
    int a = 0;
    for(int i = 0; i < S.size(); i++){
        if(S.at(i) == '-'){
            a--;
        }else{
            a++;
        }
    }
    cout << a << endl;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

void solve(long long r) { cout << 3 * r * r << endl; }

int main() {
  long long r;
  scanf("%lld", &r);
  solve(r);
  return 0;
}


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

const long long MOD = 1e9 + 7;

long long myPow(long long x, long long n) {
    if (n == 0) {
        return 1;
    } else if (n % 2) {
        return x * myPow(x, n - 1) % MOD;
    } else {
        return myPow(x * x % MOD, n / 2);
    }
}

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

    int N, K;
    cin >> N >> K;
    vector<long long> V(K + 1, 0);
    long long ans = 0;

    for (int i = K; i > 0; --i) {
        int res = K / i;
        V.at(i) = myPow(res, N);
        for (int j = 2; i * j <= K; ++j) {
            V.at(i) -= V.at(i * j);
            V.at(i) += MOD;
            V.at(i) %= MOD;
        }
        (ans += (V.at(i) * i)) %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3960
#include<iostream>

int main()
{
	int a, b, c;
	int i;
	int ans = 0;
	std::cin >> a;
	std::cin >> b;
	std::cin >> c;
	for (i = a; i <= b; i++){
		if (c % i == 0){
			ans++;
		}
	}
	std::cout << ans << '\n';
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<climits>
#include<queue>
using namespace std;
#define int long long
vector<double> dijk(vector<tuple<int,int,double>> edge_list, int start){
        const int DJMAX = INT_MAX;
        set<int> node_list;
        for(auto edge : edge_list){
                node_list.insert(get<0>(edge));
                node_list.insert(get<1>(edge));
        }
        int nodenum = *node_list.rbegin()+1;
        vector<vector<double>> cost_map(nodenum, vector<double>(nodenum, DJMAX));
        for(auto edge : edge_list){
                cost_map[get<0>(edge)][get<1>(edge)] = get<2>(edge);
        }
        vector<double> cost(nodenum,DJMAX);
        cost[start] = 0;
        vector<int> visited(nodenum,0);
        priority_queue<pair<int,int>> que;
        que.push(pair<double,int>(0,start));
        while(!que.empty()){
                int s = que.top().second;
                que.pop();
                visited[s] = 1;
                for(int j=0;j<nodenum;j++){
                        if(visited[j]==1) continue;
                        double nc = cost[s]+cost_map[s][j];
                        if(nc<cost[j]){
                                cost[j] = nc;
                                que.push(pair<double,int>(-cost[j],j));
                        }
                }
        }
        return cost;
}
signed main(){
        int n;
        cin >> n;
        vector<tuple<int, int, double>> edges;
        for(int i=0;i<n;i++){
                int vs, vn;
                cin >> vs >> vn;
                for(int j=0;j<vn;j++){
                        int vt,c;
                        cin >> vt >> c;
                        edges.push_back(tuple<int,int,double>(vs,vt,c));
                }
        }
        auto ans = dijk(edges, 0);
        for(int i=0;i<n;i++){
                cout << i << " " << ans[i] << endl;
        }
        return 0;
}

Measured memory_bytes: 3332
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define mp make_pair
#define pb push_back
#define ld long double
#define ss(x) (int) x.size()
#define FOR(i, j, n) for(int i = j; i <= n; ++i)
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl;
#define ios cin.tie(0); ios_base::sync_with_stdio(0)
 
using namespace std;
using namespace __gnu_pbds;
 
// order_of_key
// find_by_order
// tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ja;
const int nax = 5005;
const ll INF = 1e18;
int n;
pair<int, int> t[nax];
ll dp[nax];


int main() {		
	
	cin >> n;
	FOR(i, 1, n) {
		cin >> t[i].fi >> t[i].se;
	}
	
	sort(t + 1, t + n + 1, [](pair<int, int> a, pair<int, int> b) {
		return a.fi + a.se < b.fi + b.se;
	});
	
	FOR(i, 1, n)
		dp[i] = INF;
	
	FOR(i, 1, n)
		for(int j = n; 1 <= j; --j) {
			if(t[i].fi >= dp[j - 1])
				dp[j] = min(dp[j], dp[j - 1] + t[i].se);
		}
	
	int ans = n;
	while(dp[ans] == INF)
		ans -= 1;
	
	cout << ans;
	
	
	return 0;
}
		


Measured memory_bytes: 384
from numpy import *
N,K = map(int,input().split())
P = list(map(int,input().split()))
Q = (N-K+1)*[0]
R = sum(P[0:K])
Q[0] = R

for n in range(1,N-K+1):
  R+=P[n-1+K]-P[n-1]
  Q[n] = R

S = argmax(Q)
print(0.5*(sum(P[S:S+K])+K))

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

int N, M;

int main() {
	map<string, int> mp1;
	cin >> N;
	string s;
	for (int i = 0; i < N; i++) {
		cin >> s;
		mp1[s]++;
	}
	cin >> M;
	string t;
	map<string, int> mp2;
	for (int i = 0; i < M; i++) {
		cin >> t;
		mp2[t]++;
	}
	int ans = 0;
	for (auto i = mp1.begin(); i != mp1.end(); i++) {
		ans = max(ans, mp1[i->first]-mp2[i->first]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*
    https://atcoder.jp/contests/abc128/tasks/abc128_a
*/
#include <bits/stdc++.h>
using namespace std;

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

    int a, p;
    cin >> a >> p;
    cout << ((a * 3 + p) / 2) << endl;
}

Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]


n = input()

if "9" in n:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 8896
#include<bits/stdc++.h>
using namespace std;
const int N=2010;
typedef long long ll;
const ll llf=(1ll<<63)-1;
ll dp[N][N],a[N]; 
ll x,ans=llf;int n;
int main()
{
   
    scanf("%d%lld",&n,&x);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        dp[0][i]=a[i];
    }
    for(int i=1;i<=n-1;i++)
    {
        for(int j=1;j<=n;j++)
        {
            int ind=j-i;
            if(ind<=0)ind=n+ind;
            dp[i][j]=min(dp[i-1][j],a[ind]);
        }
    }
    for(int i=0;i<=n-1;i++)
    {
        ll ant=0;
        for(int j=1;j<=n;j++)ant+=dp[i][j];
        ans=min(ans,ant+i*x);
    }
    printf("%lld\n",ans);
    return 0;
}

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

vector<int>G[maxn];
int step1[maxn],step2[maxn];
int vis1[maxn],vis2[maxn];
int n,s1,s2,u,v;

void bfs(int k){
    if(k==s1){
        queue<int>q;
        q.push(k);
        step1[k]=0;
        vis1[k]=1;
        while(!q.empty()){
          int a=q.front();
          q.pop();
          for(int b:G[a]){
             if(!vis1[b]) {
                step1[b]=step1[a]+1;
                //cout<<b<<" "<<step1[b]<<endl;
                vis1[b]=1;
                q.push(b);
          }
        }
      }
    }
    else if(k==s2){
        queue<int>q;
        q.push(k);
        step2[k]=0;
        vis2[k]=1;
        while(!q.empty()){
          int a=q.front();
          q.pop();
          for(int b:G[a]){
            if(!vis2[b]) {
                step2[b]=step2[a]+1;
                //cout<<b<<" "<<step2[b]<<endl;
                vis2[b]=1;
                q.push(b);
            }
         }
      }
   }
}

int main(){
    memset(vis1,0,sizeof(vis1));
    memset(vis2,0,sizeof(vis2));
    memset(step1,0,sizeof(step1));
    memset(step2,0,sizeof(step2));
    cin>>n>>s1>>s2;
    for(int i=0;i<n-1;i++){
        scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    bfs(s1);
    bfs(s2);
    int ans=0;
    for(int i=1;i<=n;i++){
        if(step1[i]<step2[i]) ans=max(ans,step2[i]);
    }
    cout<<ans-1;
  return 0;
}


Measured memory_bytes: 7424
#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 x,y;
  cin >> x >> y;
  if (y>=2*x && y<=4*x && y%2==0) {
    cout << "Yes" << endl;
  }else{
    cout << "No" <<endl;
  }
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    vector<int> B(N);
    rep(i,N) B[A[i]-1] = i+1;
    rep(j,N) cout<<B[j]<<endl;
    return 0;
    
}

Measured memory_bytes: 1664
a = int(input())
attack_num = 0
num_list = []
count = 1

def attack(hp):
  global attack_num,num_list,count
  
  attack_num = attack_num + count
  count = count *2
  if hp <= 1:
    num_list.append(attack_num)
  elif hp % 2 == 0:
    attack(hp/2)
  elif hp % 2 == 1:
    attack((hp-1)/2)
    
    
attack(a)
print(num_list[-1])


Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int n;
  cin>>n;
  int d[50];
  for(int i=0;i<n;i++){
    cin>>d[i];
  }
  int answer=0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      answer+=d[i]*d[j];
    }
  }
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#define MN 301000
#define MM 1601000

typedef std::pair<int, int> P;
int h[MN], nxt[MM], to[MM], cost[MM], K = 0;
std::vector<P> v[101000];
int d[MN], n, m;
std::deque<int> q;

void ins(int u, int v, int c) {nxt[++K] = h[u]; h[u] = K; to[K] = v; cost[K] = c;}

int bfs()
{
	q.push_back(1);
	memset(d, 0x3f, sizeof(d)); d[1] = 0;
	while(!q.empty())
	{
		int u = q.front(); q.pop_front();
		for(int i = h[u]; i; i = nxt[i])
		{
			if(d[to[i]] > d[u] + cost[i])
			{
				d[to[i]] = d[u] + cost[i];
				if(cost[i]) q.push_back(to[i]);
				else q.push_front(to[i]);
			}
		}
	}
	if(d[n] > 1e9) return -1;
	return d[n];
}

int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; i++)
	{
		int p, q, c; scanf("%d%d%d", &p, &q, &c);
		v[p].push_back(P(c, i));
		v[q].push_back(P(c, i));
		ins(p, n + i, 1); ins(n + i, p, 0);
		ins(q, n + i, 1); ins(n + i, q, 0);
	}
	for(int i = 1; i <= n; i++)
	{
		std::sort(v[i].begin(), v[i].end());
		int S = v[i].size();
		for(int j = 1; j < S; j++)
		{
			if(v[i][j].first == v[i][j - 1].first)
			{
				ins(v[i][j].second + n, v[i][j - 1].second + n, 0);
				ins(v[i][j - 1].second + n, v[i][j].second + n, 0); 
			}
		}
	}
	printf("%d\n", bfs());
}

Measured memory_bytes: 30592
from itertools import accumulate

def Sdiff(s, m, e):
    # Sdiff(s, m, e) = [A_s, A_s+1 ..., A_m] [A_m+1 .... A_e]
    #    L = cl[m]-cl[s-1], R = cl[e] - cl[m]
    # diff(L,R) = abs(cl[m] - cl[s-1] - cl[e] + cl[m]) = abs(2*cl[m] - cl[s-1] - cl[e])

    x = 0 if s == 0 else cl[s-1]
    return abs(2*cl[m] - x - cl[e])

def partial(start, end, last):
    #print("partial: {}-{} last:{}".format(start,end, last))
    odiff = Sdiff(start, last, end)

    for c in range(last, end):
        diff = Sdiff(start, c, end)
        #print("partial loop: c:{}, diff:{} -> {}".format(c, odiff, diff))
        if odiff < diff:
            return c-1
        odiff = diff
    return c

if __name__ == '__main__':
    # read input
    N = int(input())
    l = list(map(int, input().split()))
    # create cumlative list first
    cl = list(accumulate(l))

    #  0  F(i)      i i+1 G(i)      len-1
    #  |------|------|-------|-------|
    #         c0    c1       c2
    #  <-----L------> <------R------->
    # pick up a c1 (i:i+1) and evaluate
    result = 9 * 10e9
    c1 = 0
    c3 = 2
    for i in range(1, N-2):
        #print("LEFT:RIGHT {}/={}=/{}".format(l[0:i+1], i, l[i+1: N]))
        # LEFT
        c1 = partial(0, i, c1)
        # RIGHT
        c3 = partial(i+1, N-1, c3)

        # evaluate
        mb = cl[c1]
        mc = cl[i] - mb
        md = cl[c3] - cl[i]
        me = cl[N-1] - cl[c3]
        diff = abs(max(mb, mc, md, me) - min(mb, mc, md, me))
        #print("\t\t{}/{}/{}: [{} {} {} {}]".format(c1, i, c3, mb, mc, md, me))
        #print("\t\tdiff={}".format(diff))
        if diff < result:
            result = diff

    print(result)

Measured memory_bytes: 24180
a, b = map(int, input().split())

ans = 0
for month in range(1, a + 1):
    if month == a:
        last_day = b
    elif month in [1, 3, 5, 7, 8, 10, 12]:
        last_day = 31
    elif month in [4, 6, 9, 11]:
        last_day = 30
    elif month == 2:
        last_day = 28
    for day in range(1, last_day + 1):
        if month == day:
            ans += 1
print(ans)


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

int solver(int n, string s, string t){
	int ret = 0;
	//cout << n << " " << t.length() << " " << s.length() << endl;
	if(n+t.length()>s.length()) return 10000000;
	int j=0;
	for(int i=n; i<n+t.length(); ++i){
	//	cout << s[i];
		if(s[i]!=t[j]) ret++;
		++j;
	}
	//cout << endl;
	//cout << ret << endl;
	return ret;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s, t; cin >> s >> t;
	int nax=1000000;
	for(int i=0; i<=s.length(); ++i){
		//cout << i << " " << s << " " << t << endl;
		nax = min(nax, solver(i, s, t));
	}
	cout << nax << endl;
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n ;
  cin >> n ;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    int light ;
    cin >> light;
    a.at(i) = light;
  }
  int sum , pre;
  pre = 1 ;
  for(int i = 0 ; i < n ; i++){
    pre = a.at(pre - 1);
    sum += 1;
    if(pre == 2){
      cout << sum << endl;
      break;
    }
    if( i == n -1 ){
      cout << -1 << endl;
    }
  }
}

Measured memory_bytes: 640
n = int(input())
a, b = [int(_) for _ in input().split()]
p = [int(_) for _ in input().split()]

first = 0
second = 0
third = 0
for pi in p:
    if pi <= a:
        first += 1
    elif pi <= b:
        second += 1
    else:
        third += 1

print(min(first, second, third))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll                   long long int
#define ld                   long double
#define scl(n)               scanf("%lld",&n)
#define scd(n)               scanf("%lf",&n)
#define eb                   emplace_back
#define pb                   push_back
#define pf                   push_front
#define ppf                  pop_front
#define ppb                  pop_back
#define pi 		     acos(-1.0)
#define mod                  1000000007
#define eps                  0.0000000001
#define inf                  9000000000000000
#define en                   "\n"

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

    int a; cin>>a;
    cout<<a+a*a+a*a*a<<en;

    return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		char[] ch = new char[s.length()];
		for (int i = 0; i < ch.length; i++) {
			ch[i] = s.charAt(i);
		}
		for (int i = 0; i < ch.length; i++) {
			int j = ch[i];

			if (j + n > 90) {
				j = j - 26 + n;
			} else {
				j = ch[i] + n;
			}
			System.out.print((char) (j));
		}
		sc.close();
	}
}


Measured memory_bytes: 39856
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(aa) (aa).begin(), (aa).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<pill,int> PA;
//ll MOD;
//ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	ll weight;
};

int cost[105][105];
int H,W;
string str[100];
int main(){
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	cin>>H>>W;
	rep(i,H)cin>>str[i];
	cost[0][0]=0;
	rep(i,H)rep(j,W){
		if(i!=0||j!=0)cost[i][j]=300;
		if(i>0){
			if(str[i][j]!=str[i-1][j])cost[i][j]=cost[i-1][j]+1;
			else cost[i][j]=cost[i-1][j];
		}
		if(j>0){
			if(str[i][j]!=str[i][j-1])cost[i][j]=min(cost[i][j],cost[i][j-1]+1);
			else cost[i][j]=min(cost[i][j],cost[i][j-1]);
		}
	}
	/*rep(i,H){
		rep(j,W)cout<<cost[i][j];
		cout<<endl;
	}*/
	int num=cost[H-1][W-1];
	if(str[0][0]=='#')num++;
	if(str[H-1][W-1]=='#')num++;
	cout<<num/2<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
using namespace std;
typedef long long ll;

int main() {
	ll a, b, c;
	cin >> a >> b >> c;

	if (a + b >= c)
		cout << "Yes" << endl;
	else 
		cout << "No" << endl;
}

Measured memory_bytes: 256