akhauriyash/Code-Regression huggingface dataset:
from collections import deque

H, W = [int(i) for i in input().split()]
S = [list(input()) for _ in range(H)]

white = sum(s.count(".") for s in S)

S[0][0] = "_"
Q = deque([(0, 0, 1)])
while Q:
    h, w, count = Q.popleft()
    if (h, w) == (H - 1, W - 1):
        print(white - count)
        quit()

    for nh, nw in [(h, w + 1), (h, w - 1), (h + 1, w), (h - 1, w)]:
        if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == ".":
            S[nh][nw] = "_"
            Q.append((nh, nw, count + 1))
print(-1)


Measured memory_bytes: 39920
n = int(input())

max_n = 110000
dp = [n] * max_n
dp[0] = 0

for i in range(1, n+1):
    count6 = 1
    count9 = 1
    while count6 <= n:
        dp[i] = min(dp[i-count6] + 1, dp[i])
        count6 *= 6

    while count9 <= n:
        dp[i] = min(dp[i-count9] + 1, dp[i])
        count9 *= 9

print(dp[n])

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define int long long

int a[5010], n, k;
bitset<5010> dp1[5010], dp2[5010];
int solve(int mid){
	if(a[mid] >= k)return 1;
	bitset<5010> dp;
	dp = dp2[mid+1];
	for(int i = 1;i <= k;i++){
		if(dp1[mid-1][i] == 0)continue;
		dp = dp | dp2[mid+1]<<i;
	}
	dp[k] = 0;
	for(int i = k-1;i >= 1;i--)
	if(dp[i+1])dp[i] = 1;
	if(dp[k-a[mid]])return 1;
	return 0;
}

signed main(){
	scanf("%lld%lld", &n, &k);
	for(int i = 1;i <= n;i++)scanf("%lld", &a[i]);
	
	sort(a+1,a+n+1);
	dp1[0] = dp2[n+1] = 1;
	for(int i = 1;i <= n;i++){
		dp1[i] = dp1[i-1] | dp1[i-1]<<a[i];
	}
	for(int i = n;i >= 1;i--){
		dp2[i] = dp2[i+1] | dp2[i+1]<<a[i];
	}
	
	int lb = 0, ub = n+1;
	while(ub-lb > 1){
		int mid = (lb+ub)/2;
		int res = solve(mid);
		if(res)ub = mid;
		else lb = mid;
	}
	printf("%lld\n", ub-1);
	//for(int i = 1;i <= n;i++)cout << dp2[i] << endl;
	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>

using namespace std;

template<typename T>
vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init)
{ return vector< vector<T> >(rows, vector<T>(cols, init)); }

#define debug(x) cout << #x << "==" << x << endl;

const int inf = 100000000;

typedef long long ll;



int memo[1001][1001];
bool checked[1001][1001];
// Levenshtein Distance
int ld(string s, string t, int si, int ti) {
  if( si == -1 && ti == -1) {
    return 0;
  }
  if( si == -1 ) {
    return ld(s, t, si, ti-1) + 1;
  }
  if( ti == -1) {
    return ld(s, t, si-1, ti) + 1;
  }

  if( checked[si][ti] ) {
    return memo[si][ti];
  }
  checked[si][ti] = true;

  int r1 = ld(s, t, si-1, ti) + 1;  // s??????????????????
  int r2 = ld(s, t, si, ti-1) + 1;  // t??????????????????
  int r3 = ld(s, t, si-1, ti-1) + ( s[si] == t[ti] ? 0 : 1 ); // ???????????????????????????????????´?????????????????¨?????¨?????´??????????????´????????????

  int res = min(r1, min(r2, r3)  );

  return memo[si][ti] = res;

}


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

  string s, t;
  cin >> s >> t;

  int s_size = s.size();
  int t_size = t.size();

  // dp[i][j] := s1,..si ??¨ t1,..,tj ??? Edit Distance.
  // dp[0][0] = 0;
  // dp[i+1][j+1] =
  //   min(
  //     dp[i][j+1] + 1,  ?????????????????????
  //     dp[i+1][j] + 1,  ?????????????????????
  //     dp[i][j]  (+1 if s[i] != s[j]) ?????´???????????????????????????????????????????????????????????????
  //   )
  auto dp = make_2d_vector(s_size + 1, t_size + 1, -inf);

  for(int i = 0; i <= s_size; i++) { dp[i][0] = i; }
  for(int j = 0; j <= t_size; j++) { dp[0][j] = j; }

  for(int i = 0; i < s_size; i++) {
    for(int j = 0; j < t_size; j++) {
      dp[i+1][j+1] = min( dp[i][j] + ( s[i]==t[j] ? 0 : 1 ),
                          min( dp[i][j+1] + 1, dp[i+1][j] + 1 ) );
    }
  }

  cout << dp[s_size][t_size] << "\n";

  // cout << ld(s, t, s.size() - 1, t.size() - 1) << "\n";

  return 0;

}

Measured memory_bytes: 6840
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main {
    public static void main(String[] args) throws Exception{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line = br.readLine();
            int n = Integer.parseInt(line);
            int money = 100000;
            for(int i=0;i<n;i++){
            	money *= 1.05;
            	money = money % 1000 == 0 ? money : ((money / 1000) + 1) * 1000;
            }
            System.out.println(money);
    }
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(a - c) <= d) cout << "Yes" << endl;
    else if(abs(a - b) <= d && abs(b - c) <= d) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc128/tasks/abc128_d

import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    N, K = map(int, input().split())
    D = list(map(int, input().split()))

    ans = 0
    try_count = min(N, K)
    for a in range(try_count + 1):
        # print(a)
        b = 0
        while b <= try_count - a:
            can_discard = K - a - b
            # print('{} {} {}'.format(a, b, can_discard))
            gets = D[:a] + D[N - b:]
            # print(gets)
            gets.sort()

            while len(gets) > 0 and can_discard > 0:
                if gets[0] < 0:
                    gets.pop(0)
                    can_discard -= 1
                else:
                    break

            # print(gets)
            ans = max(ans, sum(gets))
            b += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41964
#include <cstdio>
#include <cstring>

const int N = 110;

char str[N], t[N];

int main() {
	int n;
	scanf("%d%s", &n, str);
	for (int i = 0; i < n / 2; ++i) {
		t[i] = str[i];
	}
	for (int i = n / 2; i < n; ++i) {
		t[i] = t[i - n / 2];
	}
	t[n] = '\0';
	strcmp(str, t) == 0 && !(n & 1) ? printf("Yes\n") : printf("No\n");
	return 0;
}

Measured memory_bytes: 128
a = input()
ans = "Yes"

char_list = list(a)
doubli = list(set(char_list))
#print(doubli)

for x in doubli:
    #print(char_list.count(x))
    if(char_list.count(x) % 2 == 1):
        ans = "No"
        break
print(ans)

Measured memory_bytes: 2940
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int h,w; cin >> h >> w;
    vector<vector<char> > s(h,vector<char>(w));
    for(int i = 0;i < h;i ++){
        for(int j = 0;j < w;j ++){
            cin >> s.at(i).at(j);
        }
    }
    int b = 0;
    for(int i = 0;i < h;i ++){
        for(int j = 0;j < w;j ++){
            if(s.at(i).at(j) == '.') b ++;
        }
    }

    b -= 2;

    vector<vector<int> > itta(h,vector<int>(w)),count(h,vector<int>(w));
    for(int i = 0;i < h;i ++){
        for(int j = 0;j < w;j ++){
            if(s.at(i).at(j) == '#'){
                itta.at(i).at(j) = 1;
            }
        }
    }

    itta.at(0).at(0) = 1;

    queue<int> qx,qy;
    qx.push(0);
    qy.push(0);
    vector<int> dx(4),dy(4);
    dx.at(0)=-1;
    dx.at(1)=0;
    dx.at(2)=1;
    dx.at(3)=0;
    dy.at(0)=0;
    dy.at(1)=1;
    dy.at(2)=0;
    dy.at(3)=-1;

    while(qx.size()>0){
        int x = qx.front();
        int y = qy.front();
        for(int i = 0;i < 4;i ++){
            if(0 <= x+dx.at(i) && x+dx.at(i)<h && 0 <= y+dy.at(i) && y+dy.at(i) < w){
                if(itta.at(x+dx.at(i)).at(y+dy.at(i)) == 0){
                    itta.at(x+dx.at(i)).at(y+dy.at(i)) = 1;
                    count.at(x+dx.at(i)).at(y+dy.at(i)) = count.at(x).at(y) +1;
                    qx.push(x+dx.at(i));
                    qy.push(y+dy.at(i));
                }
            }
        }

        qx.pop();
        qy.pop();
    }

    if(count.at(h-1).at(w-1) == 0) cout << -1 << endl;
    else cout << b - count.at(h-1).at(w-1) + 1 << endl; 

}


Measured memory_bytes: 256
import collections

n = int(input())
route = {i + 1 : {} for i in range(n)}
for i in range(n - 1):
    a, b, c = map(int, input().split())
    route[a][b] = c
    route[b][a] = c
q, k = map(int, input().split())
queue = collections.deque([k])
length = [0] * (n + 1)
while queue:
    search = queue.popleft()
    pairs = []
    for i, j in route[search].items():
        queue.append(i)
        length[i] = length[search] + j
        pairs.append([search, i])
    for i, j in pairs:
        del route[i][j]
        del route[j][i]
for i in range(q):
    x, y = map(int, input().split())
    print(length[x] + length[y])

Measured memory_bytes: 68740
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, i,result;
    list<int> A;

    cin >> n;

    for (int t = 0; t < n; t++)
    {
        cin >> i;
        A.insert(A.end(), i);
    }
    A.sort();

    result = abs(A.front() - A.back());

    cout << result << endl;

    return 0;
}

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

using namespace std;

int main(){
	
	int n;
	map<int , int> mp;
	cin >> n;
	
	for(int i = 0; i < n; i ++){
		int t;
		cin >> t;
		mp[t]++;
	}
	
	int fg = 0;
	for(auto it: mp){
		if(it.second >= 2){
			fg = 1;
			cout << "NO";
			break;
		}
	}
	
	if(!fg) cout << "YES";
	
	return 0;
}

Measured memory_bytes: 9600
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	//数値を文字列へ変換
	s := strconv.Itoa(n)
	
	//一文字ずつ分ける
	slice := strings.Split(s,"")
	
	for i:= 0; i < len(slice); i++ {
		if slice[i] == "1" {
			slice[i] = "9"
		} else if slice[i] == "9" {
			slice[i] = "1"
		}
	}
	//文字列を結合して数値に変換
	n, _  = strconv.Atoi(strings.Join(slice,""))
	
	fmt.Println(n)
}

Measured memory_bytes: 640
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const double INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

struct Point {double x,y;};
struct Line {double a,b,c;};
struct Circle {double r; Point p;};

//点と直線の符号付距離
double dist(Point p, Line l){
    return -(l.a*p.x+l.b*p.y+l.c)/sqrt(l.a*l.a+l.b*l.b);
}

//円と直線の交点
vector<Point> LCInter(Circle cir,Line l){
    vector<Point> res;
    double d=dist(cir.p,l);
    if(fabs(d)>cir.r) return res;
    double h=sqrt(cir.r*cir.r-d*d);
    Point H={d*l.a/sqrt(l.a*l.a+l.b*l.b)+cir.p.x,d*l.b/sqrt(l.a*l.a+l.b*l.b)+cir.p.y};
    res.push_back({H.x-h*l.b/sqrt(l.a*l.a+l.b*l.b),H.y+h*l.a/sqrt(l.a*l.a+l.b*l.b)});
    res.push_back({H.x+h*l.b/sqrt(l.a*l.a+l.b*l.b),H.y-h*l.a/sqrt(l.a*l.a+l.b*l.b)});
    return res;
}

//2円の交点
vector<Point> CCInter(Circle c1,Circle c2){
    Line l={2.0*(c1.p.x-c2.p.x),2.0*(c1.p.y-c2.p.y),
    -c1.p.x*c1.p.x-c1.p.y*c1.p.y+c2.p.x*c2.p.x+c2.p.y*c2.p.y+c1.r*c1.r-c2.r*c2.r};
    return LCInter(c1,l);
}

int N; vector<Point> p;
bool b(double r){
    rep(i,N){
        FOR(j,i+1,N){
            vector<Point> v=CCInter(Circle{r,p[i]}, Circle{r,p[j]});
            rep(k,SZ(v)){
                bool res=true;
                rep(l,N){
                    if(l==i || l==j) continue;
                    if((p[l].x-v[k].x)*(p[l].x-v[k].x)+(p[l].y-v[k].y)*(p[l].y-v[k].y)>r*r){
                        res=false;
                        break;
                    }
                }
                if(res) return true;
            }
        }
    }
    return false;
}

double BS(double l,double r){
    if(r-l<EPS) return r;
    double m=(l+r)/2.0;
    if(b(m)) return BS(l,m);
    else     return BS(m,r);
}

int main(){
    cin>>N; p.resize(N);
    rep(i,N) cin>>p[i].x>>p[i].y;
    printf("%.10lf\n",BS(0.0,INF));
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))


cnt = 0
for i in range(q):
    key = T[i]
    L = 0
    R = len(S)-1
    mid = (L+R) // 2

    while L <= R:
        if S[mid] == key:
            cnt += 1
            break
        elif S[mid] > key:
            R = mid - 1
        elif S[mid] < key:
            L = mid + 1
        mid = (L+R) // 2

print(cnt)


Measured memory_bytes: 16704
#1st: Code Festival 2015 Qualifying B (0408)
if False:
    N,M=map(int,input().split())
    A=[int(i) for i in input().split()]
    B=[int(i) for i in input().split()]
    A.sort()
    B.sort()
    ans='YES'
    if N<M:
        ans='NO'
    else:
        while B:
            a=A.pop()
            b=B.pop()
            if b>a:
                ans='NO'
                break
    print(ans)

#2nd: CF2014QA-C
if False:
    A,B=map(int,input().split())
    def uruu(n):
        ret=0
        ret+=n//4
        ret-=n//100
        ret+=n//400
        return ret
    print(uruu(B)-uruu(A-1))

#3rd: Code Formula 2014 - C
if False:
    S=input()
    stack=list(S[::-1])
    # print(stack)
    user=[]
    s=stack.pop()
    while stack:
        # print(s)
        if s=="@":
            tmp=''
            x=stack.pop()
            while not(x in ('@',' ')):
                # print(x)
                tmp+=x
                if not stack:
                    break
                x=stack.pop()
            user.append(tmp)
            s=x
        else:
            s=stack.pop()
    user=list(set(user))
    user.sort()
    for u in user:
        if u:
            print(u)

#4th: Hitachi Programming Contest 2020 - A    
if False: 
    S=input()
    hi=['hi'*i for i in range(1,10)]
    print('Yes' if S in hi else 'No')

#5th: Keyence Programming Contest 2019 - C
if True:
    N=int(input())
    A=[int(i) for i in input().split()]
    B=[int(i) for i in input().split()]
    S=list(zip(A,B))
    if sum(A)<sum(B):
        print(-1)
    else:
        C=[]
        for s in S:
            a,b=s
            if a<b: C.append(s)
        CA=sum(C[i][0] for i in range(len(C)))
        CB=sum(C[i][1] for i in range(len(C)))
        S.sort(key=lambda x: x[0]-x[1])
        while CA<CB:
            c,d=S.pop()
            CA+=c
            CB+=d
            C.append((c,d))
        print(len(C))






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

int main()
{
  int n, p, min, sum = 0;
  cin >> n;
  min = n + 1;
  for (int i = 0; i < n; i++)
  {
    cin >> p;
    if (p < min)
    {
      sum++;
      min = p;
    }
  }
  cout<<sum<<endl;
}


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

int W,H;
char table[60][60] ;
char d[] = { '+' , '-' };
int dx[] = {-1,0,1,0};
int dy[] = {0,-1,0,1};

void search( int x ,int y ,int c ){
	
	if( table[y][x] == 'W' || table[y][x] == 'B' ) return ;
	if( table[y][x] == '*' || table[y][x] == d[c]) return ;
	
	if( table[y][x] == d[(c+1)%2] ){
		table[y][x] = '*' ;
	}else {
		table[y][x] = d[c] ;
	}
	
	for( int k=0 ; k<4 ; k++ ){
		search( x+dx[k] , y+dy[k] , c );
	}
}

int main(){
	
	while( cin >> W >> H ){
		if( !W && !H ) break ;
		
		for( int i=0 ; i<=H+1 ; i++ ){
			for( int j=0 ; j<=W+1 ; j++ ){
				if( !i || !j || i==H+1 || j==W+1 ) table[i][j] = '*' ;
				else cin >> table[i][j] ;
			}
		}
		
		for( int i=1 ; i<=H ; i++ ){
			for( int j=1 ; j<=W ; j++ ){
				if( table[i][j] == 'W' || table[i][j] == 'B' ){
					for( int k=0 ; k<4 ; k++ ){
						search( j+dx[k] , i+dy[k] , (table[i][j]=='W')?0:1 );
					}
				}
			}
		}
		
		int ansW=0,ansB=0;
		for( int i=1 ; i<=H ; i++ ){
			for( int j=1 ; j<=W ; j++ ){
				if( table[i][j] == '+' ) ansW++;
				if( table[i][j] == '-' ) ansB++;
			}
		}
		
		cout << ansB << " " ;
		cout << ansW << endl;
	}
	
	return 0;
}

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


int main (){
    int L, M, N;
    cin>>L>>M>>N;
    int out=L*N-M;
    cout<<out<<endl;
    for(int i=0;i<9;i++){
        out=out*L-M;
        cout<<out<<endl;
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
const long long mod = 1e9 + 7;
 
long long n;
 
int main() {
  scanf("%lld", &n);
  
  long long sol = 1, a = 1, b = 1;
  
  for (int i = 0; i < n; i++) {
  	sol *= 10;
  	sol %= mod;
    a *= 9;
    a %= mod;
    b *= 8;
    b %= mod;
  }
  
  printf("%lld", (sol - 2 * a + b + 5 * mod) % mod);
  
  return 0;
}

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

int main() {
  int a, b, q;
  cin >> a >> b >> q;
  vector<long long int> A(a);
  vector<long long int> B(b);
  for(int i=0;i<a;i++) cin >> A[i];
  for(int i=0;i<b;i++) cin >> B[i];

  set<long long int> s(A.begin(), A.end());
  set<long long int> t(B.begin(), B.end());

  for(int i=0;i<q;i++) {
    long long int x;
    cin >> x;
    set<long long int>::iterator its = s.upper_bound(x);
    long long int s1;
    long long int s0;
    if(its == s.begin()) {
      s1 = *its;
      s0 = -2 * (long long int)pow(10, 10);
    } else if(its == s.end()) {
      s1 = 2 * (long long int)pow(10, 10);
      s0 = *prev(its, 1);
    } else {
      s1 = *its;
      s0 = *prev(its, 1);
    }
    set<long long int>::iterator itt = t.upper_bound(x);
    long long int t1;
    long long int t0;
    if(itt == t.begin()) {
      t1 = *itt;
      t0 = -2 * (long long int)pow(10, 10);
    } else if (itt == t.end()) {
      t1 = 2 * (long long int)pow(10, 10);
      t0 = *prev(itt, 1);
    } else {
      t1 = *itt;
      t0 = *prev(itt, 1);
    }
    vector<long long int> ans(4);
    ans[0] = abs(min(s0, t0) - x);
    ans[1] = abs(max(s1, t1) - x);
    if(min(s1, t1) == s1) ans[2] = s1 - x + s1 - t0;
    else ans[2] = t1 - x + t1 - s0;
    if(max(s0, t0) == s0) ans[3] = x - s0 + t1 - s0;
    else ans[3] = x - t0 + s1 - t0;

    cout << *min_element(ans.begin(), ans.end()) << endl;
  }
}

Measured memory_bytes: 12288
#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;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,C,K;
  cin >> N >> C >> K;
  vi ts(N);
  rep(i,N) {
    cin >> ts[i];
  }
  sort(rng(ts));
  int ans = 0;
  int l=0;
  rep(r,N) {
    if(r-l==C) {
      ans++;
      l=r;
      continue;
    }
    if(ts[l]+K>=ts[r]) {
      continue;
    }
    ans++;
    l=r;
  }
  if(l<N) {
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using ll = long long;

signed main(){
	ll K; std::cin >> K;
  ll now = 0, ans = -1;
  for(int i = 1; i <= 1e6 + 10; i++){
    now = now * 10 + 7;
    if(now % K == 0){
      ans = i;
      break;
    }
    now %= K;
  }
  std::cout << ans << std::endl;
}

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

int calc(int r, int D, int x, int count)
{
    if (count == 0)
    {
        return 0;
    }

    int nx = r * x - D;

    cout << nx << endl;

    return calc(r, D, nx, --count);
}

int main()
{
    int r, D, x;
    cin >> r >> D >> x;

    calc(r, D, x, 10);

    return 0;
}


Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    const int mod = 1e9 + 7;
    int n;
    string s;
    cin >> n >> s;
    map<char, int> m;
    rep(i, n) m[s[i]]++;
    ll ans = 1;
    
    for (auto x : m) {
        ans = ans * (x.second + 1) % mod;
    }
    
    cout << (ans - 1) << endl;
    return 0;
}

Measured memory_bytes: 512
# C
N = int(input())

if N == 0:
    print('0')
else:

    idx = 0
    while True:
        idx += 1
        left = sum([(-2)**i for i in range(idx+1) if i%2==1])
        right = sum([(-2)**i for i in range(idx+1) if i%2==0])
        if left <= N <= right:
            break

    max_idx = idx
    coeff = [0 for _ in range(max_idx+1)]
    for idx in range(max_idx, 0-1, -1):
        left = sum([(-2)**i for i in range(idx) if i%2==1])
        right = sum([(-2)**i for i in range(idx) if i%2==0])
#         print(left, N, right)
        if not left <= N <= right:
            N -= (-2)**(idx)
            coeff[idx] = 1
    #     print(N)
    # print(reversed(coeff)
    print(''.join(map(str, reversed(coeff))))

Measured memory_bytes: 3064
// AOJ 1182 Railway Connection
// 2018.2.22 bal4u
 
#include <stdio.h>
#include <string.h>

#define QMAX 10000
typedef struct { int t; int s; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define INF 0x10101010

int d[22][102][102];
int p[22], q[22][52], r[22][52];
int hi[250], to[102][250], w[102][250];
int dist[102];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	while (c <= ' ') c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int dijkstra(int s, int g)
{
	int i, e, d;

	memset(dist, INF, sizeof(dist));
	qsize = 0;
	enq(s, 0), dist[s] = 0;
	while (qsize) {
		s = que[0].s, deq();
		if (s == g) return dist[g];
		for (i = 0; i < hi[s]; i++) {
			e = to[s][i], d = dist[s] + w[s][i];
			if (d < dist[e]) dist[e] = d, enq(e, d);
		}
	}
	return -1;
}

int fare(int c, int dist)
{
	int i, pre, ans;

	ans = 0, pre = 0;
	for(i = 0; q[c][i] <= dist; i++) {
		ans += r[c][i] * (q[c][i] - pre);
		pre = q[c][i];
	}
	return ans + r[c][i] * (dist - pre);
}
	
int main()
{
	int N, M, C, S, G, i, j, k;
	int x, y, c, t;

	while (N = in()) {
		M = in(), C = in(), S = in()-1, G = in()-1;

		memset(d, INF, sizeof(d));
		for (c = 0; c < C; c++) for (i = 0; i < N; i++) d[c][i][i] = 0;

		for (i = 0; i < M; i++) {
			x = in()-1, y = in()-1, t = in(), c = in()-1;
			if (t < d[c][x][y]) d[c][x][y] = d[c][y][x] = t;
		}

		for (c = 0; c < C; c++) {
			for (k = 0; k < N; k++) for (i = 0; i < N; i++) for (j = 0; j < N; j++) {
				t = d[c][i][k] + d[c][k][j];
				if (t < d[c][i][j]) d[c][i][j] = t;
			}
		}

		for (c = 0; c < C; c++) p[c] = in();
		for (c = 0; c < C; c++) {
			for (i = 1; i < p[c]; i++) q[c][i] = in();
			q[c][p[c]] = INF;
			for (i = 1; i <= p[c]; i++) r[c][i] = in();
		}

		if (!M) { puts(S == G? "0": "-1"); continue; }

		memset(hi, 0, sizeof(hi));
		for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
			t = INF;
			for (c = 0; c < C; c++) if (d[c][i][j] < INF) {
				if (t > (k=fare(c, d[c][i][j]))) t = k;
			}

			if (t < INF) {
				k = hi[i]++, to[i][k] = j, w[i][k] = t;
				k = hi[j]++, to[j][k] = i, w[j][k] = t;
			}
		}
		printf("%d\n", dijkstra(S, G));
	}
	return 0;
}



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

#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define pb push_back
#define FR first
#define SC second
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000000
#define pll pair<ll, ll>
#define vl vector<ll>
#define vll vector< vl >
#define vb vector<bool>
#define vbb vector< vb >
#define vpl vector<pll>
#define vpll vector< vpl >

void solve()
{
	ll n, m ,k;
	cin>>n;
	vl sum(n), diff(n);
	for(ll i = 0; i < n; i++)
	{
	    ll x, y;
	    cin>>x>>y;
	    sum[i] = x + y;
	    diff[i] = x - y;
	}
	sort(all(sum));
	sort(all(diff));
	cout<<max(sum.back() - sum.front(), diff.back() - diff.front());
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll t = 1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 6312
import java.util.Arrays;
import java.util.Scanner;


public class Main {
    public static void main(String[] args){

        Scanner s = new Scanner(System.in);

        int standard = s.nextInt();
        long array[] = new long[standard];

        for (int i = 0; i < standard; i++) {
        	// Ai-iの計算
            array[i] = s.nextInt() - i - 1;
        }

        Arrays.sort(array);
        long median = 0;

//        //中央値算出
//        switch (array.length % 2) {
//         case 0:
          median = array[array.length/2];
//          break;
//         case 1:
//             median = array[array.length/2];
//          break;
//        }

        long ans = 0;
        for (int i = 0; i < standard; i++) {
            ans += Math.abs(array[i]-median);
        }

        System.out.println(ans);
    }
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    int k; cin >> k;
    vector<ll> a;
    // 1 ~ 9 までをいれる
    for(int i = 1; i <= 9; i++) a.push_back(i);
    while(1){
        // kに達してたら出力
        if(k <= a.size()){
            cout << a[k - 1] << endl;
            return 0;
        }
        // 1 ~ 9までの分は引いておく
        k -= a.size();
        vector<ll> old;
        swap(old, a);
        for(ll x : old){
            // 今の数字の末尾に-1, 0, +1のいずれか追加
            for(int i = -1; i <= 1; i++){
                // 末尾に付け足す数字を求める
                int d = x % 10 + i;
                // 0 ~ 9でなければスルー
                if(d < 0 || d > 9) continue;
                // 今の桁を繰り上げて末尾の数字を足す
                ll nx = x * 10 + d;
                a.push_back(nx);
            }
        }
    }
}


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

using namespace std;
#define taskname "A"
#define pb	push_back
#define mp 	make_pair
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)

#ifndef LOCAL
#define cerr if(0)cout
#endif

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
const int maxn = 2e5 + 6;

int n , a[maxn];

ll dp[maxn][2];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n;
    for(int i = 1 ; i <= n ; ++i)cin >> a[i];
    dp[0][1] = -(ll)1e18;
    for(int i = 1 ; i <= n ; ++i){
        if(i != n)dp[i][1] = max(dp[i - 1][0] - a[i] , dp[i - 1][1] + a[i]);
        dp[i][0] = max(dp[i - 1][0] + a[i] , dp[i - 1][1] - a[i]);
    }
    cout << dp[n][0];
}


Measured memory_bytes: 2176
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

const int mod = 1000000007;
int N; long long S[404],D[404][404];

int main()
{
	scanf ("%d",&N);
	for (int i=1;i<=N;i++) scanf ("%lld",&S[i]), S[i] += S[i-1];
	for (int l=2;l<=N;l++){
		for (int i=1,j=l;j<=N;i++,j++){
			D[i][j] = D[i][i] + D[i+1][j];
			for (int k=i;k<j;k++){
				if (D[i][j] > D[i][k] + D[k+1][j])
					D[i][j] = D[i][k] + D[k+1][j];
			}
			D[i][j] += S[j] - S[i-1];
		}
	}
	printf ("%lld\n",D[1][N]);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define int long long
using namespace std;
const string fix="2019/04/30";
const int yd[2]={365,366};
const int days[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31},{0,31,29,31,30,31,30,31,31,30,31,30,31}};
int is_leap(int y)
{
    return y%4==0 && y%100 || y%400==0;
}
int day_to_int(int y,int m,int d)
{
    int res=0,yy=is_leap(y);
    res+=y*365+(y-1)/4-(y-1)/100+(y-1)/400;
    for(int i=1;i<m;i++)res+=days[yy][i];
    return res+d-1;
}
int Date(string str)
{
	int y=0,m=0,d=0;
	int i=0;
	for(i=0;str[i]!='/';i++)y=y*10+str[i]-'0';
	for(i=i+1;str[i]!='/';i++)m=m*10+str[i]-'0';
	for(i=i+1;i<(int)str.size();i++)d=d*10+str[i]-'0';
	return day_to_int(y,m,d);
}
signed main()
{
	string str;
	cin>>str;
	cout<<((Date(str)<=Date(fix))?"Heisei":"TBD")<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,h[25],sum=1,wa;
  cin>>n;
  for(int i=0; i<n; i++){
    cin>>h[i];
  }
  for(int i=1; i<n; i++){
    wa=0;
    for(int j=0; j<i; j++){
      if(h[j]>h[i]){
	wa=1;
      }
    }
    if(wa==0){
      sum++;
    }
  }
  cout<<sum<<'\n';
  return 0;
}


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

int ctoi(const char c)
{
    if ('0' <= c && c <= '9')
        return (c - '0');
    return -1;
}

int main() {
    string n; cin >> n;
    int sum = 0;
    for (int i = 0; i < n.length(); i++)
    {
        sum += ctoi(n[i]);
    }
    if (sum % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3724
import java.util.Scanner;

public class Main {

	private static Scanner sc;

	public static void main(String[] args){
		sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		int a[][]=new int[n][m];
		int b[][]=new int[m][l];
		long c[][]=new long[n][l];

		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				a[i][j]=sc.nextInt();
			}
		}
		for(int i=0;i<m;i++){
			for(int j=0;j<l;j++){
				b[i][j]=sc.nextInt();
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<l;j++){
				for(int k=0;k<m;k++){
					c[i][j]+=a[i][k]*b[k][j];
				}
				System.out.print(c[i][j]);
				if(j!=l-1)System.out.print(" ");
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 53532
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
  const double PI=3.14159265358979;
  double inr=0,ind=0;
  double x=0,y=0;
  int degree=90;
  while(scanf("%lf,%lf",&inr,&ind) , inr||ind){
    y+=inr*sin(PI/180*degree);
    x+=inr*cos(PI/180*degree);
    degree-=ind;
  }
  x=(int)x;
  y=(int)y;
  cout<<x<<endl<<y<<endl;
  return 0;
}

Measured memory_bytes: 1284
from bisect import bisect_left

N = int(input())
A = sorted(list(map(int, input().split())))
flag = False
if A[-1] - A[0] == 0:
    a = A[0]
    if N == a + 1 or N >= 2 * a:
        flag = True
elif A[-1] - A[0] == 1:
    c = bisect_left(A, A[-1])
    if A[-1] > c and 2 * A[-1] - c <= N:
        flag = True
print("Yes" if flag else "No")

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

#define all(x) (x).begin(), (x).end()
#define itn int
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

int main() {
	int n = nxt(), x = nxt();
	vector<int> b(n), l(n), r(n);
	for (int i = 0; i < n; ++i) {
		b[i] = nxt(), l[i] = nxt(), r[i] = nxt();
	}

	long long cur = 0;
	for (int i = 0; i < n; ++i) {
		cur -= 1ll * l[i] * b[i];
	}

	vector<pair<long long, int>> can(n);
	for (int i = 0; i < n; ++i) {
		can[i] = {1ll * r[i] * (x - b[i]) + 1ll * l[i] * b[i], i};
	}
	sort(all(can));
	vector<int> c(n);
	long long ans = 0;
	while (!can.empty() && cur + can.back().first <= 0) {
		cur += can.back().first;
		c[can.back().second] = x;
		ans += x;
		can.pop_back();
	}

	long long tmp = x;
	for (int i = 0; i < n; ++i) {
		if (c[i]) {
			continue;
		}
		if (1ll * r[i] * (x - b[i]) + 1ll * l[i] * b[i] + cur < 0) {
			continue;
		}
		if (cur + 1ll * b[i] * l[i] >= 0) {
			tmp = min(tmp, (-cur + l[i] - 1) / l[i]);
		} else {
			tmp = min(tmp, b[i] + (-cur - l[i] * 1ll * b[i] + r[i] - 1) / r[i]);
		}
	}
	if (cur >= 0) {
		tmp = 0;
	}
	if (!can.empty()) {
		cur += can.back().first;
		c[can.back().second] = x;
		for (int i = 0; i < n; ++i) {
			if (!c[i]) {
				continue;
			}
			cur -= 1ll * r[i] * (x - b[i]) + 1ll * l[i] * b[i];
			if (1ll * r[i] * (x - b[i]) + 1ll * l[i] * b[i] + cur < 0) {
				continue;
			}
			if (cur + 1ll * b[i] * l[i] >= 0) {
				tmp = min(tmp, (-cur + l[i] - 1) / l[i]);
			} else {
				tmp = min(tmp, b[i] + (-cur - l[i] * 1ll * b[i] + r[i] - 1) / r[i]);
			}
			cur += 1ll * r[i] * (x - b[i]) + 1ll * l[i] * b[i];
		}
	}

	cout << ans + tmp << "\n";

	return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>

int main(void){
  int N;
  int count = 0;
  int i;
  int number;
  int max = 0;
  int maxnumber = 1;
  int num;

  scanf("%d",&N);

  for(i=1;i<=N;i++){

    number = i;
    num = i;
    while(1){
      if(number%2 != 0)break;
      number = number/2;
      count++;
    }

    if(max<count){max=count;maxnumber=num;}
    count = 0;

  }

  printf("%d\n",maxnumber);


  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
struct Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
        ll a, b, c;
        in >> a >> b >> c;
        out << min(a + c, min(a + b, b + c)) << endl;
    }
};
void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,M;
	cin >> N >> M;
	vector<ll> a(N);
	rep(i,N)cin >> a[i];
	rep(i,N){
		if(i==0)a[i] = a[i];
		else a[i] += a[i-1];
		a[i]%=M;
	}
	sort(ALL(a));
	ll ans = 0;
	rep(i,N){
		ll cnt = 1;
		if(a[i]==0)ans++;
		while(a[i]==a[i+1] &&i+1<N){
			i++;
			cnt++;
			if(a[i]==0)ans++;
		}
		ans += cnt*(cnt-1) /2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
  int weight;
  int hundou[10]={1,2,4,8,16,32,64,128,256,512};
  while(cin>>weight){
    int point[10]={};
    for(int i=9;i>=0;i--){
      if(weight>=hundou[i]){
	weight-=hundou[i];
	point[i]=1;
      }
    }

    int maxpointer=0;
    for(int i=0;i<10;i++){
      if(point[i])
	maxpointer=i;
    }

    for(int i=0;i<=maxpointer;i++){
      if(point[i]){
	cout<<hundou[i];
	if(i!=maxpointer)
	  cout<<" ";
      }
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    ll X, Y;
    cin >> X >> Y;
    if(X % Y == 0) {
        cout << -1 << "\n";
        return 0;
    } else
        cout << X << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n, a, b;
  cin >> n >> a >> b;
  vector<ll> x(n);
  rep(i,n) cin >> x[i];
  ll ans = 0;
  rep(i,n-1) {
    if ((x[i+1]-x[i])*a > b) {
      ans += b;
    }
    else {
      ans += (x[i+1]-x[i])*a ;
    }
  }
  cout << ans << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 4028
#include <iostream>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main(){
	string s[3];
	while(1) {
		cin >> s[0];
		if(s[0] == "0") break;
		rep2(i,1,3) {
			cin >> s[i];
		}
		rep(i,3) {
			int a = 0, b = 0;
			rep2(j,1,s[i].size()) {
				if(s[i][j] == 'A') a++;
				else b++;
			}
			if(a>b) a++;
			else b++;
			cout << a << " " << b << endl;
		}
	}
   return 0;
}

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

int main()
{
	int N;
	int A[200000];
	string output = "YES";

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

	sort(A, A+N);

	for(int i=1; i<N; i++){
		if(A[i-1] == A[i]){
			output = "NO";
			break;
		}
	}

	cout << output;

	return 0;
}

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

int main(int argc, char const *argv[])
{
	int n,k;
	cin>>n>>k;
	map<int,int> mp;
	int a;
	for (int i = 0; i < n; ++i)
	{
		cin>>a;
		++mp[a];
	}
	vector<int> memo;
	for (auto i = mp.begin(); i != mp.end(); ++i)
	{
		memo.push_back(i->second);
	}
	sort(memo.begin(), memo.end());
	reverse(memo.begin(), memo.end());
	int ans=n;
	for (int i = 0; i < k; ++i)
	{
		ans-=memo[i];
		if (ans==0)
		{
			cout<<"0\n";
			return 0;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 10748
# 参考

import numpy

H, W = map(int, input().split())
values = [None] * H

for y in range(H):
    values[y] = [0 if v == "#" else H + W for v in input()]
values = numpy.array(values)

for x in range(W - 1):
    values[:, x + 1] = numpy.minimum(values[:, x] + 1, values[:, x + 1])

for x in range(W - 1, 0, -1):
    values[:, x - 1] = numpy.minimum(values[:, x] + 1, values[:, x - 1])

for y in range(H - 1):
    values[y + 1, :] = numpy.minimum(values[y, :] + 1, values[y + 1, :])

for y in range(H - 1, 0, -1):
    values[y - 1, :] = numpy.minimum(values[y, :] + 1, values[y - 1, :])

print(numpy.max(values))

Measured memory_bytes: 60408
#include <stdio.h>

int linearsearch(int *,int,int);

int main(){
  int i,num1,num2,array[10001],key,count=0;
  scanf("%d",&num1);
  for(i=0;i<num1;i++) scanf("%d",&array[i]);

  scanf("%d",&num2);
  for(i=0;i<num2;i++){
    scanf("%d",&key);
    if(linearsearch(array,num1,key)==1) count++;
  }
  printf("%d\n",count);
  return 0;
}

int linearsearch(int *array,int num1,int key){
  int i=0;
  array[num1]=key;
  while(array[i]!=key) i++;
  if(i!=num1) return 1;
  else return 0;
}



Measured memory_bytes: 2052
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cstring>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

ll n,m;
ll p[100005]={};
ll ans=0;

int main()
{
    while(1){
        cin >> n >> m;
        if(n==0&&m==0)return 0;
    
        for (int i = 0; i < n; i++) {
            cin >> p[i];
        }

        sort(p,p+n);
        reverse(p,p+n);

        for(int i=0; i<n; i++){
            if(i%m!=m-1)ans+=p[i];
        }
        cout<<ans<<endl;
        ans=0;
    }
}

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

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

  int n, k;
  cin >> n >> k;

  int ans = 1;
  for (int i = 0; i < n; i++) {
    int a = ans * 2;
    int b = ans + k;

    ans = min(a, b);
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
    stack<int> S;
    string s;
    int lhs;
    int rhs;

    while(cin >> s) {
        if(s == "+") {
            rhs = S.top();
            S.pop();
            lhs = S.top();
            S.pop();
            S.push(lhs + rhs);
        } else if (s == "-") {
            rhs = S.top();
            S.pop();
            lhs = S.top();
            S.pop();
            S.push(lhs - rhs);
        } else if (s == "*") {
            rhs = S.top();
            S.pop();
            lhs = S.top();
            S.pop();
            S.push(lhs * rhs);
        } else {
            S.push(atoi(s.c_str()));
        }
    }
    cout << S.top() << endl;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<double> X(N, 0);
  double sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> X.at(i);
    sum += X.at(i);
  }
  
  int P = round(sum/N);
  
  double result = 0;
  for (int i = 0; i < N; i++) {
	result += (X.at(i) - P) * (X.at(i) - P);
  }
  
  cout << result;
}

Measured memory_bytes: 256
#include<iostream>
#include<float.h>
#include<cfloat>
#include<string>
#include<ctype.h>
#include<algorithm>
#include<errno.h>
#include<cerrno>
#include<assert.h>
#include<cassert> 
#include<map>
#include<memory.h>
#include<cctype>
#include<ctype.h>
#include<math.h>
#include<vector> 
#include<cstdio> 
#include<set>
#include<string.h>
#include<stdio.h>
#include<new>
#include<memory>
#include<cmath>
#include<queue>
#include<cstring>
#define ll long long
#define fo(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define br break
#define ct continue
#define pb push_back
#define mp make_pair 
#define pi 3.141592653589793238462643383279502884197169
#define F first
#define S second
#define pii pair<int,int>  
#define em empty()
#define vei vector<int>
#define ves vector<string>
#define qui queue<int> 
#define qu queue
using namespace std;
int a[250];
int main()
{int n;
 cin>>n;
 int ans=0;
 fo(i,0,n*2)
 cin>>a[i];
 sort(a,a+2*n);
 for(int i=0;i<2*n;i+=2)
 ans+=a[i];
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int n;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  cout << n/2*(n-n/2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int ans(int x,int y,int z){
  if(y==0)
    return x+z;
  else
    return x-z;
}
char pm(int y){
    if(y==0)
    return '+';
  else
    return '-';
}
  

int main() {
  string S;
  cin >> S;
  vector<int> T(4),A(4);
  for(int i=0; i<4; i++){
  T.at(i) = char(S.at(i)-'0');
  }
  
  for (int tmp = 0; tmp < (1 << 3); tmp++) {
  bitset<3> op(tmp); 
    A.at(0) = T.at(0);
    for(int j=0; j<3; j++){
      A.at(j+1) = ans(A.at(j), op[j], T.at(j+1));
  	}
    if(A.at(3)==7){
    cout << S.at(0) << pm(op[0])
         << S.at(1) << pm(op[1])
         << S.at(2) << pm(op[2])
         << S.at(3) << "=7" << endl;
	break;
  }
  }
  return 0;
} 
    
    

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
string s, tmp;
int cnt;

int main(){
	cin >> s;
	
	for(int i=1;i<s.size();++i){
		if(s[i] != s[i-1]) ++ cnt;
	}
	
	printf("%d\n", cnt);
}

Measured memory_bytes: 3868
import sys
A, B, C, D = map(int, sys.stdin.readline().split())
T = 0
O = 0
while C > 0:
    C = C - B
    T += 1

while A > 0:
    A = A - D
    O += 1

if T <= O:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9056