akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  int W,H,x,y,r;
	
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if(W <= x){
	
		printf("No\n");
	
	}
	else if(W < x+r){
	
		printf("No\n");
	
	}
	else if(H <= y){
	
		printf("No\n");
	
	}
	
	else if(H < y+r){
	
		printf("No\n");
	
	}
	
	else if(x-r < 0){
	
		printf("No\n");
	
	}
	
	else if(y-r < 0){
	
		printf("No\n");
	
	}
	
	else printf("Yes\n");
	
	
	return 0;
}

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

#define int long long
#define DEBUG 0
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;

//??¶?´?????????£???????????? int:INF ll:INFL
#define INFG INFL
using Weight = ll;//int;

class Edge {
public:
	int s; //source
	int d; //destination
	Weight w; //weight
	Edge(int s = 0, int d = 0, Weight w = INFG) : s(s), d(d), w(w) {};
	bool operator<(const Edge &e)const { return w > e.w; }
};
using Edges = vector<Edge>;
//???????????\: g[u].push_back(Edge(u, v, c));
//????????¨???????????????????????°??????????????\?????????????????????
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

//?????¢?´¢, ??¢?´¢???, ??¢?´¢???
enum { WHITE, GRAY, BLACK };

//?´?????????????????§????
//Union-Find??¨
struct UnionFind {
	vector<int> p; //parent
	int s; //size ???????????°
	UnionFind(int n) :p(n, -1), s(n) {}
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (size(x) < size(y)) swap(x, y);
		p[x] += p[y]; p[y] = x; s--;
		return true;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); }
	//?????????????´???°
	int size(int x) { return -p[root(x)]; }
};

//????°???¨?????¨
//Kruskal O(|E|log|E|)
pair<Weight, Edges> kruskal(const Graph &g) {
	UnionFind UF(g.size());
	Edges es;
	for (int i = 0; i < g.size(); i++) for (auto &e : g[i]) es.emplace_back(e);
	sort(es.begin(), es.end());
	Weight total = 0;
	Edges T;
	for (auto &e : es) if (!UF.same(e.s, e.d)) {
		T.push_back(e); total += e.w; UF.unite(e.s, e.d);
	}
	return make_pair(total, T);
}

//????°???¨?????¨
//Prim O(ElogV)
//r????????°?????????????????????????±?
//Edge??? bool operator<(const Edge &e)const { return w > e.w; } ????????????????????????
pair<Weight, Edges> prim(const Graph &g, int r = 0) {
	Edges T; Weight total = 0; vector<int> v(g.size());
	priority_queue <Edge> q;
	q.emplace(-1, r, 0);
	while (q.size()) {
		Edge e = q.top(); q.pop();
		if (v[e.d]) continue;
		v[e.d] = true;
		total += e.w; if (e.s != -1) T.emplace_back(e);
		for (auto &f : g[e.d]) if (!v[f.d]) q.emplace(f);
	}
	return make_pair(total, T);
}

signed main() {
	for (int n; cin >> n&&n;) {
		int m; cin >> m;
		Graph g(n);
		rep(i, 0, m) {
			char c;
			int a, b, d; cin >> a >> c >> b >> c >> d;
			g[a].emplace_back(a, b, d);
			g[b].emplace_back(b, a, d);
		}
		pair<Weight, Edges> k = prim(g, 0);
		cout << k.first / 100 - k.second.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 3532
#include<stdio.h>
int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	char s[55];
	scanf("%s", s);
	int i;
	for (i = 0; i < n; i++)
	{
		if (i != k - 1)
			printf("%c", s[i]);
		else
			printf("%c", s[i] - 'A' + 'a');
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    string weather;
    cin >> weather;
    if(weather == "Sunny")
    cout << "Cloudy" << endl;
    else if (weather == "Cloudy")
    {
        cout << "Rainy" << endl;
    }
    else if (weather == "Rainy")
    {
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = 0
for i in range(n):
    if i > 0 and a[i] == a[i-1]+1:
        ans += b[a[i]-1] + c[a[i-1]-1]
    else:
        ans += b[a[i]-1]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
                using namespace std;
                #define int long long
                #define fi first
                #define se second
                #define pi pair<int,int>  
                #define pb push_back

                // dont forget to initialize global variables inside main() ;
                

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

                int tt=1;       
                
                
                while( tt-- ){
                    int x,k,d;
                    cin>>x>>k>>d;

                    x = abs(x);
                    int a = x/d;
                   // cout<<k*d<<endl;
                    if( a >= k )
                        cout<<x-k*d<<endl;
                    else{
                        
                        if( (k-a)%2==0 )
                            cout<<x%d<<endl;
                        else
                            cout<<d-x%d<<endl;
                    }

                }

                return 0;
            }

                        
         

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

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

	auto ans = 0ll;
	for (auto b = K + 1; b <= N; ++b)
	{
		ans += N / b * (b - K);
		if (K > 0)
		{
			ans += max(0, N % b - K + 1);
		}
		else
		{
			ans += N % b;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))

t = [0] * N
for _ in range(M):
    A, B = map(int, input().split())
    t[A - 1] = max(t[A - 1], H[B - 1])
    t[B - 1] = max(t[B - 1], H[A - 1])

result = 0
for i in range(N):
    if H[i] > t[i]:
        result += 1
print(result)


Measured memory_bytes: 20128
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    var ll = mutableListOf<Int>()
    var rl = mutableListOf<Int>()
    for (i in 0 until m) {
        val (l, r) = readLine()!!.split(" ").map { it.toInt() }
        ll.add(l)
        rl.add(r)
    }
    ll.sort()
    rl.sort()
    println(Math.max((rl.min()!! - ll.max()!! + 1), 0))
}


Measured memory_bytes: 59216
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<bool> flg(26, false);
    rep(i, n) {
        flg[s[i]-'a'] = true;
    }
    rep(i, 26) {
        if (!flg[i]) {
            cout << (char)('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 3720
a,b,c = map(int, input().split())
if a <= b <= c:
    print (a, b, c)
elif a <= c <= b:
    print (a, c, b)
elif b <= a <= c:
    print (b, a, c)
elif b <= c <= a:
    print (b, c, a)
elif c <= a <= b:
    print (c, a, b)
else:
    print (c, b, a)
    
    


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
char s[11];
cin >> s;
int num = strlen(s);
int flg = -1;
int c;
if(s[0]!='A') flg++;
int cnt=0;
REP(i,num-3) {
  if(s[i+2]=='C') {
    cnt++;
    c=i+2;
  }
}
if(cnt!=1) flg++;
REP(i,num) {
  if(i!=0&&i!=c&&isupper(s[i])) {
    flg++;
  }
}
if(flg==-1) { 
  cout << "AC" << endl;
} else {
  cout << "WA" << endl;
}
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
    cin >> n;
    int a,b;
    cin >> a >> b;
    long s[1001];
  	for(int i = a;i <= b;i ++)
    {
     	if(i % n == 0)
        {
          	cout << "OK";
          	return 0;
        }
    }
 	 cout << "NG";
    return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a >= 1 && b >= 1 && c >= 1 && a <= 10000 && b <= 10000
				&& c <= 10000) {
			if (a > b && b < c && c > a) {
				System.out.println(b + " " + a + " " + c);
			} else if (b > a && a > c && b > c) {
				System.out.println(c + " " + a + " " + b);
			} else if (a > b && b > c && a > c) {
				System.out.println(c + " " + b + " " + a);
			} else if ((a > b && b == c)) {
				System.out.println(b + " " + c + " " + a);
			} else if ((b > a && a == c)) {
				System.out.println(a + " " + c + " " + b);
			} else if ((c > b && a == b)) {
				System.out.println(a + " " + b + " " + c);
			} else if ((a > b && b < c && c < a)) {
				System.out.println(b + " " + c + " " + a);
			} else {
				System.out.println(a + " " + b + " " + c);
			}
		}

	}

}



Measured memory_bytes: 26192
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 10e9;
const int MAX_V = 201;

void ChristmasEveEve(){
	int n;
	cin >> n;
	int mp = 0;
	int sum = 0;
	for (size_t i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		sum += a;
		mp = max(mp, a);
	}
	cout << (sum - mp / 2) << endl;

}
int main() {
	ChristmasEveEve();
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int64_t n;
  cin>>n;
  std::vector<int64_t> a(3*n);
  for (int i = 0; i < 3*n; ++i)
  {
    cin>>a[i];
  }
  sort(a.begin(), a.end());
  
  deque<int64_t> deq;
  for(auto&& e: a) {
    deq.push_back(e);
  }
  int64_t ans=0;
  
  for (int i = 0; i < n; ++i)
  {
    deq.pop_front();
    deq.pop_back();
    ans+=deq.back();
    deq.pop_back();
  }
  cout<<ans;
}

Measured memory_bytes: 4992
n,m=map(int,input().split())
ac=[False for i in range(n)]
wa=[0 for i in range(n)]
for i in range(m):
    p,s=input().split()
    p=int(p)
    if s=="WA":
        if ac[p-1]==False:
            wa[p-1]+=1
    elif s=="AC":
        ac[p-1]=True
AC=0
WA=0
for i in range(n):
    if ac[i]==True:
        AC+=1
        WA+=wa[i]
print(AC,WA)

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


bool hantei(string s){
  string t(s.rbegin(),s.rend());
    return s == t;
}

int main() {
  string s;
  cin >> s;
  int n = s.size();
  if(hantei(s)&&hantei(s.substr(0,(n-1)/2))&&hantei(s.substr((n+1)/2)))
    cout << "Yes" <<endl;
  
 else
   cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;cin >> a >> b;
	if(a + b == 3) cout << 3 << endl;
	else if(a + b == 4) cout << 2 << endl;
	else cout << 1 << endl;
}


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

int main(void){
    
    int n, m; cin >> n >> m;
    long long dp[1010][1010];
    for(int i = 0; i <= m; i++){
        for(int j = 0; j <= n; j++){
            dp[i][j] = INF; 
        }
    }
    int d[1010];
    for(int j = 1; j <= n; j++){
        cin >> d[j];
    }

    int c[1010];
    for(int i = 1; i <= m; i++){
        cin >> c[i];
    }

    for(int i = 0; i <= m; i++){
        dp[i][0] = 0;
    }
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++){
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-1] + c[i]*d[j]);
        }
    }
    cout << dp[m][n] << endl;
    return 0;

}

Measured memory_bytes: 11000
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, K;
  cin >> N >> K;
  ll A;
  vl cnt(N, 0);
  rep(i, N){
    cin >> A;
    cnt[A - 1]++;
  }

  stable_sort(cnt.begin(), cnt.end(), greater<ll>());

  ll sum = 0;
  rep(i, K) sum += cnt[i];

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


Measured memory_bytes: 2560
#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 all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    string ans = "CODEFESTIVAL2016";
    string a;
    cin >> a;
    int t = 0;
    rep(i, 16) {
        if (ans[i] != a[i]) {t++;}
    }
    cout << t << endl;

}


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


#define	SIZE	2000000


// up_heap 必要な所まで浮かび上がらせる
void Insert(int *tree, int key, int pos)
{
	int parent = pos / 2;


	while(pos > 1){
		if(tree[parent] < key){
			tree[pos] = tree[parent];
			pos = parent;
			parent = pos / 2;
		}else
			break;
	}
	tree[pos] = key;
}


// down_heap	一番上を一番下(pos)と交換、一番上の値をちょうど良いところまで沈ませる
void Delete(int *tree, int count)
{
	int x;
	int pos;
	int left = 2;


	printf("%d\n", tree[1]);

	x = tree[1] = tree[count--];
	pos = 1;
	while(left <= count){
		if(left + 1 <= count && tree[left] < tree[left + 1])
			left++;

		if(x < tree[left]){
			tree[pos] = tree[left];
			pos = left;
			left = pos * 2;
		}else
			break;
	}
	tree[pos] = x;
}


int main()
{
	int *tree;
	char command[10];
	int key;
	int count;
	int i;

	tree = (int *)malloc(sizeof(int) * SIZE);

	count = 1;
	while(1){
		scanf("%s", command);

		if(!strcmp(command, "insert")){
			scanf("%d", &key);
			Insert(tree, key, count);
			count++;
		}else if(!strcmp(command, "extract")){
			Delete(tree, --count);
		}else if(!strcmp(command, "end")){
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 5708
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int n;
char s[200005];
int white[200005];
int black[200005];
int main(){
	scanf("%d",&n);
	scanf("%s",s);
	white[1] = (s[0] == '.');
	black[n] = (s[n-1] == '#');
	int mini = 212123123;
	for (int i=1;i<n;i++){
		white[i+1] = white[i] + (s[i] == '.');
		black[n-i] = black[n-i+1] + (s[n-i-1] == '#');
	}
	for (int i=0;i<=n;i++){
		mini = min(mini, (n-white[i] - black[i+1])); 
	}
	printf("%d\n",mini);
	return 0;
}

Measured memory_bytes: 1920
#include <stdio.h>
#include <string.h>

int main(void)
{
    char O[51], E[51];
    char *pO = O, *pE = E;
    int n;
    scanf("%s", O);
    scanf("%s", E);
    n = strlen(O) + strlen(E);
    for (int i = 0; i < n; i++) {
        if (i&1) {
            putchar(*pE);
            pE++;
        } else {
            putchar(*pO);
            pO++;
        }
    }
    putchar('\n');
    return 0;
}


Measured memory_bytes: 128
import unittest


class TestB(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think('akasaka'), 'Yes')

    def test_2(self):
        self.assertEqual(think('level'), 'No')

    def test_3(self):
        self.assertEqual(think('atcoder'), 'No')


def solve():
    s = read()
    result = think(s)
    write(result)


def read():
    return read_line()


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(s):
    if not is_palindrome(s):
        return 'No'
    m = len(s) // 2
    if is_palindrome(s[0:m]) and is_palindrome(s[m + 1:]):
        return 'Yes'
    return 'No'


def write(result):
    print(result)


def is_palindrome(s):
    right = len(s) - 1
    for left in range(len(s)):
        if s[left] == s[right]:
            right -= 1
            continue
        return False
    return True


if __name__ == '__main__':
    # unittest.main()
    solve()

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

int w,h;

string mini(string a,string b){
    if(a.size()>b.size()){
        return a;
    }
    if(a.size()<b.size()){
        return b;
    }
    for(int i=0;i<a.size();i++){
        if(a[i]>b[i]) return a;
        if(a[i]<b[i]) return b;
    }
    return a;
}

bool isrange(int i,int j){return 0<=i && i<h && 0<=j && j<w;}

string dfs(int i,int j,vector<string> &c,vector<vector<int>> &check,vector<vector<string>> &dp){
    if(dp[i][j]!="#"){
        return dp[i][j];
    }
    check[i][j]=true;
    string res="";
    string cstr="";
    res+=c[i][j];
    cstr+=c[i][j];
    if(isrange(i+1,j) && isdigit(c[i+1][j])){
        res=mini(res,cstr+dfs(i+1,j,c,check,dp));
    }
    if(isrange(i,j+1) && isdigit(c[i][j+1])){
        res=mini(res,cstr+dfs(i,j+1,c,check,dp));
    }
    return dp[i][j]=res;
}

int main(){
    while(cin>>w>>h,w){
        vector<string> c(h);
        for(int i=0;i<h;i++){
            cin>>c[i];
        }
        string res="0";
        vector<vector<int>> check(h,vector<int>(w,0));
        vector<vector<string>> dp(h,vector<string>(w,"#"));
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(!check[i][j] && isdigit(c[i][j]) && c[i][j]!='0'){
                    res=mini(res,dfs(i,j,c,check,dp));
                }
            }
        }
        cout<<res<<endl;
    }

}

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

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

    int t_zero = INT_MAX;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        int t = l + i - 1;
        ans += t;
        if (abs(t) < abs(t_zero)) {
            t_zero = t;
        }
    }
    ans -= t_zero;
    cout << ans << endl;
}


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

int main(){
  int n, ans=0, m=0, c;
  cin >> n;
  vector<pair<int, int>> a(n), p;
  for(int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
  }
  sort(a.begin(), a.end());
  for(int i = 0; i < n; i++) {
    for(int j = i+1; j < n; j++) {
      p.push_back(make_pair(a[j].first - a[i].first, a[j].second - a[i].second));
    }
  }
  for(int i = 0; i < p.size(); i++) {
    for(int j = 0; j < n; j++) {
      for(int k = j+1; k < n; k++) {
        if(p[i].first == a[k].first - a[j].first && p[i].second == a[k].second - a[j].second)
          ans++;
      }
    }
    m = max(m, ans);   
    ans=0;
  }
  cout << n - m;
}

Measured memory_bytes: 384
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.charset.StandardCharsets;
//给出两个数a,b 求出[a,b]中各位数字之和能整除原数的数的个数。
public class Main {

    int mod ;
    //
    //int[][] dp = new int[1001][1001];
    void solve(long n) {
        long[] fact = new long[17];
        long[] dp = new long[17];
        fact[1] = (long)26;
        fact[0] = (long)1;
        //dp[0] = 0;
        for(int i=1;i<=14;i++){
            fact[i]  = fact[i-1]*26;
            //dp[i] = dp[i-1]+fact[i];
            //System.out.println(i+" " +fact[i]);
        }
        n--;
        long k = n;
        int cnt = 1;
        while(k>=0){
            if(k>=fact[cnt]){
                k-=fact[cnt];
                cnt++;
            }else{
                break;
            }
        }
        //System.out.println(k+" "+cnt);
        helper(fact,cnt,k);

    }
    void helper(long[] fact, int len, long n){
        StringBuilder sb = new StringBuilder();
        for(int i=len;i>=1;i--){
            long idx = n/fact[i-1];
            //System.out.println(idx);
            n -= idx*fact[i-1];
            sb.append((char) ((int)idx+'a'));
        }
        System.out.println(sb);

    }


    public static void main(String[] args)  throws IOException {
        // Use the Scanner class

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[]  s = br.readLine().split(" ");
        Main test = new Main();

        long n = Long.parseLong(s[0]);

        test.solve(n);
        //int tot = Integer.parseInt(br.readLine());


//        int i =1;
//        System.out.println();
//        while(tot>0){
//
//            String s = br.readLine();
//            String[] sr = s.split(" ");
//            List<Long> ls = new ArrayList<>();
//            for(String ss:sr){
//                ls.add(Long.parseLong(ss));
//            }
//            Main tt = new Main();
//            tt.sol(ls);
//            // String Buffer to store answer
//            StringBuffer sb = new StringBuffer();
////            Solution obj = new Solution();
////
////            System.out.println("Case #"+i+": "+obj.sol());
//            tot--;
//            i++;
//        }
    }

}


Measured memory_bytes: 32624
#include<iostream>
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  int a[N + 1];
  a[0] = 0;
  for (int i = 1;i <= N;++ i) cin >> a[i];
  long ans = 0;
  for (int i = 1;i <= N;++ i) {
    ans += max(0, a[i - 1] + a[i] - x);
    a[i] = min(a[i], x - a[i - 1]);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
string op(string x) {
    if (x == "Sunny") {
        return ("Cloudy");
    }
    if (x == "Cloudy") {
        return ("Rainy");
    }
    if (x == "Rainy") {
        return ("Sunny");
    }
    return 0;
}

int main() {
    long long a, b, c = 1;
    cin >> a >> b;
    if (b == 1){
        cout << 0;
        return 0;
    }
    for (int i = 1; i < 100; i++) {
        c += a - 1;
        if (c >= b) {
            cout << i << endl;
            return 0;
        }
    }
}

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

class Parser{
public:
  size_t i;
  string s;
  map<string,int> M;
  int parse(){
    i = 0;
    return Molecule();
  }
  int Molecule(){
    int ret = 0;
    while(i < s.length() && s[i] != ')'){
      if(s[i] == '('){
        ++i;
        int t = Molecule();
        if(t == -1){
          i = s.length();
          return -1;
        }
        ++i;
        if(s[i] >= '0' && s[i] <= '9') t *= Number();
        ret += t;
      }else{
        int t = Atom();
        if(t == -1){
          i = s.length();
          return -1;
        }
        if(s[i] >= '0' && s[i] <= '9') t *= Number();
        ret += t;
      }
    }
    return ret;
  }
  int Atom(){
    string t = string(1,s[i]);
    ++i;
    while(i < s.length() && s[i] >= 'a' && s[i] <= 'z'){
      t += string(1,s[i]);
      ++i;
    }
    //cout << t << " " << M[t] << endl;
    if(M[t] > 0) return M[t];
    else return -1;
  }
  int Number(){
    int ret = 0;
    while(i < s.length() && s[i] >= '0' && s[i] <= '9'){
      ret *= 10;
      ret += s[i] - '0';
      ++i;
    }
    return ret;
  }
};


int main(){
  Parser P;
  string element;
  while(cin >> element, element != "END_OF_FIRST_PART"){
    int w;
    cin >> w;
    P.M[element] = w;
  }
  string molecule;
  while(cin >> molecule, molecule != "0"){
    P.s = molecule;
    int ans = P.parse();
    if(ans == -1) cout << "UNKNOWN" << endl;
    else cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n,vector<int>(m,l));
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>;
#define pint pair<int,int>;
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")

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

	int a, b, c;
	cin >> a >> b >> c;
	if (a + b == c || a + c == b || b + c == a)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	cout << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
#include <utility>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<int> v(s.size());
  v[0] = 0;
  for (int i = 1; i < s.size(); i++) {
    v[i] = v[i - 1];
    if (s[i - 1] == 'A' && s[i] == 'C') v[i]++;
  }

  rep (i, q) {
    int l, r;
    cin >> l >> r;
    P(v[r - 1] - v[l - 1]);
  }

  return 0;
}



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

using namespace std;

#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(),a.end()

const int N = 3e5 + 5;
int n, m, it[N], ans[N];
ii e[N];
vector<int> seg[N];
vector<ii> line[N];

void upd(int i, int val){
	for(; i <= 3e5; i += i & -i) it[i] += val;
}

int get(int i){
	int ans = 0;
	for(; i; i -= i & -i) ans += it[i];
	return ans;
}

main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= n; ++i) cin >> e[i].fi >> e[i].se;
	for(int i = 1; i <= n; ++i) seg[e[i].fi].pb(e[i].se);
	for(int i = 1; i <= m; ++i){
		ans[i] = n;
	}
	for(int i = 1; i <= m; ++i){
		for(int j = 0; j <= m; j += i){
			line[j+1].pb({min(m, i+j-1), i});
		}
	}
	for(int i=m; i; --i){
		for(auto &v : seg[i]) upd(v, 1);
		for(auto &v : line[i]) ans[v.se] -= get(v.fi);
	}
	for(int i=1; i<=m; ++i) cout<<ans[i]<<'\n';
}

Measured memory_bytes: 36340
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v) for (auto &&V : v)
#define all(x) (x).begin(), (x).end()
const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
using lint = long long;

using namespace std;

int count_bit(unsigned long long data) {
  data = (data & 0x5555555555555555) + ((data & 0xAAAAAAAAAAAAAAAA) >> 1);
  data = (data & 0x3333333333333333) + ((data & 0xCCCCCCCCCCCCCCCC) >> 2);
  data = (data & 0x0F0F0F0F0F0F0F0F) + ((data & 0xF0F0F0F0F0F0F0F0) >> 4);
  data = (data & 0x00FF00FF00FF00FF) + ((data & 0xFF00FF00FF00FF00) >> 8);
  data = (data & 0x0000FFFF0000FFFF) + ((data & 0xFFFF0000FFFF0000) >> 16);
  data = (data & 0x00000000FFFFFFFF) + ((data & 0xFFFFFFFF00000000) >> 32);
  return data;
}

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

  int n, m;
  cin >> n >> m;
  vector<vector<int>> light(m);
  vector<int> light_bit(m);
  rep(i, m) {
    int k;
    cin >> k;
    light[i].resize(k);
    int bit = 0;
    rep(j, k) {
      int s;
      cin >> s;
      --s;
      light[i][j] = s;
      bit |= (1 << s);
    }
    light_bit[i] = bit;
  }
  vector<int> p(m);
  rep(i, m) cin >> p[i];
  int count = 0;
  for (int bit = 0; bit < (1 << n); ++bit) {
    bool flag = true;
    rep(j, m) {
      if ((count_bit(bit & light_bit[j]) % 2) != p[j]) {
        flag = false;
        break;
      }
    }
    if (flag) ++count;
  }
  cout << count << endl;
  return 0;
}

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

int main(){
    double L;
    cin >> L;
    
    double ans;

    ans = (L/3.0) * (L/3.0) * (L/3.0);

    // cout << ans << endl;
    printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<bool> vecbool;
typedef vector<vector<int>> vec2int;
typedef pair<int, int> P;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  int n, k;
  cin >> n >> k;
  vecint num(n, 0);
  REP(i, k) {
    int d;
    cin >> d;
    REP(j, d) {
      int a;
      cin >> a;
      a--;
      num[a]++;
    }
  }
  int ans = 0;
  REP(i, n) {
    if (num[i] == 0) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define L long long
using namespace std;
int n;
map<L,int> f;
L p;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j;
	L k=0;
	f[0]=1;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	  {
       scanf("%d",&j);
       k+=j;
       p+=f[k];
       f[k]++;
      }
    printf("%lld\n",p);
	return 0;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }

int N;
int A[20];
int x[20][20];
int y[20][20];

int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

int main(int argc, char const *argv[]) {
  cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> A[i];
        for(int j = 1; j <= A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for(int bits = 1; bits < (1 << N); bits++) {
        bool ok = true;
        for(int i = 1; i <= N; i++) {
            if(!(bits & (1 << (i-1)))) continue;
            for(int j = 1; j <= A[i]; j++) {
                if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
            }
        }
        if(ok) ans = max(ans, counter(bits));
    }
    cout << ans << endl;
  return 0;
}


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

using namespace std;

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

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

void solve()
{
        string a, b, c; cin >> a >> b >> c;
        char turn = a[0];
        a.erase(a.begin());
        while (true)
        {
                //cout << "turn = " << turn << endl;
                if (turn == 'a')
                {
                        turn = a[0];
                        if (a.size() == 0)
                        {
                                cout << "A";
                                return;
                        }
                        a.erase(a.begin());
                }
                else if (turn == 'b')
                {
                        turn = b[0];
                        if (b.size() == 0)
                        {
                                cout << "B";
                                return;
                        }
                        b.erase(b.begin());
                }
                else if (turn == 'c')
                {
                        turn = c[0];
                        if (c.size() == 0)
                        {
                                cout << "C";
                                return;
                        }
                        c.erase(c.begin());
                }
        }
        
}

int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        solve();
}


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

using namespace std;
typedef long long int ll;

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

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

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

// Mod int
const int mod = 1000000007;
struct mint {
  ll x;
  mint() : x(0) {}
  mint(ll x) : x((x % mod + mod) % mod) {}
  // mint(ll x):x(x){}
  mint& fix() {
    x = (x % mod + mod) % mod;
    return *this;
  }
  mint operator-() const { return mint(0) - *this; }
  mint& operator+=(const mint& a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint& a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint& a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint& a) const { return mint(*this) += a; }
  mint operator-(const mint& a) const { return mint(*this) -= a; }
  mint operator*(const mint& a) const { return mint(*this) *= a; }
  bool operator<(const mint& a) const { return x < a.x; }
  bool operator==(const mint& a) const { return x == a.x; }
};
istream& operator>>(istream& i, mint& a) {
  i >> a.x;
  return i;
}
ostream& operator<<(ostream& o, const mint& a) {
  o << a.x;
  return o;
}
typedef vector<mint> vm;
//

void Main() {
  Cin(ll, n);
  Cin(string, s);

  vector<int> c(26);
  for (auto e : s) c[e - 'a']++;

  mint ans = 1;
  for (auto e : c) ans *= e + 1;
  ans -= 1;

  cout << ans << endl;
}

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

Measured memory_bytes: 512
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, C: int, S: str):
    l = [None] * N
    r = [None] * N

    pre = -float('inf')
    k = -1
    for cur in range(N):
        if cur - pre > C and S[cur] == 'o':
            k += 1
            pre = cur
            l[k] = cur

    pre = float('inf')
    k = K
    for cur in range(N-1, -1, -1):
        if pre - cur > C and S[cur] == 'o':
            k -= 1
            pre = cur
            r[k] = cur

    return [ll+1 for ll, rr in zip(l[:K], r[:K]) if ll == rr]
    


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    print(*solve(N, K, C, S), sep='\n')

if __name__ == '__main__':
    main()


Measured memory_bytes: 30392
def main():
    N = int(input())
    a1, b1, c1 = map(int, input().split())
    dp = [[0] * 3 for _ in range(N)]
    dp[0] = [a1, b1, c1]
    
    for i in range(1, N):
        a, b, c = map(int, input().split())
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a
        dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + b
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c
    
    print(max(dp[N-1]))


if __name__ == "__main__":
    main()

Measured memory_bytes: 22772
n,k = map(int,input().split())
li = list(map(int,input().split()))
#print(li)
d = []
for i in range(n-k+1):
    d.append(min(abs(li[i]) + abs(li[k-1+i] - li[i]),abs(li[k-1+i]) + abs(li[k-1+i] - li[i])))
print(min(d))

Measured memory_bytes: 15020
from fractions import gcd
import sys
input = sys.stdin.readline

def main():
    _, m = map(int, input().split())
    a = list(map(int, input().split()))

    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
        if i == 1:
            if (int(x / a[0]) % 2 == 0) or (int(x / a[i]) % 2 == 0):
                print(0)
                return
        else:
            if (int(x / a[i]) % 2 == 0):
                print(0)
                return

    print(int((int(m * 2 / x) + 1) / 2))

if __name__ == '__main__':
    main()

Measured memory_bytes: 16240
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

double dp[10][10];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  I n;
  cin >> n;
  vector<P> vp(n);
  V v(10);
  v.at(2) = 2;
  v.at(3) = 4;
  v.at(4) = 12;
  v.at(5) = 48;
  v.at(6) = 240;
  v.at(7) = 1440;
  v.at(8) = 10080;
  REP(i,n){
    I x,y;
    cin >> x >> y;
    vp.at(i).first = x;
    vp.at(i).second = y;
  }
  double t=0;
  REP(i,n-1){
    for (I j=i+1;j<n;j++){
      dp[i][j] = sqrt(pow(vp.at(i).first - vp.at(j).first,2) + pow(vp.at(i).second - vp.at(j).second,2));
      t += dp[i][j] * v.at(n);
    }
  }
  double an = t/facctorialMethod(n);
  COUTDOUBLE(an, 10);
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define mp make_pair
#define pb push_back
#define MAXN 100010
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n,a,b;
	cin>>n>>a>>b;
	if((b-a)%2==1){
		cout<<"Borys";
	}
	else
		cout<<"Alice";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

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

    int cnt = 0;
    int left = 0;
    rep(i, n){
        if(s[i]=='('){
            cnt++;
        }else{
            if(cnt>0){
                cnt--;
            }else{
                left++;
            }
        }
    }

    rep(i, left) cout << "(";
    rep(i, n) cout << s[i];
    rep(i, cnt) cout << ")";
    cout << endl;
    // printf("%d\n", N);
    return 0;
}

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

int main(){
  int n,sum=0;
  cin >> n;

  int *C,*V;
  C = new int[n];
  V = new int[n];

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

  for(int i=0; i<n; i++){
    cin >> C[i];
    V[i] = V[i] - C[i];
    if( V[i] > 0){
      sum += V[i];
    }
  }

  cout << sum;

  return 0;
}


Measured memory_bytes: 256
H,W=map(int,input().split())
S=[]
for i in range(H):
    S.append(list(input()))
for i in range(len(S)):
    for j in range(len(S[i])):
        a=0
        if S[i][j]=='.':
            for k in range(i-1,i+2):
                for l in range(j-1,j+2):
                    if (0<=k and k<=len(S)-1) and (0<=l and l<=len(S[i])-1) and S[k][l]=='#':
                        a+=1
            S[i][j]=str(a)
for i in range(len(S)):
    print(''.join(S[i]))

Measured memory_bytes: 81660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    while(true){
        int n;
        cin >> n;
        if(!n) break;
        vector<ll> way(31);
        way[0] = 1;
        way[1] = 1;
        way[2] = 2;
        for(int i = 3; i <= n; i++){
            way[i] = way[i - 1] + way[i - 2] + way[i - 3];
        }
        int total = way[n];
        cout << ((total + 9) / 10 + 364) / 365 << endl;
    }
}


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

int gcd(int a, int b) {
    int r = a % b;
    return r ? gcd(b, r) : b;
}

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

    int N; cin >> N;
    int ans; cin >> ans;
    for (int i = 1; i < N; i++) {
        int A; cin >> A;
        ans = gcd(ans, A);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    ll N; cin >> N;
    map<int,int> mp;
    vector<int> v;
    REP(i,16) {
        v.push_back(i*(i+1)/2);
        //cerr << v.back() << endl;
    }
    

    for (ll i = 2; i * i <= N; i++) {
        if (N % i == 0) {
            while(N % i == 0) {
                mp[i]++;
                N /= i;
            }
        }
    }
    if (N != 1) {
        mp[N]++;
    }

    ll ans = 0;
    for (auto p:mp) {
        auto it = lower_bound(ALL(v),p.second);
        ll d = distance(v.begin(),it);
        if (*it > p.second) d--;
        ans += d;
        //cerr << p.first << " " << p.second << " " << *it << " " << ans << endl;
    }
    OUT(ans);

    return 0;
}

Measured memory_bytes: 3644
class ConvexHullTrick:
	def __init__(self):
		self.AB = []

	def check(self,a,b):
		a1,b1 = self.AB[-1][0],self.AB[-1][1]
		a2,b2 = self.AB[-2][0],self.AB[-2][1]
		lhs = (b2-b1)*(a -a1)
		rhs = (b1-b )*(a1-a2)
		return lhs>=rhs

	# 一次関数 y=a*x+b を追加
	# 追加の際、傾きaは単調減少（既存の傾きより最小？）であること
	def append(self,a,b):
		while 2<=len(self.AB) and self.check(a,b):
			self.AB.pop()
		self.AB.append((a,b))
		return
	# min_i {a[i]*x+b[i]}
	def query(self,x):
		def eval(ab,x):
			return ab[0]*x+ab[1]
		l,r = -1, len(self.AB)-1
		while l+1<r:
			m = (l+r)//2
			if eval(self.AB[m+1],x)<=eval(self.AB[m],x):
				l = m
			else:
				r = m
		return eval(self.AB[r],x)

N,C = map(int,input().split())
h = list(map(int,input().split()))
#print(h)

cht = ConvexHullTrick()

dp = [0]*N
dp[0] = 0
cht.append(-2*h[0],h[0]**2+dp[0])
for i in range(1,N):
	#best = 99999999999999
	# for j in range(i):
	# 	#cost = dp[j]+(h[i]-h[j])**2+C
	# 	cost = (-2*h[j])*h[i]+(h[j]**2+dp[j])
	# 	best = min(best,cost)
	best = cht.query(h[i])
	dp[i] = best+h[i]**2+C

	cht.append(-2*h[i],h[i]**2+dp[i])

ans = dp[N-1]
print(ans)


Measured memory_bytes: 95308