akhauriyash/Code-Regression huggingface dataset:
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/


int main(){
ld a,b,x;
cin>>a>>b>>x;
ld ans;
if(x/pow(a,2)>=b/2){
ans=atan(2*(b-x/pow(a,2))/a);
}
else{
    ans=atan(a*pow(b,2)/(2*x));
}
cout(10)<<ans*180/M_PI<<endl;
return 0;
}

Measured memory_bytes: 3792
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N = I()
s = set()
for i in range(N):
    s.add(I())

print(len(s))


Measured memory_bytes: 61596
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, std::vector<std::string> s, std::vector<long long> t, std::string x){
    int tk = distance(s.begin(), find(s.begin(), s.end(), x));
    i64 ans = 0;
    for(int i = tk + 1; i < n; ++i){
        ans += t[i];
    }
    cout << ans << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> s(N);
    std::vector<long long> t(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> s[i];
        scanf("%lld",&t[i]);
    }
    std::string X;
    std::cin >> X;
    solve(N, std::move(s), std::move(t), X);
    return 0;
}


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

using namespace std;

int main(){
    int n; cin >> n;
    int cnt=0;
    int max_cnt=0;
    int result=1;

    for(int i=2; i<=n; i++){
        int a = i;
        cnt = 0;
        while(1){
            if(a % 2 == 1){
                if(cnt > max_cnt){
                    max_cnt = cnt;
                    result = i;
                }
                break;
            }else{
                a /= 2;
                cnt++;
            }
        }
    }

    cout << result << endl;

    return  0;
}

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

using pll = pair<long long,long long>;

int main(void){
	int N;cin >> N;
	vector<pll> pos(N);
	for(int i=0;i<N;i++)cin >> pos[i].first >> pos[i].second;
	
	int par = (abs(pos[0].first)+abs(pos[0].second))%2;
	for(int i=0;i<N;i++){
		int par2 = (abs(pos[i].first)+abs(pos[i].second))%2;
		pos[i] = pll(pos[i].first + pos[i].second,pos[i].first - pos[i].second);
		if(par2 != par){
			cout << -1 << endl;
			return 0;
		}
	}
	
	vector<long long> d;
	for(int i=30;i>=0;i--)d.push_back(1LL<<i);
	if(par %2 == 0 ) d.push_back(1);
	cout << d.size() << endl;
	for(int j = 0; j < d.size(); j++){
		if(j!=0)cout <<" ";
		cout << d[j];
	}
	cout << endl;
	
	for(int i=0;i<N;i++){
		int xdir,ydir;
		long long xsum = 0, ysum = 0;
		for(int j=0;j<(int)d.size();j++){
			if(xsum<=pos[i].first) xdir = 1,xsum += d[j];
			else xdir = -1,xsum -=d[j];
			if(ysum<=pos[i].second) ydir = 1, ysum +=d[j];
			else ydir = -1,ysum -=d[j];
			
			if(xdir == 1     && ydir == 1)cout <<"R";
			else if(xdir ==1 && ydir ==-1)cout <<"U";
			else if(xdir ==-1&& ydir ==-1)cout <<"L";
			else cout <<"D";
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

struct node{
    int key;
    int parent, left, right;
    node(){ parent=-1; left=-1; right=-1; }
};

vector<node> tree;
int root=-1;

void print_pre(int id)
{
    if(id==-1){ return; }
    printf(" %d", tree[id].key);
    print_pre(tree[id].left);
    print_pre(tree[id].right);
}

void print_in(int id)
{
    if(id==-1){ return; }
    print_in(tree[id].left);
    printf(" %d", tree[id].key);
    print_in(tree[id].right);
}

void insert(int z)
{
    int y=-1;
    int x=root;
    while(x!=-1){
        y=x;
        if(tree[z].key<tree[x].key){
            x=tree[x].left;
        } else{
            x=tree[x].right;
        }
    }
    tree[z].parent=y;
    if(y==-1){
        root=z;
    } else if(tree[z].key<tree[y].key){
        tree[y].left=z;
    } else{
        tree[y].right=z;
    }
}

int main()
{
    int m;
    scanf("%d", &m);
    tree=vector<node>(m);
    int n=0;
    for(int i=0; i<m; i++){
        char buf[8]; scanf("%s", buf);
        if(*buf=='i'){
            int k; scanf("%d", &k);
            tree[n].key=k;
            insert(n);
            n++;
        } else{
            print_in(root);
            printf("\n");
            print_pre(root);
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 9932
#include<bits/stdc++.h>
#include<atcoder/dsu>
#define REP(i,b,e) for(int i=b; i<e; i++)

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    atcoder::dsu uf(n);
    REP(i, 0, m){
        int a, b;
        scanf("%d %d", &a, &b);
        uf.merge(a-1, b-1);
    }

    int cnt = 0;
    REP(i, 0, n){
        if(uf.leader(i)==i) cnt++;
    }
    printf("%d\n", cnt-1);
    return 0;
}


Measured memory_bytes: 3796
//線形探索やら範囲探索？やらすると、計算量が半端ない。正解の解の数自体が多すぎるので、限定もしづらい。
//N回目に符号をつける数は、どのパターンでも一緒であるので、
//N-1回目までに演算して出てきた値が同じのものは、N回目の演算における結果が一致する。
//結果のバリエーションが少なく、結果が同じものはその前に依存せず、次の結果も同じになる。
//よって、結果によって処理をまとめておこなう、動的計画法とやらが使えそう。
#include<stdio.h>

int main(){
	FILE *fp1,*fp2;
	int num;
	int i,j,d,ans;
	long long data[99][21] = {0};	//data[i][j]には、i回目の演算でjという値がでる場合の数を保存.
													
	//fp1 = fopen("input.txt","r");
	//fp2 = fopen("output.txt","w");
	fscanf(stdin,"%d",&num);
	fscanf(stdin,"%d",&d);		//最初の数字は0以上20以下である。
	data[0][d] = 1;
	for(i = 1;i < num-1;i++){
		fscanf(stdin,"%d",&d);
		for(j = 0;j < 21;j++){
			if(j+d <= 20)
				data[i][j+d] += data[i-1][j];
			if(j-d >= 0)
				data[i][j-d] += data[i-1][j];
		}
	}
	fscanf(stdin,"%d",&ans);
	fprintf(stdout,"%lld\n",data[num-2][ans]);
	//fclose(fp1);
	//fclose(fp2);
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 105;
int n, m, k, ans;
int a[N];

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n, greater<int>());
    for (int i = 0; i < n; ++i) {
        if (i & 1)
            k += a[i];
        else
            m += a[i];
    }
    cout << m - k << endl;
    return 0;
}


Measured memory_bytes: 3620
n, m = map(int, input().split())
a = [[int(i) for i in input().split()] for i in range(m)]
city = [0 for i in range(n)]
for i in range(m):
    city[a[i][0]-1] += 1
    city[a[i][1]-1] += 1
for i in range(n):
    print(city[i])


Measured memory_bytes: 38384
#include<iostream>
using namespace std;
int main(){
    int r,c,A[101][101];cin>>r>>c;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            cin>>A[i][j];
        }
    }
    for(int i=0;i<=r;i++) A[i][c]=0;
    for(int j=0;j<=c;j++) A[r][j]=0;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            A[i][c]+=A[i][j];
            A[r][j]+=A[i][j];
            A[r][c]+=A[i][j];
        }
    }
    for(int i=0;i<=r;i++){
        for(int j=0;j<=c;j++){
            if(j>0){
                cout<<" ";
                cout<<A[i][j];
            }
            else{
                cout<<A[i][j];
            }
        }cout<<endl;
    }return 0;
}


Measured memory_bytes: 3108
N=int(input())
L=[]
for i in range(N):
    L.append(input())
S=set(L)
if len(S)<len(L):
    print('No')
else:
    p=0
    for i in range(N-1):
        a=L[i]
        A=a[-1:]
        b=L[i+1]
        B=b[:1]
        if A!=B:
            print('No')
            break
        else:
            p+=1
    if p==N-1:
        print('Yes')

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

int main(){
  int n,m,i,x,y,cant=0;
  cin>>n>>m;
  int a[n];
  for(i=0;i<n;i++){
    a[i]=-1;
  }
  for(i=0;i<m;i++){
    cin>>x>>y;
    if(a[x-1]==-1||a[x-1]==y){
      a[x-1]=y;
      if(a[0]==0&&n>=2){
        cant=1;
      }
    }else{
      cant=1;
    }
  }
  if(cant){
    cout<<-1;
    return 0;
  }
  for(i=0;i<n;i++){
    if(a[i]==-1&&i>=1){
      a[i]=0;
    }else if(a[i]==-1&&i==0&&n>=2){
      a[i]=1;
    }else if(a[i]==-1&&i==0&&n==1){
      a[i]=0;
    }
    cout<<a[i];
  } 
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()?.toInt() ?: return
    val memo = hashMapOf<Int, Boolean>()
    memo[s] = true
    var f = s
    var count = 1
    while (true) {
        count++
        if (f % 2 == 0) {
            f /= 2
        } else {
            f = 3 * f + 1
        }
        if (memo.containsKey(f)) {
            println(count.toString())
            return
        }
        memo[f] = true
    }
}

Measured memory_bytes: 31984
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

/*
p????q
q??p
という組
1~9について、先頭がi,末尾がjである数字の個数をc[i][j]で表す

i!=jの場合、計上する場合の数は？
例：i=1, j=2
12, 102, 112, 21, 201, 211
単純な掛け算.

i==jのときは？
同じ数どうしを重複して数え上げるため、単純な掛け算という訳には行かない
例：1,11,101,111,121
このときの場合の数は5C2

*/

int first(int x){
    return (to_string(x).front()) - '0';
}
int last(int x){
    return (to_string(x).back()) - '0';
}

int c[12][12];

void solve(){
    int n;
    cin >> n;
    rep(i,12){
        rep(j,12){
            c[i][j]=0;
        }
    }

    for(int i=1; i<=n; i++){
        c[first(i)][last(i)]++;
    }

    ll ans = 0;

    rep(i,10){
        rep(j,10){
            if(i!=j){
                ans += c[i][j]*c[j][i];
                //cout << "先頭が" << i << ", 末尾が" << j << ", 足す数は" << c[i][j]*c[j][i] << endl;
            }
            else{
                ans += c[i][j]*(c[i][j]-1)+c[i][j];
                //cout << "先頭が" << i << ", 末尾が" << j << ", 足す数は" << c[i][j]*(c[i][j]-1)/2+c[i][j] << endl;
            }
        }
    }

   

    cout << ans << endl;

}

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


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

using namespace std;

vector<int> furui(10001, 0);

int main () {
	furui[0] = furui[1] = 1;
	for (int i = 2; i*i <= 10001; i++) {
		if (furui[i] == 0) {
			for (int j = 2; j <= 10000/i; j++) {
				furui[i*j] = 1;
			}
		}
	}
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		for (int i = n; i > 0; i--) {
			if (furui[i] == 0 && furui[i-2] == 0) {
				cout << i-2 << " " << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<string>
#include<cstdlib>


using namespace std;

int main() {

  int n;
  int x, y, t;
  string result = "Yes";

  cin >> n;
  x = 0;
  y = 0;
  t = 0;

  for (int i = 0; i < n; i++) {
    int nx, ny, nt;

    cin >> nt >> nx >> ny;
    int dist = abs(nx - x) + abs(ny -y);

    if (dist > (nt - t)) {
      result = "No";
      break;
    }

    if (abs(dist - (nt - t))%2 != 0) {
      result = "No";
      break;
    }

    x = nx;
    y = ny;
    t = nt;
  }

  cout << result << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	int N, K; cin >> N >> K;
	int x[101];
	int sum = 0;
	rep(i, 0, N) {
		cin >> x[i];
		sum += (x[i] < K - x[i]) ? x[i] * 2 : (K - x[i]) * 2;
	}

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

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

void main() {
    size_t n;
    string s1, s2;
    readf("%d\n%s\n%s\n", &n, &s1, &s2);
    auto a1 = s1.split.map!(to!int).array;
    auto a2 = s2.split.map!(to!int).array;
    foreach (i; 1..n) {
        a1[i] += a1[i-1];
        a2[n-i-1] += a2[n-i];
    }
    // a1[] += a2[];
    foreach (i; 0..n) {
        a1[i] += a2[i];
    }
    sort(a1);
    writeln(a1[n-1]);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n];
    long[] b = new long[n];
    long[] c = new long[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
      b[i] = sc.nextLong();
      c[i] = sc.nextLong();
    }
    long[][] dp = new long[n][3];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(int i = 1; i < n; i++) {
      dp[i][0] = Math.max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
      dp[i][1] = Math.max(dp[i - 1][0] + b[i], dp[i - 1][2] + b[i]);
      dp[i][2] = Math.max(dp[i - 1][0] + c[i], dp[i - 1][1] + c[i]);
    }
    long ans = Math.max(dp[n - 1][0], dp[n - 1][1]);
    ans = Math.max(ans, dp[n - 1][2]);
    System.out.println(ans);
  }
}

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

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

  int a, b, x;
  cin >> a >> b >> x;

  if (a > x) cout << "NO\n";
  else if (a + b >= x) cout << "YES\n";
  else cout << "NO\n";

  return (0);
}


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

signed main(){

  int n;
  cin>>n;

  vector<vector<int>> a;

  int k;
  cin>>k;
  vector<int> t(k);
  for(auto& ti:t)cin>>ti;

  for(int b=0;b<(1<<k);++b){
    bitset<20> tbit(b);
    bitset<30> bit;
    vector<int> ai(1);
    for(int i=0;i<k;++i)if(tbit[i]){
      bit.set(t[i]);
      ai.emplace_back(t[i]);
    }
    ai[0] = bit.to_ulong();
    a.emplace_back(ai);
  }
  sort(a.begin(),a.end(),[](auto& a,auto& b){return a[0]<b[0];});

  for(auto v:a){
    cout<<v[0]<<":";
    for(int i=1;i<v.size();++i){
      cout<<" "<<v[i];
    }
    cout<<endl;
  }

}


Measured memory_bytes: 22612
#include <iostream>

using namespace std;

int main()
{
    int n ;
    cin >> n ;
    string s ;
    cin >> s;
    string ans ;
    int c = 0;
    for(int i =0 ; i<n ;i++){
        if(s[i]=='(')c++;
        else c--;
        if(c<0)ans = '('+ans ,c++;
        ans+=s[i];
    }
    while(c--)ans+=')';
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
def solve():
    res = float('inf')
    for i in range(n):
        r_top = coordinates[i][1]
        for j in range(n):
            r_bottom = coordinates[j][1]
            if r_bottom < r_top:
                continue
            for k in range(n):
                c_left = coordinates[k][0]
                for l in range(n):
                    c_right = coordinates[l][0]
                    if c_right < c_left:
                        continue
                    cnt = 0
                    for c, r in coordinates:
                        # print(r_top, r, r_bottom, c_left, c, c_right)
                        if (r_top <= r <= r_bottom) and (c_left <= c <= c_right):
                            cnt += 1
                            if cnt >= need:
                                res = min(res, (r_bottom - r_top) * (c_right - c_left))
                                break

    return res


n, need = map(int, input().split())
coordinates = tuple(sorted(tuple(map(int, input().split())) for _ in range(n)))
# x,y昇順

# print(coordinates)

print(solve())


Measured memory_bytes: 44380
#include <iostream>
#include <bits/stdc++.h>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF 1000000000
#define MOD 1000000007
#define M 998244353
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ll long long
#define endl "\n"
#define fori(i, a, b) for(i=a; i<b; i++)
#define ford(i, a, b) for(i=a; i>b; i--)
using namespace std;
const ll N = 500043;
ll fact[N];
ll add(ll x, ll y)
{
	x += y;
	while(x >= MOD) x -= MOD;
	while(x < 0) x += MOD;
	return x;
}
ll mul(ll x, ll y)
{
	return (x * 1ll * y) % MOD;
}
ll mulmod(ll a, ll b)
{
    ll res = 0;
    a = a % MOD;
    while (b>0)
    {
        if (b % 2 == 1)
            res = (res + a) % MOD;
        a = (a * 2) % MOD;
        b /= 2;
    }
    return res % MOD; 
}
ll binpow(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = mul(z, x);
		x = mul(x, x);
		y /= 2;
	}
	return z;
}
ll inv(ll x)
{
	return binpow(x, MOD - 2);
}
ll divide(ll x, ll y)
{
	return mul(x, inv(y));
}
void precalc()
{
	fact[0] = 1;
	ll i;
	fori(i, 1, N)
		fact[i] = mul(i, fact[i - 1]);
}
ll C(ll n, ll k)
{
	if(k > n)
	    return 0;
	return divide(fact[n], mul(fact[n-k], fact[k]));
}
ll arr[10];
ll prod()
{
    ll v=1, i;
    fori(i, 0, 10)
        v*=arr[i];
    return v;
}

ll solve()
{
    ll n, i;
    cin >> n;
    ll a[n];
    fori(i, 0, n)
        cin >> a[i];
    sort(a, a+n);
    ll p=1;
    p*=a[0];
    if(p==0)
        return 0;
    ford(i, n-1, 0)
    {
        if(a[i] <= 1000000000000000000/p)
            p*=a[i];
        else
            return -1;
    }
    if(p>1000000000000000000LL)
            return -1;
    return p;
}
signed main()
{
    io
    int t;
    t=1;
    // cin >> t;
    while(t--)
        cout << solve() << endl;
        // solve();
    return 0;
}

Measured memory_bytes: 4392
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;


bool solve(){
	string a = "yuiophjklnm";	// b = "qwertyasdfgzxcvb";
	int asize = a.size();
	
	while(1){
		string str;
		cin>> str;
		if(str == "#") break;
		
		int ans = 0;
		int rl_pre = 0;
		for(int j=0;j<asize;j++){
			if(str[0] == a[j]){
				rl_pre = 1;
				break;
			}
		}
		for(int i=1;i<str.size();i++){
			int rl_crr = 0;
			for(int j=0;j<asize;j++){
				if(str[i] == a[j]){
					rl_crr++;
					break;
				}
			}
			if(rl_pre != rl_crr){
				rl_pre = rl_crr;
				ans++;
			}
		}
		cout<< ans<< endl;
	}
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

 

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

using namespace std;
typedef pair<double, double> P;

int main() {
  int n;
  cin >> n;
  vector<P> xy(n);
  for (int i = 0; i < n; ++i) {
    double x, y;
    cin >> x >> y;
    xy[i] = P(x, y);
  }

  vector<int> a(n);
  iota(a.begin(), a.end(), 0);
  double average = 0;
  int cnt = 0;
  do {
    cnt++;
    for (int i = 0; i < n - 1; ++i) {
      average += sqrt(pow((xy[a[i]].first - xy[a[i + 1]].first), 2) + pow((xy[a[i]].second - xy[a[i + 1]].second), 2));
    }
  } while(next_permutation(a.begin(), a.end()));
  double ans = average / cnt;
  printf("%.10f\n", ans);
  return 0;
}



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

int n;
string v[10];
map<string,string> memo[1024];

string merge(string a,string b){
	if(~a.find(b)) return a;
	for(int i = 0 ; i < a.size() ; i++){
		bool f = true;
		for(int j = 0 ; i+j < a.size() ; j++){
			if( a[i+j] != b[j] ){ f = false; break; }
		}
		if(f) return a.substr(0,i) + b;
	}
	return a+b;
}

int main(){
	//cout << merge("abc","aab") << endl;
	while(cin >> n && n){
		for(int i = 0 ; i < 1024 ; i++) memo[i].clear();
		for(int i = 0 ; i < n ; i++) cin >> v[i];
		sort(v,v+n);
		for(int i = 0 ; i < n ; i++){
			memo[1<<i][v[i]] = v[i];
		}
		for(int bit = 0 ; bit < (1<<n) ; bit++){
			for( map<string,string>::iterator it = memo[bit].begin() ; it != memo[bit].end() ; ++it){
				string s = it->second;
				for(int i = 0 ; i < n ; i++){
					if(!(bit>>i&1)){
						string m = merge(s,v[i]);
						string sub = m.substr(max(0,(int)m.size()-10));
						string& ans = memo[bit|(1<<i)][sub];
						
						if(ans == "" || ans.length() > m.length() || (ans.length() == m.length() && m < ans))
							ans = m;
					}
				}
			}
		}
		string ans = "";
		for( map<string,string>::iterator it = memo[(1<<n)-1].begin() ; it != memo[(1<<n)-1].end() ; ++it){
			string m = it->second;
			if(ans == "" || ans.length() > m.length() || (ans.length() == m.length() && m < ans))
				ans = m;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 7884
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
int main(){
  ll a,b=0,c=0;cin>>a;
  while(b<a){
    b+=c;
    c++;
    }
  b=b-a;
  rep(i,c-1){
    if(i+1==b)continue;
    cout<<i+1<<endl;
  }
}



Measured memory_bytes: 27024
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

// n 個の玉を区別する
// k 個の箱を区別しない
// 入れ方は 1 個以上
// スターリング数
// S(n, k) = S(n - 1, k - 1) + k * S(n - 1, k)
// Σ(-1)^(k - i) * kCi * i^n / (k!) より O(klogn) に減らせる
vector<vector<ll>> S(1010, vector<ll>(1010, 0));
void stir_init(){
    S[0][0] = 1;
    for(int n=1; n<1010; n++){
        for(int k=1; k<1010; k++){
            S[n][k] = S[n - 1][k - 1] + k * S[n - 1][k];
            S[n][k] %= MOD;
        }
    }
}

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

    int n, k; cin>>n>>k;

    stir_init();

    cout << S[n][k] << endl;

    return 0;
}


Measured memory_bytes: 11236
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)


#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

typedef long long ll;

const ll INF = 1e9+7;

using namespace std;

int main(){
  
  int N,A,B;
  cin>>N>>A>>B;
  int ans = min(A*N,B);
  print(ans)
  
  
  return 0;
}


Measured memory_bytes: 256
import numpy as np
row = [input().split() for i in range(3)]
f = np.vectorize(int)
c = f(row)

if c[1][0] - c[2][0] == c[1][1] - c[2][1] == c[1][2] - c[2][2] and c[1][0] - c[0][0] == c[1][1] - c[0][1] == c[1][2] - c[0][2] and c[0][0] - c[2][0] == c[0][1] - c[2][1] == c[0][2] - c[2][2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14452
def LI(): return list(map(int,input().split()))
N,D = LI()
X = [LI() for _ in range(N)]
ans = 0
for i in range(N):
    for j in range(i+1,N):
        temp = 0
        for k in range(D):
            temp += (X[j][k]-X[i][k])**2
        if temp **0.5%1==0:
            ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (typeof((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(typeof(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}



typedef pair<int,int> parsed;

parsed equation(string str, int p = 0);
parsed factor(string str, int p = 0);
parsed term(string str, int p = 0);

bool overflow = false;

int conv(string str) {
    int res = 0;
    for (int i = 0; i < str.size(); ++i) {
        res = res * 10 + (str[i] - '0');
    }
    return res;
}

parsed equation(string str, int p) {
    parsed res = factor(str, p);
    while (str[res.second] == '+' || str[res.second] == '-') {
        parsed temp = factor(str, res.second+1);
        if (str[res.second] == '+') res.first = res.first + temp.first;
        else if (str[res.second] == '-') res.first = res.first - temp.first;
        res.second = temp.second;
    }
    return res;
}

parsed factor(string str, int p) {
    parsed res = term(str, p);
    while (str[res.second] == '*' || str[res.second] == '/') {
        parsed temp = term(str, res.second+1);    
        if (str[res.second] == '*') res.first = res.first * temp.first;
        else if (str[res.second] == '/') res.first = res.first / temp.first;
        res.second = temp.second;
    }
    return res;
}

parsed term(string str, int p) {
    if (str[p] == '(') {
        parsed res = equation(str, p+1);
        res.second += 1;
        return res;
    }
    else {
        string snum = "";
        if (p < str.size()) {
            while (isdigit(str[p]) || str[p] == 'i') {
                snum += str[p++];
            }
        }
        int num = conv(snum);
        return parsed(num, p);
    }
}


int main() {
    //freopen( "/Users/macuser/Documents/Programming/Contest/input.in", "r", stdin );
    
    int n;
    cin >> n;
    string str;
    for (int i = 0; i < n; ++i) {
        cin >> str;
        cout << equation(str).FI << endl;
    }
    
    return 0;
}


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

int main() {
	
	string s; cin >> s;
	int n = s.size()-1;
	if (s[n]=='2'||s[n]=='4'||s[n]=='5'||s[n]=='7'||s[n]=='9') {
		printf("hon\n");
	} else if (s[n]=='0'||s[n]=='1'||s[n]=='6'||s[n]=='8') {
		printf("pon");
	} else {
		printf("bon");
	}
	
	return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;



int main(){
    //input    
    int A,B,T;
    cin >> A >> B >> T;
    int ans;
    ans = (T / A)*B;
    cout << ans << endl;
    

    return 0;
}

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

using namespace std;

struct Dice
{
  int x, y;
  int l, r, f, b, d, u;

  void RollF()
  {
    --y;
    int buff = d;
    d = f;
    f = u;
    u = b;
    b = buff;
  }

  void RollB()
  {
    ++y;
    int buff = d;
    d = b;
    b = u;
    u = f;
    f = buff;
  }

  void RollL()
  {
    --x;
    int buff = d;
    d = l;
    l = u;
    u = r;
    r = buff;
  }

  void RollR()
  {
    ++x;
    int buff = d;
    d = r;
    r = u;
    u = l;
    l = buff;
  }
};


int main()
{
  auto input = []()
  {
    Dice dice;
    cin >> dice.u;
    cin >> dice.f;
    cin >> dice.l;
    cin >> dice.r;
    cin >> dice.b;
    cin >> dice.d;
    return (dice);
  };


  Dice d1 = input();
  Dice d2 = input();

  for(int i = 0; i < 4; i++) {
    d1.RollL();
    for(int j = 0; j < 4; j++) {
      d1.RollB();
      for(int k = 0; k < 4; k++) {
        d1.RollL();
        if(d1.u == d2.u && d1.f == d2.f && d1.l == d2.l && d1.r == d2.r && d1.b == d2.b && d1.d == d2.d) {
          cout << "Yes" << endl;
          return (0);
        }
      }
    }
  }

  cout << "No" << endl;
}

Measured memory_bytes: 3064
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1000000007;

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

  string res;
  cout << 0 << endl;
  cin >> res;

  string z;
  if (res == "Vacant") return 0;
  z = res;

  cout << n - 1 << endl;
  cin >> res;
  if (res == "Vacant") return 0;

  ll lp = 0;
  ll rp = n - 1;
  while (true) {
    ll mid = (lp + rp) / 2;
    cout << mid << endl;
    cin >> res;
    if (res == "Vacant") break;

    if (res == z) {
      if (mid % 2 == 0)
        lp = mid;
      else
        rp = mid;
    } else {
      if (mid % 2 == 1)
        lp = mid;
      else
        rp = mid;
    }
  }

  return 0;
}


Measured memory_bytes: 852
import java.util.*;

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

        int total = K * 500;

        if (total >= X)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 35892
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long lint;
typedef complex<double> point;

template<typename Key, typename Value>
using hash_map = cc_hash_table<Key, Value>;
template<typename T, typename Cmp = less<T>>
using oset = tree<T, null_type, Cmp, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 0x3f3f3f3f;
const lint INFL = 0x3f3f3f3f3f3f3f3fLL;
const double E = 1e-9, pi = 2 * acos(0);

template<typename T, typename U> void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> void amax(T &x, U y) { if (x < y) x = y; }

const int N = 100'000, SQRT = 300;

vector<vector<int>> graph;
vector<int> color;

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

bool solve(int testNumber) {
	int n, m;
	if (!(cin >> n >> m)) {
		return false;
	}
	graph.assign(n, {});
	color.assign(n, -1);
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		graph[u].push_back(v);
		graph[v].push_back(u);
	}
	bool bipartite = dfs(0, 0);
	lint ans;
	if (!bipartite) {
		ans = (lint)n * (n - 1) / 2 - m;
	} else {
		int c0 = count(color.begin(), color.end(), 0), c1 = n - c0;
		ans = (lint)c0 * c1 - m;
	}
	printf("%lld\n", ans);
	return true;
}

void init(const char *in = nullptr, const char *out = nullptr) {
	if (in) freopen(in, "r", stdin);
	if (out) freopen(out, "w", stdout);
}

int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(nullptr);
	init();
	for (int i=1; solve(i); i++);
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
 
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            
            return false;
        }
    }
 
    return true;
}
signed main() {
	int x;
	cin >> x;
    int y;
	for (int i = x; i < 10 ^ 8; i++) {
        if (IsPrime(i)) {
            y = i;
            break;
       }
	}
    cout << y << endl;
}

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

int main() {
  int N;
  cin >> N;
  int ans;
  ans = 100;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    int k;
    k = 0;
    while (A%2==0) {
      k++;
      A /= 2;
    }
    if (k < ans) {
      ans = k;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
Q = int(input())
import numpy as np

n = 10 ** 5
doubel_primes = np.zeros(n+1, dtype=int)
primes_flags = np.zeros(n+1, dtype=bool)
primes_flags[1] = True # Trueはprimeでない.
primes_flags[0] = True # Trueはprimeでない.
#primes_flags[2] = True # Trueはprimeでない.
primes_flags[::2] = True # Trueはprimeでない.
if Q >= 1:
    primes_flags[2] = False
def prime_check(n=100000):
    i = 3
    while i  < n:
        if not primes_flags[i]:
            if not primes_flags[i//2 + 1]:
                doubel_primes[i] = 1
            k = i * i
            while k <= n:
                primes_flags[k] = True
                k += i
        i += 2
        
prime_check(n)
prime_sum = doubel_primes.cumsum()
for _ in range(Q):
    l, r = list(map(int, input().split()))
    print(prime_sum[r] - prime_sum[l-1])



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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

long long Pow(long long a ,long long m) {
	long long res = 1;
	res = (a * a) % m;
	return res;
}
int main() {
	long long n, x, m;
	cin >> n >> x >> m;
	vector<long long> v;
	v.push_back(x);
	long long start = 0;
	bool hasZ = false;
	for (int i = 1; i < n; i++) {
		long long temp = Pow(v[i - 1], m);
		if (find(v.begin(), v.end(), temp) != v.end()) {
			start = find(v.begin(), v.end(), temp) - v.begin();
			break;
		}
		if (!temp) hasZ = true;
		v.push_back(temp);
	}
	if (hasZ) {
		cout << accumulate(v.begin(), v.end(), 0ll) << "\n";
		return 0;
	}
	long long sumBefore = accumulate(v.begin(), v.begin() + start, 0ll);
	long long sumCycle = accumulate(v.begin() + start, v.end(), 0ll);
	long long res = sumBefore;
	res += (sumCycle * ((n - start) / ((int) v.size() - start)));
	long long rest = n - start - (((int) v.size() - start) * ((n - start) / ((int) v.size() - start)));
	while (rest--) {
		res += v[start];
		start++;
	}
	cout << res << "\n";
	return 0;
}


Measured memory_bytes: 3928
require 'pp'
# これだと

N,d=gets.chomp.split(' ').map{|n| n.to_i}
S=Array.new(N)

if(N==3)
	puts "2 5 63"
	exit(0)
elsif(N==4)
	puts "2 5 20 63"
	exit(0)
end

int = [2,3,4,6]
iter = 0
base = 0
0.upto(N-1){|i|
	S[i] = base+int[iter]
	iter += 1
	base += 6 * (iter / 4)
	iter %= 4
}
sum = S.inject(0){|sum,a| sum+a}
case sum % 6
	when 2
		S[4] = base+6
	when 3
		S[5] = base+6
	when 5
		# 30000をこえてはいけないためこの組み合わせを選択
		# ただしペアとなる+2がない場合(N==5の場合)はS[4]=次の6の倍数+3とする
		if(N==5)
			S[4] = base+6+3
		else
			S[5] = base+4
		end
end
# puts sum
# puts S.inject(0){|sum,a| sum+a}
puts S.join(" ")




Measured memory_bytes: 4220
X, N = map(int,input().split())
p = list(map(int,input().split()))

a = X
b = X
if X not in p:
    print(X)
    exit()
for i in range(1000):
    a -= 1
    b += 1
    if a not in p:
        print(a)
        break
    elif b not in p:
        print(b)
        break


Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define x first
#define y second
#define PII pair < int , int >
#define PLL pair < ll , ll >
#define mod 1000000007
#define maxn 100100

using namespace std;

ll n, a[300100], k, mx;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    sort(a+1, a+n+1);
    for (int i = n; k--; i--) mx += a[i];
    cout << mx;
}

Measured memory_bytes: 256
#include <stdio.h>

int compare_int(const void *a, const void *b)
{return *(int*)a - *(int*)b;}

int main()
{
  int x[10];
  int i, j;
  int tmp;

  for(i=0; i<10; i++)
    scanf("%d", &x[i]);

  qsort(x, 10, sizeof(int), compare_int);

  for(i=0; i<3; i++)
    printf("%d\n", x[9-i]);

  return 0;
}

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

using namespace std;

int main()
{
    long long N;
    cin >> N;
    long long luces[N], i;
    for(i=0; i<N; i++)
    {
        cin >> luces[i];
    }
    long long aux=1, contador=1;
    while((luces[aux-1]!=2)&&(contador<N+3))
    {
        contador++;
        aux=luces[aux-1];
    }
    if (contador>N+1)
    {
        cout << -1 << endl;
        return 0;
    }
    else
    {
            cout << contador << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int v[4][2] = {
        {0, 1},
        {1, 0},
        {-1, 0},
        {0, -1},
};

int main(){
    int h, w;
    cin >> h >> w;
    char a[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }

    int count = h*w;
    vector<pair<int, int> > s1;
    s1.reserve(h*w);
    vector<pair<int, int> > s2;
    s2.reserve(h*w);
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(a[i][j] == '#'){
                s1.push_back(make_pair(i, j));
                count--;
            }
        }
    }

    int c = 0;
    while(count > 0){
        while(!s1.empty()) {
            auto p = s1.back();
//        for(int i = 0; i < s1.size(); i++){
//            cerr << s1[i].first << " " << s1[i].second << endl;
//        }
//        cerr << endl;
            s1.pop_back();
            for(auto &i : v) {
                if(p.first+ i[0] < 0 || h <= p.first+ i[0] || p.second+ i[1] < 0 || w <= p.second+ i[1]){
                    continue;
                }
//                cerr << p.first + first+ i[0] << " " << p.second + i[1] << endl;
                if(a[p.first + i[0]][p.second + i[1]] == '.') {
                    a[p.first + i[0]][p.second + i[1]] = '#';
                    count--;
                    s2.push_back(make_pair(p.first + i[0], p.second + i[1]));
                }
            }
        }
        // for(int i = 0; i < h; i++) {
        //     for(int j = 0; j < w; j++) {
        //         cerr << a[i][j] << " ";
        //     }
        //     cerr << endl;
        // }
        s1.clear();
        copy(s2.begin(), s2.end(), back_inserter(s1));
        s2.clear();
        c++;
    }
    cout << c << endl;

    return 0;
}


Measured memory_bytes: 11904
/**
 *      ///----- My Info -----///
 *      Code by: Ernesto Abreu
 *      Codeforces User: Ernest0_0Abreu
 *      Country: Cuba
 *      E-mail: ernestoabreup@gmail.com
 *      CopyRight
**/
#include <bits/stdc++.h>
#ifdef Ernest0_0Abreu
#include <debug/to_string.h>
#endif
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
    	///----- My Template -----///
///======================================================================================================================================
/// Red-Black Tree
// #include <ext/pb_ds/assoc_container.hpp>  // .find_of_order(x); .order_of_key(x);
// using namespace __gnu_pbds;
// typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > indexed_set;
/// Function
#define pi (acos(-1))
#define lg2(x) 31-__builtin_clz(x)
#define lgx(x,b) log(b)/log(x)
/// Macros
#define fst first
#define scd second
#define left (node<<1)
#define right ((node<<1)+1)
#define size(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
/// Debug
#define _end cout << "\n"
#ifdef Ernest0_0Abreu
#define db(x) cerr << "[ "<< #x << " ]: " << to_string(x) << "\n"
#define dbrange(x,begin,end) cerr << "[ "<< #x << " ]: " << to_string(x,begin,end) << "\n"
#define dbname(x) cerr << to_string(x,#x) << "\n"
#define dbnamerange(x,begin,end) cerr << to_string(x,#x,begin,end) << "\n"
#define dbmat(x,begin_n,end_n,begin_m,end_m) cerr << to_string(x,#x,begin_n,end_n,begin_m,end_m) << "\n"
#define dbST(x,end) cerr << to_string(x,end) << "\n";
#define dbendl cerr << "\n";
#else 
#define db(x) ;
#define dbrange(x,begin,end) ;
#define dbname(x) ;
#define dbnamerange(x,begin,end) ;
#define dbmat(x,begin_n,end_n,begin_m,end_m) ;
#define dbST(x,end) ;
#define dbendl ;
#endif
/// Typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/// Constant
const int MAXN = 1e5+7;
const int MOD = 1e9+7;
const ull BASE = 311;
const ld EPS = 1e-9;
const int INF = ((1<<30)-1);
const ll INFLL = ((1ll<<62ll)-1ll);
const ll oo = 2e18;
/// Hash Prime Numbers: 2, 277, 293, 307, 331, 337, 1009, 2027;
/// Module Prime Numbers: 3, 998244353, 1000000007, 1000000009, 1000000021, 1000000033;
///=======================================================================================================================================
#define int long long
		///----- My code -----///

int h[MAXN];
vector<int> G[MAXN];

int32_t main(){
	
	ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

	int N, M;
	cin >> N >> M;
	for(int i = 1; i <= N; ++i){
		cin >> h[i];
	}
	for(int i = 1; i <= M; ++i){
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	int ans = 0;
	for(int i = 1; i <= N; ++i){
		int H = h[i];
		bool mk = true;
		for(auto it : G[i]){
			if(h[it] >= H) mk = false;
		}
		if(mk) ans++;
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 10248
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;

//const int MOD=998244353;
const double PI=3.14159265359;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    vector<int> v(3);
    for(int&i:v)cin>>i;
    sort(v.begin(),v.end());
    cout<<v[0]*v[1]/2;
    
    
    return 0;
}

Measured memory_bytes: 256
import operator
for e in iter(input,'0'):
    target = [[*map(int,input().split())]for _ in[0]*int(e)]
    s,t = min(target)
    target = {(x - s, y - t) for x, y in target}
    max_tx = max(map(lambda x:x[0], target))
    b = {tuple(map(int,input().split()))for _ in[0]*int(input())}
    max_sx = max(map(operator.itemgetter(0), b))
    lim_x = max_sx - max_tx
    for x,y in b:
        if x > lim_x:continue
        for u,v in target:
            if (x + u, y + v) not in b:break
        else:
            print(x - s, y - t)
            break


Measured memory_bytes: 6100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 2e5 + 5;
const ll MOD = 1e9 + 7;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pis pair<ll,string>
#define F first
#define S second
#define LCM(a,b) ((a*b)/__gcd(a,b))
#define inf 1e15
#define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define SETBIT(x) __builtin_popcountll(x)
const double EPS = 1E-9;
typedef vector< vector<double> > matrix;
typedef vector<int> vi;

ll A[N], B[N];


ll exp(ll x, ll n, ll mod){
    ll ans = 1LL, X = x, N = n;
    while(N > 0){
        if(N & 1) ans = (ans * X) % mod;
        X = (X * X) % mod;
        N >>= 1;
    }
    return ans;
}

int main() {
    fast;

    int n; cin >> n;
    for(int i = 1; i <= n; i++) cin >> A[i];

    int cnt = 0;
    for(int i = 1; i <= n; i++) if( (A[i]&1)  && (i&1) ) cnt++;

    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define INF 1e9
using namespace std;
	typedef struct edge{
	int to,cap,rev;
	}edge;
void add_edge(int from,int to,int cap,vector<vector<edge> > &g){
	edge f,t;
	f = (edge){to,cap,(int)g[to].size()};
	g[from].push_back(f);
	t = (edge){from,0,(int)g[from].size()-1};
	g[to].push_back(t);
}
int dfs(int v,int t,int f,vector<vector<edge> > &g,vector<bool> &used){
	if(v==t)return f;
	used[v] = true;
	for(int i=0;i<g[v].size();i++){
		edge &e = g[v][i];
		if(!used[e.to]&&e.cap>0){
			int d = dfs(e.to,t,min(f,e.cap),g,used);
			if(d>0){
				e.cap -=d;
				g[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s,int t,vector<vector<edge> > &g){
	int flow=0;
	while(1){
		vector<bool>  used(g.size(),false);
		int f = dfs(s,t,INF,g,used);
		if(f==0) return flow;
		flow+=f;
	}
}

int gcd(int a,int b){
if(b==0)return a;
else return gcd(b,a%b);
}
int main(){
	while(1){
	int n,m;
	cin>>m>>n;
	if(m==0)break;
	vector<int> b(m),r(n);
	for(int i=0;i<m;i++)cin>>b[i];
	for(int i=0;i<n;i++)cin>>r[i];
	vector<vector<edge> > g(n+m+2);
	for(int i=0;i<m;i++) add_edge(0,i+1,1,g);
	for(int i=0;i<n;i++) add_edge(m+i+1,m+n+1,1,g);
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			if(gcd(b[i],r[j])!=1)add_edge(i+1,1+m+j,1,g);
		}
	}
	cout<<max_flow(0,m+n+1,g)<<endl;
	}
	return 0;
}



Measured memory_bytes: 7288
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
using namespace std;
int main(){
	int a = 0, b = 0, c=0, d[100000], e[100000],f=0,g=0,h=0, count = 0;
	char ac,uc[100000];
	string manji,gage;
	cin >> a>>b;
	if (a + b >= 10) {
		cout << "error" << endl;
	}
	else { cout << a + b << endl; }
	return 0;
}

Measured memory_bytes: 256