akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

string to_string(int n)
{
	char buf[10];
	sprintf(buf,"%d",n);
	return buf;
}

int main()
{
	for(int n,k;cin>>n>>k,n|k;){
		vi a(n);
		rep(i,n)
			cin>>a[i];
		
		vi p(n);
		rep(i,n)
			p[i]=i;
		
		set<string> s;
		do{
			string temp;
			rep(i,k)
				temp+=to_string(a[p[i]]);
			s.insert(temp);
			reverse(k+allof(p));
		}while(next_permutation(allof(p)));
		
		cout<<s.size()<<endl;
	}
	
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int answer=0;
    int min=n+1;
    rp(i,n){
        int p;
        cin >> p;
        if(p<min){
            min=p;
            answer++;
        }
        if(p==1)break;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;
bool ok[28];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	string s;cin>>s;
	int n = s.size();
	int ans = INF;
	REP(i,n){
		ok[s[i]-'a'] = true;
	}
	REP(i,28){
		if(!ok[i])continue;
		char tar = 'a' + i;
		int ct = 0;
		int maxct = 0;
		REP(j,n){
			if(s[j] == tar){
				maxct = max(ct,maxct);
				ct = 0;
			}else{
				ct++;
			}
		}
		maxct = max(ct,maxct);
		ans = min(maxct,ans);
	}
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n,a,b= map(int,input().split())
sum=0

for i in range(n):
  tar=i+1
  ketasum= tar%10 + int(tar/10)%10 + int(tar/100)%10 + int(tar/1000)%10 + int(tar/10000)%10
  if a <= ketasum <= b:
    sum+=tar

print(sum)

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  int a,b,c,d,e;
  int x,y;
  scanf("%d %d",&x,&y);
  for(a=0;a<=x;a++){
   if(a*2+(x-a)*4==y){
    printf("Yes");
     return 0;
   }
    
    
  }
  
  
  printf("No");
  
 return 0; 
}

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

	int gcd(int a,int b){
		int gcd1;
		int x = min(a,b);
		int y = a + b-x;
		int t=1;
        while(t){
		t = y % x;
		if(t==0){
			gcd1 = x;
			break;
		}
		y =x;
		x=t;
	}
	return gcd1;
	}
signed main() {
 	ios::sync_with_stdio(false);
  			cout.tie(nullptr);
  			cin.tie(nullptr);
  			int k;
  			long long int sum =0;
  			cin >> k;
  			for(int a =1;a<=k;a++)
  			{
  				for(int b =1;b<=k;b++){

  					for(int c = 1;c<=k;c++){
  						int r= gcd(a,b);
  			int gcd2 = gcd(r,c);
  			sum = sum + gcd2;
  					}
  				}
  			}

  			cout << sum;
  			
  			
  			
  		}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

string S;

int main(void) {

	cin >> S;

	int N = S.size();

	string T = S;
	reverse(T.begin(), T.end());

	string tmp = S.substr(0, (N - 1) / 2);

	string tmp2=tmp;
	reverse(tmp2.begin(), tmp2.end());

	string Y = "#" + S;

	Y = Y.substr((N + 3) / 2);

	string Y2 = Y;

	reverse(Y2.begin(), Y2.end());


	/*cout << S << endl;
	cout << T << endl;
	cout << tmp << endl;
	cout << Y << endl;*/

	if (S == T && tmp == tmp2 && Y == Y2) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
 
  map<int, int> order;
  for(int j=0; j<n; j++){
    order[a[j]] = j+1;
  }
 
  for(int k=1; k<n+1; k++){
    cout << order[k] << " ";
  }
  
}

Measured memory_bytes: 5888
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
      int a=sc.nextInt();int b=sc.nextInt();
      System.out.println(((a+b)%3==0||a%3==0||b%3==0)?"Possible":"Impossible");
    }
}


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

int main(){
    int d;
    cin>>d;
    int g;
    cin>>g;
    vector<int> p(d);
    vector<int> c(d);
    for(int i=0;i<d;i++) cin>>p[i]>>c[i];
    
    

    int res=10000;
    for(int i=0;i<(1<<d);i++){
        int sc=0;
        int cnt=0;
        for(int j=0;j<d;j++){
            if((i>>j)&1){
                sc+=100*p[j]*(j+1)+c[j];
                cnt+=p[j];
            }
        }
        for(int j=d-1;j>=0;j--){
            if((i>>j)&1) continue;
            for(int k=0;sc<g && k<p[j];k++){
                sc+=100*(j+1);
                cnt++;
            }
        }
        res=min(res,cnt);
    }    
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
// Contest: ACL Beginner Contest (https://atcoder.jp/contests/abl)
// Problem: C: Connect Cities (https://atcoder.jp/contests/abl/tasks/abl_c)


// region boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion

namespace snippets_dsu {
    struct DSU {
        vi p;
        explicit DSU(int n) : p(n, -1) {}

        int find(int i) { return p[i] < 0 ? i : p[i] = find(p[i]); }
        bool same(int i, int j) { return find(i) == find(j); }
        int size(int i) { return -p[find(i)]; }
        bool join(int i, int j) {
            i = find(i), j = find(j);
            if (i == j) return false;
            if (p[i] > p[j]) swap(i, j);
            p[i] += p[j], p[j] = i;
            return true;
        }
    };
} using namespace snippets_dsu;

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

    int n, m; cin >> n >> m;
    DSU dsu(n);
    int comp = n;
    rep(_, m) {
        int u, v; cin >> u >> v; --u, --v;
        comp -= dsu.join(u, v);
    }

    cout << (comp - 1) << '\n';
    return 0;
}


Measured memory_bytes: 3676
#include <iostream>
using namespace std;
int main(){
	int n; cin >> n;
	int a[n], b[n], c[n-1];
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	for(int i = 0; i < n-1; i++) cin >> c[i];
	int ans = 0;
	ans += b[a[0]-1];
	for(int i = 1; i < n; i++){
		ans += b[a[i]-1];
		if(a[i] - a[i-1] == 1) ans += c[a[i-1]-1];
	}
	cout << ans << endl;
}


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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin>>n;
  long long arr[n+1]={0};
  for(long long i=1;i<=n;i++)
  {
    for(long long j=i;j<=n;j+=i)
    {
      arr[j]++;
    }
  }
  long long ans=0;
  for(long long i=1;i<=n;i++)ans+=(long long)(i*arr[i]);
  cout<<ans;
}


Measured memory_bytes: 81760
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main()
{
    int n;
    cin >> n;
    string p;
    cin >> p;

    string a = p.substr(0, n / 2);

    if (a + a == p)cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;

}


Measured memory_bytes: 256
<?php
//error_reporting(0);
//$A = explode(" ",trim(fgets(STDIN)));
//$s = trim(fgets(STDIN));
list($N,$A,$B) = explode(" ",trim(fgets(STDIN)));
$total=0;
for($i=1;$i<=$N;$i++) {
  $ary = str_split($i,1);
  $sum = 0;
  foreach($ary as $a) {
    $sum+=$a;
  }
  if ($sum >= $A && $sum <= $B) {
    $total+=$i;
  }
}
printf("%d\n",$total);


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    OUT(n/3)

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <utility>
#include <functional>
#include <valarray>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>

using namespace std;

#define REP(i, n) for(i = 0; i < (n); i++)
#define FOR(i, a, n) for(i = a; i < n; i++)
#define REV(i, a, n) for(i = a; i > n; i--)

template<typename T> T gcd(T a, T b) {
    if(!b) return a;
    return gcd(b, a % b);
}
template<typename T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

typedef long long ll;
typedef long double ld;


int a, b, i, n, ok, sum;

int main(void) {
    while(scanf("%d", &n) && n != 0) {
        vector<pair<int, int> > vp(n);
        sum = 0; ok = 1;
        REP(i, n) {
            scanf("%d%d", &vp[i].second, &vp[i].first);
        }
        sort(vp.begin(), vp.end());
        REP(i, n) {
            sum += vp[i].second;
            if(sum > vp[i].first) ok = 0;
        }
        if(ok == 1) {
            puts("Yes");
        } else {
            puts("No");
        }
    }
    return 0;
}

Measured memory_bytes: 1172
#import decimal
#decimal.getcontext().prec==500 Floatの桁数を500まで増やす
#Decimal(c).sqrt() それで平方根を求める
#Decimal(1) / Decimal(7) 1/7
from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math
from fractions import gcd
import sys
#input = sys.stdin.readline


#N=int(input())

N,Ma,Mb=map(int,input().split())
ABC=[list(map(int,input().split())) for i in range(N)]
idle_max=10**9
dp=[[[idle_max for b in range(400)] for a in range(400)] for i in range(N)]
used=set()
a,b,c=ABC[0]
dp[0][a][b]=c

for n in range(1,N):
    a,b,c=ABC[n]

    for x in range(400):
        for y in range(400):
            if x-a>=0 and y-b>=0 and dp[n-1][x-a][y-b]!=idle_max:
                dp[n][x][y]=min(dp[n-1][x-a][y-b]+c,dp[n-1][x][y])
            else:
                dp[n][x][y]=dp[n-1][x][y]
    dp[n][a][b]=min(dp[n-1][a][b],c)
value=idle_max
for x in range(1,400):
    for y in range(1,400):
        z=gcd(x,y)
        a=x//z;b=y//z
        if Ma==a and Mb==b:
            value=min(dp[-1][x][y],value)

if value!=idle_max:
    print(value)
else:
    print(-1)


Measured memory_bytes: 121304
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;

int main(){
    int a,b;
    cin >> a >> b;
    cout << a * b << endl;
}

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

typedef pair<int, int> P;

const int MAX_H = 1000, MAX_W = 1000;
const int INF = 100000000;
int H, W, N;
char field[MAX_H][MAX_W + 1];
int d[MAX_H][MAX_W + 1];
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
int result = 0;
P start, goal;

int bfs(P start, P goal);

int main(){
	cin >> H;
	cin >> W;
	cin >> N;
	for(int i=0; i<H; i++){
		cin >> field[i];
	}

	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			if(field[i][j] == 'S'){
				goal.first = i;
				goal.second = j;
			}
		}
	}

	for(int n=1; n<=N; n++){
		start.first = goal.first;
		start.second = goal.second;

		for(int i=0; i<H; i++){
			for(int j=0; j<W; j++){
				if(field[i][j] == n+'0'){
					goal.first = i;
					goal.second = j;
				}
			}
		}
		result += bfs(start, goal);
	}

	cout << result << endl;

	return 0;
}

int bfs(P start, P goal){
	for(int i=0; i<MAX_H; i++)
		for(int j=0; j<MAX_W; j++) d[i][j] = INF;

	queue<P> que;
	que.push(start);
	d[start.first][start.second] = 0;

	while(que.size()){
		P p = que.front();
		que.pop();

		if(p.first==goal.first && p.second==goal.second) break;

		for(int i=0; i<4; i++){
			int xnew = p.first + dx[i];
			int ynew = p.second + dy[i];

			if(0<=xnew && xnew<H && 0<=ynew && ynew<W && field[xnew][ynew]!='X' && d[xnew][ynew]==INF){
				que.push(P(xnew, ynew));
				d[xnew][ynew] = d[p.first][p.second] + 1;
			}
		}
	}

	return d[goal.first][goal.second];
}

Measured memory_bytes: 6108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

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

    vector<pi> v;
    rep(i,n){
        int m;
        cin >>m;
        rep(j,m){
            int c;
            cin >>c;
            v.pb({c,i});
        }
    }
    sort(all(v),greater<pi>());
    int V = v.size();

    set<int> t;
    rep(i,n) t.insert(i);

    ll ans = 0;
    rep(i,V){
        int idx = v[i].se;

        auto itr = t.upper_bound(idx);
        if(itr != t.begin()){
            --itr;
            ans += v[i].fi;
            t.erase(itr);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 19036
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    string s;
    cin >> s;
    int i0=0, i1=0;
    for (int i=0; i< s.size(); i++) {
        if (s[i] == '0') {
            i0++;
        } else {
            i1++;
        }
    }
    cout << min(i0,i1)*2 << endl;
    return 0;
}

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

#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define ALL( a )        (a).begin(), (a).end()             

int main(void){
    int w; cin >> w;
    cout << w * 32 << endl;
}


Measured memory_bytes: 3080
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
S = np.frombuffer(readline().rstrip(),'S1')
Q = int(readline())
query = map(int,read().split())

isD = S == b'D'
isM = S == b'M'
isC = S == b'C'

cumD = isD.cumsum(dtype=np.int64)
cumM = isM.cumsum(dtype=np.int64)

def F(K):
    """
    ・Cごとに数える。
    ・そのためには(i-K,i] 内のDMの個数を調べる（負インデックスには関係ない文字があると思っておく）
    ・区間内のDの個数、Mの個数が取得できれば、差分が取得できるので最後に累積和
    """
    # (i-K,i]内のDの個数、Mの個数
    D = cumD.copy(); D[K:] -= cumD[:-K]
    M = cumM.copy(); M[K:] -= cumM[:-K]
    # 最後がMのとき、Dの個数分増える
    DM = isM * D
    # 左端のDを捨てるとき、Mの個数分減る
    DM[K:] -= isD[:-K] * M[K-1:-1]
    np.cumsum(DM,out=DM)
    # Cごとに集計
    return DM[isC].sum()

print('\n'.join(str(F(K)) for K in query))

Measured memory_bytes: 71552
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;


#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9+7;
vector<pair<int, int> > vp;
 
struct Less {
    bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
        return x.first > y.first;
    }
};

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


//グラフの隣接リスト
VI g[200010];
//頂点の入次数を管理
int h[100010];

vector<int> v;
int L[200009], R[200009];
int C[510][510], X[510][510];
int main(void) {
    int n; cin >> n;
    cout << (n/2)*((n+1)/2) << endl;
    return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int len;
    string s;
    string const cand[4] = {"dream", "dreamer", "erase", "eraser"};
    cin >> s;
    len = s.length();
    
        for(int i=0;i<4;i++){
            int clen = cand[i].length();
            if(len >= clen){
                if(s.substr(len-clen, clen) == cand[i]){
                    len -= clen;
                    i = -1;
                }
            }
        }
    if(len == 0)puts("YES");
    else puts("NO");
    
}


Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  double fa=a,fb=b;
  //cout << (a/b) <<" "<<(a%b)<<" "<<(fa/fb)<<endl;
  printf("%d %d %.5f\n",(a/b),(a%b),(fa/fb));
  return 0;
}



Measured memory_bytes: 3216
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>


//pair sort firstに揃う

#define int long long
#define pb(n) push_back(n)
#define Rap(n,i) for(int (i)=0;(i)<(n);(i)++)
#define Pr(n) cout<<n<<endl;
#define F first
#define S second
#define Vector1  vector<int>
#define vector2 vector<vector<int> >
#define index(v,x) find((v).begin(), (v).end(), (x))-(v).begin()
#define ctoi(c) (int)(c-'0')
#define incin(n) int (n); cin>>(n);
#define stcin(s) string (s); cin>>(s);
#define all(v) (v).begin() , (v).end()
#define PI 3.14
#define Rad2Deg  57.29578

using namespace std;

signed  main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    incin(n);
    incin(k);
    Vector1 h(n);
    Rap(n,i){
        cin >> h.at(i);
    }
    int count = 0;
    Rap(n,i){
        if(h[i]>=k){
            count++;
        }
    }
    Pr(count);
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
  char O[60], E[60];
  int i=0;
  scanf("%s", O);
  scanf("%s", E);

  while(O[i] != '\0'){
    printf("%c", O[i]);
    if(E[i] == '\0') break;
    printf("%c", E[i]);
    i++;
  }
  return 0;
}


Measured memory_bytes: 128
n=int(input())
x_list=[int(i) for i in input().split()]
x_sorted=sorted(x_list)
left=x_sorted[n//2-1]
right=x_sorted[n//2]

for i in x_list:
    if i<=left:
        print(right)
    elif right<=i:
        print(left)

Measured memory_bytes: 25556
#include <bits/stdc++.h>
using namespace std;
int main()
{
	char a[12];
	int n;
	cin>>a;
	n=strlen(a);
	long long s=0;
	for(int i=0;i<(1<<(n-1));i++)
	{
		long long m=a[0]-'0';
		for(int j=0;j<n-1;j++)
		{
			if(i&(1<<j))
			{
				s+=m;
				m=0;
			}
			m=m*10+a[j+1]-'0';
		}
		s+=m;
	}
	cout<<s<<'\n';
	return 0;
}


Measured memory_bytes: 256
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String c = sc.next();
        sc.close();
        if(s.charAt(0) == c.charAt(2) && s.charAt(1) == c.charAt(1) && s.charAt(2) == c.charAt(0)){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 35572
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int k;
  cin >> k;
  vector<string> sub;
  for(int i = 1;i <= k;i++){//Kthsubstrの最大sizeはK
    for(int j = 0;j < s.size()-i+1;j++){//sizeがK以下のものを全探索(せいぜい500ぐらい)
      sub.push_back(s.substr(j,i));
    }
  }
  sort(sub.begin(),sub.end());
  for(int i = 0;i < sub.size()-1;i++){
    if(sub[i] == sub[i+1]){// 一緒なら削除andその場所からもう一度(-1することでiが変化しない)
      sub.erase(sub.begin()+i+1);
      i -= 1;
    }    
  }
  cout << sub.at(k-1) << endl;
}

Measured memory_bytes: 1660
#include<cstdio>
#include<iostream>
using namespace std;
#define N 300000
#define lowbit(x) (x&-x)
//int subm[N],Rsubm[N];
int a[N],Mx[20][N],Sx[20][N],ans[N];
int main()
{
	int n,nn;
	scanf("%d",&n);nn=1<<n;
	for (int i=0;i<nn;++i) scanf("%d",&a[i]);
//	subm[0]=a[0];for (int i=1;i<nn;++i) subm[i]=max(a[i],max(subm[i-lowbit(i)],subm[lowbit(i)]));
//	now=max(now,subm[0]);
//	for (int i=1;i<nn;++i)
//	{
//		now=max(now,a[i]+subm[i]);
//		cout<<now<<endl;
//	}
	for (int i=0;i<nn;++i) Mx[0][i]=a[i];
	for (int j=1;j<=n;++j)
		for (int i=0;i<nn;++i)
		{
			Mx[j][i]=Mx[j-1][i],Sx[j][i]=Sx[j-1][i];
			if (i&(1<<(j-1)))
			{
				int T=i^(1<<(j-1));
				if (Mx[j-1][T]>Mx[j][i])
				{
					Sx[j][i]=max(Mx[j][i],Sx[j-1][T]);
					Mx[j][i]=Mx[j-1][T];
				}else Sx[j][i]=max(Sx[j][i],Mx[j-1][T]);
			}
		}
	ans[0]=Mx[n][0]+Sx[n][0];
	for (int i=1;i<nn;++i) ans[i]=max(ans[i-1],Mx[n][i]+Sx[n][i]);
	for (int i=1;i<nn;++i) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 51200
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <numeric>

using namespace std;

typedef long long int lo;
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define inf (lo)1e9
#define N (lo)1e5 * 5
#define all(x) (x).begin(), (x).end()
#define ii pair<lo,lo>
#define iii pair<lo, pair<lo,lo> >
#define si pair<string,lo>
#define vi vector <lo> 
#define vii vector <ii> 

int main() {
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0);
    lo k,a,b,d = 1;
    cin >> k >> a >> b;
    for(lo i = a ; i <= b ; i++){
	if(i % k == 0){
	    cout << "OK\n";
	    return 0;
	}
    }
    cout << "NG\n";
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdlib>
using namespace std;
string s[102],t[102];
bool s1[102],t1[102];
int n ,m;
int d(int a);
int k;

int main()
{
    cin>>n;
    for(int i=0;i<n;i++)cin>>s[i];
    cin>>m;
    for(int i=0;i<m;i++)cin>>t[i];
    int ans=0;
    for(int i= 0;i<n;i++){
    k=0;
    d(i);
    if(k>ans)ans=k;
    }
cout<<ans<<endl;
return 0;
}
int d(int a){

for(int i=0;i<n;i++){
if(s[i]==s[a]){
   k++;
}
}
for(int i=0;i<m;i++){
if(t[i]==s[a]){
   k--;
}
}
return 0;
}

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

int main(){
  int H, W;
  string b[100];
  vector<int> row;
  vector<int> col;
  cin >> H >> W;
  for(int i=0; i<H; i++){
    cin >> b[i];
  }
  for(int i=0; i<H; i++){
    bool flag = true;
    for(int j=0; j<W; j++){
      if(b[i][j]=='#'){
        flag = false;
      }
    }
    if(flag) row.push_back(i);
  }
  for(int j=0; j<W; j++){
    bool flag = true;
    for(int i=0; i<H; i++){
      if(b[i][j]=='#'){
        flag = false;
      }
    }
    if(flag) col.push_back(j);
  }
  for(int i=0; i<H; i++){
    if(find(row.begin(), row.end(), i)!=row.end()) continue;
    for(int j=0; j<W; j++){
      if(find(col.begin(), col.end(), j)==col.end()){
        cout << b[i][j];
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

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

	double sum = 0.0;
	for (int i = 0; i < n; i++) {
		sum = sum + (1.0 / a[i]);
	}

	cout << (1 / sum) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mp make_pair


int main() {
    int a,b,c;
    cin>>b>>a>>c;
    c-=b-a;
    cout<<max(c,0);
    return 0;
}
//5 1 5 -10 -10 -10 5 7


Measured memory_bytes: 256
import sys
from bisect import bisect_right, insort

def I(): return int(sys.stdin.readline())

def main():
  n = I()
  a = [I() for i in range(n)]
  b = []

  for i in range(n-1, -1, -1):
    t = bisect_right(b, a[i])
    if len(b)-1<t or b[t]==a[i]:
      insort(b, a[i])
    else:
      b[t] = a[i]
  print(len(b))

if __name__ == '__main__':
  main()

Measured memory_bytes: 7832
// https://qiita.com/_rdtr/items/c49aa20f8d48fbea8bd2

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

// 入力
string s, t;

// DPテーブル
int dp[3100][3100] = {0}; // 初期値も初期条件も 0

int main(){
    
    string s, t;
    cin >> s >> t;
    
    int n = (int)s.size(), m = (int)t.size();
    
    
    for (int i = 0; i < n; i++){
        
        for (int j = 0; j < m; j++){
            
            if (s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j] + 1);
            
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }
    
    // 解の復元をする
     string ans = "";
     
     int i = n, j = m;
     while (i > 0 && j > 0){
         
         if (dp[i][j] == dp[i][j-1]) j--;
         else if (dp[i][j] == dp[i-1][j]) i--;
         else{
             ans = s[i-1] + ans;
             i--, j--;
         }
     }
     cout << ans << endl;
}



Measured memory_bytes: 37120
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;



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

	int N;
	cin >> N;
	int A[N];
	rep(i,N) cin >> A[i];
	if(N % 2 == 0){
		int dp[N][2];
		rep(i,N){
			rep(j,2){
				dp[i][j] = -1 * INF;
			}
		}
		rep(i,N){
			if(i == 0){
				dp[i][0] = A[0];
				continue;
			}
			if(i == 1){
				dp[i][0] = A[0];
				dp[i][1] = A[1];
				continue;
			}
			if(i % 2 == 0){
				dp[i][0] = dp[i-1][0] + A[i];
				dp[i][1] = dp[i-1][1];
			}
			else{
				dp[i][0] = dp[i-1][0];
				dp[i][1] = dp[i-1][1] + A[i];
			}

			if(i % 2 == 0){
				dp[i][1] = max(dp[i-1][0], dp[i][1]);
			}


		}
		cout << max(dp[N-1][0], dp[N-1][1]) << endl;
	}
	else{
		int dp[N][3]{};
		rep(i,N){
			rep(j,3){
				dp[i][j] = -1 * INF;
			}
		}

		rep(i,N){
			if(i == 0){
				dp[0][0] = A[0];
				dp[0][1] = 0;
				continue;
			}
			if(i == 1){
				dp[1][0] = A[0];
				dp[1][1] = A[1];
				continue;
			}
			if(i == 2){
				dp[i][2] = A[2];
			}

			if(i % 2 == 0){
				dp[i][0] = max(dp[i][0], dp[i-1][0] + A[i]);
				dp[i][2] = max(dp[i][2], dp[i-1][2] + A[i]);
				dp[i][1] = max(dp[i][1], dp[i-1][1]);
				if(i == N-1) dp[i][0] = dp[i-1][0];
			}
			else{
				dp[i][1] = dp[i-1][1] + A[i];
				dp[i][0] = dp[i-1][0];
				dp[i][2] = dp[i-1][2];
			}
			if(i % 2 == 0){
				dp[i][1] = max(dp[i-1][0], dp[i][1]);
			}
			else{
				dp[i][2] = max(dp[i-1][1], dp[i][2]);
			}

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


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

const int MAX_N = 100002;

int par[MAX_N];
int rank_[MAX_N];

void init(int n){
    for(int i = 0; i < n; i++){
        par[i] = i;
        rank_[i] = 0;
    }
}

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

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rank_[x] < rank_[y]) par[x] = y;
    else{
        par[y] = x;
        if(rank_[x] == rank_[y]) rank_[x]++;
    }
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    init(n);
    int p[n];
    for(int i = 0; i < n; i++){
        cin >> p[i];
        p[i]--;
    }
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        unite(p[x], p[y]);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(same(i, p[i])) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main (void){
	long long n,k;
	cin >> n >> k;
	long long li[100001];
	for (int i=0;i<100001;i++){
		li[i]=0;
	}
	for (int i=0;i<n;i++){
		long long a,b;
		cin>>a>>b;
		li[a]+=b;
	}
	//cout << n << ","<<k<<endl;  	
	long long s =0;
	for (int i=0;i<100001;i++){
		s+=li[i];
		if(s>=k){
		cout << i << endl;
		break;
	}
	//cout << li[i] << "," << s << endl;
	}
}


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

int n;
double li[105];

double tot = 0.0;

int main()
{
   scanf("%d",&n);
   for(int i=0;i<n;i++){
      scanf("%lf",&li[i]);
      tot+=li[i];
   }
   tot/=n;
   double dif = fabs(tot-li[0]);
   int id = 0;
   for(int i=1;i<n;i++){
      double cur = fabs(tot-li[i]);
      if(cur < dif){
         dif = cur;
         id = i;
      }
   }
   printf("%d\n",id);
	return 0;
}


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

int choose(int n, int r) {
    if (r == 0) return 1;
    if (r > n / 2) return choose(n, n - r); 
    long res = 1; 
    for (int k = 1; k <= r; k++) {
        res *= n - k + 1;
        res /= k;
    }
    return res;
}

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

    int N,M;
    cin >>N>>M;

    printf("%d\n",choose(N+M,2)-N*M);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define INF 10000000
typedef long long ll;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
using namespace std;

int main()
{
    int n, q;
    cin >> n >> q;
    vector<vector<int>> connect(n);
    vector<int> value(n, 0);
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        connect[b - 1].push_back(a - 1);
    }
    rep(i, q)
    {
        int p, x;
        cin >> p >> x;
        value[p - 1] += x;
    }

    rep(i, n)
    {
        if (i != 0)
        {
            int sum = 0;
            rep(j, connect[i].size())
            {
                value[i] += value[connect[i][j]];
            }
        }
        cout << value[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 14080
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 998244353
#define MAX 100
#define INF 800000000

int main(){
  int N;
  string s;
  cin>>N;
  int left=0;
  int right=N;
  vector<int> seat(N,-1);
  cout<<0<<endl;
  cin>>s;
  if(s!="Vacant"){
    if(s=="Male"){
      seat.at(0)=1;
    }else{
      seat.at(0)=0;
    }
    cout<<(left+right)/2<<endl;
    cin>>s;
    if(s!="Vacant"){
      while(s!="Vacant"){
        if(s=="Male"){
          seat.at((left+right)/2)=1;
        }else{
          seat.at((left+right)/2)=0;
        }
        if(((left+right)/2-left)%2==0){
          if(seat.at((left+right)/2)==seat.at(left)){
            left=(left+right)/2;
          }else{
            right=(left+right)/2;
          }
        }else{
          if(seat.at((left+right)/2)==seat.at(left)){
            right=(left+right)/2;
          }else{
            left=(left+right)/2;
          }
        }
        cout<<(left+right)/2<<endl;
        cin>>s;
      }
    }
  }
}


Measured memory_bytes: 1236
import Data.List

f::String->(Int,Int)
f s=let (x:y:[])=map read (words s)::[Int]
    in (x,y)

f2::[(Int,Int)]->Int->Int->Int
f2 [] _ ans=ans
f2 ((a,b):xs) m ans
    |m<=b=ans+m*a
    |otherwise=f2 xs (m-b) (ans+a*b)

main = do
       e1<-getLine
       es<-getContents
       let xs=lines es
           (n:m:[])=map read (words e1)::[Int]
           ys=sort [f e|e<-xs]
       print $ f2 ys m 0

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll n;
    cin >> n;
    vector<string> S(n);
    REP(i,0,n) cin >> S[i];

    mat A(n, vec(26, 0));
    REP(i,0,n) {
        REP(j,0,SZ(S[i])) ++A[i][S[i][j]-'a'];
    }
    vec B(26);
    REP(i,0,26) {
        B[i] = A[0][i];
        REP(j,1,n) B[i] = MIN(B[i],A[j][i]);
    }
    REP(i,0,26) {
        REP(j,0,B[i]) cout << (char)(i+'a');
    }
    cout << endl;

    return 0;
}

/*



*/

Measured memory_bytes: 3612
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>

//#include<boost/circular_buffer.hpp>
using namespace std;

//cout << fixed << setprecision(10);
typedef long long ll;
#define PI 3.141592653589793
#define Yes(a) a ? "Yes" : "No";
#define YES(a) a ? "YES" : "NO";
#define rep(i,n) for(int i=0;i<n;i++)

long long int gcd(long long int a, long long int b) {
	if (a < b) {
		long long int tmp = a;
		a = b;
		b = tmp;
	}
	long long int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

long long int lcm(long long int a, long long int b) {
	long long int L;
	L = a / gcd(a, b);
	L *= b;
	return L;
}

vector<long long  int> Prime;
void Eratosthenes(long long int n) {
	vector<bool> is_prime(n, true);
	for (int i = 2; i * i <= n; i++) {
		;
		if (is_prime.at(i)) {
			for (int j = i * i; j < n; j += i) {
				is_prime.at(j) = false;
			}
		}
		Prime.emplace_back(i);
	}
}

/*
map<int, int> prime;
void Prime_number(long long int n) {
	for (int i = 2; i <= n; i++) {
		int count = 0;
		while (n % i == 0) {
			count++;
			n /= i;
		}
		if (count != 0) {
			prime.insert(make_pair(i, count));
		}
	}
}
*/
//std::cout.fill('0');

int keta(long long int N) {
	int k = 0;
	while (N > 0) {
		N /= 10;
		k++;
	}
	return k;
}

int Combination(int n, int m) {
	long long int s = 1, t = 1;
	int tmp = n;
	while (n - m != tmp) {
		s *= tmp;
		tmp--;
	}
	tmp = m;
	while (tmp != 1) {
		t *= tmp;
		tmp--;
	}
	return s / t;
}


int main() {
	long long int n, k, p, s, r, ans = 0;
	string t;
	cin >> n >> k;
	cin >> r >> s >> p;
	cin >> t;
	vector<bool> check(n, true);
	for (int i = 0; i < n; i++) {
		if (check.at(i)) {
			if (i + k < n && t[i] == t[i + k]) {
				check.at(i + k) = false;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (check.at(i)) {
			if (t[i] == 'r') {
				ans += p;
			}
			else if (t[i] == 's') {
				ans += r;
			}
			else {
				ans += s;
			}
		}
	}
	cout << ans << endl;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<ll> a;
bool f(int x){
    ll now=a[x];
    int next_i=0;
    while(a[next_i]<=2*now){
        if(next_i==x) {
            next_i++;
            continue;
        }
        now+=a[next_i];
        next_i++;
        if(next_i>=a.size()) return true;
    }
    return false;
}

int main() {
    int n;
    cin>>n;
    a.resize(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(all(a));
    
    int ng = -1, ok = n-1;
    while (ok - ng > 1) {
        int mid = (ng + ok) / 2;
        (f(mid) ? ok : ng) = mid;
    }
    
    cout<<n-ok<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int h,w,d[1005][1005],dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
int main(void){
    scanf("%d%d",&h,&w);
    queue<P>bfs;
    for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			char c;
			scanf(" %c",&c);
			if(c=='#')bfs.push(P(i,j));
			else d[i][j]=-1;
		}
	}
	while(!bfs.empty()){
		int y=bfs.front().F,x=bfs.front().S;
		bfs.pop();
		for(int k=0;k<4;k++){
			int ny=y+dy[k],nx=x+dx[k];
			if(0<=ny&&ny<h&&0<=nx&&nx<w&&d[ny][nx]==-1){
				d[ny][nx]=d[y][x]+1;
				bfs.push(P(ny,nx));
			}
		}
	}
	int ans=0;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)ans=max(ans,d[i][j]);
	printf("%d\n",ans);
}


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

long long solve(string str) {
    long long ans = 0;

    for (int i = 0; i + 1 < (int) str.size(); i++)
        if (str[i] == str[i + 1]) {
            ans++;
            i++;
        }

    return ans;
}

int main() {
    string S;
    long long K;
    cin >> S >> K;
    long long ans[4];
    ans[1] = solve(S);
    ans[2] = solve(S + S);
    ans[3] = solve(S + S + S);
    long long small = (K - 1) % 2 + 1;
    cout << ans[small] + (K - small) / 2 * (ans[3] - ans[1]) << '\n';
}


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

int main() {
  int h, w;
  cin>>h>>w;
  string s[h];
  for (int i=0; i<h; i++) cin>>s[i];
  long long dp[h][w];
  long long mod = 1e9 + 7;
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      dp[i][j] = 0;
    }
  }
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (i ==0 && j == 0) {
        dp[i][j] = 1;
      } else if (i == 0) {
        if (s[i][j] == '.') {
          dp[i][j] = dp[i][j-1];
        }
      } else if (j == 0) {
        if (s[i][j] == '.') {
          dp[i][j] = dp[i-1][j];
        }
      } else {
        if (s[i][j] == '.') {
          dp[i][j] = dp[i-1][j] + dp[i][j-1];
          dp[i][j] %= mod;
        }
      }
    }
  }
  cout<<dp[h-1][w-1]<<endl;
}

Measured memory_bytes: 9088
a,b=map(int,input().split())
if a>0 and b>0:
    print('Positive')
elif  a<0 and b<0 and (abs(a)-abs(b)+1)%2 != 0:
    print('Negative')
elif a<0 and b<0 and (abs(a)-abs(b)+1)%2==0:
    print('Positive')
else:
    print('Zero')

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

#define int long long int
#define pb push_back
const int MOD = 1000000007;
#define MAXX 100005


int power(int a,int n)
{

    int res = 1;
    while(n)
    {
        if(n&1)
        {
            n--;
            res = ((res%MOD)*(a%MOD))%MOD;
        }
        else
        {
            n/=2;
            a = ((a%MOD)*(a%MOD))%MOD;
        }
    }
    return (res%MOD);
}

int gcd(int a,int b)
{
    if(b == 0)
        return a;
    return gcd(b,a%b);
}
void solve(void)
{
    string n;
    cin >> n;
    int sz = n.size();
    if(n[sz-1] == 's')
        n += "es";
    else n += "s";
    cout <<n;
    return;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T = 1;
    //cin >> T;
    while(T--)
        solve();

    return 0;
}








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

int n, k,s, v[200005];
vector<int> b;
int main()
{
	int i, a;
	cin >> n >> k;
	for (i = 0; i < n; i++) {
		scanf ("%d", &a);
		v[a]++;
	}
	for (i = 0; i< 200002; i++) {
		if (v[i] > 0) b.push_back(v[i]);
	}
	sort(b.begin(), b.end());
	if (k < b.size()) {
		for (i = 0; i < b.size() - k; i++) s += b[i];
	}
	cout << s;
    return 0;
}


Measured memory_bytes: 2168
#include <stdio.h>

int main(){
    char str[15];
    char ans[15];
    scanf("%s", str);

    int j = 0;
    for (int i=0; str[i]!='\0'; i++){
        if (str[i] != 'B'){
            ans[j++] = str[i];
            // printf("%d = %c\n", j-1, ans[j-1]);
            if (str[i+1] == 'B'){
                j--;
            }
            ans[j] = '\0';
        }
        else{
            if (j >= 0){
                // printf("%d = null\n", j);
                ans[j] = '\0';
                if (str[i+1] == 'B'){
                    (j == 0) ? j = 0 : j--;
                }
            }
        }
        // printf("%d = %s\n", i+1, ans);
    } 
    printf("%s\n", ans);
    
    return 0;
}   


Measured memory_bytes: 1644
import sys
import copy
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n, t = na()
li = na()
ans = 0
for i in range(n - 1):
    if li[i + 1] - li[i] < t:
        ans += li[i + 1] - li[i]
    else:
        ans += t
ans += t
print(ans)

Measured memory_bytes: 27028
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std;
using namespace placeholders;

using LL = long long;
using ULL = unsigned long long;
using VI = vector< int >;
using VVI = vector< vector< int > >;
using VS = vector< string >;
using SS = stringstream;
using PII = pair< int, int >;
using VPII = vector< pair< int, int > >;
template < typename T = int > using VT = vector< T >;
template < typename T = int > using VVT = vector< vector< T > >;
template < typename T = int > using LIM = numeric_limits< T >;

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define NUMBERED( name, number ) NUMBERED2( name, number )
#define NUMBERED2( name, number ) name ## _ ## number
#define REP1( n ) REP2( NUMBERED( REP_COUNTER, __LINE__ ), n )
#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2, REP1 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &&e : c )
#define ALL( c ) begin( c ), end( c )
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + ( p ), ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

template < typename T > inline bool chmin( T &a, const T &b ){ if ( b < a ) { a = b; return true; } return false; }
template < typename T > inline bool chmax( T &a, const T &b ){ if ( a < b ) { a = b; return true; } return false; }

#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );
	cout << setprecision( 12 ) << fixed;

	int N, K;
	cin >> N >> K;

	VI counts( 256 );
	REP( N )
	{
		string s;
		cin >> s;
		++counts[ s[0] ];
	}

	priority_queue< int > que( begin( counts ) + 'A', begin( counts ) + 'Z' + 1 );

	int res = 0;
	while ( true )
	{
		VI nums;
		REP( K )
		{
			nums.PB( que.top() );
			que.pop();
		}

		if ( nums.back() == 0 )
		{
			break;
		}

		++res;
		for_each( ALL( nums ), [&]( const int a ){ que.push( a - 1 ); } );
	}
	cout << res << endl;

	return 0;
}


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

int main(){
  string s;
  cin >> s;
  string t = s;
  int n = s.size();
  reverse(s.begin(), s.end());
  for(int i = 0; i < n; i++){
    if(s[i] == 'b'){
      s[i] = 'd';
      continue;
    }
    else if(s[i] == 'd'){
      s[i] = 'b';
      continue;
    }
    else if(s[i] == 'p'){
      s[i] = 'q';
      continue;
    }
    else if(s[i] == 'q'){
      s[i] = 'p';
      continue;
    }
  }
  if(s == t) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> p;

int main(){
	int x,a,b;//x+a>b dangerous //x+a<=b safe// b<=a deliciou
	//b-a ga nannitigo ka wo arawasu
	cin>>x>>a>>b;
	if(b-a<=0){
		cout<<"delicious"<<endl;
	  }
	  else if(b-a>0&&b-a<=x){
		  cout<<"safe"<<endl;
		}
		else{
			cout<<"dangerous"<<endl;
		  }

  }


Measured memory_bytes: 256