akhauriyash/Code-Regression huggingface dataset:
module.exports=function(r){var e={};function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},t.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},t.t=function(r,e){if(1&e&&(r=t(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var o in r)t.d(n,o,function(e){return r[e]}.bind(null,o));return n},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},t.p="",t(t.s=0)}([function(r,e,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(r,e){function t(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=[],n=!0,o=!1,u=void 0;try{for(var i,f=r[Symbol.iterator]();!(n=(i=f.next()).done)&&(t.push(i.value),!e||t.length!==e);n=!0);}catch(r){o=!0,u=r}finally{try{n||null==f.return||f.return()}finally{if(o)throw u}}return t}(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}r.exports=function(r){for(var e=t(r[0].split(" ").map(function(r){return Number(r)}),3),n=e[0],o=e[1],u=e[2],i=[],f=0;f<n;f++){var l=Number(r[f+1]);i.push(l)}i.sort(function(r,e){return r-e});for(var a=1,c=o-1,p=i[0],s=1;s<n;s++)i[s]<=p+u&&c>0?c-=1:(a+=1,c=o-1,p=i[s]);console.log(a)}},function(r,e){r.exports=require("fs")}]);

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

#define ll long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 100005
ll dp[101][mxn];
ll w[101],a[101];
int n;
ll W;

ll solve(int id,ll profit){
if(profit==0)return 0;
if(id==n+1||profit<0)return 1e15;
ll &ans=dp[id][profit];
if(ans!=-1)return ans;
ans=min(solve(id+1,profit),w[id]+solve(id+1,profit-a[id]));
return ans;
}


int main(){
sp;
cin>>n>>W;
for(int i=1; i<=n; ++i)cin>>w[i]>>a[i];
memset(dp,-1,sizeof dp);
ll ans=0;
for(int i=1; i<=100000; ++i){
    ll temp=solve(1,i);
    if(temp<=W)ans=i;
}
cout<<ans;
return 0;}


Measured memory_bytes: 79232
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N;
  cin >> N;
  vector<int> a(N + 1);
  for (int i = 0; i < N; i++) {
    cin >> a[i + 1];
  }
  vector<int> ans(N + 1);
  for (int i = N; i >= 1; i--) {
    if (i * 2 > N) {
      ans[i] = a[i];
      continue;
    }
    int tmp = 0;
    for (int j = 2; i * j <= N; j++) {
      tmp += ans[i * j];
    }
    tmp %= 2;
    ans[i] = tmp ^ a[i];
  }
  debug(ans);
  cout << accumulate(ans.begin(), ans.end(), 0) << endl;
  for (int i = 1; i <= N; i++) {
    if (ans[i] == 1) {
      cout << i << ' ';
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 4840
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
char in[6];
int main(){
	scanf("%s",in);
	int ret=700;
	for(int i=0;i<3;i++)if(in[i]=='o')ret+=100;
		printf("%d\n",ret);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

struct Dice{
	int me[6];
	Dice(int a[6]){
		for (int i = 0; i < 6; i++){
			me[i] = a[i];
		}
	}
};

int a[6], q, yoko[6][4] = { { 1, 2, 4, 3 }, { 5, 2, 0, 3 }, { 1, 5, 4, 0 },
{ 1, 0, 4, 5 }, { 0, 2, 5, 3 }, { 4, 2, 1, 3 } };
string s;

int main(){
	REP(i, 6)cin >> a[i];
	Dice d(a);
	cin >> q;
	REP(k, q){
		int t, f;
		cin >> t >> f;
		REP(i, 6){
			if (d.me[i] == t){
				REP(j, 4){
					if (d.me[yoko[i][j]] == f){
						cout << d.me[yoko[i][(j + 1) % 4]] << endl;
					}
				}
			}
		}
	}
}

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

int main() {
  string S,T;
  cin >> S>>T;
  int N=S.size();
  int C=0;
  for(int i=0;i<N;i++){
    if(S[i]!=T[i]){
      C+=1;
    }
  }
  cout<<C<<endl;
}

Measured memory_bytes: 3892
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    vector<int> v;
    char s[20];
    cin>>s;
    for(int i = 0; s[i]; i++){
        if(s[i] == '0') v.push_back(0);
        else if(s[i] == '1') v.push_back(1);
        else if(!v.empty()) v.erase(v.end() - 1);
    }

    for(int i = 0; i < v.size(); i++){
        cout<<v[i];
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N 100005
// #define MAX 200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"
const int inf = (int)1e18 + 10;
vec v;
signed main(){
 int n , k , one = 0  ,zero = 0 , ans = 0 , sum = 0;
  string s;
  cin >> n >> k;
  cin >> s;
  if(s[0] == '0')
    v.pb(0);

  for(int i = 0 ; i < n ; i++){
    if(s[i] == '0' && one  == 0)
      zero++;
    else if(s[i] == '0' && one )
      v.pb(one) ,one = 0 , zero = 1;
    else if(s[i] == '1' && zero == 0)
      one++;
    else if(s[i] == '1' && zero > 0)
      v.pb(zero) , zero = 0 , one = 1;
  }
  if(one > 0)
    v.pb(one);
  else
    v.pb(zero);



  int box = 2*k + 1;
  int sz = 0;
  for(int i = 0 ; i < v.size() ; i++){
           if(sz < box){
            sum += v[i];
            ans = max(ans , sum);
            sz++;
           }
            
           else {
              i++;
               ans = max(ans , v[i] + v[i-1] + sum - v[i - sz ] - v[i - sz - 1]);
               sum += v[i] + v[i-1];
               sum -= (v[i-sz] + v[i-sz - 1]);
           }
  }

  cout << ans << endl;
}	





Measured memory_bytes: 1528
#include <stdio.h>

int n,A[2500000];

void maHe(int);

int main(){
  int i,a;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }

  a=n/2;
  for(i=a;i>0;i--){
    maHe(i);
  }
  for(i=1;i<=n;i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
    
}

void maHe(int i){
  int l,r,la,tp;

  l=2*i;
  r=2*i+1;

  if(l<=n && A[l]>A[i])la=l;
  else la =i;
  if(r<=n && A[r]>A[la])la=r;
  if(la!=i){
    tp=A[i];
    A[i]=A[la];
    A[la]=tp;
    maHe(la);
  }
}



Measured memory_bytes: 3724
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
#include<cassert>
using namespace std;
#define N 3
#define N2 9

struct Puzzle{
  int f[N2];
  int space;
  string path;

  bool operator < ( const Puzzle &p ) const{
    for ( int i = 0; i < N2; i++ ){
      if ( f[i] == p.f[i] ) continue;
      return f[i] > p.f[i];
    }
    return false;
  }
};

static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char dir[4] = {'u', 'l', 'd', 'r'};

bool isTarget(Puzzle p){
  for ( int i = 0; i < N2; i++ )
    if ( p.f[i] != (i + 1) ) return false;
  return true;
}

string bfs(Puzzle s){
  queue<Puzzle> Q;
  map<Puzzle, bool> V;
  Puzzle u, v;
  s.path = "";
  Q.push(s);
  V[s] = true;
  
  while( !Q.empty() ){
    u = Q.front(); Q.pop();
    if ( isTarget(u) ) return u.path;
    int sx = u.space/N;
    int sy = u.space%N;
    for ( int r = 0; r < 4; r++ ){
      int tx = sx + dx[r];
      int ty = sy + dy[r];
      if ( tx < 0 || ty < 0 || tx >= N || ty >= N ) continue;
      v = u;
      swap(v.f[u.space], v.f[tx*N+ty]);
      v.space = tx*N+ty;
      if ( !V[v] ){
        V[v] = true;
        v.path += dir[r];
        Q.push(v);
      }
    }
  }
  assert(false);
  return "unsolvable";
}

int main(){
  Puzzle in;
  
  for ( int i = 0; i < N2; i++ ){
    cin >> in.f[i];
    if ( in.f[i] == 0 ) {
      in.f[i] = N2; 
      in.space = i;
    }
  }
  string ans = bfs(in);
  cout << ans.size() << endl;

  return 0;
}


Measured memory_bytes: 30608
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

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

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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int r, D, x; cin >> r >> D >> x;
  rep(i, 10) {
    x = r * x - D;
    cout << x << endl;
  }
}


Measured memory_bytes: 256
## coding: UTF-8
s = input().split()
t = [int(p) for p in s]
#print(t)
N = t[0]
A = t[1]
B = t[2]

def some(k): # 各位の桁の和を算出する
    if(k < 10): # 1の位しかない
        return int(k)
    elif(10 <= k < 100): # 1の位と10の位
        one = k % 10 # 1の位
        ten = (k - one) / 10 # 10の位
        return int(one + ten)
    elif(100 <= k < 1000): # 1の位と10の位と100の位
        one = k % 10 # 1の位
        ten = (k - one) % 100 / 10 # 10の位
        hundred = (k - ten * 10 - one) / 100 # 100の位
        return int(one + ten + hundred)
    elif(k == 10000):
        return 1
    else: # 1の位と10の位と100の位と1000の位
        one = k % 10 # 1の位
        ten = (k - one) % 100 / 10 # 10の位
        hundred = (k - ten * 10 - one) % 1000 / 100 # 100の位
        thousand = (k - hundred * 100 - ten * 10 - one) / 1000 # 1000の位
        return int(one + ten + hundred + thousand)

'''
print(some(92)) # 11
print(some(14)) # 5
print(some(8)) # 8
print(some(893)) # 20
print(some(110)) # 2
print(some(999)) # 27
print(some(1000)) # 1
print(some(1234)) # 10
print(some(2580)) # 15
print(some(9800)) # 17
'''
sum = 0
for i in range(1,N+1):
    if(A <= some(i) and some(i) <= B):
        sum += i

print(sum)

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

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

    map<int, int> m;

    for (int i = 2; i <= n; i++) {
        int x = i;
        int d = 2;
        while (x > 1) {
            if (x % d == 0) {
                m[d]++;
                x /= d;
            } else {
                d++;
            }
        }
    }

    long long c = 1;
    for (const auto a : m) {
        c = (c * (a.second + 1)) % 1000000007;
    }

    cout << c << endl; 
}

Measured memory_bytes: 256
n = int(input())
i = n
for i in range(1,n+1):
    if i % 3 == 0:
        print(' {}'.format(i),end = '')
    
    else:
        st = str(i)
        for j in range(len(st)):
            if(st[j] == '3'):
                print(' {}'.format(i),end = '')
                break
print()


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

int main(){
  string s,S;
  cin >>s;
  long long  i=0;
  long long  leng=s.size();
  S="";
  while(i<leng){
    if (s[i]=='A'){
      S+="A";
      i+=1;
    }
    else if (i+1<leng &&s[i]=='B'&&s[i+1]=='C'){
      S+="B";
      i+=2;
    }
    else{
      S+="C";
      i+=1;
    }
  }
  string T=S;
  reverse(T.begin(),T.end());
  //cout <<S<<endl;
  //cout <<T<<endl;
  vector<int> l(T.size(),0);
  long long  ans=0;
  for (int i=0;i<T.size()-1;i++){
    if (T[i]=='B'){
      l[i+1]=l[i]+1;
    }
    else if (T[i]=='A'){
      l[i+1]=l[i];
      ans+=l[i];
    }
  }
  if (T[T.size()-1]=='A') ans+=l[T.size()-1];
  cout <<ans<<endl;
}


Measured memory_bytes: 1800
#include<stdio.h>

int main()
{
    long long int N;
    int count = 0;
    fscanf(stdin, "%lld", &N);

    do {
        if( (N % 10) == 2) {
            count++;
        }
    } while( (N = N/10) != 0);

    fprintf(stdout, "%d\n", count);

    return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	//"reflect"

	//"reflect"

	//"reflect"

	//"reflect"
	"strconv"
)

// 呼び出し
func main() {
	// 共通
	sc := NewScanner()

	var a, b, c, d, e, N float64

	// *** NextInt
	N = sc.NextFloat()

	a = sc.NextFloat()
	b = sc.NextFloat()
	c = sc.NextFloat()
	d = sc.NextFloat()
	e = sc.NextFloat()

	min := min(a, b, c, d, e)
	num := math.Ceil(N / min)

	fmt.Println(int(num) + 4)
}

func min(args ...float64) float64 {
	min := args[0]
	for _, i := range args {
		if i < min {
			min = i
		}
	}

	return min
}

// ======================= 以下ライブラリ ========================

func till(i, m int) int {
	if i > m {
		return m
	}

	return i
}

func abs(i int) int {
	if i < 0 {
		return -i
	}
	return i
}

// *** int
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

// *** int64
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

// **** float
func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

// *** []int 一行読み取って
func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}

// *** string 一行読み読み取って
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}

// ====================以下共通部分==================================
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}

func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}

func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#b

N, *A = map(int, open(0).read().split())
M = (N+1)*N//2
S = sum(A)
if S%M!=0:
  print('NO')
  exit()
cnt = S//M
for i in range(N):
  df = A[(i+1)%N]-A[i]
  if (cnt-df)%N!=0 or cnt<df:
    print('NO')
    break
else:
  print('YES')

Measured memory_bytes: 14108
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>
#include <limits>

using vi = std::vector<int>;
using vvi = std::vector<vi>;

class BinomialFactory2
{
    vi stock2;

    int k2(int n)
    {
        int count = 0;
        while (n % 2 == 0)
        {
            n /= 2;
            count++;
        }
        return count;
    }

public:
    explicit BinomialFactory2(int N)
    {
        stock2.resize(N + 1);
        for (int i = 1; i <= N; i++)
        {
            stock2[i] = stock2[i - 1] + k2(i);
        }
    }

    int bi(int n, int r) const
    {
        if (r == 0 || r == n) return 0;

        return stock2[n] - stock2[n - r] - stock2[r];
    }
};

int calc_parity(const BinomialFactory2 &bifac,const vi& a, int N)
{
    int parity = 0;
    for (int i = 0; i < N; i++)
    {
        if (a[i] == 1 && bifac.bi(N - 1, i) == 0)
        {
            parity++;
        }
    }
    return parity % 2;
}

int f(vi& a, int N)
{
    BinomialFactory2 bifac(N);

    if (calc_parity(bifac, a, N) == 1)
    {
        return 1;
    }

    for (int i = 0; i < N; i++)
    {
        if (a[i] == 1)
        {
            return 0;
        }
        if (a[i] == 2)
        {
            a[i] = 1;
        }
    }

    if (calc_parity(bifac, a, N) == 1)
    {
        return 2;
    }
    else
    {
        return 0;
    }
}

int main()
{
	int N;
	std::cin >> N;
	vi a(N);
	for (int i = 0; i < N; i++)
	{
		char c;
		std::cin >> c;
		a[i] = c - '1';
	}

	std::cout << f(a, N);
}


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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);
#define int long long int
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(a) a.begin(), a.end()

const int N = 500009;
const int mod = 1000000007;

int n, k;
vector<int> A, F;

bool check(int x)
{
	int req = 0;
	for (int i = 0; i < n; i++)
	{
		int see = (A[i] * F[i]);
		if (see <= x)
			continue;
		int itne = (see - x + F[i] - 1) / F[i];
		req += itne;
		if (req > k)
			return 0;
	}
	return 1;
}

void pre()
{
}

int32_t main()
{
	IOS;
	pre();
	cin >> n >> k;
	A.resize(n);
	F.resize(n);
	for (int i = 0; i < n; i++)
		cin >> A[i];
	for (int i = 0; i < n; i++)
		cin >> F[i];
	sort(all(A));
	sort(all(F));
	reverse(all(F));
	int l = 0;
	int r = LLONG_MAX;
	while (l < r)
	{
		int mid = (l + r) / 2;
		if (check(mid))
		{
			r = mid;
		}
		else
		{
			l = mid + 1;
		}
	}
	cout << l << endl;
}

Measured memory_bytes: 3328
import itertools
import sys

N = int(input())
key = ["M", "A", "R", "C", "H"]
S = [x for x in [input() for i in range(N)] if x[0] in key]
march = {}
for x in S:
    march.setdefault(x[0], []).append(x)

if len(march) < 3:
    print(0)
    sys.exit()

sizes = [len(x) for x in march.values()]

print(sum([a*b*c for a, b, c in itertools.combinations(sizes, 3)]))


Measured memory_bytes: 11172
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

H, W = map(int, input().split())
H += 2
W += 2
B = [0] * H
block = 0
for i in range(H):
    if i == 0 or i == H - 1:
        B[i] = '#' * W
    else:
        B[i] = '#' + input() + '#'
        block += B[i].count("#") - 2

start = (1, 1)
goal = (H - 2, W - 2)

from collections import deque
def bfs(start, goal):
    dist = [[-1] * W for _ in range(H)]
    q = deque([])
    sy, sx = start
    dist[sy][sx] = 1
    q.append(start)

    ys = [0, 1, 0, -1]
    xs = [1, 0, -1, 0]

    while len(q) > 0:
        y, x = q.popleft()
        if (y, x) == goal:
            return dist[y][x]

        for dy, dx in zip(ys, xs):
            ny, nx = y + dy, x + dx
            if B[ny][nx] == '#':
                continue
            if dist[ny][nx] != -1:
                continue
            dist[ny][nx] = dist[y][x] + 1
            q.append((ny, nx))
    return -1

res = bfs(start, goal)
if res == -1:
    print(res)
else:
    print((H - 2) * (W - 2) - block - res)

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

bool cmp(pair<int, int> a,  pair<int, int> b) { return a.second < b.second; }

int main()
{
    int N, M;
    cin >> N >> M;

    vector<pair<int, int>> island(M);
    for (int i = 0; i < M; i++) {
        cin >> island[i].first >> island[i].second;
    }

    sort(island.begin(), island.end(), cmp);

    int t = 0, ans = 0;

    for (int i = 0; i < M; i++) {
        if (t <= island[i].first) {
            ans++;
            t = island[i].second;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define F 3
#define R 10

void print(int array[F][R]){
    for(int i = 0; i < F; i++){
        for(int j = 0; j < R; j++){
            cout << " " << array[i][j];
            /*
            if(j != 9){
                cout << " ";
            }
            */
        }
        cout << endl;
        
    }
       
}

int main() {
    int n;
    cin >> n;
    int first[F][R];
    int second[F][R];
    int third[F][R];
    int forth[F][R];
    for(int i = 0; i < F; i++){
        for(int j = 0; j < R; j++){
            first[i][j] = 0;
            second[i][j] = 0;
            third[i][j] = 0;
            forth[i][j] = 0;
        }
    }

    for(int i = 0; i < n; i++){
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        f--; r--;
        if(b == 1){
            first[f][r] += v;
        }
        else if(b == 2){
            second[f][r] += v;
        }
        else if(b == 3){
            third[f][r] += v;
        }
        else if(b == 4){
            forth[f][r] += v;
        }
    }

    for(int i = 0; i < 4; i++){
        if(i == 0){
            print(first);
        }
        else if(i == 1){
            print(second);
        }
        else if(i == 2){
            print(third);
        }
        else {
            print(forth);
        }
        if(i != 3) cout << "####################" << endl;
    }
    return 0;
}


Measured memory_bytes: 3124
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int B=20001,N=2e5+500;
int a[N],b[N],n,p[N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)a[i]=a[i-1]+B;
    for(int i=1;i<=n;i++)b[i]=a[n+1-i];
    for(int i=1;i<=n;i++)scanf("%d",p+i);
    for(int i=2;i<=n;i++)
    {
        int t=a[p[i]]+b[p[i]]-a[p[i-1]]-b[p[i-1]];
        if(t<=0)a[p[i]]+=-t+1;
    }
    for(int i=1;i<=n;i++)printf("%d ",a[i]);puts("");
    for(int i=1;i<=n;i++)printf("%d ",b[i]);puts("");
}

Measured memory_bytes: 4056
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

n,a,b,c = lr()
l = [ir() for i in range(n)]
l.sort(reverse=True)

def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b)

ans = inf

for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            now = [l[i],l[j],l[k]]
            ret = [0 for w in range(5-(n-3))]
            pre = 0
            for g in range(n):
                if g!=i and g!=j and g!=k:
                    ret.append(l[g])
            for h in range(4**(n-3)):
                now = [l[i], l[j], l[k]]
                pre = 0
                judge = base10to(h, 4)
                tmp = ''
                for w in range(5-len(judge)):
                    tmp = ''.join([tmp,'0'])
                judge = ''.join([tmp,judge])

                for p,t in enumerate(judge):
                    if t == '1':
                        now[0]+=ret[p]
                        pre+=10
                    elif t == '2':
                        now[1]+=ret[p]
                        pre+=10
                    elif t == '3':
                        now[2]+=ret[p]
                        pre+=10
                now.sort(reverse=True)
                ans = min(ans,pre+abs(a-now[0])+abs(b-now[1])+abs(c-now[2]))
print(ans)

Measured memory_bytes: 89908
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
using namespace std;

int dp[100005][4];
vector <vector <int > > v;
int n;

int solve(int days,int prev){
    if(days > n) return 0;
    if(dp[days][prev] != -1) return dp[days][prev];
    int ans = INT_MIN;
    for(int i=1 ; i<=3  ; i++){
        if(i == prev) continue;
        ans = max(ans, solve(days+1,i) + v[days][i]);
    }
    return dp[days][prev] = ans;
}

int32_t main()
{
    memset(dp,-1,sizeof dp);
    cin>>n;
    v.resize(n+1);
    for(int i=1 ; i<=n ; i++){
        v[i].resize(4);
        for(int j=1 ; j<=3 ; j++) cin>>v[i][j];
    }
    cout<<solve(1,0);

    return 0;
}


Measured memory_bytes: 16640
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> dp(n+1);
  dp[0] = 1; dp[1] = 1;
  rep(i, n-1){
    dp[i+2] = dp[i] + dp[i+1];
  }
  cout << dp[n] << endl;
  
  return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
long long int V[200010];
long long int C[200010];




int main(void){
    // Your code here!
    long long int N,H,W,A,B,C,i,j,k,ans,count,cost,tmp;
    
    
    string T;
    bool flag;
    count=0;
    ans=0;
    flag=false;
    cin >>A>>B>>C;
    cin>>N;
    while (A>=B){
        B*=2;
        ans+=1;
    }
    
    while (B>=C){
        C*=2;
        ans+=1;
    }
 
      //cout<< ans <<endl;
        
    if (ans<=N){
        cout<< "Yes" <<endl;
    }
    else{
        cout<< "No" <<endl;
    
    }
    
    
    

    return 0;
    
}



Measured memory_bytes: 3624
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;
const ld pi=acos(-1.0);

ld solve(int N, int M, vector<ld>ps) {
	vector<vector<vector<ld>>>dp(N+1,vector<vector<ld>>(M+1,vector<ld>(N,-1e8)));
	dp[1][1][0]=0;
	for (int now = 1; now < N; ++now) {
		for (int used_cnt = 0; used_cnt <= M; ++used_cnt) {
			for (int pre_use_id = 0; pre_use_id < now; ++pre_use_id) {
				dp[now+1][used_cnt][pre_use_id]=max(dp[now+1][used_cnt][pre_use_id],
					dp[now][used_cnt][pre_use_id]);

				if (used_cnt != M) {

					ld plus = 0.5*(sin(2 * pi*(ps[now] - ps[pre_use_id])));
					dp[now + 1][used_cnt + 1][now] = max(
						dp[now + 1][used_cnt + 1][now],
						dp[now][used_cnt][pre_use_id] + plus);
				}
			}
		}
	}
	ld ans=0;
	for (int pre_use_id = 0; pre_use_id < N; ++pre_use_id) {

		ld plus = 0.5*(sin(2 * pi*(ps[0] - ps[pre_use_id])));
		ans=max(ans,dp[N][M][pre_use_id]+plus);
	}
	return ans;
}

int main() {
	while (true) {
		int N, M; cin >> N >> M;
		if(!N)break;
		vector<ld>ps;
		for (int i = 0; i < N; ++i) {
			ld theta; cin >> theta;
			ps.push_back(theta);
		}

		ld ans = 0;
		for (int i = 0; i < N; ++i) {
			rotate(ps.begin(), ps.begin() + 1, ps.end());
			ans = max(ans, solve(N, M, ps));
		}
		cout<<setprecision(6)<<fixed<<ans<<endl;
	}
	

	return 0;
}


Measured memory_bytes: 3768
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            String card = sc.next(); //最初のカードの並び
            if (card.equals("-")) break;
            int s = sc.nextInt(); //シャッフル回数
            int n = 0;//下から何枚目
            for (int i=0; i<s; i++) {
                n += sc.nextInt();
            }
            for (int i=0; i<card.length(); i++) {
                System.out.print(card.charAt((n+i)%card.length()));
            }
            System.out.println("");
        }
    }
}



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

using namespace std;

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

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

int main() {
	int n;
	int a[110];
	while(n=in()){
		int i;
		for(i=0;i<n;i++){
			a[i]=in();
		}
		int j;
		int res=0;
		for(i=0;i<n;i++){
			for(j=i+1;j<n;j++){
				if(a[i]>a[j])res++;
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
# ABC145C - Average Length
from itertools import permutations


def calc(seq: "Array[int]") -> float:
    ret = 0
    for i, j in zip(seq, seq[1:]):
        xi, yi = XY[i]
        xj, yj = XY[j]
        ret += ((xi - xj) ** 2 + (yi - yj) ** 2) ** 0.5
    return ret


def fact(x: int) -> int:
    ret = 1
    for i in range(1, x + 1):
        ret *= i
    return ret


def main():
    global XY
    N, *XY = map(int, open(0).read().split())
    XY = list(zip(*[iter(XY)] * 2))
    ans = sum(calc(perm) for perm in permutations(range(N), N)) / fact(N)
    print(ans)


if __name__ == "__main__":
    main()

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

int main() {
  int N, M;
  cin >> N >> M;

  int a[M], b[M];
  for (int i = 0; i < M; i++) cin >> a[i] >> b[i];

  int road_num[N];
  for (int i = 0; i < N; i++) road_num[i] = 0;

  for (int i = 0; i < M; i++) {
    road_num[a[i] - 1]++;
    road_num[b[i] - 1]++;
  }

  for (int i = 0; i < N; i++) cout << road_num[i] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (int i=0; i<n; i++){
    cin >> a[i];
  }
  ll x = 0;
  rep(i, n) {
    x ^= a[i];
  }
  rep(i, n) {
    a[i] ^= x;
  }
  rep(i, n) {
    if (i>0) cout << " ";
    cout << a[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 4820
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 1000000000
#define MOD 1000000007
#define ll long long int
using namespace std;


int main(){
 string s; cin>>s;
 string test="";
 for(int i=0;i<=s.size()+10;i++){
   if(i % 2 == 0) test += '0';
   else test += '1';
 }

 int ans1=0;
 int ans2=0;

 for(int i=0;i<s.size();i++){
   if(s[i] != test[i]) ans1++;
   else ans2++;
 }
cout<<min(ans1,ans2)<<endl;


  return 0;
}

Measured memory_bytes: 640
while str = STDIN.gets
  n = str.split(" ")
  a = n[0].to_i
  b = n[1].to_i
  c = n[2].to_i

  if a > b
     n = b
     b = a
     a = n
  end

  if b > c
       n = b
       b = c
       c = n
  end

   if a > c
      n = a
      a = c
      c = n
   end

  if a > b
     n = b
     b = a
     a = n
  end

  puts "#{a} #{b} #{c}"

end


Measured memory_bytes: 6868
#include <iostream>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <tuple>
using namespace std;
long long N, K, a[100009], b[100009];
int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++)cin >> a[i] >> b[i];
	long long L = 0, R = (1LL << 61), M, maxv = (1LL << 61);
	for (int i = 0; i < 100; i++) {
		long long sum = 0; M = (L + R) / 2;
		for (int j = 0; j < N; j++) {
			sum += max(0LL, (M - a[j]) / b[j] + 1LL);
			if (sum >= (1LL << 61))break;
		}
		if (sum >= K) { maxv = min(maxv, M); R = M; }
		else { L = M; }
	}
	cout << maxv << endl;
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        int res = 0;
        var a = Reader.NextLong;
        var b = Reader.NextLong;
        var c = Reader.NextLong;
        if ((a & 1) + (b & 1) + (c & 1) == 0 && a == b && b == c)
        {
            Console.WriteLine(-1);
            return;
        }
        while ((a & 1) + (b & 1) + (c & 1) == 0)
        {
            var newa = (b >> 1) + (c >> 1);
            var newb = (a >> 1) + (c >> 1);
            var newc = (a >> 1) + (b >> 1);
            a = newa;
            b = newb;
            c = newc;
            res++;
        }
        Console.WriteLine(res);
    }
}


static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = 0;
    static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; } }


    public static long NextLong
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            long res = 0; while (Buffer[ptr] < 48) Move();
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res;
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = (int)1e6 + 34;

int a[N];
void solve() {
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
    }
    printf("%d\n", (n - 1 + k - 2) / (k - 1));
}

int main() {
#ifdef SERT
    freopen("a.in", "r", stdin);
    solve();
    solve();
#endif
    solve();
    return 0;
}

Measured memory_bytes: 640
import static java.lang.System.*;
import java.util.*;

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

        int n = sc.nextInt();
		int k = sc.nextInt();
		char[] s = sc.next().toCharArray();
		
		ArrayList<Integer> list = new ArrayList<Integer>();
		
		char prev = '1';
		list.add(0);
		for(int i=0; i<n; i++) {
			if(s[i] == prev) {
				list.set(list.size()-1, list.get(list.size()-1)+1);
			}
			else {
				prev = s[i];
				list.add(1);
			}
		}
		for(int i=0; i<k*2; i++) list.add(0);		
			
		int ans = 0;
		int sum = 0;
		for(int i=0; i<k*2; i++) 
			sum += list.get(i);
		
		for(int i=k*2; i<list.size(); i++) {
			sum += list.get(i);			
			if(i%2==0) ans = Math.max(ans, sum);
			sum -= list.get(i-k*2);		
		}
		
        out.println(ans);
    }
}

Measured memory_bytes: 29064
o = input()
for _ in range(int(input())):
    s = input().split()
    a, b = map(int, s[1:3]); b+=1
    if s[0][2]=='i': print(o[a:b])
    elif s[0][2]=='p': o=o[:a]+s[3]+o[b:]
    else: o=o[:a]+o[a:b][::-1]+o[b:]


Measured memory_bytes: 5612
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

int n, k;
int W[100000];

long long check(long long P) {

	long long count = 0;
	for (long long i = 0; i < k; i++)	{
		long long sum = 0;
		while (true) {
			sum += W[count];
			if (sum <= P) {
				count++;
				if (count == n) 
					return count;
			}
			else break;
		}
	}
	return count;
}

long long solve() {

	long long left = 0;
	long long right = 100000 * 10000;
	long long mid;
	while (left < right) {
		mid = (left + right) / 2;
		int res = check(mid);
		if (res >= n) {
			right = mid;
		}
		else {
			left = mid + 1;
		}
	}
	return right;
}

int main() {
	
	cin >> n >> k;
	for (int i = 0; i < n; i++)	{
		scanf("%d", &W[i]);
	}

	cout << solve() << endl;


	return 0;
}



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

using namespace std;

int alphabet[26];


const long long  MOD = 1e9 + 7;

int main(){
 int  N; cin >> N; string S; cin >> S;
 for(int i = 0; i < 26; i++){ alphabet[i] = 0;}
  
  for(int i = 0; i < N; i++){
    char c = S[i]; alphabet[c - 'a']++;} long long ans = 1;
  
  for(int i = 0; i < 26; i++){  ans *= (alphabet[i] + 1); ans %= MOD;}
  
  cout << ans - 1 << endl; return 0;}

Measured memory_bytes: 512
import Control.Monad
import Data.List

main = do
  [n, m] <- map read.words <$> getLine :: IO [Int]
  abl <- sortBy (\[a1, _] [a2, _] -> compare a1 a2) <$> (replicateM n $ map read.words <$> getLine :: IO [[Int]])
  print $ f abl m

f :: [[Int]] -> Int -> Int
f ([a, b]:abl) m
  | m == 0 = 0
  | b >= m = (*) m a
  | otherwise = (b * a) + (f abl (m - b))

Measured memory_bytes: 137596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define srep(i,j,n) for (int i = j; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi; 
const ll inf = 1001001001;
ll dp[100001][3];
int main(){
    int n;
    cin >> n;
    vi hap[3];
    rep(i,3) hap[i].resize(n); 
    
    rep(i,n){
        rep(k,3) cin >> hap[k][i];
    }
    rep(i,n) rep(j,3) dp[j][i] = 0; 

    rep(i,n){
        rep(j,3) {
            rep(k,3){
                if(j==k) continue;
                dp[i+1][j] = max(dp[i+1][j],dp[i][k]+hap[j][i]);

            }
        }
    }
    // rep(i,n){
    //     rep(k,3) {
    //         if(dp[i+1] < dp[i]+hap[k][i] && flag[i] != k){
    //             dp[i+1] = dp[i]+hap[k][i];
    //             flag[i+1] = k;
    //         }
    //     }
    // }
    ll ans = 0;
    rep(j,3) ans = max(ans,dp[n][j]);
    cout<<ans<<endl;
}

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

int solve(int W, int H) {
    vector<vector<char>> field(H + 2, vector<char>(W + 2, '#'));
    vector<vector<int>> cnt(H + 2, vector<int>(W + 2, 0));
    pair<int, int> p;
    queue<pair<int, int>> Q;

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> field[i][j];
            if (field[i][j] == '@') {
                Q.push(make_pair(i, j));
                cnt[i][j] = 1;
            }
        }
    }

    int dx[] = {1, -1, 0, 0};
    int dy[] = {0, 0, 1, -1};
    while (!Q.empty()) {
        p = Q.front();
        Q.pop();
        for (int i = 0; i < 4; i++) {
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if (field[ny][nx] == '#') continue;
            if (cnt[ny][nx] == 1) continue;
            Q.push(make_pair(ny, nx));
            cnt[ny][nx] = 1;
        }
    }
    int ret = 0;
    for (int i = 0; i < cnt.size(); i++) {
        for (int j = 0; j < cnt[i].size(); j++) {
            if (cnt[i][j] == 1) ret++;
        }
    }

    return ret;
}

int main() {
    int W, H;
    vector<int> ans;
    while (1) {
        cin >> W >> H;
        if (!W && !H) break;
        ans.push_back(solve(W, H));
    }

    for (int r : ans) cout << r << endl;
}


Measured memory_bytes: 3064
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    N,M = map(int, input().split())
    a = N*(N-1)//2
    b = M*(M-1)//2
    print(a+b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {

	var n, k int
	fmt.Scan(&n, &k)

	pList := make([]int, n)

	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		pList[i] = nextInt()
	}

	sort.SliceStable(pList, func(i, j int) bool { return pList[i] < pList[j] })

	sum := 0
	for _, x := range pList[:k] {
		sum += x
	}

	fmt.Println(sum)
}


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

ll N, A, B;

int main() {
    cin >> N >> A >> B;
  
    if (A > B) cout << 0 << endl;
    else if (N == 1 && A != B) cout << 0 << endl;
    else cout << (N-2)*(B-A)+1 << endl;
 
    return 0;
}


Measured memory_bytes: 256
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
'''
N = ii()
A = li()
right = 0
flag = [0]*(10**5+1)
ans = 0

for left in range(N):
    #flag[A[left]] = 1
    while right < N and flag[A[right]]!=1:
        flag[A[right]] = 1
        right += 1
    #print(left, right)
    ans = max(ans, right-left)
    if left == right:
        right += 1
    else:
        flag[A[left]] = 0

print(ans)
'''

from collections import deque

H, W = mi()
S = [input() for i in range(H)]

d = deque()
dx = [1, 0, -1, 0]
dy = [0, -1, 0, 1]
ans = 0
flag = dp2(0, W, H)

for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            flag = dp2(0, W, H)
            d.append([i, j, 0])
            flag[i][j] = 1
            while d!=deque():
                a = d.popleft()
                for k in range(4):
                    x, y = a[0]+dy[k], a[1]+dx[k]
                    if 0 <= x < H and 0 <= y < W:
                        if S[x][y] == '.' and flag[x][y] != 1:
                            d.append([x, y, a[2]+1])
                            flag[x][y] = 1
                            ans = max(ans, a[2]+1)

print(ans)

Measured memory_bytes: 3316
//... ...
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
const int M = 1e5 + 7;
int a[M];

int main() {
	int n;
	cin >> n;
	for(int i = 1 ; i <= n ; i++) cin >> a[i];
	int l = a[1] , r = a[1];
	for(int i = 2 ; i <= n ; i++) {
		l = min(a[i] , l);
		r = max(a[i] , r);
	}
	if(r - l > 1) cout << "No" << endl;
	else {
		if(l == r) {
			int gg = n - l;
			if(gg == 1) cout << "Yes" << endl;
			else {
				if(n == 1 || gg >= l) cout << "Yes" << endl;
				else cout << "No" << endl;
			}
		} else {
			int cnt1 = 0 , cnt2 = 0;
			for(int i = 1 ; i <= n ; i++) {
				if(a[i] == l) cnt1++;
				if(a[i] == r) cnt2++;
			}
			if(cnt1 >= r) cout << "No" << endl;
			else {
				int gg = n - r;
				if(gg >= r - cnt1) cout << "Yes" << endl;
				else cout << "No" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))
cnt4=0
cnt2=0
cnt1=0
for i in a:
    if i%4==0:
        cnt4+=1
    elif i%2==0:
        cnt2+=1
    else:
        cnt1+=1
if cnt2==0 and cnt4+1>=cnt1:
    print("Yes")
elif cnt4>=cnt1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 15020