akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
	int N;
  	cin >> N;
  	vector<int> a(N);
  	rep(i,N) cin >> a[i];
  	sort(a.begin(), a.end());
  	cout << a[N-1]-a[0] << endl;
	return;
}

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

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

using namespace std;
typedef long long ll;

int simen[201];

int dp1[2][1000001];
int dp2[2][1000001];

int main()
{
	for(int i=1;i<201;i++)
	{
		simen[i]=i*(i+1)*(i+2)/6;

	}
	fill(dp1[0],dp1[1],1e8-1);
	dp1[0][0]=0;
	for(int i=1;i<201;i++)
	{
		for(int j=0;j<1000001;j++)
		{
			if(j<simen[i])
				dp1[i&1][j]=dp1[(i-1)&1][j];
			else
				dp1[i&1][j]=min(dp1[i&1][j-simen[i]]+1,dp1[(i-1)&1][j]);
		}
	}
	fill(dp2[0],dp2[1],1e8-1);
	dp2[0][0]=0;
	for(int i=1;i<201;i++)
	{
		for(int j=0;j<1000001;j++)
		{
			if(simen[i]%2==0 || j<simen[i])
				dp2[i&1][j]=dp2[(i-1)&1][j];
			else
				dp2[i&1][j]=min(dp2[i&1][j-simen[i]]+1,dp2[(i-1)&1][j]);
		}
	}

	while(1)
	{
		int n;
		cin>>n;
		if(n==0)
			break;
		cout<<dp1[0][n]<<" "<<dp2[0][n]<<endl;
	}
	return 0;
}


Measured memory_bytes: 18628
a,b,c,x,y=map(int,input().split())
if a+b<2*c:
    print(x*a+y*b)
else:
    ans=2*c*min(x,y)
    if x>y:
        x=x-y
        if a<2*c:
            ans=ans+x*a
        else:
            ans=ans+x*2*c
    else:
        y=y-x
        if b<2*c:
            ans=ans+y*b
        else:
            ans=ans+y*2*c
    print(ans)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int a;
    vector<int> v;
    for (int i=0;i<N;i++){
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    cout << v.back() - v.front() << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

# debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    A, B = LI()

    print(max(0, A-2*B))

solve()

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<iomanip>
#include<string>
#include<string.h>
#include<cctype>
using namespace std;
int main()
{
    long long int n,d,x,y;
    int count=0;
    cin>>n>>d;
    while(n--)
    {
        cin>>x>>y;
        if(((x*x)+(y*y))<=(d*d))
            count++;


    }
    cout<<count;













    return 0;
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define dump(x) cerr<<#x<<": "<<x<<endl
#define debug(x) cerr<<#x<<": "<<x<<" ("<<__LINE__<<")"<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;
using ll = long long;
using vll = vector<ll>;

int main() {
    int h, w; cin >> h >> w;
    vstring a(h+2, "");
    rep(i, w) {
        a[0] += ".";
        a[h+1] += ".";
    }
    FOR(i, 1, h+1) {
        string s; cin >> s;
        a[i] = "." + s + ".";
    }
    FOR(y, 1, h+1) {
        FOR(x, 1, w+1) {
            if(a[y][x] == '#' && a[y+1][x-1] == '#') {
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }
    cout << "Possible" << endl;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
 
using namespace std;
 
int main(){
    double x1,x2,x3,y1,y2,y3,xp,yp;
    double calc1,calc2,calc3;
 
    while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
        calc1 = (x2-x1)*(yp-y1)-(y2-y1)*(xp-x1);
        calc2 = (x3-x2)*(yp-y2)-(y3-y2)*(xp-x2);
        calc3 = (x1-x3)*(yp-y3)-(y1-y3)*(xp-x3);
 
        if((calc1>0&&calc2>0&&calc3>0) || (calc1<0&&calc2<0&&calc3<0)){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2616
#include<bits/stdc++.h>
#define re register
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int a,b,c,d;
int main(){
	a=read();b=read();c=read();d=read();
	b=(c-1)/b+1;d=(a-1)/d+1;
	if(b<=d)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

int main(){
	ll n;
	cin >> n;
	ll res  = 1000 - (n%1000);
	if (res == 1000) res = 0;
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 3616
from sys import stdin
a = int(stdin.readline().rstrip())
b = int(stdin.readline().rstrip())
c = int(stdin.readline().rstrip())
x = int(stdin.readline().rstrip())
ans = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1

print(ans)

Measured memory_bytes: 40048
#include<stdio.h>
#define MAX 100000
int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}
int main()
{
  int H,i,A[MAX+1];
  scanf("%d",&H);
  for(i=1;i<=H;i++)
    {
      scanf("%d",&A[i]);
    }
  for(i=1;i<=H;i++)
    {
      printf("node %d: key = %d, ",i,A[i]);
      if(parent(i)>=1)
	printf("parent key = %d, ",A[parent(i)]);
      
      if(left(i)<=H)
	printf("left key = %d, ",A[left(i)]);
    
      if(right(i)<=H)
	printf("right key = %d, ",A[right(i)]);
      
      printf("\n");
    }
  return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#include<string>
using namespace std;
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define init(arr,value) memset(arr,value,sizeof(arr))
#define test unsigned int tet;cin >> tet;while(tet--)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define sf scanf 
#define pf printf 
int max(int a,float b){
    if(a>b)
       return a;
    return b;
}
ll gcd(ll a,ll b){
    if(a%b==0)
        return b;
    else
        return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a*b/gcd(max(a,b),min(a,b));
}
bool sort_pair(pair<int,int>a,pair<int,int> b){
   return a.first>b.first;
}
bool sort_pair_(pair<int,int>a,pair<int,int>b){
    return a.second>b.second;
}
bool isprime(int x){
    for(int i=2;i<=sqrt(x);i++){
        if(x%i==0)
        return 0;
    }
    return 1;
}
bool prime[100002];
int main() {
    int t;
    sf("%d",&t);
    int x=t/1000;
    if(t%1000==0){
        pf("%d",0);
    }
    else{
        pf("%d",(x+1)*1000-t);
    }
    
}



Measured memory_bytes: 3760
import sys
input=sys.stdin.readline

def main():
    n,t=map(int,input().split())
    AB=[list(map(int,input().split())) for _ in range(n)]
    AB.sort(key=lambda x: (x[0],-x[1]))
    DP=[[0]*(6001) for _ in range(n+1)]
    for i,(a,b) in enumerate(AB):
        for j in range(1,6001):
            if j<a:
                DP[i+1][j]=max(DP[i][j],DP[i+1][j-1])
            elif j-a<t:
                DP[i+1][j]=max(DP[i][j],DP[i+1][j-1],DP[i][j-a]+b)
            else:
                DP[i+1][j]=max(DP[i][j],DP[i+1][j-1])
    print(max(DP[-1]))
    
if __name__=='__main__':
    main()

Measured memory_bytes: 181596
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  int N, sum = 0;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++)
  {
    cin >> d.at(i);
  }

  for (int i = 0; i < N - 1; i++)
  {
    for (int j = i + 1; j < N; j++)
    {
      sum += d[i] * d[j];
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3100
const log = console.log;

const parseLines = (s: string) => s.trim().split("\n");
const parseSpaceSeparated = (line: string) => line.trim().split(" ");
const parseDecimalInt = (s: string) => parseInt(s);
const parseSpaceSeparatedDecimalInt = (line: string) =>
  parseSpaceSeparated(line).map(parseDecimalInt);

const ascendingSorter = (a: number, b: number) => a - b;

const accumulateLimited = (numArray: number[], limit: number) => {
  let sum = 0;
  let count = 0;

  for (const currentNum of numArray) {
    const nextSum = sum + currentNum;
    if (nextSum > limit) break;
    sum = nextSum;
    count += 1;
  }

  return { amount: sum, count };
};

// ----

function Main(input: string): void {
  const [head, body] = parseLines(input);
  const [n, x] = parseSpaceSeparatedDecimalInt(head);
  const a = parseSpaceSeparatedDecimalInt(body);

  a.sort(ascendingSorter);

  const maxSum = accumulateLimited(a, x);
  let satisfiedCount = maxSum.count;

  // last child not satisfied
  if (satisfiedCount === a.length && maxSum.amount < x) satisfiedCount -= 1;

  log(satisfiedCount);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
  cout.tie(0);
  int d,t,s;
  cin>>d>>t>>s;
  if((t*s)>=d)
  	cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 3612
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: u128};

    let sqrt_n = (n as f64).sqrt() as usize + 1;

    let mut dis = std::u128::MAX;

    for i in 1..sqrt_n {
        if n % i as u128 == 0 {
            let x = n / i as u128;
            dis = std::cmp::min(dis, x + i as u128 - 2)
        }
    }

    println!("{}", dis);
}


Measured memory_bytes: 2200
import math

# print(math.sqrt(4**2 + 3**2 - 2*4*3*math.cos(math.radians(90))))



A, B, H, M = [float(i) for i in input().split(' ')]
# print("A:", A, "B:", B, "H:", H, "M:", M)
a = H*30+M*0.5
b = M*6
X = abs(a - b)
kaku = min(X, 360 - X)


print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(kaku))))

Measured memory_bytes: 9288
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    s = input()
    s=s[::-1]

    t = ["dream", "dreamer", "erase", "eraser"]
    table = [ti[::-1] for ti in t]

    while len(s) > 0:
        flg = True
        for ti in table:
            if s[:len(ti)] == ti:
                s = s[len(ti):]
                flg = False
                break
        if flg:
            break

    print("YES" if len(s) == 0 else "NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 13676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int K = 1e5+9;
ll r[K];
inline ll read() {
    ll s = 1, a = 0; char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-') s = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') {a = a * 10 + ch - '0'; ch = getchar();}
    return s * a;
}
inline void turn(ll &v, ll x) {
    if (v < 0) v = 0;
    if (v > x) v = x;
}
int main() {
    ll x = read(), k = read();
    for (int i = 1; i <= k; i++) r[i] = read();
    ll q = read();
    ll low = 0, mid = 0, upp = x;
    int i = 1, sign = -1;
    while (q--) {
        ll t = read(), a = read();
        while (i <= k && r[i] <= t) {
            ll dta = (r[i] - r[i - 1]) * sign;
            low += dta, upp += dta, mid += dta;
            turn(low, x), turn(upp, x);
            i++, sign *= -1;
        }
        ll res = a + mid;
        ll dta = (t - r[i - 1]) * sign;
        if (res < low) res = low;
        if (res > upp) res = upp;
        res += dta, turn(res, x);
        printf("%lld\n", res);
    }
    return 0;
}

Measured memory_bytes: 2048
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

constexpr ll INF = 1e16;

#define rep(i, N) for(ll i=0; i<N; ++i)

ll max(ll a, ll b) {return a < b ? b : a; }
ll min(ll a, ll b) {return a > b ? b : a; }
double maxf(double a, double b) { return a < b ? b : a; }

int main() {
  int n, k;
  int ans = 0;

  cin>>n>>k;
  while(n > 0){
    n/=k;
    ans++;
  }

  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main{
    public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
      		String str = sc.nextLine();
      		for(int i=str.length()-1; i>=0; i--){
              System.out.print(str.charAt(i));
            }
              System.out.println();
    }
}



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

using namespace std;
typedef long long ll;

int main() {
  string s,t;
  cin >> s;
  cin >> t;
  
  int c=0;
  int size;
  size = s.size();
  for(int i=0;i<size;++i){
    if(s[i]!=t[i]) c++;
  }
  cout<<c<<endl;


}

Measured memory_bytes: 3888
#include <cstdio>
#include <cstring>

int main() {
  int n;
  while (true) {
    scanf("%d", &n);
    if (n == 0) break;
    int cnt = 0;
    bool ru = false, lu = false;
    for (int i=0;i<n;i++) {
      char f[3]; scanf("%s", f);
      if (!strcmp(f,"lu")) lu = true;
      else if (!strcmp(f,"ru")) ru = true;
      else if (!strcmp(f,"ld")) lu = false;
      else ru = false;
      if (lu == ru && (lu & ru) == !(cnt & 1)) cnt++;
    }
    printf("%d\n", cnt);
  }
  return 0;
}

Measured memory_bytes: 2676
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int sum = a + b + c;
  cout << sum - max(a, max(b, c)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>

int main() {

    int N, M;
    std::cin >> N >> M;


    std::cout << ((N * (N - 1)) / 2) + ((M * (M - 1)) / 2) << "\n";


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;

int func(int n){
    int cnt=0;
    while(n>0){
        n/=10;
        cnt++;
    }
    return cnt;
}
int main(){
int n;
string s;
cin>>n;
int ans=0;
for (int i = 1; i <= n; i++)
{
    int a=func(i);
    if(a%2==1){
        ans++;
    }
}
cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
	string S;
	int a , b, c , d,e;
	cin>>a>>b;
	c=b-a+1;
	for (int i = 1; i < c; i++) {
		d=d+i;
	}
	e=d-b;
	cout<<e<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int t[210000];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		int p;scanf("%d",&p);
		t[p-1]++;
	}
	std::sort(t,t+a);
	int ret=0;
	for(int i=0;i<a-b;i++)ret+=t[i];
	printf("%d\n",ret);
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define MIN(a, b) (((a) > (b)) ? (b) : (a))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int main() {
	int N;
	cin >> N;
	N *= 2;
	vector<int> L(N);
	for(int i = 0; i < N; i++) {
		cin >> L[i];
	}
	sort(L.begin(), L.end());
	int S = 0;
	for(int i = 0; i < N; i++) {
		S += MIN(L[2 * i], L[2 * i + 1]);
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int N, K;
  cin >> N >> K;
  vector<ll> h(N);
  rep(i, N)
  {
    cin >> h[i];
  }
  sort(h.begin(), h.end());
  int ans = 1e9;
  for (int i = 0; i < N - K + 1; i++)
  {
    int tmp = h[i + K - 1] - h[i];
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<=ll(b);++i)
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define which(flag,msg1,msg2) cout<<((flag)? msg1:msg2);

#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
map<char,int> 
count_same_elements(const vector<char>& v){map<char,int>cmap; for_each(v.begin(),v.end(),[&cmap](int x){cmap[x]++;}); return cmap; }
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A> bool
all_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]<1){flag=false;}; }return flag;}
template<class A> bool
any_of(const vector<A>& v){bool flag=false;rep(i,v.size()){ if(v[i]>0){flag=true; break;}; }return flag;}
template<class A> bool
none_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]>0){flag=false;}; }return flag;}
template<class T>
void scan_vector(long long size,vector<T>& vector){
    vector.resize(size);
    for(long long i=0;i<size;++i){
        cin>>vector[i];
    }
}
// 約数列挙
template <class T>
vector< T > divisor(T n) {
    vector< T > ret;
    for(T i = 1; i * i <= n; i++) {
        if(n % i == 0) {
        ret.push_back(i);
        if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

ll n,x;
string s,t;
void input(){
    cin>>n;
}
void src(){
    ll cnt=0;
    repi(i,105,n){
        if(i%2==1){
            auto m=divisor(i);
            if(m.size()==8) cnt++;
        }
    }
    cout<<cnt;
}   

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

const int N = 110000;
const int L = 32;

int a[N];
int nxt[N][L];

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n; cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	int LL; cin >> LL;
	for (int i = 1; i <= n; i++) nxt[i][0] = upper_bound(a + 1, a + n + 1, a[i] + LL) - a - 1;
	for (int j = 1; j < L; j++) {
		for (int i = 1; i <= n; i++) nxt[i][j] = nxt[nxt[i][j - 1]][j - 1];
	}
	int q; cin >> q;
	while (q--) {
		int l, r; cin >> l >> r;
		if (l > r) swap(l, r);
		long long ans = 0;
		for (int i = L - 1; i >= 0; i--) {
			if (nxt[l][i] < r) ans += 1LL << i, l = nxt[l][i];
		}
		cout << ans + 1 << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 13696
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include<unordered_map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define mod 1000000007
#define endl ("\n")
#define pi (3.141592653589)
#define mod 1e9+7
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,n) for(int i=0;i<n;i++)
//obtained in which function and that gets added up.

void solve()
{
    string s;
    cin>>s;
    char a='R';
    char b='S';
    int c=0;
    for(int i=0; i<s.length();)
    {
        if(s[i]==a)
        {
            int y=0;
            while(s[i]==a)
            {


                y++;
                i++;
                c=max(c,y);
            }
        }
        else
        {
            i++;
        }

    }
    cout<<c<<endl;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    {

        solve();
    }
}


Measured memory_bytes: 3636
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 1; i <= n * 2; i++)
			list.add(i);
		for (int i = 0; i < m; i++) {
			List<Integer> tmp = new ArrayList<Integer>();
			int a = scanner.nextInt();
			if (a == 0) {
				for (int j = 0; j < n; j++) {
					tmp.add(list.get(j));
					tmp.add(list.get(j + n));
				}
			} else {
				for (int j = 0; j < n * 2; j++) {
					tmp.add(list.get((j + a) % (n * 2)));
				}
			}
			list = tmp;
		}
		for (int ans : list)
			System.out.println(ans);
	}
}

Measured memory_bytes: 26680
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
string s;
ll power[100005];
ll powe(ll a,ll b){
	ll res=1;
	while(b>0){
		if(b%2){
			res*=a;
			res%=mod;
		}
		a*=a;
		a%=mod;
		b/=2;
	}
	return res;
}
int main(){
	std::ios::sync_with_stdio(false);
	ll i,q=0,a,b,c,ab,bc,reqb,val=0,res=0,ans=0,q1;  
	cin>>s;
	rep(i,s.length()+2){
		power[i]=i>0?power[i-1]*3LL:1;
		power[i]%=mod;
	}	
	a=0;
	c=0;
	ab=0;
	rep(i,s.length()){
		if(s[i]=='?'){
			q++;
			continue;
		}
		if(s[i]=='A'){
			a++;
		}
		if(s[i]=='B'){
			//b++;
			ab+=a;
			ab%=mod;
		}
		if(s[i]=='C'){
			c++;
			ans+=ab;
			ans%=mod;
		}
	}
	res=ans;
	res*=power[q];
	res%=mod;
	//cout<<res<<endl;
	if(q>=1){
		a=0;
		ab=0;
		ans%=mod;
		ans=0;
		//cout<<c<<endl;
		rep(i,s.length()){
			if(s[i]=='?'){
				ans+=a*c;
				ans%=mod;
				ans+=ab;
				ans%=mod;
			}
			if(s[i]=='A'){
				a++;
			}
			if(s[i]=='C'){
				c--;
			}
			if(s[i]=='B'){
				ab+=a;
				ab%=mod;
			}
		}
		c=0;
		bc=0;
		fd(i,s.length()-1,0){
			if(s[i]=='?'){
				ans+=bc;
				ans%=mod;
			}
			if(s[i]=='C'){
				c++;
			}
			if(s[i]=='B'){
				bc+=c;
				bc%=mod;
			}
		}
		//cout<<ans<<endl;
		res+=ans*power[q-1];
		res%=mod;
	}
	if(q>=3){
		val=q*(q-1);
		val%=mod;
		val*=q-2;
		val%=mod;
		val*=powe(6,mod-2);
		val%=mod;
		val*=power[q-3];
		val%=mod;
		res+=val;
		res%=mod;
	}
	if(q>=2){
		a=0;
		q1=q;
		ans=0;
		rep(i,s.length()){
			if(s[i]=='?'){
				q1--;
				ans+=q1*a;
				ans%=mod;
			}
			if(s[i]=='A'){
				a++;
			}
		}
		q1=q;
		c=0;
		fd(i,s.length()-1,0){
			if(s[i]=='?'){
				q1--;
				ans+=q1*c;
				ans%=mod;
			}
			if(s[i]=='C'){
				c++;
			}
		}
		reqb=0;
		b=0;
		q1=q;
		int fl=0;
		fd(i,s.length()-1,0){
			 if(s[i]=='?'){
			 	val=(q-q1)*q1;
			 	val%=mod;
			 	ans+=val*b;
			 	ans%=mod;
			 	b=0;
			 	q1--;

			 }
			 if(s[i]=='B'){
			 	b++;
			 }
		}
		res+=ans*power[q-2];
		res%=mod;
	}
	cout<<res<<endl;
} 
	

Measured memory_bytes: 1232
# sys.stdin.readline
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        S = input().rstrip()
        dp = [False] * (len(S) + 1)

        words = ["dream", "dreamer", "erase", "eraser"]

        dp[0] = True
        for i in range(len(S)):
            if not dp[i]:
                continue
            for word in words:
                if S[i:i + len(word)] == word:
                    dp[i + len(word)] = True

        print('YES' if dp[len(S)] else 'NO')


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 41456
//

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

int main(){
	double R;
	cin >> R;

	double ans = M_PI * R * 2.0;

	cout << fixed << setprecision(10);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3776
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)


typedef long long int ll;
typedef double D;      // ??§?¨?????????????double???long double?????????
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;


const int INF = (1<<30) - 1;
const D EPS = 1e-9;

#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

int N, W;

void solve(){
    vector<int> occurs(15);
    for(int i=0; i<N; i++){
        int v; cin >> v;
        occurs[v/W]++;
    }
    int m = 0;
    for(int o: occurs)
        m = max(m, o);
    
    int leftmost = 15-1;
    while(occurs[leftmost] == 0) leftmost--;
    double ans = 0;
    for(int i=0; i<=leftmost; i++){
        ans += occurs[i] * (leftmost-i) / double(leftmost) / m;
    }
    printf("%.7lf\n", ans+0.01);
}

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    while(cin>>N>>W, N|W)
        solve();
    
    return 0;
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

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

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      abcs: [[usize; 3]; n],
    }
    let mut dp = vec![vec![0; n]; 3];
    dp[0][0] = abcs[0][0];
    dp[1][0] = abcs[0][1];
    dp[2][0] = abcs[0][2];

    for i in 1..n {
        dp[0][i] = max(
            dp[1][i-1] + abcs[i][0],
            dp[2][i-1] + abcs[i][0],
        );

        dp[1][i] = max(
            dp[0][i-1] + abcs[i][1],
            dp[2][i-1] + abcs[i][1],
        );

        dp[2][i] = max(
            dp[0][i-1] + abcs[i][2],
            dp[1][i-1] + abcs[i][2],
        );
    }
    let mut ans = dp[0][n-1];
    for i in 0..3 {
        ans = max(ans, dp[i][n-1]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 14588
#include <iostream>
#include <queue>
#include <vector>
#define INF 1000000000000

using namespace std;
using llong = long long;
using P = pair<llong,int>;
vector<P> graph[100000];
llong dist[100000];

int main(){
  int n,m,r;

  cin >> n >> m >> r;
  for(int i=0;i<m;++i){
    int s,t,d;
    cin >> s >> t >> d;
    graph[s].emplace_back(d,t);
  }

  priority_queue<P,vector<P>,greater<P>> q;

  for(int i=0;i<n;++i){
    dist[i] = INF;
    q.push(P(0,r));
  }

  while(!q.empty()){
    auto p = q.top();q.pop();
    int v = p.second;
    llong w = p.first;
    if(dist[v]!=INF) continue;
    dist[v] = w;
    for(auto &next_p:graph[v]){
      int next_v = next_p.second;
      if(dist[next_v]!=INF) continue;
      q.push(P(w+next_p.first,next_v));
    }
  }

  for(int i=0;i<n;++i){
    if(dist[i]!=INF){
      cout << dist[i] << endl;
    }else{
      cout << "INF" << endl;
    }
  }

}

Measured memory_bytes: 21484
import sys
 
N, A, B = map(int,input().split())
 
ans = 0
 
if N < A:
  print(N)
  sys.exit()
 
if N < A+B:
  print(A)
  sys.exit()
 
if N%(A+B) <A:
  print((A*(N//(A+B))) + (N%(A+B)))
else:
  print((A*(N//(A+B))) + A)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;

using vec=vector<ll>;
using mat=vector<vec>;

vec mul(vec &a,vec &b)
{
  vec res(a.size());
  rep(i,a.size())
  {
    res[i]=b[a[i]];
  }

  return res;
}

vec pow(vec &a,ll n)
{
  vec b(a.size());
  for(ll i=0;i<a.size();i++)
  {
    b[i]=i;
  }
  while(n>0)
  {
    if(n&1)b=mul(a,b);
    a=mul(a,a);
    n>>=1;
  }
  return b;
}
int  main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin>>n;
  vec x(n);
  vec dx(n-1);
  rep(i,n)cin>>x[i];
  rep(i,n-1)
  {
    dx[i]=x[i+1]-x[i];
  }


  ll m,k;
  cin>>m>>k;
  vector<ll> nx(n-1);
  rep(i,n-1)nx[i]=i;
  rep(i,m)
  {
    ll a;cin>>a;
    a--;
    swap(nx[a-1],nx[a]);
  }
  vec t=pow(nx,k),dans=mul(t,dx);
  cout<<x[0]<<endl;
  ll cnt=x[0];
  rep(i,n-1)
  {
    cnt+=dans[i];
    cout<<cnt<<"\n";
  }
  cout<<flush;


  return 0;

}


Measured memory_bytes: 5200
count = STDIN.gets.chomp.to_i

while count != 0
	sannpenn = STDIN.gets.chomp.split("\s")
	sannpenn.map!{|item| item.to_i}
	sannpenn.sort!
	count += -1
	if (sannpenn[0]**2 + sannpenn[1]**2) == sannpenn[2]**2
		puts "YES"
		else
		puts "NO"
	end

end

Measured memory_bytes: 6100
using System;

public class Hello
{
    public static void Main()
    {
        var dx = new int[] { 0, 1, 0, -1 };
        var dy = new int[] { 1, 0, -1, 0 };
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var w = int.Parse(line[0]);
            var h = int.Parse(line[1]);
            if (w == 0 && h == 0) break;
            var map1 = new int[h, w]; var map2 = new int[h, w];
            for (int i = 0; i < h; i++)
            {
                var s = Console.ReadLine().Trim();
                for (int j = 0; j < w; j++)
                    if (s[j] == 'B') { map1[i, j] = 1; map2[i, j] = 1; }
                    else if (s[j] == 'W') { map1[i, j] = 2; map2[i, j] = 2; }
            }
            var found = false;
            for (int i = 0; i < h; i++)
                for (int j = 0; j < w; j++)
                {
                    if (map1[i, j] == 1) { goDfs(map1, dx, dy, i, j); found = true; }
                    if (map2[i, j] == 2) { goDfs(map2, dx, dy, i, j); found = true; }
                }
            if (!found) { Console.WriteLine("0 0");  goto end; }
            var wcount = 0; var bcount = 0;
            for (int i = 0; i < h; i++)
                for (int j = 0; j < w; j++)
                {
                    if (map1[i, j] == 0) wcount++;
                    if (map2[i, j] == 0) bcount++;
                }
            Console.WriteLine("{0} {1}", bcount, wcount);
            end:;
        }
    }
    public static void goDfs(int[,] map, int[] dx, int[] dy, int x, int y)
    {
        var h = map.GetLength(0); var w = map.GetLength(1);
        if (map[x, y] == 0) map[x, y] = 10;
        for (int i = 0; i < 4; i++)
        {
            var nx = x + dx[i];
            var ny = y + dy[i];
            if (nx >= 0 && nx < h && ny >= 0 && ny < w && map[nx, ny] == 0)
                goDfs(map, dx, dy, nx, ny);
        }
    }
}

Measured memory_bytes: 9332
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		String s = sc.next();
		String str;
		if(k >= s.length()) str = s;
		else {
			str = s.substring(0, k);
			str += "...";
		}
		System.out.println(str);
	}
}

Measured memory_bytes: 38620
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int x;
    cin >> x;
    int ans = 0;
    if (x == 1){
        cout << 1 << endl;
    } else {
        for (int b = 2; b < x; b++){
            for (int p = 2; p < 10; p++){
                if (ans <= pow(b, p) && pow(b, p) <= x)ans = pow(b,p);
            }
        }
        cout << ans << endl;
    }
   
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
 
 
const double EPS=1e-6;
const double INF=1e10;
 
typedef complex<double> Point;
typedef complex<double> Vector;
 
struct Line
{
    Point a, b;
    Line() {}
    Line(const Point &_a, const Point &_b)
    {
        a = _a; b = _b;
    }
};
 
//Line????????????
struct Segment
{
    Point a, b;
    Segment() {}
    Segment(const Point &_a, const Point &_b)
    {
        a = _a; b = _b;
    }
};
 
istream& operator >> (istream& is, Point &p)
{
    double x, y;
    is >> x >> y;
    p.real(x); p.imag(y);
    return is;
}
 
Segment ToSegment(const Line l)
{
    return Segment(l.a, l.b);
}
 
Line ToLine(const Segment s)
{
    return Line(s.a, s.b);
}
 
double dot(const Vector &a, const Vector &b)
{
    return a.real()*b.real() + a.imag()*b.imag();
}
 
double cross(const Vector &a, const Vector &b)
{
    return a.real()*b.imag() - a.imag()*b.real();
}
 
double GetDistance(const Line &l, const Point &p)
{
    return abs(cross(l.a - l.b, p - l.a) / abs(l.b - l.a));
}
 
double GetDistance(const Segment &s, const Point &p)
{
    if (dot(s.b - s.a, p - s.a) < 0.0) return abs(p - s.a);
    if (dot(s.a - s.b, p - s.b) < 0.0) return abs(p - s.b);
    return GetDistance(ToLine(s), p);
}
 
 
 
int N,M;
Point p[11111];
bool used[11111];
double dist[11111];
signed main(){
    cin>>N>>M;
    rep(i,N+1)cin>>p[i];
 
    used[0]=true;
    double ans=0;
    rep(i,N+1)dist[i]=abs(p[i]-p[0]);
    rep(t,M){
        int mi=-1;
        for(int i=N;i>=0;i--){
            if(used[i])continue;
            if(mi==-1)mi=i;
            else if(dist[mi]+EPS>dist[i])mi=i;
        }
        double mincost=INF;
        int vv=-1;
        for(int i=N;i>=0;i--){
            if(!used[i])continue;
            double tmp=abs(p[mi]-p[i]);
            if(mincost+EPS>tmp){
                mincost=tmp;
                vv=i;
            }
        }
 
        ans+=mincost;
        used[mi]=true;
        Segment s(p[mi],p[vv]);
        rep(i,N+1){
            if(used[i])continue;
            chmin(dist[i],GetDistance(s,p[i]));
        }
    }
 
    printf("%.20f\n",ans);
}

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

long long dp[310][310], sum[310][310];
long long C[310][310];

int main () {
	int n, k, mod; scanf("%d%d%d", &n, &k, &mod);
	for (int i = 0; i <= 300; i++) {
		C[i][0] = 1;
		for (int j = 1; j <= i; j++) {
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
		}
	}
	for (int i = 0; i <= k; i++) {
		dp[1][i] = 1;
	}
	for (int i = 2; i <= n + 1; i++) {
		for (int j = k; j >= 0; j--) {
			sum[i - 1][j] = (sum[i - 1][j + 1] + dp[i - 1][j]) % mod;
		}
		for (int j = 0; j <= k; j++) {
			for (int ni = 1; ni <= i - 1; ni++) {
				dp[i][j] = (dp[i][j] + sum[ni][j + 1] * C[i - 2][ni - 1] % mod * dp[i - ni][j]) % mod;
			}
		}
	}
	printf("%lld\n", dp[n + 1][0]);
	return 0;
}


Measured memory_bytes: 5952
/*hello! guys~*/
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i=0,n,a,b,c;
  cin>>a>>b>>c;
  if(a==b)
  i++;
  if(a==c)
  i++;
  if(b==c)
  i++;
  if(i==1)printf("Yes");
  else  printf("No");
  return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;
typedef long double ld;


int main(){
	ll n, a, b;
	cin >> n >> a >> b;
	ll seg = a+b;
	ll blue = a*(n/seg) + min(n%seg, a);
	cout << blue << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;
using Graph = vector<vector<int>>;

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


signed main() {
  int K;
  cin >> K;
  
  int ans = 0;
  for( int a = 1; a <= K; a++ ){
    for( int b = 1; b <= K; b++ ){
      for( int c = 1; c <= K; c++ ){
        int d = gcd(a, b);
        ans += gcd(d, c);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using static Reader;

public static class P
{
    public static void Main()
    {
        var n = NextInt;
        var k = NextInt;
        var reducedA = new int[n];
        for (int i = 0; i < n; i++)
            reducedA[i] = NextInt - k;
        var accum = new long[n + 1];
        for (int i = 0; i < reducedA.Length; i++)
            accum[i + 1] = accum[i] + reducedA[i];
        //var compressDict = accum.Distinct().OrderBy(x => x).Select((elem, ind) => new Tuple { Item1 = elem, Item2 = ind }).ToDictionary(x => x.Item1, x => x.Item2);
        var distincted = accum.Distinct().ToArray();
        Array.Sort(distincted);
        long res = 0;
        BIT<int> bit = new BIT<int>(distincted.Length, 0, (x, y) => x + y);
        for (int i = 0; i < accum.Length; i++)
        {
            var ind = Array.BinarySearch(distincted, accum[i]);
            res += bit.Query(ind);
            bit.Operate(ind, 1);
        }
        Console.WriteLine(res);
    }
}

struct Tuple
{
    public long Item1;
    public int Item2;
}


class BIT<T>
{
    public readonly int Size;
    T Identity;
    T[] Elements;
    Func<T, T, T> Merge;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public BIT(int size, T identity, Func<T, T, T> merge)
    {
        Size = size;
        Identity = identity;
        Merge = merge;
        Elements = new T[Size + 1];
        for (int i = 0; i < Elements.Length; i++) Elements[i] = identity;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Query(int r)
    {
        T res = Identity;
        for (r++; r > 0; r -= r & -r) res = Merge(res, Elements[r]);
        return res;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Operate(int i, T x)
    {
        for (i++; i < Elements.Length; i += i & -i) Elements[i] = Merge(Elements[i], x);
    }
}


static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = BUF_SIZE - 1;
    static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; } }

    public static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; while (Buffer[ptr] < 48) Move();
            do { res = res * 10 + (int)(Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res;
        }
    }
}


Measured memory_bytes: 29024
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

signed main()
{
	ios::sync_with_stdio(false);
	int l;
	cin>>l;
	cout<<fixed<<setprecision(10)<<(double)(l*l*l*1.0)/(double)27.0<<endl;	
	return 0;
}

Measured memory_bytes: 256
/**************************************************
filename       :B.cpp
author         :maksyuki
created time   :2018/1/14 20:06:54
last modified  :2018/1/16 12:06:46
file location  :C:\Users\abcd\Desktop\atcoder
***************************************************/

#pragma comment(linker, "/STACK:102400000,102400000")
#include <set>
#include <bitset>
#include <list>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <vector>
#include <ios>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <complex>
#include <numeric>
#include <functional>
#include <cmath>
#include <ctime>
#include <climits>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cassert>
using namespace std;

#define CFF freopen ("in", "r", stdin)
#define CFO freopen ("out", "w", stdout)
#define CPPFF ifstream cin ("in")
#define CPPFO ofstream cout ("out")
#define	DB(ccc)	cout << #ccc << " = " << ccc << endl
#define	DBT printf("time used: %.2lfs\n", (double) clock() / CLOCKS_PER_SEC)
#define PB push_back
#define MP(A, B) make_pair(A, B)

typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef pair <int, int> PII;
typedef pair <int, bool> PIB;

const int INF = 0x7F7F7F7F;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = 2 * acos (0.0);
const int maxn = 1e5 + 6666;

LL aa[maxn];

int main()
{
#ifdef LOCAL
    CFF;
    //CFO;
#endif
    
    int n;
    while(cin >> n) {
        for(int i = 1; i <= n; i++) cin >> aa[i];
       
        LL Li = 2, Ri = 2;
        bool ok = true; 
        for(int i = n; i >= 1; i--) {
            if(Li % aa[i]) Li += aa[i] - (Li % aa[i]);

            Ri -= Ri % aa[i];
            if(Li > Ri) {
                ok = false;
                break;
            }
            Ri += aa[i] - 1;
        }

        if(!ok) puts("-1");
        else cout << Li << " " << Ri << endl;
    }
    return 0;
}


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

//1139
int main(){
  	double N,lt,bt;
	cin>>N;
	lt=(N+1)/1.08;
  	bt=N/1.08;
  	if(ceil(bt)<lt)cout<<ceil(bt)<<endl;
  	else cout<<":("<<endl;
	}


Measured memory_bytes: 256