akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
#define popcount __builtin_popcount
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}

const string YES = "Yes";
const string NO = "No";
#define judge(f) cout<<((f)?YES:NO)<<"\n";


int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    if(A>=B){
        for (long long i = 0; i < K; i++) {
            if(A>=B){
                B*=2;
            }else{
                K-=i;
                break;
            }
            if(i==K-1){
                K=0;
            }
        }
    }
    // debg(K)
    if(B>=C){
        for (long long i = 0; i < K; i++) {
            if(B>=C){
                C*=2;
            }else{
                K-=i;
                break;
            }
        }
    }
    judge(A<B&&B<C);
    return 0;
}


Measured memory_bytes: 3760
#include "bits/stdc++.h"
#define ll long long
#define lld long double
#define MOD 1000000007
#define inf 1000000000000000000ll
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x,ll y, ll md=inf){ll res = 1;x%=md;while(y){if(y&1)res = (res*x)%md;x *= x; if(x>=md) x %= md; y >>= 1;}return res;}
 
using namespace std;


#define endl '\n'
#define int ll

signed main() {
	fast;

	int h,w;
	cin>>h>>w;

	pii v[200002];
	for(int i=0;i<h;i++) cin>>v[i].f>>v[i].s;

	map<int,int> mp;
	for(int i=1;i<=w;i++) mp[i] = 0;

	map<int,int> mini = {{0,w}};

	for(int i=0;i<h;i++) {
		int l = v[i].f;
		int r = v[i].s;

		auto it = mp.lower_bound(l);
		int mn = inf;

		while(it!=mp.end() && it->f <= r) {
			mn = min(mn, r+1-(it->f)+(it->s));
			auto it1 = it++;
			if(mini[it1->s]==1) mini.erase(it1->s);
			else mini[it1->s]--;
			mp.erase(it1);
		}

		if(r+1<=w && mn<inf) {
			if(it!=mp.end() && it->f == r + 1) {
				if(it->s > mn) {
					if(mini[it->s]==1) mini.erase(it->s);
					else mini[it->s]--;
					mini[mn]++;
					it->s = mn;
				}
			}
			else {
				mp.insert({r+1,mn});
				mini[mn]++;
			}
		}

		if(mini.size()) cout<<mini.begin()->f+i+1<<endl;
		else cout<<-1<<endl;

	}
}

Measured memory_bytes: 19248
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int w = scan.nextInt();
        int h = scan.nextInt();
        int x = scan.nextInt();
        int y = scan.nextInt();
        int r = scan.nextInt();

        if (x<r || y<r || (x+r)>w || (y+r)>h) 
              System.out.println("No");
        else
              System.out.println("Yes");
     }
}

Measured memory_bytes: 26364
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N,K=LI()
INL=LI()
DP=[False]*(K+1)

for i in range(0,K+1):
    for v in INL:
        if v+i <= K:
            DP[v+i] = DP[v+i] or not DP[i]

# print(DP)
print('First' if DP[K] else 'Second')


Measured memory_bytes: 42092
import sys

s = input()
k = int(input())

onaji = 1
before = s[0]
for i in range(len(s)):
    now = s[i]
    if now != before:
        onaji = 0

if onaji == 1:
    print((len(s)*k)//2)
    sys.exit()

s_2 = s + s

num_first = 0
renzoku = 1
before = 0
for i in range(len(s)):
    now = s[i]
    if now == before:
        renzoku += 1
    else:
        num_first += renzoku // 2
        renzoku = 1
    before = now
num_first += renzoku // 2

num_rest = 0
renzoku = 1
before = 0
for i in range(len(s_2)):
    now = s_2[i]
    if now == before:
        renzoku += 1
    else:
        num_rest += renzoku // 2
        renzoku = 1
    before = now
num_rest += renzoku // 2

num_rest -= num_first

print(num_first + (k-1) * num_rest)

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

using namespace std;

int main(){
	int K, S, ans = 0; cin >> K >> S;
	for(int i = 0; i <= K; ++i){
		for(int j = 0; j <= K; ++j){
			int z = S - i - j;
			if(0 <= z && z <= K){
				ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CPyramid solver = new CPyramid();
        solver.solve(1, in, out);
        out.close();
    }

    static class CPyramid {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
        /*
        気合のO(N^3)でよさそう
        頂点座標を(a,b)としたときにすべてつじつまが合えばよい
         */
            int n = in.nextInt();
            int[] x = new int[n];
            int[] y = new int[n];
            int[] h = new int[n];
            int xxx = 0, yyy = 0, hhh = 0;
            for (int i = 0; i < n; i++) {
                x[i] = in.nextInt();
                y[i] = in.nextInt();
                h[i] = in.nextInt();
                if (h[i] != 0) {
                    xxx = x[i];
                    yyy = y[i];
                    hhh = h[i];
                }
            }

            for (int i = 0; i <= 100; i++) {
                for (int j = 0; j <= 100; j++) {
                    int height;
                    int xx = Math.abs(i - xxx);
                    int yy = Math.abs(j - yyy);
                    height = hhh + xx + yy;
                    boolean f = true;
                    for (int l = 0; l < n; l++) {
                        int dx = Math.abs(i - x[l]);
                        int dy = Math.abs(j - y[l]);
                        f = f && (Math.max(height - dx - dy, 0) == h[l]);
                    }
                    if (f && height >= 1) {
                        out.println(i + " " + j + " " + height);
                        return;
                    }
                }
            }

        }

    }
}



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

int main(){
    int H,W;
    
    while(1){
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        for (int i = 0; i < H; i++){
            for (int j = 0; j < W; j++){
                if( i == 0 || j == 0 || i == H-1 || j == W-1 ) cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


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

#define INF 2147483647
#define LINF 9223372036854775807

#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

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

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

vector<int> ranlen(string s){

    char now = s[0];
    int i=0,count=0,len=s.size();
    vector<int>l;

    while(i < len){
        count=0;
        now = s[i];
        while(s[i]==now  && i < len){
            ++i;
            ++count;
        }

        l.push_back(count);
    }
    return l;
}

int main(){
    bool flag=true;
    ll ans=0,sum=0;

    int n,k;
    string s;
    cin >>n>>k>>s;

    vector<int> r = ranlen(s);
    if(s[0] == '0')r.insert(r.begin(),0);
    if(s[n-1] == '0')r.push_back(0);

    /*
    for (int i = 0; i < r.size(); i++){
        cout << r[i] << " ";
    }
    ln;
    */


    vector<int> sumr( r.size() );
    sumr[0] = r[0];
    
    rep1(i,1,r.size()){
        sumr[i] = sumr[i-1]+r[i];
    }

    int tmp;
    if(r.size()<=2*k){
        ans = n;
    }else{
        
        tmp = sumr[2*k];
        chmax(ans,tmp);

        int p = 2;
        while(p+2*k < r.size()){
            tmp = sumr[p+2*k] - sumr[p-1];
            chmax(ans,tmp);
            p += 2;
        }
    }


    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 4264
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define SZ(x) (int)(x.size())
#define F0(i,n) for(int i=0;i<n;i++)
#define F1(i,n) for(int i=1;i<=n;i++)
#define CL(a,x) memset(x, a, sizeof(x));
const int MOD = 1000000007;
const double pi = atan(1.0)*4.0;
const double eps = 1e-8;
ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
int bc(int n) { return n ? bc((n-1)&n)+1 : 0; }

int i, j, k, m, n, l;
string s;
ll ans;
int cnt[26], sum;

int main() {
    // freopen("x.in", "r", stdin);

    cin >> s;
    n = SZ(s);
    
    ans = 1;
    for (int i = n - 1; i >= 0; i--) {
        ans += (sum - cnt[s[i]-'a']);
        cnt[s[i]-'a']++;
        sum++;
    }
    cout <<ans << endl;

    return 0;
}

Measured memory_bytes: 640
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

num = int(input())
s = {}
for i in range(0,num):
	clist = [c for c in input()]
	clist.sort()
	string = ''.join(clist)
	if string in s.keys():
		s[string] += 1
	else:
		s[string] = 1

ans = 0
for key in s:
	if not s[key] == 1:
		ans += combinations_count(s[key], 2)
print(ans)


Measured memory_bytes: 17848
#include <bits/stdc++.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007


int main(){
    int n;
    cin >> n;
    cout << 48-n << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using p = pair<int,int>;
using pp = pair<p,p>;
using ll = long long;
const auto INF =(ll)1e9;
int main(){
  int n;
  cin >> n;
  auto a = vector<int>(n,0);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  sort(a.begin(),a.end(),greater<int>());
  ll x[4] ={-1,-2,-3,-4};
  bool f = true;
  for (int i = 0; i < n; i++)
  {
    if(x[0]!=x[1]){
      x[0]=x[1];
      x[1]=x[2];
    }
    x[2]=x[3];
    x[3]=a[i];
    //cout << x[0]<<" "<<x[1]<<" "<<x[2]<<" "<<x[3]<<endl;
    if(x[0]==x[1]&&x[2]==x[3]){
      cout << x[0]*x[3];
      f=false;
      break;
    }
  }
  if(f) cout << 0;
  return 0;
}

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

#define x first
#define y second
#define pb push_back
#define mp make_pair

#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()

#define ll long long
#define ld long double

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x;
    cin >> x;
    for (ll a = -4000; a <= 4000; a++) {
        for (ll b = -4000; b <= 4000; b++) {
            if (a * a * a * a * a - b * b * b * b * b == x) {
                cout << a << " " << b;
                return 0;
            }
        }
    }
    return 0;
}


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



int main(){
    int n;
    int a[3][100005];
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>a[j][i];
        }
    }
    
    ll dp[3][100005];
    
    dp[0][0]=a[0][0];
    
    dp[1][0]=a[1][0];
    
    dp[2][0]=a[2][0];
    
    for(int i=1;i<n;i++){
        dp[0][i]=max(dp[1][i-1],dp[2][i-1])+a[0][i];
        dp[1][i]=max(dp[2][i-1],dp[0][i-1])+a[1][i];
        dp[2][i]=max(dp[0][i-1],dp[1][i-1])+a[2][i];
    }
    
    
    ll ans=max(dp[0][n-1],dp[1][n-1]);
    ans=max(ans,dp[2][n-1]);
    
    cout<<ans<<endl;
   
    return 0;
}




Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    vector<vector<int>> mat(3, vector<int>(3));
    rep(i, 3) rep(j, 3) cin >> mat[i][j];
    vector<int> b(3);
    b[0] = mat[0][0];
    b[1] = mat[0][1];
    b[2] = mat[0][2];
    bool ans = true;
	for(int i=0; i<3; i++) {
		if(mat[1][i]-b.at(i) != mat[1][(i+1)%3]-b.at((i+1)%3)) ans = false;
		if(mat[2][i]-b.at(i) != mat[2][(i+1)%3]-b.at((i+1)%3)) ans = false;
	}
    ans ? puts("Yes") : puts("No");
    return 0;
}

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

int main() {
  int n; cin >> n;
  int a[n]; for (int i = 0; i < n; ++i) cin >> a[i];
  int sorted_a[n]; copy(a, a + n, sorted_a); sort(sorted_a, sorted_a + n);
  
  for (int a_i = 0; a_i < n; ++a_i) {
    if (a[a_i] != sorted_a[n - 1]) cout << sorted_a[n - 1] << endl;
    else cout << sorted_a[n - 2] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3200
S = [ord(s) - 97 for s in input()]
T = [ord(t) - 97 for t in input()]
SS = S + S
ls = len(S)

indexes = [[] for _ in range(26)]
for i, s in enumerate(SS):
    indexes[s].append(i)
m = [[-1] * 26 for _ in range(2 * ls)]
for s in range(26):
    inds = [0] + indexes[s]
    for r in range(1, len(inds)):
        for i in range(inds[r-1], inds[r]):
            m[i][s] = inds[r] - i

ans = 0
i = ls - 1
for t in T:
    cnt = m[i][t]
    if cnt == -1:
        print(-1)
        exit()
    ans += cnt
    i = (i + cnt) % ls
print(ans)


Measured memory_bytes: 230324
from sys import stdin,setrecursionlimit
input = stdin.readline
setrecursionlimit(1000000) 

N, Q = map(int, input().split())
T = [[] for _ in range(2 * (10 ** 5))]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    T[a].append(b)
    T[b].append(a)

d = [0] * N

for _ in range(Q):
    p, x = map(int, input().split())
    d[p - 1] += x

def dfs(u, v):
    global d
    for p in T[u]:
        if p == v:
            continue
        d[p] += d[u]
        dfs(p, u)

dfs(0, -1)

for v in d:
    print(v)


Measured memory_bytes: 227760
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
    string in;
    cin >> in;
    int size = in.size() / 2 - 1;
    while (size >= 0) {
        if (in.substr(0, size) == in.substr(size, size)) {
            cout << size * 2 << endl;
            return 0;
        } else {
            size--;
        }
    }
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(Args&&... args) const { print(std::forward<Args>(args)...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(T&& head, Tail&&... tail) const { std::cout << head, print_rest(std::forward<Tail>(tail)...); }
        template <class T, class... Tail>
        void print_rest(T&& head, Tail&&... tail) const { std::cout << sep << head, print_rest(std::forward<Tail>(tail)...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
    template <class T>
    void print_vec(const std::vector<T>& vec, const char* sep = " ", const char* term = "\n") const {
        const size_t sz = vec.size();
        for (size_t i = 0; i < sz; i++) std::cout << vec[i] << (i == sz - 1 ? term : sep);
    }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vl A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    Vl cum(N + 1);
    for (ll i = 0; i < N; i++) {
        cum[i + 1] = cum[i] + A[i];
    }
    ll ans = L_INF;
    ll idx1 = 1, idx2 = 3;
    for (ll i = 2; i < N - 1; i++) {
        while (idx1 < i && cum[idx1] < cum[i] - cum[idx1]) {
            ++idx1;
        }
        while (idx2 < N - 1 && cum[idx2] - cum[i] < cum[N] - cum[idx2]) {
            ++idx2;
        }
        ll p1 = cum[idx1 - 1];
        ll p2 = cum[idx1];
        ll q1 = cum[i] - cum[idx1 - 1];
        ll q2 = cum[i] - cum[idx1];
        ll r1 = cum[idx2 - 1] - cum[i];
        ll r2 = cum[idx2] - cum[i];
        ll s1 = cum[N] - cum[idx2 - 1];
        ll s2 = cum[N] - cum[idx2];
        ll t = L_INF;
        t = min(t, max({p1, q1, r1, s1}) - min({p1, q1, r1, s1}));
        t = min(t, max({p2, q2, r1, s1}) - min({p2, q2, r1, s1}));
        t = min(t, max({p1, q1, r2, s2}) - min({p1, q1, r2, s2}));
        t = min(t, max({p2, q2, r2, s2}) - min({p2, q2, r2, s2}));
        ans = min(ans, t);
    }
    prints()(ans);
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

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

int main() {
    string S;
    cin >> S;

    int res = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
            int len = 0;
            while (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
                len++;
                i++;
            }
            res = max(res, len);
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    int dpa[n],dpb[n],dpc[n];
    for(int i = 0 ; i<n ; i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    dpa[0] = a[0];
    dpb[0] = b[0];
    dpc[0] = c[0];
    for(int i =1 ; i<n ; i++){
        dpa[i] = a[i] + max(dpb[i-1],dpc[i-1]);
        dpc[i] = c[i] + max(dpb[i-1],dpa[i-1]);
        dpb[i] = b[i] + max(dpa[i-1],dpc[i-1]);
    }
    cout<<max(dpa[n-1],max(dpb[n-1],dpc[n-1]));
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

string s;
int main() {
	cin >> s;

	bool flag = true;
	for (int i=0; i<s.size(); i+=2)
		if (s[i] == 'L') flag = false;
	for (int i=1; i<s.size(); i+=2)
		if (s[i] == 'R') flag = false;

	if (flag) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        int[,] array = new int[4, 13];
        int n;
        int num = 0;
        char cha;

        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 13; j++)
            {
                array[i, j] = 0;
            }
        }

        string str1 = Console.ReadLine();
        n = int.Parse(str1);

        for (int h = 0; h < n; h++)
        {
            string[] str2 = Console.ReadLine().Split(' ');
            cha = char.Parse(str2[0]);
            num = int.Parse(str2[1]);

            switch (cha)
            {
                case 'S':
                    array[0, num - 1] = 1;
                    break;
                case 'H':
                    array[1, num - 1] = 1;
                    break;
                case 'C':
                    array[2, num - 1] = 1;
                    break;
                case 'D':
                    array[3, num - 1] = 1;
                    break;
            }
        }

        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 13; j++)
            {
                if (array[i, j] == 0)
                {
                    if (i == 0)
                    {
                        Console.WriteLine("S " + (j + 1));
                    }
                    if (i == 1)
                    {
                        Console.WriteLine("H " + (j + 1));
                    }
                    if (i == 2)
                    {
                        Console.WriteLine("C " + (j + 1));
                    }
                    if (i == 3)
                    {
                        Console.WriteLine("D " + (j + 1));
                    }
                }
            }
        }
    }
}



Measured memory_bytes: 9184
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long LLINF = 1LL<<60;
const int INF = 1e9;
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; }
typedef long long ll;
#define pint pair<int,int>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s,t; cin >> s >> t;
    cout << t+s << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
#define mp make_pair
const int maxn=2e5;
string s;
int main()
{
    //freopen("ce.in","r",stdin);
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>s;
    int n=s.length();
    for(int i=0;i<n;++i) printf("x");
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(obj) (obj).begin(), (obj).end() //sort(ALL(obj))みたいな



using namespace std;

int main() {
  int h,n,m;
  cin >> h >> n;
  int ans = 0;
  rep(i, n) {
    cin >> m;
    ans += m;
  }
  // if (h <= ans) cout << "Yes" << endl;
  // else cout << "No" << endl;
  cout << (h <= ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int n = scan.nextInt();
			String[]S = new String[n];
			ArrayList<Map<Character,Integer>>aray = new ArrayList<Map<Character,Integer>>();
			
			for(int i = 0;i<n;i++) {
				Map<Character,Integer> map = new TreeMap<Character,Integer>();
				for(int j = 0;j<26;j++){
					char x =(char)('a'+j);
					map.put(x, 0);
				}
				aray.add(map);
			}
			
			
			for(int i = 0;i<n;i++) {
				S[i] = scan.next();
				char[]s = new char[S[i].length()];
				s = S[i].toCharArray();
				for(int j = 0;j<s.length;j++) {
					aray.get(i).put(s[j], aray.get(i).get(s[j])+1);
				}
			}
			
			StringBuffer sb = new StringBuffer();
			
			
			for(int i = 0;i<26;i++) {
				char y = (char)('a'+i);
				int min = Integer.MAX_VALUE;
				for(int j = 0;j<n;j++) {
					int k = aray.get(j).get(y);
					if(min>k)min =k;
				}
				if(min!=0) {
					for(int j = 0;j<min;j++) {
						sb.append(y);
					}

				}
				
			}
			
			System.out.println(sb.toString());
			
			
			
			
			
			
			
			
			
			
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 22484
#include<stdio.h>
int main(void){
  int n;
  int num=1;
  int i=1;
  scanf("%d",&n);
  
  while(i<=n){
    i=i*2;
    num=i;
  }
  
  if(i>=num){
    printf("%d",num/2);
  }
  
  return 0;
}

Measured memory_bytes: 128
import sys,math
N,D = map(int,input().split())
x = []
ans = 0
tmp = 0
for i in range(N):
    a = [int(j) for j in input().split()]
    x.append(a)
for i in range(N):
    for k in range(i,N):
        if i == k:
            continue
        for j in range(D):
            tmp += (x[i][j] - x[k][j]) ** 2
        tmp = math.sqrt(tmp) 
        if tmp.is_integer():
            ans += 1
        tmp = 0
print(ans)

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    // Your code here!
    var n = readLine()!!.toInt()
    var list = readLine()!!.split(" ").map{it.toInt()}.sorted()
    var cnt = 0
    var index = 1
    
    for(i in 1..n){
        cnt = 0
        for(j in index-1..list.size-1){
            if(i != list[j]){
                break
            }
            cnt += 1
            index += 1
        }
        println(cnt)         
    }
}


Measured memory_bytes: 78580
/*siddharth goyal*/
#include<bits/stdc++.h>
using namespace std;
#define   pb              push_back
#define   REP(i,n)        for(int i=1;i<=n;i++)
#define   FOR(i,a,b)      for(int i=a;i<=b;i++)
#define   all(v)          v.begin(),v.end()
#define   F               first
#define   S               second
#define   vl              vector<LL>
#define   itr             ::iterator it
#define   lb              lower_bound
#define   ub              upper_bound
#define   LL              long long
#define   ULL             unsigned long long
#define   ret             return 
#define   sz(x)           (LL)x.size()
LL n,i,j,ans = 0,k;
LL a[1000],dp[100+3][100000+9] ;  
LL M = (LL)1E9+7 ; 

int main()
{   // Read the constraints,highlights,Time Limit,Test Cases
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k ; 
    REP(i,n) cin>>a[i] ;
    //sort(a+1,a+1+n) ;
    for(int i=0;i<=a[1];i++)
      dp[1][i] = 1 ; 
    for(int i=2;i<=n;i++)
    {   dp[i][0] = 1 ;
        LL sum = 1 ;  
        for(int j=1;j<=a[i];j++)
        {   dp[i][j] = (sum + dp[i-1][j] + M)%M ;
            sum = (sum + dp[i-1][j] + M)%M ;  
        } 
        sum = (sum - 1 + M)%M ;
        LL k1 = 1;   
        for(int j=1 + a[i];j<=100000;j++)
        {  sum = (sum + dp[i-1][j] + M)%M ; 
           dp[i][j] = (sum + M)%M ; 
           sum = (sum - dp[i-1][k1] + M)%M;
           k1++ ; 
          // if(i==3) cout<<"sum = "<<sum<<endl ; 
        }

    } 
    // for(int i=1;i<=n;i++)
    // {  for(int j=1;j<=5;j++)
    //       cout<<dp[i][j]<<" " ; 
    //    cout<<endl;
    // }
    cout<<(dp[n][k] + M)%M<<endl; 
}
//Check for 0,1 and other corner cases.

Measured memory_bytes: 79360
n = num = int(input())
i=2
while i * i <= n:
    if n % i ==0:
        num = num // i * (i - 1)
        while n % i == 0:
            n //= i
    i += 1
if n != 1 :
    num = num // n * (n - 1)
print(num)


Measured memory_bytes: 5592
#include<stdio.h>
#include<stdlib.h>


int n;
void maxHeapify(int [], int);
void buildMaxHeap(int []);
int main() {
	int i,H[500001];


	
	scanf("%d",&n);
	
	for(i=1;i<=n;i++) {
		scanf("%d",&H[i]);
		}
	buildMaxHeap(H);	
	for(i=1;i<=n;i++) {
	printf(" %d",H[i]);
	}
	printf("\n");
		return 0;
}
		
	void	  maxHeapify(int A[], int i) {
		int d,largest,l,r;
	
  l = 2*i;
 
 r = 2*i+1;
      // 左の子、自分、右の子で値が最大のノードを選ぶ
      if (l <= n && A[l] > A[i])
          largest = l;
      else 
         largest = i;
     if (r <= n && A[r] > A[largest])
         largest = r;

     if (largest != i) {
     	 d=A[i];
     A[i]= A[largest];   
     A[largest]=d;
          
         maxHeapify(A, largest); 
         }// 再帰的に呼び出し
         }
         
      void   buildMaxHeap(int A[]){
      	int i;
   for( i = n/2; i>=1;  i--)
       maxHeapify(A, i);
       }



Measured memory_bytes: 3752
xn = input().split()
data_2 = []
x = int(xn[0]) #これに近い値

if int(xn[1]) == 0:
    print(x)
else:
    data_str = input().split()
    data = [int(s) for s in data_str] #data_strをint型に変換
    data.sort() #小さい順
    #dataにない値が出るまでxから１引き続ける　１引き続けた値をaとする
    a = int(xn[0])
    #check
    while True: #while1
        while True: #while2
            for i in range(len(data)):
                if data[i] != a:
                    continue
                else:
                    a -= 1
                    break #forから抜け出す
            else:
                data_2.append(a)
                break #while2から抜け出す

        if len(data_2) == 1: #リストに１つデータが入っていたら　入ってないならwhile1ループ
            break #while1から抜け出す    


    #dataにない値が出るまでxかに１を足し続ける　１足し続けた値をbとする
    b = int(xn[0])
    while True: #while1
        while True: #while2
            for i in range(len(data)):
                if data[i] != b:
                    continue
                else:
                    b += 1
                    break #forから抜け出す
            else:
                data_2.append(b)
                break #while2から抜け出す

        if len(data_2) == 2: #リストに2つデータが入っていたら　入ってないならwhile1ループ
            break #while1から抜け出す  


    #aとbの小さい方をprint
    if abs(x-a) <= abs(b-x):
        print(a)
    else:
        print(b)

Measured memory_bytes: 9236
#include <stdio.h>
#include <stdlib.h>

#define HASH 200003

typedef struct List {
	struct List *next;
	char *s;
} list;

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

int hash_string(char* s)
{
	int i, x = 0;
	for (i = 0; s[i] != 0; i++) x = ((x << 5) + s[i] - 'a') % HASH;
	return x;
}

int lex_smaller(char* s1, char* s2)
{
	int i;
	for (i = 0; s1[i] != 0 && s2[i] != 0; i++) {
		if (s1[i] < s2[i]) return 1;
		else if (s1[i] > s2[i]) return -1;
	}
	if (s1[i] == s2[i]) return 0;
	else if (s1[i] == 0) return 1;
	else return -1;
}

int main()
{
	int i, j, l[200001], N;
	char *S[200001], T[1000001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%s", T);
		for (l[i] = 0; T[l[i]] != 0; l[i]++);
		S[i] = (char*)malloc(sizeof(char) * (l[i] + 1));
		for (j = 0; j <= l[i]; j++) S[i][j] = T[j];
	}
	
	int h[200001];
	list *p, *hash[HASH], d[200001];
	for (i = 1; i <= N; i++) {
		h[i] = hash_string(&(S[i][1]));
		d[i].s = S[i];
		d[i].next = hash[h[i]];
		hash[h[i]] = &(d[i]);
	}
	
	int k, m, dp[26];
	long long ans = 0, tmp, pow[32];
	const long long inv = div_mod(1, 32, HASH);
	for (k = 1, pow[0] = 32; k < 32; k++) pow[k] = pow[k-1] * pow[k-1] % HASH;
	for (i = 1; i <= N; i++) {
		if (l[i] <= 1) continue;
		for (j = l[i] - 2, k = 0, tmp = 1; j > 0; j >>= 1, k++) if ((j & 1) == 1) tmp = tmp * pow[k] % HASH;
		h[i] = (h[i] - tmp * (S[i][1] - 'a') % HASH + HASH) % HASH;
		for (j = 0; j < 26; j++) dp[j] = 0;
		dp[S[i][0] - 'a'] = 1;
		for (j = 1, m = 1; j < l[i]; j++) {
			dp[S[i][j] - 'a'] = 1;
			for (p = hash[h[i]]; p != NULL; p = p->next) {
				if (dp[p->s[0] - 'a'] == 1 && lex_smaller(&(p->s[1]), &(S[i][j+1])) == 0) ans++;
			}
			tmp = tmp * inv % HASH;
			h[i] = (h[i] - tmp * (S[i][j+1] - 'a') % HASH + HASH) % HASH;
		}
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 15800
while True:
    h,w = map(int,input().split())
    if h == w == 0:
        break
    else:
        for i in range(h):
            for j in range(w):
                if j == 0 or j == w-1 or i ==0 or i ==h-1:
                    print("#",end="")
                else:
                    print(".",end="")
            print()
    print()
    


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

int main() {
  string s;
  cin >> s;
  rep(i, s.size()) s.at(i) = 'x';
  cout << s << endl;
} 

Measured memory_bytes: 256
A, B, M = map(int, input().split())
ref_p = list(map(int, input().split()))
mic_p = list(map(int, input().split()))

# X_i番目の冷蔵庫とY_i番目の電子レンジを同時に買うと支払い増額がC_i安くなる
X_Y_C = [list(map(int, input().split())) for _ in range(M)]

# 割引を使わない場合の最小値
ans = min(ref_p) + min(mic_p)
for x, y, c in X_Y_C:
    temp = ref_p[x-1] + mic_p[y-1] - c

    ans = min(temp, ans)
print(ans)


Measured memory_bytes: 38648
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

void Main() {
    int n; string s; cin >> n >> s;
    vector<BIT<int>> tree(26, BIT<int>(n));
    rep(i, n) {
        int a = s[i] - 'a';
        tree[a].add(i, 1);
    }
    
    int q; cin >> q;
    while(q--){
        int t; cin >> t;
        if(t == 1){
            int i; char c; 
            cin >> i >> c;
            i--;
            
            int now = c - 'a';
            rep(a, 26){
                if(tree[a].sum(i, i+1) == 1){
                    if(a == now) break;
                    else{
                        tree[a].add(i, -1);
                        tree[now].add(i, 1);
                    }
                }
            }
        }else{
            int l, r; 
            cin >> l >> r; 
            l--; r--;
            
            int cnt = 0;
            rep(a, 26){
                if(tree[a].sum(l, r+1) != 0){
                    cnt++;
                }
            }
            cout << cnt << endl;
        }
    }
	return;
}

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

Measured memory_bytes: 56544
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
const int N=1000005;

void solve()
{
    
    int n,k;
    cin>>n>>k;
    int ans=0;
    while(n>0)
    {
        ans++;
        n=n/k;
    }
    cout<<ans<<endl;
    
    
}

int32_t main()
{
    IOS;
    
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll a;
  cin >> a;
  string s;
  cin >> s;

  ll b = 0;
  ll mul = 100;
  for (ll i = 0; i < s.size(); ++i) {
    if (s[i] == '.') continue;
    b += (s[i]-'0')*mul;
    mul /= 10;
  }

  ll ans = (a*b)/100;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
double calc_dist(double x1, double y1, double x2,double y2)
{
	double dx =x1-x2;
	double dy = y1-y2;
	return pow(dx * dx + dy * dy, 0.5);
}
int main() {
	int n;
	cin>>n;
	double ans=0;
	double arr_x[n],arr_y[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr_x[i]>>arr_y[i];
	}
    for(int i=0;i<n;i++)
    {
    	for(int j=i+1;j<n;j++)
    	{
    		ans+=  (2*calc_dist(arr_x[i],arr_y[i],arr_x[j],arr_y[j]))/n;
    	}
    }
    cout << fixed << setprecision(10) << ans << endl;
	return 0;
}

Measured memory_bytes: 512
n=int(input())
s=input()
ans=0
for i in range(1,n-1):
    tmp=0
    sa=list(s[:i])
    sa=set(sa)
    sa=list(sa)
    sb=list(s[i:])
    for j in range(len(sa)):
        if sa[j] in sb:
            tmp+=1
    if tmp>ans:
        ans=tmp
print(ans)

Measured memory_bytes: 39536
from pprint import pprint
from collections import deque

h,w=map(int,input().split())
ch,cw=map(int,input().split())
ch-=1;cw-=1
dh,dw=map(int,input().split())
dh-=1;dw-=1

INF=float("inf")

maze=[input() for _ in range(h)]
dist=[[INF]*w for _ in range(h)]

q=deque()
p=[]

dist[ch][cw]=0
q.append((ch,cw))


while q:
    x,y=q.popleft()
    d=dist[x][y]
    for i in range(-2,3):
        for j in range(-2,3):
            if abs(i)+abs(j)==1:
                xx=x+i
                yy=y+j
                if 0<=xx<=h-1 and 0<=yy<=w-1:
                    if maze[xx][yy]==".":
                        if dist[xx][yy]>d:
                            dist[xx][yy]=d
                            q.appendleft((xx,yy))
            if abs(i)+abs(j)>=2:
                xx=x+i
                yy=y+j
                if 0<=xx<=h-1 and 0<=yy<=w-1:
                    if maze[xx][yy]==".":
                        if dist[xx][yy]>d+1:
                            dist[xx][yy]=d+1
                            q.append((xx,yy))
                            
ans=dist[dh][dw]
if ans==INF:
    print(-1)
else:
    print(ans)


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

int a[100005][3],n,dp[100005][3];
int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        for(int j=0; j<3; j++)
        {
            scanf("%d",&a[i][j]);
            dp[i][j] = INT_MAX;
        }

    for(int i=1; i<=n; i++)
    {
        dp[i][0] = a[i][0] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = a[i][1] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = a[i][2] + max(dp[i-1][1],dp[i-1][0]);
    }

    printf("%d\n",max(max(dp[n][0],dp[n][1]),dp[n][2]));



}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;


int main(){

  llong p, q;
  cin >> p >> q;

  llong a = q, b = p;
  llong r = a % b;
  while(r != 0){
    a = b;
    b = r;
    r = a % b;
  }
  p /= b; q /= b;

  map<llong, llong> mp;
  for(int i = 2; i * i <= q; ++i){
    if(q % i == 0){
      mp[i]++;
      while(q % i == 0) q /= i;
    }
  }
  if(q != 1){
    mp[q]++;
  }

  llong ans = 1;
  REPI(itr, mp){
    ans *= itr->first;
  }
  cout << ans << endl;
  return 0;
}



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

struct Point 
{
  double x, y;
  
  Point() {}
  
  Point(double x, double y) : x(x), y(y) {}
  
  void input() { scanf("%lf %lf", &x, &y); }
  void output() { printf("%.10f %.10f\n", x, y); }
  double abs() { return (sqrt(norm())); }
  double norm() { return (x * x + y * y); }
  
  Point operator + (Point d) { return (Point(x + d.x, y + d.y)); }
  Point operator - (Point d) { return (Point(x - d.x, y - d.y)); }
  Point operator - () { return (Point(-x, -y)); }
  Point operator * (double a) { return (Point(x * a, y * a)); }
  Point operator / (double a) { return (Point(x / a, y / a)); }
  
};

struct Segment
{
  Point p1, p2;
  
  Segment() {}
  Segment(Point p1, Point p2) : p1(p1), p2(p2) {}

  void input() { p1.input(); p2.input(); }
  
};

typedef Point Vector;
typedef vector < Point > Polygon;

double dot(Vector a, Vector b)
{
  return (a.x * b.x + a.y * b.y);
}

double cross(Vector a, Vector b)
{
  return (a.x * b.y - a.y * b.x);
}

Point project(Segment s, Point p)
{
  Vector base = s.p2 - s.p1;
  return (s.p1 + base * (dot(p - s.p1, base) / base.norm()));
}

Point reflect(Segment s, Point p)
{
  Point q = project(s, p);
  return (-p + q * 2);
}


main()
{
  int n;
  Segment s;
  
  s.input();
  cin >> n;

  for(int i = 0; i < n; i++) {
    Point p;
    p.input();
    reflect(s, p).output();
  }
  
  
  return (0);
}

Measured memory_bytes: 3180
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

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

    set<int> s;
    for (auto &&i : a) {
        s.insert(i);
    }

    const bool ans = s.size() == n;
    cout << (ans ? "YES" : "NO") << endl;
}


Measured memory_bytes: 11264
#include <stdio.h>
#include <string.h>
#include <algorithm>


int main(void) {
    char input1[100] = "";
    char input2[100] = "";
    char inputU[100] = "";
    int inputA = 0;
    int inputB = 0;
    scanf("%s", input1);
    scanf("%s", input2);
    scanf("%d", &inputA);
    scanf("%d", &inputB);
    scanf("%s", inputU);
    // printf("%d\n", inputN);
    // printf("%d\n", inputM);

    if (strcmp(input1 , inputU) == 0)
        inputA--;
    else 
        inputB--;

    printf("%d %d\n", inputA, inputB);
    return 0;
}

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

// ABC 088 B
int main() {
  int N;
  int a[100];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> a[i];

  sort(a, a + N, greater<int>());
  int Alice = 0, Bob = 0;
  for (int i = 0; i < N; i++){
    if (i % 2 == 0) Alice += a[i];
    else Bob += a[i];
  }

  cout << Alice - Bob << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    unsigned long int n,half,denomi,i,ans=0;
    scanf("%ld",&n);
    if(n%2==1){
        printf("0");
        return 0;
    };
    half=n/2;
    denomi=1;
    for(i=1;i<26;i++){
        denomi*=5;
        ans+=half/denomi;
        //printf("found= %ld; ans= %ld \n",half/denomi, ans);        
    };
    printf("%ld",ans);
    return 0;
};


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  vector<int> vecA(N);
  for(int j=0; j<N; j++){
    vecA.at(j) = j+1;
  }
  int count = 0;
  for(int k=0; k<N; k++){
    if(vecA.at(k) != vec.at(k)){
      count++;
    }
  }
  
  if(count == 2 || count == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256