akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int A,B,H,M;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B>>H>>M;
	H=H*60+M;
	
	double hd=4*atan(1)*2*H/720;
	double md=4*atan(1)*2*M/60;
	double hx=A*cos(hd);
	double hy=A*sin(hd);
	double mx=B*cos(md);
	double my=B*sin(md);
	_P("%.12lf\n",hypot(hx-mx,hy-my));
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 200200;

int A[MAX];
int B[MAX];

VI g[MAX];
VI gr[MAX];

map<int, int> S, T;

void no()
{
	cout<<-1<<endl;
	exit(0);
}

bool U[MAX];
int cnt;

void dfs(int x)
{
	U[x] = true;
	cnt += abs(SZ(g[x]) - SZ(gr[x]));
	FOR (i, 0, SZ(g[x]))
	{
		int to = g[x][i];
		if (U[to]) continue;
		dfs(to);
	}

	FOR (i, 0, SZ(gr[x]))
	{
		int to = gr[x][i];
		if (U[to]) continue;
		dfs(to);
	}
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n;
	scanf("%d", &n);
	int x = 0;
	FOR (i, 0, n)
	{
		scanf("%d", &A[i]);
		S[A[i]]++;
		x ^= A[i];
	}

	S[x]++;

	FOR (i, 0, n)
	{
		scanf("%d", &B[i]);
		T[B[i]]++;
	}

	int diff = 0;

	ITER(it, T)
	{
		int x = it->first;
		int c = it->second;
		if (c > S[x]) no();
		if (S[x] > c)
		{
			diff += S[x] - c;
		}
	}

	if (diff > 1) no();

	VI V;

	FOR (i, 0, n)
	{
		V.PB(A[i]);
		V.PB(B[i]);
	}
	V.PB(x);

	sort(ALL(V));
	V.erase(unique(ALL(V)), V.end());

	int tot = 0;

	FOR (i, 0, n)
	{
		A[i] = lower_bound(ALL(V), A[i]) - V.begin();
		B[i] = lower_bound(ALL(V), B[i]) - V.begin();

		if (A[i] != B[i])
		{
			tot++;
			g[B[i]].PB(A[i]);
			gr[A[i]].PB(B[i]);
		}
	}

	x = lower_bound(ALL(V), x) - V.begin();

	int res = 0;
	dfs(x);
	cnt /= 2;

	if (cnt != 0)
	{
		if (SZ(g[x]) > SZ(gr[x])) cnt--;
	}

	res = cnt;

	FOR (i, 0, n)
	{
		if (U[i]) continue;
		if (SZ(g[i]) == 0 && SZ(gr[i]) == 0) continue;

		cnt = 0;
		dfs(i);
		cnt /= 2;
		if (cnt == 0) cnt++;
		res += cnt;
	}

	res += tot;

	cout<<res<<endl;


}


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

int main(){
  long long N, K;
  cin >> N >> K;
  long long ans;
  if(K%2!=0){
    ans=(N/K)*(N/K)*(N/K);
  }
  else{
    ans=(N/K)*(N/K)*(N/K)+((N+K/2)/K)*((N+K/2)/K)*((N+K/2)/K);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 100+10;
const int N = 1e5+10;
const int E = 1e6+10; 
ll n,m,k;
ll a,b;

ll qpow(ll n,ll b){
	ll res = 1;
	while(b){
		if(b&1) res=res*n%mods;
		n=n*n%mods;
		b>>=1;		 
	}
	return res;
}
ll x,y,z,w;


int main(){
	cin>>n;
	cin>>a>>b;
	if(n==2){
		printf("0");
		return 0;
	}
	ll ans = 0;
	x=y=z=w=1; 
	F(i,n-a+1,n){
		x=x*i%mods;
	}
	F(i,1,a){
		y = y*i%mods;
	}
	F(i,1,b){
		z = z*i%mods;
	}
	F(i,n-b+1,n){
		w = w*i%mods;
	}
	ans=(qpow(2,n)-1-x*qpow(y,mods-2)%mods+mods)%mods;
	ans=(ans - w*qpow(z,mods-2)%mods+mods)%mods;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    cout << min(B / A, C) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main()
{
	int n, a[100], ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	reverse(a, a + n);
	for (int i = 0; i < n; i++) {
		if (i % 2) { ans -= a[i]; }
		else { ans += a[i]; }
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

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

ll cnt = 0;

int merge(vll &a, int left, int mid, int right) {
  int n_comp = 0, n1 = mid - left, n2 = right - mid;

  vll l(n1 + 1), r(n2 + 1);
  rep(i, n1) l[i] = a[left + i];
  rep(i, n2) r[i] = a[mid + i];

  l[n1] = LLONG_MAX;
  r[n2] = LLONG_MAX;
  
  int i = 0, j = 0;
  for (int k = left; k < right; k++) {
    n_comp++;
    if (l[i] <= r[j]) {
      a[k] = l[i];
      i++;
    } else {
      a[k] = r[j];
      j++;
      cnt += n1 - i;
    }
  }

  return n_comp;
}

int merge_sort(vll &a, int left, int right) {
  int n_comp = 0;
  if (right > left + 1) {
    int mid = (right + left) / 2;
    n_comp += merge_sort(a, left, mid);
    n_comp += merge_sort(a, mid, right);
    n_comp += merge(a, left, mid, right);
  }

  return n_comp;
}

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

  vll a(n);
  rep(i, n) scanf("%lld", &a[i]);

  merge_sort(a, 0, n);
  cout << cnt << endl;
}



Measured memory_bytes: 6004
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
using ll = long long;
int a[200000];
ll sum[200000];
int cnt[200000];
int n;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		cnt[a[i]]++;
	}
	ll res = 0;
	for(int i = 1; i <= n; ++i){
		if(cnt[i] >= 2) {
			sum[i] = 1ll * cnt[i] * (cnt[i] - 1) / 2;
			res += sum[i];
		}
	}
	ll tmp, ans;
	for(int i = 0; i < n; ++i){
		tmp = a[i];
		ans = res - sum[tmp];
		tmp = cnt[tmp] - 1;
		if(tmp >= 2){
			ans += tmp * (tmp - 1) / 2;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

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

int H, W;
int s[50][50][2];   // 0:x(down), 1:y(right)

bool inside(int x, int y) {
    return 0 <= x && x < H && 0 <= y && y < W;
}

int bfs(int sx = 0, int sy = 0, int gx = H - 1, int gy = W - 1) {
    queue<P> que;
    que.push(P(sx, sy));
    vector<vector<int>> d(H, vector<int>(W, INF));
    d[sx][sy] = 1;

    while (!que.empty()) {
        int x, y;
        tie(x, y) = que.front(); que.pop();
        if (x == gx && y == gy)
             break;

        rep(k, 4) {
            int nx = x + dx[k], ny = y + dy[k];

            if (inside(nx, ny) && !s[min(x, nx)][min(y, ny)][x == nx] && d[nx][ny] == INF) {
                que.push(P(nx, ny));
                d[nx][ny] = d[x][y] + 1;
            }
        }
    }

    return (d[gx][gy] == INF ? 0 : d[gx][gy]);
}

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

    while (cin >> W >> H, W) {
        rep(i, 2 * H - 1) {
            if (i % 2 == 0) {
                rep(j, W - 1) {
                    cin >> s[i / 2][j][1];
                }
            }
            else {
                rep(j, W) {
                    cin >> s[i / 2][j][0];
                }
            }
        }

        cout << bfs() << endl;
    }
}

Measured memory_bytes: 3056
require 'prime'
a,b=gets.split.map(&:to_i).sort
if a==1
  p 1
  exit
end
c = 1
(a ** 0.5).floor.times do |i|
  if a%(i+1)==0 && b%(i+1)==0 && Prime.prime?(i+1)
    c += 1
  end
  j = a/(i+1)
  if a%j==0 && b%j==0 && Prime.prime?(j)
    c += 1
  end
end
p c

Measured memory_bytes: 2428
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;
using Weight = ll;
Weight INF = 1000000000000000ll;
struct Edge{
  int src, dest; Weight weight;
  bool operator < (const Edge &rhs) const {return weight > rhs.weight;}
};
using Array = vector<Weight>;
using Edges = vector<Edge>;

// BellmanFord (Negative Cycle)
bool bellman_ford(const Edges &es, Array &d, int s, vector<bool>& loop) {
  boost::fill(d, INF); d[s] = 0;
  boost::fill(loop, false);
  bool neg = false;
  REP(i, 2*d.size()) {
    bool updated = false;
    for (Edge e : es) {
      if (d[e.src] < INF && d[e.dest] > d[e.src] + e.weight) {
        d[e.dest] = d[e.src] + e.weight;
        if (i >= d.size() - 1) {
          loop[e.dest] = true;
          neg = true;
        }
        updated = true;
      }
    }
    if (!updated) return true;
  }
  return !neg;
}

int main()
{
  int n,m,p;
  cin>>n>>m>>p;
  Edges ve;
  REP(i,m) {
    ll a,b,c;
    cin>>a>>b>>c;
    --a;--b;
    ve.push_back((Edge){a,b,p-c});
  }
  Array d(n);
  vector<bool> loop(d.size(), false);
  bellman_ford(ve, d, 0, loop);
  if (loop[n-1]) {
    cout<<-1<<endl;
  } else {
    ll e=-d[n-1];
    ll z=0;
    cout<<max(z,e)<<endl;
  }
  return 0;
}


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

int main(){
  int A,B,C,X,cnt=0;
  cin >> A >> B >> C >> X;
  for(int i=0; i<=A; i++){
    for(int j=0; j<=B; j++){
      for(int k=0; k<=C; k++){
        if(500*i+100*j+50*k == X){
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3624
using System;
class Program
{
    static void Main(string[] args)
    {
        int a = Int32.Parse(Console.ReadLine());
        ulong h = 1;
        for (int s = 1; s <= a; s++) { h = h * (ulong)s % 1000000007; }
        Console.WriteLine(h);
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(), (x).end())
#define Reverse(x) reverse((x).begin(), (x).end())
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15) //15桁まで表示
#define str string
typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<ui,ui> puu;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<str> vs;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int floor(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
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() {
    int n;
    cin >> n;
    if (n==1) cout << "Hello World" << endl;
    else{
        int a,b;
        cin>>a>>b;
        cout << a+b << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

#define big ((long long)(1e9)+7)

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
  int n,r;
  cin >> n >> r;
  if(n < 10){
    r += 100*(10-n);
  }
  cout << r << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int N;
    scanf("%d", &N);
    int i;
    int a[100000];
    for(i = 1; i <= N; i++)
        scanf("%d", &a[i]);
    int now_count = 1;
    int count;
    for(count = 1;count <= N; count++)
    {
        //printf("Count: %d Now Count: %d\n",count,now_count);
        if(a[now_count] == 2)
        {
            printf("%d\n",count);
            return 0;
        }
        else
            now_count = a[now_count];
        //printf("Count: %d Now Count: %d\n",count,now_count);
    }
    printf("-1\n");
    return 0;
}

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

int main() {

  int N,M,mini=-1,maxi=-1,ans = 0;
  cin >> N >> M;
  
  for (int i = 0 ; i < M ; i++){
    
    int L,R;
    cin >> L >> R ;
    if (mini < 0 && maxi <0){
      mini = L;
      maxi = R;
    }
    else{
      if (mini < L)
        mini = L;
      if (maxi > R)
        maxi = R;
    }
    
  }
  
  if (maxi < mini)
    cout << 0 << endl;
  else
    cout << maxi - mini + 1 << endl; 
  
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define dbg(x) cout<<#x"="<<x<<endl

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

#define INF 1000000000
#define N_MAX 5000
#define M_MAX 500000

int nails[N_MAX+2][N_MAX+2];

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

  rep(i, n+2){
    rep(j,i+2)
      nails[i][j]=0;
  }

  // imosu method (applying to triangle)
  int a,b,x;
  rep(i, m){
    scanf("%d %d %d", &a, &b, &x);
    a--; b--;
    nails[a][b]++;
    nails[a][b+1]--;
    nails[a+x+1][b]--;
    nails[a+x+2][b+1]++;
    nails[a+x+2][b+x+2]--;
    nails[a+x+1][b+x+2]++;
  }

  int current=0;
  // from left to right
  rep(i, n){
    current=0;
    rep(j, i+1){
      current += nails[i][j];
      nails[i][j] = current;
    }
  }
  // from upper-right to bottom-left
  rep(i,n){
    current=0;
    rep(j,n-i){
      current += nails[i+j][i];
      nails[i+j][i] = current;
    }
  }

  int res=0;
  // from upper-left to bottom-right
  rep(i,n){
    current=0;
    rep(j, n-i){
      current += nails[i+j][j];
      nails[i+j][j] = current;
      if(current>0) res++;
    }
  }

  /*
  rep(i, n){
    rep(j,i+1){
      cout << nails[i][j];
    }
    cout << endl;
  }
  */


  cout << res << endl;

}

Measured memory_bytes: 97372
#include<bits/stdc++.h>
using namespace std;
#define ms(a,b) memset(a,0,sizeof(a))
#define debug(x) cerr<<#x<<"="<<x<<endl;
typedef long long ll;
const int maxn=1e5+100;

int main()
{
	int x,y,z;
	cin>>x>>y>>z;
	int i;
	for(i=1;i<=x;i++){
		if (x>=(i*y+(i+1)*z)){
			continue;
		}
		else{
			i--;
			break;
		}
	}
	cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

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

ll nCr(ll n,ll r){
  if(r == 1) return n;
  else if(r == 0) return 1;
  else return nCr(n-1,r-1)*n/r;
}

int main(){
  ll n,k; cin >> n >> k; ll ans1 = 0; ll ans2 = 0; vl num(n);
  vl cntnum(2000); vl sumnum(2000);
  
  rep(i,n){
    ll x; cin >> x; 
    x--;
    num[i] = x;
    cntnum[x]++;
  }
  
  for(ll i=0; i < n; i++){
    for(ll j=i+1; j < n; j++){
      if(num[i] > num[j]) ans1++;
    }
  }
  
  ans1 = mod(ans1);
  
  sumnum[0] = cntnum[0];
  rep(i,1999){
    sumnum[i+1] = sumnum[i] + cntnum[i+1];
  }
  
  for(ll i=0; i < n; i++){
    if(num[i] != 0){
      ans2 += sumnum[num[i]-1];
    }
  }
  
  ans2 = mod(ans2);
  
  cout << mod(mod(k*ans1) + mod(mod(k*(k-1)/2)*ans2)) << endl;
  
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int[] numbers = new int[3];
  
        for (int i = 0; i < 3; i++) {
            numbers[i] = sc.nextInt();
        }
    
        Arrays.sort(numbers);
        
        System.out.println(numbers[0] + " " + numbers[1] + " " + numbers[2]);
    }
}


Measured memory_bytes: 26240
#include<iostream>
using namespace std;
int main() {
int A[3];int a,b,c;
for(int i=0;i<10;i++){cin>>a;if(a>A[0]){b=A[0];A[0]=a;c=A[1];A[1]=b;A[2]=c;}else if(a>A[1]){b=A[1];A[1]=a;A[2]=b;}else if(a>A[2]){A[2]=a;}}
cout<<A[0]<<endl<<A[1]<<endl<<A[2]<<endl;return 0;}

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


int main(){
    int k,a,b;
    cin >>k;
    cin >>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k == 0){
            cout <<"OK"<<endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3620
// D - Axis-Parallel Rectangle

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

vector<pair<ll, ll>> p;
set<ll> x_set, y_set;
vector<ll> x_vec, y_vec;

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

	for (int i=0; i<N; i++) {
		ll x, y;
		cin >> x >> y;
		p.push_back(make_pair(x, y));
		x_set.insert(x);
		y_set.insert(y);
	}

	x_vec = vector<ll>(x_set.begin(), x_set.end());
	y_vec = vector<ll>(y_set.begin(), y_set.end());

	ll ans = INF;

	for (int i1=0; i1<x_vec.size(); i1++) {
		for (int i2=i1+1; i2<x_vec.size(); i2++) {
			for (int j1=0; j1<y_vec.size(); j1++) {
				for (int j2=j1+1; j2<y_vec.size(); j2++) {
					ll x1 = x_vec[i1];
					ll y1 = y_vec[j1];
					ll x2 = x_vec[i2];
					ll y2 = y_vec[j2];

					int cnt = 0;
					for (int k=0; k<N; k++) {
						ll x = p[k].first;
						ll y = p[k].second;
						if (x >= x1 && x <= x2 && y >= y1 && y <= y2) {
							cnt++;
						}
					}

					if (cnt >= K) ans = min(ans, (x2 - x1) * (y2 - y1));
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
(* O(n) *)
let n = Scanf.scanf " %d" @@ (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ fun a -> a - 1
let rec loop acc i =
  if acc > n then (print_endline "-1"; exit 0)
  else if i = 1 then (Printf.printf "%d\n" acc; exit 0)
  else loop (acc + 1) a_s.(i)
let _ = loop 0 0

Measured memory_bytes: 4992
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

int N, R, T;
int p[110];
//カップの数を記録する
int cup[1010] = {};
int empcup[1010] = {};
//部員の位置、最初全員0にいる
int locate[1010] = {};
ll ans = 0;

int main() {
	cin >> N >> R >> T;
	REP(i, N) cin >> p[i];

	REP(i, T) {
		REP(j, N) {
			//ここで一ターン
			locate[j] += p[j];
			locate[j] %= R;
			if (i != 0) empcup[locate[j]]++;
			if (cup[locate[j]] != 0) cup[locate[j]]--;
		}
		REP(j, R) {
			//空のやつを全部補充する
			cup[j] += empcup[j];
			empcup[j] = 0;
		}
	}

	REP(i, R) ans += cup[i] + empcup[i];
	ans += N;
	cout << ans << endl;
}


Measured memory_bytes: 3116
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def dfs(nodes, src):
    """ DFS(木、スタック、重みなし) """

    N = len(nodes)
    stack = [(src, -1, 0)]
    dist = [-1] * N
    while stack:
        u, prev, c = stack.pop()
        dist[u] = c
        for v in nodes[u]:
            if v != prev:
                # 0,1を交互に入れて二部グラフを塗り分け
                stack.append((v, u, 1-c))
    return dist

N = INT()
nodes = [[] for i in range(N)]
for _ in range(N-1):
    a, b = MAP()
    a -= 1; b-= 1
    nodes[a].append(b)
    nodes[b].append(a)

res = dfs(nodes, 0)
cnt0 = res.count(0)
cnt1 = res.count(1)

ans = [0] * N
# グラフの偏りによって場合分け
if cnt0 <= N // 3 or cnt1 <= N // 3:
    if cnt0 > cnt1:
        cnt0, cnt1 = cnt1, cnt0
        res = [1-c for c in res]
    # 少ない方に全部0mod3入れて、多い方は残りを適当に入れる
    p12 = 1
    p3 = 3
    for i in range(N):
        if res[i] == 0:
            ans[i] = p3
            p3 += 3
    for i in range(N):
        if res[i] == 1:
            if p12 <= N:
                ans[i] = p12
                p12 += 1
                if p12 % 3 == 0:
                    p12 += 1
            else:
                ans[i] = p3
                p3 += 3

else:
    # それぞれに1mod3と2mod3を優先して入れて、なくなったら残りには0mod3を入れる
    p1 = 1
    p2 = 2
    p3 = 3
    for i in range(N):
        if res[i] == 0:
            if p1 <= N:
                ans[i] = p1
                p1 += 3
            else:
                ans[i] = p3
                p3 += 3
        else:
            if p2 <= N:
                ans[i] = p2
                p2 += 3
            else:
                ans[i] = p3
                p3 += 3
print(*ans)


Measured memory_bytes: 54656
import sys
from math import ceil, sqrt
def input(): return sys.stdin.readline().strip()


def main():
    X = int(input())
    """
    # ここで丸め誤差が出たせいで数学的にはTrueなものがFalse扱いされていた！！！
    # （例：3125**(1/5) = 5.000000000000001）
    x = int(X ** (1/5))
    if x == X ** (1/5):
        print("{} {}".format(x, 0))
        return
    # 正しくは以下：
    """
    x = round(X ** (1/5))
    if x ** 5 == X:
        print("{} {}".format(x, 0))
        return
    
    for B in range(1, x + 1):
        """
        # ここも丸め誤差が出るので修正が必要
        A = (X - B**5) ** (1/5)
        if A < B: break
        if int(A) == A:
            print("{} {}".format(int(A), -B))
            return
        """
        A = round((X - B**5) ** (1/5))
        if A < B: break
        if A ** 5 + B ** 5 == X:
            print("{} {}".format(int(A), -B))
            return
    
    """
    ここも修正
    y = sqrt(X)
    if int(y) == y:
    """
    y = round(sqrt(X))
    if y ** 2 == X:
        upper = y + 1
    else:
        upper = y

    for d in range(1, upper):
        if X % d == 0:
            B = 1
            while (B + d) ** 5  < B ** 5 + X:
                B += 1
            if (B + d) ** 5 == B ** 5 + X:
                print("{} {}".format(B + d, B))
                return
            
            e = X // d
            B = 1
            while (B + e) ** 5  < B ** 5 + X:
                B += 1
            if (B + e) ** 5 == B ** 5 + X:
                print("{} {}".format(B + e, B))
                return
       


if __name__ == "__main__":
    main()


Measured memory_bytes: 63032
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;

int main()
{
  ll N;
  cin>>N;
  ll M;
  M=sqrt(N);
  ll A;
  A=1;
  for(ll i=M;i>0;--i)
  {
    A=i;
    if(N%i==0)
    {
      break;
    }
  }
  ll Ans;
  Ans=A+N/A-2;
  cout<<Ans<<endl;

}


Measured memory_bytes: 256
from math import ceil

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
ai = ceil(a/10)*10
bi = ceil(b/10)*10
ci = ceil(c/10)*10
di = ceil(d/10)*10
ei = ceil(e/10)*10
sm = ai+bi+ci+di+ei
r = [sm-ai+a, sm-bi+b, sm-ci+c, sm-di+d, sm-ei+e]
print(min(r))

Measured memory_bytes: 3064
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    a,b,c,d=map(int, input().split())
    if abs(a-c)<=d or (abs(a-b)<=d and abs(c-b)<=d):
        print("Yes")
    else:
        print("No")

main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

// 数列の全ての要素が奇数だと積が偶数とならない。
// したがって、1つ以上の要素が偶数であり、かつ全ての要素が0より大きい組み合わせを考える。

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

    ll ans = 1;
    ll sub = 1;
    rep(i, n){
        ll a; cin >> a;
        ans *= 3;
        sub *= (a%2 == 0 ? 2 : 1);
    }
    // 全部が奇数の場合を引く
    cout << ans-sub << endl;
}

Measured memory_bytes: 3648
#include<stdio.h>

using namespace std;

int A[50];
int n, res = 0;

int solve(int i, int m) {
    if(m == 0) return 1;
    if(i >= n) return 0;
    return solve(i+1, m) || solve(i+1, m-A[i]);
}

int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    int q, m;
    scanf("%d", &q);
    for(int i = 0; i < q; i++) {
        scanf("%d", &m);
        if(solve(0, m)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}

Measured memory_bytes: 2620
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <numeric>

using namespace std;
using ll = long long;
const ll INF = 1e18;

typedef pair<int, int> C;
typedef pair<ll, int> P;
map<P, ll> G;
vector<int> V[100001];
ll d[100001];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<>> que;
    for (int i = 0; i < 100001; i++) d[i] = INF;
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (auto to : V[v]) {
            ll cost = G[C(v, to)];

            if (d[to] > d[v] + cost) {
                d[to] = d[v] + cost;
                que.push(P(d[to], to));
            }
        }
    }
}

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--; b--;
        G[C(a, b)] = c;
        G[C(b, a)] = c;
        V[a].push_back(b);
        V[b].push_back(a);
    }

    int Q, K;
    cin >> Q >> K;
    K--;
    dijkstra(K);
    for (int i = 0; i < Q; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << d[x] + d[y] << endl;
    }

    return 0;
}

Measured memory_bytes: 21620
N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())

for n in range(N-1):
    A[n+1] = A[n]+A[n+1]
B[0] = B[0]+A[0]
for n in range(N-1):
    B[n+1] = max(A[n+1],B[n])+B[n+1]
print(B[N-1])


Measured memory_bytes: 3060
<?php
	fscanf(STDIN, '%d', $jobNum);
	for($i = 0; $i < $jobNum; $i++){
		fscanf(STDIN, '%d %d', $workTime, $deadLine);
      	$works[$deadLine] += $workTime;
    }
	ksort($works);
	$sum = 0;
	$result = 'Yes';
	foreach($works as $key => $value){
      	$sum += $value;
      	if($sum > $key){
          	$result = 'No';
          	break;
        }
    }
	echo $result;

Measured memory_bytes: 17400
#include <iostream>
#include <cstring>
#include <set>
#include <algorithm>
using namespace std;
int main()
{
    int n,s;
    cin>>n>>s;
    if(s%1000==0)//如果末三位不为0则输出-1 -1 -1 
    {
    	s=s/1000;
    	for(int i=0;i<=n;i++)
		{
			for(int j=0;j<=n;j++)
			{
				int t=10*i;
				if(i==n)t+=0;
				else if(i+j<=n)t+=j*5+(n-i-j);
				else break;
				//cout<<i<<" "<<j<<" "<<(n-i-j)<<" "<<t<<endl;
				if(t==s)
				{
					cout<<i<<" "<<j<<" "<<(n-i-j)<<endl;
					return 0;
				}
			}
		} 
    }
    cout<<"-1 -1 -1\n";
    return 0;
}


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

int n, p, q, a;

int dfs(int i, int last, int prod, int c, int d){
    int count = 0;
    if (c * q == d * p) {
        return 1;
    }
    if (i >= n) {
        return 0;
    }
    for (int j = last; j * prod <= a; j++) {
        if (q * (c * j + d) <= (p * j * d)){
            count += dfs(i+1, j, j*prod, c*j+d, d*j);
        }
    }
    return count;
}

int main()
{
    while (true) {
        cin >> p >> q >> a >> n;
        if (p == 0) {
            break;
        }
        cout << dfs(0, 1, 1, 0, 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 1156
def lcm(a, b)
    x = a * b

    if a < b then
        tmp = a
        a = b
        b = tmp
    end

    r = a % b
    while(r != 0)
        a = b
        b = r
        r = a % b
    end
    return x / b
end

def dp(t)
    if t.size == 1 then 
        return t[0]
    elsif t.size == 2 then
        return lcm(t[0], t[1])
    else
        return lcm(dp(t.slice(0,t.size/2)), dp(t.slice(t.size/2,t.size-t.size/2)))
    end
end

t = Array.new

gets
STDIN.each_line {|line| t.push(line.to_i) }

puts dp(t)

Measured memory_bytes: 1788
from itertools import permutations as p

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = y = 0
i = 1
for v in p(list(range(1, n + 1))):
  if list(v) == a:
    x = i
  if list(v) == b:
    y = i
  i += 1
print(abs(x - y))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

using pii = pair<int,int>;

using Graph = vector<vector<pii>>;
int n, m, Q;
Graph g;

int u[200010], v[200010], er[200010];
pii dist[100010];
int ans[200010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> n >> m >> Q;
    g.assign(n, {});
    rep(i, m){
        cin >> u[i] >> v[i];
        --u[i]; --v[i];
        er[i] = 1e9;
    }

    rep(i, Q){
        int r;
        cin >> r;
        --r;
        er[r] = i;
    }

    rep(i, m){
        int &u = ::u[i], &v = ::v[i], &e = er[i];
        g[u].emplace_back(v, e);
        g[v].emplace_back(u, e);
    }

    using state = tuple<int,int,int>;
    priority_queue<state> q;
    rep(i, n) dist[i] = pii(1e9, -1e9);
    dist[0].first = 0;
    dist[0].second = 1e9;
    q.emplace(0, 1e9, 0);
    while(q.size()){
        int cd, ct, cv;
        tie(cd, ct, cv) = q.top();
        cd = -cd;
        q.pop();
        if(dist[cv].first < cd) continue;
        for(auto &e : g[cv]){
            int nd = cd + 1, nt, nv;
            tie(nv, nt) = e;
            nt = min(ct, nt);
            if(dist[nv].first > nd){
                dist[nv] = pii(nd, nt);
                q.emplace(-nd, nt, nv);
            } else if(dist[nv].first == nd && dist[nv].second < nt){
                dist[nv] = pii(nd, nt);
                q.emplace(-nd, nt, nv);
            }
        }
    }

    rep(i, n){
        if(dist[i].second != 1e9) ++ans[dist[i].second];
    }

    rep(i, Q){
        cout << ans[i] << '\n';
        ans[i+1] += ans[i];
    }
}

Measured memory_bytes: 15984
#include <stdio.h>

int main()
{
    int H, W, x, y;
    
    while(1){
        
        scanf("%d %d", &H, &W);
        
        if(H==0 && W==0){
            break;
        }
        
        for(y=0; y<H; y++){
            for(x=0; x<W; x++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    
    return 0;
}

Measured memory_bytes: 572
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                  cerr<<#x<<": "<<x<<endl
#define trace2(x, y)              cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)              cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)          cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}



int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
	ll b[n+1];
	rep(i,1,n) cin >> b[i];
	ll a[n+1];
	a[n]=b[n-1];
	b[0]=inf;
	for(ll i=n-1; i>=1; i--){
		a[i]=min(b[i-1],b[i]);
	}
	ll ans=0;
	for(ll i=1; i<=n; i++) ans+=a[i];
	cout << ans;
    return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  Set<Integer> s = new HashSet<>();
  for (int i=0; i<N; i++) {
    int di = sc.nextInt();
    s.add(di);
  }
  System.out.println(s.size());
}}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using llu = long long unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);
    char s[202020];
    Scs(s);

    int r = 0;
    Rep(i,N) r += (s[i]=='R');

    int ans = 0;
    Rep(i,r) ans += (s[i]=='W');

    printf ("%d\n", ans );

    return 0;
}




Measured memory_bytes: 4020
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#include <bits/stdc++.h>//atcoderでsqrtを使うときに必要
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;

void solve() {
	int N;
	cin >> N;
	vector<float> x(N), y(N);

	fi(N) {
		cin >> x[i] >> y[i];
	}

	float n = N;
	float C;

	if (N == 2) {
		C = 1;
	}
	else if (N == 3) {
		C = 3;
	}
	else if (N == 4) {
		C = 6;
	}
	else if (N == 5) {
		C = 10;
	}
	else if (N == 6) {
		C = 15;
	}
	else if (N == 7) {
		C = 21;
	}
	else if (N == 8) {
		C = 28;
	}


	double res = 0;

	for (int i = 0; i < N-1; i++) {
		for (int m = i + 1; m < N; m++) {
			res += sqrt((x[i]-x[m])*(x[i] - x[m]) + (y[i] - y[m])*(y[i] - y[m]));
		}
	}



	res *= (n-1)/C;

	cout << fixed << setprecision(15) << res << endl;

}

int main()
{
	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

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

int main(){
  string ss;
  queue<char> s[3];
  REP(i,3){
    cin>>ss;
    for(int j=0;j<ss.size();j++){
      s[i].push(ss.at(j));
    }
    s[i].push('Z');
  }

  char c='a';
  while(!s[0].empty() && !s[1].empty() && !s[2].empty()){
    int i=2;
    if(c=='a') i=0;
    else if(c=='b') i=1;
    c=s[i].front();
    s[i].pop();
  }
  if(s[0].empty()) cout<<'A';
  else if(s[1].empty()) cout<<'B';
  else cout<<'C';
}

Measured memory_bytes: 256
k,s=map(int,input().split())
# 0<=x,y,z<=k
# x+y+z=s となるxyzの組み
ans=0
for x in range(k+1):
  if s-x<0:
    break
  a=max(0,s-x+1)
  a-=max(0,(s-x-k)*2)
  ans+=max(0,a)
print(ans)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
    bool chk=true;
 string S;
 cin >> S;
 for(int i=0; i<S.size(); i++)
 {
     if(i%2==0&&(!(S.at(i)=='R'||S.at(i)=='U'||S.at(i)=='D')))
     {
         chk=false;
     }
    if(i%2==1&&(!(S.at(i)=='L'||S.at(i)=='U'||S.at(i)=='D')))
     {
         chk=false;
     }
 }
 if(chk)
 {
     cout <<"Yes"<<endl;
 }
 else
 {
     cout<<"No"<<endl;
 }
 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int N, Q;
    cin >> N >> Q;
    int a[N - 1], b[N -1 ];
    int p[Q], x[Q];
    REP(i, N - 1) cin >> a[i] >> b[i];
    REP(i, Q) cin >> p[i] >> x[i];

    REP(i, N - 1) {
        a[i]--;
        b[i]--;
    }
    REP(i, Q) {
        p[i]--;
    }

    set<int> s[N];
    REP(i, N - 1) {
        s[a[i]].insert(b[i]);
        s[b[i]].insert(a[i]);
    }

    ll score[N];
    REP(i, N) score[i] = 0;
    REP(i, Q) {
        score[p[i]] += x[i];
    }
    bool visited[N];
    REP(i, N) visited[i] = false;
    deque<int> dq;
    dq.push_back(0);
    visited[0] = true;
    while(dq.size() != 0) {
        int parent = dq.front();
        dq.pop_front();
        for (auto itr = s[parent].begin(); itr != s[parent].end(); ++itr) {
            int child = (*itr);
            if (!visited[child]) {
                score[child] += score[parent];
                visited[child] = true;
                dq.push_back(child);
            }
        }
    }

    cout << score[0];
    FOR(i, 1, N) cout << " " << score[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 36096
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+5;
int n,a[3],b[3],mxN;
int f[25000005];
signed main(){
	cin>>n;mxN=n;
	for(int i=0;i<3;++i)
		cin>>a[i];
	for(int i=0;i<3;++i)
		cin>>b[i];
	f[n]=n;
	for(int i=0;i<=25000000;++i)
		f[i]=i;
	for(int i=0;i<3;++i){
		for(int j=a[i];j<=25000000;++j)
			f[j]=max(f[j-a[i]]+b[i],f[j]);
		
	}
	mxN=f[mxN];
//	cout<<mxN<<endl;
	for(int i=0;i<=25000000;++i)
		f[i]=i;
	for(int i=0;i<3;++i){
		for(int j=b[i];j<=25000000;++j)
			f[j]=max(f[j-b[i]]+a[i],f[j]);
		
	}mxN=f[mxN];
	cout<<mxN;
	return 0;
}

Measured memory_bytes: 198944
from collections import defaultdict
n = int(input())
li_a = list(map(int, input().split()))
s = [0] * (n+1)
dd = defaultdict(lambda:0)
for i in range(n):
    s[i+1] += s[i] + li_a[i]
for i in range(n+1):
    dd[s[i]] += 1
ans = 0
for key in dd:
    ans += (dd[key]*dd[key] - dd[key])//2
print(ans)

Measured memory_bytes: 42688
N = int(input())
numlist = list(map(int,input().split()))
numlist.sort()

check = 0
i = 0
while i < N-1:
    j = i + 1
    if numlist[i] == numlist[j]:
        check = 1
        break
    i = i + 1

if check == 1:
    print('NO')
else:
    print('YES')

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) cin >> vec.at(i);

  int M, P, X;
  cin >> M;

  for (int i = 0; i < M; i++) {
    cin >> P >> X;
    cout << accumulate(vec.begin(), vec.end(), 0) - (vec.at(P - 1) - X) << endl;
  }
}

Measured memory_bytes: 256
row = list(map(int, input().split()))
N = row[0]
Y = row[1]
Flag = 0
for x in range(N+1):
    for y in range(N+1):
        z = N - x - y
        if Y == x*10000 + y*5000 + z*1000 and z >= 0:
            print(x, y, z)
            Flag = 1
            break
    if Flag == 1:
        break
if Flag == 0:
    print(-1, -1, -1)

Measured memory_bytes: 3064
n = int(input())

A = [int(x) for x in input().split()]
print(*A)

for i in range(1,n):
    v = A[i]
    j = i-1
    while j>=0 and A[j]>v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(*A)



Measured memory_bytes: 5980
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll a,b;
    cin>>a>>b;

    ll st = 1;
    ll ans = 0;
    while(st<b)
    {
        st=st-1+a;

        ans++;
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
/**
 *    Author: "Robin Singh" !!
 *    rob_in_1
**/

#include <bits/stdc++.h>
using namespace std;

#define dbg( args...) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) { vector<string> v; stringstream ss( s); string x; 
while ( getline( ss, x, c)) v.emplace_back(x); return move(v); }
void err( vector<string>::iterator it) { } 
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t'; err( ++it, args...); }

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define MP make_pair
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     
#define bk(i, j, k) for(int i = j-1; i >= k; i--)
#define mem(ptr, val)  memset(ptr, val, sizeof ptr)
#define sbit(n)  __builtin_popcount(n)
#define nl "\n"

typedef long double ld;
typedef pair<int, int> pii;
typedef vector <int> vi;
typedef vector < pair<int,int> > vpii;
const long double eps = 1e-9;
const int mod = 1e9+7;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

//*********************************!Template Ends Here!**********************************//

const int nn = 1e5+5;
int h[nn], dp[nn];

void robin(){
	int n, k;
	cin >> n >> k;
	
	for(int i=1; i<=n; i++){
		cin >> h[i];
	}
	
	for(int i = 2; i <= n; i++){
		dp[i] = dp[i-1] + abs(h[i] - h[i-1]);

		for(int j = 1; j <= k; j++){
			if(i-j <= 0) break;
			int t = abs(h[i] - h[i-j]) + dp[i-j];
			dp[i] = min(dp[i], t);
		}
	}
	cout << dp[n];
}

int32_t main(){
    // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
    	// cout << "Case #" << tc << ": ";
    	robin();
    }
    return 0;
}

Measured memory_bytes: 1792
import math
A, B = map(float, input().split())
p = max(A/0.08,B/0.1)
q = min((A+1)/0.08,(B+1)/0.1)
if q.is_integer():
    q = q-1
low = math.ceil(p)
high = math.floor(q)
if low>high:
    print(-1)
else:
    print(low)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n;
	scanf("%d", &n);
	vector<int> pos(n + 1);
	for (int i = 0; i < n; ++i) {
		int a;
		scanf("%d", &a);
		pos[a] = i;
	}
	set<int> S = {-1, n};
	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		auto it = S.lower_bound(pos[i]);
		int e = *it - pos[i];
		int s = pos[i] - *prev(it);
		ans += (ll)i * e * s;
		S.insert(pos[i]);
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 10368
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<list>
#define ll long long
using namespace std;
int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll int cnt=0,i;
	string x,y;
	cin>>x>>y;
	for(i=0;i<x.size();i++) 
	if(x[i]!=y[i]) 
	cnt+=1;
	cout<<cnt<<endl;
	return 0;
} 


Measured memory_bytes: 3800
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
 
using namespace std;
 
typedef long long ll;
const int maxn=1e5+7;
const ll mod= 998244353;

struct node{
	ll x,y;
	 
}a[1100];;
bool cmp(node a,node b){
	return atan2(a.x,a.y) < atan2(b.x,b.y);
}
 
int main()
{
//	freopen("input.txt","r",stdin);
	
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++) cin>>a[i].x>>a[i].y;
	sort(a,a+n,cmp);
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		ll x=a[i].x,y=a[i].y;
		ans=max(ans,x*x+y*y);
		for(ll j=(i+1)%n;j!=i;j=(j+1)%n)
		{
			x+=a[j].x,y+=a[j].y;
			ans=max(ans,x*x+y*y);
		}
	}
	double res=sqrt(ans);
	printf("%.13f\n",res);
    
    return 0;
}

















Measured memory_bytes: 256