akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;

int main(){
	int x; cin>>x;
	if(x<=599) cout<<8<<endl;
	else if(x>=600&&x<=799) cout<<7<<endl;
	else if(x>=800&&x<=999) cout<<6<<endl;
	else if(x>=1000&&x<=1199) cout<<5<<endl;
	else if(x>=1200&&x<=1399) cout<<4<<endl;
	else if(x>=1400&&x<=1599) cout<<3<<endl;
	else if(x>=1600&&x<=1799) cout<<2<<endl;
	else cout<<1<<endl;
}

Measured memory_bytes: 3628
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n string
	fmt.Scan(&n)
	nInt, _ := strconv.Atoi(n)
	ans := 0
	for i:=1; i<nInt+1; i++ {
		if i < 10 {
			ans++
		} else if 99 < i && i < 1000 {
			ans++
		} else if 9999 < i && i < 100000 {
			ans++
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
#include<stdio.h>
#include<algorithm>
using namespace std;
int A[40000];
int B[40000];
int C[40000];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%d",A+i);
		for(int i=0;i<a;i++)scanf("%d",B+i);
		std::sort(A,A+a);
		std::sort(B,B+a);
		for(int i=0;i<a;i++){
			C[i]=lower_bound(A,A+a,B[i]+1)-A-1;
		}
		bool ok=false;
		for(int i=1;i<a;i++){
			int t=a-i;
			if(C[a-(i+1)/2]<a-i){
				ok=true;
				printf("%d\n",i);
				break;
			}
		}
		if(!ok)printf("NA\n");
	}
}

Measured memory_bytes: 1524
"""
@author:  wangquaxiu
@time:  2020/4/20 22:04
"""


n,m = map(int,input().split())
box = [[1,0] for _ in range(n+1)]
box[1][1] = 1
# print(n,m)
count = 0
for i in range(m):
    x,y = map(int,input().split())
    if(box[x][0] == 1 and box[x][1] == 1):
        box[x][1] = 0
        box[y][1] = 1
    elif(box[x][1] == 1):
        box[y][1] = 1

    box[x][0] -= 1
    box[y][0] += 1

for b in box:
    if(b[1] == 1):
        count+=1

print(count)

Measured memory_bytes: 13172
#include<stdio.h>
int main() {
   int N, M;
   int answer = 0;
   scanf("%d %d", &N, &M);
   
   for(int i = 1; i < N; i++) {
      answer += i;
   }
   for(int i = 1; i < M; i++) {
      answer += i;
   }
   printf("%d\n", answer);
   return 0;
}


Measured memory_bytes: 1676
#include<iostream>
#include<vector>
#include<string>

int main(){
    std::string S;
    std::cin >> S;
    int a = S[S.size() - 1] - '0';
    if(a == 2 || a == 4 || a == 5 || a == 7 || a == 9){
        std::cout << "hon" << std::endl;
    }else if(a == 0 || a == 1 || a == 6 || a == 8){
        std::cout << "pon" << std::endl;
    }else{
        std::cout << "bon" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3596
N, M = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))

ans = 0
for ii in range(2**N):
    check = True
    for i in range(M):
        cnt = 0
        for j in range(1, len(ks[i])):
            if (ii >> (ks[i][j]-1)) & 1:
                cnt += 1
        if cnt % 2 != p[i]:
            check = False
            break
    if check:
        ans += 1
print(ans)

Measured memory_bytes: 9224
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d", &a);
    scanf("%d", &b);
    
    if(a<b)
    {
        printf("a < b\n");
    }
    else if(a>b)
    {
        printf("a > b\n");
    }
    else
    {
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2696
#frozen_sr\tring_literal: true

a = gets.chomp.to_i + 1
b = gets.chomp.to_i + 1
c = gets.chomp.to_i + 1
x = gets.chomp.to_i
cnt = 0
a.times do |s|
    b.times do |t|
        c.times do |u|
            if s * 500 + t * 100 + u * 50 == x
                cnt += 1
            end
        end
     end
end

puts cnt

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
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;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll n,x,y,dis,l,r;
map<ll,ll> m;
int main()
{
    //IOS;
    cin>>n>>x>>y;
    for(int i=1; i<=n; i++)
    {
        for(int j=i+1; j<=n; j++)
        {
            /*if(i<=j)
            {
                continue;
            }*/
            l=i,r=j;
            if(i==j)
            {
                continue;
            }
            if(l<=r&&r<=x&&x<=y)
            {
                dis=(r-l);
            }
            else if(x<=y&&y<=l&&l<=r)
            {
                dis=(r-l);
            }
            else if(x<=l&&l<=r&&r<=y)
            {
                dis=min((r-l),(l-x)+1+(y-r));
            }
            else if(l<=x&&x<=y&&y<=r)
            {
                dis=(x-l)+1+(r-y);
            }
            else if(l<=x&&x<=r&&r<=y)
            {
                dis=min((r-l),((x-l)+1+(y-r)));
                /*if(dis==1)
                {
                    cout<<i<<' '<<j<<' '<<(r-l)<<' '<<(l-x)+1+(y-r)<<endl;
                }*/
            }
            else if(x<=l&&l<=y&&y<=r)
            {
                dis=min((r-l),((l-x)+1+(r-y)));
                /*if(dis==1)
                {
                    cout<<i<<' '<<j<<' '<<(r-l)<<' '<<(l-x)+1+(y-r)<<endl;
                }*/
            }
            /*if(dis==1)
            {
                cout<<i<<' '<<j<<endl;
            }*/
            m[dis]++;
        }
    }
    for(int i=1;i<=n-1;i++)
    {
        cout<<m[i]<<endl;
    }
    return 0;
}
/*

*/


Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
    string s;
    int q;
    cin >> s >> q;
    bitset<1> state = 1;//1なら元の順、0なら逆順
    rep(i, q) {
        int t; cin >> t;
        if (t == 1) state.flip();
        else {
            int f; char c; cin >> f >> c;
            if (state == 1) {
                if (f == 1) s.insert(s.begin(), c);
                else s.push_back(c);
            } else {
                if (f == 1) s.push_back(c);
                else s.insert(s.begin(), c);
            }
        }
    }

    if (state == 1) cout << s << endl;
    else {
        reverse(all(s));
        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 900
#include <vector>
#include <iostream>
using namespace std;
struct edge{
    int to;
    int cap;
    long long cost;
    int inv;
};
struct primal{
    long long INF;
    int V;
    vector<int> prevv, preve;
    vector<vector<edge>> G;
    primal(int N){
        V = N;
        prevv.resize(V);
        preve.resize(V);
        G.resize(V);
        INF = 1e18;
    }
    void add(int s, int t, int cap, long long cost){
        edge e1 = {t, cap, cost, (int)G[t].size()};
        G[s].push_back(e1);
        edge e2 = {s, 0, -cost, (int)G[s].size() - 1};
        G[t].push_back(e2);
    }
    long long solve(int s, int t, int f){
        int res = 0;
        while(f > 0){
            vector<long long> d(V, INF);
            bool update = true;
            d[s] = 0;
            while(update){
                update = false;
                for(int i = 0; i < V; i++){
                    if(d[i] == INF) continue;
                    for(int j = 0; j < (int)G[i].size(); j++){
                        edge e = G[i][j];
                        if(e.cap > 0 && d[e.to] > d[i] + e.cost){
                            d[e.to] = d[i] + e.cost;
                            prevv[e.to] = i;
                            preve[e.to] = j;
                            update = true;
                        }
                    }
                }
            }
            if(d[t] == INF) return INF;
            int dmin = f;
            for(int v = t; v != s; v = prevv[v]){
                dmin = min(dmin, G[prevv[v]][preve[v]].cap);
            }
            f -= dmin;
            res += d[t] * dmin;
            for(int v = t; v != s; v = prevv[v]){
                edge &e = G[prevv[v]][preve[v]];
                e.cap -= dmin;
                G[v][e.inv].cap += dmin;
            }
        }
        return res;
    }
};

int main(){
    int N, K;
    cin >> N >> K;
    vector<vector<long long>> A(N, vector<long long>(N));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++) cin >> A[i][j];
    }
    primal pd(N * N + 2*N + 2);
    const int start = N * N + 2 * N, goal = N * N + 2 * N + 1;
    for(int i = 0; i < N; i++){
        pd.add(start, N * N + i, K, 0);
        pd.add(N * N + N + i, goal, K, 0);
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            pd.add(N * N + i, i * N + j, 1, 0);
            pd.add(i * N + j, N * N + N + j, 1, -A[i][j]);
        }
    }
    long long ans = 0;
    long long res = 0;
    vector<vector<edge>> g;
    while(1){
        long long temp = pd.solve(start, goal, 1);
        if(temp == pd.INF) break;
        res += -temp;
        if(res > ans){
            ans = res;
            g = pd.G;
        }
    }
    cout << ans << endl;
    vector<vector<char>> judge(N, vector<char>(N, '.'));
    for(int i = 0; i < N; i++){
        for(edge e: g[N * N + i]){
            if(e.to == start || e.cap > 0) continue;
            if(e.cap == 0){
                int x = e.to / N, y = e.to % N;
                judge[x][y] = 'X';
            }
        }
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++) cout << judge[i][j];
        cout << endl;
    }
}

Measured memory_bytes: 4428
#include<bits/stdc++.h>
#define rgi register int
#define ll long long
class fastin{
	private: int _ch,_f;
	public: inline fastin& operator>>(char&c) {c=getchar(); return *this;}
		template<typename _Tp> inline fastin& operator>>(_Tp&_x){
		_x=0; while(!isdigit(_ch)) _f|=(_ch==45),_ch=getchar();
		while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
		_f&&(_x=-_x,_f=0); return *this;}
	fastin() {_ch=_f=0;}
}fin;
class fastout{
#define endl '\n'
	private: int _num[32],_head;
	public: inline fastout& operator<<(char c) {putchar(c); return *this;}
		template<typename _Tp> inline fastout& operator<<(_Tp _x){
		_Tp _k; if(_x==0) {putchar('0'); return *this;} if(_x<0) putchar('-'),_x=-_x;
		while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
		while(_head>0) putchar(_num[_head]),--_head; return *this;}
	fastout() {_head=0;}
}fout;
// ----------------------------
// #define int ll
// using namespace std;
const int maxn=200004;
const int mod=998244353,inf=1000000007;

signed main()
{
	int a,b,c,d,e;
	fin>>a>>b>>c>>d>>e;
	fout<<(c-a)*60+d-b-e;
	return 0;
}
// ----------------------------
// by imzzy


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

using namespace std;

int main(){
  
  long a,b;
  long ans;
  
  cin >> a >> b;
  
  for(int i=0; i<=1e9; i++){
    if(abs(a-i) == abs(b-i)){
      cout<<i<<endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" <<endl;
  
  return 0;
}


Measured memory_bytes: 256
program CCC
!
      implicit none
      integer :: A,N,M
!
      read(*,*) N
!
      A = 0
!
      do A=1,N-1
        M = N/A + M
        if(mod(N,A) == 0) M = M-1
      end do
!
      write(*,*) M
!
      end program CCC

Measured memory_bytes: 2856
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>

using namespace std;
template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}
template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp make_pair
#define pb push_back
#define y2 y2228
const string FILENAME = "input";
const int MAXN = 200228;
const int Mod = 1000000007;



int mul(int a, int b) {
	return (1LL * a * b) % Mod;
}


int sum(int a, int b) {
	return (a + b) % Mod;
}


int n;
int c[MAXN];
int dp[MAXN];
int kek[MAXN];


int  main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    //read(FILENAME);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	} 
	for (int i = 0; i < n; i++) {
		dp[i] = (i == 0 ? 1: sum(dp[i - 1], (c[i] != c[i - 1] ? kek[c[i]]: 0)));
		//cout << dp[i] << endl;
		if (i == 0 || (c[i] != c[i - 1])) {
			kek[c[i]] = sum(kek[c[i]], (i == 0 ? 1: dp[i - 1]));
		}
	}
	cout << dp[n - 1] << '\n'; 
 	return 0; 
}


Measured memory_bytes: 2560
import sys
def S(): return sys.stdin.readline().rstrip()
S = S()
seq = [0]*(len(S)+1)
for i in range(len(S)):
    if S[i]=='<':
        seq[i+1] = seq[i]+1
for j in range(len(S))[::-1]:
    if S[j]=='>':
        seq[j] = max(seq[j],seq[j+1]+1)
print(sum(seq))


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

#define N 20

const struct
{
  char s[ 8 ];
  int  p;
} d[ N ] = {
  { "yotta", 24 },
  { "zetta", 21 },
  { "exa", 18 },
  { "peta", 15 },
  { "tera", 12 },
  { "giga", 9 },
  { "mega", 6 },
  { "kilo", 3 },
  { "hecto", 2 },
  { "deca", 1 },
  { "deci", -1 },
  { "centi", -2 },
  { "milli", -3 },
  { "micro", -6 },
  { "nano", -9 },
  { "pico", -12 },
  { "femto", -15 },
  { "ato", -18 },
  { "zepto", -21 },
  { "yocto", -24 },
};

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int n;
  int i;

  scanf ( "%d", &n );
  while ( n-- )
  {
    char v[ 2048 ];
    char t[ 64 ];
    int e = 0;

    scanf ( " %s %s", v, t );
    for ( i = 0; i < N; ++i )
    if ( strcmp ( t, d[ i ].s ) == 0 )
    {
      e = d[ i ].p;
      scanf ( " %s", t );
    }

    if ( strncmp ( "0.", v, 2 ) == 0 )
    {
      memmove ( v, v + 2, strlen ( v + 1 ) );
      e -= strlen ( v );
    }
    else
    {
      char *p = strchr ( v, '.' );
      if ( p != NULL )
      {
        e -= strlen ( p + 1 );
        memmove ( p, p + 1, strlen ( p + 1 ) + 1 );
      }
    }

    for ( i = 0; v[ i ] != '\0'; ++i )
    if ( v[ i ] != '0' )
    {
      if ( i != 0 )
        memmove ( v, v + i, strlen ( v + i ) + 1 );
      break ;
    }

    if ( v[ i + 1 ] == '\0' )
      printf ( "%s * 10^%d %s\n", v, e, t );
    else
      printf ( "%c.%s * 10^%d %s\n", v[ 0 ], v + 1
             , e + (int)strlen ( v + 1 ), t );
  }

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 636
n,w = map(int,input().split())
box = []
for i in range(n):
  W,V = map(int,input().split())
  box.append([W,V])
dp = [[0 for i in range(w+1)] for j in range(n+1)]

for i in range(1,n+1):
  for j in range(w+1):
    if j >= box[i-1][0]:
      dp[i][j] = max(dp[i-1][j-box[i-1][0]] + box[i-1][1] ,dp[i-1][j])
    else:
      dp[i][j] = dp[i-1][j]
print(dp[n][w])

Measured memory_bytes: 171528
#include<stdio.h>

int main(){
	int n,m,d,p,a,i;

	for( ; scanf("%d%d",&n,&m) , n|m ; printf("%d\n",a) ){
		a=0;
		int f[12]={0};
		for( i=n ; i-- ; f[p] += d )
			scanf("%d%d",&d,&p);
		for( i=10 ; i >= 0 ; a += f[i]*i , i-- )
			for( ; f[i] && m ; )
				m--,f[i]--;
	}
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 100001
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

bool b[501];
int main(){
	int n, m, t1,t2;
	while(1){
		stack<int> s[501];
		scanf("%d%d", &n, &m);
		if(!n)break;
		fill(b, b+501, false);
		rep(i,m){
			scanf("%d%d", &t1, &t2);
			s[t1].push(t2);
			s[t2].push(t1);
		}
		while(!s[1].empty()){
			t1 = s[1].top();s[1].pop();
			b[t1] = 1;
			while(!s[t1].empty()){
				t2 = s[t1].top();s[t1].pop();
				b[t2] = true;
			}
		}
		int ans = 0;
		rrep(i,n)if(b[i]&&i!=1)ans++;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3468
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  long a, b, c=0, d=0, e, f, g, h, n;
  string odd, even, pas={};
  cin >> odd >> even;
  rep(i,0,even.size()){
    pas+=odd[i];
    pas+=even[i];
  }
  if(odd.size()!=even.size()) pas+=odd[odd.size()-1];
  co(pas);
  
  return 0;
}

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


int main()
{
	int N;
	cin>>N;
	cout<<(N+1)/2<<endl;
	return 0;
}


Measured memory_bytes: 3680
N,M=map(int,input().split())
K=[]
like=[]
food=[]
for i in range(N):
    B=[int(h) for h in input().split()]
    K.append(B[0])
    B.remove(B[0])
    for k in range(K[i]):
        like.append(B[k])
  
for j in range(1,M+1):
    food.append(like.count(j))

print(food.count(N))
    
  

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int N;
lint X[15], Y[15], P[15];
lint dst_x[1 << 15][15], dst_y[1 << 15][15];
lint ans[16];

void rec(int i, int Sx, int Sy, int K) {
    if (i == N) {
        lint val = 0;
        for_(k,0,N) val += min(dst_x[Sx][k], dst_y[Sy][k]) * P[k];
        ans[K] = min(ans[K], val);
        return;
    }

    rec(i + 1, Sx, Sy, K);
    rec(i + 1, Sx | 1 << i, Sy, K + 1);
    rec(i + 1, Sx, Sy | 1 << i, K + 1);
}

int main() {
    cin >> N;
    for_(i,0,N) cin >> X[i] >> Y[i] >> P[i];
    for_(i,0,N+1) ans[i] = 1LL << 60;

    for_(S,0,1<<N) {
        for_(i,0,N) {
            lint mnx = abs(X[i]), mny = abs(Y[i]);
            for_(j,0,N) {
                if (S >> j & 1) {
                    mnx = min(mnx, abs(X[j] - X[i]));
                    mny = min(mny, abs(Y[i] - Y[j]));
                }
            }
            dst_x[S][i] = mnx;
            dst_y[S][i] = mny;
        }
    }

    rec(0, 0, 0, 0);

    for_(i,0,N+1) cout << ans[i] << endl;
}

Measured memory_bytes: 11256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
signed main(){
  int H,W;
  cin>>H>>W;
  vector<string> A(H);
  for(string &S:A)cin>>S;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++){
      if(A[i][j]=='.')goto home;
      for(int k=0;k<4;k++){
        int x=i+dx[k],y=j+dy[k];
        if(0<=x && x<H && 0<=y && y<=W && A[x][y]=='#')goto home;
      }
      puts("No");
      return 0;
      home:;
    }
  puts("Yes");
}

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

typedef long long ll;
typedef vector<int> vi;
#define PB push_back
#define MP make_pair
#define endl '\n'
#define all(a) (a).begin(),(a).end()
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int n,k;
int arr[100005];
int dp[100005];

int f(int indx)
{
    if(indx>=n-1)
        return 0;

    if(dp[indx]!=-1)
        return dp[indx];
     int x=INT_MAX;
     for(int i=1;i<=2;i++)
     {
         if(indx+i<=n-1)
            x=min(x,abs( arr[indx]-arr[indx+i])+f(indx+i));
     }
    return dp[indx]=x;
}

int main()
{
    optimize();
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>arr[i];

   memset(dp,-1,sizeof(dp));
    cout<<f(0)<<endl;
    return 0;
}


Measured memory_bytes: 7512
from sys import stderr, setrecursionlimit
setrecursionlimit(2147483647)
def getInt():
    return int(input())
def getInts():
    return [int(i) for i in input().split()]
def getIntLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInt())
    return res
def getIntsLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInts())
    return res
def debug(*args, **kwargs):
    print(*args, file=stderr, **kwargs)

n = getInt()
a = getInts()
colors = [0, 0, 0, 0, 0, 0, 0, 0, 0]
for rate in a:
    if rate <= 399:
        colors[0] += 1
    elif rate <= 799:
        colors[1] += 1
    elif rate <= 1199:
        colors[2] += 1
    elif rate <= 1599:
        colors[3] += 1
    elif rate <= 1999:
        colors[4] += 1
    elif rate <= 2399:
        colors[5] += 1
    elif rate <= 2799:
        colors[6] += 1
    elif rate <= 3199:
        colors[7] += 1
    else:
        colors[8] += 1

monocolors = len(list(filter(lambda x:x!=0,colors[:-1])))
if monocolors == 0:
    print(1, colors[8])
else:
    print(monocolors, monocolors + colors[8])

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	int ret=0, l, r;
	for (int i=0; i<n; i++)
		cin>>l>>r, ret+=r-l+1;
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N;
string s[3];

void solve(){
	int ans = 0;
	rep(i, N){
		if(s[0][i] == s[1][i]){
			if(s[1][i] == s[2][i]){
				continue;
			}
			else{
				ans++;
			}
		}
		else if(s[1][i] == s[2][i]){
			ans++;
		}
		else if(s[0][i] == s[2][i]){
			ans++;
		}
		else
			ans+=2;
	}
	cout << ans << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	rep(i, 3) {
		cin >> s[i];
	}
	solve();
	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()

ans = 0

for i in range(len(S)):
    s1 = S[0:i+1]
    s2 = S[i+1:len(S)]
    #print(s1,s2)
    set1 = set(s1)
    set2 = set(s2)
    #print(set1, set2)
    inse = set1.intersection(set2)
    #print(inse)
    ans = max(ans, len(inse))

print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <iostream>

using namespace std;

int ans[300'009];

int main() {
  int n, a, b;
  scanf("%d %d %d", &n, &a, &b);
  if (a + b - 1 > n || n > (long long)a * b) {
    puts("-1");
    return 0;
  }
  int w = 0;
  if (b > a) {
    swap(a, b);
    w = 1;
  }
  for (int i = 0; i < n; i += a) {
    int j = min(i + a - 1, n - 1);
    for (int k = j; k >= i; --k) {
      ans[i + j - k] = w == 0 ? n - k : k + 1;
    }
  }
  for (int i = n / a * a; i >= 0; i -= a) {
    int rem = n - i;
    if (i / a + rem >= b) {
      int need = b - i / a;
      int extra = rem - need + 1;
      sort(ans + i, ans + n);
      if (w == 0) {
        reverse(ans + i, ans + n);
      }
      for (int j = 0; j < extra / 2; ++j) {
        swap(ans[i + j], ans[i + extra - 1 - j]);
      }
      break;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (i > 0) {
      putchar(' ');
    }
    printf("%d", ans[i]);
  }
  putchar('\n');
}


Measured memory_bytes: 3328
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out = 0, fh = 1;
	char jp = getchar();
	while ((jp > '9' || jp < '0') && jp != '-')
		jp = getchar();
	if (jp == '-')
		fh = -1, jp = getchar();
	while (jp >= '0' && jp <= '9')
		out = out * 10 + jp - '0', jp = getchar();
	return out * fh;
}
int main()
{
	int a = read(), b = read(), c = read(), d = read(), f = 1;
	while (1)
	{
		c -= b;
		if (c <= 0)
			return puts(f ? "Yes" : "No"), 0;	
		swap(a, c), swap(b, d);
		f ^= 1;
	}	
	return 0;
}


Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
x,y=[0]*N,[0]*N
for i in range(N):
    a,b=map(int,input().split())
    x[i],y[i]=a+b,a-b
x.sort()
y.sort()
print(max(max(x)-min(x),max(y)-min(y)))

Measured memory_bytes: 75532
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int N; cin >> N;
    string S; cin >> S;
    int K; cin >> K;
    
    char c = S[K-1];
    for(int i=0; i<N; i++){
        if(S[i]!=c) S[i] = '*';
    }
    cout << S << endl;
    return 0;
}


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

typedef long long int ll;
#define pb push_back
#define mp make_pair
#define N 300005

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	double n;
	cin>>n;
	double ans = M_PI*n*2;
	cout<<ans<<endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> h(N), m(N);
  for (int i = 0; i < N; ++i)
    cin >> h[i] >> m[i];
  int M;
  cin >> M;
  vector<int> k(M), g(M);
  for (int i = 0; i < M; ++i)
    cin >> k[i] >> g[i];

  vector<int> t(N + M);
  for (int i = 0; i < N + M; ++i) {
    if (i >= 0 && i < N)
      t[i] = h[i] * 60 + m[i];
    else
      t[i] = k[i - N] * 60 + g[i - N];
  }

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

  int prev = -1;
  for (int i = 0; i < N + M; ++i) {
    if (t[i] != prev) {
      if (i) cout << " ";
      if (t[i] % 60 >= 10)
        cout << t[i] / 60 << ':' << t[i] % 60;
      else
        cout << t[i] / 60 << ':' << 0 << t[i] % 60;
    }

    prev = t[i];
  }
  cout << endl;
}


Measured memory_bytes: 3152
#coding:utf-8
#1_5_B
def merge_sort(array):
    if len(array) > 1:
        L, countL = merge_sort(array[0:len(array)//2])
        R, countR = merge_sort(array[len(array)//2:])
        return merge(L, R, countL+countR)

    if len(array) == 1:
        return [array, 0]

def merge(L, R, count=0):
    L.append(10**9+1)
    R.append(10**9+1)
    response = []
    i = 0
    j = 0
    for k in range(len(L)-1 + len(R)-1):
        if L[i] <= R[j]:
            response.append(L[i])
            i += 1
            count += 1
        else:
            response.append(R[j])
            j += 1
            count += 1
    return [response, count]

n = int(input())
S = list(map(int, input().split()))
numbers, count = merge_sort(S)
print(*numbers)
print(count)

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

int main(){
	int H, W;
	cin >> H >> W;
	vector<string> a(H);
	for(int i=0;i<H;i++){
		cin >> a.at(i);
	}
	
	for(int i=0;i<W+2;i++){
		cout << "#";
	}
	cout << endl;
	
	for(int i=0;i<H;i++){
		cout << "#" << a.at(i) << "#" << endl;
	}
	
	for(int i=0;i<W+2;i++){
		cout << "#";
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <set>
#include <stdlib.h>
using namespace std;
int main()
{
    int a,b,c,x,ans;
    cin>>a>>b>>c>>x;
    for (int i=0;i<=a;i++)
    {
    	for (int j=0;j<=b;j++)
    	{
    		for (int m=0;m<=c;m++)
        {
        	if (500*i+100*j+50*m==x) ans++;
		}
		}
	}   
	cout<<ans;	
	return 0;   
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

const int inf=1e9+10;
const int maxn=2e5+10;

vector <pair<ll,ll> > v;
ll ans=0,n,a,d;
queue <pair<ll,ll> > que;

ll calc(ll x){
	return (x%a==0?ll(x/a):ll(ll(x/a)+1ll));
}

int main(){
	scanf("%lld%lld%lld",&n,&d,&a);
	for(int i=0;i<n;i++){
		ll x,h;
		scanf("%lld%lld",&x,&h);
		v.pb(mp(x,h));
	}
	sort(v.begin(),v.end());
	int t=0;
	for(int i=0;i<n;i++){
	//	if(!que.empty()) printf("%lld\n",que.front().fst);
		while(!que.empty()&&que.front().fst<v[i].fst){
			t-=que.front().snd;
			que.pop();
		}
		v[i].snd-=t;
		if(v[i].snd<=0) continue;
		t+=ll(calc(v[i].snd)*a);
		ans+=calc(v[i].snd);
		que.push(mp(ll(v[i].fst+ll(2ll*d)),ll(calc(v[i].snd)*a)));
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 6512
/*
 * atcoder/dp_3rd/f.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

string S, T;
int N, M;
ll dp[3100][3100];

void input() {
  cin >> S >> T;
  N = S.size(); M = T.size();
}

ll rec(int n = 0, int m = 0) {
  ll &cc = dp[n][m];
  if (~cc) return cc;
  if (n == N || m == M) return cc = 0;
  ll max_ = 0;
  chmax(max_, (S[n] == T[m]) + rec(n + 1, m + 1));
  chmax(max_, rec(n + 1, m));
  chmax(max_, rec(n, m + 1));
  return cc = max_;
}

void memoRec() {
  memset(dp, -1, sizeof(dp));
  rec();
  ll count = dp[0][0];
  vector<char> lcs(count+1);
  ll n = 0, m = 0;
  while (n < N && m < M) {
    if (S[n] == T[m]) {
      lcs[dp[n][m]] = S[n];
      n++;m++;
      continue;
    }

    if (dp[n+1][m] > dp[n][m+1]) n++;
    else m++;
  }
  for (int i=count; i>=1; i--) cout << lcs[i];
  cout << endl;
}

void give() {
  memset(dp, 0, sizeof(dp));
  for (int n=1; n<=N; n++) {
    for (int m=1; m<=M; m++) {
      chmax(dp[n][m], (S[n-1] == T[m-1]) + dp[n-1][m-1]);
      chmax(dp[n][m], dp[n][m-1]);
      chmax(dp[n][m], dp[n-1][m]);
    }
  }
  ll count = dp[N][M];
  vector<char> lcs(count+1);
  ll n = N, m = M;
  while (n > 0 && m > 0) {
    if (S[n-1] == T[m-1]) {
      lcs[dp[n][m]] = S[n-1];
      n--;m--;
      continue;
    }

    if (dp[n-1][m] > dp[n][m-1]) n--;
    else m--;
  }
  for (int i=1; i<=count; i++) cout << lcs[i];
  cout << endl;
}

void dump() {
  for (int n=0; n<=N; n++) {
    for (int m=0; m<=M; m++) {
      cout << dp[n][m] << " ";
    }
    cout << endl;
  }
}

void solve() {
  // memoRec();
  give();
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 75392
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define forsn(i,x,y) for(long long i = (x) ; i <= (y) ; ++i)
typedef long long ll;
typedef long double ld;

int main() {
  int a, b;
  cin >> a >> b;
  if(a == 0 || b == 0) {
    cout << "Zero" << endl;
  }
  else if(a > 0) {
    cout << "Positive" << endl;
  }
  else if(b > 0) {
    cout << "Zero" << endl;
  }
  else {
    if((b-a) % 2 == 0) {
      cout << "Negative" << endl;
    }
    else {
      cout << "Positive" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

int main(){
  int N;
  while(cin>>N){
    vector<int> a(N+10,0);
    vector<int> dist(N+10,-1);
    REP(i,N)cin>>a[i];
    deque<int> que;
    que.push_back(0);
    dist[0] = 0;
    int ans = -1;
    while(!que.empty()){
      int current = que.front(); que.pop_front();
      int now = dist[current];
      //printf("%d %d\n",current,now);
      if(current >= N-1){
        ans = now;
        break;
      }
      for(int dice = 6; dice >= 1; dice--){
        int next = current + dice;
        while(!(next >= N-1 || dist[next] != -1 || a[next] == 0)){
          dist[next] = now + 1;
          next += a[next];
        }
        if(dist[next] == -1){
          dist[next] = now + 1;
          que.push_back(next);
        }
      }
    }
    assert(ans != -1);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll h[100010];
    rep(i,0,N) cin >> h[i];
    ll dp[100010] = {};
    fill(dp, dp+N+1, INF);
    dp[0] = 0;
    rep(i,0,N){
        if(i < N-1){
            dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]));
        }
        if(i < N-2){
            dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]));
        }
    }
    print(dp[N-1]);


}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

ll n,m,T,k;
const ll big = 1000000007;
const ll big2 = 998244353;

bool inbounds(ll i, ll j){
    return i >= 0 && j >= 0 && i < n && j < m;
}

ll DX[4] = {0,0,1,-1};
ll DY[4] = {1,-1,0,0};
bool mark[401][401] = {0};

ll M[401][401] = {0};

pll siz(ll i, ll j){
    mark[i][j] = 1;
    pll res = {0,0};
    if((i+j)%2 == 0){
        res.first++;
    }
    else{
        res.second++;
    }
    for(int c1 = 0; c1 < 4; c1++){
        ll i2 = i+DX[c1];
        ll j2 = j+DY[c1];
        if(inbounds(i2,j2)){
                if(!mark[i2][j2] && M[i2][j2] == M[i][j]){
                    pll ny = siz(i2,j2);
                    res.first += ny.first;
                    res.second += ny.second;
                }
        }
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,e;

    cin >> n >> m;
    for(int c1 = 0; c1 < n; c1++){
        string s;
        cin >> s;
        for(int c2 = 0; c2 < m; c2++){
            a = 0;
            if(s[c2] == '#')a = 1;
            M[c1][c2] = (a+c1+c2)%2;
        }
    }

    ll ans = 0;
    for(int c1 = 0; c1 < n; c1++){
        for(int c2 = 0; c2 < m; c2++){
            if(!mark[c1][c2]){
                pll ny = siz(c1,c2);
                ans += ny.first*ny.second;
            }
        }
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 11648
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(void){
    // Your code here!
    int n,x,t;
    cin >> n >> x >> t;
    
    int y = n / x;
    
    if(n%x == 0){
        cout << y*t << endl;
    }else{
        cout << (y+1)*t << endl;
    }
    
    
    
    
}

Measured memory_bytes: 3632
n, m = map(int, input().split())
d = [0] * m

for i in range(n):
    k, *a = list(map(int, input().split()))
    for num in a:
        d[num-1] += 1

c = 0
for num in d:
    if num == n:
        c += 1
print(c)

Measured memory_bytes: 9080
"use strict";

var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/),
    cid = 0;

function next() {
    return +cin[cid++];
} // number一個取得
function nextstr() {
    return cin[cid++];
} // 文字列一個取得
function nextbig() {
    return BigInt(cin[cid++]);
} // BigInteger一個取得
// 長さnの配列として取得。aは文字列フラグ
function nexts(n, a) {
    return a ? cin.slice(cid, cid += n) : cin.slice(cid, cid += n).map(a => +a);
}
// 長さnのBigInt配列として取得。
function nextsbig(n) {
    return cin.slice(cid, cid += n).map(a => BigInt(a));
}
// w個ずつを組にして長さhの配列。aは文字列フラグ。
function nextm(h, w, a) {
    var r = [],
        i = 0;
    if (a)
        for (; i < h; i++) r.push(cin.slice(cid, cid += w));
    else
        for (; i < h; i++) r.push(cin.slice(cid, cid += w).map(a => +a));
    return r;
}
// 多次元配列。v,a1,a2,a3 なら、3次元。[[値vで長さa3の配列]をa2個並べた配列]をa1個並べた配列。
function xArray(v) {
    var a = arguments,
        l = a.length,
        r = "Array(a[" + --l + "]).fill().map(x=>{return " + v + ";})";
    while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")";
    return eval(r);
}


console.log(main().toString());

function main() {
    let n = next();
    let a = nexts(n);
    let min = a[0];
    let max = a[0];
    for (let i = 1; i < n; i++) {
        min = Math.min(min, a[i]);
        max = Math.max(max, a[i]);
    }
    return max - min;
}

Measured memory_bytes: 7372
h,w = map(int,input().split())
a = [input() for _ in range(h)]
tmp = []
flag = True
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            flag = False
    if flag:
        tmp.append(i)
    flag = True
flag = True
tmp2 = []
for i in range(w):
    for j in range(h):
        if a[j][i] == '#':
            flag = False
    if flag:
        tmp2.append(i)
    flag = True
t = set(tmp)
t2 = set(tmp2)
for i in range(h):
    for j in range(w):
        if i not in t and j not in t2:
            print(a[i][j],end='')
    if i not in t:
        print()


Measured memory_bytes: 9244
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define clr(x, y) memset(x,y,sizeof(x));
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i, m, n) for(int i=m ; i<n ; i++)
#define forr(i, m, n) for(int i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N = 2e5 + 5;
int OO = 1e9 + 7;
using namespace std;

int main() {
    IO;
    int n,k,a[N]; cin>>n>>k;
    rep(i,0,n) cin>>a[i];
    sort(a,a+n);
    int mn=INT_MAX;
    for(int i=0;i<=n-k;i++){
        mn=min(mn,a[i+k-1]-a[i]);
    }
    cout<<mn;
    

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MOD 1000000007
#define MAX 1000000

int main(){
  int N;
  cin>>N;
  vector<pair<int,int>> BA(N);
  for(int i=0;i<N;i++){
    cin>>BA.at(i).second>>BA.at(i).first;
  }
  sort(BA.begin(),BA.end());

  int sum=0;
  bool flag=true;
  for(int i=0;i<N;i++){
    sum+=BA.at(i).second;
    if(sum>BA.at(i).first){
      flag=false;
      cout<<"No"<<endl;
      break;
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }
}


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

ll calc(vector<ll> a, ll b) {
  ll ret = 0;
  for(auto x : a) ret+=abs(x-b);
  return ret;
}

int main() {
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> b(n);
  ll mmi = 0;
  ll pma = 0;
  rep(i,n) {
    b[i] = a[i]-(i+1);
    if(b[i]>0) pma = max(pma,b[i]);
    if(b[i]<0) mmi = max(mmi,-b[i]);
  }
  ll ans1 = 0;
  {
    ll ok = pma+1;
    ll ng = 0;
    while(abs(ok-ng)>1) {
      ll mid = (ok+ng)/2;
      if(calc(b, mid+1)-calc(b,mid)>0) {
	ok = mid;
      } else {
	ng = mid;
      }
    }
    // cout << "ans1:" << endl;
    // cout << ok << endl;
    ans1 = calc(b,ok);
  }
  ll ans2 = 0;
  {
    ll ok = mmi+1;
    ll ng = 0;
    while(abs(ok-ng)>1) {
      ll mid = (ok+ng)/2;
      if(calc(b, -mid)-calc(b,-mid-1)<0) {
	ok = mid;
      } else {
	ng = mid;
      }
    }
    // cout << "ans2:" << endl;
    // cout << ok << endl;
    ans2 = calc(b,-ok);
  }
  cout << min(ans1, min(ans2, calc(b,0))) << endl;
  return 0;
}


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

int main(void)
{
    IOS
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = a * c;
    ans = max(ans,a*d);
    ans = max(ans,b*c);
    ans = max(ans,b*d);
    cout << ans << '\n';

    return 0;
}

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

int main(){
    int A, B, C;
    cin >> A >> B >> C;

    if (A == B && B == C) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  string x;cin>>x;
  ll s=0,t=0;
  rep(i,x.size()){
    if(x[i]=='S')s++;
    if(x[i]=='T')t=min(s,t+1);
  }
  cout<<x.size()-2*t<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#define ll long long
using namespace std;
int main() {
    ll H = 0, N = 0;
    cin >> H >> N;
    ll total = 0;
    ll A = 0;
    for (ll i=0; i<N; ++i) {
        cin >> A;
        total += A;
    }
    if (total >= H) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h[100001];
int dp[100001];
int main(void){
	int n;
	cin>>n;
	int i,j;
	for(i=1;i<=n;i++)	cin>>h[i];
	for(i=0;i<=n;i++)	dp[i]=INT_MAX;
	dp[1]=0;
	for(i=1;i<=n;i++){
		if(i+1<=n)	dp[i+1]=min(dp[i]+abs(h[i]-h[i+1]),dp[i+1]);
		if(i+2<=n)	dp[i+2]=min(dp[i]+abs(h[i]-h[i+2]),dp[i+2]);
	}
	cout<<dp[n]<<endl;
	return 0;
}

	

Measured memory_bytes: 1024
r, c = map(int, input().split()) # r = 4, c = 5
ss = [list(map(int, input().split())) for row in range(r)] 
for line in ss:
	line.append(sum(line))

sum_line = [0 for i in range(c + 1)] # ?????????1????????§??????.
for line in ss:
	for i in range(c + 1):
		sum_line[i] += line[i]
ss.append(sum_line)

for i in range(r + 1):
	print(' '.join(map(str, ss[i])))

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1 && b == 1)cout << "Draw" << endl;
	else if (a == 1)cout << "Alice" << endl;
	else if (b == 1)cout << "Bob" << endl;
	else if (a > b) cout << "Alice" << endl;
	else if (b > a) cout << "Bob" << endl;
	else cout << "Draw" << endl;
	return 0;
}


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

using namespace std;
using ll = long long;

ll choose(vector<int> &ch_pos, int i, int j) {
  auto it = upper_bound(ch_pos.begin(), ch_pos.end(), j);
  ll ans = distance(it, ch_pos.end());
  bool found = binary_search(it, ch_pos.end(), 2 * j - i);
  if (found) {
    ans = max(0ll, ans - 1);
  }

  return ans;
}

int main(int argc, const char *argv[]) {
  int n;
  string s;
  cin >> n >> s;

  array<vector<int>, 256> ch_pos;
  for (int i = 0; i < n; i++) {
    ch_pos[s[i]].push_back(i);
  }

  array<char, 3> kinds{'B', 'G', 'R'};
  ll ans = 0;
  do {
    for (int i : ch_pos[kinds[0]]) {
      for (int j : ch_pos[kinds[1]]) {
        if (i < j) {
          ans += choose(ch_pos[kinds[2]], i, j);
        }
      }
    }
  } while (next_permutation(kinds.begin(), kinds.end()));
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3676
#include<iostream>
using namespace std;
int main(){
  int k,a,b,flag=0;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      
      flag=1;
    }
  }
  if(flag==1){
    cout<<"OK";}
  else cout<<"NG";
 
  return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	static int num[];
	static long dp[][];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		num = new int[N];
		for (int i = 0; i < N; i++) {
			num[i] = sc.nextInt();
		}
		dp = new long[N][21];
		System.out.println(DP(N));
	}
	private static long DP(int N) {
		dp[0][num[0]] = 1;
		for (int i = 1; i < N - 1; i++) {
			for (int j = 0; j <= 20; j++) {
				if (dp[i-1][j] > 0) {
					int plus = j + num[i];
					if (plus >=0 && plus <= 20) {
						dp[i][plus] += dp[i-1][j];
					}
					int minus = j - num[i];
					if (minus >=0 && minus <= 20) {
						dp[i][minus] += dp[i-1][j];
					}
				}
			}
		}
		return dp[N-2][num[N-1]];
	}
}

Measured memory_bytes: 18160
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

long ans = 1L<<60;

void main(){
    long h, w;
    readVars(h, w);
    calc(h, w);
    calc(w, h);
    writeln(ans);
}

void calc(long h, long w){
    long s0, s1, s2;
    foreach (a ; 1 .. w) {
        s0 = a * h;

        s1 = h * ((w - a + 1) / 2);
        s2 = h * ((w - a) / 2);

        ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2));

        s1 = (w - a) * ((h + 1) / 2);
        s2 = (w - a) * (h / 2);

        ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2));
    }
}

void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}

Measured memory_bytes: 256