akhauriyash/Code-Regression huggingface dataset:
//
// Knuth-Morris-Pratt
//   fail[i] := pat[0:i) の suffix と pat の prefix がどれだけ一致するか (長さ i 未満で)
//   O(N) で構築できる
//   これを利用して以下を求められたる
//     ・pat[0:i) の最小周期 ("abcabcab" は "abc" の繰り返しを区切ることでできるので 3)
//     ・文字列 S において S[i:] の prefix が pat と一致するような i をすべて求める
//
// verified:
//   ARC 060 F - 最良表現
//     https://atcoder.jp/contests/arc060/tasks/arc060_d
//


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;


struct KMP {
    string pat;
    vector<int> fail;

    // construct
    KMP(const string &p) { init(p); }
    void init(const string &p) {
        pat = p;
        int m = (int)pat.size();
        fail.assign(m+1, -1);
        for (int i = 0, j = -1; i < m; ++i) {
            while (j >= 0 && pat[i] != pat[j]) j = fail[j];
            fail[i+1] = ++j;
        }
    }

    // the period of S[0:i]
    int period(int i) { return i - fail[i]; }
    
    // the index i such that S[i:] has the exact prefix p
    vector<int> match(const string &S) {
        int n = (int)S.size(), m = (int)pat.size();
        vector<int> res;
        for (int i = 0, k = 0; i < n; ++i) {
            while (k >= 0 && S[i] != pat[k]) k = fail[k];
            ++k;
            if (k == m) res.push_back(i-m+1);
        }
        return res;
    }
};


vector<long long> divisor(long long n) {
    vector<long long> res;
    for (long long i = 1LL; i*i <= n; ++i) {
        if (n%i == 0LL) {
            res.push_back(i);
            long long temp = n/i;
            if (i != temp) res.push_back(temp);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    string str; cin >> str;
    int n = (int)str.size();
    vector<long long> divs = divisor(n);
    long long syuuki = n;
    for (auto d : divs) {
        bool ok = true;
        for (int j = 0; j + d < n; ++j) {
            if (str[j] != str[j+d]) ok = false;
        }
        if (ok) syuuki = min(syuuki, d);
    }
    if (syuuki == n) cout << 1 << endl << 1 << endl;
    else if (syuuki == 1) cout << n << endl << 1 << endl;
    else {
        vector<int> cannot_cut(n*2, 0);
        string str2 = str;
        reverse(str2.begin(), str2.end());
        KMP kmp1(str);
        KMP kmp2(str2);
        for (int d = 1; d < n; ++d) {
            if (kmp1.period(d) < d && d % kmp1.period(d) == 0) cannot_cut[d] = true;
            if (kmp2.period(d) < d && d % kmp2.period(d) == 0) cannot_cut[n-d] = true;
        }
        int con = 0;
        for (int i = 1; i < n; ++i) if (!cannot_cut[i]) ++con;
        cout << 2 << endl << con << endl;
    }
}


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

using namespace std;

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

    string s;
    cin >> s;
    int k = s.size();
    int cnto = count(begin(s), end(s), 'o');
    if (cnto + 15 - k >= 8) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }

    return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
set_bule = N//(A+B) * A
other = N - N//(A+B) * (A+B)
hashi_bule=0
if 0 <= other <= A:
    hashi_bule = other
else :
    hashi_bule = A
print(set_bule + hashi_bule) 

Measured memory_bytes: 3060
// Vicfred
// https://atcoder.jp/contests/abc130/tasks/abc130_c
// math
import std.stdio;

void main() {
    double w, h, x, y;
    readf("%s %s %s %s\n", &w, &h, &x, &y);
    writef("%.12s ", w*h/2.0);
    if(x + x == w && y + y == h)
        writefln("1");
    else
        writefln("0");
}



Measured memory_bytes: 2944
stdin = gets.chomp().split(" ").map {|n| n.to_i}
allnum = stdin[0]
qa = stdin[1]
qb = stdin[2]

maxnum = qa>=qb ? qb : qa

minnum = (qa+qb)-allnum
minnum = minnum>=0 ? minnum : 0
    


print(maxnum.to_s+" "+minnum.to_s)

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<iomanip>
#include<deque>
using namespace std;
typedef pair<int, int>P;
typedef pair<int, pair<int, int>>PP;
typedef long long ll;
ll inf = -1;
ll mod = mod = pow(10, 9) + 7;

int main() {
	long double w, h, x, y; cin >> w >> h >> x >> y;
	cout << fixed<<w * h / 2 << ' ';
	cout << (x * 2 == w && y * 2 == h) << endl;
	return 0;
}

Measured memory_bytes: 256
program sample
    implicit none
  
    integer(8) :: i,j,m,n,k,a,b
    
    integer(8),allocatable :: x(:)
    integer(8)::y(4)
  
    read(*,*) n
    allocate(x(n))
    read(*,*)x
    
    call msort(x)
    a=0
    b=0
    do i=n,1,-1
        
        if(x(i)==x(i-1))then
            if (a==1)then
                a=0
                cycle
            end if
            a=1
            b=b+1
            if (b==1)then
                m=x(i)
                a=1
            else
                m=m*x(i)
                exit
            end if
        else
            a=0
        end if
    end do
    if (b==2)then
    write(*,*)m
    else
        write(*,*)0
    end if

    stop
    
    contains
    recursive subroutine msort(x)
    implicit none
    integer(8), intent(inout) :: x(:)
 
    integer(8) :: n, mid, i, j, k
    integer(8), allocatable :: tmp(:)
    
    n = size(x)
    
    if(n == 1) then
      return
    end if
 
    !
    ! 前半と後半に分けてソート
    ! 1~midとmid+1~nをそれぞれソート済みにする
    !
    mid = n / 2
    call msort(x(:mid))
    call msort(x(mid+1:))
 
    !
    ! tmpという配列にxを一時的に保管
    ! マージソートは外部ソート
    !
    allocate(tmp(n))
    tmp = x
 
    ! tmpの後半部分を左右反転
    do k = n, mid+1, -1
      tmp(k) = x(mid + n - k + 1)
    end do
 
    ! iは前半のリストのうちまだ見ていないものの最小値
    ! jは後半のリストのうちまだ見ていないものの最小値
    ! kは見た回数の合計
    i = 1
    j = n
 
    do k = 1, n
      !
      ! 一番左と一番右のうち小さい方をxに入れていく
      ! ここが等号つき不等号なので、安定ソートとなる
      !
      if(tmp(i) <= tmp(j)) then
        x(k) = tmp(i)
        i = i + 1
      else
        x(k) = tmp(j)
        j = j - 1
      end if
    end do
    
    deallocate(tmp)
    return
  end subroutine msort
 
end program sample
  



Measured memory_bytes: 4880
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    c = set([n])
    for k in range(100):
        d = set()
        for t in c:
            ci = -1
            for i in range(100):
                if 6**i > t:
                    ci = i-1
                    break
            d.add(t-6**ci)
            ci = -1
            for i in range(100):
                if 9**i > t:
                    ci = i-1
                    break

            d.add(t-9**ci)
        c = d
        if 0 in d:
            return k+1

    return -1


print(main())



Measured memory_bytes: 7752
#include <stdio.h>
int main()
{
  int i, a, num;
  int c = 0;

  scanf("%d", &num);

  for (a = num; a < 100003; a++)
  {c=0;

    for (i = 2; i < a; i++)
    {

      if (a % i == 0)
      {
        c++;
        break;
      }
    }

    if (c == 0)
    {
      break;
    }
  }
  printf("%d", a);
  return 0;
}


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

int main() {
    vector<int> v(3);
    cin >> v.at(0) >> v.at(1) >> v.at(2);
    int max = *max_element(v.begin(), v.end());
    int min = *min_element(v.begin(), v.end());
    cout << max - min << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
    
    void solve() throws IOException {
        int n=ni();
        int[]A=new int[n];
        for (int i=0;i<n;i++) A[i]=ni();
        
        ArrayList<Integer>P=new ArrayList();
        boolean[]F=new boolean[1001];
        for (int i=2;i<1001;i++) {
            if (!F[i]) {
                P.add(i);
                for (int j=i;j<1001;j+=i) F[j]=true;
            }
        }
        
        int q=P.size();
        HashSet<Integer>G=new HashSet();
        HashMap<Integer,Integer>H=new HashMap();
        
        boolean cp=true;
        
        for (int i=0;i<n;i++) {
            for (int j=0;j<q;j++) {
                if (A[i]%P.get(j)==0) {
                    if (G.contains(P.get(j))) cp=false;
                    else G.add(P.get(j));
                    if (H.containsKey(P.get(j))) H.put(P.get(j),H.get(P.get(j))+1);
                    else H.put(P.get(j),1);
                    while (A[i]%P.get(j)==0) A[i]/=P.get(j);
                    if (A[i]==1) break;
                }
            }
            if (A[i]>1) {
                if (G.contains(A[i])) cp=false;
                else G.add(A[i]);
                if (H.containsKey(A[i])) H.put(A[i],H.get(A[i])+1);
                else H.put(A[i],1);
            }
        }
        
        if (cp) out.println("pairwise coprime");
        else {
            cp=true;
            for (Integer v:H.keySet())
                if (H.get(v)==n) cp=false; 
                
            if (cp) out.println("setwise coprime");
            else out.println("not coprime");
        }
        
        //out.println(ans);
        out.flush();
    }
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
}

Measured memory_bytes: 80132
#include<iostream>
using namespace std;
int main()
{
	long long n,a[100000]={0},count=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		count+=a[i];
	}
	if(count%2==0)
	{
		cout<<"YES";
		return 0;
	 } 
	cout<<"NO";
	return 0;
 } 

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>
#include <cstring>

#define sz(v) ((int)((v).size()))
#define all(v) (v).begin(), (v).end()

using namespace std;

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

const int INF = 0x3c3c3c3c;
const ll LINF = 1ll*INF*INF*2;

const int MAX_N = 100001;
int n, m;

int input[MAX_N];
int cnt[2][MAX_N];

int main(void) {
	scanf("%d", &n);
	for(int i=0; i<n; i++) scanf("%d", input+i);

	for(int i=0; i<n; i++) {
		cnt[i&1][input[i]]++;
	}
	
	int M1=0, M2=0;
	int idx1=-1, idx2=-1;
	for(int i=1; i<=100000; i++) {
		if(cnt[0][i] > M1) {
			M2 = M1;
			idx2 = idx1;
			M1 = cnt[0][i];
			idx1 = i;
		} else if(cnt[0][i] > M2) {
			M2 = cnt[0][i];
			idx2 = i;
		}
	}

	int x1=0, x2=0;
	int y1=-1, y2=-1;
	for(int i=1;i<=100000; i++) {
		if(cnt[1][i] > x1) {
			x2 = x1; y2 = y1;
			x1 = cnt[1][i]; y1 = i;
		} else if(cnt[1][i] > x2) {
			x2 = cnt[1][i]; y2 = i;
		}
	}

	if(y1 != idx1) {
		printf("%d", n-M1-x1);
		return 0;
	}
	
	printf("%d", n-max(M1+x2, M2+x1));
	return 0;
	
}


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

using namespace std;

typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;

    vector<ll> r(A);
    for(int i = 0 ; i < A ; ++i){
        cin >> r[i];
    }
    vector<ll> g(B);
    for(int i = 0 ; i < B ; ++i){
        cin >> g[i];
    }
    vector<ll> c(C);
    for(int i = 0 ; i < C ; ++i){
        cin >> c[i];
    }
    sort(r.begin(), r.end(), greater<int>());
    sort(g.begin(), g.end(), greater<int>());
    sort(c.begin(), c.end(), greater<int>());
    int ri = X-1;
    int gi = Y-1;
    int ci = 0;
    while(ci < C && ( (ri >= 0 && r[ri] < c[ci]) || (gi >= 0 && g[gi] < c[ci]) ) ){
        if(ri < 0 && gi < 0){
            ci = X+Y;
            break;
        }
        if(ri < 0){
            --gi;
            ++ci;            
        }
        else if(gi < 0){
            --ri;
            ++ci;
        }
        else if(r[ri] < g[gi]){
            --ri;
            ++ci;
        }
        else{
            --gi;
            ++ci;
        }
    }

    ll ret = 0;
    for(int i = 0 ; i <= ri ; ++i){
        ret += r[i];
    }
    for(int i = 0 ; i <= gi ; ++i){
        ret += g[i];
    }
    for(int i = 0 ; i < ci ; ++i){
        ret += c[i];
    }

    cout << ret << endl;


    return 0;
}

Measured memory_bytes: 2560
from itertools import accumulate
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, K = map(int, input().split())
S = input()[:-1]

L = [0]
L_index = [0]
prev = ""
for c in S:
    if c == prev:
        L[-1] += 1
    else:
        prev = c
        L.append(1)
        L_index.append(c)

L_acc = list(accumulate(L))

ans = 0
len_L = len(L)
for s in range(1, len_L):
    if L_index[s] == "0":
        right_end = min(s+K*2-1, len_L-1)
    else:
        right_end = min(s+K*2, len_L-1)
    ans = max(ans, L_acc[right_end]-L_acc[s-1])
print(ans)


Measured memory_bytes: 9008
n=int(input())

def f(a,b):
    a,b=len(str(a)),len(str(b))
    return max(a,b)

flist=[]
a=int(n**0.5)

for i in range(1,a+1):
    if n%i==0:
        j=int(n/i)
        tmp=f(i,j)
        flist.append(tmp)
print(min(flist))

Measured memory_bytes: 9444
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;

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

int m,n;
int prime[7700001];

int main(void){
	while(1){
		scanf("%d%d",&m,&n);
		if(m==0 && n==0)break;
		memset(prime,true,sizeof(prime));
		int cnt=0;
		prime[0]=false;
		prime[1]=false;
		for(int i=m;i<=7700000;i++){
			if(cnt==n)break;
			if(prime[i]){
				cnt++;
				for(int j=i;j<=7700000;j+=i){
					prime[j]=false;
				}
			}
		}
		int res=m+n;
		while(!prime[res])res++;
		printf("%d\n",res);
	}
	return 0;
}

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

int main() {
    int n, m , x;
    cin >> n >> m >> x;
    int costL = 0, costR = 0;
    
    for (int i = 0; i < m; i++){
        int temp;
        cin >> temp;
        if (temp < x){
            costL++;
        }
        else{
            costR++;
        }
    }

    cout << (costL < costR ? costL : costR) << endl;
}

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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 2003;
//#define int long long
const int INF = 1e9;

vector<int> g[MAXN];
           
void solve(){
  int n, k;
  cin >> n >> k;

  vector<pair<int, int>> e;
  for (int i = 0; i < n-1; i++){
      int a, b;
      cin >> a >> b;
      a--, b--;
      g[a].eb(b);
      g[b].eb(a);
      e.eb(a, b);
  }

  auto bfs = [&](int v1, int v2 = -1){
    deque<int> q;
    vector<int> d(n, INF);
    q.eb(v1);
    d[v1] = 0;
    if (v2 != -1){
      d[v2] = 0;
      q.eb(v2);
    }
    while (!q.empty()){
      int v = q.front();
      q.pop_front();
      for (auto i : g[v]){
        if (d[i] > d[v] + 1){
          d[i] = d[v] + 1;
          q.eb(i);
        }
      }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) if (d[i] > (k >> 1)) ans++;
    return ans;
  };

  int ans = INF;
  if (k % 2 == 0)
  for (int i = 0; i < n; i++){
    ans = min(ans, bfs(i));
  }
  else
  for (int i = 0; i < n-1; i++){
    ans = min(ans, bfs(e[i].ff, e[i].ss));
  }

  cout << ans << '\n';
}

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}


Measured memory_bytes: 3808
e_1,e_2,e_3,e_4=map(int,input().split())
if e_1==e_2 and e_3==e_4:
    print("yes")
elif e_1==e_3 and e_2==e_4:
    print("yes")
elif e_1==e_4 and e_2==e_3:
    print("yes")
else:
    print("no")


Measured memory_bytes: 5596
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<62;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> x(n),y(n);
    for(int i=0;i<n;++i){
        cin>>x[i]>>y[i];
    }
    auto xs = x;
    auto ys = y;
    sort(xs.begin(),xs.end());
    sort(ys.begin(),ys.end());
    ll ret = 1ll*(xs[n-1] -xs[0])*(ys[n-1] - ys[0]);
    for(int i=0;i<n-1;++i){
        for(int j=i+1;j<n;++j){
            for(int m=0;m<n-1;++m){
                for(int l=m+1;l<n;++l){
                    int num = 0;
                    for(int w=0;w<n;++w){
                        if(xs[i] <= x[w] and x[w] <= xs[j] and ys[m] <= y[w] and y[w] <= ys[l])num++;
                    }
                    if(num >= k)ret = min(ret,1ll*(xs[j] - xs[i])*(ys[l] - ys[m]));
                }
            }
        }
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int a[2][101];
int main()
{
    int n;
    while(scanf("%d",&n)==1)
    {
        for(int i = 0; i < 2; i++)
        {
            for(int j = 0; j < n; j++)
            {
                scanf("%d",&a[i][j]);
            }
        }
        int maxx = -1;
        int tem = 0;
        for(int i = 0; i < n; i++)
        {
            tem = 0;
            for(int j = 0; j <= i; j++)
                tem += a[0][j];
            for(int j = i; j <= n-1; j++)
                tem += a[1][j];
            if(tem > maxx)
                maxx = tem;
        }
        printf("%d\n",maxx);
    }
    return 0;
}


Measured memory_bytes: 256
let inputStr = '';

process.stdin.on('data', (input) => {inputStr += input;});

process.stdin.on('end', () => {
  const arr = inputStr.split('\n');
  search(arr[1].split(' '), arr[3].split(' '));
});

const search = (a, b) => {
  const base = a.length > b.length ? b : a;
  const target = a.length > b.length ? a : b;
  
  let match = 0;

  base.forEach((baseChar) => {
    for (let i=0; i<target.length; i++) {
      if (target[i] === baseChar) {
        match++;
        return;
      }
    }
  });

  console.log(match);
};


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

int main(){
    int N;
    cin >> N;
    vector<int> a(N+1);
    int b = 1, ans = 0;
    for(int i = 0; i < N; ++i) cin >> a[i+1];
    for(int i = 1; i < N+1; ++i){
        ++ans;
        b = a[b];
        if(b == 2) break;
        else if(i == N) ans = -1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3748
import java.util.Scanner;

public class Main {

	public static void main (String[] args){
	    Scanner scan = new Scanner(System.in);
	    Integer r = Integer.parseInt(scan.next());
	    Integer g = Integer.parseInt(scan.next());
	    Integer b = Integer.parseInt(scan.next());
	    Integer i = (r * 100 + g * 10 + b) % 4;

	    if(i == 0){
	    	System.out.println("YES");
	    }else{
	    	System.out.println("NO");
	    }
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
	~debug(){cerr<<endl;}
	template<class T> debug& operator<<(T x){cerr<<boolalpha<<x; return *this;}
	template<class B, class C> debug& operator<<(pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
	template<class T> debug& operator<<(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
	template<class T> debug& operator<<(vector<T> x){ return *this<<range(x.begin(),x.end());}
#else
	template<class T> debug& operator <<(const T&){return *this;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;


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

    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }
    vector<vector<int>> g(n);
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    
    for(int i = 0; i < n; i++) {
        sort(g[i].begin(), g[i].end());
        g[i].resize(unique(g[i].begin(), g[i].end())-g[i].begin());
    }
    int ans = 0;
    
    for(int i = 0; i < n; i++) {
        int me = h[i];
        int lower = 0;
        for(int j : g[i]) {
            if(h[j] < me) {
                lower++;
            }
        }
        if(lower == (int) g[i].size()) {
            ans++;
        }
    }
    
    cout << ans << endl;
        
}


Measured memory_bytes: 8680
from bisect import bisect_right, bisect_left

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

ans = 0
for b in B:
  ans += bisect_left(A, b) * (N - bisect_right(C, b))

print(ans)

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

int main()
{
    int N, K; cin >> N >> K;
    vector<pair<int, int>> xy(N);
    for (int i = 0; i < N; i++) cin >> xy[i].first >> xy[i].second;
    sort(xy.begin(), xy.end());

    ll ans = LLONG_MAX;
    for (int i = 0; i < N-1; i++) {
        for (int j = i + K - 1; j < N; j++) {
            ll dx = xy[j].first - xy[i].first;
            vector<int> y;
            for (int m = i; m <= j; m++) {
                y.push_back(xy[m].second);
            }
            sort(y.begin(), y.end());
            for (int m = 0; m + K - 1 < y.size(); m++) {
                int n = m + K - 1;
                ll a = dx * (y[n] -y[m]);
                if (a < ans) ans = a;
            } 
        }
    }
    cout << ans << endl;
}

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

int main(){
    long long n;

    map<long long, long long>T;
    cin >> n;

    long long a;
    for(int i = 0; i < n; i++){
        cin >> a;
        if(T.find(a) == T.end()){
            T[a] = 1;
        }
        else{
            T[a] += 1;
        }
    }

    map<long long, long long>::iterator it;

    long long sum;
    long long maxv = 0;

    for(it = T.begin(); it != T.end(); it++){
        sum = 0;
        sum += it->second;

        if(T.find(it->first-1) != T.end()){
            sum += T[it->first-1];
        }

        if(T.find(it->first+1) != T.end()){
            sum += T[it->first+1];
        }

        maxv = max(maxv, sum);
    }

    printf("%lld\n", maxv);

    return 0;

}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#include <cstring>
#include <ctype.h>
#include<stdlib.h>

#define flin            freopen("input.txt", "r", stdin); 
#define flout           freopen("output.txt", "w", stdout);
#define ll              long long
#define ull             unsigned long long
#define fastio          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl              '\n'
#define nll             '\0'
#define pb              push_back
#define bdyptb          return 0;
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define all(x)          x.begin(), x.end()
#define mset(a, b)      memset(a, b, sizeof(a));
#define testcase        ll t,tt; cin>>tt; for(t=1;t<=tt;t++)

#define pi acos(-1.00)   
#define mx 1000007

using namespace std;
int gcd(int x,int y)
{        
    return x ? gcd(y%x,x) : y;   
}  

int main()
{
    fastio;
    int n;
    cin>>n;
    int p[n+1];
    for(int i=1; i<=n; i++)
    cin>>p[i];

    int a[n+1],b[n+1];
    for(int i=1; i<=n; i++)
    {
        a[i]=(i*(n+2));
        b[i]=((n-i+1)*(n+2));
    }

    for(int i=1; i<=n; i++)
    b[p[i]]+=i;


    for(int i=1; i<=n; i++)
    cout<<a[i]<<' ';
    cout<<nl;
    
    for(int i=1; i<=n; i++)
    cout<<b[i]<<' ';
    cout<<nl;

    bdyptb;
}

Measured memory_bytes: 3868
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.next();

		if(str.equals("Sunny"))
        {
          System.out.println("Cloudy");
        }
      	if(str.equals("Cloudy")){
          System.out.println("Rainy");
        }
      	if(str.equals("Rainy")){
		  System.out.println("Sunny");
        }
	}
}

Measured memory_bytes: 23636
import sys
input = sys.stdin.readline
n, q = map(int, input().split())
s = input()

count = [0]
for i in range(1, n):
    count.append(count[i-1])
    if(s[i-1:i+1] == "AC"):
        count[i] += 1

# print(count)

for _ in range(q):
    l, r = map(int, input().split())
    print(count[r-1]-count[l-1])

Measured memory_bytes: 6340
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define rep(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(void){
    int x,y;
    cin>>x>>y;
    printf("%d %d\n",x*y,(x+y)*2);
}





Measured memory_bytes: 3216
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    cout << ( s=="AKIHABARA" || s=="AKIHABAR" || s=="AKIHABRA" || s=="AKIHABR" || s=="AKIHBARA" || s=="AKIHBAR" || s=="AKIHBRA" || s=="AKIHBR" || s=="KIHABARA" || s=="KIHABAR" || s=="KIHABRA" || s=="KIHABR" || s=="KIHBARA" || s=="KIHBAR" || s=="KIHBRA" || s=="KIHBR" ? "YES" : "NO" ) << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

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

int h, w;
int c[15][15];
int d[15][15];
int a[210][210];

void warshall_floyd()
{
	for (int k = 0; k < 10; k++) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

void dijkstra(int s)
{
	//priority_queue<int, vector<int>, greater<int>> q;

}

int main()
{
	cin >> h >> w;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> c[i][j];
			d[i][j] = c[i][j];
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}
	//cout << "a" << endl;
	ll sum = 0;

	warshall_floyd();
	/*
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cout << d[i][j] << " ";
		}
		cout << endl;
	}
	*/
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int k = a[i][j];
			if (k != -1)sum += d[k][1];
		}
	}
	cout << sum << endl;


	return 0;
}

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

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

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


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

  rep(i,n){
    cin>>a[i];
    a[i]--;
  }
  ll st=0;
  ll bef=0;
  ll loop=0;

  ll now=st;
  vector<ll> vis(n,-1);
  rep(i,n){
    if (vis[now]!=-1){
      bef=vis[now];
      loop=i-vis[now];
      st=now;
      break;
    }
    vis[now]=i;
    now=a[now];
  }
  //cout<<bef<<endl;
  //cout<<loop<<endl;
  ll ans=0;
  if (k<=bef){
    rep(i,k){
      ans=a[ans];
    }
  }
  else{

    k-=bef;
    k%=loop;

  ans=now;
  rep(i,k){
    ans=a[ans];
  }
}
//cout<<now<<endl;
  cout<<ans+1;
}


Measured memory_bytes: 11152
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second
#define MP make_pair
#define PB push_back

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;


int main()
{
  int n, y ;
  cin >> n >> y ;
  
  REP(a,n+1){
    REP(b,n-a+1){
      if((y/1000-n-9*a)%4==0 && b==(y/1000-n-9*a)/4){
        cout << a << " " << b << " " << n-a-b <<endl ;
        return 0 ;
      }
    }
  }
  cout << -1 <<" "<< -1 <<" "<< -1 <<endl ;
      
  


  return 0 ;
}
  


Measured memory_bytes: 256
#ABC169: C-Multiplication3
class Calc():
  def multi(self,x,y):
    x, y, sign, rslt = str(x)+".", str(y)+".",1 ,""
    if x[0]=="-":
      sign*=-1
      x=x[1:]
    if y[0]=="-":
      sign*=-1
      y=y[1:]
    x,y=x.split("."),y.split(".")
    x2 = [int(x[1][-i-1]) for i in range(len(x[1]))] + [int(x[0][-i-1]) for i in range(len(x[0]))]
    y2 = [int(y[1][-i-1]) for i in range(len(y[1]))] + [int(y[0][-i-1]) for i in range(len(y[0]))]
    sum=[0]*(len(x2)+len(y2))
    for i, p in enumerate(y2):
      for j, q in enumerate(x2):
        K=i+j
        sum[K]+=p*q
        while sum[K]>9:
          sum[K+1], sum[K] = sum[K+1] + int(sum[K]/10) , sum[K]%10
          K+=1
    for i in range(len(sum)): rslt+=str(sum[-i-1])
    dclen=len(x[1])+len(y[1])
    if dclen>0: rslt=rslt[:len(rslt)-dclen]+"."+rslt[len(rslt)-dclen:len(rslt)]
    for i in range(len(rslt)):
      if rslt[i]=="0" and (rslt[i+1] if i<len(rslt)-1 else ".")!="." : continue
      else:
        rslt=rslt[max(i,0):]
        break
    if "." in rslt: rslt=rslt[:rslt.index(".")] #(小数点以下切捨て)
    return ("-" if sign==-1 else "")+rslt

A,B=input().split()
print( Calc().multi(A,B) )

Measured memory_bytes: 9320
#include <iostream>
#include <set>
#include <string>
#include <queue>

using namespace std;

main(){
  string in;                    //¶ñÌúóÔ(ªÆÈé)
  while(cin>>in){
    if(in[0]=='0')break;        //I¹ð

    //gpÏÌú»
    int ans=-1;                 //answer(ðÉHèÂ¯È¢ê-1ÌÜÜ)
    set<string> vis;            //Tõµ½m[h
    queue<pair<string,int> > q; //ÉTõ·é¶ñðüêéB

    q.push(make_pair(in,0));    //ªðL[ÉüêéBÅZèÍà¿ëñ0
    vis.insert(in);             //¶ñssÍTõµ½B

    
    //TõÌæªcÁÄ¨èAðÉ½Çè¢ÄÈ¢ÀèTõ
    while(!q.empty()){
      //Tõm[hÌ¶ñÆA[³ðæèo·B
      string str=q.front().first;
      int depth=q.front().second;
      q.pop();
      
      //¶ñªê¶ÌÝ©ç\¬³êÄ¢é©ð»èB
      //ê¶ÌÝ©çÈÁÄ¢½êA¦ª©Â©Á½±ÆÉÈéÌÅTõðÅ¿ØéB
      int r=0,g=0,b=0;
      for(int i=0;i<str.size();i++){
        switch(str[i]){
        case 'r':++r;break;
        case 'g':++g;break;
        case 'b':++b;break;
        }
      }
      if(r==str.size() || g==str.size() || b==str.size()){
        ans=depth;
        break;
      }

      //ÙÈéñgÌ¶ðTµoµA»êðL[ÉlßéB
      for(int i=0;i<str.size()-1;i++){
        if(str[i]!=str[i+1]){
          string next(str);      //ðÁ¦é¶ñ(ÈºÌ3ÂÌif¶ÅKp)
          
          if( (str[i]=='b' && str[i+1]=='g') ||
              (str[i]=='g' && str[i+1]=='b')){
            next[i]='r';
            next[i+1]='r';
          }

          if( (str[i]=='r' && str[i+1]=='g') ||
              (str[i]=='g' && str[i+1]=='r')){
            next[i]='b';
            next[i+1]='b';
          }
          
          if( (str[i]=='b' && str[i+1]=='r') ||
              (str[i]=='r' && str[i+1]=='b')){
            next[i]='g';
            next[i+1]='g';
          }

          //·ÅÉTõµÄ¢½¶ñ¾Á½êXLbv
          if(vis.count(next)==1)continue;

          //Tõ\èÌm[hÆµÄL[ÉüêéB
          q.push(make_pair(next,depth+1));
          vis.insert(next);
        }
      }
    }
    
    if(ans==-1)cout<<"NA"<<endl;    //SÄðTõµÄàðª©Â©çÈ©Á½ê
    else cout<<ans<<endl;           //ðª©Â©Á½êÅZðoÍ
  }
}

Measured memory_bytes: 1768
#include <stdio.h>
int main(void){
 int x,y;
 while(1){
     scanf("%d %d",&x,&y);
     if(x==0 && y==0)break;
     if(x>y){
         printf("%d %d\n",y,x);
     }
     else{
         printf("%d %d\n",x,y);
     }
 }
 return 0;
    
}



Measured memory_bytes: 2616
#include<stdio.h>
int main()
{
  int H[300],W[300],i,j,k;

  for(k=1;k<=300;k++){
    scanf("%d %d",&H[k],&W[k]);
     if(H[k]==0&&W[k]==0){
      break;
     }
  }
  for(k=1;k<=300;k++){
    if(H[k]==0&&W[k]==0){
      break;
     }
  for(i=1;i<=H[k];i++){
    for(j=1;j<=W[k];j++){
    printf("#");
    }
    printf("\n");
  }
  printf("\n");

  }
  return 0;
}



Measured memory_bytes: 2148
using System;

class Program
{
  static void Main(string[] args)
  {
    int N = int.Parse(Console.ReadLine());
    int minA = 1 << 30;
    int maxA = 0;

    string[] items = Console.ReadLine().Split(' ');
    for (int i = 0; i < N; ++i)
    {
      int a = int.Parse(items[i]);
      minA = Math.Min(minA, a);
      maxA = Math.Max(maxA, a);
    }

    Console.WriteLine(maxA - minA);
  }
}


Measured memory_bytes: 11092
# -*- coding: utf-8 -*-

### TESTCASE
test = ""
#test = \
"""
10 4
ans 3
"""

"""
10000 1
"""
############
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
####### MAIN


def roundup(n, d):
    if n % d:
        return n // d + 1
    else:
        return n // d


h, a = map(int, input2().split())
    
print(roundup(h, a))


Measured memory_bytes: 3060
N, K = gets.split(" ").map(&:to_i)
S = gets.chomp.chars
l = "1"
ary = [0, 0]

S.each do |c|
    if c == l
        ary[-1] += 1
    else
        ary << ary[-1] + 1
    end
    l = c
end

ary += [ary[-1]] * (N * 2)
p ((ary.size - K) / 2).times.map{|i| ary[i * 2 + K * 2 + 1].to_i - ary[i * 2]}.max

Measured memory_bytes: 12980
using System;

namespace A_Registration
{
    class Program
    {
        static void Main()
        {
            string ans = "Yes";
            string s = Console.ReadLine();
            string t = Console.ReadLine();

            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] != t[i])
                {
                    ans = "No";
                }
            }

            Console.WriteLine(ans);
        }
    }
}

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

int main(){
    int n, v[25], c[25], ans = 0;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> v[i];
    }
    for(int i=0; i<n; i++){
        cin >> c[i];
    }
    for(int i=0; i<n; i++){
        ans += max(v[i] - c[i], 0);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

int main() {
  int a, L, res1, res2, res3;
  bool flag;
  while (cin >> a >> L, a | L) {
    vector<int> a_list;
    while (1) {
      a_list.pb(a);
      int tmp1 = 0, tmp2 = 0;
      int num[L];
      for (int i = 0; i < L; i++) {
        num[i] = a%10;
        a /= 10;
      }
      sort(num, num+L);
      for (int i = 0; i < L; i++) {
        tmp1 = tmp1*10 + num[L-i-1];
        tmp2 = tmp2*10 + num[i];
      }
      a = tmp1 - tmp2;
      flag = true;
      for (int i = 0; i < a_list.size(); i++) {
        if (a_list[i] == a) {
          res1 = i;
          res2 = a_list[i];
          res3 = a_list.size()-i;
          flag = false;
        }
      }
      if (!flag) break;
    }
    cout << res1 << " " << res2 << " " << res3 << el;
  }
}

Measured memory_bytes: 1220
#include <iostream>
using namespace std;
const int sz=1e6+10;
int a[sz];
main()
{
    int n, x;
    cin >> n >> x;
    long long ans = 0;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
    {
        int dif = a[i] + a[i + 1] - x;
        if (dif > 0)
        {
            ans += dif;
            a[i + 1] -= dif;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1e9+10
int n,X,D,ans,cnt,dp[125003];
int w[53],val[53],pos[53];
int tot,V[53*53],W[53*53];
inline int read(){
    int x=0,k=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')k=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return x*k;
}
struct edge{
    int cnp,to[53],last[53],head[53];
    edge(){cnp=1;}
    void add(int u,int v){
		to[cnp]=v,last[cnp]=head[u],head[u]=cnp++;
	}
}E1;
void dfs(int u){
    val[u]=1;
    for(int i=E1.head[u];i;i=E1.last[i]){
        int v=E1.to[i];
        dfs(v);
        w[u]+=w[v],val[u]+=val[v];
    }
    cnt+=val[u]*n;
	pos[u]=u;
}
inline bool cmp(int x,int y){
	return val[x]*w[y]>val[y]*w[x];
}
inline void Get_min(int &x,int y){
	x=x<y?x:y;
}
signed main(){
    n=read(),X=read(),D=read();
    w[1]=read();
    for(int i=2;i<=n;i++){
        w[i]=read();
		int x=read();
        E1.add(x,i);
    }
    dfs(1);
    sort(pos+1,pos+n+1,cmp);
    int tmp=min(n,D);
    for(int i=1;i<=cnt;i++){
    	dp[i]=INF;
	}
    for(int i=1;i<=n;i++){
        int len=1,lim=tmp;
        while(lim>=len){
            V[++tot]=len*val[pos[i]];
            W[tot]=len*w[pos[i]];
            lim-=len,len<<=1;
        }
        if(lim){
        	V[++tot]=lim*val[pos[i]],W[tot]=lim*w[pos[i]];
		}
    }
    for(int i=1;i<=tot;i++){
    	for(int j=cnt;~j;j--){
        	if(j>=V[i]){
				Get_min(dp[j],dp[j-V[i]]+W[i]);
			}
		}
	}
    int ans=0;
    for(int i=0;i<=cnt;i++){
        if(dp[i]>X){
        	continue;
		}
        int ret=i,left=X-dp[i];
        for(int j=1;j<=n;j++){
            int tem=pos[j],used=min(max(D-n,0LL),left/w[tem]);
            if(tem==1) used=left/w[tem];
            left-=w[tem]*used;
            ret+=val[tem]*used;
        }
        ans=max(ans,ret);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(void) {
    string ss;
    cin >> ss;

    if(ss.at(0)==ss.at(1) || ss.at(1)==ss.at(2)|| ss.at(2)==ss.at(3)) cout << "Bad" << endl;
    else cout << "Good" << endl;
    
    return (0);
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll x,t;
    cin >> x>>t;
    if(t > x) cout << 0 <<endl;
    else cout << x-t << endl;
    
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=1e9+7;
const ll inf=2e14;
const ll ms=(2e5) +5;

ld ar[ms];

int main()
{
    idfc;
    int n,k;
    cin>>n>>k;
    int i;
    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
        ar[i]++;
        ar[i]/=2;
    }
    ld mx=0;
    for(i=1;i<=k;i++)
    {
        mx+=ar[i];
    }
    ld sm=mx;
    for(i=k+1;i<=n;i++)
    {
        sm-=ar[i-k];
        sm+=ar[i];
        mx=max(mx,sm);
    }
    cout<<fixed<<setprecision(10)<<mx;
    return 0;
}

Measured memory_bytes: 3456
N = int(input())
h_list = list(map(int, input().split()))

ans = 0
h_min = min(h_list)

ans += h_min

for i in range(N):
    h = h_list[i]
    if i == 0:
        ans += h - h_min
        pre = h
    else:
        if h >= pre:
            ans += h - pre
            pre = h
        else:
            pre = h
print(ans)


Measured memory_bytes: 3060
#include <iostream>

int main()
{
    std::size_t S, W;
    std::cin >> S >> W;
    if(S <= W)
    {
        std::cout << "unsafe" << std::endl;
    }
    else
    {
        std::cout << "safe" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
using namespace std;
#define ll long long
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define TOAD
//#define int ll
#ifdef TOAD
#define bug(x) cerr<<__LINE__<<": "<<#x<<" is "<<x<<endl
#define IOS() 
#else
#define bug(...)
#define IOS() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
const ll inf = 1ll<<60;
const int iinf=2147483647;
const ll mod = 998244353;
const ll maxn=300005;
ll pow(ll a, ll b){
  ll re=1;
  while(b){
    if (b&1){
      re*=a;
      re%=mod;
    }
    a*=a;
    a%=mod;
    b>>=1;
  }
  return re;
  //ㄑ 
}
ll mul2(ll a,ll b,ll n){
    a%=n,b%=n;
    ll y=(ll)((long double)a*b/n+0.5); 
    ll r=(a*b-y*n)%n;
    return r<0?r+n:r;
}
 
signed main (){
  IOS();
  int a, b, c; cin>>a>>b>>c;
  if ((c-b)%2==0) cout<<"Alice\n";
  else cout<<"Borys\n"<<endl;
 }

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

struct LazySegmentTree {
    int size;
    vector<ll> node, lazy;

    LazySegmentTree(int n) {
        size = 1;
        while (size < n) size <<= 1;
        node.resize(2 * size);
        lazy.resize(2 * size);
    }

    void eval(int k) {
        if (lazy[k] == 0) return;
        node[k] += lazy[k];
        if (k < size) {
            lazy[2 * k] += lazy[k] / 2;
            lazy[2 * k + 1] += lazy[k] / 2;
        }
        lazy[k] = 0;
    }

    void update(int a, int b, ll x, int k = 1, int l = 0, int r = -1) {
        if (r == -1) r = size;
        eval(k);
        if (r <= a || b <= l) return;
        if (a <= l && r <= b) {
            lazy[k] = (r - l) * x;
            eval(k);
        } else {
            int m = (l + r) / 2;
            update(a, b, x, 2 * k, l, m);
            update(a, b, x, 2 * k + 1, m, r);
            node[k] = node[2 * k] + node[2 * k + 1];
        }
    }

    ll query(int i, int k = 1, int l = 0, int r = -1) {
        if (r == -1) r = size;

        eval(k);
        int m = (l + r) / 2;
        if (k >= size && l == i) return node[k];
        if (l <= i && i < m) return query(i, 2 * k, l, m);
        else return query(i, 2 * k + 1, m, r);
    }
};

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

    int n, q;
    cin >> n >> q;
    LazySegmentTree st(n);
    for (int j = 0; j < q; j++) {
        int type;
        cin >> type;
        if (type == 0) {
            int s, t, x;
            cin >> s >> t >> x;
            st.update(s - 1, t, x);
        } else {
            int i;
            cin >> i;
            cout << st.query(i - 1) << '\n';
        }
    }
}


Measured memory_bytes: 7072
#include <bits/stdc++.h>
using namespace std;
template <typename T>
constexpr T INF = numeric_limits<T>::max() / 16;
struct CostGraph
{
    CostGraph(const int v) : edge(v) {}
    struct Edge
    {
        Edge(const int from, const int to, const int cost) : from{from}, to{to}, cost{cost} {}
        const int from, to, cost;
    };
    void addEdge(const int from, const int to, const int cost) { edge[from].push_back(Edge{from, to, cost}); }
    vector<vector<Edge>> edge;
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (true) {
        int N, M, C;
        cin >> N >> M >> C;
        if (N == 0 and M == 0 and C == 0) { break; }
        CostGraph g(N);
        for (int i = 0; i < M; i++) {
            int f, t, c;
            cin >> f >> t >> c, g.addEdge(f - 1, t - 1, c);
        }
        vector<vector<int>> dp(N, vector<int>(N, INF<int>));
        using PP = pair<int, pair<int, int>>;
        priority_queue<PP, vector<PP>, greater<PP>> q;
        dp[0][0] = 0;
        q.push({0, {0, 0}});
        while (not q.empty()) {
            const auto& p = q.top();
            const int s = p.second.first, m = p.second.second, c = p.first;
            q.pop();
            if (dp[s][m] < c) { continue; }
            for (const auto& e : g.edge[s]) {
                if (dp[e.to][m] > dp[s][m] + e.cost) { dp[e.to][m] = dp[s][m] + e.cost, q.push({dp[e.to][m], {e.to, m}}); }
                if (m < N - 1 and dp[e.to][m + 1] > dp[s][m]) { dp[e.to][m + 1] = dp[s][m], q.push({dp[e.to][m + 1], {e.to, m + 1}}); }
            }
        }
        for (int i = 1; i < N; i++) {
            if (dp[N - 1][i] <= C) {
                cout << i << "\n";
                break;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3296
#include "bits/stdc++.h"
using namespace std;

int main(){
 	int a,b;
 	cin >> a >> b;
 	vector<string> c (a);
 	for(int i=0;i<a;i++){
 	    cin >> c.at(i);
 	}
 	for(int i=0;i<b+2;i++){
 	    cout <<'#';
 	}
 	cout << endl;
 	for(int i=0;i<a;i++){
 	        cout<<'#' << c.at(i) <<'#' << endl;
 	    }
 	 
 	    for(int i=0;i<b+2;i++){
 	        cout <<'#';
 	    }
 	    cout <<endl;
 	}


Measured memory_bytes: 256
n,m=map(int,input().split())
s=[]
for _ in range(m):
  k,*b=map(int,input().split())
  s.append(b)
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
  tr=bin(i)[2:].zfill(n)
  light=0
  for j in range(m):
    sw=0
    for l in s[j]:
      if tr[l-1]=='1':
        sw+=1
    if sw%2==p[j]:
      light+=1
  if light==m:
    ans+=1
print(ans)

Measured memory_bytes: 74240
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)


int main(){
    string s, t;
    cin >> s >> t;
    int n=s.size();
    vector<int> s_letter_num(26,0), t_letter_num(26,0);
    REP(i,n){
        s_letter_num[s[i] - 'a']++;
        t_letter_num[t[i] - 'a']++;
    }
    sort(s_letter_num.begin(), s_letter_num.end());
    sort(t_letter_num.begin(), t_letter_num.end());
    REP(i,26){
        if(s_letter_num[i]!=t_letter_num[i]){
            cout << "No" << endl;
        return 0;
        }
        
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1020