akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.math.BigDecimal;
import java.math.RoundingMode;

class Main{

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

		boolean flg = true;

		while(flg){

			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();

			int ans = 0;

			switch(op){
				case "+":
				ans = a + b;
				System.out.println(ans);
				break;
				case "-":
				ans = a - b;
				System.out.println(ans);
				break;
				case "*":
				ans = a * b;
				System.out.println(ans);
				break;
				case "/":
				ans = a / b;
				System.out.println(ans);
				break;
				default:
				flg = false;
			}
		}
	}
}


Measured memory_bytes: 26324
array = input().split()
five_count, seven_count = (0, 0)
for i in range(3):
    if int(array[i]) == 5:
        five_count += 1
    elif int(array[i]) == 7:
        seven_count += 1
print('YES') if five_count == 2 and seven_count == 1 else print('NO')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

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

void Main() {
  Cin(int, n, k);
  Cins(int, n, p);

  vector<double> e(n);
  rep(i, n) e[i] = (1 + p[i]) / 2.;

  vector<double> s(n + 1);
  s[0] = 0;
  for (int i = 1; i <= n; ++i) s[i] = s[i - 1] + e[i - 1];

  double mx = 0;
  for (int i = 0; i + k <= n; ++i) mx = max(mx, s[i + k] - s[i]);

  cout << mx << endl;
}

Measured memory_bytes: 4224
n=gets.to_i
d=gets.split.map(&:to_i).sort
x=Array.new(24,0)
x[0]=1
d.each.with_index{|t, i|
  if i%2==0 then
    x[t]+=1
  else
    x[-t]+=1
  end
}

y=[]
z=[]
x.size.times{|i|
  y << i if x[i]>0
  z << 0 if x[i]>1
}

(y.size-1).times{|i|
  z << y[i+1]-y[i]
}
z << (24-y[-1]+y[0])%24

p z.min

Measured memory_bytes: 3836
import numpy as np
N, M, K = [int(_) for _ in input().split()]
mod = 998244353


class Factorial:
    def __init__(self, max_fact, mod):
        #mod should be prime number
        #using homogeneous_product(n,r), max_fact ≧ max(n+r-1)
        f = [1] * (max_fact + 1)
        for idx in range(2, max_fact + 1):
            f[idx] = f[idx - 1] * idx
            f[idx] %= mod
        if mod > max_fact:
            fi = [pow(f[-1], mod - 2, mod)]
            for idx in range(max_fact, 0, -1):
                fi += [fi[-1] * idx % mod]
            fi = fi[::-1]
        else:
            fi = [pow(n, mod - 2, mod) for n in f]
        self.mod = mod
        self.f = f
        self.fi = fi

    def factorial(self, n):
        return self.f[n]

    def factorial_inverse(self, n):
        return self.fi[n]

    def combination(self, n, r):
        f = self.f
        fi = self.fi
        return f[n] * fi[r] * fi[n - r] % self.mod

    def permutation(self, n, r):
        return self.f[n] * self.fi[n - r] % self.mod

    def homogeneous_product(self, n, r):
        f = self.f
        fi = self.fi
        return f[n + r - 1] * fi[r] * fi[n - 1] % self.mod


max_fact = N
fact_instance = Factorial(max_fact, mod)
comb = fact_instance.combination
ans = 0
for r in range(K + 1):
    ans += comb(N - 1, r) * M * pow(M - 1, N - r - 1, mod)
    ans %= mod
print(ans)


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

typedef long long ll;

int main() {
    ll N;
    cin >> N;
    vector<bool> prime(1000001, true);
    prime[0] = false;
    prime[1] = false;
    for (ll i = 2; i * i < 1000001; i++) {
        if (!prime[i]) continue;
        for (ll j = 2 * i; j < 1000001; j += i) {
            prime[j] = false;
        }
    }
    vector<ll> primes;
    rep(i, 1000001) {
        if (prime[i]) primes.push_back(i);
    }
    //rep(i, 100) cout << primes[i] << " ";
    //cout << "\n" << primes.back() << "\n";
    ll ans = 0;
    rep(i, primes.size()) {
        ll p = primes[i];
        if (p * p > N) break;
        if (N % p != 0) continue;
        int c = 0;
        while (N % p == 0) {
            N /= p;
            c++;
        }
        rep(j, 1000001) {
            if (c > j) {
                ans++;
                c -= j + 1;
            } else {
                break;
            }
        }
    }
    if (N > 1) ans++;
    cout << ans << "\n";
}

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

using namespace std;

int power10(int x);
int GetDigit(int x);

int main(void)
{
	int Q;
	cin >> Q;
	for(int i=0;i<Q;i++){
		int N, cnt=0;
		cin >> N;
		while(N >= 10){
			int Digit;
			int maxi = 0;
			Digit = GetDigit(N);
			for(int j=1;j<Digit;j++){
				int n, m;
				n = N / power10(Digit-j);
				m = N - n*power10(Digit-j);
				maxi = max(maxi, n*m);
			}
			N = maxi;
			cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

int power10(int x){
	if (x==0){
		return 1;
	}
	return power10(x-1)*10;
}

int GetDigit(int x){
	int ret=0;
	int n=x;
	do{
		ret++;
	}while((n/=10) != 0);
	return ret;
}


Measured memory_bytes: 3100
// This code wrote by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
using namespace std;
template <class t> inline void read(t &s)
{
	s=0;
	reg int f=1;
	reg char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	s*=f;
	return;
}
int n,m,q;
int A[100];
int a[100],b[100],c[100],d[100];
int ans;
inline void dfs(int dep,int x)
{
	if(dep>n)
	{
		reg int res=0;
		for(int i=1;i<=q;++i)
			if(A[b[i]]-A[a[i]]==c[i])
				res+=d[i];
		ans=max(ans,res);
		return;
	}
	for(int i=x;i<=m;++i)
		A[dep]=i,dfs(dep+1,i);
	return;
}
signed main(void)
{
	cin>>n>>m>>q;
	for(int i=1;i<=q;++i)
		cin>>a[i]>>b[i]>>c[i]>>d[i];
	dfs(1,1);
	cout<<ans<<endl;
	return 0;
}



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

using namespace std;

typedef long long ll;
ll n, A[200050];
int main(){
	cin >> n;
	for(int i = 1; i<=n; i++){
		cin >> A[i-1];
		A[i-1]-=i;
	}
	sort(A, A+n);
	ll ans = 0;
	for(int i = 0; i<n; i++){
		ans += abs(A[i]-A[n/2]);
	}
	cout << ans;
}


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

//#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
/* }}} */

signed main() 
{
  string s,t;
  cin >> s >> t;
  sort(ALL(s));
  sort(ALL(t));
  reverse(ALL(t));
  s<t?print("Yes"):print("No");
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    boolean[] arr = new boolean[1000001];
    boolean[] is = new boolean[1000001];
    int n = Integer.parseInt(sc.next());
    int[] a = new int[n];
    for(int i=0;i<n;i++){
      a[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(a);
    int sum = 0;
    for(int i=0;i<n;i++){
      if(!arr[a[i]] && !is[a[i]]){
       
        //System.out.println(a[i]);
        sum++;
        for(int j=2*a[i];j<1000001;j+=a[i]){
          arr[j] = true;
        }
        is[a[i]] = true;
      }else if(!arr[a[i]] && is[a[i]]){
        arr[a[i]] = true;
        sum--;
      }
    }
    System.out.println(sum);
                    
  }
}

Measured memory_bytes: 62572
from collections import*
I=lambda:map(int,input().split())
n,m=I()
a=Counter(I())
for _ in[0]*m:b,c=I();a[c]+=b
s=0
for k,v in sorted(a.items())[::-1]:
 if n<v:exit(print(s+k*n))
 n-=v;s+=k*v

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

using namespace std;

constexpr static int MOD = 1e9 + 7;
constexpr static int MAXN = 1e6 + 10;

int64_t b[MAXN];


bool check(const vector <int>& a) {
    int n = a.size();
    for (int i = 0; i < n; i++) {
        if (a[i] > n - i)
            return false;
        for (int j = i + 1; j < n && j < i + a[i]; j++)
            for (int k = j + 1; k < n && k <= i + a[i]; k++)
                if (a[j] != a[k])
                    return false;
    }
    return true;
}

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

    b[0] = 1;
    b[1] = 1;
    b[2] = 2;
    b[3] = 4;
    for (int i = 4; i < n + 4; i++)
        b[i] = (b[i - 1] + b[i - 2] + b[i - 4]) % MOD;

    int64_t sum = n + 1LL * (n - 1) * (n - 1) % MOD;
    for (int i = 0; i + 1 < n; i++) {
        sum += 1LL * b[i] * (n - 1) % MOD;
        if (i > 0)
            sum += 1LL * b[i - 1] * (n - 1) % MOD * (n - 1) % MOD;
        sum %= MOD;
    }
    cout << sum << endl;

    /*
    vector <int> p(n + 1);
    p[0] = 1;
    for (int i = 1; i <= n; i++)
        p[i] = p[i - 1] * n;
    int cnt = 0;
    vector <int> a(n);
    for (int mask = 0; mask < p[n]; mask++) {
        int m = mask;
        for (int i = 0; i < n; i++) {
            a[i] = (m % n + 1);
            // cout << a.back() << ' ';
            m /= n;
        }
        // cout << endl;
        if (check(a))
            cnt++;
    }
    cout << cnt << endl;
    */
}


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

using namespace std;

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

int main() {
    vector<int> inputs(5);
    rep(i, 5){
        cin >> inputs.at(i);
    }
    int ans = 1;
    for(int i=0; i<inputs.size(); i++){
        if(inputs.at(i) == 0){
            ans += i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(void)
{
	int n = 1;
	int cou = 0;
	while (n != 0){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		while (n != 1){
			if (n % 2 == 0){
				n /= 2;
			}
			else {
				n = n * 3 + 1;
			}
			cou++;
		}
		printf("%d\n", cou);
		cou = 0;
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
const ll mo = 1000000007;
auto mod = [](ll modx) {modx%=mo;modx+=mo;modx%=mo;return modx; };
const ll MAX = 2000100;
const ll MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(ll n, ll k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
ll r , c , t , v ;
cin >> r >> c >> t >> v ;
COMinit();
ans+=COM(t+1+v+1,v+1)-1;
ans-=COM(r+v+1,v+1)-1;
ans-=COM(t+1+c,c)-1;
ans+=COM(r+c,c)-1;
cout << mod(ans) << endl;
return 0;
}

Measured memory_bytes: 47104
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int main() {

	int a[151][151] = {};

	for (int i = 1; i <= 150; i++) {
		for (int j = i + 1; j <= 150; j++) {
			a[i][j] = i*i + j*j;
		}
	}

	for (int h, w; cin >> h >> w && h && w;) {
		int m = 150 * 150 + 150 * 150;
		int n = h*h + w*w;
		int H, W;
		for (int i = 150; i >= 1; i--) {
			for (int j = i + 1; j <= 150; j++) {
				if (m >= a[i][j] && a[i][j] >= n && !(i == h&&j == w)) {
					if (a[i][j] == n&&i < h)continue;
					m = a[i][j];
					H = i; W = j;
					//cout << M << endl;
				}
			}
		}
		cout << H << " " << W << endl;
	}
	return 0;
}

Measured memory_bytes: 1256
#include <stdio.h>
int main(void)
{
	int n;
	while (scanf("%d", &n) != EOF) {
		int a, b, c, d, count = 0;
		for (a = 0; a <= 9; a++)
            		for (b = 0; b <= 9; b++)
            			for (c = 0; c <= 9; c++)
            				for (d = 0; d <= 9; d++)
                        				if (a + b + c + d == n)
                        					count++;
	printf("%d\n", count);
    }
    return 0;
}


Measured memory_bytes: 2000
import sys
S = input()
L = len(S) - 1
T = 0
if S[0] == 'A':
  if S[1] != 'C' and S[1].islower() == True and S[L] != 'C' and S[L].islower() == True:
    for i in range(2, L):
      if S[i] == 'C':
        T += 1
      elif S[i].isupper() == True:
        print("WA")
        sys.exit()
    if T != 1:
      print("WA")
      sys.exit()
  else:
    print("WA")
    sys.exit()
else:
  print("WA")
  sys.exit()
print("AC")
      

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

const ll MOD = 1000000007;

int main() {
  int N;
  multiset<int> S;

  cin >> N;
  for (int i=0;i<N;i++)  {
    int a;
    cin >> a;
    auto it = S.lower_bound(a);
    if ( it != S.begin() ) {
//      cout << " Erase " << *(--it)<< endl; ++it;
      S.erase(--it);
    }
    S.insert(a);
  }

  cout << S.size() << endl;
  
}


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

using namespace std;

void dfs(vector<vector<int> > &G, int node, vector<bool> &visited, vector<int> &dp){
    visited[node] = true;
    for(auto &e: G[node]){
        if(!visited[e])
            dfs(G, e, visited, dp);
        
        dp[node] = max(dp[node], dp[e]+1);
    }
}

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

    vector<vector<int> > G(N+1);
    for(int i=0; i<M; i++){
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
    }

    vector<int> dp(N+1, 0);
    vector<bool> visited(N+1, false);
    for(int i=1; i<=N; i++){
        if(!visited[i]){
            dfs(G, i, visited, dp);
        }
    }

    int ans = 0;
    for(auto &p:dp){
        ans = max(ans, p);
    }

    cout << ans << "\n";

    return 0; 
} 

Measured memory_bytes: 9600
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define itr(v)          for(auto it:v)
#define show(arr,n) for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fd(i,n)         for(int i=n-1;i>=0;i--)
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

bool cmp(int a,int b) {return a>b;}
int fast_pow(int b,int p,int m=1){
     if(p==0) return 1;
     if(p==1) return b;
    int res=fast_pow(b,p/2,m);  res=(res*res)%m;
    if(p%2==0) return res; else return  (b*res)%m;
}
int mmi(int a,int m){ return fast_pow(a,m-2,m);}

int a[200001],b[200001];

int32_t main()
{
    FIO
    string s; cin>>s;
    int dp[2019]={0};
    dp[s[0]-'0']++;
    int ans=0;
    for(int i=1;i<s.length();i++){
        int d[2019]={0};
        fi(j,2019){
            if(dp[j]>0){
                int rem=(j*10+(s[i]-'0'))%2019;
                if(rem==0) ans+=dp[j];
                d[rem]+=dp[j];
            }
        }
        d[s[i]-'0']++;
        fi(j,2019) dp[j]=d[j];
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3776
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(); 
    int G = sc.nextInt();
    int[] p = new int[N];
    int[] c = new int[N];
    for (int i = 0; i < N; i++) {
      p[i] = sc.nextInt();
      c[i] = sc.nextInt();
    }
    int min = Integer.MAX_VALUE;
    for (int i = 0; i < Math.pow(2,N); i++) {
      int count = 0;
      int total = 0;
      int t = -1;
      for (int j = N-1; j >= 0; j--) {
        if((1&i>>j) == 1) {
          count += p[j];
          total += c[j] + p[j]*(j+1)*100;
        } else if (t == -1) {
          t = j;
        }
      }
      if (G > total && t != -1) {
        for (int j = 0; j < p[t]-1; j++) {
          total += (t+1)*100;
          count ++;
          if (total >= G) break;
        }
      }
      if (G > total) continue;
      //System.out.println("i: " + i + " total: " + total + " count: " + count + " min: " + min);
      min = Math.min(min, count);
    }
    System.out.println(min);
  }
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        a--;
    }
    return ans;
}
int main(){
    double n,count=0;
    ll ans=0;
    cin  >> n;
    vl vec(n);
    rep(i,n){
        int a;
        cin >> a;
        count+=a;
        vec[i]=a;
    }
    double y = count/n;
    int x = round(y);
    rep(i,n){
        ans+=(vec[i]-x)*(vec[i]-x);
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int N = 1e6+6;

void solve(){
	int k;
	cin>>k;
	int cur=7;
	for(int i=1;i<=1e7;++i){
		if(cur%k==0){
			cout<<i;
			return;
		}
		cur=(cur*10+7)%k;
	}
	cout<<-1;

}

int main(){
	ios_base :: sync_with_stdio(false);
	int test = 1; 
	//cin >> test;	
	while (test--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3664
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

long long max(int len, ...) {
    long long i, _max, num;
    va_list ap;
    va_start(ap, len);

    _max = va_arg(ap, long long);
    for (i = 1; i < len; i++) {
        num = va_arg(ap, long long);
        if (num > _max)
            _max = num;
    }
    va_end(ap);
    return _max;
}

int main(void) {
    int i, j, k, slen, tlen, dp[3010][3010] = {0};
    char s[3010], t[3010], u[3010];
    scanf("%s%s", &s, &t);
    slen = strlen(s);
    tlen = strlen(t);

    for (i=1;i<=slen;i++) {
        for (j=1;j<=tlen;j++) {
            if (s[i-1] == t[j-1]) dp[i][j] = dp[i-1][j-1] + 1; //u[k++] = s[i];
            else dp[i][j] = max( 2, dp[i-1][j], dp[i][j-1] );
        }
    }
    // for (i=1;i<=slen;i++) {
    //     for (j=1;j<=tlen;j++) {
    //         printf("%2d ", dp[i][j]);
    //     }
    //     printf("\n");
    // }
    i = slen; j = tlen;
    u[dp[i][j]] = '\0';
    while (i>0 && j>0) {
        while (j>0 && dp[i][j-1] == dp[i][j]) { j--; }
        while (i>0 && dp[i-1][j] == dp[i][j]) { i--; }
        u[dp[i][j]-1] = s[i-1];
        i--; j--;
    }

    printf("%s\n",u);
    return 0;
}

Measured memory_bytes: 35584
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		StringBuffer a=new  StringBuffer(sc.next());
		StringBuffer b=new  StringBuffer(sc.next());

		StringBuffer c=new  StringBuffer(sc.next());

		
		
		
		StringBuffer v[]=new  StringBuffer[3];
		
		
		v[0]=a;
		v[1]=b;
		v[2]=c;
		//a 97 || //b 98 || //c 99 || 
		//A 65 || //B 66 || //C 67 || 
		char x=97;
		while(true) {
			if(v[x-97].length()==0) {
				x-=32;
				p(x+"");
				break;
			}
		//	p(x+"");
			char f=v[x-97].charAt(0);
			v[x-97].delete(0, 1);
			x=f;
			
			
		}
		
		}
		
		
	

	

	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	public static long lcm(long n, long m) {
        return n / gcd(n, m) * m;
}
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 21844
/*  ex4_3 Stone Monument
    pandacodeb  */

#include <stdio.h>

int findDepth(int west, int east);

int main(void){
    int west, east;
    scanf("%d %d", &west, &east);
    printf("%d\n", findDepth(west, east));
    return 0;
}

int findDepth(int west, int east){
    int n = east - west;
    int sum = 0;
    for (int i = 1; i < n; i++){
        sum += i;
    }
    int depth = sum - west;
    return depth;
}

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

int main(void) {
    int n, fa = 0,ta = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a / 4 * 4 == a) fa++;
        else if (a / 2 * 2 == a) ta++;
    }
    cout << (fa * 2 + ta >= n || fa * 2 + 1 >= n ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}


int N, L;

int main(int argc, char **argv) {
    std::cin >> N >> L;

    int total = 0;
    for (int i = 1; i <= N; i++) {
        total += L + i - 1;
    }

    int eat = L;
    for (int i = 2; i <= N; i++) {
        if (abs(L + i - 1) < abs(eat)) {
            eat = L + i - 1;
            //std::cout << eat << std::endl;
        }
    }

    std::cout << total - eat << std::endl;

    return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  
  vector<int> days(M);
  for(int i = 0; i < M; i++){
    cin >> days.at(i);
  }
  
  for(int i = 0; i < M; i++){
    N -= days.at(i);
    
    if(N < 0){cout << -1 << endl;
             return 0;}
  }
  cout << N << endl;
}
  
  

Measured memory_bytes: 3620
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] array = sc.next().toCharArray();
        List<String> list = new ArrayList<>();
        for(int i=0;i<array.length;i++) {
            if (array[i]=='B') {
                if (list.size() != 0) {
                    list.remove(list.size()-1);
                }
            } else {
                list.add(String.valueOf(array[i]));
            }
        }
        for (String s: list) {
            System.out.print(s);
        }
        System.out.println();

    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
#define EPS 1e-15
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,t;cin>>s>>t;
  ll n = s.size();
  bool fl = true;
  ll now = 0;
  t+='A';
  for(int i=0;i<n;i+=2){
    bool can = false;
    while(now < n){
      if(t[now] == s[i]){
	can = true;
	now++;
	break;
      }
      now++;
    }
    if(t[now] == 'A' && can == false){
      fl = false;
    }
  }
  now = 0;
  //t+='A';
  bool fl2=  true;
  for(int i=1;i<n;i+=2){
    bool can = false;
    while(now < n){
      if(t[now] == s[i]){
	can = true;
	now++;
	break;
      }
      now++;
    }
    if(t[now] == 'A' && can == false){
      fl2 = false;
    }
  }
  if(fl||fl2)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}



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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;

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

int const MAX = 2e5 + 41;

int const INF = 1e9 + 41;

int n;
int a[MAX];
int b[MAX];
ll ans;

void solve0() {
	bool f = 1;
	fi(1, n) {
		if (a[i] != b[i]) f = 0;		
	}
	if (f) {
		printf("0\n");
		exit(0);
	}
}

void solve() {
	solve0();
	int mini = INF;	
	fi(1, n) {
		if (a[i] > b[i]) {
			mini = min(mini, b[i]);
		}		
	}
	fi(1, n) {
		ans += b[i];
	}
	ans -= mini;
	printf("%lld\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d", &n);
	fi(1, n) {
		scanf("%d %d", &a[i], &b[i]);
	}  
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#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))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

signed main(){
    int A,B,C; cin>>A>>B>>C;
    int first = max(max(A,B),C);
    int third = min(min(A,B),C);
    int second = A+B+C-first-third;
    int ans;
    if((second+third)%2==0){
        ans = (first-second)+(first-(third+(first-second)))/2;
    }
    else{
        ans = (first-second)+(first-(third+(first-second)))/2+2;
    }
    Out(ans);
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long
int N;
std::vector<LL> A;
LL ans;
int main() {
	std::cin >> N;
	for (int i = 0; i < N * 3; i++) {
		LL tmp;
		std::cin >> tmp;
		A.emplace_back(tmp);
	}
	std::sort(A.rbegin(), A.rend());
	for (int i = 1; i <= N; i++) {
		ans += A[2 * i - 1];
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 6512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

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

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c - '0';}

// TODO: write
int main() { 
  int n;cin>>n;
  int ans = INF;
  
  rep(i,n+1){
    int c = 0;
    int t = i;
    while(t)c += t%6,t/=6;
    t = n-i;
    while(t)c+=t%9,t/=9;
    chmin(ans,c);
  }

  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int b1,b2,b3;
	scanf("%d %d %d",&b1,&b2,&b3);
	if(b1==1 && b2==1 || b3==1){
		printf("Open\n");
	}
	else{
		printf("Close\n");
	}
	return 0;
}

Measured memory_bytes: 1012
#B
import sys
n,a,b=map(int,input().split())
if a==0:
    print(0)
    sys.exit()
else:
    s=int(n/(a+b))
    if s==0:
        m=n
    else:
        absum=(a+b)*s
        m=n%(absum)#余り
    if m<a:
        print(s*a+m)
    else:
        print((s+1)*a)

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

//main関数
int main() {
    //入力
    long N,M,K;
    cin>>N>>M>>K;
    
    //計算
    for(int i=0;i<=N;i++){
        for(int j=0;j<=M;j++){
            if((N-i)*j+i*(M-j)==K){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    
    //出力
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <stack>
#include <cmath>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
using namespace std;
//
const int inf=1e9+7;
const int mod=1e9+7;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll a,ll b){
	return (b==0)?(a):(GCD(b,a%b));
}
ll LCM(ll a,ll b){
	return a/GCD(a,b)*b;
}
//
int main(){
	int A,B;
	cin>>A>>B;
	cout<<(A+B)/2<<endl;
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);	
  
	int n;
  	string s;
  	cin >> n >> s;
  	rep(i,s.size()){
    	if(s[i] +n <='Z')s[i] += n;
      	else{s[i] += (n-26);}
    }
  	cout << s << endl;
}

Measured memory_bytes: 256
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var a = new int[n];
        for (int i = 0; i < n; i++) a[i] = int.Parse(Console.ReadLine().Trim());
        var p1 = checkUp(a, n);
        var p2 = checkDown(a, n);
        Console.WriteLine(Max(p1, p2));
    }
    static int checkDown(int[] a, int n)
    {
        var dmax = 0;
        var pre = a[0]; var down = false; var tdown = 0;
        for (int i = 1; i < n; i++)
        {
            if (a[i] - pre < 0)
            {
                if (!down) down = true;
                tdown++;
                dmax = Max(dmax, tdown);
            }
            else if (a[i] > pre && down) { down = false; dmax = Max(dmax, tdown); tdown = 0; }
            pre = a[i];
        }
        return dmax + 1;

    }
    static int checkUp(int[] a, int n)
    {
        var umax = 0;
        var pre = a[0]; var up = false; var tup = 0;
        for (int i = 1; i < n; i++)
        {
            if (a[i] - pre > 0)
            {
                if (!up) up = true;
                tup++;
                umax = Max(umax, tup);
            }
            else if (a[i] < pre && up) { up = false; umax = Max(umax, tup); tup = 0; }
            pre = a[i];
        }
        return umax + 1;
    }
}



Measured memory_bytes: 20040
#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<int> g[125252];
int indeg[125252];
int len[125252],bef[125252];
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		--x;--y;
		g[x].push_back(y);
		indeg[y]++;
	}
	fill(bef,bef+n,-1);
	stack<int>s;
	for(int i=0;i<n;i++)if(indeg[i]==0)s.push(i);
	while(s.size())
	{
		int p=s.top();
		s.pop();
		for(int to=0;to<g[p].size();to++)
		{
			if(len[p]+1>len[g[p][to]])
			{
				len[g[p][to]]=len[p]+1;
				bef[g[p][to]]=p;
			}
			indeg[g[p][to]]--;
			if(indeg[g[p][to]]==0)s.push(g[p][to]);
		}
	}
	printf("%d\n",*max_element(len,len+n));
	return 0;
}

Measured memory_bytes: 7552
from sys import stdin
readline = stdin.readline


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def diff(p, i):
    return p[(i + 1) % len(p)] - p[i]

# http://www.prefield.com/algorithm/geometry/convex_diameter.html
def convex_diameter(p):
    js = ks = 0
    for i in range(1, len(p)):
        if p[i].imag > p[js].imag:
            js = i
        if p[i].imag < p[ks].imag:
            ks = i

    maxd = abs(p[js] - p[ks])
    j, k = js, ks
    while True:
        if cross(diff(p, j), diff(p, k)) >= 0:
            k = (k + 1) % len(p)
        else:
            j = (j + 1) % len(p)
        if maxd < abs(p[j] - p[k]):
            maxd = abs(p[j] - p[k])
        if j == js and k == ks:
            break
    return maxd


n = int(readline())
p = [map(float, readline().split()) for _ in range(n)]
p = [x + y * 1j for x, y in p]
print('{:.6f}'.format(convex_diameter(p)))

Measured memory_bytes: 54508
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	llint n, k;
	cin >> n >> k;
	//(n-k+1)C(i)*(k-1)C(i-1)で求まる(iは回数を表す)
	for (llint i = 1; i <= k; i++) {
		llint ans;
		ans = convination(n - k + 1, i) * convination(k - 1, i - 1);
		ans %= 1000000007;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <queue>
#include <time.h>

using namespace std;

#define INT_MAX 2147483647
typedef long long ll;

ll gcd(ll m, ll n);		//最大公倍数
ll lcm(ll m, ll n);		//最小公倍数

int main(void) {

	int n;
	cin >> n;
	vector<int> v;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
		ans += tmp;
	}
	sort(v.begin(), v.end());
	ans = ans - v.back()/2;


	cout << ans << endl;

	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  

#if 1
//最大公倍数
ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
#endif

Measured memory_bytes: 256
inf = 10**15
mod = 10**9+7

h,w,k = list(map(int, input().split()))
# 高さiの時jにいる通り
dp = [[0 for j in range(w+1)]for i in range(h+1)]
dp[0][1] = 1
for i in range(h):
    for x in range(2**(w-1)):
        flag = True
        count = 0
        tmp = x
        for l in range(w-1):
            if ((tmp >> l) & 1):
                count+=1
                if count == 2:
                    flag = False
            else:
                count=0
        if flag:
            zeroflag = True
            for j,y in enumerate(range(w-1)):
                if ((x >> y) & 1):  # 1だったら(オンだったら)
                    dp[i+1][j+1] += dp[i][j+2]
                    dp[i+1][j+2] += dp[i][j+1]
                    zeroflag = False
                else:
                    if zeroflag:
                        dp[i+1][j+1] += dp[i][j+1]
                    else:
                        zeroflag = True
            if zeroflag:
                dp[i+1][-1] += dp[i][-1]
    for g in range(1,w+1):
        dp[i+1][g] = dp[i+1][g] % mod
print(dp[h][k])

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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m, T; cin >> n >> m >> T;
    vector<ll> t(n); cin >> t;
    ll prev = 0;
    ll ans = 0;
    rep(i, n) {
        ans += max(0LL, t[i]-(prev+m));
        prev = t[i]+m;
    }
    ans += max(0LL, T-prev);
    cout << ans << endl;
}

Measured memory_bytes: 3192
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb emplace_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<int, pii>
#define puu pair<ULL, ULL>
#define pdd pair<long double, long double>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

string s;
int main() {
    cin >> s;
    sort(s.begin(), s.end());
    if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main() {
    while (1) {
        int q;
        cin >> q;
        if (q == -1) {
            return 0;
        }
        double n = q / 2.0;
        while (abs(pow(n, 3) - q) >= 0.00001 * q) {
            n -= (pow(n, 3) - q) / (3 * pow(n, 2));
        }
        printf("%.6f\n", n);
    }
    
}



Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <cstdlib>  // abs() for integer
#include <cmath>
#include <bitset>
#include <iomanip>
using namespace std;

int main (){
    string S;
    cin >>S;
    if (S == "Sunny"){
        cout << "Cloudy";
    }
    else if (S == "Rainy"){
        cout << "Sunny";
    }
    else {
        cout << "Rainy";
    }
    }
    

Measured memory_bytes: 256