akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
typedef long long ll;
const int num = 1e3 + 5;

int n,d,a;
ll ans;

struct point{
  int place = 0,health = 0,diff;
}li[N];

int main(){
  // freopen("input.txt","r",stdin);
  ios::sync_with_stdio(false);
  cin>>n>>d>>a;
  for(int i = 1;i <= n;i++){
    cin>>li[i].place>>li[i].health;
  }
  sort(li+1,li+n+1,[](point x,point y){return x.place < y.place;});
  for(int i = 1;i < n;i++) li[i].diff = li[i+1].health - li[i].health;
  d <<= 1;
  int l = 1,r = 1,cur = li[1].health;
  while(l <= n){
    while(r <= n && li[r+1].place - li[l].place <= d) {r++;}
    int tmp = (cur/a + (cur % a != 0));
    ans += tmp;
    cur -= tmp*a;
    li[r].diff += tmp*a;
    while(cur <= 0){
      cur += li[l++].diff;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2688
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

const double PI = acos(-1);

ll as[200000+10];
ll fs[200000+10];
int N;
ll K;
bool isOK(ll m) {
  ll rest = K;
  REP(i, N) {
    ll tobe = m / fs[i];
    rest -= max(0LL, as[i] - tobe);
  }
  return rest >= 0;
}

int main(void) {
  scanf("%d%lld", &N, &K);
  REP(i, N) {
    scanf("%lld", &as[i]);
  }
  REP(i, N) {
    scanf("%lld", &fs[i]);
  }
  sort(as, as + N);
  sort(fs, fs + N);
  reverse(fs, fs + N);
  ll left = -1;
  ll right = 1e18;
  while(left + 1 < right) {
    ll md = (left + right) / 2;
    if(isOK(md)) {
      right = md;
    } else {
      left = md;
    }
  }
  cout << right << endl;
  return 0;
}


Measured memory_bytes: 3328
n = int(input())
s = [input() for i in range(n)]
from collections import Counter
cnter = Counter(s)
lis = cnter.most_common()
maxi = lis[0][1]
i = 0
string = []
for i in range(len(lis)):
    if maxi != lis[i][1]:
        break
    string.append(lis[i][0])
string.sort()
for i in range(len(string)):
    print(string[i])

Measured memory_bytes: 121424
/* dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll ,ll>
#define vll          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005
vll a[N];

int main()
{
    ios
   	ll n,i,j;
   	cin>>n;
   	if(n==1){
   		cout<<"Yes\n2\n1 1\n1 1";return 0;
   	}
   	ll cnt=1,lin=4;
   	a[1].pb(1);
   	a[1].pb(2);
   	a[2].pb(2);
   	a[2].pb(3);
   	a[3].pb(3);
   	a[3].pb(1);
   	cnt=4;
   	if(n<3){cout<<"No";return 0;}
   	while(1){
   		//cout<<cnt<<"\n";
   		if(cnt==n+1){
   			cout<<"Yes\n";
   			cout<<lin-1<<"\n";
   			for(i=1;i<lin;i++){
   				cout<<a[i].size()<<" ";
   				for(auto ii:a[i])cout<<ii<<" ";
   					cout<<"\n";
   			}
   			return 0;
   		}
   		ll req=a[1].size(),ptr=1;
   		for(j=cnt;j<=cnt+req;j++){
   			a[lin].pb(j);
   			a[ptr].pb(j);ptr++;
   		}
   		lin++;
   		cnt+=req;
   		if(cnt>n){
   			cout<<"No";return 0;
   		}
   		cnt++;
   	}
    return 0;
}

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

struct edge{
    int to, cap, rev;
};

#define MAX_V 15000
vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap){
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size()-1});
}

// v...target vertex, t...end vertex, f...maximum flow 
int dfs(int v, int t, int f){
    if(v == t)  return f;

    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }

    return 0;
}

const int INF = 1<<29;

// maxflow from s to t
int max_flow(int s, int t){
    int flow = 0;
    while(1){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if(f == 0)  return flow;
        flow += f;
    }
}

int di[8] = {0,0,1,-1,1,1,-1,-1};
int dj[8] = {1,-1,0,0,1,-1,1,-1};
#define inRange(x,a,b) (a <= x && x < b)

// 解説AC
int main(){
    int h, w;
    cin >> h >> w;
    auto f = [=](int i, int j)->int{
        return i*w+j;
    };
    int si, sj, gi, gj;
    char mat[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> mat[i][j];
            if(mat[i][j] == 'S'){
                si = i, sj = j;
                mat[i][j] = 'o';
            }else if(mat[i][j] == 'T'){
                gi = i, gj = j;
                mat[i][j] = 'o';
            }
        }
    }
    if(si == gi || sj == gj){
        cout << -1 << endl;
        return 0;
    }
    int SOURCE = 14998, SINK = 14999;
    // 始点・終点につながっている辺の容量を極端に大きくすることで
    // 最小カットによって蓮S, Tがカットされないようにする
    add_edge(SOURCE, si, INF);
    add_edge(SOURCE, h+sj, INF);
    add_edge(gi, SINK, INF);
    add_edge(h+gj, SINK, INF);
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(mat[i][j] != 'o')    continue;
            add_edge(i, h+j, 1);
            add_edge(h+j, i, 1);
        }
    }
    cout << max_flow(SOURCE, SINK) << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, a[N], c, k;

int main() {
    cin >> n >> c >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    int res = 0;
    for (int i = 1; i <= n; ) {
        int key = lower_bound(a + i, a + n + 1, a[i] + k) - a;
        if (key == n + 1 || a[key] - a[i] > k) key--;
        if (key > i + c - 1) key = i + c - 1;
        res++;
        i = key + 1;
    }
    cout << res << endl;
}


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

inline int Input() {
	char c = getchar(); int x = 0, z = 1;
	for(; c < '0' || c > '9'; c = getchar()) z = c == '-' ? -1 : 1;
	for(; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x * z;
}

const int maxn(505);

int n, m, a[maxn][maxn];

struct Info {
	int x1, y1, x2, y2;
};

vector <Info> ans;

int main() {
	n = Input(), m = Input();
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j) a[i][j] = Input();
	int sx = 1, sy = 1, flg = a[sx][sy] & 1, d = 1;
	while (true) {
		int nx = sx, ny = sy + d;
		if (!ny) ny = 1, nx++, d = 1;
		if (ny > m) ny = m, nx++, d = -1;
		if (nx > n) break;
		if (flg) {
			ans.push_back((Info){sx, sy, nx, ny});
			if (a[nx][ny] & 1) flg = 0;
		}
		else if (a[nx][ny] & 1) flg = 1;
		sx = nx, sy = ny;
	}
	int len = ans.size();
	printf("%d\n", len);
	for (int i = 0; i < len; ++i) printf("%d %d %d %d\n", ans[i].x1, ans[i].y1, ans[i].x2, ans[i].y2);
	return 0;
}

Measured memory_bytes: 5232
class Main{
	public static void main(String[] args){
		java.util.Scanner sc = new java.util.Scanner( System.in );
		int a = sc.nextInt();
		int b = sc.nextInt();
		if( a > b ) System.out.println( "a > b" );
		if( a < b ) System.out.println( "a < b" );
		if( a == b ) System.out.println( "a == b" );
		
	}
}

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

int main() {
    // H: row , W: column
    int H, W;
    cin >> H >> W;
    vector<vector<char>> vec(H, vector<char>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> vec.at(i).at(j);
        }
    }

    for (int i = 0; i < W + 2; i++) {
        cout << '#';
    }
    cout << endl;

    for (int i = 0; i < H; i++) {
        cout << '#';
        for (int j = 0; j < W; j++) {
            cout << vec.at(i).at(j);
        }
        cout << '#' << endl;
    }

    for (int i = 0; i < W + 2; i++) {
        cout << '#';
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int ans=0;
	string s;
	cin>>s;
	for(int i=0;i<4;i++)
	{
		if(s[i]=='+')
			ans++;
		else
			ans--;
	}
	cout<<ans<<endl;
	return 0;
}

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

struct segment_tree {
    void build(std::string const &a) {
        t.resize(4 * a.size());
        build(0, 0, a.size(), a);
    }

    void update(size_t pos, char new_value) {
        update(0, 0, t.size() / 4, pos, new_value);
    }

    int32_t get(size_t l, size_t r) {
        return get(0, 0, t.size() / 4, l, r + 1).size();
    }

private:
    std::vector<std::set<char>> t;
    void build(size_t v, size_t l, size_t r, std::string const &a) {
        if (l + 1 == r) {
            std::set<char> m;
            m.insert(a[l]);
            t[v] = m;
        } else {
            size_t mid = (l + r) / 2;
            build(2 * v + 1, l, mid, a);
            build(2 * v + 2, mid, r, a);
            for (auto elem : t[2 * v + 1]) {
                t[v].insert(elem);
            }
            for (auto elem : t[2 * v + 2]) {
                t[v].insert(elem);
            }
        }
    }

    void update(size_t v, size_t l, size_t r, size_t pos, char new_value) {
        if (l + 1 == r) {
            std::set<char> m;
            m.insert(new_value);
            t[v] = m;
        } else {
            size_t mid = (l + r) / 2;
            if (pos < mid) {
                update(2 * v + 1, l, mid, pos, new_value);
            } else {
                update(2 * v + 2, mid, r, pos, new_value);
            }
            t[v].clear();
            for (auto elem : t[2 * v + 1]) {
                t[v].insert(elem);
            }
            for (auto elem : t[2 * v + 2]) {
                t[v].insert(elem);
            }
        }
    }

    std::set<char> get(size_t v, size_t l, size_t r, size_t req_l, size_t req_r) {
        if (req_l >= req_r) {
            return std::set<char> ();
        } else if (l == req_l && r == req_r) {
            return t[v];
        } else {
            size_t mid = (l + r) / 2;
            std::set<char> cur = get(2 * v + 1, l, mid, req_l, std::min(mid, req_r));
            for (auto elem : get(2 * v + 2, mid, r, std::max(mid, req_l), req_r)) {
                cur.insert(elem);
            }
            return cur;
        }
    }
};

int main() {
    std::ios_base::sync_with_stdio(false);
    segment_tree chr;
    size_t n;
    std::string a;
    std::cin >> n;
    std::cin >> a;
    chr.build(a);
    size_t k;
    std::cin >> k;
    while (k-- > 0) {
        size_t type;
        std::cin >> type;
        if (type == 1) {
            size_t pos;
            char ch;
            std::cin >> pos >> ch;
            chr.update(pos - 1, ch);
        } else {
            size_t l, r;
            std::cin >> l >> r;
            std::cout << chr.get(l - 1, r - 1) << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 235676
#include<bits/stdc++.h>
using namespace std;
 int indegree[200001];
class graph{
    list<int>*l;
      int *level;
    int V;
    public:
    graph(int n)
    {    
          level=new int[n+1];
          for(int i=0;i<=n;i++)
            {
                level[i]=-1;
            }
        l=new list<int>[n+1];
        this->V=n;
    }
    void addedge(int x,int y)
    {
        l[x].push_back(y);
    }
    int dfs(int src)
    {
        if(level[src]!=-1)
        return level[src];
        
        int ans=0;
        for(auto child:l[src])
        {   
            ans=max(ans,1+dfs(child));
        }
    return level[src]=ans;
    }

    void dfs_help(int src)
    {
        
       int u=dfs(src);

    }
    int findfun()
    {   
        int maxi=0;
        for(int i=1;i<=V;i++)
        {
            maxi=max(maxi,level[i]);
        }
        return maxi;
    }  
};
int main()
{  
    int n,m,a,b;
    cin>>n>>m;
    graph g(n);
   
    for(int i=0;i<n+1;i++)
    indegree[i]=0;
    for(int i=0;i<m;i++)
    {
        cin>>a>>b;
        g.addedge(a,b);
        indegree[b]++;
    }
    for(int i=1;i<=n;i++)
    {
        if(indegree[i]==0)
        {  
            g.dfs_help(i);
        }
    }
    cout<<g.findfun()<<endl;

    return 0;
}

Measured memory_bytes: 14384
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 100000000000000000
#define mod 1000000007
#define MAX 300005
#define pb push_back
#define mp make_pair
#define vit vector<int>::iterator
typedef pair<lint,lint> pii;
map<pii,lint> MP;
lint X[MAX],Y[MAX];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    lint H,W,M,mx=0,my=0,a,b;
    cin>>H>>W>>M;
    for(lint i=1;i<=M;i++){
        cin>>a>>b;
        MP[mp(a,b)]=1;
        X[a]++;
        Y[b]++;
    }
    for(lint i=1;i<=H;i++) mx=max(mx,X[i]);
    for(lint i=1;i<=W;i++) my=max(my,Y[i]);
    lint ans=mx+my-1;
    vector<lint> xx,yy;
    for(lint i=1;i<=H;i++){
        if(X[i]==mx){
            xx.pb(i);
        }
    }
    for(lint i=1;i<=W;i++){
        if(Y[i]==my){
            yy.pb(i);
        }
    }
    for(auto u:xx){
        for(auto v:yy){
            if(!MP[mp(u,v)]){
                cout<<ans+1;
                return 0;
            }
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 35036
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <map>
#include <iostream>
#include <cstring>
#include <cmath>
#define ull unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
void close(){
   	std::ios::sync_with_stdio(false);
   	std::cin.tie(0);
}
const int maxn=1e5+10;
int a[maxn],vis[maxn];
int n,m,b,ans1=0,ans2=0;
string s;
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>b;
		cin>>s;
		if(s[0]=='A'&&vis[b]==0) {
			ans1++;
			ans2+=a[b];
			vis[b]=1;
		}
		if(s[0]=='W'&&vis[b]==0){
			a[b]++;
		}
	}
	cout<<ans1<<" "<<ans2<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define pp pair<ll,ll>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
template <typename T>
ll max(ll x, ll y)
{
    return x>y ? x : y;
}
ll min(ll x, ll y)
{
    return x<y ? x : y;
}ll ans;
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;cin >> n;
    ll a[n];ll mn=1e18;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        mn=min(mn,a[i]);
        if(mn==a[i])ans++;
    }
    cout << ans;
    }

Measured memory_bytes: 1792
import sys
import math
import itertools


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, M = map(int, input().split())
    L = 1
    R = 10 ** 5 + 1

    for i in range(M):
        l, r = map(int, input().split())
        L = max(l, L)
        R = min(r, R)

    print(max(R-L+1,0))


if __name__ == "__main__":
    main()


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	--k;
	s[k] = s[k] - ('A' - 'a');
	cout << s << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{ 
    cool;
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    cout<<s1[0]<<s2[1]<<s3[2];
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> v(q);
  vector<int> cnt(n);
  for(int i = 0, temp; i < q; ++i){
    cin >> temp;
    cnt[temp - 1]++;
  }
  for(int i = 0; i < n; ++i){
    if(k - q + cnt[i] > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;

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

	for (int i = 0; i < 2*K-1; i++)
	{
		cout << X - K + 1 << " ";
		X = X + 1;
	}
}

Measured memory_bytes: 256
def sumitb2019_c
    x = gets.chomp.to_i

    if x < 100
        puts 0
        exit
    else
        yen = [100, 101, 102, 103, 104, 105]
        for y in yen
            if x % y == 0
                puts 1
                exit
            end
        end
    end

    y = x.to_s[-2..-1].to_i
    z = (y - 1) / 5 + 1
    puts (x - z*100 > 0) ? 1 : 0
end

sumitb2019_c

Measured memory_bytes: 1788
'''input
8
-406 10
512 859
494 362
-955 -475
128 553
-986 -885
763 77
449 310
'''
# A coding delight
from sys import stdin, stdout
import gc
gc.disable()
input = stdin.readline
from itertools import permutations


def compute_distance(index):
	index = list(index)
	dist = 0
	for i in range(1, len(index)):
		x2 = coord[index[i]][0]
		y2 = coord[index[i]][1]
		x1 = coord[index[i - 1]][0]
		y1 = coord[index[i - 1]][1]
		dist += ((x1 - x2) ** 2 + (y1 - y2)**2) ** 0.5
	return dist

# main starts
n = int(input().strip())
coord = []
for _ in range(n):
	x, y = list(map(int, input().split()))
	coord.append([x, y])

index = [x for x in range(n)]
All = permutations(index)
k = 0
dist = 0
for i in All:
	k += 1
	dist += compute_distance(i)
print(dist/k)

Measured memory_bytes: 3184
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        int n = Integer.valueOf(arr01[0]);
        String arr02[] = mylist.get(1).split(" ");
        List<String> list01 = new ArrayList<String>(Arrays.asList(arr02));
        //        System.out.println(list01);
        String arr_result[] = new String[n];
        //        String s = "";
        HashMap<Integer, Integer> map = new HashMap<>();

        for (int i = 1; i <= list01.size(); i++) {
            //            System.out.println(list01.get(i));
            int v = Integer.valueOf(list01.get(i - 1));
            //            System.out.println(i + " " + v);
            map.put(i, v);
            //            arr_result[i - 1] = i + 1;

        }

        // 昇順
        map.entrySet().stream()
                .sorted(java.util.Map.Entry.comparingByValue())
                .forEach(s -> System.out.print(s.getKey() + " "));

    }

}

Measured memory_bytes: 60040
N,M,C= map(int,input().split())
B=list(map(int,input().split()))
a=[list(map(int,input().split()))for i in range(N)]
res=0
for n in range(N):
	ans=0
	for m in range(M):
		ans = ans+a[n][m]*B[m]
	if ans+C>0:
		res=res+1
print(res)
	

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

int main() {
  int H,W;
  cin>>H>>W;
  string Sue,Schu,Ssita;
  cin>>Schu>>Ssita;
  for (int i=0;i<H;i++){
    
    string Susie=Schu;
    for(int j=0;j<W;j++){
      if(Susie.at(j)=='.'){
        int count=0;
        if(i>0){
          if(Sue.at(j)=='#'){count++;}
          if(j>0 && Sue.at(j-1)=='#'){count++;}
          if(j<W-1 && Sue.at(j+1)=='#'){count++;}
        }
        if(j>0 && Schu.at(j-1)=='#'){count++;}
        if(j<W-1 && Schu.at(j+1)=='#'){count++;}
        if(i<H-1){
          if(j>0 && Ssita.at(j-1)=='#'){count++;}
          if(Ssita.at(j)=='#'){count++;}
          if(j<W-1 && Ssita.at(j+1)=='#'){count++;}
        }
        if(count==0){Susie.at(j)='0';}
        if(count==1){Susie.at(j)='1';}
        if(count==2){Susie.at(j)='2';}
        if(count==3){Susie.at(j)='3';}
        if(count==4){Susie.at(j)='4';}
        if(count==5){Susie.at(j)='5';}
        if(count==6){Susie.at(j)='6';}
        if(count==7){Susie.at(j)='7';}
        if(count==8){Susie.at(j)='8';}
      }
    }
    cout<<Susie<<endl;
    if(i==H-1){break;}
    else{
      Sue=Schu;
      Schu=Ssita;
      cin>>Ssita;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INFTY 10000000000
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
using ipair = pair<ll,ll>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
  int n;cin>>n;
  ll h;cin>>h;
  vector<ll> a(n),b(n);
  rep(i,n)cin>>a[i]>>b[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  reverse(a.begin(),a.end());
  reverse(b.begin(),b.end());
  int ok = 1;
  ll ans =0,dmg=0;
  int i = 0;
  while(ok){
    if(a[0]<b[i]){
      dmg += b[i];
      ans++;i++;
    }
    else if(i>=n||a[0]>=b[i]){
      ok = 0;
      if((h-dmg)%a[0]==0)ans += (h-dmg)/a[0];
      else ans += (h-dmg)/a[0]+1;
    }
    if(dmg>=h)ok = 0;
    //cout<<dmg<<endl;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int R = sc.nextInt();
		int D = sc.nextInt();
		int x = sc.nextInt();
		
		for (int i = 0; i < 10; i++) {
			x = R * x - D;
			out.println(x);
		}
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 21332
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <list>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) x.begin(), x.end()

int N, M;
ll A[5050], B[5050][210];

typedef pair<ll, int> PL;
ll T[5050][5050];

void solve(){
	scanf("%d%d", &N, &M);
	for(int i=2;i<=N;i++)scanf("%lld", A+i), A[i] += A[i-1];
	for(int i=1;i<=N;i++){
		for(int j=1;j<=M;j++)scanf("%lld", B[i]+j);
	}
	for(int i=1;i<=M;i++){
		vector <PL> v;
		for(int j=1;j<=N;j++)v.pb(PL(B[j][i], j));
		sort(all(v)); reverse(all(v));
		set <int> S;
		S.insert(0); S.insert(N+1);
		for(PL e : v){
			auto it = S.lower_bound(e.Se);
			int R = *it;
			int L = *(--it);
			int x = e.Se;
			T[x][L+1] += e.Fi;
			T[R][L+1] -= e.Fi;
			T[x][x+1] -= e.Fi;
			T[R][x+1] += e.Fi;
			S.insert(e.Se);
		}
	}
	ll ans = 0;
	for(int i=1;i<=N;i++){
		for(int j=1;j<=N;j++){
			T[i][j] += T[i-1][j] + T[i][j-1] - T[i-1][j-1];
			if(j <= i)ans = max(ans, T[i][j] - A[i] + A[j]);
		}
	}
	printf("%lld", ans);
}

int main(){
	int Tc = 1;// scanf("%d", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}

Measured memory_bytes: 206036
def mul(a, b, n, m)
  c = []
  for i in 0..(n-1)
    ai = a[i]
    c.push(dot(ai, b, m))
  end
  return c
end

def dot(x, y, m)
  dot_xy_array = []
  dot_xy = 0
  for i in 0..(m-1)
    dot_xy_array.push(x[i] * y[i])
  end
  dot_xy = 0
  dot_xy_array.each do |i|
    dot_xy += i
  end
  return dot_xy
end

input_nm_array = gets.chomp.split.map(&:to_i)
n = input_nm_array[0]
m = input_nm_array[1]
input_a_arrays = []
n.times do
  input_a_array = gets.chomp.split.map(&:to_i)
  input_a_arrays.push(input_a_array)
end
input_b_values = []
m.times do
  input_b_value = gets.chomp.to_i
  input_b_values.push(input_b_value)
end

answer = mul(input_a_arrays, input_b_values, n, m)
for i in 0..(n-1)
  puts answer[i]
end

Measured memory_bytes: 8972
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n, k;
#include <cassert>
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);

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

  cin >> n >> k;
  if(k == 1) {
    cout << 0 << endl;
    return 0;
  }
  vector<ll> a(n);

  REP(i, n) cin >> a[i];

  sort(a.begin(), a.end());

  mint ans = 0;
  mint t = 0;
  FOR(i, k - 1, n) {
    t += c((i + 1 - 2), k - 2);
    ans += a[i] * t.x;
  }

  t = 0;

  RREP(i, n - k + 1) {
    t += c(((n - i) - 2), k - 2);
    ans -= a[i] * t.x;
  }

  cout << ans << endl;
}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 50;
char s[N], t[N];
char mp1[256], mp2[256];
int main()
{
    scanf("%s%s", s, t);
    for (char *ps = s, *pt = t; *ps; ps++, pt++)
        //if (*ps != *pt)
        {
            if (mp1[*ps] == 0 && mp2[*pt] == 0)
                mp1[*ps] = *pt, mp2[*pt] = *ps;
            if (mp1[*ps] != *pt || mp2[*pt] != *ps)
                return puts("No"), 0;
        }
    return puts("Yes"), 0;
}

Measured memory_bytes: 640
import math

N = int(input())
rout = int(math.sqrt(N))

ans = 15

for i in range(1, rout + 1):
    if N % i == 0:
        A = i
        B = int(N / i)
        F = max(len(str(A)), len(str(B)))
        if ans >= F:
            ans = F

print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
 
int main(){
  int n,i,j,flag=0;
  int A[100];
  int num,temp,count=0;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<n;i++){
    num = i;
    for(j=i;j<n;j++){
      if(A[j]<A[num])
        num = j;
     }  
    if(i!=num){
      temp=A[i];    
      A[i]=A[num];
      A[num]=temp;
      count++;
      }
     }
    for(i=0;i<n;i++){
      if(i<n-1) printf("%d ",A[i]);
      else printf("%d\n",A[i]);
    }
    printf("%d\n",count);  
 
    return 0;
   } 



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

int main(){
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k-1] << endl;
    return 0;
}

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

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

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

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 102;
const int V = 100005;

int n, W;
int w[N], v[N];
ll dp[V];

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n >> W;
	for (int i = 0; i < n; i++)
		cin >> w[i] >> v[i];
	MMS(dp, '?');
	dp[0] = 0;
	int res = 0;
	for (int i = 0; i < n; i++) {
		for (int c = V - 1; c >= v[i]; c--) {
			dp[c] = min(dp[c], dp[c - v[i]] + w[i]);
			if (dp[c] <= W)
				res = max(res, c);
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
  int point, a, b;
  cin>>point>>a>>b;
  
  int dist, dist1;
  
  if(a > point)
    dist = a-point;
  else if (a < point)
    dist = point - a;
  
  if(b > point)
    dist1 = b - point;
  else if(point > b)
    dist1 = point - b;
  
  if(dist > dist1)
    cout<<"B";
  else
    cout<<"A";
  return 0;
}

Measured memory_bytes: 256
using namespace std;
#include <bits/stdc++.h>
#define fdto(i, r, l) for(int i = r; i >= l; --i)
#define fto(i, l, r) for(int i = l; i <= r; ++i)
#define forit(it, type, var) for(type::iterator it = var.begin(); it != var.end(); it++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define MEMS(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define ll long long
#define ld long double
#define maxN 1000000000000000000
ll power(ll a,ll b){ll res=1;while(b>0){res*=a;b--;}return res;}
int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,a;
    char b;
    vector<char>ans;
    cin>>n;

    
    ll prod=1,ls,i;
    
    while(n>0)
    {
        a=n%26;
        a+=96;
        if(a==96)
        a=122;
        
        b=(char)a;
        
        ans.pb(b);

        
        n/=26;
        if(a==122)
        n-=1;
    }
    for(i=ans.size()-1;i>=0;i--)
    {
        cout<<ans[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3624
from collections import Counter
N=int(input())
a=list(map(int, input().split()))
flag=False
c=Counter(a)
if len(c.keys())==1:
  if 0 in c.keys():
    flag=True
elif len(c.keys())==2:
  if 0 in c.keys() and N%3==0:
    if c[0]*3==N:
      flag=True
elif len(c.keys())==3:
  x, y, z=c.keys()
  if c[x]==c[y] and c[y]==c[z] and x^y==z and N%3==0:
    flag=True
if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14468
import itertools

N = int(input())
S = input()
S = [int(x) for x in S]

left_index = [[-1] * (N+1) for _ in range(10)]

for i,x in enumerate(S,1):
	for j in range(10):
		left_index[j][i] = left_index[j][i-1]
	left_index[x][i] = i


answer = 0
for a,b,c in itertools.product(range(10),repeat=3):
	i = N
	bl = True
	for x in [a,b,c]:
		i = left_index[x][i] - 1
		if i < -1:
			bl = False
			break
	if bl:
		answer += 1

print(answer)

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

ll dp[101][100001];
ll nn, a[101], k, mod=1000000007;

void solve(ll n, ll m)
{
    // cout << n << m<<"\n";
    if (dp[n][m]!=-1)
    {
        return;
    }
    else
    {
        dp[n][m]=0;
    }
    if (m==0)
    {
        dp[n][m]=1;
        return;
    }
    if (n==nn-1)
    {
        if(a[n]>=m)
        dp[n][m]=1;
        return;
    }

    if (n>=nn||m<0)
    {
        return;
    }

    if(m>=a[n]+1)
    {
        solve(n, m-1);
        solve(n+1, m);

        solve(n+1, m-a[n]-1);
        dp[n][m]=dp[n][m-1]+dp[n+1][m]-dp[n+1][m-a[n]-1]+mod;
        dp[n][m]%=mod;
    }
    
    else
    {
        solve(n, m-1);
        solve(n+1, m);
        dp[n][m]=dp[n][m-1]+dp[n+1][m];
        dp[n][m]%=mod;
    }
    
    return ;

}

int main()
{

    cin >> nn>> k;
    for (int i = 0; i < 101; ++i)
    {
        for (int j = 0; j < 100001; ++j)
        {
            dp[i][j]=-1;
        }
    }
    for (int i = 0; i < nn; ++i)
    {
        cin >> a[i];
    }

    solve(0, k);
    // cout <<"\n";
    cout << dp[0][k];
}

Measured memory_bytes: 85376
N = int(input())
lis = list(map(int,input().split()))
lis.insert(0,0)
listed = [lis[-i-1]-lis[-i-2] for i in range(len(lis)-1)]
for i in range(len(listed)-1):
  if listed[i] < 0:
    listed[i] += 1
    listed[i+1] -=1
listed.sort()
if listed[0] < 0:
  print('No')
else:
  print('Yes')


Measured memory_bytes: 14396
import java.util.*;

/* 階乗の素因数分解の仕方。参考: https://youtu.be/28IanD3lXGg */

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
	
		int[] numExp = new int[n + 1];
		for (int i = 2; i < n + 1; i++) {
			int a = i;
			while (1 < a) {
				for (int j = 2; j < a + 1; j++) {
					if (a % j == 0) {
						numExp[j]++;
						a /= j;
						break;
					}
				}
			}
		}
		
		long answer = 1;
		for (int i = 0; i <= n; i++) {
			answer = answer * (numExp[i] + 1) % 1000000007; 
		}
		System.out.println(answer);
	}
	
}

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

int main() {
    int n, y;
    scanf("%d %d", &n, &y);

    int a1(0), a5(0), a10(0);

    if (y % 1000 != 0) {
        cout << "-1 -1 -1\n";
        return 0;
    }

    y = y / 1000;

    int x, z, bill = n, temp, status = 1;

    if (y%5 != 0) {
        x = y % 5;
        a1 += x;
        y -= x;
        n -= x;
    }

    while(1) {
        if (y/5 < n) {
            if (y%5 != 0) {
                x = y % 5;
                a1 += x;
                y -= x;
                n -= x;
            }
            if (n <= 0) {
                break;
            }
            else {
                if (y/5 >= n) {
                    continue;
                }
                else {
                    z = y / 5;
                    temp = n - z;
                    n = z;
                    a1 += temp;
                    y -= temp;
                }
            }
        }

        else {
            if (y%10 == 0) {
                a10 = y / 10;
            }
            else {
                a10 = y / 10;
                a5 = 1;
            }
            while(1) {
                if (a10 + a5 >= n) {
                    status = 0;
                    break;
                }
                else {
                    a10--;
                    a5 += 2;
                }
                if (a10 == 0) {
                    status = 0;
                    break;
                }
            }
        }
        if (status == 0) {
            break;
        }
    }

    if (a1+a5+a10 == bill) {
        printf("%d %d %d\n", a10, a5, a1);
    }
    else {
        cout << "-1 -1 -1\n";
    }

    return 0;
}


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

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	if (B % A == 0) cout << A + B << endl;
	else cout << B - A << endl;
	return 0;
}

Measured memory_bytes: 3556
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 9e18
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;

// 座標圧縮
int compress(vector<int> x, map<int, int> &zip, vi &unzip) {
	sort(x.begin(), x.end());
	x.erase(unique(x.begin(), x.end()), x.end());
	for (int i = 0; i < x.size(); i++) {
		zip[x[i]] = i;
		unzip[i] = x[i];
	}
	return x.size();
}

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

	int N, K;
	cin >> N >> K;
	vi x(N), y(N);
	rep(i, N) {
		cin >> x[i] >> y[i];
	}

	map<int, int> xzip, yzip;
	vi xunzip(N), yunzip(N);

	int X = compress(x, xzip, xunzip);
	int Y = compress(y, yzip, yunzip);

	vvi cum(X+1, vi(Y+1,0));
	rep(i, N) {
		cum[xzip[x[i]]+1][yzip[y[i]]+1]++;
	}
	repr(i, 1, X + 1) rep(j, Y + 1){
		cum[i][j] += cum[i - 1][j];
	}
	rep(i, X + 1)repr(j, 1, Y + 1) {
		cum[i][j] += cum[i][j - 1];
	}
	ll ans = INFL;
	repr(x1, 1, X + 1)repr(x2, x1, X+1)repr(y1, 1, Y + 1)repr(y2, y1, Y+1) {
		if (cum[x2][y2] - cum[x1-1][y2] - cum[x2][y1-1] + cum[x1-1][y1-1] >= K) {
			ans = min(ans, ((ll)xunzip[x2 - 1] - xunzip[x1 - 1])*((ll)yunzip[y2 - 1] - yunzip[y1 - 1]));
		}
	}
	cout << ans << endl;

	return 0;
}

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

struct btree_node
{
    btree_node(void):zero(nullptr), one(nullptr){}
    btree_node *zero;
    btree_node *one;
};

int main(void)
{
    int N;
    long long L;
    std::cin >> N >> L;
    // Make a tree
    btree_node bn[100005];
    btree_node *next_node = bn+1;
    for(int i=0; i<N; ++i)
    {
        std::string line;
        std::cin >> line;
        auto p = &bn[0];
        for(auto c : line)
        {
            if(c == '0')
            {
                if(!p->zero)
                {
                    p->zero = next_node;
                    p = next_node;
                    ++next_node;
                }
                else
                    p = p->zero;
            }
            else // 1
            {
                if(!p->one)
                {
                    p->one = next_node;
                    p = next_node;
                    ++next_node;
                }
                else
                    p = p->one;
            }
        }
        assert(p-&bn[0] < 100005);
    }
    long long flag = 0;
    std::queue<std::pair<btree_node*,int>> Q;
    Q.push(std::make_pair(&bn[0], 0));
    while(!Q.empty())
    {
        auto p = Q.front();
        Q.pop();
        if(p.first->zero)
        {
            Q.push(std::make_pair(p.first->zero, p.second+1));
        }
        else
        {
            long long a = L-p.second;
            flag ^= a&-a;
        }
        if(p.first->one)
        {
            Q.push(std::make_pair(p.first->one, p.second+1));
        }
        else
        {
            long long a = L-p.second;
            flag ^= a&-a;
        }
    }
    std::cout << (flag ? "Alice" : "Bob") << std::endl;
    return 0;
}


Measured memory_bytes: 2048
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

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

		Map<String, Integer> set = new HashMap<>();
		for (int i = 0; i < n; i++) {
			String s = sc.next();
			char[] ch = s.toCharArray();
			Arrays.sort(ch);
			String e = new String(ch);
			
			set.compute(e, (k, v) -> {
				return v == null ? 0 : v + 1;
			});

		}
		
		long cnt = 0;
		for( Integer it : set.values() ) {
			long nn = it;
			cnt += nn*(nn+1)/2;
		}

		System.out.println(cnt);

	}
}


Measured memory_bytes: 69452
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))


def fur(n,r):
    p,q = 1,1
    for i in range(r):
        p = p*(n-i)%mod
        q = q*(i+1)%mod
    return p * pow(q,mod-2,mod) % mod

x, y = nm()

if (x + y) % 3 != 0:
    print(0)
    exit()

n = (2*y - x) // 3 # (X, Y) -> (X+1, Y+2) 
m = (2*x - y) // 3 # (X, Y) -> (X+2, Y+1) 

if n < 0 or m < 0:
    print(0)
    exit()

print(fur(n+m, n))



Measured memory_bytes: 3696
a, b = map(int, input().split())
cnt = 0
l = []
newl = []

for i in range(a, b+1):
    l = []
    while (i > 0):
        l.append(i%10)
        i//=10
    newl = l[::-1]
    if (l == newl):
        cnt+=1
print(cnt)


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    int m,d,ans=0;
    cin >> m >> d;
    for(int i=1;i<=m;i++){
        for(int j=20;j<=d;j++){
            if(j%10==1) continue;
            int now=j;
            int cnt=1;
            rep(i,2){
                cnt*=now%10;
                now/=10;
            }
            if(cnt==i) ans++;
        }
    }
    
    cout << ans << endl;

    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define LONG_LONG_MAX    9223372036854775807LL
#define LONG_LONG_MIN    (-LONG_LONG_MAX-1)


/*
3
0 1 1
1 0 1
1 1 1
*/

vector<vector<int> >v;
vector<vector<int> >dp;
int n;

int ways(int men,int women){
    //cout << "men: "<<men<<"\n";
    //cout<<"women: "<<bitset<10>(women)<<"\n";
    //int q;cin>>q;

    if(men==n){
        //cout<<"in1\n";
        return 1;
    }
    if(dp[men][women]!=-1){
        //cout<<"in2\n";
        return dp[men][women];
    }
    int w=0;
   for(int i=0;i<n;i++){
       //cout<<"ttth: "<<i<<" ,"<< bitset<10>((women&(1<<i)))<<" "<<v[men][i]<<"\n";
        if((women&(1<<i)) && v[men][i]==1){
            //cout<<"ith: "<<i<<" ,"<< bitset<10>(women&(~(1<<i)))<<"\n";
            w += ways(men+1,(women&(~(1<<i))));
            w %=mod;
        }
   }
   return dp[men][women] = w;
}

void solve(){
   cin>>n;
   v.resize(n,vector<int>(n,0));
   //cout << "SHUBH01\n";
   for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
        cin>>v[i][j];
    }
   }
   //cout << "SHUBH02\n";
   int men = (1<<n)-1;
   int women = (1<<n)-1;
   //cout << "SHUBH03"<<men<<" "<<women<<"\n";
   dp.resize(n+1,vector<int>(women+1,-1));
   //cout << "SHUBH04\n";
   cout<<ways(0,women)<<"\n";

}

int main(){
//    cin.tie(0);
//    cout.tie(0);
//    cin.sync_with_stdio(0);
//    cout.sync_with_stdio(0);

    cout.precision(10);
    int t=1;//cin>>t;
    while(t--){

        solve();
    }
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  rep(i,n) cin >> x[i] >> y[i];
  // lambda function
  auto dist = [&](int i, int j) {
    double dx = x[i]-x[j];
    double dy = y[i]-y[j];
    return sqrt(dx*dx+dy*dy);
  };
  
  vector<int> p(n);

  rep(i, n) p[i] = i;
  double len = 0;
  int cnt = 0;
  do{
    rep(i, n-1) {
      len += dist(p[i], p[i+1]);
    }
    cnt++;
  } while (next_permutation(p.begin(), p.end()));
  double ans = len/cnt;
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 256