akhauriyash/Code-Regression huggingface dataset:
def sumitrust2019_d_01():
    n = int(input())
    s = input()
    ans = 0

    for i in range(1000):
        # 確認するpinの数字の組み合わせと桁の初期化
        # pin = list(str(i).zfill(3))
        pin = f'{i:0>3}'

        # list+indexで書こうと思ったけど、そもそも文字列でやっているのでfindで探しちゃう
        p1 = s.find(pin[0])

        if p1 != -1:
            p2 = s.find(pin[1], p1 + 1)
            if p2 != -1:
                p3 = s.find(pin[2], p2 + 1)
                if p3 != -1:
                    ans += 1

    print(ans)

if __name__ == '__main__':
    sumitrust2019_d_01()

Measured memory_bytes: 9224
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(i,j,k) for(int i=j;i<=k;i++) 
#define dec(i,j,k) for(int i=j;i>=k;i--)
const int mod = 1e9+7;
const int N = 2e5+1;
using namespace std;
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << " ";
	err(++it, args...);
}

typedef long long ll;
vector<pair<int,int>> v;
ll n,k,x,y;
ll ans;
ll arr[N];
ll binpow(ll  a , ll n)
{
	ll res = 1;
	while(n)
	{
		if(n&1)
			res=res*a%mod;
		a=a*a%mod;
		n/=2;
	}
	return res;
}
void solve()
{  cin>>n;
   vector<ll> dp(n+1);
   dp[0]=1;
   for(int i=1;i<=n;i++)
   { ll sum = 0;
	   for(int j=3;j<=i;j++)
	   {
		   if(i-j>=0)
			   sum=(sum+dp[i-j])%mod;
	   }		   
	   dp[i]=sum%mod;
   }
   cout<<dp[n];
   //cerr<<"\n";
}
int main()
{ 
//#ifndef ONLINE_JUDGE
 // freopen("fi.txt","r",stdin);
 // freopen("fo.txt","w",stdout); 
 // freopen("err.txt","w",stderr);
//#endif
  int t;
  t=1;
  //cin>>t;
  while(t--)
  {
	  solve();
  }
  return 0;
}

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

using ll = long long;

#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, std::vector<ll> A) {
  vector<ll> l(N + 1, -1);

  rep(i, N) {
    auto it = lower_bound(l.rbegin(), l.rend(), A.at(i));
    l.at(l.rend() - it) = A.at(i);
  }

  int ans = 0;
  rep(i, N) {
    if (l.at(i) == -1) break;
    ans++;
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  std::vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


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

int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    int S_size = (int)S.size();

    int ans = 0;
    rep(i,S_size-1){
        string S1 = S.substr(0, i+1);
        string S2 = S.substr(i+1, S_size-i-1);
        int val = 0;

        set<char> set1(S1.begin(), S1.end());
        set<char> set2(S2.begin(), S2.end());
        for(char c: set1){
            for(char c2: set2){
                if(c == c2){
                    val += 1;
                }
            }
        }
        if( val > ans )ans=val;
        
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
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; }
int Inf = (1<<30);
ll inf = (1LL<<60);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() { // reverseは結構時間がかかる
	int n;
	cin >> n;
	int i;
	queue<int> k;
	stack<int> g;
	stack<int> K;
	queue<int> G;
	if (n % 2 == 0) {
		for (i = 1; i <= n; i++) {
			int a;
			cin >> a;
			if (i % 2 != 0) k.push(a);
			else g.push(a);
		}
	}
	else {
		for (i = 1; i <= n; i++) {
			int a;
			cin >> a;
			if (i % 2 != 0) K.push(a);
			else G.push(a);
		}
	}
	if (n % 2 == 0) {
		while (!g.empty()) {
			cout << g.top() << " ";
			g.pop();
		}
		while (!k.empty()) {
			cout << k.front() << " ";
			k.pop();
		}
	}
	else {
		while (!K.empty()) {
			cout << K.top() << " ";
			K.pop();
		}
		while (!G.empty()) {
			cout << G.front() << " ";
			G.pop();
		}
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

char c[26];

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
long long arr[1000007];
long long cs[1000007];
long long ps[1000007];

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

    long long cnt=0;

    for(int i=1; i<=n; i++)
    {
        cnt+=n/i;


    }

    cout<<cnt<<endl;
    return 0;

}
















Measured memory_bytes: 3588
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val x = sc.nextInt()
    println(problem149c(x))
}

fun problem149c(x: Int): Int {
    /**
     * 素数判定
     */
    fun isPrime(num: Int): Boolean {
        if (num < 2) return false
        if (num == 2) return true
        if (num % 2 == 0) return false

        val sqrtNum = Math.sqrt(num.toDouble()).toInt()
        for (i in 3..sqrtNum step 2) {
            if (num % i == 0) return false
        }
        return true
    }
    var x = x
    while (true) {
        if (isPrime(x)) return x
        x++
    }
}

Measured memory_bytes: 31264
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{

	int A1, A2, A3;
	cin >> A1 >> A2 >> A3;

	int total = A1 + A2 + A3;

	if (total >= 22) {
		cout << "bust" << endl;
	}
	else {
		cout << "win" << endl;
	}
	
	

	
}


Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;

int main()
{
    const int price = 800;
    const int get = 200;
    const int times = 15;

    int N;
    if (scanf("%d", &N) < 1) return 0;

    printf("%d\n", price * N - (N / times) * get);
    return 0;
}


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

using namespace std;

int main()
{
    string s;
    int len;
    cin >> s;
    for (int i = 0, len = s.length(); i < len; ++i)
    {
        if(!(i & 1)) cout << s[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 512
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>

// type alias
using lint = long long;
using ldouble = long double;
template <class T>
using greater_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T>>;


/* ----- class ----- */

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Edges = std::vector<Edge<Cost>>;

template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;


/* ----- debug ----- */

#if __has_include("../setting/source/debug.hpp")
#include "../setting/source/debug.hpp"
#endif


/* ----- short functions ----- */

template <class T>
inline T sq(T a) { return a * a; }

template <class T>
inline T iceil(T n, T d) { return (n + d - 1) / d; }

template <class T>
T gcd(T a, T b) {
    while (b > 0) {
        a %= b;
        std::swap(a, b);
    }
    return a;
}

template <class T, class U>
T ipow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= b;
        n >>= 1;
        b *= b;
    }
    return ret;
}

// 0-indexed
template <class T, class U>
inline T kthbit(T a, U k) { return (a >> k) & 1; }

template <class T, class U>
inline T mask(T a, U k) { return a & ((1 << k) - 1); }

template <class T>
std::map<T, int> compress(std::vector<T>& v) {
    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());

    std::map<T, int> rev;
    for (int i = 0; i < v.size(); ++i) rev[v[i]] = i;
    return rev;
}

template <class T>
T Vec(T v) { return v; }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return std::vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}


/* ----- constants ----- */

// const int INF = std::numeric_limits<int>::max() / 3;
// const lint INF = std::numeric_limits<lint>::max() / 3;
// const ldouble PI = acos(-1);
// const ldouble EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));


using namespace std;

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

    int sum = 0, del = L;
    for (int i = 0; i < N; ++i) {
        int a = L + i;
        sum += a;
        if (abs(a) < abs(del)) del = a;
    }

    cout << sum - del << endl;
    return 0;
}


Measured memory_bytes: 256
// http://yumai6.hatenablog.com/entry/2015/12/21/222930

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

//---------------------------------------------------------------
//---------------------------------------------------------------

string S;

signed main(){
	cin >> S;
	
	int wk;
	int diff = 753;
	REP(i, S.size()) {
		REP(j, 3) {
			wk = abs(atoi(S.substr(i, j+1).c_str()) - 753);
			if(diff > wk)
				diff = wk;
		}
	}
	cout << diff << endl;

	return 0;
}


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

using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
vector<vector<int> > graph;
bool used[N];
int color[N];

bool dfs(int v, int c) {
    bool res = true;
    if (used[v]) {
        return color[v] == c;
    }
    used[v] = true;
    color[v] = c;
    for (int u : graph[v]) {
        if (!dfs(u, 1 - c))
            res = false;
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    ll n, m;
    cin >> n >> m;
    graph.resize(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    ll g1 = 0;
    ll g2 = 0;
    ll g3 = 0;
    for (int i = 0; i < n; i++) {
        if (used[i])
            continue;
        if (graph[i].size() == 0) {
            g1++;
        } else if (dfs(i, 0)) {
            g2++;
        } else {
            g3++;
        }
    }
    ll ans = 2 * g1 * n - g1 * g1;
    ans += 2 * g2 * g2 + g3 * g3 + 2 * g2 * g3;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 10112
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <string.h>
#include <math.h>
typedef long long ll;
#define INF			100000
#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REP(i,x,y)	for (int (i)=(x);(i)<(y);(i)++)
#define REP_(i,x,y)	for ((i)=(x);(i)<(y);(i)++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef pair<int, int> Point;
typedef vector<vector<Point>> Graph;

int A,B,K;
string s;

int main() {
	
 	cin >> s;

	if (
		(s[0]=='a' || s[1]=='a' || s[2]=='a') 
	&&	(s[0]=='b' || s[1]=='b' || s[2]=='b') 
	&&	(s[0]=='c' || s[1]=='c' || s[2]=='c') 
	)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

template<class T>
inline bool chmax(T &a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
};

template<class T>
inline bool chmin(T &a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
};

void print() {
  cout << endl;
}

template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}

template <class T>
void print(vector<T> &vec, ll k){
   ll n = vec.size();
   k = min(k, n);
   rep(i, 0, k-1) cout << vec[i] << " ";
   cout << vec[k-1] << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
    print(vec);
  }
}

template<class T, class U>
void print(pair<T,U> &p){
  cout << p.first << " " << p.second << "\n";
}

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

  int K; cin >> K;
  string S;
  cin >> S;
  if (S.size() <= K) {
    cout << S << endl;
  } else {
    rep(i, 0, K) {
      cout << S[i];
    }
    cout << "..." << endl;
  }

  return 0;
};


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

int main(void) {
int N, k;
int s[100];
k = 0;
cin >> N;
for(int i= 0; i <N; i++) {
cin >> s[i];
}
for(int i= N; i <100; i++) {
s[i] = 0;
}
for(int i= 0; i <N; i++) {
k = k + s[i];
}
if (k%10 != 0) {
cout << k << endl;
} else {
sort(s, s + 100);
for(int i= 0; i <N; i++) {
if (s[100-N+i] % 10 != 0) {
k = k - s[100-N+i];
cout << k << endl;
break;
}
}
}
if (k%10 == 0) {
cout << 0 << endl;
}
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define read(a) scanf("%d", &a)
#define readl(a) scanf("%lld", &a)
#define reads(a) scanf("%s", a)
#define readf(a) scanf("%lf", &a)
#define readc(a) scanf("%c", &a)
#define debug(a, b) printf("%s = %d\n", a, b)
#define debug1(a, i, b) printf("%s[%d] = %d", a, i, b)
#define show(a) putchar(a)
#define pb emplace_back
#define mk make_pair
#define _rand mt19937 RAND(time(0))
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define mem(a) memset(a, 0, sizeof(a))
#define Buff ios::sync_with_stdio(false)
typedef long long ll;
typedef long long LL;
typedef int Int;
typedef double db;
using namespace std;
const int INF = 1e9 + 7;
const int N = 2e5 + 7;
const int M = 5e6 + 7;
char s[N];
ll dp[N];
signed main()
{
    int n, p;
    read(n); read(p);
    reads(s + 1);

    ll ans = 0;
    if(p == 2 || p == 5)
    {
        for(int i = n; i; i--)
            if((s[i]-'0') % p == 0)
                ans += 1ll*i;
    }
    else
    {
        ll d = 1, x = 0;
        for(int i = n; i; i--)
        {
            x += (s[i]-'0') * d;
            x %= p;

            d *= 10;
            d %= p;

            ans += dp[x];
            dp[x]++;
            if(x == 0) ans++;
        }
    }
    printf("%lld\n", ans);
    return 0;
}
/**

**/



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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ll N; ll K; cin >> N >> K;
    ll over = N*(N-1)/2 - K + 1; //上からover番目は何か、という問題で、over以上の数は少なくともover個ある
    ll not_pos = 0;
    ll neg = 0;
    ll A[N]; rep(i, N){ cin >> A[i]; if(A[i] <= 0) not_pos++; if(A[i] < 0) neg++;}
    sort(A, A+N);
    //非正整数はnot_pos*(N-not_pos)個ある
    ll ok, ng, m;
    //prod[M]を,昇順に積を並べたものとする (M = N(N-1)/2)
    //積がkey以上となるようなペアがK個以上ある -> ok = key
    if(K <= not_pos*(N-not_pos)){
        //答えは非正整数
        //A[0]からA[not_pos-1]までが非正整数
        ok = -1000000000000000000;
        ng = 1;
    }
    else{
        //答えは非負整数(0かもしれない. not_pos*(N-not_pos) <= (積が0以下となるペアの数))
        //ex) N = 4, K = 5, A = {-1, 0, 1, 2}のとき 2*2 <= 5
        ok = 0;
        ng = 1000000000000000001;
    }
    m = (ok+ng)/2;
    while(abs(ok-ng) > 1){
        ll acc = 0;
        //O(NlogN)でmを超すようなペアの数を数える
        //A[i] < 0 のとき ok2 = -1, ng2 = Nとして探索, ok2+1を足す (0 <= i <= ok2なら1引く)
        //A[i] = 0のとき m <= 0ならacc += N-1, m > 0ならpass
        //A[i] > 0のとき ok2 = N, ng2 = -1として探索, N-ok2を足す (ok2 <= i <= N-1なら1引く)
        rep(i, N){
            ll ok_2, ng_2, m_2;
            if(A[i] == 0){
                if(m <= 0) acc += N-1;
                continue;
            }
            else if(A[i] > 0){
                ok_2 = N; ng_2 = -1;
            }
            else{
                ok_2 = -1; ng_2 = N;
            }
            m_2 = (ok_2 + ng_2)/2;
            while(abs(ok_2 - ng_2) > 1){
                if(A[i]*A[m_2] >= m) ok_2 = m_2;
                else ng_2 = m_2;
                m_2 = (ok_2 + ng_2)/2;
            }
            if(A[i] < 0){
                if(i <= ok_2) acc--;
                acc += ok_2+1;
            }
            else{
                if(ok_2 <= i) acc--;
                acc += N-ok_2;
            }
        }
        //この手法は(A[i],A[j])と(A[j],A[i])を区別している(ダブルカウントしている)ので閾値はKでなく2Kになる
        //mを超えるペアの数がacc個ある
        //それがKより大きいなら,K
        if(acc >= over*2) ok = m;
        else ng = m;
        m = (ok+ng)/2;
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0;i < N;i++)cin >> A[i];
    sort(A.rbegin(),A.rend());
    int mindif = INF;
    for(int i = 1;i < N;i++){
        if(mindif > max(A[0]-A[i],A[i])){
            mindif = A[i];
        }
    }   
    cout << A[0] << " " << mindif << endl;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  vector<double> a(n);
  REP(i,n) cin >> a[i];
  double ans = 0;
  REP(i,n) ans += 1.0/a[i];
  ans = 1.0/ans;
  cout << setprecision(9) << ans<< endl;
  return 0;
}


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

ab_sorted = sorted(ab, key=lambda x:(x[0], -x[1]))

num = 0
amount_of_money = 0
for i in range(n):
  buy = min(ab_sorted[i][1], m-num)
  num += buy
  amount_of_money += ab_sorted[i][0] * buy
    
  if num >= m:
    print(amount_of_money)
    exit(0)


Measured memory_bytes: 38712
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する
int A, B, C, D, E, F;

int main() {
    int n;
    cin >> n;
    vector<int> sum1(n);
    ll cnt1 = 0;
    vector<int> sum2(n);
    ll cnt2 = 0;
    vector<int> inp(n);
    REP(i, 0, n) {
        cin >> inp[i];
    }
    //最初を無理やり正に
    REP(i, 0, n) {
        if (i == 0) {
            sum1[i] = inp[i];

        } else {
            sum1[i] = sum1[i - 1] + inp[i];
        }
        if (sum1[i] <= 0 && i % 2 == 0) {
            int tmp = 1 - sum1[i];
            cnt1 += abs(tmp);
            sum1[i] += tmp;
        }
        if (sum1[i] >= 0 && i % 2 == 1) {
            int tmp = -1 - sum1[i];
            cnt1 += abs(tmp);
            sum1[i] += tmp;
        }
    }
    //最初を無理やり負にする
    REP(i, 0, n) {
        if (i == 0) {
            sum2[i] = inp[i];

        } else {
            sum2[i] = sum2[i - 1] + inp[i];
        }
        if (sum2[i] >= 0 && i % 2 == 0) {
            int tmp = -1 - sum2[i];
            cnt2 += abs(tmp);
            sum2[i] += tmp;
        }
        if (sum2[i] <= 0 && i % 2 == 1) {
            int tmp = 1 - sum2[i];
            cnt2 += abs(tmp);
            sum2[i] += tmp;
        }
    }
    cout << min(cnt1,cnt2) << endl;
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);

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

    int maxi = 0;
    int ans = 0;
    for (int i = 0; i < a.size(); i++){
        ans += a[i];
        if (maxi < a[i]) maxi = a[i];
    }

    ans -= int(maxi / 2);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        String s = scanner.next();
        String[] ss = s.split("");
        int sabun = 999;
        int tmp = 0;
        for (int i=0;i<s.length()-2;i++) {
        	tmp = Integer.parseInt(ss[i]+ss[i+1]+ss[i+2]);
        	if(Math.abs(tmp-753)<sabun) {
        		sabun = Math.abs(tmp-753);
        	}
        	if(sabun==0) {
        		break;
        	}
        }
        System.out.println(sabun);

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 23376
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, k) = readIntegerList()
    val aList = readIntegerList()
    val tmp = k - 1
    val ans = (n - 1 + (tmp - 1)) / tmp
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 49644
n = int(input())
s = []
second = 0
max_k = 0
for _ in range(n):
    k = int(input())
    max_k, min_k = max(k, max_k), min(k, max_k)
    second = max(min_k, second)
    s.append(k)
kk = s.index(max_k)
for i in range(n):
    if i != kk:
        print(max_k)
    else:
        print(second)

Measured memory_bytes: 12532
//math.hをインクルード
#include <stdio.h>
#include <math.h>

int main(void)
{
	//rは半径、areaは面積、circuitは円周
	double r, area, circuit;

	scanf("%lf", &r);

	//M_PIは定数π
	area = M_PI * (r * r);
	circuit = 2 * M_PI * r;

	printf("%f %f", area, circuit);

	return 0;
}


Measured memory_bytes: 2040
n, a, b = map(int, input().split())
a, b = min(a,b), max(a,b)
if (b-a) % 2 == 0:
    print((b-a)//2)
else:
    d = min(a - 1, n - b)
    print(d + 1 + (b-a-1)//2)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
bool check(int a)
{
	bool b3=false,b5=false,b7=false;
	while(a)
	{
		switch(a%10)
		{
			case 3:
				b3=true;
				break;
			case 5:
				b5=true;
				break;
			case 7:
				b7=true;
				break;
			default:
				return false;
		}
		a/=10;
	}
	return(b3&&b5&&b7);
}
int main()
{
	int n;
	int ans=0;
	cin>>n;	
	if(n>=777777753)
	{
			cout<<26484<<endl;	
	return 0;
	
		}	
	for(int i=357;i<=n;)
	{
		if(check(i))
		{
			ans++;
		}
		switch(i)
		{
			case 77777753:
				i=333333357;
				break;
			case 337777775:
				i=353333337;
				break;
			case 357777777:
				i=373333335;
				break;
			case 377777775:
				i=533333337;
				break;
			case 537777777:
				i=553333337;
				break;
			case 557777773:
				i=573333333;
				break;
			case 577777773:
				i=733333335;
				break;
			case 737777775:
				i=753333333;
				break;
			case 757777773:
				i=773333335;
				break;
			case 777777753:
				i=n;
				break;
			default:
				i+=2;
				break;					
		}
		
	}	
	cout<<ans<<endl;	
	return 0;
}


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

if N<=9:
    print(N)
elif 10<=N<=99:
    print(9)
elif 100<=N<=999:
    print(9+N-99)
elif 1000<=N<=9999:
    print(909)
elif 10000<=N<=99999:
    print(909+N-9999)
elif N==100000:
    print(90909)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const ll MOD = 998244353;
const ll INF = 2e15 + 10;
const ll MAX = 1e14 + 10;
const ld EPS = 1e-9;
const int N = 110;
const int M = 1e5 + 10;

ll d[N][M];
ll w[N], c[N];

void solve() {
    int n, k;
    cin >> n >> k;
    int m = 1e5;
    fr(i, n)
        cin >> c[i] >> w[i];
    fr(i, n + 1)
        fill(d[i], d[i] + m + 1, INF);
    d[0][0] = 0;
    fr(i, n)
        fr(j, m + 1) {
            if (d[i][j] == INF)
                continue;
            d[i + 1][j] = min(d[i + 1][j], d[i][j]);
            if (j + w[i] <= m)
                d[i + 1][j + w[i]] = min(d[i + 1][j + w[i]], d[i][j] + c[i]);
        }
    ll ans = 0;
    fr(i, n + 1)
        fr(j, m + 1)
            if (d[i][j] <= k)
                ans = max(ans, (ll)j);
    cout << ans;
}



int main() {
    //freopen("a.in", "r", stdin);
    ios_base::sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 80128
import java.util.Scanner;

public class Main {
	public	static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String n = sc.next();
			if(n.contains("-")){
				break;
			}
			int m = sc.nextInt();
			int h = 0;
			for(int i = 0;i < m; i++) {
				h += sc.nextInt();
			}
			int a = h%n.length();
			if(a != 0) {
				 n = n.substring(a) + n.substring(0,a);
			 }

			 System.out.println(n);
		}
	}
}


Measured memory_bytes: 26524
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N,M;cin>>N>>M;
	int p;string s;
	int AC[N]={},WA[N]={};
	rep(i,0,M){
		cin>>p>>s;
		if(AC[p-1]==0){
			if(s=="AC") AC[p-1]=1;
			else WA[p-1]++;
		}
	}
	int a=0,b=0;
	rep(i,0,N){
		a+=AC[i];
		if(AC[i]) b+=WA[i];
	}cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <unordered_set>
#include <cmath>
#include <queue>
#include <stdio.h>
#include <sstream>

using namespace std;
using ll = long long;
using ld = long double;
template <class T> using vec = std::vector<T>;
template <class T> using vvec = std::vector<std::vector<T>>;

#define REP(i, s, e) for (ll i = s; i < e; ++i)

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

    ll A, B; cin >> A >> B;
    cout << ((A + B)%2 == 0 ? to_string((A + B) / 2) : "IMPOSSIBLE") << endl;

    return 0;
}


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

int main()
{
    int N, buf;
    std::cin >> N;
    std::vector<int> vec;
    for (int i = 0; i < N; i++)
    {
        std::cin >> buf;
        vec.push_back(buf);
    }

    std::sort(vec.begin(), vec.end(), [](int l, int r) { return l > r; });
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
    std::cout << vec.size() << std::endl;
    return 0;
}

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

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main(void)
{
    int X;
    cin >> X;
    cout << ((X >=3 && X <= 7 && X % 2) ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

s = input().rstrip()
n = int(input())

if len(s) == 1:
    print(n // 2)
    exit()

s += "#"

k = 0
seq = []
for i, ch in enumerate(s):
    if i == 0:
        prev = ch
        k = 1
        continue
    if prev == ch:
        k += 1
    else:
        seq.append(k)
        k = 1
        prev = ch
    
if len(seq) == 1:
    ans = (seq[0] * n) // 2
    print(ans)
    exit()

if s[0] != s[-2]:
    ans = 0
    for item in seq:
        ans += item // 2
    print(ans * n)
else:
    mid = 0
    for item in seq[1:-1]:
        mid += item // 2
    ans = mid * n + seq[0] // 2 + seq[-1] // 2
    ans += ((seq[0] + seq[-1]) // 2) * (n - 1)
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define oo 0x3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

set<ll> d;
void factors(ll n) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i)
			continue;
		d.insert(i);
		d.insert(n / i);
	}
}

bool valid(ll n, ll k) {
	while (n % k == 0)
		n /= k;
	if (n % k == 1)
		return true;
	return false;
}
int main() {
	run();
	ll n;
	cin >> n;
	factors(n);
	factors(n - 1);
	d.erase(1);
	ll cnt = 0;
	for (auto it : d){
		cnt += valid(n, it);
	}
	cout << cnt << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define lint long long

using namespace std;
int n;
int d;
int dt;

int main(){
  cin >> n;
  int nx = 0;
  int ny = 0;
  int nt = 0;
  string ans = "Yes";
  REP(i,n){
    int t,x,y;
    cin >> t >> x >> y;
    d = abs(nx-x)+abs(ny-y);
    dt = t - nt;
    nt = t;
    nx = x; ny = y;
    if(d>dt || (abs(d-dt))%2==1) ans = "No";
  }
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 256
import
    std.algorithm,
    std.array,
    std.conv,
    std.functional,
    std.stdio,
    std.string;

void main()
{
    auto b = readln.chomp.split.to!(int[]);
    auto arr = readln.chomp.split.to!(int[]);
    solve(b[1], b[2], arr).writeln;
}

int[] cards;
int _solveX(in int y, in size_t p)
{
    int answer = abd(y, cards[$-1]);
    foreach (i; 1..p)
        answer = solveY(cards[$-i-1], i).max(answer);
    return answer;
}
int _solveY(in int x, in size_t p)
{
    int answer = abd(x, cards[$-1]);
    foreach (i; 1..p)
        answer = solveX(cards[$-i-1], i).min(answer);
    return answer;
}
alias solveX = memoize!_solveX;
alias solveY = memoize!_solveY;
auto solve(in int x, in int y, int[] a)
{
    cards = a;
    return solveX(y, a.length);
}
auto abd(in int x, in int y)
{
    return x < y ? y - x : x - y;
}


Measured memory_bytes: 2812
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}

ll mpow(ll a, ll x){
  ll res = 1;
  while(x > 0){
    if(x & 1) res = (res * a);
    a = (a * a);
    x >>= 1;
  }
  return res;
}

int main(){
  ll N, K; cin >> N >> K;
  vector<ll> A(N); rep(i,N) cin >> A[i];
  vector<int> cnt(40,0);
  rep(i,N){
    ll now = A[i];
    rep(j,40){
      cnt[j] += now&1;
      now >>= 1;
    }
  }
  reverse(all(cnt));
  //rep(i,40) cout << cnt[i];
  //cout << endl;
  vector<int> k(40,0);
  ll kk = K;
  rep(i,40){
    k[i] = kk & 1;
    kk >>= 1;
  }
  reverse(all(k));
  //rep(i,40) cout << k[i];
  //cout << endl;
  ll x=0;
  bool f = false;
  rep(i,40){
    ll pre = (cnt[i]*2<=N)?1:0;
    if(k[i]==0 && (!f)){
      pre = 0;
    }
    if(pre==0 && k[i]==1){
      f = true;
    }
    x += pre * mpow(2,39-i);
  }
  //cout << x << endl;
  ll ans = 0;
  rep(i,N){
    ans += x^A[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 4024
A1, A2, A3 = [int(elem) for elem in input().split(' ')]

abs1 = abs(A1 - A2)
abs2 = abs(A1 - A3)
abs3 = abs(A2 - A3)

sum_task = sum([abs1, abs2, abs3]) - max([abs1, abs2, abs3])
print(sum_task)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define pb push_back



using namespace std;
using ll = long long;
const ll mod = 1000000007;
const double PI = acos(-1);

ll ab(ll x){
    return max(x,-x);
}

ll gcd(ll a,ll b){
    if(a==0 ) return ab(b);
    if(b==0) return ab(a);
    if(ab(a) == ab(b)) return ab(a);
    if(ab(a) ==1 || ab(b) == 1) return 1;

    if(ab(a) > ab(b)){
        return gcd(ab(a)%ab(b),ab(b));
    }else return gcd(ab(a),ab(b)%ab(a));
}

pair<ll,ll> f(pair<ll,ll> a){
    pair<ll,ll> b;
    if(a.first == 0){
        b.first = 0;
        b.second = ab(a.second);
    }
    if(a.first < 0){
        b.first = -a.first;
        b.second = -a.second;
    }else b = a;


    return b;
}

pair<ll,ll> vert(pair<ll,ll> a){
    pair<ll,ll> b;
    b.first = -a.second;
    b.second = a.first;
    b = f(b);
    return b;
}


ll modpow(ll a,ll b){
    
    if(b == 0) return 1;
    if(b%2 == 0){
        return modpow(a,b/2)*modpow(a,b/2)%mod;
    }else return modpow(a,b-1)*a%mod;
}



int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n,s=0;
    cin >> n;
    ll a[n];

    rep(i,n){
        cin >> a[i];
        s = s^a[i];
    }
    rep(i,n){
        ll ans = a[i]^s;
        cout << ans << endl;
    }
    return 0;
}


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

#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define for1(i, n) for(int i = 1; i <= (int)(n); ++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; --i)
#define ford1(i, n) for(int i = (int)(n); i>=1; --i)
#define fored(i, a, b) for(int i = (int)(b); i >= (int)(a); --i)
#define sz(v) ((int)((v).size()))
#define all(v) (v).begin(), (v).end()
#define clr(v) memset(v, 0, sizeof(v))
#define clr1(v) memset(v, 0xFF, sizeof(v))
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long i64;
typedef unsigned long long u64;
typedef long double ld;
typedef vector<ld> vld;

typedef vector<i64> vi64;

template<class T> bool uax(T&a, const T& b) { if( a < b ) { a = b; return true; } return false; }
template<class T> bool uin(T&a, const T& b) { if( a > b ) { a = b; return true; } return false; }

const int N = 2010;

vi g[N];

int dfs(int v, int p, int md) {
  int s = 1;
  if (md > 0) for (int u : g[v]) if (u != p)
    s += dfs(u, v, md - 1);
  return s;
}

void solve() {
  int n, k;
  cin >> n >> k;
  forn(i, n - 1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].pb(b);
    g[b].pb(a);
  }
  int r = 0;
  if (k % 2 == 0) forn(i, n) {
    int z = dfs(i, -1, k / 2);
    // cerr << "d " << i << '=' << z << '\n';
    uax(r, z);
  } else {
    forn(v, n) for(int u: g[v]) {
      int z = dfs(v, u, k / 2) + dfs(u, v, k / 2);
      cerr << "d " << v << ' ' << u <<  '=' << z << '\n';
      uax(r, z);
    }
  }
  cout << n - r << '\n';
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed; cout.precision(15);
  cerr << fixed; cerr.precision(15);
#ifdef HOME
  freopen("input.txt", "r", stdin);
#endif
  solve();
  return 0;
}


Measured memory_bytes: 384
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 len(d)!=0:
                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 <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll a[3];
    for(int i=0;i<3;i++)
    {
        cin>>a[i];
    }
    sort(a,a+3);
    cout<<(a[0]*a[1])/2<<endl;
}
return 0;
}

Measured memory_bytes: 256
import sys
L,R = map(int,input().split())
list1 = []
i = L
j = L + 1
jcount = 0
while True:
    if i < R:
        if i*j %2019 == 0:
            print(0)
            sys.exit()
        list1.append(i*j%2019)
        if j < R:
            j += 1
        else:
            jcount += 1
            j = L+1 + jcount
            i += 1
    else:
        break
if len(list1) == 0:
    print(i*j%2019)
print(min(list1))

Measured memory_bytes: 6892
#include <iostream>
#include  <vector>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <string>
using namespace std;

int main()
{

    string s1, s2;
    cin >> s1 >> s2;
    if(s1.size() > s2.size()){
        cout << "GREATER" << endl;
    }else if (s1.size() < s2.size()){
        cout << "LESS" << endl;
    }else {
        for (int i = 0; i < max(s1.size(), s2.size()); i++) {
            int i1 = s1[i] - '0';
            int i2 = s2[i] - '0';
            if (i1 > i2) {
                cout << "GREATER" << endl;
                break;
            } else if (i1 < i2) {
                cout << "LESS" << endl;
                break;
            } else if (i == max(s1.size(), s2.size()) - 1) {
                cout << "EQUAL" << endl;
            }
        }
    }
    return 0;
}

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

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var s = Console.ReadLine();
            var k = long.Parse(Console.ReadLine());

            var count = 0;
            var left = 0;
            var right = 0;
            for (var i = 0; i < s.Length; i++)
            {
                if (s[i] == s[0]) left++;
                else break;
            }
            if (left == s.Length)
            {
                Console.WriteLine(s.Length * k / 2);
                return;
            }

            for (var i = s.Length - 1; i >= 0; i--)
            {
                if (s[i] == s[0]) right++;
                else break;
            }

            var tmp = 1;
            var prev = s[0];
            for (var i = left; i < s.Length - right; i++)
            {
                if (s[i] == prev)
                {
                    tmp++;
                }
                else
                {
                    count += tmp / 2;
                    tmp = 1;
                }
                prev = s[i];
            }
            count += tmp / 2;
            var edge = (left + right) / 2;
            count += edge;

            Console.WriteLine(count * k - edge + left / 2 + right / 2);
        }
    }
}


Measured memory_bytes: 11092