akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

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

int main()
{

    string N;

    cin >> N;

    long long sum = 0;

    for (long long i = 0; i < N.length(); i++)
    {
        sum += ctoi(N[i]);
        // std::cout << ctoi(N[i]) << std::endl;
        // std::cout << N[i] << std::endl;
    }

    // std::cout << sum << std::endl;
    if (sum % 9 == 0)
        std::cout << "Yes" << std::endl;
    else
    {
        std::cout << "No" << std::endl;
    }
}

Measured memory_bytes: 3696
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  ll n,c,k;
  cin >> n >> c >> k;
  vector<ll>t(n);
  rep(i,n) cin >> t.at(i);
  sort(t.begin(),t.end());
  ll num = t.at(0);
  ll hito = 1;
  ll cnt = 0;
  if(c == 1){
    cout << n << endl;
  }
  else{
  for(int i=0;i<n-1;){
    if(t.at(i+1) - num <=k){
      i++;
      hito++;
    }
    else{
      i++;
      cnt++;
      hito = 1;
      num = t.at(i);
    }
    if(hito == c){
      i++;
      if(i >= n) break;
      cnt++;
      hito = 1;
      num = t.at(i);
    }
  }
  cout << cnt + 1 << endl;
  }
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
int gt[210][210];
int gcd(int a,int b)
{
    return b>0?gcd(b,a%b):a;
}
int main(void)
{
    sync;
    int k;
    cin>>k;
    for(int i=1;i<=k;++i)
        for(int j=i;j<=k;++j)
            gt[i][j]=gt[j][i]=gcd(i,j);
    ll res=0;
    for(int i=1;i<=k;++i)
        for(int j=1;j<=k;++j)
            for(int l=1;l<=k;++l)
                res+=gcd(i,gt[j][l]);
    cout<<res<<endl;
    return 0;
}

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

int main(){
int n;
cin>>n;
    string s1,s2;
    cin>>s1>>s2;
int i,j,k,a=1,b=1;
string m="";
for(i=0,j=0,k=0;i<2*n;i++)
{
    if(a==1)
    {
       /// cout<<"m="<<m<<endl;
        m=m+s1[j];
        j++;
        a=0;
        b=1;
    }
    else if(b==1)
    {
       /// cout<<"m="<<m<<endl;
        m=m+s2[k];
        k++;
        b=0;
        a=1;
    }
}
cout<<m<<endl;
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private int N, K;
    private int[] A;
    private void Scan()
    {
        var line = Console.ReadLine().Split(' ');
        N = int.Parse(line[0]);
        K = int.Parse(line[1]);
        A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }


    public void Solve()
    {
        Scan();
        var a = new long[N];
        var b = new long[N];
        long bSum = 0;
        long aSum = 0;
        for (int i = 0; i < N; i++)
        {
            aSum += A[i];
            bSum += Math.Max(0, A[i]);
            a[i] = aSum;
            b[i] = bSum;
        }
        long ans = 0;
        for (int i = 0; i <= N - K; i++)
        {
            long q = 0;
            long w = a[i + K - 1];
            long e = b[N - 1] - b[i + K - 1];

            if (i > 0)
            {
                q = b[i - 1];
                w -= a[i - 1];
            }
            //Console.WriteLine($"{i} {q} {w} {e}");
            ans = Math.Max(q + e + Math.Max(0, w), ans);
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 31580
import java.math.BigInteger;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        long x = scanner.nextLong(), y = scanner.nextLong();
        System.out.println(BigInteger.valueOf(Long.highestOneBit(y / x)).bitLength());
    }
}

Measured memory_bytes: 23124
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int res[10][2000];

int main() {
	int n;
	while(n=in()){
		int i;
		int a,b;
		memset(res,0,sizeof(res));
		res[0][0]=1;
		for(i=0;i<n;i++){
			cin>>a>>b;
//cout<<"piyo"<<endl;
			int j,k;
			for(j=0;j<=1000;j++){
//cout<<i<<" "<<j<<endl;
				for(k=0;k<=b;k++){
					if(0>j-a*k)break;
					res[i+1][j]+=res[i][j-a*k];
				}
			}
		}
//cout<<"hoge"<<endl;
		int m=in();
		for(i=0;i<m;i++){
			int j;
			cin>>j;
			cout<<res[n][j]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
 
 
void swap (int *x, int *y) {
  int temp;    
 
  temp = *x;
  *x = *y;
  *y = temp;
}
 
int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }
 
  if(b==0){
    return a;
  }
 
  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }
 
  return b;
}
 
/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}
 
 
int modpow(int a,int n,int mod){
  int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}
 
int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}
 
int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}
 
void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }
 
  return;
}
 
void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }
 
  return;
}
 

int main(void){
  long int n,a,b;
  scanf("%ld%ld%ld",&n,&a,&b);
  long int count;
  long int mod;
  long int ans=0;
  if(a+b==0){
    count=1;
    mod=0;
  }else{
    count=(n+a+b-1)/(a+b);
    mod=n%(a+b);
  }
  ans=(count-1)*a;
  if(mod==0 || a<=mod){
    ans+=a;
  }else{
    ans+=mod;
  }
  printf("%ld\n",ans);
  return 0;
}

Measured memory_bytes: 1720
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let A: i32 = read();
    let B: i32 = read();
    let C: i32 = read();
    let X: i32 = read();

    let mut ans: i32 = 0;

    for i in 0..A+1 {
        for j in 0..B+1 {
            for k in 0..C+1 {
                if(500*i + 100*j + 50*k == X) {
                    ans += 1;
                }
            }
        }
    }

    println!("{}", ans);
}


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

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

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

    long count = 0;
    for (int i = 0; i < N; i++) {
        // A[i]対B[i]
        if (A[i] >= B[i]) {
            count += B[i];
        }
        else {
            count += A[i];
            // A[i+1]対(B[i]-A[i])
            if (A[i+1] >= B[i]-A[i]) {
                count += B[i]-A[i];
                A[i+1] -= B[i]-A[i];
            }
            else {
                count += A[i+1];
                A[i+1] = 0;
            }
        }
    }
    cout << count << endl;
}


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

#define ll long long
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

// n ^ r % m
template <typename T> T mod_pow(T n, T r, T m)
{
	T ret = 1;
	T tmp = n;
	
	while(r != 0) {
		if(r % 2) {
			ret *= tmp;
		}
		tmp *= tmp;
		tmp %= m;
		ret %= m;
		r /= 2;
	}
	return ret;
}

// フェルマーの小定理より X / Y %MOD == X * Y^(MOD-2) %MOD
template <typename T> T mod_inv (T a, T m)
{
	return mod_pow(a, m - 2, m);
}

// a / b / m (m == MODとか)
template <typename T> T mod_div (T a, T b, T m)
{
	return a * mod_inv(b, m) % m;
}

// (a - b)%MOD
template <typename T> T mod_sub (T a, T b, T m)
{
	return (a < b) ? m + a - b : (a - b) % m;
}

int main()
{
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans = 0;
    ans = mod_pow((ll)2,n,MOD) - 1;

    ll div_a = 1;
    ll div_b = 1;
    ll key_a = a;
    ll key_b = b;
    if( key_a > n/2) key_a = n - key_a;

    if( key_b > n/2) key_b = n - key_b;

    
    ll tmp = 1;
    rep(i,max(key_a,key_b))
    {
        tmp = tmp*(n-i)%MOD;
        tmp = mod_div(tmp, (ll)i+1, MOD);
        if( (i+1) == key_a )
        {
            div_a = tmp;
        }
        if( (i+1) == key_b )
        {
            div_b = tmp;
        }
    }
        
    ans = mod_sub(ans, div_a, MOD);
    ans = mod_sub(ans, div_b, MOD);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll MOD =  1000000007;
const ll INF =  1LL << 60;
ll n, m, x, y,z,w,h, sum= 0, ans;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
template <typename T>
struct BIT {
    int n;             // 要素数
    vector<T> bit[2];  // データの格納先
    BIT(int n_) { init(n_); }
    void init(int n_) {
        n = n_ + 1;
        for (int p = 0; p < 2; p++) bit[p].assign(n, 0);
    }
    void add_sub(int p, int i, T x) {
        for (int idx = i; idx < n; idx += (idx & -idx)) {
            bit[p][idx] += x;
        }
    }
    void add(int l, int r, T x) {  // [l,r) に加算
        add_sub(0, l, -x * (l - 1));
        add_sub(0, r, x * (r - 1));
        add_sub(1, l, x);
        add_sub(1, r, -x);
    }
    T sum_sub(int p, int i) {
        T s(0);
        for (int idx = i; idx > 0; idx -= (idx & -idx)) {
            s += bit[p][idx];
        }
        return s;
    }
    T sum(int i) { return sum_sub(0, i) + sum_sub(1, i) * i; }
};
int main(void) {
    cin >> n >> m; BIT<ll> b(n);
    rep(i, m) {
        cin >> x;
        if (x == 0) {
            cin >> y >> z >> w;
            b.add(y, z+1, w);
        }
        else {
            cin >> y >> z;
            cout << b.sum(z) - b.sum(y - 1) << endl;
        }
    }
}


Measured memory_bytes: 4376
n = int(input())
li = list(map(int,input().split()))
new_li = []
for l in li:
    new_li.append(l-1)
    new_li.append(l)
    new_li.append(l+1)
import collections
c = collections.Counter(new_li)
print(c.most_common()[0][1])

Measured memory_bytes: 72900
from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

inf = 10 ** 9 + 7

cnt = [0] * 60

for a in A:
    s = bin(a)[2:].zfill(60)
    s = s[::-1]
    for i in range(60):
        if s[i] == '1':
            cnt[i] += 1

ans = 0
for i in range(60):
    ans += (cnt[i] * (N - cnt[i])) * (2 ** i)
    ans %= inf

print(ans)


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

using namespace std;

int solve(vector<int> &v)
{
	sort(v.begin(), v.end());
	if (v[1] == v[2]) {
		int d = v[1] - v[0];
		return (d + 1) / 2 + d % 2;
	}
	else {
		int d = v[2] - v[1];
		v[0] += d;
		v[1] += d;
		return d + solve(v);
	}
}

int main()
{
	vector<int> v(3);
	for (auto &x : v) {
		cin >> x;
	}
	cout << solve(v) << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

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

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

void run(){
    string s;
    cin>>s;
    stack<char> st;
    rep(i,s.length()){
        if(st.empty()||st.top()==s[i])st.push(s[i]);
        else st.pop();
    }
    cout<<s.length()-st.size()<<endl;
}

Measured memory_bytes: 512
"use strict";

function main(input) {
  input = input
    .split(/\n|\s/)
    .map(v => ~~v)
    .slice(1, -1);

  input.sort((a, b) => {
    return b - a;
  });

  let prev = 0;
  let ans = 0;

  for (let i = 0; i < input.length; i++) {
    if (i === 0 || input[i] < prev) ans++;
    prev = input[i];
  }

  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define f1 first
#define s2 second
#define pb push_back
#define mp make_pair
#define ll long long
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);
const ll N = 2e5+5;

ll n,h[N],val[N],dp[N],seg[4*N],ans;

ll qmax(ll v,ll tl,ll tr,ll l,ll r){
	if(l>r){
		return -1;
	}
	else if(l==tl && tr==r){
		return seg[v];
	}
	ll mid=(tl+tr)/2;
	return max(qmax(v*2,tl,mid,l,min(r,mid)),qmax(v*2+1,mid+1,tr,max(l,mid+1),r));
}

void update(ll v,ll tl,ll tr,ll idx,ll val){
	//if(idx<tl || idx>tr)return;
	if(tl==tr){
		seg[v]=val;
		return;
	}
	else{
		ll mid=(tl+tr)/2;
		if(idx<=mid){
			update(v*2,tl,mid,idx,val);
		}
		else update(v*2+1,mid+1,tr,idx,val);
	}
	seg[v]=max(seg[v*2],seg[v*2+1]);
}

int main(){
	//fri("in.txt");
	//fro("out.txt");
	cin>>n;
	for(ll i=0;i<n;i++)cin>>h[i];
	for(ll i=0;i<n;i++)cin>>val[i];
	for(ll i=n-1;i>=0;i--){

		dp[i]=qmax(1,1,n,h[i],n)+val[i];
		update(1,1,n,h[i],dp[i]);

		//cout<<h[i]<<" "<<dp[i]<<endl;
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 11136
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<ll, ll> P;
typedef pair<double, double >pd;
typedef pair<string, string> sP;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 5e14;
const double eps = 1e-10;
const double PI = acos(-1);
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second


ll n;

int main() {
	cin >> n;
	for (int i = 0;i < 100;i++) {
		for (int j = 0;j < 100;j++) {
			if (i * 4 + j * 7 == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O30")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << x << "\n")
using ll = uint16_t; using ld = long double; using namespace std;

#ifndef __GNUC__
string text =
R"X(
8
7 3 5 4 2 1 6 8
3 8 2 5 4 6 7 1
)X";
stringstream iss{text};
#endif

class CountOrder
{
	ll N{0};
	vector<ll> p, q;
	void inp( ) {
		iss >> N; p.resize(N); q.resize(N);
		rep(n, N) { iss >> p[n]; }
		rep(n, N) { iss >> q[n]; }
		//for_each(begin(p), end(p), [](auto x) { cout << x << "\n"; });
	}
	void change( ) {
		long long sa{0};
		auto it0{begin(p)}, it1{end(p)};
		if (p > q) { it0 = begin(q); it1 = end(q); }
		do {
			if (p == q) break;
			++sa;
		} while (next_permutation(it0, it1));
		p(sa);
	}
public:
	void procedures( ) {
		inp( );
		change( );
	}
};
//https://atcoder.jp/contests/abc145/tasks/abc145_c
int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	class CountOrder a; a.procedures( );
}

Measured memory_bytes: 3680
import java.util.Scanner;

   class Main{
      public static void main(String args[]){
         Scanner scan = new Scanner(System.in);
         String  str  = scan.nextLine();

            for(int i =0;i< str.length();i++){

               int c=str.charAt(i);

               if('a'<=c&&c<='z'){
                  c+='A'-'a';
               } else if ('A'<=c&&c<='Z'){
                  c-='A'-'a';
               }

               System.out.print((char)c);

            }

             System.out.println();

      }
   }


Measured memory_bytes: 26636
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
const ll M = 1000000007;

ll length(ll z[100010], int k) {
  ll ans = 0;
  for (ll i = 0; i < k-1; ++i) {
    ll cnt = ((i+1) * (k-1-i))%M;
    ans += (cnt * (z[i+1] - z[i])) %M;
    ans %= M;
  }
  return ans;
}

int n, m;
ll x[100010], y[100010];

int main () {
  cin >> n >> m;
  for (auto i = 0; i < n; ++i) {
    cin >> x[i];
  }
  for (auto i = 0; i < m; ++i) {
    cin >> y[i];
  }
  cout << (length(x, n) * length(y, m)) % M << endl;
}


Measured memory_bytes: 1792
n,c,k=map(int,input().split())

cnt=0


time=[]
for _ in range(n):
    time.append(int(input()))


time.sort()

count_up=0
member=0
cnt=0

temp=[]

for t in time:
    if count_up==0:
        count_up=t

    if t>count_up+k:
        #print(temp)
        cnt+=1
        count_up=t
        member=1
        temp=[t]
    else:
        member+=1
        temp.append(t)
        if member>=c:
            #print(temp)
            member=0
            cnt+=1
            count_up=0
            temp=[]

if member>0:
    cnt+=1
    #print(temp)

print(cnt)
    






Measured memory_bytes: 50520
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace LogicSummoner
{
    class Program
    {
        static void Main(string[] args)
        {
            var nums = GetNumbersInt();
            var a = nums[0];
            var b = nums[1];
            var max = Math.Max(a, b);
            var min = Math.Min(a, b);
            while (true)
            {
                var r = max % min;
                if (r == 0)
                {
                    Console.WriteLine(min);
                    break;
                }
                max = min;
                min = r;
            }
        }

        //static StreamReader Console = new StreamReader("input.txt");

        static int GetNumber()
        {
            return int.Parse(Console.ReadLine().Trim());
        }

        static double GetDounble()
        {
            return double.Parse(Console.ReadLine().Trim());
        }

        static int[] GetNumbersInt(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static long[] GetNumbersLong(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToArray();
        }

        static double[] GetNumbersDouble(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => double.Parse(x)).ToArray();
        }

        static string[] GetStrings(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToArray();
        }
    }
}

Measured memory_bytes: 10076
N, A = gets.split.map(&:to_i)
XS = gets.split.map(&:to_i).map{|e|e-A}.sort
@dp = {}
def solve(i, s)
  return 0 if i == N
  return @dp["#{i}-#{s}"] if @dp["#{i}-#{s}"]
  @dp["#{i}-#{s}"] = solve(i+1, s) + solve(i+1, s+XS[i]) + (s+XS[i] == 0 ? 1 : 0)
end

puts solve(0,0)


Measured memory_bytes: 5244
#include <iostream>

#include <algorithm>
#include <map>
#include <set>

using namespace std;

#define int unsigned long long

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

	int n;
	cin >> n;
	map<int, int> m;
	set<int> tree;
	//m.reserve(1000000);

	int x;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		if (m.find(x) == m.end())
		{
			m[x] = 1;
			continue;
		}
		else {
			++m[x];
			tree.insert(x);
		}
	}

	if (tree.empty() || m.size() < 2)
	{
		cout << 0 << endl;
		return 0;
	}
	auto sitr = tree.end();
	sitr--;
	if (m[*sitr] >= 4)
	{
		cout << *sitr * *sitr << endl;
		return 0;
	}


	cout << *sitr * *(--sitr) << endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef long double ld;
const double E = 1e-7;
const ll INF = 1e17;
#define forn(i, s, f) for (int i = s; i < f; ++i)
#define ft first                                                 
#define sec second
#define fora(i, n) for (auto i : n)
#define sz(a) (int)(a).size()
#define sort_(a) sort(a.begin(), a.end())
#define pb push_back
#define mp make_pair
#define rsort_(a) sort(a.begin(), a.end()); reverse(a.begin(), a.end())
#define fast_ cin.tie(0), ios_base::sync_with_stdio(false)
// ____________________________________________________________
#define cina(a) forn(i,0,sz(a)) cin >> a[i]
#define cinpr(a) cin >> a.ft >> a.sec 
//--------------------------------------------------------------
 
int main() {
    int n; cin >> n;
    vector<char> a(n);
    forn(i,0,n) cin >>a[i];
    int cnt = 0; 
    forn(i,0,n) {
        if (a[i] == 'R') cnt++;
    }
    int cnt2 = 0;
    forn(i,0,cnt) if (a[i] == 'R') cnt2++;
    cout << cnt - cnt2;
}

Measured memory_bytes: 3628
import sys


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    n, k = _ia()
    a = list(_ia())
    return "\n".join(map(lambda x: "Yes" if x > 0 else "No",
                         (a[k+i] - a[i] for i in range(n-k))))


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 108956
def resolve():
    N, K, Q = list(map(int, input().split()))
    A = [int(input()) for _ in range(Q)]
    points = [0 for _ in range(N)]
    for a in A:
        points[a-1] += 1
    for p in points:
        print("Yes" if Q-K<p else "No")


    
if '__main__' == __name__:
    resolve()

Measured memory_bytes: 85404
#include<cstdio>
#include<algorithm>
#include<cmath>
const int maxn = 1e5 + 5;
using namespace std;

long long a,ans;

int main(){
	scanf("%lld", &a);
	for(long long i = 2; i <= sqrt(a); i++){
		if(a % i == 0){
			long long cnt = i;
			while(a % cnt == 0){
				ans++;
	//			printf("%lld %d\n", ans, cnt);
				a /= cnt;
				cnt *= i;
			}
			while(a % i == 0) a /= i;
		}
	}
	if(a != 1) ans++;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2152
import sys

n, q = map(int, input().split())
lines = sys.stdin.readlines()
coordinates = set()
kkk = []
for line in lines[:n]:
    s, t, x = map(int, line.split())
    sx = s - x
    tx = t - x
    kkk.append((x, sx, tx))
    coordinates.add(sx)
    coordinates.add(tx)
kkk.sort()
ddd = list(map(int, lines[n:]))
coordinates.update(ddd)
coordinates = {d: i for i, d in enumerate(sorted(coordinates))}
coord_len = len(coordinates)

ans = [-1] * coord_len
skip = [-1] * coord_len
for x, sx, tx in kkk:
    ss = coordinates[sx]
    tt = coordinates[tx]
    while ss < tt:
        sk = skip[ss]
        if sk == -1:
            ans[ss] = x
            skip[ss] = tt
            ss += 1
        else:
            ss = sk
print('\n'.join(map(str, map(ans.__getitem__, map(coordinates.get, ddd)))))


Measured memory_bytes: 159536
#include<iostream>
using namespace std;
int main()
{
  int x;
  cin>>x;
  for(int i=1;i<=9;i++)
    for(int j=1;j<=9;j++)
      if(i*j==x)
      {
        puts("Yes");
        return 0;
      }
  puts("No");
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
sc = [input().split() for _ in range(m)]

ans = -1
for i in range(10**n):
    x = str(i)
    if len(x) != n:
        continue
    for j in range(m):
        s, c = sc[j]
        s = int(s)
        if x[s-1] != c:
            break
    else:
        ans = i
        break
print(ans)

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

using namespace std;

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

const ld EPS = 1e-9;
const ld PI = acos(-1.0);
const int INF = (int)1e9 + 5;
const ll LINF = (ll)1e18 + 5;

bool eq(double a, double b) {
	return fabs(a - b) < EPS;
}

template<class T>
T sqr(const T & x) { return x * x; }

template<class T> 
ll abs(const T & x) { return x < 0 ? -x : x; }

template<class T>
ll myround(const T & x) { return x < 0 ? x - 0.5 : x + 0.5; }

template<class T> 
bool chmin(T & x, const T & y) {
	if (y < x) {
		x = y;
		return true;
	}
	return false;
}

template<class T>
ostream & operator <<(ostream & os, const vector<T> & v) {
	os << "{";
	for (typename vector<T>::const_iterator it = v.begin(); it != v.end(); ++it) {
		os << *it;
		if ((it + 1) != v.end()) os << ", ";
	}
	os << "}";
	return os;
}

template<class P, class Q>
ostream & operator <<(ostream & os, const pair<P, Q> & p) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template<class T> 
bool chmax(T & x, const T & y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

#define all(a) (a).begin(), (a).end()

int main() {
	srand(time(0));
#ifdef LOCAL 
	freopen("input.txt", "r", stdin);
#else
#endif

	ll a, b, c;

	cin >> a >> b >> c;

	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) cout << 0 << endl;
	else cout << min(a * b, min(b * c, a * c)) << endl;

}

Measured memory_bytes: 764
#include <iostream>

using namespace std;
int n, p[1007], x[1007], dp[1007][5007], t, fa, lim, odp;

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

    cin >> n;
    for (int i = 2; i <= n; i++) cin >> p[i];
    for (int i = 1; i <= n; i++) cin >> x[i];

    for (int i = n; i > 0; i--) {
        fa = p[i], lim = x[i];
        for (int j = x[fa]; j >= 0; j--) {
            odp = dp[fa][j], dp[fa][j] = (int) 1e5;
            if (lim <= j)
                dp[fa][j] = (lim == 0 ? odp : dp[fa][j - lim]) + dp[i][lim];

            if (dp[i][lim] <= j) {
                t = (dp[i][lim] == 0 ? odp : dp[fa][j - dp[i][lim]]) + lim;
                if (dp[fa][j] > t) dp[fa][j] = t;
            }
        }
    }
    cout << (dp[1][x[1]] < (int) 1e5 ? "POSSIBLE" : "IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 18432
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String w;
		w = in.next();
		for (int i = 0; i < w.length(); i++) {
			char c = w.charAt(i);
			int contatore = 0;
			for (int j = 0; j < w.length(); j++) {
				char c2 = w.charAt(j);
				if (c == c2)
					contatore++;
			}
			if (contatore % 2 != 0) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 9428
# https://atcoder.jp/contests/abc068/tasks/arc079_a
require 'set'

MAX = 20_0000 + 1
NEIGHBOURS = Array.new(MAX).map { Array.new }

Node = Struct.new("Node", :cost, :pos)

n, m = gets.split.map(&:to_i)

m.times do
  from, to = gets.split.map(&:to_i)
  NEIGHBOURS[from].push(to)
  NEIGHBOURS[to].push(from)
end

start_neighbours = NEIGHBOURS[1].to_set
goal_neighbours = NEIGHBOURS[n].to_set
mid_islands = start_neighbours & goal_neighbours

puts mid_islands.size > 0 ? 'POSSIBLE' : 'IMPOSSIBLE'

Measured memory_bytes: 39648
<?php
list($n, $m) = ints();
for ($i  = 0; $i < $m; $i++) {
    fscanf(STDIN, '%d %d', $a, $b);
    $a--; // 0スタートに合わせる
    $b--;
    $g[$a][] = $b;
    $g[$b][] = $a; // 無向グラフの場合
}

// BFS（幅優先探索）：最短経路アルゴリズムとして活用
$q = new SplQueue(); // キューを用意
$dist = array_fill(0, $n, -1); // 距離を格納する配列（-1の場合はその頂点が未発見）

$dist[0] = 0; // 頂点0からの距離格納配列
$q->enqueue(0); // キューに0を追加

while (!$q->isEmpty()) {
    $v = $q->dequeue();

    foreach ($g[$v] as $next_v) {
        if ($dist[$next_v] !== -1) continue; // 発見済み

        $dist[$next_v] = $dist[$v] + 1;
        $q->enqueue($next_v);
    }
}
echo $dist[$n - 1] !== -1 && $dist[$n - 1] <= 2 ? 'POSSIBLE' : 'IMPOSSIBLE';
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 106992
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

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

  int n, m;
  cin >> n >> m;
  int k[m + 5], s[m + 5][n + 5], p[m + 5];
  rep(i, m){
    cin >> k[i];
    rep(j, k[i]){
      cin >> s[i][j];
    }
  }
  rep(i, m){
    cin >> p[i];
  }

  lol ans = 0;
  rep(bit, (1 << n)){
    bool out = false;
    rep(i, m){
      int sum = 0;
      rep(j, k[i]){
	if(bit & (1 << (s[i][j] - 1))){
	  sum ++;
	}
      }
      if(sum % 2 != p[i]){
	out = true;
      }
    }
    if(!out){
      ans ++;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python

n = int(input())
t = input().split()
p = []
for i in t:
    p.append(int(i))

q = sorted(p)
c = 0
for i,j in enumerate(p):
    if p[i] != q[i]:
        c += 1
if c == 2 or c == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
import bisect
n=int(input())
l=[1]
for i in range(2,int(1000**0.5)+1):
    j=2
    while i**j<=1000:
        l.append(i**j)
        j+=1
l=list(set(l))
l.sort()
print(l[bisect.bisect_left(l,n+1)-1])

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<int> > map(h, vector<int>(w, inf));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            char c;
            cin >> c;
            if(c=='c') map[i][j] = 0;
        }
    }

    for(int i=0; i<h; i++){
        int curr = inf;
        for(int j=0; j<w; j++){
            curr = min(curr, map[i][j]);
            if(curr >= inf){
                map[i][j] = -1;
            }else{
                map[i][j] = curr;
            }
            curr++;
        }
    }

    for(int i=0; i<h; i++){
        for(int j=0; j<w-1; j++){
            cout << map[i][j] << " ";
        }
        cout << map[i][w-1] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3172
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(true){
			int n = sc.nextInt();
			int k = sc.nextInt();
			if(n==0 && k==0)break;
			
			int[] c = new int[n+1];
			for(int i=0;i<k;i++){
				c[sc.nextInt()]++;
			}
			
			int max = 0;
			int count = 0;
			if(c[0]==0){
				for(int t=1;t<=n;t++){
					if(c[t]>0){
						count++;
					}else if(c[t]==0){
						if(count>max)max=count;
						count=0;
					}
				}
				if(count>max)max=count;
			}else if(c[0]>0){
				int p = 0;
				int q = 0;
				for(int t=1;t<=n;t++){
					if(c[t]>0){
						count++;
					}else if(c[t]==0){
						if(p+count>max)max=p+count;
						if(t!=1 && t!=n && c[t-1]==1 && c[t+1]==1){
							p = count + 1;
						}else{
							p = 0;
						}
						count=0;
					}
				}
				if(p+count>max)max=p+count;
			}
			System.out.println(max);		
		}
	}	
}

Measured memory_bytes: 60732
/* March 28 2020 */

#include <vector>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>

#define ll long long

int main(void) {
    ll x; scanf("%lld", &x);
    ll ans = (x / 500) * 1000;
    x = x % 500;
    printf("%lld\n", ans + (5*(x/5)));
    return 0;
}



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

double dist (double x, double y);

double dist (double x, double y){
  return sqrt(x*x+y*y);
}
int main(void){
  int n;
  int a;
  double x, y;
  int sum=0;
  int i;
  scanf("%d", &n); scanf("%d", &a);
  for (i=1;i<=n;i++){
    scanf("%lf", &x);
    scanf("%lf", &y);
    if (dist(x,y) <= a){
      sum++;
    }
    }
  printf("%d", sum);
  return 0;
}
  


Measured memory_bytes: 2220
#!/usr/bin/env ruby

def main
    n,a,b = gets.chomp.split(" ").map(&:to_i)
    ans = 0
    (1..n).each do |i|
        sum = i.to_s.split("").map(&:to_i).inject(:+)
        ans += i if (a <= sum) && (sum <= b)
    end
    puts ans    
end

main

Measured memory_bytes: 2044
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;
int n, k; 
llong T[MAX];

int check(llong P){
    int i = 0;
    for (int j = 0;j < k; j++){
        llong s = 0;
        while(s+T[i] <= P ){
            s += T[i];
            i++;
            if (i == n) return n;
        }
    }
    return i;
}

int solve() {
    llong left = 0;
    llong right = 100000 * 10000;
    llong mid;
    while (right - left > 1){
        mid = (left + right) / 2;
        int v = check(mid);
        if ( v >= n )right = mid;
        else left = mid;
    }
    return right;
}

int main(){
    cin >> n >> k;
    for (int i = 0; i < n; i++ ) cin >> T[i];
    llong ans = solve();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3880
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)
#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pii pair<int,int>
#define pLL pair<long long,long long>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
typedef long long ll;
typedef long long int lln;
ll INF=1<<28;
//typedef long long lld;
const double pi=acos(-1.0);
int fx[]={1,-1,0,0}; //direction array
int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
const long double EPS=1e-7;
//#define INF 10000
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    return a/gcd(a,b)*b;
}

bool cmp(int a, int b)
{
    return a<b;
}

struct compare
{
  bool operator()(const int& l, const int& r)
  {
      return l>r;
  }
};
ll inf=1e18;
ll dp[200][100005];
int W[200],V[200],C[200];
int n;
ll fun(int pos,int w)
{
    if(pos==n)
        return 0;
    if(dp[pos][w]!=-1)
        return dp[pos][w];
    ll ans=0;
    if(W[pos]<=w)
    {
        ans=max(ans,V[pos]+fun(pos+1,w-W[pos]));
    }
    ans=max(ans,fun(pos+1,w));
    return dp[pos][w]=ans;
}
int main()
{
//    READ;
    int w;
    sf2(n,w);
    mem(dp,-1);
    for(int i=0;i<n;i++)
    {
        sf2(W[i],V[i]);
    }
    cout<<fun(0,w)<<endl;
    return 0;
}


Measured memory_bytes: 156544
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

struct dice {
    int u, d, l, r, f, b;

    void spinl(){ // f -> l
        int tmp = f; f = r; r = b; b = l; l = tmp;
    }
    void spinr(){
        for (int i = 0; i < 3; ++i) spinl();
    }

    void gof(){
        int tmp = f; f = u; u = b; b = d; d = tmp;
    }

    void gob(){
        for (int i = 0; i < 3; ++i) gof();
    }

    void gor(){
        int tmp = u; u = l; l = d; d = r; r = tmp;
    }

    void gol(){
        for (int i = 0; i < 3; ++i) gor();
    }

    dice(int a, int x) {
        u = 1, d = 6, f = 2, b = 5, l = 4, r = 3;
        if(a == 2) gob();
        else if(a == 3) gol();
        else if(a == 4) gor();
        else if(a == 5) gof();
        else if(a == 6) gof(), gof();
        while(f != x) spinl();
    }
    dice(){
        u = 0, d = 0, f = 0, b = 0, l = 0, r = 0;
    }
};

int main() {
    dice D(1, 2);
    int h, w;
    cin >> h >> w;
    vector<vector<int>> v(h+2, vector<int>(w+2, 0));

    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < w; ++j) {
            if(s[j] != '#') v[i+1][j+1] = s[j] - '0';
        }
    }
    vector<vector<dice>> a(h+2, vector<dice>(w+2));
    a[1][1] = D;
    queue<pair<int, int>> Q;
    Q.emplace(1, 1);
    while(!Q.empty()){
        int y, x; tie(y, x) = Q.front(); Q.pop();
        dice d = a[y][x];
        if(v[y-1][x] && a[y-1][x].r == 0){
            d.gob();
            if(d.d == v[y-1][x]){
                Q.emplace(y-1, x);
                a[y-1][x] = d;
            }
            d.gof();
        }
        if(v[y+1][x] && a[y+1][x].r == 0){
            d.gof();
            if(d.d == v[y+1][x]){
                Q.emplace(y+1, x);
                a[y+1][x] = d;
            }
            d.gob();
        }
        if(v[y][x-1] && a[y][x-1].r == 0){
            d.gol();
            if(d.d == v[y][x-1]){
                Q.emplace(y, x-1);
                a[y][x-1] = d;
            }
            d.gor();
        }
        if(v[y][x+1] && a[y][x+1].r == 0){
            d.gor();
            if(d.d == v[y][x+1]){
                Q.emplace(y, x+1);
                a[y][x+1] = d;
            }
            d.gol();
        }
    }
    if(a[h][w].d){
        puts("YES");
    }else {
        puts("NO");
    }
    return 0;
}


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,x[100010],l[100010];
	vector<P> vec;
	cin >> n;
	for(int i = 0;i < n;i++) cin >> x[i] >> l[i];
	for(int i = 0;i < n;i++) vec.emplace_back(x[i] + l[i],x[i] - l[i]);
	sort(all(vec));
	int ans = 0,f = -INF;
	for(int i = 0;i < n;i++){
		if(vec[i].second >= f){
			ans++;
			f = vec[i].first;
		}
	}
	cout << ans << endl;

}

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

int main(){
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	if(a+b<2*c){
		cout<<(a*x+b*y)<<endl;
	}else{
		if(x>y){
			if(a>2*c){
				cout<<(2*c*x)<<endl;
			}else{
				cout<<(2*c*y+a*(x-y))<<endl;
			}
		}else{
			if(b>2*c){
				cout<<(2*c*y)<<endl;
			}else{
				cout<<(2*c*x+b*(y-x))<<endl;
			}
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
using namespace std;
#define LATTE 10000

int dp[502][10][500][2][2];


int main(){
	char str[2][502];
	int M;
	cin>>str[0]>>str[1]>>M;
	int len[2] = {strlen(str[0]),strlen(str[1])};
	for(int i=0;i<2;i++)for(int j=0;j<len[i];j++) str[i][j]-='0';

	int ans[2]={};
	for(int m=0;m<2;m++){
		memset(dp,0,sizeof(dp));

		//printf(" %d,%d\n",str[m][0],len[m]);
		for(int i=1;i<str[m][0];i++){
			dp[0][i][i%M][0][0] = 1;
			if(0!=len[m]-1) dp[0][i][i%M][1][0] = 1;
			//printf("  %d,%d\n",i,i%M);
		}
		dp[0][str[m][0]][str[m][0]%M][0][1] = 1;
		if(0!=len[m]-1) dp[0][str[m][0]][str[m][0]%M][1][1] = 1;

		/*for(int i=0;i<10;i++){
			printf("%d ",dp[0][i][0][0][0]+dp[0][i][0][1][0]+dp[0][i][0][0][1]+dp[0][i][0][1][1]);
		}puts("");*/

		for(int i=0;i+1<len[m];i++){
			for(int j=1;j<10;j++){
				dp[i+1][j][j%M][0][0] = 1;
				if(i+1!=len[m]-1) dp[i+1][j][j%M][1][0] = 1;
			}
			for(int j=0;j<10;j++){
				for(int k=0;k<M;k++){
					for(int l=j+1;l<10;l++){
						dp[i+1][l][(k*10+l)%M][1][0] += dp[i][j][k][0][0]%LATTE;
						if(l<str[m][i+1])
							dp[i+1][l][(k*10+l)%M][1][0] += dp[i][j][k][0][1]%LATTE;
						if(l==str[m][i+1])
							dp[i+1][l][(k*10+l)%M][1][1] += dp[i][j][k][0][1]%LATTE;
					}
					for(int l=j-1;l>=0;l--){
						dp[i+1][l][(k*10+l)%M][0][0] += dp[i][j][k][1][0]%LATTE;
						if(l<str[m][i+1])
							dp[i+1][l][(k*10+l)%M][0][0] += dp[i][j][k][1][1]%LATTE;
						if(l==str[m][i+1])
							dp[i+1][l][(k*10+l)%M][0][1] += dp[i][j][k][1][1]%LATTE;
					}
				}
			}
		}
		for(int i=0;i<10;i++){
			ans[m] += (dp[len[m]-1][i][0][0][0]+dp[len[m]-1][i][0][1][0])%LATTE;
			if(m==1)
				ans[m] += (dp[len[m]-1][i][0][0][1]+dp[len[m]-1][i][0][1][1])%LATTE;
		}
	}
	printf("%d\n",(ans[1]%LATTE+LATTE-ans[0]%LATTE)%LATTE);
    return 0;
}

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

int main()
{
	int N;
	while(cin >> N){
		if(N > 81){
			cout << "No" << endl;
		}
		else if(N <= 9)
		    cout << "Yes" << endl;
		else{
			int a = 9;
			bool flag = false;
			while(a > 1){
				int k = a;
				if(N % a == 0){
					a = N/a;
					if(a < 10){
						cout << "Yes" << endl;
						flag = true;
						break;
					}
				}
				a = k;
				--a;
			}
			if(!flag)
			   cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 256
A, B, C, X, Y = map(int,input().split())
if A + B <= C*2:
    print(X*A+Y*B)
elif X <= Y:
    if C*2 <= B:
        print(C*2*Y)
    else:
        print(C*2*X + (Y-X)*B)
else:
    if C*2 <= A:
        print(C*2*X)
    else:
        print(C*2*Y + (X-Y)*A)

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

int main() {
  int N;
  cin >> N;
  vector<int> num(N);
  
  rep(i, N) cin >> num.at(i);
  
  int count = 0;
  
  while(true) {
    bool odd = false;
    rep(i, N) {
      if(num.at(i) % 2 != 0) odd = true;
    }
    if(odd) break;
    rep(i, N) {
      num.at(i) /= 2;
    }
    count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <iomanip>
 
using namespace std;
 
int main(){
	int n, k;
	cin >> n >> k;
 
	double prob = 0.0;
 
	for(int i = 1; i <= n; ++i){
		if(i >= k){
			prob += 1.0/n;
		}else{
			int current = i;
			int step = 0;
			while(current < k){
				current *= 2;
				++step;
			}
			prob += 1.0/n * pow(0.5, step);
		}
	}
 
	cout << setprecision(20) << prob << endl;
 
	return 0;
}

Measured memory_bytes: 512
S = list(input())
N = int(input())

for i in range(N):
    list1 = input().split()
    if list1[0] == "print":
        print("".join(S[int(list1[1]):int(list1[2])+1]))
    elif list1[0] == 'reverse':
        S[int(list1[1]):int(list1[2])+1] = reversed(S[int(list1[1]):int(list1[2])+1])
    else:
        S[int(list1[1]):int(list1[2])+1] = list1[3]


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

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

  int num_of_operations = 0;
  while (true) {
    bool is_all_even = true;
    for (auto& e : a) {
      if (e < 2 || e & 1) {
        is_all_even = false;
        break;
      }
      e = e >> 1;
    }
    if (is_all_even == false) { break; }
    num_of_operations++;
  }
  cout << num_of_operations << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())

cd = defaultdict(int)
C = [list(map(int, input().split())) for _ in range(N)]

for i in range(N):
    for j in range(N):
        if i == j:
            continue
        cd[(C[i][0]-C[j][0],C[i][1]-C[j][1])] += 1

if N == 1:
    print(1)
else:
    print(N-max(cd.values()))


Measured memory_bytes: 3828