akhauriyash/Code-Regression huggingface dataset:
"use strict";
main(
  require("fs")
    .readFileSync("/dev/stdin", "UTF-8")
    .trim()
    .split("\n")
);

function main(input) {
  const num = parseInt(input.shift());
  input = input[0].split(" ").map(Number);

  const minPosition = Math.min(...input);
  const maxPosition = Math.max(...input);

  let sumCon = [];

  for (let i = minPosition; i <= maxPosition; i++) {
    let result = 0;
    for (let f = 0; f < num; f++) {
      result += Math.pow(input[f] - i, 2);
    }
    sumCon.push(result);
  }

  console.log(Math.min(...sumCon));
}


Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c, d=0;
  	cin >> a >> b >> c;
  	int i = min(a,b);
  	for (; d < c; i--) {
     	if (a%i==0&&b%i==0) d++; 
    }
  	cout << ++i << endl;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int A, B, C;
    cin >> A >> B >> C;

    int mx = max({A, B, C});
    int r = mx * 3 - (A + B + C);

    if (r & 1) {
        cout << 1 + (r + 1) / 2 << endl;
    }
    else {
        cout << r / 2 << endl;
    }

    return 0;
}

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

int main() {
   int n;
   cin >> n;
   int four = 0, two = 0, one = 0;
   for (int i = 0; i < n; i++) {
      int a; cin >> a;
      if (a % 4 == 0) {
         four++;
      } else if (a % 2 == 0) {
         two++;
      } else {
         one++;
      }
   }

   if (two) one++;

   if (one <= four+1) {
      puts("Yes");
   } else {
      puts("No");
   }

   return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < (n); i++)
using namespace std;
int a1[15][15], b1[15], n;
signed main() {
	while (cin >> n, n) {
		for0(i, 10)for0(j, 10)a1[i][j] = 5000 * (i != j);
		int m = 0;
		for0(i, n) {
			int a, b, c; cin >> a >> b >> c;
			m = max({ m, a, b });
			a1[a][b] = min(c, a1[a][b]);
			a1[b][a] = a1[a][b];
		}m++;
		for0(i, m)for0(j, m)for0(k, m)a1[j][k] = min(a1[j][k], a1[j][i] + a1[i][k]);
		for0(i, m)b1[i] = 0;
		for0(i, m)for0(j, i) {
			b1[i] += a1[i][j];
			b1[j] += a1[i][j];
		}
		int ans1 = -1, ans2 = 500000;
		for0(i, m)if (ans2 > b1[i]) { ans2 = b1[i]; ans1 = i; }
		cout << ans1 << ' ' << ans2 << endl;
	}
}


Measured memory_bytes: 3104
from collections import deque

N, K = map(int, input().split())
S = input()

q = deque()

cnt = 0
for i in range(N - 1):
    cnt += 1
    if S[i] != S[i + 1]:
        q.append(cnt)
        cnt = 0

q.append(cnt + 1)

for _ in range(K):
    if not q:
        break
    a = q.popleft()
    b = q.popleft() if q else 0
    c = q.popleft() if q else 0
    q.appendleft(a+b+c)

print(sum(q) - len(q))

Measured memory_bytes: 75720
#include <bits/stdc++.h>
#define N 200010
using namespace std;
 
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
struct edge{int v,next;}vs[N<<1];
int n,ee,st[N<<1],du[N],Rt,F[N];
inline void addedge(int u,int v)
{
	vs[++ee].v=v;vs[ee].next=st[u];st[u]=ee;
}
inline void dfs(int rt,int pr,int x)
{
	vector <int> v; v.clear();
	for(int i=st[rt];i;i=vs[i].next)
	{
		if(vs[i].v==pr) continue;
		dfs(vs[i].v,rt,x);
		v.push_back(F[vs[i].v]);
	}
	if(!(v.size()&1)) v.push_back(0);
	sort(v.begin(),v.end());
	// printf("son of node %d len of %d\n",rt,x);
	// for(int i=0;i<v.size();i++) printf("%d ",v[i]); puts("");
	int l=0,r=v.size()-1,rs=n+1;
	while(l<=r)
	{
		int mid=(l+r)>>1,fg=1;
		for(int i=0,j=v.size()-1;i<j;i++,j--)
		{
			if(i==mid) i++; if(j==mid) j--;
			fg&=(v[i]+v[j])<=x;
		}
		if(fg) r=mid-1,rs=v[mid];
		else l=mid+1;
	}
	F[rt]=rs+1;
}
inline bool check(int x)
{
	dfs(Rt,0,x); return F[Rt]<=x+1;
}
int main()
{
	// freopen("read.in","r",stdin);
	n=read(); for(int i=1;i<n;i++)
	{
		int u=read(), v=read();
		addedge(u,v); du[u]++;
		addedge(v,u); du[v]++;
	}
	int cnt=0; for(int i=1;i<=n;i++) 
		cnt+=du[i]&1,Rt=du[i]==1? i:Rt;
	//Rt=1;
	int l=1,r=n,B=0;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid)) r=mid-1,B=mid;
		else l=mid+1;
	}
	cout << cnt/2 << " " << B << endl;
	return 0;
}

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

const int maxn = 1e5+10;

typedef pair<int,int> II;
vector<II> vt[maxn];

int visited[maxn];
int res[maxn];

void dfs(int u, int id) {
	visited[u] = true;

	res[u] = id;
	for(II e: vt[u]) {
		int v = e.first;
		int w = e.second;
		if (visited[v]) continue;
		if (w == 0) dfs(v ,id);
		else dfs(v, (id ^ 1));
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = 0;
	cin >> n;
	for(int i=0;i<n-1;i++) {
		int u = 0;
		int v = 0;
		int w = 0;
		cin >> u >> v >> w;
		u --;
		v --;
		w %= 2;
		vt[u].push_back(II(v, w));
		vt[v].push_back(II(u, w));
	}

	dfs(0, 0);
	for(int i=0;i<n;i++) cout << res[i] <<endl;
	return 0;
}


Measured memory_bytes: 8704
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
/********************************************************************************************************************************/
/* main *************************************************************************************************************************/
/********************************************************************************************************************************/
int DEBUG = 0;										/* デバッグプリント 提出時は0 */

int main()
{
	int		i,j,r,c,t;
	int		a[101][101];

	scanf("%d %d", &r, &c);
	for(i=1;i<=r;i++) {
		t = 0;
		for(j=1;j<=c;j++) {
			scanf("%d",&a[i][j]);
			t += a[i][j];
		}
		a[i][c+1] = t;
	}

	for(i=1;i<=r;i++) {
		for(j=1;j<=c+1;j++) {
			printf("%d",a[i][j]);
			if (j==c+1) printf("\n");
			else printf(" ");
		}
	}

	for(j=1;j<=c+1;j++) {
		t = 0;
		for(i=1;i<=r;i++) {
			t += a[i][j];
		}
		printf("%d",t);
		if (j==c+1) printf("\n");
		else printf(" ");
	}

	return 0;
}



Measured memory_bytes: 2108
#include<iostream>
#include<functional>
#include<algorithm>

using namespace std;

int main(){
	int n;
	int a[110];
	cin >> n;
	for(int i=0; i<n; ++i)  cin >> a[i];

	sort(a,a+n,greater<int>());;
	int alice=0;
	int bob=0;
	for(int i=0; i<n; ++i){
	   	if(i%2==0)
			alice+=a[i];
		else
			bob+=a[i];
	}
	cout << alice-bob << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,n;
  cin>>N;
  n=N;
  int s;
  if (N!=0){  
    while(N>0){
    s=s+N%10;
    N=(N-N%10)/10;
    	if(N==0){
          if(n%s==0)
             cout<<"Yes";
  		  else
    		 cout<<"No";
        } 
    }
  }
  else cout<<"No";
}


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int a,b;
    cin >> a >> b;
    if (a + b < 10){
        cout << a+b;
    } else {
        cout << "error" << endl;
    }

    return 0;
}


Measured memory_bytes: 504
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

ll nC2(ll n){
    return n*(n-1)/2;
}

int main() {
   
    ll n;
    cin >> n;
    const ll p = n;
    ll a[p];
    for (ll i=1;i<=n;i++){
        a[i] = 0;
    }
    vector <ll> v;
    for(ll i=1;i<=n;i++){
        ll tmp;
        cin >> tmp;
        a[tmp]++;
        v.push_back(tmp);
    }
    ll ans = 0;
    for (ll i=1;i<=n;i++){
//        cout << a[i] << endl;
        ans += nC2(a[i]);
//        cout << ans << endl;
    }
    for(ll i=0;i<n;i++){
        cout << ans - nC2(a[v[i]]) + nC2(a[v[i]] - 1) << endl;
    }

}

Measured memory_bytes: 5872
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define pb push_back
int main()
{
    string a,b,c;
    int f,i;
    cin>>a;
    f=0;
    for(i=2;i<6;i+=2)
    {
        if(a[i]!=a[i+1])
        {
            f=1;
            break;
        }
    }
    if(f==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

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

  int n,k;
  cin>>n>>k;

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

  int dp[n];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  
  for (int i = 2; i < n; ++i)
  {
    dp[i]=2000000000;
  	for(int j=i-k>0?i-k:0;j<i;++j)
  	{
  		dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]));
  	}
  }
   // for (int i = 0; i < n; ++i)
   // {
   // 	cout<<dp[i]<<" ";
   // }
  cout<<dp[n-1];
  return 0;
}


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

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef long long ll; 
typedef long double ld; 
typedef pair<int,int> p32;   
typedef pair<ll,ll> p64;  
typedef pair<double,double> pd; 
typedef pair<ld,ld> pld; 
typedef vector<int> v32;  
typedef vector<ll> v64;  
typedef vector<pd> vpd;   
typedef vector<p32> vp32;  
typedef vector<p64> vp64;  
typedef vector<v32> vv32;  
typedef vector<v64> vv64;  

#define pb push_back
#define mp make_pair
#define prarr(a,n) cerr<<#a<<" : ";for(ll i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define prmat(mat,row,col) cerr<<#mat<<" :\n";for(ll i=0;i<row;i++) {for(ll j=0;j<col;j++) cerr<<mat[i][j]<<"\t";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(NULL); cin.tie(NULL)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {ll idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
template <class T> void prall(T a) { prc(all(a)); }

#include <bits/extc++.h> /** keep-include */
using namespace __gnu_pbds;
template <class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag,
        tree_order_statistics_node_update>;

const int inf=1000*1000*1000+9; 
const ll infl=1ll*inf*inf; 
int mod=1000*1000*1000+7;  
// ----------------------------------------------------------------------------	-------------- 

void pre(){
}

void solve(){
  int n; cin>>n;
  vector<map<int,ll>> dp(n+1); 
  v32 vals(n+1); 
  for(int i=1;i<=n;i++) cin>>vals[i]; 
  dp[1][1]=vals[1]; 
  dp[2][1]=max(vals[2],vals[1]); 
  for(int i=3;i<=n;i++){
    for(int j=-2;j<=2;j++){
      int up=i/2+(i%2); 
      int prevup=(i-1)/2+(i-1)%2; 
      if(i/2+j<=up){
        dp[i][i/2+j]=max((i/2+j<=prevup)?dp[i-1][i/2+j]:-infl,dp[i-2][i/2+j-1]+vals[i]); 
      }
    }
  }
  cout<<dp[n][n/2]<<endl; 
}



int main(){
	// clock_t beg=clock(); 
  fast_io; 
  int testcases=1; 
  pre(); 
  // cin>>testcases; 
  cout << fixed << setprecision(13); 
  int cs=0; 
  while(testcases--){
    cs++; 
    // cout<<"Case #"<<cs<<": "; 
    solve(); 	
  }
	// clock_t end=clock(); 
	// fprintf(stderr, "%lf\n", (double)(end-beg)/(CLOCKS_PER_SEC));
}





Measured memory_bytes: 57016
# B - Count Balls
n, a, b = map((int),(input().split()))


if a == 0:
    print(0)
else:
    count = (int)(n / (a + b))
    amari = (int)(n % (a + b))

    if amari > a:
        amari = a
    print(count * a + amari)

Measured memory_bytes: 3060
#include <iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define pb push_back
#define fi first
#define se second
#define sz(x)  x.size()
#define cl(x)  x.clear()
#define all(x)  x.begin() , x.end()
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++)
#define per(i , n , x)  for(int i = n ; i >= x ; i --)
#define mem(x)  memset(x , 0 , sizeof(x))
#define mem_1(x)  memset(x , -1 , sizeof(x))
#define mem_inf(x)  memset(x , 0x3f3f3f3f , sizeof(x))
#define debug(x)  cout << '*' << x << '\n'
#define ddebug(x , y)  cout << '*' << x << ' ' << y << '\n'
using namespace std ;
typedef long long ll ;
typedef pair<int , int> pii ;
typedef pair<ll , ll> pll ;
const ll mod =  1e9+7;
const ll maxn = 1e5 + 10 ;
const int inf = 0x3f3f3f3f ;
const double eps = 1e-8 ;


int main(){
    int l,r,d;
    cin>>l>>r>>d;
    int a=(l+d-1)/d,b=r/d;
    cout<<b-a+1;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define NIL 2000000

int get_depth(int node_id, vector<int> &parent) {
    int parent_id = parent.at(node_id);
    if (parent_id == NIL)
        return 0;
    return get_depth(parent_id, parent) + 1;
}

void print_children(int node_id, vector<int> &left, vector<int> &right) {
    int left_c = left.at(node_id);

    if (left_c != NIL) {
        cout << left_c;
        int right_c = right.at(left_c);
        while (right_c != NIL) {
            cout << ", " << right_c;
            right_c = right.at(right_c);
        }
    }
}

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

    vector<int> parent(n, NIL), left(n, NIL), right(n, NIL);

    for (int i = 0; i < n; i++) {
        int node;
        cin >> node;

        int k;
        cin >> k;
        if (k) {
            vector<int> children(k);
            for (int j = 0; j < k; j++)
            {
                cin >> children.at(j);
            }
            for (int c : children) {
                parent.at(c) = node;
            }
            left.at(node) = children.at(0); // 最も左の子
            
            if (k > 1) {
                for (int j = 0; j < k - 1; j++) {
                    right.at(children.at(j)) = children.at(j + 1); // すぐ右の子
                }
            }
        }
        
    }

    for (int node_i = 0; node_i < n; node_i++) {
        // node_id
        cout << "node " << node_i << ": ";
        
        // parent
        cout << "parent = ";
        if (parent.at(node_i) == NIL)
            cout << -1;
        else
            cout << parent.at(node_i);
        cout << ", ";

        // depth
        cout << "depth = ";
        cout << get_depth(node_i, parent);
        cout << ", ";

        // type
        if (parent.at(node_i) == NIL)
            cout << "root";
        else if (left.at(node_i) == NIL)
        {
            cout << "leaf";
        }
        else
        {
            cout << "internal node";
        }
        cout << ", ";

        // children
        cout << "[";
        print_children(node_i, left, right);
        cout << "]";
        cout << endl;
    }
}



Measured memory_bytes: 4288
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.InputMismatchException;

public class Main {

	public static void main(String[] args) {
		Task task = new Task();
		task.solve();
	}

	public static class Task {
		static final long MOD = (long) 1e9 + 7;
		static int[] to_use = { 3, 5, 7 };
		static long target, res;
		HashSet<Integer> valids;

		public void solve() {
			Scan sc = new Scan();
			target = sc.scanLong();
			valids = new HashSet<>();
			res = 0;
			dfs(0);
			System.out.println(res);
		}

		private void dfs(long soFar) {
			if (soFar > target) {
				return;
			}
			valids.clear();
			long cpy = soFar;
			while (cpy > 0) {
				int last_digit = (int) (cpy % 10);
				if (last_digit == 3 || last_digit == 5 || last_digit == 7)
					valids.add(last_digit);
				if (valids.size() == 3) {
					++res;
					break;
				}
				cpy /= 10;
			}
			for (Integer digit : to_use)
				dfs(soFar * 10 + digit);
		}
	}

	public static class Scan {
		private byte[] buf = new byte[1024];
		private int index;
		private InputStream in;
		private int total;

		public Scan() {
			in = System.in;
		}

		public int scan() {
			if (total < 0)
				throw new InputMismatchException();
			if (index >= total) {
				index = 0;
				try {
					total = in.read(buf);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				if (total <= 0)
					return -1;
			}
			return buf[index++];
		}

		public long scanLong() {
			long integer = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n)) {
				if (n >= '0' && n <= '9') {
					integer *= 10;
					integer += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			return neg * integer;
		}

		public double scanDouble() throws IOException {
			double doub = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n) && n != '.') {
				if (n >= '0' && n <= '9') {
					doub *= 10;
					doub += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			if (n == '.') {
				n = scan();
				double temp = 1;
				while (!isWhiteSpace(n)) {
					if (n >= '0' && n <= '9') {
						temp /= 10;
						doub += (n - '0') * temp;
						n = scan();
					} else
						throw new InputMismatchException();
				}
			}
			return doub * neg;
		}

		public String scanString() {
			StringBuilder sb = new StringBuilder();
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			while (!isWhiteSpace(n)) {
				sb.append((char) n);
				n = scan();
			}
			return sb.toString();
		}

		public char scanChar() {
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			return (char) n;
		}

		private boolean isWhiteSpace(int n) {
			if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
				return true;
			return false;
		}
	}
}


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

int main(int argc, char* argv[]){
  int n,m; cin >> n >> m;
  vector<vector<int>> x(m, vector<int>(0));
  for(int i = 0; i < n ; i++){
    int a; cin >> a;
    if(a % m == 0) x[0].push_back(a);
    else x[a%m].push_back(a);
  }
  int ans = 0;
  for(int i = 0; i < (x.size() - x.size()%2)/2 + 1; i++){
    if(i%m == 0) ans += (x[0].size() - (x[0].size()%2))/2;
    else if((i * 2) % m == 0) ans += (x[i].size() - x[i].size()%2)/2;
    else{
      int a,b;
      if(x[i].size() > x[m-i].size()){
        a = i;
        b = m - i;
      }
      else{
        a = m - i;
        b = i;
      }
      ans += x[b].size();
      int count = 0;
      sort(x[a].begin(), x[a].end());
      for(int j = 0; j < x[a].size()-1 ; j++){
        if(x[a].size() - x[b].size() >= count+2){
          if(x[a][j] == x[a][j+1]){
            count += 2;
            j++;
          }
        }
        else break;
      }
      ans += count/2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 5760
#include  <functional>
#include  <algorithm>
#include  <exception>
#include  <stdexcept>
#include  <streambuf>
#include  <iterator>
#include  <string.h>
#include  <stdlib.h>
#include  <typeinfo>
#include  <valarray>
#include  <iostream>
#include  <sstream>
#include  <istream>
#include  <stdio.h>
#include  <climits>
#include  <clocale>
#include  <complex>
#include  <csetjmp>
#include  <csignal>
#include  <cstdarg>
#include  <cstddef>
#include  <ctype.h>
#include  <cassert>
#include  <cstdlib>
#include  <utility>
#include  <cstring>
#include  <numeric>
#include  <ostream>
#include  <cwctype>
#include  <fstream>
#include  <iomanip>
#include  <math.h>
#include  <bitset>
#include  <cctype>
#include  <string>
#include  <vector>
#include  <limits>
#include  <locale>
#include  <memory>
#include  <cerrno>
#include  <iosfwd>
#include  <cfloat>
#include  <cstdio>
#include  <cwchar>
#include  <cmath>
#include  <ctime>
#include  <deque>
#include  <queue>
#include  <stack>
#include  <list>
#include  <ios>
#include  <map>
#include  <set>
#include  <new>
#define fi first
#define se second
#define pb push_back
#define ll long long
#define pii pair<int,int>
using namespace std;
const int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
const int maxn=100005,maxm=105;
int n,m;
int col;
int a[maxn];
int ans[maxm][maxm];
int main()
{
    cin>>n>>m;
    cin>>col;
    for(int i=1;i<=col;i++)
    {
        cin>>a[i];
    }
    int k=0,now=1;
    bool flag=0;
    for(int i=0;i<n;i++)
    {
        if(!flag)
        {
            for(int j=0;j<m;j++)
            {
                ans[i][j]=now;
                k++;
                if(k==a[now])
                {
                    now++;
                    k=0;
                }
            }
            flag=1;
        }
        else
        {
            for(int j=m-1;j>=0;j--)
            {
                ans[i][j]=now;
                k++;
                if(k==a[now])
                {
                    now++;
                    k=0;
                }
            }
            flag=0;
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
    int n, hbef, haft, dec = 0, decmax = 0;
    cin >> n >> hbef;
    for(int i = 1; i < n; i++){
        scanf("%d", &haft);
        if(hbef >= haft){
            dec++;
        }
        else{
            decmax = (decmax >= dec ? decmax : dec);
            dec = 0;
        }
        hbef = haft;
    }
    decmax = (decmax >= dec ? decmax : dec);
    cout << decmax << endl;
    return 0;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
S = []
for i in range(H):
    S.append(input())
for i in range(1,H-1):
    for j in range(1,W-1):
        if S[i][j]== "#" and S[i+1][j] == S[i][j+1] == S[i-1][j] == S[i][j-1] == ".":
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 39408
/**
 *   
 *   Date: 31 March 2020
 *   Time: 12:45:06
**/
#pragma GCC optimize("03")
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vec;
typedef vector<vector<ll> > matrix;
ll const mod=1000000007;
ll deg[100100],dp[100100];
vec adj[100100];
int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll n,m,mx=0,x,y;
	queue<ll> qe;
	cin>>n>>m;
	for(ll i=0;i<m;i++)
	{
		cin>>x>>y;
		adj[x].push_back(y);
		deg[y]+=1;
	}
	for(ll i=1;i<=n;i++)
	{
		if(deg[i] == 0)
		{
			qe.push(i);
		}
	}
	while(!qe.empty())
	{
		x=qe.front();
		qe.pop();
		for(auto it=adj[x].begin();it != adj[x].end();it++)
		{
			dp[*it]=max(dp[x]+1,dp[*it]);
			deg[*it]-=1;
			if(deg[*it] == 0)
				qe.push(*it);
		}
	}
	for(ll i=1;i<=n;i++)
	{
		mx=max(mx,dp[i]);
	}
	cout<<mx<<endl;

return 0;
}

Measured memory_bytes: 7296
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			int r = in.nextInt();
			if(n*r==0){
				break;
			}

			Vector<Integer> card = new Vector<Integer>();
			for (int i = 1; i <= n; i++) {
				card.add(i);
			}
			for (int i = 0; i < r; i++) {
				int p = in.nextInt();
				int c = in.nextInt();

				int pp = n-p-c+1;
				for (int j = pp; c>0; c--) {
					card.add(card.get(pp));
					card.remove(j);
				}
			}
			System.out.println(card.elementAt(n-1));
		}

	}

}

Measured memory_bytes: 36876
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <vector>
#include <iomanip>

using namespace std;

int main(void) {
  string s;
  cin >> s;
  int c = 0;
  for (int i = 0; i < 6; i++) {
    if (s[i] == '1') c++;
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 888
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma comment(linker, "/STACK:2000000")

#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'
using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 2e5+5, LG = 19, MOD = 998244353;
const int SQ =320;
const long double EPS = 1e-7;
vector<ll> a;
int n;
ll solve(int l, int r, ll curX, ll curY){
  if(l>r)return 0;

  ll ans = LLONG_MAX;

  for(int i = l; i <= r; i++){

    ans = min(ans, solve(l,i-1,curX,curX+curY) + solve(i+1,r,curX+curY,curY) + (curX + curY) * a[i]);

  }

  return ans;

}
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  cin >> n;
  a.resize(n);
  f(i,0,n)
    cin >> a[i];
  ll ans = a[0] + a.back();
  a.erase(a.begin());
  a.pop_back();

  n -= 2;
  cout << ans+solve(0,n-1,1,1) << '\n';

  return 0;
}


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

int main()
{
  int N,M,sum,n=0;
  int w[1500],h[1500],W[1000000]={},H[1000000]={};

  while(1){
    cin>>N>>M;
    if(N==0&&M==0)break;
    for(int i=0;i<N;i++)cin>>h[i];
    for(int i=0;i<M;i++)cin>>w[i];
    sum=0;
    for(int i=0;i<N;i++){
      for(int j=i;j<N;j++){
        n+=h[j];
	H[n]++;
      }
      n=0;
    }
    for(int i=0;i<M;i++){
      for(int j=i;j<M;j++){
        n+=w[j];
	W[n]++;
      }
      n=0;
    }
    for(int i=0;i<1000000;i++){
      sum+=H[i]*W[i];
      H[i]=0;W[i]=0;
    }
    cout<<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 8988
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll const mod = 1e9+7;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll ans = 0;
    for(ll i = k; i <= n+1; i++){
        ll L = i * (i-1) / 2;
        ll R = n * i - L;
        ans += R - L + 1;
    }
    cout<<ans%mod<<"\n";

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

struct HLD {
  vector<int> label, parent, head;

  HLD(const vector<vector<int>> &g) : label(g.size()), parent(g.size()), head(g.size()) {
    const int n = g.size();
    vector<int> size(n, 1);
    auto dfs = [&](auto dfs, int u, int p) -> void {
      for (int v : g[u]) if (v != p) {
        dfs(dfs, v, u);
        size[u] += size[v];
      }
    };
    dfs(dfs, 0, -1);
    int k = 0;
    auto dfs2 = [&](auto dfs, int u, int p, int h) -> void {
      label[u] = k++;
      head[u] = h;
      parent[u] = p;
      pair<int, int> heavy(-1, -1);
      for (int v : g[u]) if (v != p) heavy = max(heavy, {size[v], v});
      if (heavy.first != -1) dfs(dfs, heavy.second, u, h);
      for (int v : g[u]) if (v != p && v != heavy.second) dfs(dfs, v, u, v);
    };
    dfs2(dfs2, 0, -1, 0);
  }

  int lca(int u, int v) {
    for (;;) {
      if (label[u] > label[v]) swap(u, v);
      if (head[u] == head[v]) return u;
      v = parent[head[v]];
    }
  }
};

#define getchar getchar_unlocked
#define putchar putchar_unlocked

int i32() {
  int n, c;
  while ((c = getchar()) < '0') if (c == EOF) return -1;
  n = c - '0';
  while ((c = getchar()) >= '0') n = n * 10 + c - '0';
  return n;
}

void print(int n) {
  int res[11], i = 0;
  do { res[i++] = n % 10, n /= 10; } while (n);
  while (i) putchar(res[--i] + '0');
  putchar('\n');
}

int main() {
  int n = i32();
  int q = i32();
  vector<vector<int>> g(n);
  struct edge {
    int v, c, w;
  };
  vector<vector<edge>> g2(n);
  rep(i, n-1) {
    int u = i32() - 1;
    int v = i32() - 1;
    int c = i32();
    int w = i32();
    g[u].push_back(v);
    g[v].push_back(u);
    g2[u].push_back((edge){v, c, w});
    g2[v].push_back((edge){u, c, w});
  }
  HLD hld(g);
  vector<ll> ans(q);
  struct query {
    int x, y;
    int coeff;
    int i;
  };
  vector<vector<query>> qs(n);
  rep(i, q) {
    int x = i32();
    int y = i32();
    int u = i32() - 1;
    int v = i32() - 1;
    qs[u].push_back((query){x, y, 1, i});
    qs[v].push_back((query){x, y, 1, i});
    qs[hld.lca(u, v)].push_back((query){x, y, -2, i});
  }
  ll dist = 0;
  vector<ll> distc(n);
  vector<ll> cnt(n);
  auto dfs = [&](auto dfs, int u, int p) -> void {
    for (query q : qs[u]) {
      ans[q.i] += q.coeff * (dist - distc[q.x] + cnt[q.x] * q.y);
    }
    for (edge e : g2[u]) {
      if (e.v == p) continue;
      distc[e.c] += e.w;
      cnt[e.c]++;
      dist += e.w;
      dfs(dfs, e.v, u);
      dist -= e.w;
      cnt[e.c]--;
      distc[e.c] -= e.w;
    }
  };
  dfs(dfs, 0, -1);
  rep(i, q) {
    print(ans[i]);
  }
}


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

template<typename T1,typename T2> inline void cmax(T1 &a,T2 b) {
  if (a < b) a = b;
}

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector V(H + 1, vector(W + 1, 0));
  for (int h, w, v; cin >> h >> w >> v;) V.at(--h).at(--w) = v;
  vector DP(H + 1, vector(W + 1, vector(5, 0L)));
  DP.at(0).at(0).at(1) = V.at(0).at(0);
  for (int h = 0; h < H; h++) {
    for (int w = 0; w < W; w++) {
      for (int i = 0; i < 4; i++) {
        long now = DP.at(h).at(w).at(i);
        cmax(DP.at(h + 1).at(w).at(0), now);
        cmax(DP.at(h + 1).at(w).at(1), now + V.at(h + 1).at(w));
        cmax(DP.at(h).at(w + 1).at(i), now);
        cmax(DP.at(h).at(w + 1).at(i + 1), now + V.at(h).at(w + 1));
      }
    }
  }
  cout << *max_element(DP.at(H - 1).at(W - 1).begin(), DP.at(H - 1).at(W - 1).begin() + 4) << "\n";
}


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

int main() {
    long long n, m, k; cin >> n >> m >> k;
    long long a[n+1]; long long b[m+1]; a[0] = 0; b[0] = 0;
    for (long long i = 1; i <= n; i ++) cin >> a[i];
    for (long long i = 1; i <= m; i ++) cin >> b[i];
    for (long long i = 1; i <= n; i ++) a[i] += a[i-1];
    for (long long i = 1; i <= m; i ++) b[i] += b[i-1];
    long long firstcntr = 0; long long seccntr = m; long long maxbooks = 0;
    while(true) {
        if (a[firstcntr] > k || firstcntr >= n+1) break;
        while(a[firstcntr] + b[seccntr] > k) seccntr--;
        maxbooks = max(firstcntr + seccntr, maxbooks); firstcntr++;
    } cout << maxbooks << endl;
}

Measured memory_bytes: 6740
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <stdlib.h>     /* srand, rand */
#include <time.h>       /* time */
#define mt make_tuple
#define ll long long
#define ld long double
#define eb emplace_back
#define fi first
#define pb push_back
//#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define scanVec(vec) for(int i = 0; i < SZ(vec) ; i++){ cin >> vec[i];}
#define printVec(vec) for(int i = 0; i < SZ(vec) ; i++){ cout<<vec[i]<<" ";}
#define mod(a,b) ((a%b +b)%b)
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
//#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define lastEle(vec) vec[vec.size()-1] 
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) 
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
//#define PI 3.1415926535897932384626
 
using namespace std;
 using namespace __gnu_pbds;
 template <typename T>
 using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
 
/*
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
 */
//----------------------------------------------------------------------------------------------------------------------
 
void swap(int & a, int & b){
    auto temp = a;
    a = b;
    b = temp;
}
 
const ll MOD = 1e9 + 7;
 
ll inf = 1LL*1e17;
 
void no(){
    cout <<"NO" << endl;
   //exit(0);
}
 
void yes(){
    cout <<"YES" << endl; //exit(0);
}
 
const ll md = 998244353;

const int MAXN = 3e3 + 10;
// pref and suff
ll dp[MAXN][MAXN];

void sl(){
	int n; cin >> n;
	vector< ll > arr (n); scanVec(arr);
	
	for(int L = n - 1; L >= 0;L--){
		for(int R = L; R < n;R++){
			if(L == R) {
				dp[L][R] = arr[L];
				continue;
			}
			dp[L][R] = max(  -dp[L + 1][R] + arr[L] , -dp[L][R - 1] + arr[R]);
			
		}
	}
	
	cout << dp[0][n-1] << endl;
}

 
int main(){
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int ts = 0;
    if(ts == 1) cin >> ts;
    else ts = 1;
    while(ts--) sl(); 
    return 0;
} 


Measured memory_bytes: 70016
while True:
    try:
        a, b, c, d, e, f = map(int, input().split())
    except:
        break
    y = (c * d - f * a) / (b * d - e * a)
    x = (c - (b * y)) / a
    print("{:.3f} {:.3f}".format(x, y))

Measured memory_bytes: 5612
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;

int main(void){
        int i,j;
        long long n,k;
        
        scanf("%lld%lld",&n,&k);
       //0+...+k-1
       //(n-k+1)+...+n

       long long a = 0;
       for(i=k;i<=n+1;i++){
               a += (n-i+1)*i + 1;
               a = a % 1000000007;
       }
       printf("%lld\n", a);
        return 0;
}


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

bool JudgeTriangle(int a, int b, int c)
{
    std::vector<int> numbers;
    numbers.push_back(a);
    numbers.push_back(b);
    numbers.push_back(c);
    std::sort(numbers.begin(), numbers.end());
    
    c = numbers[2];
    b = numbers[1];
    a = numbers[0];
    return (a*a+b*b == c*c);
}

int main()
{
    int n;
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        int a, b, c;
        std::cin >> a >> b >> c;
        if (JudgeTriangle(a, b, c)) {
            std::cout << "YES" << std::endl;
        } else {
            std::cout << "NO" << std::endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3152
s = gets.split.map{|item| item.to_i}
str = []
s[0].times do
    str.push(gets)
end

ans = []
pa = "#"
(s[1] + 1).times do
    pa = pa + "#"
end
ans.push(pa)

s[0].times do |n|
    k = "#" + str[n].chomp + "#"
    ans.push(k)
end

las = pa
ans.push(las)

puts ans

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

using namespace std;
typedef long long ll;

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

    string s;
    cin >> s;
    int n = s.length();
    int sum = 0;
    for(int i = 0; i < n; ++i)
        sum += s[i] - '0';
    if(sum % 9 == 0)
        cout << "Yes" << "\n";
    else
        cout << "No" << "\n";
    
    return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
  
constexpr double eps = 0;
double deg2rad(double x) { return x / 360 * (2 * M_PI); }
double frem(double x, double y) { return fmod(fmod(x, y) + y + eps, y); }
enum face_t { ABC, ACD, ADB, BCD };
  
face_t get_face() {
    string xy; int d, l; cin >> xy >> d >> l;
    double face_theta =
        xy == "BC" ? 0 :
        xy == "CD" ? 60 :
        xy == "DB" ? 120 :
        NAN;
    double theta = deg2rad(face_theta + d);
    double x = l * cos(theta);
    double y = l * sin(theta);
    double z60 = x + y / sqrt(3);
    double z120 = - x + y / sqrt(3);
    z60 = frem(z60, 2);
    z120 = frem(z120, 2);
    double w = (z60 + z120) * (sqrt(3) / 2);
    return
        w < sqrt(3) / 2 ?
            ACD :
        w < sqrt(3) ?
            z60 > 1 ? ABC :
            z120 > 1 ? ADB :
            BCD :
        w < 3 * sqrt(3) / 2 ?
            z60 < 1 ? ABC :
            z120 < 1 ? ADB :
            BCD :
        ACD;
}
  
int main() {
    face_t a = get_face();
    face_t b = get_face();
    cout << (a == b ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 3500
#include<iostream>
#include<vector>
#include<climits>

using namespace std;

int A,B,C,D,N; vector<int>l;

const int inf = (1<<29);

int dfs(int depth, int LA, int LB, int LC){
  if( depth == N ){ 
    if(LA == 0 || LB == 0 || LC == 0){ return inf;}
     else{ return abs( LA - A) + abs( LB - B ) + abs( LC - C) - 30 ;}}
  
   int ret1 = dfs( depth+1, LA + l[depth],LB,LC) + 10 ;
   int ret2 = dfs( depth+1, LA, LB + l[depth], LC) + 10;
   int ret3 = dfs( depth+1, LA, LB, LC + l[depth]) + 10;
   int ret4 = dfs( depth+1, LA,LB,LC);
  
   return min(min(ret1,ret2),min(ret3,ret4));}
  

int main(){
 cin >> N >> A >> B >> C;
 l.resize(N);
  for(int i = 0; i < N; i++){ cin >> l[i];}
  cout << dfs(0,0,0,0) << endl; return 0;}
  
  
  
  


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}


int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}


int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}


int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}


int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


int main(){
  lint n;
  vector<lint> l;
  cin>>n;
  l.pb(1);
  l.pb(1);
  for(lint i=2;i<=n;i++) l.pb(l[i-1]+l[i-2]);
  cout<<l[n]<<endl;
}


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

int main() {
  string S;
  cin >> S;
  
  int ss =S.size();
  int count=0;
  int countmax=0;
  
  for(int i=0;i<ss-1;i++){
    if(S.at(i)=='A'||S.at(i)=='T'||S.at(i)=='G'||S.at(i)=='C'){
      count =1;
      for(int j=i+1;j<ss;j++){
        if(S.at(j)=='A'||S.at(j)=='T'||S.at(j)=='G'||S.at(j)=='C'){
          count ++;
        }
        else{ break;}
      }
    }
      if(count>countmax){
        countmax=count;}
  }
  
  if(S.at(ss-1)=='A'||S.at(ss-1)=='T'||S.at(ss-1)=='G'||S.at(ss-1)=='C'){
    count =1;
    if(count>countmax){countmax=1;}
  }
  
          
   cout << countmax <<endl;       
          
}

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

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

int main() {
	long long a, b;
  cin >> a >> b;
  cout << a / gcd(a, b) * b << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int ll
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
typedef vector<int> vi;
typedef vector<vi> vvi;
inline int in() { int x; cin >> x; return x; }

void solve() {
  int n = in(), k = in();
  vi p(n+1, 0); FOR(i,0,n) p[i+1] = in();
  int e = 0, maxe = 0;
  FOR(i,0,k) e += p[i]+1;
  FOR(i,k,n+1) {
    e += p[i]-p[i-k];
    if (maxe<e) maxe = e;
  }
  cout << fixed << setprecision(6) << (double)maxe/2 << endl;
}
#undef int
int main() {
  solve();
  return 0;
}


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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 0; i < 100; ++i) {
    if (a % 2 || b % 2 || c % 2) {
      cout << i << endl;
      return 0;
    }
    int _a = (b + c) / 2;
    int _b = (a + c) / 2;
    int _c = (a + b) / 2;
    a = _a, b = _b, c = _c;
  }
  cout << -1 << endl;
  return 0;
}



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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int a, b;
	cin >> a >> b;
	if (a == b)
		print("Draw");
	else if (a == 1)
		print("Alice");
	else if (b == 1)
		print("Bob");
	else if (a > b)
		print("Alice");
	else
		print("Bob");
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

const int nmax = 8;
vector<vector<bool>> graph(nmax, vector<bool>(nmax));

int dfs(int v, int n, vector<bool> used) {
    bool ok = true;
    rep(i, n) {
        if (!used[i]) ok = false;
    }
    if (ok) return 1;
    int res = 0;
    rep(i, n) {
        if (!graph[v][i]) continue;
        if (used[i]) continue;
        used[i] = true;
        res += dfs(i, n, used);
        used[i] = false;
    }
    return res;
}

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        graph[a][b] = graph[b][a] = true;
    }
    vector<bool> used(nmax);
    used[0] = true;
    cout << dfs(0, n, used) << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

A = np.loadtxt(open(0), np.int64, skiprows=1, ndmin=2)

N = ans = len(A)

while A.any():
    b = np.bincount(A[:, 0])
    A = np.reshape(A[A != np.argmax(b)], (N, -1))
    ans = min(ans, max(b))

print(ans)


Measured memory_bytes: 16588
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
    ll int jhogeo = 1;
    rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
    return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}

int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int N; cin>>N;
  vector<int> h(N);
  vector<int> a(N);
  
  rep(i,0,N){
    cin>>h[i];
    a[i]=0;
  }
  a[1]=abs(h[1]-h[0]);
  rep(i,2,N){
    a[i]=min(a[i-2]+abs(h[i]-h[i-2]),a[i-1]+abs(h[i]-h[i-1]));
  }
  cout<<a[N-1];
    
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順

Measured memory_bytes: 1024
fun main(args: Array<String>) = println(run {
    val n = readLine()!!.toInt()
    val v = readLine()!!.split(" ").map { it.toInt() }
    val c = readLine()!!.split(" ").map { it.toInt() }

    v.zip(c).map { it.first - it.second }.filter { it>0 }.sum()

})



Measured memory_bytes: 37720
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int x = stdIn.nextInt();

        if(a + b >= x && a <= x)
                System.out.println("YES");
        else
            System.out.println("NO");
    }
}

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true){
        	String strArr[] = br.readLine().split(" ");
            int a=Integer.parseInt(strArr[0]);
            int b=Integer.parseInt(strArr[1]);

            if(a==0 && b== 0){
            	break;
            }
            else if(b<a){
            	int c=a;
            	a=b;
            	b=c;
            }
            System.out.println(a+" "+b);

        }
    }
}

Measured memory_bytes: 27308