akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using uint = unsigned int;
 
const ll mod = 1000000007;
 
ll powmod(ll n, ll k, ll m) {
  if (k == 0) return 1;
  ll t = powmod(n, k / 2, m);
  t = (t * t) % m;
  if (k % 2 == 1)
    t = (t * n) % m;
  return t;
}
 
int main() {
  int n;
  cin >> n;
  int zero = 0;
  map<pair<ll, ll>, pair<int, int>> vct;
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) {
      zero++;
      continue;
    }
    ll g =__gcd(a, b);
    a /= g, b /= g;
    if (a == 0 || b == 0) a = abs(a), b = abs(b);
    if (b < 0) a = -a, b = -b;/// take that simple case -a and +b
    if (a <= 0) 
    {
      ll tmp = -a;
      a = b, b = tmp;
      vct[make_pair(a, b)].second++;
    } 
    else
      vct[make_pair(a, b)].first++;
  }
  ll prod = 1;
  for (auto it : vct) {
    ll sum = powmod(2, it.second.first, mod) + powmod(2, it.second.second, mod) - 1;              
    sum %= mod;
    prod = (prod * sum) % mod;
  }

  prod += zero - 1;
  if (prod < 0) prod += mod;
  cout << prod << endl;
  return 0;
}

Measured memory_bytes: 15904
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        k: usize
    }
    let mut ans = 0;
    for a in 1..k + 1 {
        for b in 1..k + 1 {
            for c in 1..k + 1 {
                ans += gcd(a, gcd (b, c));
            }
        }
    }
    println!("{}", ans);
}

fn gcd(n: usize, m: usize) -> usize {
    let mut l = min(n, m);
    let mut r = max(n, m);
    while l > 0 {
        let t = l;
        l = r % l;
        r = t;
    }
    r
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int n;
    cin >> n;
    vector<int> edge[n];
    int edgenum[n];
    rep(i,n) edgenum[i]=0;
    map<pair<int,int>,int> edgemap;
    int a,b;
    rep(i,n-1){
        cin >> a >> b;
        a--;b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
        edgenum[a]++;
        edgenum[b]++;
        edgemap[make_pair(a,b)]=i;
    }
    int colornum = 0;
    rep(i,n) colornum=max(colornum,edgenum[i]);
    cout << colornum << endl;
    queue<pair<int,int>> que;
    que.push(make_pair(0,n+2));
    bool visited[n];
    rep(i,n) visited[i]=false;
    visited[0]=true;
    int ans[n];
    while(!que.empty()){
        int now = que.front().first;
        visited[now] = true;
        int nowedgecolor = que.front().second;
        que.pop();
        int cl = 0;
        rep(i,edge[now].size()){
            int to = edge[now][i];
            if(!visited[to]){
                int num = edgemap[make_pair(min(now,to),max(now,to))];
                if(nowedgecolor==cl) cl++;
                ans[num] = cl;
                cl++; 
                que.push(make_pair(to,ans[num]));
            }
        }
    }
    rep(i,n-1) cout << ans[i]+1 << endl; 
}

Measured memory_bytes: 13312
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		int q = in.nextInt();
		for(int i=0;i<q;i++)new CGL_2B().doIt();
	}



	class CGL_2B{
		double cross(Point2D p1,Point2D p2){
			return p1.getX()*p2.getY()-p1.getY()*p2.getX();
		}
		//和
		Point2D sum(Point2D p1,Point2D p2){
			return new Point2D.Double(p1.getX()+p2.getX(),p1.getY()+p2.getY());
		}
		Point2D mul(double n,Point2D p1){
			return new Point2D.Double(p1.getX()*n,p1.getY()*n);
		}
		Point2D diff(Point2D p1,Point2D p2){
			return new Point2D.Double(p1.getX()-p2.getX(),p1.getY()-p2.getY());
		}
		Point2D intersectionPoint(Line2D l1,Line2D l2){
			return intersectionPoint(l1.getP1(), l1.getP2(), l2.getP1(), l2.getP2()); 
		}
		Point2D intersectionPoint(Point2D a1,Point2D a2,Point2D b1,Point2D b2){
			Point2D a=diff(a2,a1),
					b=diff(b2,b1);
			return sum(a1, mul(cross(b, diff(b1,a1))/cross(b,a), a));
		}
		void doIt(){
			Line2D l1 = new Line2D.Double(in.nextDouble(),in.nextDouble(),in.nextDouble(),in.nextDouble());;
			Line2D l2 = new Line2D.Double(in.nextDouble(),in.nextDouble(),in.nextDouble(),in.nextDouble());;
			Point2D p = intersectionPoint(l1, l2);
			System.out.printf("%.10f %.10f\n",p.getX(),p.getY());
		}
	}


}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

vector<int> makePrimeList(){
	int range = 1000000;
	vector<int> ret;
	vector<bool> notp(range);

	notp[0] = notp[1] = true;
	for(int i = 2;i < range;i++){
		if(!notp[i]){
			ret.PB(i);
			for(int j = 2 * i;j < range;j += i){
				notp[j] = true;
			}
		}
	}

	return ret;
}

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

	ll n;cin >> n;
	vector<ll> v(n+1);
	REV(i, n+1)cin >> v[i];

	auto p = makePrimeList();

	vector<int> ans;
	for(ll i = 0;p[i] <= n;i++){
		if(!(v[0] == 0 || v[0] % p[i] == 0))continue;
		vector<ll> now(p[i]-1, 0);
		for(int j = 1;j <= n;j++){
			now[(j-1)%(p[i]-1)] += v[j];
		}
		bool flag = true;
		REP(j, p[i]-1){
			if(abs(now[j]) % p[i] != 0)flag = false;
		}
		if(flag)ans.PB(p[i]);
	}

	v[n] = abs(v[n]);
	REP(i, p.size()){
		if(p[i] > n &&  v[n] % p[i] == 0){
			bool flag = true;
			REP(j, n)if(abs(v[j]) % p[i])flag = false;
			if(flag)ans.PB(p[i]);
		}
		while(v[n] != 0 && v[n] % p[i] == 0)v[n] /= p[i];
	}

	if(v[n] > 1){
		bool flag = true;
		REP(i, n)if(abs(v[i]) % v[n])flag = false;
		ans.PB(v[n]);
	}

	REP(i, ans.size()){
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define M_PI           3.14159265358979323846  /* pi */
using namespace std;
using  ll = long long;

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

    vector<ll>t(n + 1, 0);
    vector<ll>x(n + 1, 0);
    vector<ll>y(n + 1, 0);

    for (ll i = 1; i <= n; i++) {
        cin >> t.at(i) >> x.at(i) >> y.at(i);
    }
    ll tnow;
    ll xynow;
    bool result = true;

    for (ll i = 1; i <= n; i++) {
        tnow = (t.at(i) - t.at(i - 1));
        xynow = abs(x.at(i) - x.at(i - 1)) + abs(y.at(i) - (y.at(i - 1)));

        if (tnow < xynow)result = false;
        if (xynow % 2 != tnow % 2)result = false;
    }
    if (result == true)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 5504
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);

  auto m = 0, a = 1;
  foreach (i; 1..n+1) {
    auto r = i.bsf;
    if (r > m) {
      a = i;
      m = r;
    }
  }

  writeln(a);
}

pragma(inline) {
  pure bool bitTest(T)(T n, size_t i) { return (n & (T(1) << i)) != 0; }
  pure T bitSet(T)(T n, size_t i) { return n | (T(1) << i); }
  pure T bitReset(T)(T n, size_t i) { return n & ~(T(1) << i); }
  pure T bitComp(T)(T n, size_t i) { return n ^ (T(1) << i); }

  pure T bitSet(T)(T n, size_t s, size_t e) { return n | ((T(1) << e) - 1) & ~((T(1) << s) - 1); }
  pure T bitReset(T)(T n, size_t s, size_t e) { return n & (~((T(1) << e) - 1) | ((T(1) << s) - 1)); }
  pure T bitComp(T)(T n, size_t s, size_t e) { return n ^ ((T(1) << e) - 1) & ~((T(1) << s) - 1); }

  import core.bitop;
  pure int bsf(T)(T n) { return core.bitop.bsf(ulong(n)); }
  pure int bsr(T)(T n) { return core.bitop.bsr(ulong(n)); }
  pure int popcnt(T)(T n) { return core.bitop.popcnt(ulong(n)); }
}


Measured memory_bytes: 256
s=str(input())
a1=s[::-1]
if s!=a1:
    print("No")
    exit()
n=len(s)
a2=s[0:(n-1)//2]
#print(a2)
a21=a2[::-1]

if a2!=a21:
    print("No")
    exit()

a3=s[(n+3)//2-1:n]
#print(a3)
a31=a3[::-1]
if a3!=a31:
    print("No")
    exit()
print("Yes")

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

using namespace std;

const int md = 998244353;
const int mxn = 3e3;

long long dp[mxn + 11][mxn + 11];
int a[mxn + 11];

int main(){
	int n, s;
	scanf("%d %d", &n, &s);
	for (int i = 0; i < n; i++){
		scanf("%d", a + i);
	}
	dp[0][0] = 1;
	for (int i = 0; i < n; i++){
		for (int j = 0; j <= s; j++){
			dp[i + 1][j] += 2 * dp[i][j];
			dp[i + 1][j] %= md;
			if (j + a[i] <= s){
				dp[i + 1][j + a[i]] += dp[i][j];
				dp[i + 1][j + a[i]] %= md;
			}
		}
	}
	printf("%d\n", dp[n][s]);
	return 0;
}


Measured memory_bytes: 74340
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int k;
ll a[1000000];
PLL p[1000000];

int main(){
  cin>>k;
  rep(i,k){
    cin>>a[i];
  }
  p[k] = P(2,2);

  for(int i=k-1;i>=0;i--){
    if(p[i+1].first%a[i]!=0&&p[i+1].first/a[i]==p[i+1].second/a[i]){
      cout<<-1<<endl;
      return 0;
    }
    p[i] = PLL(a[i]*((p[i+1].first+a[i]-1)/a[i]),
      a[i]*(p[i+1].second/a[i]+1)-1);

  }

  cout<<p[0].first<<' '<<p[0].second<<endl;

  return 0;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main()
{
	ll N, K; cin >> N >> K;
  	ll cnt[5000][5000];
  	for (int i = 0; i <= 2005; i++) {
    	cnt[i][0] = 1;
      	for (int j = 1; j <= i; j++) {
        	cnt[i][j] = (cnt[i - 1][j - 1] + cnt[i - 1][j]) % MOD;
        }
    }
  	for (ll i = 1; i <= K; i++){
    	cout << cnt[K - 1][i - 1] * cnt[N - K + 1][i] % MOD << endl;
    }
}


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

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

const ll INF = (1LL<<60);
const int INFi = (1<<29);

int main(){

    ll a, b; cin >> a >> b;

    cout << a*b << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <math.h>
#include <vector>
#define ll long long
using namespace std;
ll mod = 1000000007;


ll factorial[200010];
ll fact_inv[100010];
void make_fact_inv();


int main(){

    ll H,W,A,B;
    cin >> H >> W >> A >> B;


    //make x!
    factorial[0] = 1;
    for(int i=1; i<200010; ++i){
        factorial[i] = i*factorial[i-1]%mod;
    }

    make_fact_inv();

    ll ans=0;
    for(ll k=0; k<=W-B-1; ++k){
        ll add_ans = factorial[H-A-1+B+k] 
                    * fact_inv[H-A-1] % mod 
                    * fact_inv[B+k] % mod
                    * factorial[A+W-B-2-k] % mod
                    * fact_inv[A-1] % mod
                    * fact_inv[W-B-1-k] % mod;
        ans += add_ans % mod;
    }
    //cout << factorial[H-A-1+B] << " " << fact_inv(H-A-1) << " " << fact_inv(B) << endl;
    //cout << factorial[A+W-B-2] << " " << fact_inv(A-1) << " " << fact_inv(W-B-1) << endl;
    cout << ans % mod <<endl;
    


    return 0;
}

void make_fact_inv(){
    for(int a =0; a<100010; a++){
        ll powpow2[50];//a^(2^0), a^(2^1), a^(2^2), ....
        ll ret=1;
        //powpow2のテーブル埋め
        powpow2[0] = factorial[a];
        for(int i=1; i<50; ++i){
            powpow2[i] = powpow2[i-1] * powpow2[i-1] % mod;
        }
        for(int i=mod-2; i>0; i -= i&-i){
            ll pow_idx = log2(i&-i);
            ret = ret * powpow2[pow_idx] % mod;
        }
        fact_inv[a] = ret;
    }
}



Measured memory_bytes: 2560
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
signed main()
{
	fastio;
	int n,edge;
	cin>>n>>edge;
	vector<int> graph[n+1];
	int visited[n+1]={0};
	for(int i=0;i<edge;i++)
	{
		int x,y;
		cin>>x>>y;
		graph[x].pb(y);
		graph[y].pb(x);
	}
	int ans[n+1]={0};
	visited[1]=1;
	queue<int>q;
	q.push(1);
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		for(int i=0;i<graph[x].size();i++)
		{
			if(visited[graph[x][i]]==false)	
			{
				q.push(graph[x][i]);
				visited[graph[x][i]]=x;		
			}
		}
	}
	for(int i=1;i<n;i++)
	{
		if(visited[i]==false)	
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	for(int i=2;i<=n;i++)
		cout<<visited[i]<<endl;
	cout<<endl;
	
}












Measured memory_bytes: 13764
#include<cstdio>
int main()
{
	char s[18],ans[18]="\0CODEFESTIVAL2016";
	scanf("%s",s+1);
	int sum=0;
	for(int i=1;i<=16;i++){
		if(s[i]!=ans[i]){
			sum++;
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N = 710;
struct edge
{
	int to, nxt;
}e[(N * N) << 1];
int head[N], tot = 0;
int vis[N][N];
int n, m;
int col[N];
int cnt[3];
vector<int> a, b;
int dp[N], flag = 0;
void addedge(int u, int v)
{
	e[++tot] = edge{v, head[u]};
	head[u] = tot;
	return;
}
void dfs(int u, int fa)
{
	col[u] = 3 - col[fa];
	cnt[col[u]]++;
//	cout << u <<" "<< col[u] << endl;
	for(int i = head[u]; i; i = e[i].nxt)
	{
		int v = e[i].to;
		if(!col[v]) dfs(v, u);
		else
		{
			if(col[v] != 3 - col[u]) flag = 1;
		}
		if(flag) return;
	}
	return;
}
int main()
{
	scanf("%d%d", &n, &m);
	int u, v;
	for(int i = 1; i <= m; i++)
	{
		scanf("%d%d", &u, &v);
		vis[u][v] = vis[v][u] = 1;
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			if(i == j || vis[i][j]) continue;
			addedge(i, j);
		}
	}
	col[0] = 2;
	for(int i = 1; i <= n; i++)
	{
		if(col[i]) continue;
		cnt[1] = cnt[2] = 0;
		dfs(i, 0);
		a.push_back(cnt[1]);
		b.push_back(cnt[2]);
		if(flag) return printf("-1\n"), 0;
	}
	int siz = a.size();
	dp[0] = 1;
	for(int i = 0; i < siz; i++)
	{
		for(int j = n; j >= 0; j--)
		{
			if(a[i] != 0 && b[i] != 0) dp[j] = 0;
			if(j >= a[i]) dp[j] |= dp[j - a[i]];
			if(j >= b[i]) dp[j] |= dp[j - b[i]];
		}
	}
	int ans = n * n;
	for(int i = 1; i < n; i++)
	{
		if(!dp[i]) continue;
		ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
	}	
	printf("%d\n", ans);
	return 0;
} 

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

int i,j;
int a,b,k;

int main(){
  cin>>a>>b>>k;
  for(i=a;i<=b;i++){
    if(i<=a+k-1 || i>=b-k+1){
      cout<<i<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
void main() {
    int[] tmp = readln.split.to!(int[]);
    int a = tmp[0], b = tmp[1], c = tmp[2];
    writeln(min(c, b/a));
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N;
    cin >> N;
    vec t(N), v(N);
    ll s = 0;
    Rep (i, N) {
        cin >> t[i];
        t[i] *= 2;
        s += t[i];
    }
    Rep (i, N) {
        cin >> v[i];
        v[i] *= 2;
    }

    vec graph(s+1, inf);
    ll tmp = 0;
    Rep (i, N) {
        Rep (j, t[i]+1) {
            chmin(graph[tmp+j], v[i]);
        }
        tmp += t[i];
    }

    graph[0] = 0;
    Rep (i, s) {
        chmin(graph[i+1], graph[i] + 1);
    }

    reverse(graph.begin(), graph.end());
    graph[0] = 0;
    Rep (i, s) {
        chmin(graph[i+1], graph[i] + 1);
    }

    reverse(graph.begin(), graph.end());
    // Rep (i, s+1) {
    //     cout << graph[i] << " \n"[i==s];
    // }

    double ans = 0;
    Rep (i, s) {
        ans += (double)(graph[i] + graph[i+1])/2.0;
    }

    cout << fixed << setprecision(5) << ans/4 << "\n";
    
    
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,C;
  int Z=0;
  int U=0;
  cin>>N>>M>>C;
  vector<int>vec(M);
  vector<vector<int>> v(N, vector<int>(M));
  for(int X=0;X<M;X++){
    cin>>vec.at(X);
  }
  for(int X=0;X<N;X++){
    for(int Y=0;Y<M;Y++){
      cin>>v.at(X).at(Y);
    }
  }
  for(int X=0;X<N;X++){
    Z=0;
    for(int Y=0;Y<M;Y++){
      Z+=v.at(X).at(Y)*vec.at(Y);
      if(Y+1==M && Z+C>0){
        U++;
      }
    }
  }
  cout<<U<<endl;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <math.h>
#define rep(i, a, b) for(int i = (a); i < (b); ++i)

double dpow(double r, int n){
    double a = r;
    rep(i, 0, n - 1) a *= r;
    return a;
}

int main(){
    double r;
    scanf("%lf", &r);
    printf("%.6f %.6f\n", dpow(r, 2) * acos(-1), r * 2 * acos(-1));

    return 0;
}



Measured memory_bytes: 2032
#include <bits/stdc++.h>
using namespace std;
int N;
int dp[100005];
void solve(int a){
  for(int j=a;j<=N;j*=a){
    for(int i=0;i+j<=N;i++)
     dp[i+j]=min(dp[i+j],dp[i]+1);
  }
}

int main()
{
  cin>>N;
  for (int i=0; i<=N; i++)
    dp[i]=i;
  solve(6);
  solve(9);
  cout<<dp[N]<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define el "\n"
#define sp " "
typedef long long ll;

main()
{
	ios_base::sync_with_stdio(false);
cin.tie(NULL);
	ll n,W,i,j,ans=0;
	cin>>n>>W;
	ll w[n+1],v[n+1];
	for(i=0;i<n;i++)
	cin>>w[i]>>v[i];
	ll dp[101][(ll)1e5+1];
	
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=1e5;j++)
		{
			if(j==0)
			dp[i][j]=0;
			else
			
			dp[i][j]=INT_MAX;
		}
	}
	dp[0][v[0]]=w[0];
			
	
	for(i=1;i<=n;i++)
	{
		for(j=0;j<=1e5;j++)
		{
			
			 if(j>=v[i])
			dp[i][j]=min(dp[i-1][j],w[i]+dp[i-1][j-v[i]]);
			else
			dp[i][j]=dp[i-1][j];
		
			
		}
	}

	for(j=1;j<=1e5;j++)
	{
	if(dp[n-1][j]<=W)
	{
	ans=j;
		
	}
	}
	cout<<ans;
}

Measured memory_bytes: 79232
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
    
public class Main {
    public static void main(String[] args) throws IOException {
        (new Main()).execute();
    }
        
    private void execute() throws IOException {
        Scanner sc = new Scanner(System.in);
        while(true) {
	        Team[] teams = new Team[sc.nextInt()];
	        if(teams.length == 0){break;}
	        
	        int programs = sc.nextInt();
	        for(int i = 0 ; i < teams.length ; i++) {
	        	teams[i] = new Team(i+1, programs);
	        }
	        
	        int logCount = sc.nextInt();
	        for(int i = 0 ; i < logCount ; i++) {
	        	teams[sc.nextInt() - 1].answer(sc.nextInt(), sc.nextInt(), sc.next()); 
	        }
	        
	        Arrays.sort(teams, new TeamComparator());
	        
	        for(Team team : teams) {
	        	System.out.println(team.teamNum + " " + team.collects.size() + " " + team.penalty);
	        }
        }
        sc.close();
    }
    
    private class Team {
    	private static final String CORRECT = "CORRECT";
    	private int[] wrongs;
    	private Set<Integer> collects = new HashSet<Integer>();
    	private int penalty = 0;
    	private int teamNum;

    	Team(int num, int programs) {
    		teamNum = num;
    		wrongs = new int[programs + 1];
    	}

    	void answer(int program, int time, String result) {
    		if(CORRECT.equals(result)) {
    			if(collects.contains(program)){return;}
    			collects.add(program);
    			penalty += wrongs[program]*1200 + time;
    		} else {
    			wrongs[program]++;
    		}
    	}
    }
    
    private class TeamComparator implements java.util.Comparator<Team> {
		@Override
		public int compare(Team o1, Team o2) {
			if(o1.collects.size() != o2.collects.size()) {
				return o2.collects.size() - o1.collects.size();
			} else if(o1.penalty != o2.penalty) {
				return o1.penalty - o2.penalty;
			} else {
				return o1.teamNum - o2.teamNum;
			}
		}
    }
}

Measured memory_bytes: 62016
"""
解法１：
startとgoalの組み合わせの全探索で調べる。
マス目の数は最大で400なので、組み合わせの数は最大で約160000.
各組み合わせごとにBFSで最短経路を調べるので、400回ループが必要。
なので計算時間としてはO(H^3W^3)

解法２：
ワーシャルフロイドで各ノードから各ノードへの最短経路を求める。
計算量としては、O(H^3W^3となる)。

解法１だとなんかTLEするので、解法２で行く。
"""

H,W = map(int,input().split())
MAP = [list(input()) for _ in range(H)]
dp = [[float("INF")]*(H*W) for _ in range(H*W)]
adjecents = [(1,0),(-1,0),(0,1),(0,-1)]

for i in range(H):
    for j in range(W):
        if MAP[i][j] == ".":
            pointer = i*W + j
            dp[pointer][pointer] = 0
            for a,b in adjecents:
                x = i + a
                y = j + b
                if 0<=x<H and 0<=y<W and MAP[x][y] == ".":
                    pointer2 = x*W + y
                    dp[pointer][pointer2] = 1

for i in range(H*W):
    for j in range(H*W):
        for k in range(H*W):
            dp[j][k] = min(dp[j][k],dp[j][i]+dp[i][k])

ans = 0
for i in range(H*W):
    for j in range(H*W):
        if dp[i][j] != float("INF"):
            ans = max(ans,dp[i][j])
print(ans)


Measured memory_bytes: 76040
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    int odd = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a % 2 == 1)
            odd++;
    }
    if (odd % 2 == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 2e5 + 5;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
 
int fac[MAX_N], inv[MAX_N];
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b, bool usemod = true) {ll c = 1LL; while (b > 0) {if (b & 1LL) {if(!usemod)c*=a;else c = a * c%mod;}if (!usemod) a*=a;else a = a * a%mod; b >>= 1LL;}return c;}
void _nCr() {fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) {fac[i] = fac[i - 1LL] * i%mod;}for (int i = 0; i < MAX_N; i++) {inv[i] = POW(fac[i], mod - 2);}}
ll nCr(ll n, ll r) {return (fac[n] * inv[r] % mod)*inv[n - r] % mod;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}

bool solve() {
	int x,a; cin >> x >> a;
	if (x < a) cout << 0 << endl;
	else cout << 10 << endl;
}

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

Measured memory_bytes: 764
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,a[200000],b[200000];
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
        if(b[i]==a[n-1])cout<<a[n-2]<<endl;
        else cout<<a[n-1]<<endl;
    }
}


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

int main()
{
	int x, n;
	std::cin >> x >> n;
	std::vector<int> P;
	if (n == 0)
	{
		std::cout << x <<'\n';
		return 0;
	}
	for (int i = 0; i < n; i++)
	{
		int p;
		std::cin >> p;
		P.push_back(p);
	}
	std::sort(P.begin(), P.end());
	int ansp = 1000;
	int ansm = 1000;
	for (int i = 0; i <= 100; i++)
	{
		int xp = x + i;
		std::vector<int>::iterator itr = std::lower_bound(P.begin(), P.end(), xp);
		if (*itr != xp)
		{
			ansp = xp;
			break;
		}
	}
	for (int i = 0; i <= 100; i++)
	{
		int xm = x - i;
		std::vector<int>::iterator itr = std::lower_bound(P.begin(), P.end(), xm);
		if (*itr != xm)
		{
			ansm = xm;
			break;
		}
	}
	if (std::abs(x - ansp) < std::abs(x - ansm))
		std::cout << ansp << '\n';
	else
		std::cout << ansm << '\n';
	return 0; 
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod=1000000007;
//head

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    set<string> s;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        string s1;
        cin >> s1;
        s.insert(s1);
    }
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 19196
import java.util.*;
import java.math.*;

public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    // static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    static long[] fact = new long[100];
        public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        for(int i = 0;i < 100000;i++){
            long x = pow(i,5);
            for(int j = 0;j < 100000;j++){
                long y = pow(j,5);
                if(x <= n){
                    if(x+y==n){
                        System.out.println(i+" "+-1*j);
                        return;
                    }
                }else{
                    if(x-y==n){
                        System.out.println(i+" "+j);
                        return;
                    }
                }
            }
        }
    }
    static long pow(long a, long n) {
        long ans = 1;
        long m = n;
        while (m > 0) {
            if ((m & 1) == 1)
                ans = ans * a;
            a = a * a;
            m >>= 1;
        }
        return ans;
    }
    
}


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

const int MOD = 998244353;

long long power[200005], pref[200005];

struct S {
    int sz;
    long long ans;
};

S op(S a, S b) {
    return {a.sz + b.sz, (a.ans * power[b.sz] % MOD + b.ans) % MOD};
}

S e() {
    return {0, 0};
}

S mapping(int d, S a) {
    return d == -1 ? a : S{a.sz, d * pref[a.sz - 1] % MOD};
}

int composition(int f, int g) {
    return f == -1 ? g : f;
}

int id() {
    return -1;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, q;
    cin >> n >> q;

    power[0] = pref[0] = 1;
    for (int i=1; i<=n; i++) {
        power[i] = power[i-1] * 10 % MOD;
        pref[i] = (pref[i-1] + power[i]) % MOD;
    }

    lazy_segtree<S, op, e, int, mapping, composition, id> st(vector<S>(n, {1, 1}));
    for (int i=0; i<q; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        st.apply(l, r, d);
        cout << st.all_prod().ans << "\n";
    }

    return 0;
}

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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const LL LL_INF = LL(999999999999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;
const int RUN_SOLVE = 1;

#ifndef LOCAL_H
const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    for(int do_solve_time = 0;do_solve_time < RUN_SOLVE;do_solve_time++){
        void solve();
        if(DO_BENCHMARK){
            clock_t clock_start = clock();
            solve();
            clock_t clock_end = clock();
            const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
            cout << "\n------------------------------------\n" << time << "[ms]\n";
        }
        else solve();
    }
}

/************************************************************************************************************************************************/
void solve(){
    /*
    LL N;
    cin >> N;
    LL num = 0;
    while(N >= pow(26,num)){
        N-=pow(26,num);
        num++;
    }
    cout << "num = " << num << endl;
    vector<LL> name (num);
    for(LL i = 0;i < num;i++){
        name[i] = N%27;
        N /= 27;
    }
    REV(name);
    for(LL i = 0;i < num;i++){
        cout << char('a'+name[i]);
    }
    cout << endl;
    */
    int N, K;
    cin >> N >> K;
    vector<int> P (N);
    for(int i = 0;i < N;i++){
        cin >> P[i];
    }
    SORT(P);
    int sum = 0;
    for(int i = 0;i < K;i++){
        sum += P[i];
    }
    cout << sum << endl;
}



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

using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int x, n;
    cin >> x >> n;
    set<int> s;
    for (int i = 0; i < n; i++) {
        int v;
        cin >> v;
        s.insert(v);
    }
    for (int d = 0; d < n+2; d++) {
        for (int mul = -1; mul <= 1; mul += 2) {
            int v = x + d*mul;
            if (s.count(v) == 0) {
                cout << v << endl;
                return 0;
            }
        }
    }
}



Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long li;

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

    li n;
    cin >> n;

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

    li xorsum = 0;
    for (int i = 0; i < n; ++i) {
        xorsum ^= xs[i];
    }

    li ans = 0;
    for (unsigned int pos = 0; pos < 60; ++pos) {
        if ((xorsum & (1ULL << pos)) != 0) {
            ans += 1ULL << pos;
            for (int i = 0; i < n; ++i) {
                xs[i] &= ~(1ULL << pos);
            }
        }
    }

    vector<bool> used(n);
    for (unsigned int pos = 59; pos <= 59; --pos) {
        for (int pivot = 0; pivot < n; ++pivot) {
            if ((xs[pivot] & (1ULL << pos)) != 0 && !used[pivot]) {
                used[pivot] = true;
                for (int i = 0; i < n; ++i) {
                    if (i == pivot) {
                        continue;
                    }
                    if ((xs[i] & (1ULL << pos)) == 0) {
                        continue;
                    }
                    xs[i] ^= xs[pivot];
                }
            }
        }
    }

    li dupsum = 0;
    for (int i = 0; i < n; ++i) {
        dupsum ^= xs[i];
    }

    cout << ans + dupsum * 2 << endl;

    return 0;
}

Measured memory_bytes: 1024
N = int(input())
D = list(map(int,input().split()))

ans = 0

for i in range(N):
    tako1 = D[i]
    
    for j in range(0,i):
        tako2 = D[j]
        
        ans += tako1*tako2
    
    for j in range(i+1,N):
        tako2 = D[j]
        
        ans += tako1*tako2

print(ans//2)

Measured memory_bytes: 9064
#include <stdio.h>
#include <iostream>
using namespace std;	
	int main ()
	{
		bool primes[1000001];
		primes[2] = true;
		for (int i = 3; i < 1000001; i += 2) {
	    		primes[i] = true;
		}
		for (int i = 3; i * i < 1000001; i += 2) {
	    		if (primes[i]) {
	        	for (int j = i * 2; j < 1000001; j += i) {
	           	 primes[j] = false;
	      		 }
	   		}
		}
		
		int num2[100000];
		int cnt2=0;
		for(int i=0;i<100000;i++){
			cin >> num2[i];
			if(num2[i]==0) i=100000;
			cnt2++;
		}
		for(int j=0;j<cnt2-1;j++){
			int x=0;
			int cnt=0;
			for(int i=0;i<1000000;i++){
				if(primes[i]==true){
					x+=i;
					cnt++;
				}
				if(num2[j] == cnt){
					break;
				}
			}
			cout << x << endl;
		}
	return 0;
	}

Measured memory_bytes: 2140
s = str(input())
l = len(s)
ans = [0 for _ in range(l)]
pretmp = ['', -1]
for i in range(l):
    tmp = -1
    if s[i] == 'R':
        if pretmp[0] == 'R':
            tmp = pretmp[1]
        else:
            for j in range(i, l-1):
                if s[j] == 'R' and s[j+1] == 'L':
                    tmp = j
                    break
        if (tmp - i) % 2 == 0:
            ans[tmp] += 1
        else:
            ans[tmp+1] += 1
    elif s[i] == 'L':
        if pretmp[0] == 'L':
            tmp = pretmp[1]
        else:
            for j in reversed(range(0, i)):
                if s[j] == 'R' and s[j+1] == 'L':
                    tmp = j
                    break
        if (i - tmp) % 2 == 0:
            ans[tmp] += 1
        else:
            ans[tmp+1] += 1
    pretmp = [s[i], tmp]

for i in range(l):
    print(ans[i],end=' ')
print('')

Measured memory_bytes: 4872
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N; cin>>N;
	vector<int> X(N);
	for (int i=0; i<N; i++)
		cin>>X[i];
	int ret=INT_MAX;
	for (int i=1; i<=100; i++) {
		int cur=0;
		for (int j=0; j<N; j++)
			cur+=(X[j]-i)*(X[j]-i);
		ret=min(ret,cur);
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 256
/*
	 ??????????´??????????
	 2??????????´????????????????????±??????????????????¶=2??????????´??????????????????§??????
	 ?????????????????¨???father[]?????´??\?????§???????????§????????????find??¢??°??§??¢?´¢??????????????????
	 ??????????????????????????¨?????¨??????????????????
*/
#include<iostream>
#define maxn 10010
using namespace std;
int n,q;
int father[maxn];

void init(){
	for(int i=0;i<n;i++)father[i]=i;
}

int find(int x){ // x?????????????????¢??°
	if(father[x]==x)return x; // ?????????????????????????????´??????x???????????????
	// return father[x]=find(father[x]); // ??????????????§????????°??????????????????????????????(????????§?????????)
	return find(father[x]); // ??????????????§????????°??????????????????????????????(????????§?????????)
}

void unite(int x,int y){
	father[find(x)]=find(y); // x????????¨y????????????????????????
}

int same(int x,int y){
	if(find(x)==find(y))return 1; // ????????????????????????
	else return 0;
}

int main(void){
	cin>>n>>q;
	init();
	while(q--){
		int com,x,y;
		cin>>com>>x>>y;
		if(com){
			cout<<same(x,y)<<endl;
		}else{
			unite(x,y);
		}
	}
	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<63;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N; cin >> N;
    VI A(N); REP(i,N) cin >> A[i];
    SORT(A);
    REP(i,N-1){
        if(A[i] == A[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1024
X, Y = map(int, input().split())
ans = 10**10
if Y-X >= 0:
    ans = min(ans, Y-X)
if Y+X >= 0:
    ans = min(ans, Y+X+1)
if -Y-X >= 0:
    ans = min(ans, -Y-X+1)
if -Y+X >= 0:
    ans = min(ans, -Y+X+2)
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>

using namespace std;

typedef pair<int, int> P;

const int N = 400;
const int INF = (1<<28);

int n, m;
vector<P> G[N];

int solve(int s){
  int dist[N];
  fill(dist, dist+n, INF);
  dist[s] = 0;
  priority_queue<P, vector<P>, greater<P> > que;
  que.push(P(0, s));
  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second;
    if(dist[v] < p.first) continue;
    for(int i=0;i<G[v].size();i++){
      P e = G[v][i];
      if(dist[e.first] > dist[v] + e.second){
        dist[e.first] = dist[v] + e.second;
        que.push(P(dist[e.first], e.first));
      }
    }
  }
  int res = 0;
  for(int i=0;i<n;i++) res = min(res, dist[i]);
  return res;
}

main(){
  cin >> n >> m;
  for(int i=0;i<m;i++){
    int a, b, c;
    cin >> a >> b >> c;
    G[a].push_back(P(b, -c));
  }
  int ans = 0;
  for(int i=0;i<n;i++) ans = max(ans, -solve(i));
  cout << ans << endl;
}

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

using namespace std;

int main() {
	
	vector<int> v(3,0);
	scanf("%d%d%d", &v[0], &v[1], &v[2]);
	
	sort(v.begin(), v.end());
	
	printf("%d %d %d\n", v[0], v[1], v[2]);
	
}


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

using namespace std;

long long int gcd(long long int a, long long int b) {

	if (a < b) { return  gcd(b, a); }

	if (b == 0) { return a; }

	return gcd(b, a%b);
}

int main(void) {

	long long int A, B, C, D;

	cin >> A >> B >> C >> D;

	long long int sum_C;
	sum_C = B / C;
	long long int sum_D;
	sum_D = B / D;

	long long int E;
	E = (C*D) / (gcd(C, D));

	long long int num1 = B / C + B / D - B / E;
	long long int num2 = (A - 1) / C + (A - 1) / D - (A - 1) / E;

	cout << B-A+1-(num1 - num2) << endl;


	return 0;
}

Measured memory_bytes: 256
import collections
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
x = c.most_common()
ans = 0
for i in range(len(x)):
    if x[i][0]<x[i][1]:
        ans+=x[i][1]-x[i][0]
    elif x[i][0]>x[i][1]:
        ans+=x[i][1]
print(ans)

Measured memory_bytes: 21228
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N = int(input())
L = list(map(int, input().split()))

count = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                if abs(L[j] - L[k]) < L[i] and L[i] < L[j] + L[k]:
                    count += 1
print(count)

Measured memory_bytes: 74236
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
 */
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);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long N = in.nextLong();
            long A[] = new long[5];
            for (int i = 0; i < 5; i++) {
                A[i] = in.nextLong();
            }
            long min = 1_000_000_000_000_000_001L;
            for (int i = 0; i < 5; i++) {
                if (min > A[i]) {
                    min = A[i];
                }
            }
            if (N % min != 0) {
                out.println(N / min + 5);
            } else {
                out.println(N / min + 4);
            }

        }

    }
}



Measured memory_bytes: 21844
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>
#include <stack>

using namespace std;

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

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

long long int DP[1100][1100] = {};
long long int fact[1100][1100];

long long int pow_m1(long long int num){
	long long int pow_num = MOD - 2;
	long long int pow_cur = num;
	long long int ret = 1;
	while(pow_num > 0){
		if(pow_num % 2 == 1){
			ret *= pow_cur;
			ret %= MOD;
		}
		pow_cur *= pow_cur;
		pow_cur %= MOD;
		pow_num /= 2;
	}
	return ret;
}

int main(){
	
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	
	fact[1][0] = 1;
	for(int i = 1; i <= N; i++){
		fact[1][i] = fact[1][i - 1] * i;
		fact[1][i] %= MOD;
	}
	for(int i = 0; i <= N; i++){
		fact[0][i] = 1;
	}
	
	for(int i = 2; i <= N; i++){
		for(int j = 0; j <= N; j++){
			fact[i][j] = fact[i - 1][j] * fact[1][j];
			fact[i][j] %= MOD;
		}
	}
	
	DP[A - 1][0] = 1;
	for(int i = A; i <= B; i++){
		for(int j = 0; j <= N; j++){
			long long int SS;
			DP[i][j] = DP[i - 1][j];
			for(int k = C; i * k <= j && k <= D; k++){
				SS = fact[k][i];
				SS *= fact[1][N - j];
				SS %= MOD;
				SS *= fact[1][k];
				SS %= MOD;
				SS = fact[1][N - j + i * k] * pow_m1(SS);
				SS %= MOD;
				DP[i][j] += DP[i - 1][j - i * k] * SS;
				DP[i][j] %= MOD;
			}
		}
	}
	
	cout << DP[B][N] << endl;
}


Measured memory_bytes: 18688