akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimze("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)998244353
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll inf=1e18, N=200005;
ll fact[N], invFact[N];
inline ll mult(ll x,ll y){x%=hell;y%=hell;return (1LL*x*y)%hell;}
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll powMod(ll base,ll expo){
	if(base==0)return 0;
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base); 
		expo>>=1;
	}
	return ans;
}
inline ll C(ll x,ll y){
	if(x<y)return 0;
	return mult(fact[x],mult(invFact[y],invFact[x-y]));
}
void solve(){
	ll ans=0, n, k, m;
	cin>>n>>m>>k;
	rep(i,0,k+1){
		ll tmp=mult(C(n-1,i),mult(m,powMod(m-1,n-i-1)));
		ans=add(ans,tmp);
	}
	if(m==1){
		if(k==n-1)cout<<1;
		else
		cout<<0;
		return;
	}
	cout<<ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	fact[0]=1;
   	rep(i,1,N)fact[i]=mult(fact[i-1],i);
   	invFact[N-1]=powMod(fact[N-1],hell-2);
   	for(ll i=N-2;i>=0;i--)invFact[i]=mult(invFact[i+1],i+1);
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


Measured memory_bytes: 6780
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T1BC2019_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            int a = int.Parse(strs[0]);
            int b = int.Parse(strs[1]);
            int c = int.Parse(strs[2]);

            bool flag = false;

            if ((a <= b && a <= c && c <= b) ||
                (a >= b && a >= c && c >= b))
            {
                flag = true;
            }

            Console.WriteLine("{0}", flag? "Yes" : "No");
        }


    }
}


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

using namespace std;

const int size = 407;
long long int arr[size];
long long int dp[size][size];
long long int mx = 1e14 + 5;

long long int solve(int l, int r){
	if(l > r) return mx;
	if(dp[l][r] != -1) return dp[l][r];
	long long int ans = mx;
	// for(int x=l;x<=r;x++){
	// 	for(int i = x+1;i<=r;i++){
	// 		for(int j = x+1;j<=i;j++){
	// 			ans = min(ans, solve(x,j-1) + solve(j,))
	// 		}
	// 	}
	// }
	for(int j=l+1;j<=r;j++) ans = min(ans, solve(l,j-1) + solve(j,r) + ((l > 0)? arr[r] - arr[l-1] : arr[r]));
	dp[l][r] = ans;
	return ans;
}

int main(){
	int n;
	cin>>n;
	for(int x=0;x<n;x++) cin>>arr[x];
	for(int x=0;x<n;x++){
		for(int i=0;i<n;i++){
			dp[x][i] = -1;
		}
		dp[x][x] = 0;
		if(x!=0) arr[x] += arr[x-1];
	}
	cout<<solve(0, n-1);
	return 0;
}

Measured memory_bytes: 1536
import numpy as np
import sys
sys.setrecursionlimit(1000000)

def dfs(cost, i, A):
    if i == n-1:
        global ans
        if cost < ans and all([ai>=x for ai in A]):
            ans = cost
        return
    i += 1
    dfs(cost, i, A)
    dfs(cost+c[i], i, A+a[i])

    

if __name__ == "__main__":
    n, m, x = map(int, input().split())
    c, a = [None]*n, np.array([None]*n)
    for i in range(n):
        c[i], *a[i] = map(int, input().split())
    ans = 10**10
    dfs(0, -1, np.array([0]*m))
    if ans == 10**10:
        print(-1)
    else:
        print(ans)
    


Measured memory_bytes: 27248
n = int(input())
x = list(map(int,input().split()))
for i in range(n):
    temp = x[i]
    j = i - 1
    while j>= 0 and x[j] > temp:
        x[j+1] = x[j]
        j -= 1
    x[j+1] = temp
    print(*x)



Measured memory_bytes: 5976
#include "bits/stdc++.h"
 
#define int long long
 
using namespace std;
#define REP(i, s, n) for(signed i = (s); i < signed(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for(int i = signed(n) - 1; i >= 0; i--)
#define all(co) co.begin(), co.end()
typedef pair<int, int> P;
typedef long long LL;
 
#ifdef int
const long long INF = 1ll << 62ll;
#else
const singed INF = 1 << 29;
#endif
 
struct edge{ int from, to, cost; };
 
int dr[] = { -1, 0, 1, 0 };
int dc[] = { 0, 1, 0, -1 };
 
template<typename T = int>
vector<vector<T>> vvector(int h, int w, T def = T()){ return move(vector<vector<T>>(h, vector<T>(w, def))); }
class range {
private: struct I{ int x; int operator*(){ return x; }bool operator!=(I& lhs){ return x < lhs.x; }void operator++(){ ++x; } }; I i, n;
public:range(int n) :i({ 0 }), n({ n }){}range(int i, int n) :i({ i }), n({ n }){}I& begin(){ return i; }I& end(){ return n; }
};
 
signed main()
{
    int h, w;
    while (cin >> h >> w && h)
    {
        auto dp = vvector(h, w + 1);
        int ans = 0;
        rep(i, h)
        {
            stack<P> st;
            st.push(P(0, 0));
            rep(j, w + 1)
            {
                char c = 'x';
                int x = 1;
                if (j < w) cin >> c;
                if (c == '.') x = 0;
 
                if (!x) dp[i][j] = 1;
                if (i >= 1 && dp[i - 1][j] && !x)
                    dp[i][j] = dp[i - 1][j] + 1;
 
                int size = dp[i][j];
                if (size == st.top().first) continue;
                else if (size > st.top().first) st.push(P(size, j));
                else
                {
                    int beg = j;
                    while (!st.empty() && st.top().first > size)
                    {
                        P p = st.top(); st.pop();
                        ans = max(ans, (j - p.second) * p.first);
                        beg = p.second;
                    }
                    if (st.top().first == size) 
                        ans = max(ans, (j - st.top().second + 1) * st.top().first);
                    else st.push(P(size, beg));
                }
            }
        }
 
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3176
import sys

input = sys.stdin.readline

S = input().strip()
K = int(input())

ans = []
start = S[0]
count = 1

if len(S) == 1:
    print(K // 2)
    exit()

flag = True
for i in range(len(S) - 1):
    if S[i] != S[i+1]:
        flag = False
if flag:
    print((len(S)*K) // 2)
    exit()

flag = True
T = S + S[0]
for i in range(len(T) - 1):
    if T[i] == T[i+1]:
        flag = False
if flag:
    print(0)
    exit()

#if S[0] == S[-1]:
    #S = S + S[0]
    #trigger = True

for i in range(1, len(S)):
    now = S[i]
    if start == now:
        count += 1
    else:
        if count >= 2:
            ans.append(count // 2)
        count = 1
    start = now

if count >= 2:
    ans.append(count // 2)

counter2 = 1
for i in range(len(S) - 1):
    if S[i] == S[i+1]:
        counter2 += 1
    else:
        break

if (count + counter2) % 2 == 0:
    trigger = True
else:
    trigger = False

if S[0] == S[-1] and trigger:
    ans.append(1)
    trigger = True
else:
    trigger = False

out = sum(ans) * K
if trigger:
    out -= 1
print(out)


Measured memory_bytes: 3064
#include <iostream>
#include <climits>
#define rep(i, N) for(int i = 0; i < N; i++)
using namespace std;

int N, A, B, C;
int min_MP = INT_MAX;
int L[8];
int ans = INT_MAX;


int dfs(int n, int a, int b, int c, int magic_A, int magic_B, int magic_C){
    
    if(n == N){
        if(a > 0 && b > 0 && c > 0){
            ans = min(ans, abs(A-a) + abs(B-b) + abs(C-c) + ( (magic_A + magic_B + magic_C) * 10) - 30 );
            return ans;
        }
        else{
            return ans;
        }
    }
    
    dfs(n+1, a, b, c, magic_A, magic_B, magic_C);
    dfs(n+1, a+L[n], b, c, magic_A+1, magic_B, magic_C);
    dfs(n+1, a, b+L[n], c, magic_A, magic_B+1, magic_C);
    dfs(n+1, a, b, c+L[n], magic_A, magic_B, magic_C+1);
    
    return ans;
    
}


int main(void){
    
    cin >> N >> A >> B >> C;
    
    
    rep(i, N) cin >> L[i];
    
    
    cout << dfs(0,0,0,0,0,0,0) << endl;
    
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,a[110],s=0,p=0,ans=0;
	cin >> n;
	for(int i=0;i<n;i++)
	{
	    cin >> a[i];
	    s+=a[i];
	}
	p=(int)(1.0*s/n+0.5);
	for(int i=0;i<n;i++)
    {
        ans+=(a[i]-p)*(a[i]-p);
    }
        cout<< ans <<endl;
	return 0;
 }

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




int main() {
    ll h, w, n;
    cin >> h >> w >> n;
    
    map<pair<ll, ll>, ll> m;
    REP(i, n){
        ll a, b;
        cin >> a >> b;
        a--;b--;
        
        REP(j, 3){
            REP(k, 3){
                if(a - j < 0 || b - k < 0 || a - j >= h - 2 || b - k >= w - 2)continue;
                m[{a - j, b - k}]++;
            }
        }
    }
    
    vector<ll> ans(10);
    ans[0] = (h - 2) * (w - 2) - m.size();
    for(auto x : m){
        ans[x.second]++;
    }
    
    REP(i, 10){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 56448
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN   
#define linf LLONG_MAX
#define lninf LLONG_MIN   
const ll mod = 1e9+7;
const int N = 2e5+4;

int main()
{
	int n; scn(n);

	int a[n],x=0;

	int val=0,temp=0;

	rep(i,0,n)
	scn(a[i]),x+=a[i];

	x/=n; 

	rep(i,0,n)
	{
		val += (x-a[i])*(x-a[i]);

		temp += (x+1-a[i])*(x+1-a[i]);
	}

	pri(min(val,temp));

	return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define IO ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define ll long long int
int main()
{
//	IO;
	int n;
	cin>>n;
	string a;
	cin>>a;
	int c=0,m=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]=='I')
		{
			c++;
		}
		else
		{
			c--;
		}
		m = max(m,c);
	}
	cout<<m;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

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

		double ans = 0;
		for (int i = 1; i <= N; i++) {
				double P = 1;
				int x = i;
				while (x < K) {
						P *= 0.5;
						x *= 2;
				}
				ans += P / N;
		}
		printf("%.12f\n", ans);
		return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;
int a[200009];
int main()
{
    int k,n;
    cin>>n>>k;
    int q;
    for(int i=0;i<n;i++)
    {
        cin>>q;
        a[q]++;
    }
    sort(a,a+200005);
    int l=0;
    for(int i=0;i<200005;i++)
    {
        if(a[i]!=0)
        {
            l++;
        }
    }
    int h=l-k;
    int sum=0;
    if(h>0)
    for(int i=0;i<200005;i++)
    {
        if(h==0)
            break;
        if(a[i]!=0)
        {
            sum+=a[i];
            h--;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int a[110];
int ans = 0;
int v = 1;

int main() {
	int n; cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (i == 1)continue;
		if (i == n) {
			if (a[i] == a[i - 1])v++;
			ans += v / 2;
			continue;
		}
		if (a[i] == a[i - 1])v++;
		else {
			ans += v / 2;
			v = 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int y = 0;

		for(int i = 0; i < N; i++) {
			if(sc.nextInt() >= K) {
				y++;
			}
		}

		System.out.println(y);

		sc.close();
	}
}

Measured memory_bytes: 47872
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

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


//////////////////////////////////////////////////////////////////////////////////////b,cl

int main(){
    int n, x;
    int ans = 0;
    while(true){
        cin >> n >> x;
        ans = 0;
        if (n == 0 && x == 0){
            break;
        }

        for (int i=1;i<=n;i++){
            for (int j=i+1;j<=n;j++){
                for(int k=j+1;k<=n;k++){
                    if (i + k + j == x){
                        ans++;
                    }
                }
            }
        }

        cout << ans << endl;
    }

}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int main(){
	ll N,A,B;
	cin>>N>>A>>B;
	if(A>B){
		puts("0");
		return 0;
	}
	if(N==1){
		if(A==B) puts("1");
		else puts("0");
		return 0;
	}
	ll ans = B*(N-1)+A - ( A*(N-1)+B ) + 1;
	cout<<ans<<endl;
}


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

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define _ << " " <<

typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second

const int MAX = 1<<17;

int n;
vector <P> V[MAX];
int sub[MAX];
ll rje;
vector <int> Centri;

int dfs(int x, int pr) {
  int mx = 0;

  sub[x] = 1;
  for (auto it : V[x]) {
    if (it.X == pr) continue;
    int tmp = dfs(it.X, x);
    sub[x] += tmp;
    rje += 2ll * it.Y * min(sub[it.X], n - sub[it.X]);

    mx = max(mx, tmp);
  }

  mx = max(mx, n-sub[x]);
  //  TRACE(x _ mx);
  if (mx * 2 <= n) {
//    TRACE(mx _ x);
    Centri.push_back(x);
  }

  return sub[x];
}

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

  REP(i, n-1) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c); a--; b--;
    V[a].push_back({b, c});
    V[b].push_back({a, c});    
  }

  dfs(0, -1);

  //  TRACE(Centri.size());

  assert((int) Centri.size() == 1 || (int) Centri.size() == 2);
  if ((int) Centri.size() == 2) {
    for (auto it : V[Centri[0]])
      if (it.X == Centri[1])
	rje -= it.Y;
  }
  else {
    int ind = Centri[0];
    sort(V[ind].begin(), V[ind].end(), [] (P a, P b) { return a.Y < b.Y; });
    rje -= V[ind][0].Y;// + V[ind][1].Y;
  }
  
  printf("%lld\n", rje);

  return 0;
}


Measured memory_bytes: 13568
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b, c = list(input())
e, f, g = list(input())
h, i, j = list(input())

print(a, f, j, sep="")


Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pii pair<int,int>
#define reset(x,n) memset((x),(n),sizeof(x))
#define all(n) (n).begin(),(n).end()
#define pb push_back
#define IOS ios::sync_with_stdio(0),cin.tie(0);
bitset<10005> ok[5005];
int stick[] = {0,2,5,5,4,5,6,3,7,6};
bool used[10];
int n,m;

int main(){
	ok[0][0] = 1;
	cin>>n>>m;
	for(int i=1,x;i<=m;i++){
		cin>>x;
		used[x] = 1;
		for(int j=1;j<=5000;j++){
			ok[j] = ok[j] | (ok[j-1]<<stick[x]); 
		}
	}	
	int now = n;
	string ans = "";
	int st = 5000;
	while(!ok[st][now]) st--;
	for(int i=st;i>=1;i--){
		for(int j=9;j>=1;j--){
			if(used[j] && now >= stick[j] && ok[i-1][now-stick[j]]){
				ans += j + '0';
				now -= stick[j];
				break;
			}
		}
	}
	cout<<ans<<'\n';	
}


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

int main() {
    int N;
    std::cin >> N;

    std::vector<int> L;

    int l = 0;
    for (int i = 0; i < N; ++i) {
        std::cin >> l;
        L.push_back(l);
    }

    std::sort(L.begin(), L.end());

    int cnt = 0;
    for (std::size_t i = 2; i < L.size(); ++i) {
        for (std::size_t j = 0; j < i - 1; ++j) {
            for (std::size_t k = j + 1; k < i; ++k) {
                if (L[i] < (L[j] + L[k])) {
                    ++cnt;
                } 
            }
        }
    }

    std::cout << cnt << std::endl;
        
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <bitset>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
const int MAX = 510000;

set<pair<int, int>> st;

set<pair<int, int>> searched;
int main()
{
    ll H, W, N;
    cin >> H >> W >> N;
    for (int i = 0; i < N; ++i)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        st.insert(make_pair(a, b));
    }

    ll arr[10] = {0};

    for (auto e : st)
    {
        int y = e.first, x = e.second;
        for (int i = -1; i <= 1; ++i)
        {
            for (int j = -1; j <= 1; ++j)
            {
                int ny = i + y,
                    nx = j + x;
                if (searched.find(make_pair(ny, nx)) == searched.end())
                {
                    searched.insert(make_pair(ny, nx));

                    int t = 0;
                    bool c = true;
                    for (int k = -1; k <= 1; ++k)
                    {
                        for (int l = -1; l <= 1; ++l)
                        {
                            if (ny + k >= 0 && ny + k < H && nx + l >= 0 && nx + l < W)
                            {
                                if (st.find(make_pair(ny + k, nx + l)) != st.end())
                                {
                                    //cout << ny + k << " " << nx + l << endl;
                                    t++;
                                }
                            }
                            else
                            {
                                c = false;
                            }
                        }
                    }

                    if (c)
                    {
                        //cout << t << " " << ny << " " << nx << endl;
                        arr[t]++;
                    }
                }
            }
        }
    }

    ll sum = 0;
    for (int i = 0; i < 10; ++i)
        sum += arr[i];

    ll zen = (H - 2) * (W - 2);
    arr[0] = max(0LL, zen - sum);
    for (int i = 0; i < 10; ++i)
    {
        cout << arr[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 47104
#include<iostream>
using namespace std;
#define Endl '\n'
typedef long long int lli;
typedef pair<int, int> ii;
void solve();
int main(int argc, char const *argv[]){
 	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
  solve();
}

lli gcd(int a, int b){
  return a==0?b:gcd(b%a, a);
}

lli gcd(int a, int b, int c){
  return gcd(gcd(a, b), c);
}
void solve(){
  int k;
  cin>>k;
  lli sum = 0;
  for(int a = 1;a<=k;a++){
    for(int b = 1;b<=k;b++){
      for(int c=1;c<=k;c++){
        sum+=gcd(a, b, c);
      }
    }
  }
  cout<<sum<<Endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define REP(i,x) for(int i=0,i##_len=(x);i<i##_len;++i)
#define rep(i,a,b) for(int i=(a),i##_len(b);i<i##_len;++i)
#define All(x) begin(x),end(x)
#define rAll(x) rbegin(x),rend(x)
using namespace std;
using ll = long long;

int main(){
    int X,Y,A,B,C;
    cin>>X>>Y>>A>>B>>C;
    vector<ll> p(A),q(B),r(C);
    REP(i,A) cin>>p[i];
    REP(i,B) cin>>q[i];
    REP(i,C) cin>>r[i];
    priority_queue<ll,vector<ll>,greater<ll>> red,green;
    sort(rAll(p));
    sort(rAll(q));
    ll ans=0;
    REP(i,X){
        ans+=p[i];
        red.push(p[i]);
    }
    REP(i,Y){
        ans+=q[i];
        green.push(q[i]);
    }
    REP(i,C){
        if(red.top()<green.top()){
            if(r[i]>red.top()){
                ans+=r[i]-red.top();
                red.pop();
                red.push(r[i]);
            }
        }
        else{
            if(r[i]>green.top()){
                ans+=r[i]-green.top();
                green.pop();
                green.push(r[i]);
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4852
#include<bits/stdc++.h>
// #include<io.h> //for access(path) codeforces
using namespace std;

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

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define endl "\n"
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define sz(a) int64_t(a.size())
const ll mod = 1e9 + 7;

#define MAXN  1000001

int spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)
        spf[i] = i;
    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;
    for (int i=3; i*i<MAXN; i++){
        if (spf[i] == i){
            for (int j=i*i; j<MAXN; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}

// vector<int> getFactorization(int x)
// {
//     vector<int> ret;
//     while (x != 1) {
//         ret.push_back(spf[x]);
//         while(x%spf[x]==0)x = x / spf[x];
//     }
//     return ret;
// }

int a[MAXN];
void solve(){
    int n;
    cin>>n;
    sieve();
    for(int i=0; i<n; i++)cin>>a[i];
    // sort(a,a+n);
    unordered_map<int,int> mp;
    int sw =1;
    int pw = 1;
    for(int i=0; i<n; i++){
        int x = a[i];
        while(x>1) {
            int sp = spf[x];
            mp[sp]++;
            if(mp[sp]>1)pw = 0;
            if(mp[sp]==n)sw = 0;
            while(x>1 && x%sp==0)x = x/sp;
        }
    }
    if(pw) cout<<"pairwise coprime"<<endl;
    else if(sw) cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
}

int main(){
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    // freopen("in.txt", "r", stdin);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t=1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}



Measured memory_bytes: 14276
#include <bits/stdc++.h>
#define inf (int)(1e9)
using namespace std;

int n;
vector<string> s;

int solve();

int main() {
  cin >> n;
  s.resize(n);
  for (auto& p : s) cin >> p;
  cout << solve() << endl;
  return 0;
}

int solve() {
  {
    bool ch = 0;
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j)
        if (s[i][j] == '#') ch = 1;
    if (!ch) return -1;
  }
  int cnt = n, res = inf;
  for (int j = 0; j < n; ++j) {
    bool ch = 1;
    for (int i = 0; i < n; ++i)
      if (s[i][j] == '.') ch = 0;
    cnt -= ch;
  }
  for (int i = 0; i < n; ++i) {
    bool ch = 0;
    for (int j = 0; j < n; ++j)
      if (s[j][i] == '#') ch = 1;
    if (!ch) continue;
    int now = 0;
    for (int j = 0; j < n; ++j)
      if (s[i][j] == '.') ++now;
    res = min(res, cnt + now);
  }
  for (int i = 0; i < n; ++i) {
    string ns = s[i];
    {
      bool ch = 0;
      for (int j = 0; j < n; ++j)
        if (ns[j] == '#') ch = 1;
      if (!ch) continue;
    }
    for (int j = 0; j < n; ++j) {
      bool ch = 1;
      for (int k = 0; k < n; ++k)
        if (s[k][j] == '.') ch = 0;
      int now = 0;
      for (int k = 0; k < n; ++k)
        if (k != j && s[j][k] == '.') ++now;
      if (ns[j] == '.') ++now;
      res = min(res, now + cnt + ch + 1);
    }
  }
  return res;
}

Measured memory_bytes: 4140
#include <cstdio>
#include <algorithm>
using namespace std;
int a[200010];
int b[200010];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= 2 * n - 1; i++) {
		scanf("%d", &a[i]);
	}
	int lo = 1, hi = 2 * n;
	while (lo + 1 < hi) {
		int mid = (lo + hi) / 2;
		b[0] = -1;
		for (int i = 1; i <= 2 * n - 1; i++) {
			b[i] = a[i] >= mid;
		}
		for (int i = 1; i < n; i++) {
			if (b[n-i] == b[n-i+1]) {
				b[0] = b[n-i];
				break;
			}
			if (b[n+i] == b[n+i-1]) {
				b[0] = b[n+i];
				break;
			}
		}
		if (b[0] == -1) {
			b[0] = b[1];
		}
		if (b[0]) {
			lo = mid;
		} else {
			hi = mid;
		}
	}
	printf("%d\n", lo);
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
string s;

int main(){
	cin>>s;
	s='1'+s+'1';
	n=s.size();
	vl dp(5);
	dp[1]++;
	for(int i=1;i<n;i++){
		vl DP(5);
		if(s[i]=='0'||s[i]=='?'){
			DP[0]=(dp[0]+dp[1])%mod;
			DP[2]=(dp[2]+dp[3])%mod;
			DP[4]=dp[4];
		}
		if(s[i]=='1'||s[i]=='?'){
			DP[1]=(dp[0]+(i%2==0?dp[1]:0))%mod;
			DP[3]=((i%2==1?dp[1]+dp[3]:0)+dp[2])%mod;
			(DP[4]+=(i%2==0?dp[3]:0)+dp[4])%=mod;
		}
		dp=DP;
	}
	cout<<dp[4]<<endl;
}

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

int main(){
    int a,b,i;
    cin>>a>>b;
    
    int r = 0;
    for(i = a;i <= b;i++){
        int s = i % 10 , t = i / 10000 % 10;
int u = i / 10 % 10 , v = i / 1000 % 10;
if( s == t&&u == v) r++;
    }
    cout << r << endl;
    return 0;
}

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

 int main() {
   string n;
   cin >> n;
   //cout << n << endl;
   
   for(int i = 0;i < 3; i++){
    if(n.at(i) == '1'){
      n.at(i) = '9';
    }else if(n.at(i) == '9'){
      n.at(i) = '1';
    }
   }
   cout << n << endl;
} 

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

vector<pair<double, double> > v;
pair<double, double> s, ss, p;
vector<pair<double, pair<int, int> > > vv, vvv;
double sum;


void l(){
  for(int i = 1; i < v.size(); i++){
    double x = abs(v[0].first-v[i].first), y = abs(v[i].second-v[0].second);
    vv.push_back(make_pair(sqrt((x*x)+(y*y)),make_pair(0,i)));
  }
}

void ll(){

  for(int i = 1; i <= v.size()-2; i++){
    double x = abs(v[i+1].first-v[i].first), y = abs(v[i+1].second-v[i].second);
    vvv.push_back(make_pair(sqrt((x*x)+(y*y)),make_pair(i,i+1)));
  }

}

double solve(){

  for(int i = 1; i <= v.size()-2; i++){
    double z = (vv[i].first+vv[i-1].first+vvv[i-1].first)/2;
    double a = vv[i].first, b = vv[i-1].first, c = vvv[i-1].first;
    sum += sqrt(z*(z-a)*(z-b)*(z-c));
    //cout << sum;
  }
  printf("%.6f\n",sum);

}


int main(){

  char n;
  while(cin >> p.first >> n>> p.second){
      v.push_back(p);
  }
  l();
  ll();
  solve();

  
  /* for(int i = 0; i < vvv.size(); i++){
    cout << vvv[i].first << " " << vvv[i].second.first << " " << vvv[i].second.second << endl;
  */
}
  

Measured memory_bytes: 1248
def factorization(n):
    arr = []
    temp = n
    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
            if not i in arr:
                arr.append(i)

    if temp!=1:
        if not temp in arr:
                arr.append(temp)

    return arr

from fractions import gcd
A,B = map(int,input().split())
print(len(factorization(gcd(A,B)))+1)

Measured memory_bytes: 5564
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		double max=0, min=Double.MAX_VALUE;
		for(;sc.hasNext();){
			double h=sc.nextDouble();
			max=max(max,h);
			min=min(min,h);
		}
		println(""+(max-min));
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORTR(x) sort(ALLR(x));
#define SORT(x) sort(ALL(x));
#define SUM(x) accumulate(ALL(A), 0);
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
typedef vector<ll> VI;
typedef vector<VI> VVI;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}


void Main()
{
	ll result=0;
	ll X,Y;
	cin>>X>>Y;
	ll val=X;
	while(val<=Y){
		val*=2;
		result++;
	};
	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
S = input()

S_one = int(S[:2])
S_two = int(S[2:])

if S_one == 0:
    if 1 <= S_two <= 12:
        print('YYMM')
    else:
        print('NA')
elif 1 <= S_one <= 12:
    if 1 <= S_two <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= S_two <= 12:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    vector<int> A(N+1);
    rep(i, N+1) cin >> A[i];
    vector<int> B(N);
    rep(i, N) cin >> B[i];
    ll ans = 0;
    rep(i, N) {
        int temp = min(A[i], B[i]);
        A[i] -= temp; B[i] -= temp;
        temp += min(A[i+1], B[i]);
        A[i+1] -= min(A[i+1], B[i]);
        ans += temp;
    }
    cout << ans << '\n';
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second 

ll gcd(ll a, ll b) 
{ 
    if (a == 0)  return b; 
    return gcd(b % a, a); 
} 

int main(){

	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);      
    #endif
    fastio;

    ll t; t=1;
    while(t--){
    	ll n; cin>>n;
        while(n>0){
            int x=n%10;
            if(x==7){
                cout<<"Yes";
                return 0;
            }
            n=n/10;
        }
        cout<<"No";
    }
    return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> V(N,-1);
  
  for(int i=0;i<M;i++){
    int s,c;
    cin >> s >> c;
    s--;
    if(V[s]==-1) V[s] = c;
    else if(V[s]!=c){
      cout << -1 << endl;
      return 0;
    }
  }
  
  if(N==1) cout << max(V[0],0) << endl;
  else{
    if(V[0]==0){
      cout << -1 << endl;
      return 0;
    }
    else cout << max(V[0],1);
    for(int i=1;i<N;i++) cout << max(V[i],0);
    cout << endl;
  }
  return 0;
}


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

using namespace std;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  printf("%d\n", b + min(c, a + b + 1));
  return 0;
}


Measured memory_bytes: 256
/********   In the name of Allah, the most gracious, the most merciful ********/
#include <bits/stdc++.h>

using namespace std;
typedef long long int lli;
#define inf 1e18L+7
#define sci(a) scanf("%d", &a)

void min_self(lli &a, lli b)
{
    a = min(a, b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, W;
    sci(n), sci(W);
    vector<int> v(n), w(n);
    int tot_v = 0;
    for (int i = 0; i < n; i++)
    {
        sci(w[i]), sci(v[i]);
        tot_v += v[i];
    }
    vector<lli> dp(tot_v + 1, inf);
    // dp[i] = minimum weight required to obtain value i
    dp[0] = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = tot_v; j >= v[i]; j--)
        {
            min_self(dp[j], dp[j - v[i]] + w[i]);
        }
    }
    int answer = 0;
    for (int i = 0; i <= tot_v; ++i)
    {
        if (dp[i] <= W)
        {
            answer = max(answer,i);
        }
    }
    printf("%d\n", answer);
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,b,h;
    char s[101];
    // 整数の入力
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &h);


    // 出力
    printf("%d\n",(a+b)*h/2);
    return 0;
}

Measured memory_bytes: 128
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 07/14/20 20:57:13
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  int ans = n*800 - (n/15)*200;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  string str;
  cin>>str;
  int n = str.size();
  str = "." + str;
  int check = 1;
  if(str[1] == '0' || str[n] == '1')
  {
    check = 0;
  }
  for (int i = 1; i < n; i++)
  {
    if(str[i] != str[n-i])
    {
      check = 0;
    }
  }
  if(!check)
  {
    cout<<-1<<endl;
    return;
  }
  str[n] = '1';
  queue<int> q;
  for (int i = 1; i <= n; i++)
  {
    if(str[i] =='1')
    {
      q.push(i);
    }
  }
  for (int i = 1; i < n; i++)
  {
    if(i == q.front())
    {
      q.pop();
    }
    cout<<i<<" "<<q.front()<<endl;
  }
  
  
  

  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 2284
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd, sqrt
from operator import mul
from functools import reduce
from operator import mul
from pprint import pprint



sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


def f(i, j, k):
    x1, y1 = L[i]
    x2, y2 = L[j]
    x3, y3 = L[k]
    # length of each side to the second power and area of the triangle
    a2 = (x2 - x3) ** 2 + (y2 - y3) ** 2
    b2 = (x1 - x3) ** 2 + (y1 - y3) ** 2
    c2 = (x2 - x1) ** 2 + (y2 - y1) ** 2
    area = ((x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1)) / 2

    # not on the same line please
    if area == 0:
        return INF
    x = (a2 * (b2 + c2 - a2) * x1 + b2 * (c2 + a2 - b2) * x2 + c2 * (a2 + b2 - c2) * x3) / (16 * area * area)
    y = (a2 * (b2 + c2 - a2) * y1 + b2 * (c2 + a2 - b2) * y2 + c2 * (a2 + b2 - c2) * y3) / (16 * area * area)
    r = sqrt((x1 - x) ** 2 + (y1 - y) ** 2)
    for d in range(n):
        if d in (i, j, k):
            continue
        ax, ay = L[d]
        if (ax - x) ** 2 + (ay - y) ** 2 > r ** 2:
            return INF
    return r



def diametercircle(ax, ay, bx, by):
    X = (ax + bx) / 2
    Y = (ay + by) / 2
    R = sqrt((X - ax) * (X - ax) + (Y - ay) * (Y - ay))
    return X, Y, R


def distance(ax, ay, bx, by):
    return sqrt((ax - bx) ** 2 + (ay - by) ** 2)

n = I()
L = []
for _ in range(n):
    x, y = LI()
    L += [(x, y)]

ans = INF
for i, j, k in combinations(range(n), 3):

    ans = min(ans, f(i, j, k))

for l, m in combinations(range(n), 2):
    lx, ly = L[l]
    mx, my = L[m]
    mid_x = (lx + mx) / 2
    mid_y = (ly + my) / 2
    r_s = (mid_x - lx) ** 2 + (mid_y - ly) ** 2
    for i in range(n):
        if i == l or i == m:
            continue
        zx, zy = L[i]
        if (zx - mid_x) ** 2 + (zy - mid_y) ** 2 > r_s:
            break
    else:
        ans = min(ans, sqrt(r_s))






print(ans)






Measured memory_bytes: 85480
#include <bits/stdc++.h>
/*#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <cstring>
#include <cmath>
#include <string>
#include <numeric>*/

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
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; }

int main()
{
  //input
  inputInt(N);
  string S;
  cin >> S;//添え字は0~N-1
  //int NS = S.length();
  //int NT = T.length();
  
  //main
  vector<vector<int>> memo(N+10, vector<int>(N+10, 0)); //Sを左からi(0~N)文字見た&j(0~N)文字見た時の共通部分列。
  
  /*for(int i=N; i>=0; i--){
    for(int j=N; j>=0; j--){
      if(i >= 1 && j >= 1) if(S[i-1]==S[j-1]) chmax(memo[i][j], memo[i+1][j+1]+1);
      //memo[i+1][j+1]を埋める→Sのi+1文字目・j文字目まで見る→S[i]
      chmax(memo[i][j],memo[i+1][j]);
      chmax(memo[i][j],memo[i][j+1]);
    }
  }*/
  int ans = 0;
  
  for(int i=0; i<N+1; i++){
    for(int j=0; j<N+1; j++){
      if(i<= N-1 && j <= N-1) if(S[i]==S[j]) chmax(memo[i+1][j+1], memo[i][j]+1);
      //memo[i+1][j+1]を埋める→Sのi+1文字目・j文字目まで見る→S[i]
      //chmax(memo[i+1][j],memo[i][j]);
      //chmax(memo[i][j+1],memo[i][j]);
      chmax(ans,min(memo[i+1][j+1],j-i));
    }
  }
  
  // output
  /*int ans = 0;
  
  fN(i,N+1){
    fN(j,N+1){
      ans = max(ans, min(memo[i][j],j-i));
    }
  }
  
  output(ans);*/
  
  /*fN(i,N+1){
    fN(j,N+1){
      cout<<memo[i][j]<<" ";
    }
    cout << endl;
  }
  cout << endl;*/
  cout << ans << endl;
  
  /*int ans = 0;
  
  fN(i,N+1){
    fN(j,N+1){
      ans = min(memo[i][j],j-i);
      cout << ans << " ";
    }
    cout << endl;
  }
  
  output(ans);*/
  
  /*
  int res = 0;
    vector<vector<int> > dp(N+1, vector<int>(N+1, 0));
    for (int i = N-1; i >= 0; --i) {
        for (int j = N-1; j > i; --j) {
            if (S[i] == S[j]) chmax(dp[i][j], dp[i+1][j+1] + 1);
            chmax(res, min(dp[i][j], j-i));
        }
    }
    cout << res << endl;
  */
  
  return 0;
}

Measured memory_bytes: 98432
#include<bits/stdc++.h>
#define N 100010
#define ll long long
using namespace std;
ll n;
ll A[N];

ll d[N];

ll tree[N * 10], size;
#define lowbit(x) (x) & (-x)
inline void Add(ll p)
{
	while(p <= size)
	{
		++ tree[p];
		p += lowbit(p);
	}
}
inline ll Query(ll p)
{
	ll Ans = 0;
	while(p > 0)
	{
		Ans += tree[p];
		p -= lowbit(p);
	}
	return Ans;
}

inline bool check(ll k)
{
	for(ll i = 1; i <= n; ++ i)
		d[i] = (A[i] >= k) ? 1 : -1;
	for(ll i = 1; i <= n; ++ i)
		d[i] += d[i - 1];
	memset(tree, 0, sizeof(tree));
	size = 2 * N;
	ll Ans = 0;
	for(ll i = 0; i <= n; ++ i)
	{
		Ans += Query(d[i] + N);
		Add(d[i] + N);
	}
	return Ans >= n * (n + 1) / 4;
}
ll L = 0, R = 0;
int main()
{
	scanf("%lld", &n);
	for(ll i = 1; i <= n; ++ i)
		scanf("%lld", &A[i]), R = max(R, A[i]);
	while(L <= R)
	{
		ll mid = (L + R) >> 1;
		if(check(mid))
			L = mid + 1;
		else R = mid - 1;
	}
	printf("%lld", R);
	return 0;
}

Measured memory_bytes: 9600
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

int dp[3010][3010];
int main() {
    string S, T; cin >> S >> T;
    int slen = S.size(), tlen = T.size();

    // 縦S 横Tで初期化
    for(int i=0; i<=S.size(); i++){
        dp[i][0]=0;
    }

    for(int i=0; i<=T.size(); i++){
        dp[0][i]=0;
    }

    for(int i=1; i<=slen; i++){
        for(int j=1; j<=tlen; j++){
            if(S[i-1]==T[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    int len=dp[slen][tlen];
    int i=slen;
    int j=tlen;
    string ans;
    while(len>0){
        if(S[i-1]==T[j-1]){
            ans.push_back(S[i-1]);
            i--;
            j--;
            len--;
        }else if(dp[i][j]==dp[i-1][j]){
            i--;
        }else{
            j--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35584