akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

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

	vector <ll> A(N);
	for (int ii = 0; ii < N; ++ii){
		cin >> A[ii];
	}

	ll ans = 0;
	for (int ii = 1; ii < N; ++ii){
		if (A[ii-1] > A[ii]){
			ans += A[ii-1] - A[ii];
			A[ii] = A[ii-1];
			// cout << ans << endl;
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 4840
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>

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

using namespace std;

const int INF = 10000;

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

	double lap  = (double)2 * r * 3.14159265359;
	double area = (double)r * r * 3.14159265359;
	cout << fixed << setprecision(6) << area << " ";
	cout << fixed << setprecision(6) << lap << endl;

	return 0;
}



Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, P> P3;
typedef pair<P, P> PP;
constexpr ll MOD = ll(1e9 + 7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(10000) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

vector<vector<int> > g;
vector<int> cnt;

void dfs(int u, int pre){
    for(auto v : g[u]){
        if(v == pre) continue;
        cnt[v] += cnt[u];
        dfs(v, u);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    g.resize(n);
    cnt.resize(n,0);
    REP(i,n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    REP(i,q){
        int p, x;
        cin >> p >> x;
        p--;
        cnt[p] += x;
    }
    dfs(0,-1);
    REP(i,n){
        cout << cnt[i] << " \n"[i==n-1];
    }
    return 0;
}


Measured memory_bytes: 23424
#include <iostream>
using namespace std;
int n,p[100010];
int ans;
int main()
{
	cin>>n;
	for (int i=0;i<n;i++)
	{
		cin>>p[i];
	}
	for (int i=0;i<=n-1;i++)
	{
		if (p[i]==i+1)
		{
			if (i<n-1 && p[i+1]==i+2)
			swap(p[i],p[i+1]);
		}
		else
			continue;
		ans++;
	}
	cout<<ans<<endl;
	system("pause");
    return 0;
}

Measured memory_bytes: 888
from sys import stdin

class Vector:
    def __init__(self, x=None, y=None):
        self.x = x
        self.y = y

    def __add__(self, other):
        return Vector(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Vector(self.x - other.x, self.y - other.y)

    def __mul__(self, k):
        return Vector(self.x * k, self.y * k)

    def __gt__(self, other):
        return self.x > other.x and self.y > other.y

    def __eq__(self, other):
        return self.x == other.x and self.y == other.y

    def dot(self, other):
        return self.x * other.x + self.y * other.y

    # usually cross operation return Vector but it returns scalor
    def cross(self, other):
        return self.x * other.y - self.y * other.x

    def norm(self):
        return self.x * self.x + self.y * self.y

    def abs(self):
        return math.sqrt(self.norm())

class Point(Vector):
    def __init__(self, *args, **kargs):
        return super().__init__(*args, **kargs)

class Segment:
    def __init__(self, p1=Point(0, 0), p2=Point(1, 1)):
        self.p1 = p1
        self.p2 = p2

def project(s, p):
    base = s.p2 - s.p1
    hypo = p - s.p1
    r = hypo.dot(base) / base.norm()
    return s.p1 + base * r

def read_and_print_results(s, n):
    for _ in range(n):
        line = stdin.readline().strip().split()
        p = Vector(int(line[0]), int(line[1]))
        x = project(s, p)
        print('{0:0.10f} {1:0.10f}'.format(x.x, x.y))

x1, y1, x2, y2 = input().split()
p1 = Point(int(x1), int(y1))
p2 = Point(int(x2), int(y2))
s = Segment(p1, p2)
n = int(input())
read_and_print_results(s, n)


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

int main() {
	int N, M, X, A[100], border = 0;
	cin >> N >> M >> X;
	for (int i = 0; i < M; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < M - 1; i++) {
		if (A[i] < X && X < A[i + 1]) border = i + 1;
	}
	cout << min(border, M - border) << endl;
}

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

int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a+b>c+d)
        printf("Left\n");
    else if(a+b<c+d)
        printf("Right\n");
    else
        printf("Balanced\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using int64 = long long;

const long double eps = 1e-10;
int main() {
    int n,m;
    cin >> n >> m;
    int64 ans = 100*(n-m) + 1900*m;
    for (int i=0; i<m; i++) ans*=2;
    cout << ans << endl;
}

/*
 * x = (100 * (n-m) + 1900 * m) * (1/2)^m
 *
 */

Measured memory_bytes: 256
A,B,C,K = map(int,input().split())
ans = 0
count =0

if A<K-count:
    ans += A
    count += A
else:
    ans +=K-count
    count += K-count
if B<K-count:
    count += B
else:
    count += K-count
if C<K-count:
    ans -= C
    count += C
else:
    ans -=K-count
    count += K-count
print(ans)
    

Measured memory_bytes: 61668
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0;i<N;i++) cin >> d.at(i);
    sort(d.begin(),d.end());
    int upsikiri=d.at(N/2),downsikiri=d.at(N/2-1);
    cout << max(0,upsikiri-downsikiri) << endl;
    return 0;
}

Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class CGoHome {
public:
    void solve(std::istream &in, std::ostream &out) {
        int x;
        in >> x;
        int res = 0;
        for (int tot = 0; tot < x; tot += ++res);
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    CGoHome solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

const int MAX = 500000, MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

class UnionFind {
 public:
     int n;
     std::vector<int> par;
     std::vector<int> num;

     explicit UnionFind(int n) {  // [0 n)のunion find
         this->n = n;
         this->par.resize(n);
         this->num.resize(n, 1);
         for (int i = 0; i < n; i++) {
             this->par[i] = i;
         }
     }

     int root(int i) {
         if (par[i] == i)
             return i;
         else
             return par[i] = root(par[i]);
     }

     bool same(int i, int j) {
         return root(i) == root(j);
     }

     // もしすでに、くっ付いていたら-1を返す
     int unite(int i, int j) {
         int t = root(i);
         int k = root(j);

         if (t == k)
            return -1;

         par[t] = k;
         num[k] += num[t];
         return 0;
     }

     int size(int i) {
         return num[root(i)];
     }
};

signed main() {
  string s,t;
  cin>>s>>t;
  ll N = s.size();
  ll NT = t.size();
  string p="";
  while(p.size() < 3*NT || p.size() < 3*N){
    p += s;
  }
  s = p;
  vector<bool> ok(N, false);
  //cout<<"s="<<s<<endl;
  //cout<<"t="<<t<<endl;
  auto rh = rolling_hash(t+s);

  for (int i=0; i<N; i++) {
    //cout<<0<<" " << t.size()+i << " " << sa.prefixCommonLength(0, t.size()+i) << endl;
    //if(lh.prefixCommonLength(0, NT+i) >= NT ){
    if (rh.match(0, NT, NT+i, 2*NT+i)){
      ok[i%N] = true;
    }
  }


  auto uf = UnionFind(N);
  rep(i,0,N){
    if (ok[i] && ok[(i+NT)%N]){
      ll res = uf.unite(i, (i+NT)%N);
      if (res == -1){
        cout<<-1<<endl;
        return 0;
      }
    }
  }

  ll ans = 0;
  for (int i=0;i<N;i++) {
    if (ok[i])
      ans = max(ans, (ll)uf.size(i));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 89424
n, m = [int(i) for i in input().split()]
dp = [0] * (n+1)
a = set()
for _ in range(m):
    a.add(int(input()))

if 0 not in a:
    dp[0] = 1
if 1 not in a:
    dp[1] = 1
mod = 10**9+7
for i in range(2, n+1):
    if i in a:
        continue
    dp[i] = (dp[i - 1] + dp[i - 2]) % mod
print(dp[-1])


Measured memory_bytes: 50904
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
 
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }
 
typedef long long LL;
 
const int N = (int) 2005 * 2005, mod = (int) 0;
bitset<N> dp;
int main() {
	dp[0] = 1;
	int n, sum = 0;;
	cin >> n;
	for (int j = 0; j < n; ++j) {
		int x;
		cin >> x;
		sum += x;
		dp |= dp << x;
	}
	for (int j = 0; j < N; ++j)
		if (dp[j] && j + j >= sum) {
			cout << j << endl;
			return 0;
		}
}

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

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
 	int n;
 	cin>>n;
 	vector<int>v;
 	v.push_back(1);
 	for(int i=6; i<=n; i*=6){
 		v.push_back(i);
 	}
 	for(int i=9; i<=n; i*=9){
 		v.push_back(i);
 	}
 	sort(v.begin(),v.end());
 	int MAX=100001;
 	int dp[MAX];
 	for(int i=0; i<MAX; i++){
 		dp[i]=MAX;
 	}
 	dp[0]=0;
  	 	for(int i=0; i<=n; i++){
 		for(int j=0; j<v.size(); j++){
 			if(i>=v[j]){
 				dp[i]=min(dp[i],dp[i-v[j]]+1);
 			}
 		}
 	}
  cout<<dp[n]<<endl;

}

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

int main(){
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  int cnt=0;
  for(int i=0;i<=a;i++){
      for(int j=0;j<=b;j++){
          for(int k=0;k<=c;k++){
              int ans=0;
              ans+=500*i+100*j+50*k;
              if(ans==x) cnt++;
          }
      }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3592
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),m=sc.nextInt();
        int[] count = new int[m];
        int ans = 0;
        for(int i = 1;i<=n;i++){
            int k = sc.nextInt();
            for(int j = 0;j<k;j++){
                count[sc.nextInt()-1] ++;
            }
        }
        for(int i =0;i<m;i++){
            if(count[i]==n){
                ans ++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
from heapq import heappop, heappush, heappushpop, heapreplace


class HeapQueue:
    def __init__(self, reverse=False):
        self.reverse = reverse
        self.heap = []

    def __len__(self):
        return len(self.heap)

    def append(self, p, v):
        heappush(self.heap, (-p if self.reverse else p, v))

    def appendpop(self, p, v):
        return heappushpop(self.heap, (-p if self.reverse else p, v))

    def popappend(self, p, v):
        return heapreplace(self.heap, (-p if self.reverse else p, v))

    def pop(self):
        return heappop(self.heap)[1]

    def front(self):
        return self.heap[0]


N, M = map(int, input().split())
AB = [[] for _ in range(100010)]
for _ in range(N):
    a, b = map(int, input().split())
    AB[a].append(b)
ans = 0
q = HeapQueue(reverse=True)
for i in range(M):
    for b in AB[i + 1]:
        q.append(b, b)
    if len(q):
        ans += q.pop()
print(ans)


Measured memory_bytes: 75552
/*

*/
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout << setprecision(12)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((ll)(x).size())
#define cin1(x) cin >> x
#define cin2(x, y) cin >> x >> y
#define cin3(x, y, z) cin >> x >> y >> z
#define cin4(x, y, z, _) cin >> x >> y >> z >> _
#define cin5(x, y, z, p, q) cin >> x >> y >> z >> p >> q
#define cou(x) cout << x
#define cous(x) cout << x << " "
#define coul(x) cout << x << "\n"
#define ret(x) return x
#define MAX 1000000007
#define start int main() {   fastio
#define finish ret(0); }
#define Test ll _t; cin1(_t); rep(w, 0, _t)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cntv(v,a) count(v.begin(),v.end(),a)
#define fans(x) \
    if ( x  ) coul("YES"); \
    else coul("NO")
#define mset(x, y) memset(x, y, sizeof(x))
#define fileshow  freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)

struct point{    int x, y, ind;   char ch;  };
typedef long long ll;
typedef vector<ll> VI;
typedef pair<ll,ll> PII;
typedef double db;
//mt19937 mrand(random_device{}());
const ll mod=1000000007;
//ll rnd(ll x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}ret(res);}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll fact[13];
void factorial() {   fact[0]=1;  rep(i, 1, 12) fact[i]=(fact[i-1]*i);  }
 //for sieve function
//void sieve() {    rep(i, 2, MAX)  {  if (spf[i] == 0) {  spf[i] = i;   sie.pb(i);  }    for (ll j=0; j<SZ(sie) && i*sie[j] <= MAX && sie[j] <= spf[i]; j++)   spf[i * sie[j]] = sie[j]; }   }
bool cmp(point A, point B){   if(A.x != B.x) ret(A.x < B.x);  ret(A.y < B.y);   }
//void segPre(ll l, ll h, ll in) {  ll segTree[3*mx];   if ( l == h ){  segTree[ in ] = arr[ l ];   return;  }   ll m = (l + h) / 2; pre(l, m, 2*in);  pre(m+1, h, 2*in+1);    segTree[ in ] = segTree[ in*2 ] | segTree[ in*2+1 ];   segTree[ in ] = segTree[ in*2 ] ^ segTree[ in*2+1 ];    }
// head collected
// Don't use variable name as --> prev, time, _t, w, y1
// Don't use ceil and pow function

string st;
ll n;
set <string> se;


start;

    cin1( n );

    rep(i, 0, n){
        cin1( st );
        se.insert( st );
    }

    coul(se.size());

finish


/*
5 4
3 1 8 9 7
1 1 5
1 2 12
1 9 3
2 1 5


*/


Measured memory_bytes: 19240
#include <iostream>

using namespace std;

int main(void) {
    string input;
    cin >> input;
    int A = (input[0] - '0');
    int B = (input[1] - '0');
    int C = (input[2] - '0');
    int D = (input[3] - '0');
    for(int bit=0; bit<(1<<3); bit++) {
        int ans = A;
        string pm;
        if((bit>>0) & 1) {
            ans += B;
            pm[0] = '+';
        } else {
            ans -= B;
            pm[0] = '-';
        }
        if((bit>>1) & 1) {
            ans += C;
            pm[1] = '+';
        } else {
            ans -= C;
            pm[1] = '-';
        }
        if((bit>>2) & 1) {
            ans += D;
            pm[2] = '+';
        } else {
            ans -= D;
            pm[2] = '-';
        }
        if(ans == 7) {
            cout << A << pm[0] << B << pm[1] << C << pm[2] << D << "=7" << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct edge{int to,cost;};
typedef pair<int,int> P;
#define MAX_N 100005
 
int N,M,A[3];
vector< edge > G[MAX_N];
int D[(1<<3)][MAX_N];
 
void dijkstra(int bit,int* d){
  for(int i=0;i<MAX_N;i++)d[i]=1e9;
  priority_queue< P , vector<P> , greater<P> > Q;
 
  if( __builtin_popcount(bit) == 1){
    for(int i=0;i<3;i++){
      if(bit>>i&1){
        Q.push(P(0,N+i));
        d[N+i]=0;
      }
    }
  }else{
    for(int i=0;i<N+3;i++){
      d[i]=0;
      for(int j=0;j<3;j++){
        if(bit>>j&1){
          d[i]+=D[(1<<j)][i];
        }
      }
      Q.push(P(d[i],i));
    }
  }
   
  while(!Q.empty()){
    P p=Q.top();Q.pop();
    int pos=p.second;
    int cost=p.first;
    if(d[pos]<cost)continue;
    for(int i=0;i<(int)G[pos].size();i++){
      edge e=G[pos][i];
      if(cost+e.cost<d[e.to]){
        d[e.to]=cost+e.cost;
        Q.push(P(d[e.to],e.to));
      }
    }
  }
}
 
int main(){
  scanf("%d",&N);
  for(int k=0;k<3;k++)scanf("%d",&A[k]);
  for(int k=0;k<3;k++){
    for(int i=0;i<A[k];i++){
      int id;
      scanf("%d",&id);
      id--;
      G[N+k].push_back( (edge){id,0} );
      G[id].push_back( (edge){N+k,0} );
    }
  }
  scanf("%d",&M);
  for(int i=0;i<M;i++){
    int a,b;
    scanf("%d %d",&a,&b);
    a--,b--;
    G[a].push_back((edge){b,1});
    G[b].push_back((edge){a,1});
  }
   
  for(int k=1;k<(1<<3);k++)dijkstra(k,D[k]);
  int ans=1e9,ans2=-1;
   
  for(int i=0;i<N;i++){
    for(int j=0;j<(1<<3);j++){
      int k=(1<<3)-1-j;
      int cost=D[j][i]+D[k][i];
      if(ans>cost){
        ans=cost;
        ans2=i;
      }
    }
  }
 
  printf("%d %d\n",ans,ans2+1);
  return 0;
}

Measured memory_bytes: 20144
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;
#define y1     y114514
#define pb     push_back
#define mkp    make_pair
#define fi     first
#define se     second
#define all(a) a.begin(), a.end()

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

const int M = 1000000007;

int main() {
    int x;

    scanf("%d", &x);

    int g = __gcd(x, 360);
    int p = 360 / g;

    printf("%d\n", p);
    return 0;
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

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

    while (true)
    {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3620
import bisect

def solve():
    n=int(raw_input())
    m=int(raw_input())
    dist=[0]+[int(raw_input()) for _ in xrange(n-1)]+[d]
    q=[int(raw_input()) for _ in xrange(m)]
    dist.sort();

    ans=0
    for i in q:
        l=bisect.bisect_left(dist,i)
        if dist[l]==i:continue
        l-=1
        r=bisect.bisect_left(dist,i)
        ans+=min(i-dist[l],dist[r]-i)

    return ans

while 1:
    d=int(raw_input())
    if d==0:break
    ans=solve()
    print ans

Measured memory_bytes: 10132
#include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
    int N,M;
    int A[101]={};
    cin>>N>>M;
    if(N==0&&M==0)break;
    for(int i=0;i<N;i++){
      int d,v;
      cin>>d>>v;
      A[d]=max(A[d],v);
    }
    int ans=0;
    for(int i=1;i<=M;i++){
      ans+=A[i];
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
        #include<iostream>
        #include<cstdio>
        #include<vector>
        #include<queue>
        #include<map>
        #include<cstring>
        #include<string>
        #include <math.h>
        #include<algorithm>
    //    #include <boost/multiprecision/cpp_int.hpp>
        #include<functional>
      #define int long long
        #define inf  1000000007
        #define pa pair<int,int>
#define ll long long
        #define pal pair<ll,ll>
        #define ppa pair<int,pa>
        #define  mp make_pair
        #define EPS (1e-10)
        #define equals(a,b) (fabs((a)-(b))<EPS)

        using namespace std;

        class Point{
        	public:
        	double x,y;
        	Point(double x=0,double y=0):x(x),y(y) {}
        	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
        	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
        	Point operator * (double a) {return Point(x*a,y*a);}
        	Point operator / (double a) {return Point(x/a,y/a);}
        	double absv() {return sqrt(norm());}
        	double norm() {return x*x+y*y;}
        	bool operator < (const Point &p) const{
        		return x != p.x ? x<p.x: y<p.y;
        	}
        	bool operator == (const Point &p) const{
        		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
        	}
        };
        typedef Point Vector;

        struct Segment{
        Point p1,p2;
        };

    double hen(Vector a){
    if(fabs(a.x)<EPS && a.y>0) return acos(0);
    else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
    else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
    else if(fabs(a.y)<EPS && a.x>0) return 0.0;
    else if(a.y>0) return acos(a.x/a.absv());
    else return 2*acos(0)+acos(-a.x/a.absv());

    }

        double dot(Vector a,Vector b){
        	return a.x*b.x+a.y*b.y;
        }
        double cross(Vector a,Vector b){
        	return a.x*b.y-a.y*b.x;
        }
        int dx[4] = {1, 0, -1, 0};
        int dy[4] = {0, 1, 0, -1};
        //----------------kokomade temple------------


signed main(){
	int a[110]={0};
	int n,k;
	
	cin>>n>>k;
	
	int ans=k;
	
	for(int i=2;i<=n;i++){
		ans *= (k-1);
		
	}
	
	cout<<ans<<endl;
	return 0;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;
 
int main(){
  string s;
  cin >> s;
  int ch = 0;
  rep(i, 3){
    if(s.at(i)==s.at(i+1)) {cout << "Bad" << endl; ch=1; break;}
  }
  if(ch==0) cout << "Good" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long
#define ld long double
 
const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;
const ll mod = 1e9 + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1);
 
bool equal(ld a, ld b) {return abs(a - b) < EPS;}
 
struct Vector{
    ld x, y;
    Vector(){}
    Vector(ld x, ld y) : x(x), y(y) {}
    Vector operator + (const Vector &v) const {return Vector(x + v.x, y + v.y);}
    Vector operator - (const Vector &v) const {return Vector(x - v.x, y - v.y);}
    Vector operator * (ld a) const {return Vector(x * a, y * a);}
    ld len() {
        return sqrt(x * x + y * y);
    }
    Vector rotate(ld a) const {return Vector(cos(a) * x - sin(a) * y, sin(a) * x + cos(a) * y);}
};
 
struct Disk{
    Vector center;
    ld radius;
};
 
vector<Vector> inter(const Disk &c1, const Disk &c2) {
    Vector ab = c2.center - c1.center;
    ld d = ab.len();
    ld r1 = c1.radius, r2 = c2.radius;
    if (equal(d, 0)) return {};
 
    if(equal(r1 + r2, d) == true) return {c1.center + ab * (r1 / d)};
    if(equal(r1 + d, r2) == true) return {c1.center - ab * (r1 / d)};
    if(equal(r2 + d, r1) == true) return {c1.center + ab * (r1 / d)};
 
    if(r1 + r2 < d)  return {};
    if(r1 + d  < r2) return {};
    if(r2 + d  < r1) return {};
 
    double a = (d * d + r1 * r1 - r2 * r2) / (2 * d);
    return {c1.center + ab * (a / d) + ab.rotate(PI/2.0)  * (sqrt(r1*r1 - a*a) / d),
            c1.center + ab * (a / d) + ab.rotate(-PI/2.0) * (sqrt(r1*r1 - a*a) / d)};
}
 
bool is_inside(Disk c, Vector v) {
    return (c.center - v).len() < c.radius + EPS;
}
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<Vector> a(n);
    vector<ld> c(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].x >> a[i].y >> c[i];
    }
 
    ld left = 0, right = 1e6;
    for (int it = 0; it < 100; it++) {
        ld mid = (left + right) / 2;
        vector<Disk> l(n);
        for (int i = 0; i < n; i++) {
            l[i].center = a[i];
            l[i].radius = mid / c[i];
        }
        vector<Vector> check;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                for (auto &p : inter(l[i], l[j])) check.pb(p);
            }
        }
        for (int i = 0; i < n; i++) {
            check.pb(a[i]);
        }
        int mx = 0;
        for (auto &p : check) {
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                if (is_inside(l[i], p)) cnt++;
            }
            mx = max(mx, cnt);
        }
        if (mx >= k) right = mid;
        else left = mid;
    }
    cout << fixed << setprecision(15) << right;
    return 0;
}

Measured memory_bytes: 3940
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	line := strings.Split(sc.Text(), " ")
	a, _ := strconv.Atoi(line[0])
	b, _ := strconv.Atoi(line[1])
	h, _ := strconv.Atoi(line[2])
	m, _ := strconv.Atoi(line[3])
	theta := calcAngle(h, m)
	dist := calcDistance(float64(a), float64(b), theta)
	fmt.Println(dist)
}

func calcAngle(h, m int) float64 {
	theta1 := 2.0 * math.Pi * (float64(h) + float64(m)/60.0) / 12.0
	theta2 := 2.0 * math.Pi * float64(m) / 60.0
	return theta1 - theta2
}

func calcDistance(a, b, theta float64) float64 {
	square := a*a + b*b - 2*a*b*math.Cos(theta)
	return math.Sqrt(square)
}


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

const ll MOD = pow(10, 9) + 7;

// a^n mod を計算する
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

ll comb(ll n, ll k){
  ll x = 1;
    for(int i=n; i >= n-k+1; i--) {
        x = x*i%MOD;
    }

    ll y = 1;
    for(int i=1; i<=k; i++) {
        y = y*i%MOD;
    }
    y = modpow(y, MOD-2);

    return x*y%MOD;
}

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll nCa = comb(n, a);
    ll nCb = comb(n, b);
    ll ans = (modpow(2, n) - 1 - nCa - nCb) % MOD;
    while(ans < 0){
        ans += MOD;
    }
    cout <<  ans << endl;
}

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

int main(){
        int n;
        scanf("%d", &n);

        int dp[n+1][5][5][5];
        memset(dp, 0, (n+1)*500);
        dp[0][0][0][0] = 1;
        for(int i=1; i<=n; i++){
                for(int a=0; a<5; a++){
                        for(int b=0; b<5; b++){
                                for(int c=0; c<5; c++){
                                        for(int d=1; d<5; d++){
                                                if(b==1 && c==3 && d==2) continue;
                                                if(b==1 && c==2 && d==3) continue;
                                                if(b==3 && c==1 && d==2) continue;

                                                if(a==1 && c==3 && d==2) continue;
                                                if(a==1 && b==3 && d==2) continue;

                                                dp[i][b][c][d] += dp[i-1][a][b][c];
                                                dp[i][b][c][d] %= 1000000007;
                                        }
                                }
                        }
                }
        }

        int ans = 0;
        for(int i=1; i<5; i++) for(int j=1; j<5; j++) for(int k=1; k<5; k++){
                ans += dp[n][i][j][k];
                ans %= 1000000007;
        }
        printf("%d\n", ans);
        return 0;
}

Measured memory_bytes: 256
import collections
 
N = int(input())
A = list(map(int, input().split()))

A1 = []
A2 = []

for i in range(N):
    A1.append(i + A[i])
    A2.append(i - A[i])

C_A1 = collections.Counter(A1)
C_A2 = collections.Counter(A2)
ans = 0
for i in range(N):
    ans += C_A1[i]*C_A2[i]
    
print (ans)

Measured memory_bytes: 63368
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include<cmath>
#include <limits>
using namespace std;
typedef pair<pair<int, int>, int> P;
typedef long long ll;
const int INF = 100000000;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
const int MOD = 1000000007;



int main() {
	ll i, j, k, l, m, n, sum, flag, cc, M, X, N, Y, Z, K, x, y, z,A,P;
	sum = 0;
	cin >> A >> P;
	ll ans;
	ans = (P + 3 * A) / 2;
		output(ans);
	return 0;
}








Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
        mut b: [i64; n],
    }
    b.reverse();
    let mut l = 0;
    let mut f = vec![false; n];
    for i in 0..n {
        if a[i] != b[i] {
            continue;
        }
        while l < n && (b[i] == b[l] || a[l] == b[i] || f[l]) {
            l += 1;
        }
        if l >= n {
            println!("No");
            return;
        }
        b.swap(i, l);
        f[l] = true;
        f[i] = true;
        l += 1;
    }

    println!("Yes");
    for i in 0..n {
        print!("{} ", b[i]);
    }
}


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

using namespace std;

int64_t Solve(string S, int k) {
  int64_t sum = 0;
  int64_t current = 0;
  for (int i = 0; i < S.length(); i++) {
    if ((k & (1 << i)) == 0) {
      current = current * 10 + (S[i] - '0');
    } else {
      sum += current;
      current = 0;
    }
  }
  sum += current;

  return sum;
}

int main() {
  string S;
  cin >> S;

  int64_t sum = 0;
  for (int k = 0; k < (1 << S.length()); k++) {
    sum += Solve(S, k);
  }
  printf("%ld\n", sum);

  return 0;
}


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

using namespace std;

int n, vet[3][8];

int main(){
    cin >> n;
    for(int k=0;k<2;k++){
        for(int i=0;i<n;i++){
            cin >> vet[k][i];
        }
    }
    
    for(int i=0;i<n;i++){
        vet[2][i] = vet[0][i];
    }

    sort(vet[2],vet[2]+n);
    
    int sum = 0;
    bool f,s;    
    int cont = 0,c=0;
    while(1){
        f = 0;
        s = 0;
        for(int i=0;i<n;i++){
            if(vet[0][i] != vet[2][i]){
                f =1;
            }

            if(vet[1][i] != vet[2][i]){
                s=1;
            }

            if(f == 1 && s == 1) break;
        }
        
        if(f == 0) {
            sum += cont;
            c++;
        }
        if(s == 0){
            sum -= cont;
            c++;
        }

        if(c == 2) break;

        next_permutation(vet[2],vet[2]+n);
        cont++;
    }


    cout << abs(sum) << "\n";
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1000000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <cassert>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <ctime>
#include <random>
#include <bitset>
#include <limits.h>
#include <fstream>

#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define pll pair <ll, ll>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef double ld;
#define uint unsigned int

const int maxn = (int)1e6 + 10, mod = 998244353;
char s[maxn];

int mul(int x, int y) {
	return (ll)x * y % mod;
}

int add(int x, int y) {
	x += y;
	if (x >= mod) {
		x -= mod;
	}
	return x;
}

int sub(int x, int y) {
	x -= y;
	if (x < 0) {
		x += mod;
	}
	return x;
}

int my_pow(int x, int y) {
	int ans = 1;

	while (y) {
		if (y & 1) {
			ans = mul(ans, x);
		}

		x = mul(x, x);
		y >>= 1;
	}
	return ans;
}

const int maxlog = 23;
int g[maxlog + 1];

int rev(int x, int st) {
	int y = 0;

	for (int i = 0; i < st; i++) {
		y <<= 1;
		y += x & 1;
		x >>= 1;
	}
	return y;
}

void fft(vector <int> &v, int st, bool fl) {
	int n = (1 << st);

	for (int i = 0; i < n; i++) {
		int x = rev(i, st);
		if (x < i) {
			swap(v[i], v[x]);
		}
	}

	int pos = 0;

	for (int len = 2; len <= n; len <<= 1) {
		pos++;
		int wlen = g[pos];

		for (int i = 0; i < n; i += len) {
			int w = 1;

			for (int j = i; j < i + len / 2; j++) {
				int a = v[j];
				int b = mul(v[j + len / 2], w);
				v[j] = add(a, b);
				v[j + len / 2] = sub(a, b);

				w = mul(w, wlen);
			}
		}
	}

	if (fl) {
		reverse(1 + all(v));
		int rn = my_pow(n, mod - 2);

		for (int i = 0; i < n; i++) {
			v[i] = mul(v[i], rn);
		}
	}
}

int n;

vector <int> red[maxn];

const int mag = 19;

int mex(vector <int> a) {
	vector <int> cnt((int)a.size() + 1, 0);

	for (int x : a) {
		if (x < (int)cnt.size()) {
			cnt[x]++;
		}
	}

	int ans = 0;

	while (cnt[ans]) {
		ans++;
	}

	return ans;
}

vector <int> get() {
	int m;
	cin >> m;

	for (int i = 1; i <= n; i++) {
		red[i].clear();
	}

	while (m--) {
		int x, y;

		scanf("%d %d", &x, &y);
		red[y].push_back(x);
		red[x].push_back(y);
	}

	vector <int> ans(1 << mag, 0);

	int f = my_pow(10, 18);
	int x = 1;

	vector <int> ps(n + 1);

	for (int i = n; i > 0; i--) {
		vector <int> a;

		for (int u : red[i]) {
			if (u > i) {
				a.push_back(ps[u]);
			}
		}

		ps[i] = mex(a);
	}

	for (int i = 1; i <= n; i++) {
		x = mul(x, f);

		ans[ps[i]] = add(ans[ps[i]], x);
	}

	return ans;
}

vector <int> operator *(vector <int> a, vector <int> b) {
	vector <int> c(a.size(), 0);

	for (int i = 0; i < (1 << 13); i++) {
		for (int j = 0; j < (1 << 13); j++) {
			c[i ^ j] = add(c[i ^ j], mul(a[i], b[j]));
		}
	}

	return c;
}

int main() {
	g[maxlog] = my_pow(3, (mod - 1) / (1 << maxlog));
	for (int i = maxlog - 1; i >= 0; i--) {
		g[i] = mul(g[i + 1], g[i + 1]);
	}

	cin >> n;
	auto a = get();
	auto b = get();
	auto c = get();

	a = a * b;
	a = a * c;

	cout << a[0] << endl;
}

Measured memory_bytes: 39928
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * b / g;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
using Graph = vector<VE>;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	double a, b, x; cin >> a >> b >> x;
	double v = a * a*b;
	double s = 0;
	if (2 * x < v) {
		s = a * b*b / (2 * x);
	}
	else {
		s = (2 * (v - x) / (a*a*a));
	}
	double ans = atan(s)*180.0 / PI;
	cout << fixed << setprecision(15) << ans << endl;
	return 0;
}

Measured memory_bytes: 512
def main():
    N, K = map(int, input().split())
    P = map(int, input().split())
    E = [(p+1)/2 for p in P]
    sums = [sum(E[0:K])]
    for i in range(N-K):
        sums.append(sums[-1] - E[i] + E[i+K])
    print(max(sums))


if __name__ == '__main__':
    main()


Measured memory_bytes: 99840
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define lli long long int
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}
int main()
{
ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
ll x;
cin>>x;
int dp[x+1];
for(int i=0;i<=x;i++)
{
	dp[i]=0;
	
}
dp[0]=1;
for(int i=3;i<=x;i++)
{
	for(int j=3;j<=i;j++)
	{
		dp[i]+=dp[i-j]%mod;
		dp[i]=dp[i]%mod;
	}
}
cout<<dp[x]<<endl;
}




Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<tuple>
#include<stdio.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	double n;
	cin>>n;
	printf("%f\n", 2*n*3.141592);
	return 0;
}

Measured memory_bytes: 3772
#include<stdio.h>
int main(void){
  long long int n,k,i,a,b;
  scanf("%lld %lld",&n,&k);
  if(n>=k){
  a=(n-k)%k;
    if(a>=k-a){
      printf("%lld\n",k-a);
    }else{
      printf("%lld\n",a);
    }
  }else{
    if(n>=k-n){
      printf("%lld\n",k-n);
    }else{
      printf("%lld\n",n);
    }
  }
  return 0;
}
  

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  int n,k;
  int ans=0;
  cin>>n>>k;
  while(n){
    n/=k;
    ans++;
  }
  cout<<ans<<endl;
  return(0);
}


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

#define reint register int
#define coint const int

using namespace std;

typedef long long ll;

coint SIZE = 3000 + 5;

ll c[SIZE][SIZE];
ll li[SIZE], ans[SIZE];
ll xpow[SIZE];

int main(void) {
    int n;
    scanf("%d", &n);
    for (reint i = 0; i < n; ++i) scanf("%lld", &li[i]);
    for (reint i = 0; i <= n; ++i) {
        c[i][0] = 1;
        for (reint j = 1; j <= i; ++j)
            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % n;
    }
    for (reint i = 0; i < n; ++i) {
        if (!li[i]) continue;
        ans[0] = (ans[0] + 1) % n;
        xpow[0] = 1;
        for (reint j = 1; j <= n; ++j) xpow[j] = xpow[j - 1] * (n - i) % n;
        for (reint j = 0; j < n; ++j)
            ans[j] = ((ans[j] - xpow[n - 1 - j] * c[n - 1][j]) % n + n) % n;
    }
    for (reint i = 0; i < n; ++i)
        printf("%lld%c", ans[i], " \n"[i == n - 1]);

    return 0;
}



Measured memory_bytes: 69248
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<int, int>p;
struct edge { int to, cost; };
std::vector<edge>v[1000];
ll d[10];

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
bool f = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
std::string abc = "abcdefghijklmnopqrstuvwxyz";

int main() {
	int h, w;
	std::cin >> h >> w;
	for (int i = 0;i < 10;i++) {
		for (int j = 0;j < 10;j++) {
			int c;
			std::cin >> c;
			if (c != 0) {
				v[i].push_back(edge{ j,c });
			}
		}
	}
	int co[15];
	for (int i = 0;i < 10;i++) {
		for (int l = 0;l < 10;l++) {
			d[l] = INF;
		}
		d[i] = 0;
		std::priority_queue<p, std::vector<p>, std::greater<p>>pq;
		pq.push(std::make_pair(d[i], i));
		while (!pq.empty()) {
			p P = pq.top();
			pq.pop();
			int j = P.second;
			if (d[j] < P.first)continue;
			for (int k = 0;k < v[j].size();k++) {
				edge e = v[j][k];
				if (d[e.to] <= d[j] + e.cost)continue;
				d[e.to] = d[j] + e.cost;
				pq.push(std::make_pair(d[e.to], e.to));
			}
		}
		co[i] = d[1];
	}
	ll ans = 0;
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			int a;
			std::cin >> a;
			if (a != -1)ans += co[a];
		}
	}
	std::cout << ans << std::endl;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,b=0;
  cin>>N>>K;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    if(a>=K){
      b++;
    }
  }
  cout<<b;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
//const int MOD=1e9+7;
 
const int MOD=998244353;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,m;
    cin>>n>>m;
    
    vector<vector<pair<long long,int>>> graph(n+1);
    vector<int> mids(n+1);
    
    for(int i=0; i<m; i++){
        int x,y;
        long long c;
        cin>>x>>y>>c;
        
        graph[x].push_back({y,c});
    }
    
    for(int i=2; i<=n; i++){
        graph[i].push_back({i-1,0});
    }
    
    vector<long long> dists(n+1,1e18);
    vector<bool> vis(n+1);
    dists[1]=0;
    priority_queue<pair<long long,int>, vector<pair<long long,int>>, greater<pair<long long,int>>> pq;
    pq.push({dists[1],1});
    while(pq.size()){
        auto cur=pq.top();
        pq.pop();
        int v=cur.second;
        if(vis[v]) continue;
        vis[v]=1;
        for(auto p:graph[v]){
            if(dists[p.first]>dists[v]+p.second){
                dists[p.first]=dists[v]+p.second;
                pq.push({dists[p.first],p.first});
            }
        }
    }
    cout<<(dists[n]==1e18?-1:dists[n]);
    
    
    return 0;
}

Measured memory_bytes: 9724