akhauriyash/Code-Regression huggingface dataset:
// abc146_b
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define FOR(i, a) for (auto i : a)
#define pb push_back
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)
#define show1d(v)                                                              \
  rep(i, v.size()) cout << " " << v[i];                                        \
  cout << endl << endl;
#define show2d(v)                                                              \
  rep(i, v.size()) {                                                           \
    rep(j, v[i].size()) cout << " " << v[i][j];                                \
    cout << endl;                                                              \
  }                                                                            \
  cout << endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def, Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def, pii> pip;
typedef vector<pip> vip;
template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int main(int argc, char *argv[]) {
  int n;
  string s;
  cin >> n >> s;
  int s_size = s.size();
  rep(i, s_size) {
    if ((s[i] + n) > 'Z')
      cout << (char)(s[i] + n - ('Z' - 'A' + 1));
    else
      cout << (char)(s[i] + n);
    ;
  }
  cout << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;


const int N=5e5+10;
const int MOD=1e9+7;
const int inf=1e9;


int n,n1;

string s;

int a[N];
int f[N][4];


void prepare(){
    cin>>n>>s;
    n+=2;
    s='0'+s+'0';
    for(int en=0;en<n;){
        int st=en;
        while (en<n&&s[en]==s[st]) en++;
        a[++n1]=en-st;
    }
//    for(int i=1;i<=n1;i++) cout<<a[i]<<" \n"[i==n1];
}

int solve(){
    ///0 all 1 all-1 left 2 1 right 3 none
    fill(f[1]+1,f[1]+4,-inf);
//    for(int i=1;i<=n1+1;i++) cout<<a[i]<<" \n"[i==n1+1];
    for(int i=3;i<n1;i+=2){
        fill(f[i]+1,f[i]+4,-inf);
        if (a[i]==1){
            int idx=(a[i+1]>1)?1:3;
            f[i][idx]=max(f[i][idx],max(max(f[i-2][2]+1,f[i-2][1]+(a[i-1]-1)),f[i-2][0]+a[i-1]));
            f[i][2]=max(f[i][2],(*max_element(f[i-2],f[i-2]+3))+a[i+1]-1);
            f[i][3]=max(f[i][3],(*max_element(f[i-2],f[i-2]+3))+a[i+1]);
        }
        f[i][0]=*max_element(f[i-2],f[i-2]+4);
//        for(int j=0;j<4;j++) cout<<f[i][j]<<" \n"[j==3];
    }
    return *max_element(f[n1-2],f[n1-2]+4);
}
int main(){
    prepare();
    cout<<solve();
}


Measured memory_bytes: 7576
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const double PI = 3.14159265358979;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

int main() {
	string s; cin >> s;
	bool v[4] = {};
	rep(i, 0, s.size()) {
		if (s[i] == 'N')v[0] = true;
		else if (s[i] == 'S')v[1] = true;
		else if (s[i] == 'W')v[2] = true;
		else if (s[i] == 'E')v[3] = true;
	}
	if (v[0] != v[1] || v[2] != v[3]) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;

	return 0;
}

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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;

using namespace std;

struct node{
    int left, right;
    int parent, sibling, degree, depth, height;
};

node n[25];

int main() {
    int v;
    cin >> v;
    REP(i, v){
        n[i].parent = -1;
        n[i].depth = 0;
        n[i].sibling = -1;
        n[i].degree = 0;
        n[i].height = 0;
    }
    REP(i, v){
        int x, left, right;
        cin >> x >> left >> right;
        n[x].left = left;
        n[x].right = right;
        if(n[x].left != -1){
            n[n[x].left].parent = x;
            n[n[x].left].sibling = right;
            n[x].degree++;
        }
        if(n[x].right != -1){
            n[n[x].right].parent = x;
            n[n[x].right].sibling = left;
            n[x].degree++;
        }
    }

    REP(i, v){
        node x = n[i];
        int count = 0;
        while(x.parent != -1){
            count++;
            n[x.parent].height = max(count, n[x.parent].height);
            x = n[x.parent];
        }
        n[i].depth = count;
    }

    REP(i, v){
        string str;
        if(n[i].depth == 0)
            str = "root";
        else if(n[i].left == -1 && n[i].right == -1)
            str = "leaf";
        else
            str = "internal node";
        cout << "node " << i << ": parent = " << n[i].parent << ", sibling = " << n[i].sibling << ", degree = " << n[i].degree << ", depth = " << n[i].depth << ", height = " << n[i].height << ", " << str << endl;
    }

    return 0;
}

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

using namespace std;

typedef long long           ll;
typedef vector<int>         vi;
typedef pair<int,int>       ii;

#define endl                '\n'
#define ln                  puts("")
#define fi                  first
#define pf                  printf
#define se                  second
#define MX                  109
#define pb                  push_back
#define DB                  pf("Hi\n")
#define pf1(a)              pf("%lld\n",a)
#define sc1(a)              scanf("%lld",&a)
#define sz(a)               int((a).size())
#define all(c)              (c).begin(),(c).end()
#define mem(a,b)            memset(a, b, sizeof(a))
#define TC                  int _T;sc1(_T);while(_T--)
#define RD                  freopen("0iuput.txt","r",stdin)
#define WR                  freopen("0uput.txt","w",stdout)
#define rep(i,a,b)          for(int i=int(a)-(a>b);i!=(b)-(a>b);i+=1-2*(a>b))

int main()
{
    ll n,b,pal=0,a,mx = INT_MAX,sum;
    sc1(n);
    sc1(b);

    sc1(a);
    sum=a+b;
    mx = a;
    rep(i,0,n-1)
    {
        sc1(a);
        sum+=min(b,a-mx);
        mx = a;
    }
    pf1(sum);
}


Measured memory_bytes: 256
/*input
3
0.30 0.60 0.80


*/ 
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 
    
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
#define endl "\n"
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 1000000001;
const int MAX = 1e5+1;
    

int32_t main() {
    IOS;
	int n;
	cin>>n;
	vector<double>vec(n+1,0);
	vector<vector<double> >dp(n+1,vector<double>(n+1,0));
	for(int i=1;i<=n;i++)
		cin>>vec[i];
	dp[0][0]=1;
	for(int j=1;j<=n;j++)
	{
		dp[0][j]=(1-vec[j])*dp[0][j-1];
		for(int i=1;i<=j;i++)
		{
			dp[i][j]=vec[j]*dp[i-1][j-1]+(1-vec[j])*dp[i][j-1];
		}
	}
	// for(int i=0;i<=n;i++)
	// {
	// 	for(int j=0;j<=n;j++)
	// 		cout<<dp[i][j]<<" ";
	// 	cout<<endl;
	// }
	double sum=0;
	for(int i=(n+1)/2;i<=n;i++)
	{
		sum+=dp[i][n];
 
	}
	cout<<setprecision(9)<<sum<<endl;
	return 0;
}






Measured memory_bytes: 70784
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a < b) {
			if (b < c) {
				System.out.printf("%d %d %d\n", a, b, c);
			} else if (c < a) {
				System.out.printf("%d %d %d\n", c, a, b);
			} else {
				System.out.printf("%d %d %d\n", a, c, b);
			}

		} else {
			if (a < c) {
				System.out.printf("%d %d %d\n", b, a, c);
			} else if (c < b) {
				System.out.printf("%d %d %d\n", c, b, a);
			} else {
				System.out.printf("%d %d %d\n", b, c, a);
			}

		}
	}

}

Measured memory_bytes: 26228
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n,m[101]={0};
  int maxi=0;
  while(cin>>n){
    m[n]++;
    maxi=max(maxi,m[n]);
  }
  rep(i, 101){
    if(m[i]==maxi)cout<<i<<endl;
  }
  return 0;
}



Measured memory_bytes: 3104
def binary_search(arr, value)
    
    left = 0
    right = arr.size - 1
    mid = 0

    while left <= right do
        mid = (left + right) / 2

        if arr[mid] == value
            return mid
        elsif arr[mid] < value
            left = mid + 1
        else
            right = mid - 1
        end
    end

    return left
end

def arr_min(arr)
    min = arr[0]
    for i in 1..arr.size-1
        if min > arr[i]
            min = arr[i]
        end
    end
    min
end

A, B, Q = gets.split.map!{|n| n.to_i}
s = Array.new(A)
t = Array.new(B)
x = Array.new(Q)

for i in 1..A
    s[i-1] = gets.to_i
end

for i in 1..B
    t[i-1] = gets.to_i
end

for i in 1..Q
    x[i-1] = gets.to_i
end

s.unshift(-(10 ** 18))
s << 10**18
t.unshift(-(10 ** 18))
t << 10 ** 18
c = Array.new(8)

for i in 1..Q
    v = binary_search(s, x[i-1])
    w = binary_search(t, x[i-1])

    c[0] = (s[v] - x[i-1]).abs + (t[w] - s[v]).abs
    c[1] = (s[v] - x[i-1]).abs + (t[w-1] - s[v]).abs
    c[2] = (s[v-1] - x[i-1]).abs + (t[w] - s[v-1]).abs
    c[3] = (s[v-1] - x[i-1]).abs + (t[w-1] - s[v-1]).abs
    c[4] = (t[w] - x[i-1]).abs + (s[v] - t[w]).abs
    c[5] = (t[w] - x[i-1]).abs + (s[v-1] - t[w]).abs
    c[6] = (t[w-1] - x[i-1]).abs + (s[v] - t[w-1]).abs
    c[7] = (t[w-1] - x[i-1]).abs + (s[v-1] - t[w-1]).abs

    puts arr_min(c)
end

Measured memory_bytes: 6268
# include <iostream>
using namespace std;
const int N=306,M=90006;
struct node
{
	int x,y;
}a[M];
int b[N][N],c[M];
int n,m,p,q,s;
void work (void)
{
	int i,j,k;
	for (i=1;i<=q;i++)
	{
		cin>>j>>k;
		s=c[k]-c[j];
		cout<<s<<endl;
	}
}
int main (void)
{
	int i,j,k,u,v,t;
	cin>>n>>m>>p;
	t=n*m;
	for (i=1;i<=n;i++)
	for (j=1;j<=m;j++)
	{
		cin>>b[i][j];
		a[b[i][j]].x=i;
		a[b[i][j]].y=j;
	}
	for (i=1;i<=p;i++)
	{
		j=i;
		k=i+p;
		s=0;
		while (k<=t)
		{
			if (a[k].x>=a[j].x)
			v=a[k].x-a[j].x;
	   else v=a[j].x-a[k].x;
	        s+=v;
	        if (a[k].y>=a[j].y)
			v=a[k].y-a[j].y;
	   else v=a[j].y-a[k].y;
	        s+=v;
	        c[k]=s;
	        j=k;
	        k+=p;
		}
	}
	cin>>q;
	work ();
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int n;
    cin>>n;
    vi a(n),b(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];
    if(a>b) swap(a,b);
    int ans=0;
    while(a!=b)
    {
        next_permutation(a.begin(),a.end());
        ans++;
    }
    print(ans);
}

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

N = int(input())
s = input().strip()
t = input().strip()

def main():
    for i in range(N):
        if s[i:].find(t[0:N-i]) >= 0:
            print(2*N-(N-i))
            return
    print(N*2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
///

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll N = 750002;
const int mod = 1000000007;
const long long int inf = INT64_MAX;
#define pp pair<ll,ll>

typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++)    
void fastIO(void);
 
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);

int main()
{  
  ll n;
  string s;
  cin>>n>>s;
  ll ans = 0;
   rep(i,n){
      ll j = i+1;
      while(j<n && s[i]==s[j] ) j++;
      ans++;
      i = j-1;
   }
   cout<<ans<<endl;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   return ((a%mod)+(b%mod)+mod)%mod;
}
ll modpower(ll a, ll n){
   if(n==0)
      return 1;
   ll result = 1;
   while(n>0){
      if(n%2==1)
         result = modmulti(result,a);
      a = modmulti(a,a);
      n = n/2;
   }
   return result;
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}
 

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,x,y,i,sz[500001];
int main(){
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		sz[x]++;sz[y]++;
	}
	for(i=1;i<=n;i++)if(sz[i]%2==1){
		puts("NO");return 0;
	}
	puts("YES");
}

Measured memory_bytes: 640
try :
    from math import gcd
except ImportError :
    from fractions import gcd


N = int(input())
A = list(map(int,input().split()))


X = [A[0]]
Y = [A[-1]]

for i in range(1,N) :
    x = gcd(X[i-1], A[i])
    y = gcd(Y[i-1], A[N-i-1])
    X.append(x)
    Y.append(y)

ans = 0

Y = Y[::-1]

for i in range(N) :
    if i == 0 :
        calc = Y[1]
    elif i == N-1 :
        calc = X[N-2]
    else :
        calc = gcd(X[i-1],Y[i+1])
    
    ans = max(ans, calc)

print(ans)


Measured memory_bytes: 16152
#include <iostream>
#include <iomanip>

int main()
{
	int n,a[1000];
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		std::cout << a[n - i];
		if (i != n) {
			std::cout << " ";
		}
	}
	std::cout << std::endl;
	return 0;
}


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

int main() {
  int n, a, b; cin >> n >> a >> b;
  string s; cin >> s;
  string ans = "Yes";
  int border = a+b;
  int out = 1, pass = 0;
  rep(i,s.size()) {
    if (s[i] == 'c') {
      cout << "No" << endl;
      continue;
    }
    if (pass < border) {
      if (s[i] == 'a') {
        cout << "Yes" << endl;
        pass++;
      }
      if (s[i] == 'b') {
        if (b >= out) {
          cout << "Yes" << endl;
          pass++;
          out++;
        } else {
          cout << "No" << endl;
        }
      }
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

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

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

Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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 dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


const int MAX_N=200100;

int par[MAX_N];
int ran[MAX_N];

void init(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		ran[i]=0;
	}
}

int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}

void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y)return;
	
	if(ran[x]<ran[y]){
		par[x]=y;
	}else{
		par[y]=x;
		if(ran[x]==ran[y])ran[x]++;
	}
}

bool same(int x,int y){
	return find(x)==find(y);
}

int n,m;
int k[100100];

int main(){
	cin>>n>>m;
	init(MAX_N);
	REP(i,n){
		cin>>k[i];
		REP(j,k[i]){
			int mm;
			cin>>mm;
			unite(mm+100000,i+1);
		}
	}
	
	for(int i=1;i<=n-1;i++){
		if(!same(i,i+1)){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}
			

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N, Q;
	cin >> N >> Q;
	vector<vector<int>> g(N);
	for (int i = 0; i < N - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<Int> d(N, 0);
	for (int i = 0; i < Q; ++i) {
		int p; Int x;
		cin >> p >> x;
		d[p - 1] += x;
	}

	deque<int> que;
	que.push_back(0);
	vector<bool> used(N, false);
	while (!que.empty()) {
		int u = que.front(); que.pop_front();
		if (used[u]) { continue; }
		used[u] = true;
		for (auto v : g[u]) {
			if (used[v]) { continue; }
			d[v] += d[u];
			que.push_back(v);
		}
	}

	for (int i = 0; i < N; ++i) {
		cout << d[i] << (i < N - 1 ? " " : "\n");
	}

	return 0;
}


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

#define pb push_back
#define mp make_pair

#define fi first
#define se second

typedef long long ll;

using namespace std;
int n, m;
int x[100500], y[100500];
int num[100500];
bool red[100500];

int main(){

cin >> n >> m;
for(int i=1;i<=n;i++){
    num[i] = 1;
}
red[1] = 1;

for(int i=1;i<=m;i++){
    cin >> x[i] >> y[i];

    if(red[x[i]]){
        red[y[i]] = 1;
    }
    num[x[i]]--;
    num[y[i]]++;
    if(num[x[i]] < 1){
        red[x[i]] = 0;
    }
}
int ans = 0;
for(int i=1;i<=n;i++){
    if(red[i])ans++;
}
cout << ans;
return 0;
}









Measured memory_bytes: 1536
n = int(input())
a = list(int(n) for n in input().split())
b = [0] * n
num_of_minus = 0

for i in range(n):
    if a[i] < 0:
        num_of_minus += 1
        b[i] = int(a[i] * (-1))
    else:
        b[i] = int(a[i])

if num_of_minus % 2 == 0:
    ans = sum(b)
else:
    ans = sum(b) - (min(b) * 2)

print(ans)

Measured memory_bytes: 14332
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	ans := 0.0
	for i := 1; i <= n; i++ {
		score := i
		probability := 1.0
		for score < k {
			score *= 2
			probability /= 2.0
		}
		ans += probability
	}

	ans /= float64(n)
	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int[] nums=new int[n];
        for(int i=0;i<n;i++){
            nums[i]=sc.nextInt();
        }
        int ans=Integer.MAX_VALUE;
        for(int i=0;i<n-k+1;i++){
            ans=Math.min(ans,nums[i+k-1]-nums[i]+Math.min(Math.abs(nums[i+k-1]),Math.abs(nums[i])));
        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 48304
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y

a,b = input().split()
b = b[:-3] + b[-2:]
ans = int(a) * int(b)
ans = ans // 100
print(ans)


Measured memory_bytes: 61924
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    i64 N, K;
    cin >> N >> K;
    i64 ans = 0;
    if(!K) {
        cout << N * N << endl;
        return 0;
    }
    for(int b = K + 1; b <= N; b++) {
        ans += (N / b) * (b - K);
        ans += max<i64>(0, (N % b) - K + 1);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);

    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (ll i = k; i < n; i++) {
        if (a[i] > a[i - k]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<P> d(n);
    rep(i,n){
        int a, b;
        cin >> a >> b;
        d[i] = P(a,b);
    }
    sort(d.begin(), d.end());
    ll ans = 0;
    rep(i,n){
        ll a = d[i].first, b = d[i].second;
        if(m < b){
            ans += a*m;
            break;
        }
        else{
            ans += a*b;
            m -= b;
        }
    }
    cout << ans << endl;
}

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

int main()
{
	string s;
	cin >> s;
	int cnt = 0, h = 0;
	for(auto i = 0; i < (int)s.size(); ++i){
		switch(s[i]){
			case 'A': case 'C': case 'G': case 'T':
				++cnt;
				break;
			default:
				if(h < cnt) h = cnt;
				cnt = 0;
				break;
		}
	}
	cout << max(h, cnt) << endl;
	return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val src: List[List[Int]] = io.Source.stdin.getLines.map(_.split(",").map(_.toInt).toList).toList

  def whereToMeet(li: List[Int]): Int = {
    val numOfStations = 10
    val (spans, ratio) = li.splitAt(10)

    val distanceFromHead = spans.sum * ((ratio(0): Double) / (ratio(0) + ratio(1)))

    def findThePoint(spans: List[Int], distanceFromHead: Double): List[Int] = {
      if (distanceFromHead <= 0) spans
      else findThePoint(spans.tail, distanceFromHead - spans.head)
    }

    numOfStations - findThePoint(spans, distanceFromHead).length
  }

  for (list <- src) println(whereToMeet(list))
}

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

using namespace std;
//fold
#define ll long long
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define Loop(i, a, b) for(int i = a ; i < b ; ++i)
#define loop(i, n) Loop(i, 0, n)
#define ff first
#define ss second
#define mkp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define vvii vector<vii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define vvll vector<vll>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define nmbr(c) (int)(c-'0')
#define ltr(c) (int)(c-'a')
#define INF 1e18+5
#define inf 1e9+5
#define M 1000000007 //check
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

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

template <typename T> T max(T a, T b, T c){ return max(a, max(b, c));}
template <typename T> T min(T a, T b, T c){ return min(a, min(b, c));}
//endfold

int n;
ll dp[1<<17], group_score[1<<17], score[17][17];

ll group(int mask)
{
	if(mask == (1<<n)-1) return 0;
	ll &ans = dp[mask];
	if(ans != -1LL) return ans;
	vi not_taken;
	loop(i, n) if(!(mask&(1<<i))) not_taken.pb(i);
	int s = sz(not_taken);
	for(int i = 1 ; i < (1<<s) ; ++i)
	{
		int cur_mask = 0;
		loop(j, s) if(i & (1<<j)) cur_mask |= (1<<not_taken[j]);
		ans = max(ans, group(mask|cur_mask)+group_score[cur_mask]);
	}
	return ans;
}

int main() {
	_69e27;
	scanf("%d", &n);
	loop(i, n) loop(j, n) scanf("%lld", &score[i][j]);

	memset(dp, -1, sizeof(dp));
	for(int i = 1; i < (1<<n) ; ++i)
	{
		group_score[i] = 0;
		for(int j = 0 ; j < n ; ++j) 
			for(int k = j ; k < n ; ++k)
				if((i & (1<<j)) && (i & (1<<k))) 
					group_score[i] += score[j][k];
	}
	printf("%lld\n", group(0));
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;

const int N=1e7;

ll v[N+10];

ll a[N+10];


bool compare(string  &a, string &b)
{
     string f=a+b,c=b+a;

     return f<c;
}

int main()
{
    ll n;

    cin>>n;

    ll ara[n+10];

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

    sort(ara,ara+n);
    
    double sum=0,ans=0;

    sum=(ara[0]+ara[1])/2.0;

    for(ll i=2;i<n;i++)
    {
        sum=(sum+ara[i])/2.0;
    }

    cout<<sum<<endl;

}








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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    ll k,x,y;
    cin >> k >> x >> y;
    ll u = abs(x),v = abs(y),s = 1,t = 1;
    if (x && x/u < 0) s = -1;
    if (y && y/v < 0) t = -1;
    if ((u+v)&1 && k%2 == 0) {
        cout << "-1" << endl;
        return 0;
    }
    vector<P> ans;
    while (u || v) {
        ans.push_back(P(u,v));
        if (abs(u)+abs(v) == k) {
            u = v = 0;
        } else if (abs(u)+abs(v) <= 2*k && (abs(u)+abs(v))%2 == 0) {
            ll l[7] = {(u-v)/2,k-(u-v)/2,0,k-(v-u)/2,(v-u)/2,-k+(u-v)/2,-k+(v-u)/2};
            ll a,b;
            for (int i = 0;i < 7;++i) {
                ll j = k-abs(l[i]);
                if (abs(u-l[i])+abs(v-j) == k) {
                    a = l[i];
                    b = j;
                    break;
                }
                if (abs(u-l[i])+abs(v+j) == k) {
                    a = l[i];
                    b = -j;
                    break;
                }
            }
            u -= a;
            v -= b;
        } else {
            ll a = 0,b = 0;
            if (u) {
                a = min(k,u);
                u -= a;
            }
            if (a < k) {
                b = k-a;
                v -= b;
            }
        }
    }
    reverse(ans.begin(),ans.end());
    int n = ans.size();
    cout << ans.size() << endl;
    for (int i = 0;i < n;++i) cout << ans[i].first*s << " " << ans[i].second*t << endl;
}

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

using namespace std;
//using namespace __gnu_pbds;

#define LL       long long
#define DS       pair<int, int>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int x, y;
    string a, b, c;
    cin >> a >> b >> x >> y >> c;
    if (c == a) x--;
    if (c == b) y--;
    cout << x << " " << y << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <cmath>
#include <cstdio>
#include <vector>
#include <utility>
#define X real()
#define Y imag()
#define EPS 1e-10
#define INF 1e8
using namespace std;
typedef complex<double> P;
typedef pair<P, P> L;
typedef vector<P> Poly;
static const double pi = acos(-1.0);

double dot(P a, P b){
  return a.X*b.X + a.Y*b.Y;
}

double cross(P a, P b){
  return a.X*b.Y - a.Y*b.X;
}

int ccw(P a, P b, P c){
  if(cross(b-a,c-a) > EPS) return 1;
  if(cross(b-a,c-a) < -EPS) return -1;
  if(dot(b-a,c-a) < -EPS) return 2;
  if(norm(b-a)+EPS < norm(c-a))return -2;
  return 0;
}

bool is_cross(L a, L b){
  if(ccw(a.first,a.second,b.first)*ccw(a.first,a.second,b.second) <= 0 &&
     ccw(b.first,b.second,a.first)*ccw(b.first,b.second,a.second) <= 0) return true;
  return false;
}

double p_to_s_dist(P p, L s){
  if(dot(p-s.first,s.second-s.first) >= 0 &&
     dot(p-s.second,s.first-s.second) >= 0) return abs(cross(p-s.first,s.second-s.first))/abs(s.second-s.first);
  return min(abs(p-s.first),abs(p-s.second));
}

double s_to_s_dist(L a, L b){
  if(is_cross(a,b)) return 0;
  return min(min(p_to_s_dist(a.first,b),p_to_s_dist(a.second,b)),
	     min(p_to_s_dist(b.first,a),p_to_s_dist(b.second,a)));
}

double Poly_to_Poly_dist(Poly a, Poly b){
  double dist = INF;
  int na = a.size(), nb = b.size();
  a.push_back(a[0]);
  b.push_back(b[0]);
  for(int i = 0; i < na; ++i){
    for(int j = 0; j < na; ++j){
      dist = min(dist,s_to_s_dist(L(a[i],a[i+1]),L(b[j],b[j+1])));
    }
  }
  return dist;
}

Poly star(P p, double r, double a){
  Poly ret;
  for(int i = 0; i < 5; ++i){
    ret.push_back(P(polar(r,(a+90+144*i)/360*2*pi)+p));
  }
  return ret;
}

int main(){
  int N, M, L;
  double x, y, a, r;
  while(cin >> N >> M >> L, N){
    vector<Poly> stars(N);
    for(int i = 0; i < N; ++i){
      cin >> x >> y >> a >> r;
      stars[i] = star(P(x,y),r,a);
    }
    vector< vector<double> > WF(N, vector<double>(N, INF));
    for(int i = 0; i < N; ++i){
      for(int j = i; j < N; ++j){
	if(i == j) WF[i][j] = 0;
	else{
	  WF[i][j] = Poly_to_Poly_dist(stars[i],stars[j]);
	  WF[j][i] = WF[i][j];
	}
      }
    }
    for(int k = 0; k < N; ++k){
      for(int i = 0; i < N; ++i){
	for(int j = 0; j < N; ++j){
	  WF[i][j] = min(WF[i][j], WF[i][k] + WF[k][j]);
	}
      }
    }
    printf("%.10lf\n", WF[M-1][L-1]);
  }
  return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll gcd(ll x, ll y) {
    if(y == 0) {
        return x;
    }
    return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
    ll g = gcd(x, y);
    return x/g*y;
}

int main() {
    ll a, b;
    cin >> a >> b;

    out(lcm(a, b));    
    re0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*};
use superslice::*;
fn main() {
    input! {
        x: i64,
    }

    for b in (0..) {
        let ap = x + five(b);
        let am = x + five(-b);
        if five(root5(ap)) == ap {
            println!("{} {}", root5(ap), b);
            return;
        }
        if five(root5(am)) == am {
            println!("{} {}", root5(am), -b);
            return;
        }
    }

}

fn five(x: i64) -> i64 {
    x * x * x * x * x
}
fn root5(x: i64) -> i64 {
    (x as f64).powf(0.2f64) as i64
}


Measured memory_bytes: 3012
#include <stdio.h>

#define MAX_X     1000000
#define INFINITY  MAX_X
#define tetra(n)  ((n) * ((n)+1) * ((n)+2) / 6)

/* compute all solutions for x = 1 to (MAX_X-1) */
void polloc(int solution[], int oddOnly)
{
  int i, j, t;

  /* initialize */
  for (i = 1; i < MAX_X; i++) {
    solution[i] = INFINITY;
  }
  for (i = 1; (t = tetra(i)) < MAX_X; i++) {
    if (! oddOnly || t % 2 == 1) {
      solution[t] = 1;
    }
  }

  /* dynamic programming */
  for (i = 1; i < MAX_X; i++) {
    for (j = 1; (t = tetra(j)) < i; j++) {
      if (solution[i] > solution[t] + solution[i - t]) {
          solution[i] = solution[t] + solution[i - t];
      }
    }
  }
}

int main()
{
  static int solution[2][MAX_X];
  int x;

  polloc(solution[0], 0);
  polloc(solution[1], 1); /* odd only */

  for (;;) {
    scanf("%d", &x);
    if (x == 0) break;
    printf("%d %d\n", solution[0][x], solution[1][x]);
  }
  return 0;
}

Measured memory_bytes: 8412
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class D
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (N, K) = Scanner.Scan<int, int>();
            const int p = 998244353;
            var L = new int[K];
            var R = new int[K];
            for (var i = 0; i < K; i++)
            {
                var (l, r) = Scanner.Scan<int, int>();
                L[i] = l;
                R[i] = r + 1;
            }
            var dp = new long[N];
            dp[0] = 1;
            dp[1] = -1;
            for (var i = 0; i < N; i++)
            {
                if (i > 0)
                {
                    dp[i] += dp[i - 1];
                    dp[i] %= p;
                }
                for (var j = 0; j < K; j++)
                {
                    var (l, r) = (L[j], R[j]);
                    if (i + l < N)
                    {
                        dp[i + l] += dp[i];
                        dp[i + l] %= p;
                    }
                    if (i + r < N)
                    {
                        dp[i + r] -= dp[i];
                        if (dp[i + r] < 0) dp[i + r] += p;
                        dp[i + r] %= p;
                    }
                }
            }

            Console.WriteLine(dp[N - 1]);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 29888
from sys import stdin
import collections

lines = stdin.readlines()
n = int(lines[0])
a_s = [int(x) for x in lines[1].rstrip().split()]


def inc(x): return x + 1


def dec(x): return x - 1


a_s_p = [inc(x) for x in a_s]
a_s_n = [dec(x) for x in a_s]

a_s = a_s + a_s_p + a_s_n
c = collections.Counter(a_s)
print(max(list(c.values())))


Measured memory_bytes: 29620
#include <stdio.h>
int main(void){
  int x,y,z,tmp;
  scanf("%d %d %d",&x,&y,&z);
  tmp = x;
  x = y;
  y = tmp;
  tmp = x;
  x = z;
  z = tmp;
  printf("%d %d %d",x,y,z);
  return 0;
}


Measured memory_bytes: 1696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);



int main(){
	ll N,K;
	cin >> N >> K;
	vector<ll> p(N);
	FOR(i,0,N) cin >> p[i];
	double ans = 0, anst=0;
	FOR(i,0,K){
		ans += double(1.0+p[i])/2.0;
	}
	anst = ans;
	FOR(i,K,N){
		ans -= double(1.0+p[i-K])/2.0;
		ans += double(1.0+p[i])/2.0;
		anst = max(ans,anst);
	}
	out(10) << anst << endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int N;
    cin >> N;
    string sn;
    sn = to_string(N);
    string ans;
    for(int i=0; i<3; i++){
        if (sn[i] == '9'){
            ans += "1";
        }
        else ans += "9";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// Problem : C - Not so Diverse
// Contest : AtCoder Regular Contest 086
// URL : https://atcoder.jp/contests/arc086/tasks/arc086_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define size(x) (int)x.size()

const int N = 1e6 + 1, mod = 1e9 + 7, inf = 2e9;

vector<int> v;
map<int, int> cnt;
int n, k, ans = 0;

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n >> k;
	for (int i = 1, x; i <= n; i++) {
		cin >> x;
		cnt[x]++;
	}
	for (auto x : cnt) v.push_back(x.second);
	sort(v.begin(), v.end());
	k = min(k, size(v));
	while (k--) v.pop_back();
	for (auto x : v) ans += x;
	cout << ans;
}


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

int main() {
    int n,a[100];
    cin >> n;
    for (int i = 0; i < n; i++ ) {
         cin >> a[i];
    }
    
    for(int i = n -1 ; i >= 0; i--) {
        cout << a[i] ;
        if (i > 0){
            cout << " ";
        }
    }
    
    cout << endl;
    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(i) i.begin(),i.end()
template<typename T=ll>
using v =vector<T>;
template<typename T=ll>
using vv = vector<v<T>>;
template<typename T=ll,typename U=ll> using p = pair<T,U>;
const ll INF = (ll)1e9;
const ll MOD = INF+7;
template<typename T> T chmin(T &a,T b){return a=min(a,b);}
template<typename T> T chmax(T &a,T b){return a=max(a,b);}

struct modint
{
    ll a;
    modint():a(0){}
    modint(ll t){
        a=t%MOD;
        if(a<0) a+=MOD;
    }
    //operator long long() const{return a;}
    bool operator==(const modint & x)const{return a==x.a;}
    bool operator!=(const modint & x)const{return a!=x.a;}
    modint operator-() const {return modint(a?(MOD-a):0);}
    modint operator~() const {return modint(MOD -2);}
    modint operator+(const modint &x) const{return modint(*this)+=x;}
    modint operator-(const modint &x) const{return modint(*this)-=x;}
    modint operator*(const modint &x) const{return modint(*this)*=x;}
    modint operator/(const modint &x) const{return modint(*this)/=x;}
    modint &operator+=(const modint &x){
        a+= x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint &operator-=(const modint &x){
        a-= x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    
    modint &operator*=(const modint &x){
        a=a*x.a %MOD;
        return *this;
    }
    modint &operator/=(const modint &x){
        a=a*(~x).a %MOD;
        return *this;
    }

    friend ostream &operator<<(ostream &os,const modint &x){
        return os << x.a;
    }

    friend istream &operator>>(istream &is,modint &x){
        ll t;
        x=modint(t);
        return is;
    }

    modint pow(ll x)const{
        modint ret = 1,tmp=a;
        for(;x;tmp*=tmp,x>>=1){
            if(x&1) ret*=tmp;
        }
        return ret;
    }

};

modint nCr(int n,int r){
    modint ans=1;
    for(int i=1;i<=r;i++) ans*=modint(n-i+1)/modint(i);
    return ans;
}

int main(){
    ll n, x; cin >> n >> x;
    auto a = v<>(n,0);
    rep(i,n) cin >> a[i];
    sort(all(a));
    ll i=0;
    for(i=0;i<n&&x>=0;i++) {
        x-=a[i];
    }
    if(x<0||x>0) cout << i-1 << endl;
    else    cout << i << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n'
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
	int n;
	cin>>n;
	if(n==1)
	{
		cout<<"Hello World";
		return 0;
	}
	int a, b;
	int c;
	cin>>a>>b;
	c = a+b;
	cout<<c;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){

    int N,A,i;
    cin >> N >> A;

    for(i = 0; i < 1000; i++){
        if(500 * i > N){
            break;
        }
    }
    
    if(N - 500 * (i - 1) <= A){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int flag=1,i,n,a[100],count=0;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  while(flag){
    flag=0;
    for(i=n-1;i>0;i--){
      if(a[i]<a[i-1]){
	swap(a[i],a[i-1]);
	count++;
	flag=1;
      }
    }
  }
  for(i=0;i<n;i++){
    if(i==n-1)cout<<a[i];
    else cout<<a[i]<<" ";
  }
  cout<<endl;
  cout<<count<<endl;
  return 0;
  
}



Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

constexpr ll INF = (ll)1e6;
template<class T> class segtree {
    int n = 1;
    vector<T> dat;
    tuple<int, int, int> def = { INF,-1,-1 }; //Default value

public:
    segtree(int _n) {
        while (n < _n)n *= 2;
        dat.resize(2 * n - 1, def);
    }
    segtree(vector<T> a) {
        int _n = a.size();
        while (n < _n)n *= 2;
        dat.resize(2 * n - 1, def);
        rep(i, 0, _n)dat[i + n - 1] = a[i];
        rREP(i, 0, n - 1)dat[i] = fun(dat[2 * i + 1], dat[2 * i + 2]);
    }


    //sum,min,max,etc...
    T fun(T x, T y) { 
        int a = get<1>(x), b = get<1>(y);
        return (a > b ? x : y);
    }

    //assignment,chmin,chmax,etc...
    void update(int i, T a) {
        i += n - 1;
        dat[i] = a;
        while (i > 0) {
            --i /= 2;
            dat[i] = fun(dat[2 * i + 1], dat[2 * i + 2]);
        }
    }


    T value(int a, int b, int k, int l, int r) {
        if (b <= l || r <= a)return def;
        if (a <= l && r <= b)return dat[k];
        T s = value(a, b, 2 * k + 1, l, (l + r) / 2);
        T t = value(a, b, 2 * k + 2, (l + r) / 2, r);
        return fun(s, t);
    }
    T value(int a, int b) { return value(a, b, 0, 0, n); }

    T& operator[](int k) { return dat[k + n - 1]; }
};


int main() {
	init();

	int N, M; cin >> N >> M;
    vector<tuple<int, int, int>>vec(N);
    rep(i, 0, N) {
        int a, b; cin >> a >> b;
        vec[i] = { a,b ,i };
    }
    sort(all(vec));
    rep(i, 0, N) {
        int& j = get<2>(vec[i]);
        j = i;
    }
    segtree<tuple<int, int, int>>seg(vec);
    ll ans = 0;
    rep(i, 1, M + 1) {
        int l = -1, r = N;
        while (r - l > 1) {
            int mid = (r + l) / 2;
            int day = get<0>(vec[mid]);
            if (i < day)r = mid;
            else l = mid;
        }
        auto num = seg.value(0, l + 1);
        if (get<1>(num) < 0)continue;
        ans += get<1>(num);
        seg.update(get<2>(num), { INF,-1,-1 });
    }
    cout << ans << "\n";


	return 0;
}

Measured memory_bytes: 8696