akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;typedef long long lint;typedef vector<lint> liv;
//#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define linf 1152921504606846976
#define MAXN 100010
#define md 1000000007//998244353

#define pb push_back
#define _vcppunko4(tuple) _getname4 tuple
#define _getname4(_1,_2,_3,_4,name,...) name
#define _getname3(_1,_2,_3,name,...) name
#define _trep2(tuple) _rep2 tuple
#define _trep3(tuple) _rep3 tuple
#define _trep4(tuple) _rep4 tuple
#define _rep1(n) for(lint i=0;i<n;++i)
#define _rep2(i,n) for(lint i=0;i<n;++i)
#define _rep3(i,a,b) for(lint i=a;i<b;++i)
#define _rep4(i,a,b,c) for(lint i=a;i<b;i+=c)
#define _trrep2(tuple) _rrep2 tuple
#define _trrep3(tuple) _rrep3 tuple
#define _trrep4(tuple) _rrep4 tuple
#define _rrep1(n) for(lint i=n-1;i>=0;i--)
#define _rrep2(i,n) for(lint i=n-1;i>=0;i--)
#define _rrep3(i,a,b) for(lint i=b-1;i>=a;i--)
#define _rrep4(i,a,b,c) for(lint i=a+(b-a-1)/c*c;i>=a;i-=c)
template<class T>
istream& operator>>(istream& is,vector<T>& vec);
template<class T,size_t size>
istream& operator>>(istream& is,array<T,size>& vec);
template<class T,class L>
istream& operator>>(istream& is,pair<T,L>& p);
template<class T>
ostream& operator<<(ostream& os,vector<T>& vec);
template<class T,class L>
ostream& operator<<(ostream& os,pair<T,L>& p);
template<class T>
istream& operator>>(istream& is,vector<T>& vec){ for(T& x: vec) is>>x;return is; }
template<class T,class L>
istream& operator>>(istream& is,pair<T,L>& p){ is>>p.first;is>>p.second;return is; }
//template<class T>
//ostream& operator<<(ostream& os,vector<T>& vec){ os<<vec[0];rep(i,1,vec.size())os<<' '<<vec[i];return os; }
//template<class T>
//ostream& operator<<(ostream& os,deque<T>& deq){ os<<deq[0];rep(i,1,deq.size())os<<' '<<deq[i];return os; }
template<class T,class L>
ostream& operator<<(ostream& os,pair<T,L>& p){ os<<p.first<<" "<<p.second;return os; }

inline void in(){}
template <class Head,class... Tail>
inline void in(Head&& head,Tail&&... tail){ cin>>head;in(move(tail)...); }
template <class T>
inline bool out(T t){ cout<<t<<'\n';return 0; }
inline bool out(){ cout<<'\n';return 0; }
template <class Head,class... Tail>
inline bool out(Head head,Tail... tail){ cout<<head<<' ';out(move(tail)...);return 0; }

#define rep(...) _vcppunko4((__VA_ARGS__,_trep4,_trep3,_trep2,_rep1))((__VA_ARGS__))
#define rrep(...) _vcppunko4((__VA_ARGS__,_trrep4,_trrep3,_trrep2,_trrep1))((__VA_ARGS__))
#define lin(...) lint __VA_ARGS__;in(__VA_ARGS__)
#define stin(...) string __VA_ARGS__;in(__VA_ARGS__)
#define vin(type,name,size) vector<type> name(size);in(name)

int main(){
	lin(n);
	stin(s);
	lint a=0,b=0;
	rep(i,n){
		if(s[i]=='R')a++;
		else b++;
	}cout<<(a>b?"Yes":"No");
}

//int main(int argc,char *argv[]){
//	string inp;
//	if(argc>1)inp=argv[1];
//	else return 0;
//
//	ifstream fin(inp);
//	lint in_n;fin>>in_n;
//	fin.close();
//
//	lint a,b;cin>>a>>b;
//
//	return a+b!=in_n;
//}

//sub-EOF


Measured memory_bytes: 256
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['YES','NO']
Yn=['Yes','No']
 
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
#ts=time.time()
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

n,k=LI()
a=LI()

dp=[[0]*(k+1)for i in range(n+1)]
dp[0][0]=1

m=0
for i in range(n):
    b=[0]*(k+2)
    for x in range(k+1):
        b[x+1]=b[x]+dp[i][x]
        b[x+1]%=mo
    m+=a[i]
    for x in range(k+1):
        dp[i+1][x]=b[x+1]-b[max(0,x-a[i])]

ans=(dp[n][k]%mo)
print(ans)


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

using namespace std;
using ll = long long;

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

ll lmin(ll a,ll b){return a>b?b:a;}
ll lmax(ll a,ll b){return a>b?a:b;}

// Sorting
void insertionSort(int n,int*a,int g=1){for(int i=g;i<n;++i){int v=a[i],j=i-g;while(j>=0&&a[j]>v){a[j+g]=a[j];j-=g;}a[j+g]=v;}}
void shellSort(int n,int*a){vector<int>G;for(int h=1;;){if(h>n)break;G.push_back(h);h=3*h+1;}for(int i=G.size()-1;i>=0;--i)insertionSort(n,a,G[i]);}
int bubbleSort(int n,int*a){int s=0,j;bool f=1;for(int i=0;f;++i){f=0;for(j=n-1;j>=i+1;--j){if(a[j]<a[j-1]){swap(a[j],a[j-1]);f=1;s++;}}}return s;}
int selectionSort(int n,int*a){int s=0,j,m;for(int i=0;i<n-1;++i){m=i;for(j=i;j<n;++j)if(a[j]<a[m])m=j;swap(a[i],a[m]);if(i!=m)++s;}return s;}

// Searching
int binarySearch(int n,int*a,int k){int m,l=0,r=n;while(l<r){m=l+(r-l)/2;if(k<a[m])r=m;else if(a[m]<k)l=m+1;else return m;}return-1;}

// Mathematics
int gcd(int a,int b){!b?a:gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
vector<bool> primeTable(int n){
	vector<bool> t(n,1);
	t[0]=t[1]=0;
	for(int i = 2;i <= n; ++i){
		if(t[i]){
			for(int j=2;i*j<=n;++j){
				t[i*j]=0;
			}
		}
	}
	return t;
}


// Visualization
void printArray(int n,int*a){for(int i=0;i<n;++i)printf(i>0?" %d":"%d",a[i]);printf("\n");}

int main(){
	int x,ans; cin >> x;
	vector<bool> pt = primeTable(105000);
	for(int i = x; i <= 105000; ++i) if(pt[i]){
		ans = i;
		break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

vector<ll>path[101010];
ll flg[101010][2];

int main(){

    ll N, M;
    cin >> N >> M;
    rep(i, M){
        ll a, b;
        cin >> a >> b;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    flg[1][0] = 1;
    queue<P>Q;
    Q.push(P(1, 0));
    while(!Q.empty()){
        ll idx = Q.front().first;
        ll v = Q.front().second;
        Q.pop();
        ll v2 = v ^ 1;
        rep(i, path[idx].size()){
            ll to = path[idx][i];
            if(flg[to][v2])continue;
            flg[to][v2] = 1;
            Q.push(P(to, v2));
        }
    }
    
    ll ans = -M;
    ll x = 0, y = 0;
    for(ll i = 1; i <= N; i++)x += flg[i][0];
    for(ll i = 1; i <= N; i++)y += flg[i][1];
    if(x == N)ans += N * (N - 1) / 2;
    else ans += x * y;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8576
import java.util.Scanner;
import java.lang.Math.*;
class Main {
	public static void main(String args[]){	
			
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		int a[], b[];
		a = new int[n];
		b = new int[n];
		
		double one = 0;
		double two = 0;
		double three = 0;
		double inf = 0;
		
		for(int i = 0;i < n;i++){
			a[i] = scan.nextInt();
		}
			
		for(int i = 0;i < n;i++){
			b[i] = scan.nextInt();
		}		
		
		for(int i = 0; i < n; i++){
			one += Math.abs(a[i] - b[i]);
		}
		
		for(int i = 0; i < n; i++){
			two += Math.pow(Math.abs(a[i] - b[i]), 2);
		}
		two = Math.sqrt(two);
		
		for(int i = 0; i < n; i++){
			three += Math.pow(Math.abs(a[i] - b[i]), 3);
		}
		three = Math.cbrt(three);
		
		for(int i = 0; i < n; i++){
			if(inf < Math.abs(a[i] - b[i])){
				inf = Math.abs(a[i] - b[i]);
			}
		}
		
		System.out.println(one);
		System.out.println(two);
		System.out.println(three);
		System.out.println(inf);
	}
		
}

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

int main(){
	int n;
	cin >> n;
	int ans  = 1;
	if(n==120){
		cout << 3 << endl;return 0;
	}
	for(int i =1;i<=180;i++){
		if((180-n)*i % 180 == 0){
			cout << 2*i << endl;return 0;
		}
	}
}

Measured memory_bytes: 3616
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] xy = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int x = xy[0];
			int y = xy[1];

			var a = new List<int> { 1, 3, 5, 7, 8, 10, 12 };
			var b = new List<int> { 4, 6, 9, 11 };
			var c = new List<int> { 2 };

			if ((a.Contains(x) && a.Contains(y))
				|| (b.Contains(x) && b.Contains(y))
				|| (c.Contains(x) && c.Contains(y))) {
				Console.WriteLine("Yes");
			} else {
				Console.WriteLine("No");
			}
		}
	}
}

Measured memory_bytes: 11232
#include <iostream>
#include <string>

using namespace std;
int a[101],n;

void print(){
    for(int i=0;i<n-1;i++)
        cout << a[i]<<" ";
    cout <<a[n-1]<<endl;
}

int main(){
    
    cin >>n;
    
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    print();
    
    for(int i=1;i<n;i++){
        int v=a[i];
        int j=i-1;
        while(j>=0 && a[j]>v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1]=v;
        print();
    }
     
   
    
    return 0;
} 


Measured memory_bytes: 3088
N = int(input())
V = list(map(int,input().split()))
X = []
for i in range(N):
  X.append(V[i]-min(V))
def cal(V):
  A = 0
  for i in range(1,N+1):
    A += (sorted(V)[-i])/(2**(i))
  return A
print(cal(X) + min(V))  

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
int main()
{
	int n, r = 0;
	char s[101];
	scanf("%d%s", &n, s);
	for(int i = 0; i < n; ++i)
	{
		r += s[i] == 'R';
	}
	printf(r > n - r ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
N,K=map(int,input().split())
h=[0]*N
for i in range(N):
    H=int(input())
    h[i]=H
h.sort()
Ans=1000000000
for i in range(N-K+1):
    if Ans>(h[i+K-1]-h[i]):
        Ans=h[i+K-1]-h[i]
if K==1:
    print(h[0])
else:
    print(Ans)

Measured memory_bytes: 7472
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder102
{
    class Program
    {
        static void Main(string[] args)
        {
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());
            int C = int.Parse(Console.ReadLine());
            int X = int.Parse(Console.ReadLine());
            int count = 0;

            for (int i = 0; i <= A; i++)
            {
                for (int j = 0; j <= B; j++)
                {
                    for (int k = 0; k <= C; k++)
                    {
                        if (500 * i + 100 * j + 50 * k == X) count++;
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13140
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    S = input()
    A = 'CODEFESTIVAL2016'
    ans = 0
    for s, a in zip(S,A):
        if s!=a:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9072
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
}
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    cards[s][int(r) - 1] = 1
   
for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print(s, r + 1)

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    int n,m,k;cin>>n>>m>>k;
    char c[n][m],d[n][m];
    rep(i,n){
        rep(j,m){
            cin>>c[i][j];
            d[i][j]=c[i][j];
        }
    }
    int ans=0;
    rep(i,(1<<n)){
        rep(j,(1<<m)){
            rep(k,n){
                if((i>>k)&1){
                    rep(l,m){
                        d[k][l]='?';
                    }
                }
            }
            rep(k,m){
                if((j>>k)&1){
                    rep(l,n){
                        d[l][k]='?';
                    }
                }
            }
            int cnt=0;
            rep(k,n){
                rep(l,m){
                    if(d[k][l]=='#')cnt++;
                    d[k][l]=c[k][l];
                }
            }
            if(cnt==k)ans++;
        }
    }
    cout<<ans<<endl;
}

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

int main() {
	int n; cin>>n;
	int a[n],pre[n],suf[n];
	for (int i=0; i<n; i++)
		cin>>a[i];
	pre[0]=a[0];
	for (int i=1; i<n; i++)
		pre[i]=pre[i-1]+a[i];
	suf[n-1]=a[n-1];
	for(int i=n-2; i>=0; i--)
		suf[i]=suf[i+1]+a[i];
	int ans=INT_MAX;
	for(int i=0; i<n-1; i++)
		ans=min(ans, abs(pre[i]-suf[i+1]));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
  cin >> A >> B  >> C >> D;
  if(A+B > C+D)
    cout << "Left" << endl;
  if(A+B == C+D)
    cout << "Balanced" << endl;
  if(A+B < C+D)
    cout << "Right" <<endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n);++i)
const int INF =1001001001;
using ll=long long;
using P = pair<int,int>;
using Graph =vector<string>;
Graph field;
queue<P> q;

int main() {
ll n;
cin>>n;
vector<ll> a(n);
rep(i,n){
  cin>>a[i];
}
ll ans=0;
for(int i=0;i<n-2;i++){
  for(int j=i+1;j<n-1;j++){
    for(int k=j+1;k<n;k++){
      if(a[i]==a[j]||a[j]==a[k]||a[i]==a[k]){

      }else if((abs(a[i]-a[j])<a[k])&&(a[i]+a[j]>a[k])){
        ans++;
      }
    }
  }
}
cout<<ans<<endl;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  char tmp;
  long ans=0;
  long maxv=0;
  while(cin>>tmp){
    if(tmp=='I') ans++;
    else ans--;
    maxv=max(ans,maxv);
  }
  
  cout<<maxv<<endl;
}

Measured memory_bytes: 256
a,b,m=map(int,input().split())

f=list(map(int,input().split()))
r=list(map(int,input().split()))
    
ans=min(f)+min(r)

for i in range(m):
    x,y,p=map(int,input().split())
    ans=min(ans,f[x-1]+r[y-1]-p)

print(ans)
    

Measured memory_bytes: 18684
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD =   1000000007;

using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

// 入力
int N;
Graph G;
vector<int> ans;

// v を c に塗る。p は v の親
void dfs(int v, int p, int c) {
    ans[v] = c;
    for (auto e : G[v]) {
        if (e.first == p){
            continue;
        }
        
        if (e.second & 1){
            dfs(e.first, v, 1-c);
        }
        else{
            dfs(e.first, v, c);
        }
    }
}

int main()
{
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    cin >> N;
    ans.resize(N);
    G.assign(N, vector<Edge>());
    for (int i = 0; i < N-1; ++i) {
        int u, v, w; cin >> u >> v >> w;
        --u, --v;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }

    dfs(0, -1, 1);
    for (auto v : ans){
        cout << v << endl;
    }
    return 0;
}


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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pi;
typedef long double ld;
typedef pair<long double, long double> pld;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll i, j, k, l;

    ll N;
    cin >> N;
    vll A(N);
    for(auto &e : A)
        cin >> e;
    ll ans = 0;
    ll sub = A[N - 1];
    for(i = N - 2; i >= 0; i--) {
        ans = (ans + A[i] * sub % MOD) % MOD;
        sub = (sub + A[i]) % MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4780
#include<algorithm>
#include<chrono>
#include<ctime>  
#include<climits>
#include<functional>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
// #include<bits/stdc++.h>
using namespace std;
 
struct Debug{
    int cnt = 0;
    bool on = false;
    char debug[10] = "debug";
    template<class T>
    Debug & operator<<(const T & v) {
        if(on && cnt++ == 0) cerr << "debug: ";
        if(on) cerr << v << ' ';
        return *this;
    }
    Debug & operator<<(ostream&(*pManip)(ostream&)) {
        if(on) cerr << (*pManip);
        cnt = 0;
        return *this;
    }
} debug;
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {if(debug.on){for(auto x : v) debug << x; debug << endl;}}
#define printn(v, n) {if(debug.on){for(int _i = 0; _i < n; _i++) debug << *(v + _i); debug << endl;}}
 
typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

const int MAXN = 300 + 10;

int n, m, k, q;
long long graph[MAXN][MAXN] = {};

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cout.tie(nullptr);
    if(argc > 1 && !strcmp(argv[1], debug.debug)) debug.on = true;
    
    cin >> n >> m >> k;
    for(int i = 0; i < n; i++) {
    	for(int j = 0; j < n; j++) {
    		graph[i][j] = 1e15;
    	}
    }
    int u, v, w;
    for(int i = 0; i < m; i++) {
    	cin >> u >> v >> w;
    	u--; v--;
    	graph[u][v] = graph[v][u] = w;
    }

    for(int k = 0; k < n; k++) {
    	for(int i = 0; i < n; i++) {
    		for(int j = 0; j < n; j++) {
    			graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
    		}
    	}
    }

    for(int i = 0; i < n; i++) {
    	for(int j = 0; j < n; j++) {
    		graph[i][j] = graph[i][j] <= k ? 1 : 1e15;
    	}
    }

    for(int k = 0; k < n; k++) {
    	for(int i = 0; i < n; i++) {
    		for(int j = 0; j < n; j++) {
    			if(i == j) continue;
    			graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
    		}
    	}
    }

    cin >> q;
    for(int i = 0; i < q; i++) {
    	cin >> u >> v;
    	u--; v--;
    	if(graph[u][v] == 1e15)
    		cout << -1 << endl;
    	else
	    	cout << graph[u][v] - 1 << endl;
    }


    return 0;
 
}























Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
const ll MAX = 510000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 順列計算
ll ARR(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[n-k] % MOD;
}

void Main(){
    int n,m;
    cin >> n >> m;
    ll ans = 0,sign = 1;
    For(i,0,n+1){
        ll cnt = COM(n,i) * ARR(m,i) % MOD;
        cnt *= ARR(m-i,n-i) * ARR(m-i,n-i) % MOD;
        cnt %= MOD;
        ans = (ans + cnt * sign + MOD) % MOD;
        sign *= (-1);
    }
    cout << ans << endl;
}
int main(){
    COMinit();
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 15588
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



int main()
{

    int h,w;
    cin >> h >> w;
    vector<vector<int>> a(h,vector<int>(w,0));
    rep(i,h) rep(j,w) cin >> a[i][j];
    rep(i,h) rep(j,w){
        int z;cin >> z;
        a[i][j] = abs(a[i][j]-z);
    }
    const int d = 80*80*80+10;
    const int dd = d*2;
    
    vector<vector<bitset<dd>>> dp(h,vector<bitset<dd>>(w,0));
    
    
    dp[0][0][d-a[0][0]] = 1;
    dp[0][0][d+a[0][0]] = 1;
    rep(i,h) rep(j,w){
        if(i){
            dp[i][j] |= dp[i-1][j]>>a[i][j];
            dp[i][j] |= dp[i-1][j]<<a[i][j];
        }
        if(j){
            dp[i][j] |= dp[i][j-1]>>a[i][j];
            dp[i][j] |= dp[i][j-1]<<a[i][j];
        }
    }
    int ans = dd;
    rep(i,dd){
        if(dp[h-1][w-1][i]) ans = min(ans, abs(d-i));
    }

    out(ans);

    return 0;
}



Measured memory_bytes: 810752
#include <iostream>
#include <sstream>
#include <iomanip>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <set>
#include <map>
#include <stdlib.h>
#include <cctype>
#include <bitset>
using namespace std;
int main(){
    long int n,x,t;
    cin >> n >> x >> t;
    if(n % x == 0){
        cout << (n / x) * t << endl;
    }
    else{
        cout << (((n - (n % x)) / x) + 1) * t << endl;
    }
}

Measured memory_bytes: 3632
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

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

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 97;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T >, rb_tree_tag, tree_order_statistics_node_update >;

//typedef uint64_t hash_t;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int HASH_COUNT = 2;
//const hash_t HASH_P = (uint32_t)-13337;
//uniform_int_distribution<hash_t> MULT_DIST(0.25 * HASH_P, 0.75 * HASH_P);
//const hash_t HASH_MULT[HASH_COUNT] = {MULT_DIST(rng), MULT_DIST(rng)};

int main(){
  int r;
  fastScan(r);
  printf("%0.18f\n", 2.0 * PI * r);
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=998244353;
const int MAX = 510000;
const int INF = 1e9;
const double pi=acos(-1);
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;
}

int main(){
  COMinit();
  int a,b,c,d;
  cin >> a >> b >> c>> d;
  if(abs(c-a)<=d || (abs(a-b)<=d && abs(b-c)<=d))cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

/*
0-index
functionの中を書いて使う
宣言の時に単位元を書く
*/
template<typename T>
class segtree{
	int n;vector<T> dat;T ZERO;
public:
	segtree(int n_,T zero):ZERO(zero){
	  n = 1;
	  while(n < n_)n*=2;
	  dat.resize(2*n);
	  for(int i = 0;i < 2*n;i++)dat[i] = ZERO;
	}
	void update(int k, int a){
	  k += n - 1;dat[k] = a;
	  while(k > 0){
		k = (k-1)/2;
		dat[k] = function(dat[k*2+1],dat[k*2+2]);
	  }
	}
	
	T function(T a,T b){
		return a + b;
	}
	
	T get(int k){return dat[k+n-1];}
	T que(int a,int b){
		T L = ZERO,R = ZERO;
		int A = a + n - 1;
		int B = b + n - 1;
		while(A < B){
			if((A & 1) == 0)L = function(L,dat[A++]);
            if((B & 1) == 0)R = function(R,dat[--B]);
            A = A >> 1;
            B = B >> 1;
		}
		return function(L,R);
	}
};

ll mp[222222];
ll seica[222222];

int main(){
	
	ll n, k;cin >> n >> k;
	vector<pair<ll,ll>> v(n+1);
	
	REP(i,n){
		ll tmp;cin >> tmp;
		v[i+1].FI = tmp;
		v[i+1].FI -= k;
		v[i+1].SE = i+1;
	}
	REP(i,n)v[i+1].FI += v[i].FI;
	sort(ALL(v));
	REP(i,n+1) {
		mp[v[i].SE] = i;
		seica[v[i].SE] = v[i].FI;
	}
	segtree<ll> seg(n+1,0);
	seg.update(mp[0],1);
	
	ll ans = 0;
	REP(i,n){
		int place = upper_bound(ALL(v),MP(seica[i+1],LLINF)) - v.begin();
		ans += seg.que(0,place);
		seg.update(mp[i+1], 1);
		//cout << "seica " << seica[i+1] << " mp " << mp[i+1] << " place " << place << " ans " << ans << endl;
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int main() {
  int N,D,X; cin >> N >> D >> X;
  int A[101];
  for ( int i = 1; i <= N; i++ ) cin >> A[i];
  int sum = X + N;
  for ( int i = 1; i <= N; i++ ) {
    for ( int j = 1; j <=D; j++ ) {
      if ( j*A[i]+1 <=D ) sum++;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;

int main(){
    ll i,j;
    ll n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    s+='0';
    vector<ll> u(n+1);
    vector<ll> t(n+1);
    u[0]=0;
    t[0]=0;

    ll po=0;
    for(i=0;i<n;i++){
        if(s[i]=='A'&&s[i+1]=='C') u[i+1]=u[i]+1;
        else u[i+1]=u[i];
    }

    for(i=0;i<q;i++){
        ll x,y;
        cin>>x>>y;
        x--;
        y--;
        cout<<u[y]-u[x]<<endl;
    }
    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back

int main()
{
    double n, q, m, a = 2, k, x, i, tc, j, ans = 1, l;
    string s, s2;
    cin >> n;
    x = n / 3.0;
    cout << fixed << setprecision(10) << (x * x * x) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	printf("%s",m >= n ?"Yes" :"No"); 
	return 0;
}

Measured memory_bytes: 256
// g++ -std=c++11 test.cpp && ./a.out
// g++ -std=c++11 bfs.cpp && cat bfs.txt | ./a.out

#include <algorithm>
#include <iostream>
#include <queue>
#include <functional>
#include <numeric>
#include <math.h>

using namespace std;

#define PRINT(A) {for (int i = 0; i < A.size(); i++) { cout << A[i] << " ";} cout << endl;}
#define SUM(A) accumulate(A.begin(), A.end(), 0)
#define MAX(A) *max_element(A.begin(), A.end())
#define GETLINE(A) {string I; while(getline( cin, I, ' ' )){A.push_back(stoi(I));}}
#define BIT_LENGTH(N) floor(log2(N)) + 1
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;

bool check(double length, int K, VI &logs) {
    int count = 0;
    for (auto log: logs) {
        count += (ceil((double)log / length) - 1);
        if (count > K) {
            return false;
        }
    }
    return true;
}

int main() {
    int N, K;
    cin >> N >> K;    
    VI logs;
    GETLINE(logs);

    int left = 1, right = pow(10,9);
    while (left <= right) {
        int mid = (left + right) / 2;
        if (check(mid, K, logs)) {
            right = mid - 1;
        } else {
            left = mid + 1;
        }
    }
    cout << left << endl;
    return 0;
}

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

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

#define pb push_back
#define mp make_pair
#define sz(a) (ll)(a).size()
#define all(a) a.begin(), a.end()
#define ff first
#define ss second
#define endl "\n"

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
//K-th smallest
//cout << k << "rd smallest: " << *A.find_by_order(k-1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

// priority_queue <ll,vector<ll>,greater<ll> > p;

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

ll mod=1000000007;

ll power(ll x, ll y) 
{
	ll temp;
	if( y == 0)
		return 1;
	temp = power(x, y/2);
	if (y%2 == 0)
		return (temp*temp)%mod;
	else
		return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll a,b,k;
	cin>>a>>b>>k;
	if(k>=a)
	{
		k-=a;
		a=0;
	}
	else
	{
		a-=k;
		k=0;
	}
	if(k>=b)
	{
		k-=b;
		b=0;
	}
	else
	{
		b-=k;
		k=0;
	}
	cout<<a<<" "<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const int maxn = 2e5 + 7;
const LL INF = 1e18;

struct node
{
    LL val;
    int l,r;
} a[maxn];

stack<int>s;

void init(int n)
{
    while(!s.empty()) s.pop();
    for(int i=1; i<=n; i++)
    {
        while(!s.empty() && a[s.top()].val >= a[i].val) s.pop();
        if(s.empty()) a[i].l = 1;
        else a[i].l = s.top()+1;
        s.push(i);
    }
    while(!s.empty()) s.pop();
    for(int i=n; i>=1; i--)
    {
        while(!s.empty() && a[s.top()].val >= a[i].val) s.pop();
        if(s.empty()) a[i].r = n;
        else a[i].r=s.top()-1;
        s.push(i);
    }
}

int main() {
    int n;
    while(~scanf("%d",&n)) {
        for(int i = 1 ; i <= n ; i++) scanf("%d",&a[i].val);
        init(n);
        int ans = 0;
        for(int i = 1 ; i <= n ; i++) {
            if(a[i].l == 1) ans++;
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 4224
let mkls n =
  let rec f n' ls =
    if n' = 0 then List.fast_sort (fun i j -> j - i) ls
    else
      f (pred n') (Scanf.scanf "%d " (fun x -> x) :: ls)
  in
  f n []

let solve ls =
  let rec f ed = function
    | [] | [_] -> 0
    | h :: (h' :: t as t') ->
      if h = h' && ed > 0 then h * ed
      else if h = h' && ed <= 0 then f h t
      else f ed t'
  in
  f 0 ls

let () = Scanf.scanf "%d\n" mkls |> solve |> Printf.printf "%d\n"

Measured memory_bytes: 8448
/*
https://atcoder.jp/contests/dp/tasks/dp_f
*/
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

string buildSequence (const string &str1, const vector <vector <int>> &dp) {
    int r = dp.size() - 1, c = dp[0].size() - 1;
    string result;
    while (r > 0 && c > 0) {
        if (dp[r][c] != dp[r - 1][c]) {
            result += str1[r - 1];
            --r;
            --c;
        } else {
            if (dp[r - 1][c] > dp[r][c - 1]) {
                --r;
            } else {
                --c;
            }
        }
    }
    reverse(result.begin(), result.end());
    return result;
}

string getLCS (const string &str1, const string &str2) {
    int rows = str1.size(), cols = str2.size();

    vector <vector <int>> dp(rows + 1, vector <int>(cols + 1));

    for (int r = 1; r <= rows; ++r) {
        for (int c = 1; c <= cols; ++c) {
            if (str1[r - 1] == str2[c - 1]) {
                dp[r][c] = 1 + dp[r - 1][c - 1];
            } else {
                dp[r][c] = max(dp[r - 1][c], dp[r][c - 1]);
            }
        }
    }
    return buildSequence(str1, dp);
}

int  main () {
    string s, t;
    cin >> s >> t;
    cout << getLCS(s, t) << "\n";
    return 0;
}

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

int main() {
  int A,B;
cin>>A>>B;
  if(A>=13){
    cout<<B<<endl;
  }
  else if(A<=12&&A>=6){
   cout<<B/2<<endl; 
  }
  else{
   cout<<0<<endl; 
  }
}


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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input!(
    n: usize,
    k: usize,
    );
    let mut ans = 1;
    let mut n = n;
    loop {
        if n / k != 0 {
            ans += 1;
            n /= k;
        } else {break;}
    }
    println!("{}", ans);
}


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

#define check(val) std::cout << "\033[31m" << #val << ": " << val << "\033[m" << std::endl
#define check_v(vec) \
  std::cout << "\033[31m" << #vec << ": [ ";\
  for(auto it=vec.begin(); it!=vec.end(); it++){cout << *it << " ";}\
  cout << "]"<< "\033[m" << endl;


double kitai(int p) {
  double ret;
  ret = (double(p) + 1.0) / 2.0;
  // check(ret);
  return ret;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<double> p(n+k+1);
  int tmp_1;
  rep(i,n){
    cin >> tmp_1;
    p[i] = kitai(tmp_1);
  }
  // check_v(p);
  double ans = 0;
  rep(i,k) {
    ans += p[i];
  }
  double tmp = ans;
  rep(i,n) {
    // check(tmp);
    tmp = tmp - p[i] + p[i+k];
    if(tmp >= ans){
      ans = tmp;
    }
  }
  if(tmp >= ans){
      ans = tmp;
  }
  cout << fixed << setprecision(2) << ans << endl;
  // cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**8) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

a,b = li()

if a <= 0 and b >= 0:
    print('Zero')
    
elif a > 0:
    print('Positive')
    
elif b > 0:
    if (-a)%2 == 0:
        print('Positive')
    else:
        print('Negative')
        
else:
    if (a-b)%2 == 0:
        print('Negative')
    else:
        print('Positive')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

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

	cin >> N >> K;
	while(N){
	    vector<int>v(N + 1);
	int ans = -MOD;
	for (int i = 1; i <= N; i++) {
		cin >> v[i];
		v[i] += v[i - 1];
		if (i >= K) {
			ans = max(ans, v[i] - v[i - K]);
		}
	}
	cin>>N>>K;
	cout << ans << endl;
	}
}



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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define END(x) cout << x << endl; exit(0);
#define IPT(v, n) NREP(){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, minimum, maximum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> n;
    vl d(n);
    IPT(d, n)

    ans = 0;
    REP(i, 0, n) {
        REP(j, i+1, n) {
            ans += d[i] * d[j];
        }
    }
    MSG(ans)
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const double PI=3.14159265358979323846;
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
int main(void){
    int a,b,c;cin>>a>>b>>c;
    co(max(0, c-(a-b)));
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n,i,j,flag;
	scanf("%d",&n);
	char s[n][51];
	int a[n][27];
	for (i=0;i<n;i++) {
		scanf("%s",s[i]);
	}
	for (i=0;i<n;i++) {
		for (j=0;j<27;j++) {
			a[i][j] = 0;
		}
	}
	for (i=0;i<n;i++) {
		for (j=0;s[i][j]!='\0';j++) {
			a[i][s[i][j] - 'a']++;
			//printf("%d",s[i][j] - 'a');
		}
		//putchar('\n');

	}

	for (i=0;i<27;) {
		flag=1;
		for (j=0;j<n;j++) {
			a[j][i]--;
			if (a[j][i]<0) {
				flag=0;
				break;
			}
		}
		if (flag) printf("%c",'a'+i);
		else i++;
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 128
from math import gcd
n=int(input())
mod = 1000000007
z=0
d={}
for _ in range(n):
  a,b=map(int,input().split())
  if not any((a,b)):
    z+=1
    continue
  if a==0:
    d[(0,1)]=d.get((0,1),0)+1
    continue
  if b==0:
    d[(1,0)]=d.get((1,0),0)+1
    continue
  g = gcd(a,b)
  s = a//abs(a)
  a,b = (a//g)*s, (b//g)*s
  d[(a,b)]=d.get((a,b),0)+1

done = set()
ans = 1
for (a,b), v in d.items():
  if (a,b) in done:continue
  done.add((a,b))
  done.add((-b,a))
  done.add((b,-a))
  w = d.get((-b,a),0)+d.get((b,-a),0)
  ans *= (pow(2,v,mod)+pow(2,w,mod)-1)
  ans %= mod
ans = (ans + z - 1 + mod)%mod
print(ans)


Measured memory_bytes: 124756
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 998244353;

ll power(ll a, ll b)
{
	ll res = 1;
	rep(i, b)
	{
		res *= a;
		res %= mod;
	}
	return res;
}

int main()
{
	int n; cin >> n;
	vector<int> a(n, 0);
	rep(i, n)
	{
		int d; cin >> d;
		if (i == 0 && d != 0)
		{
			co(0);
			return 0;
		}
		a[d]++;
	}
	ll ans = 1;
	if (a[0] != 1)
	{
		ans = 0;
	}
	else
	{
		rep(i, n-1)
		{
			ans *= power(a[i], a[i + 1]);
			ans %= mod;
		}
	}
	co(ans);
	return 0;
}


Measured memory_bytes: 640
///   Journey to the End of earth   ///
/// Gunjan Kumar ///
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> // for less 
// using namespace __gnu_pbds; 
using namespace std;
#define ll  long long
#define s(n) scanf("%d",&n)
#define ls(n) scanf("%lld",&n)
#define p(n) printf("%d",n)
// #define ln() printf("\n")
#define pln(n) printf("%d\n",n)
#define lpln(n) printf("%lld\n",n)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rev(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define tc           ll t1; cin>>t1; while(t1--)
#define inp         ll n; cin>>n; ll arr[n]; rep(i,0,n) cin>>arr[i];
#define vect vector<ll>
#define sortv(v)       sort(v.begin(),v.end())
#define lower(v,n)    lower_bound(v.begin(),v.end(),n)-v.begin()
#define upper(v,n)    upper_bound(v.begin(),v.end(),n)-v.begin()
#define bitcount(n) __builtin_popcount(n)
#define ln <<endl
#define inf          LONG_MAX
#define ninf         LONG_MIN
#define fast         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const   ll mod=1e9+7;
const ll N=1e3+5;

char ch[N][N];




int main()
{

        
         int h,w;
         cin >>  h >> w;
         rep(i,0,h)
         cin >> ch[i];
         ll dp[h][w];
         memset(dp,0,sizeof(dp));
         dp[0][0]=1;
         for(int row=0;row<h;row++)
         {
           for(int col=0;col<w;col++)
           {
               if((col+1)<w && ch[row][col+1]=='.')
                dp[row][col+1]=(dp[row][col+1]+dp[row][col])%mod;
              if((row+1)<h && ch[row+1][col]=='.')
                dp[row+1][col]=(dp[row+1][col]+dp[row][col])%mod;
           }
         }
         cout<<dp[h-1][w-1];
         
     return 0;
}



Measured memory_bytes: 12228
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N, X, Y = MAP()
    lis = [[0 for _ in range(N-1)]for _ in range(N-1)]
    ans = [0] * (N-1)

    for i in range(N):
        for j in range(i+1, N):
            temp = min(j-i, abs(Y-j-1) + abs(X-i-1) + 1) - 1
            ans[temp] += 1

    for x in ans:
        print(x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 37860