akhauriyash/Code-Regression huggingface dataset:
s = list(input())
f = True
for i in range(len(s) - 1):
    if s[i] == s[-1 - i]:
        pass
    else:
        f = False
ss = [s[i] for i in range((len(s) - 1) // 2)]
for i in range(len(ss) // 2):
    if ss[i] == s[-1 - i]:
        pass
    else:
        f = False
sss = [s[i] for i in range((len(s) + 3) // 2 - 1, len(s))]
for i in range(len(sss) // 2):
    if sss[i] == s[-1 - i]:
        pass
    else:
        f = False
if f:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

const MOD: usize = 1_000_000_007;

fn main() {
    input! {
        n:usize,k:usize
    }
    if n == 1 {
        println!("1");
        return;
    }
    let mut count = vec![0];
    let mut i = 1;
    while i <= n {
        let j = n / i;
        if i <= j {
            count.push(1);
            i += 1;
        } else {
            count.push(n / j + 1 - i);
            i = n / j + 1;
        }
    }
    let mut dp = count.clone();
    for _ in 1..k {
        let mut sum = vec![];
        let mut buf = 0;
        for &i in &dp {
            buf += i;
            sum.push(buf);
        }
        for i in 1..count.len() {
            dp[i] = (sum[count.len() - i] * count[i]) % MOD;
        }
        //dbg!(&dp);
    }
    println!("{}", dp.iter().sum::<usize>() % MOD);
}


Measured memory_bytes: 3404
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.ABC118
{
    class A
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] ab = ReadInts();
            Console.WriteLine(
                ab[1] % ab[0] == 0 ? ab[0] + ab[1] : ab[1] - ab[0]);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main() {
	int a, b;
	cin >> a >> b;
	int ans = max(0, a - 2 * b);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    a = list(map(int, input().split()))
    l = []
    if abs(max(a)) >= abs(min(a)):
        i = a.index(max(a))
        t = max(a)
        for j in range(1, N+1):
            l.append((i+1, j))
        for i in range(1, N):
            l.append((i, i+1))
    else:
        i = a.index(min(a))
        t = min(a)
        for j in range(1, N+1):
            l.append((i+1,j))
        for i in range(N-1, 0, -1):
            l.append((i+1, i))
    print(len(l))
    for i in l:
        print(i[0], i[1])
main()


Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>

#define INF 1000000000;
#define MOD 1000000007;
typedef long long ll;
using namespace std;

ll fn(ll m, ll a) {
    return m % a;
}

int main()
{
    int a, b, x; cin >> a >> b >> x;
    string ans = "YES";
    if (a > x) {
        ans = "NO";
    }
    else if (a + b < x) {
        ans = "NO";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (l, r) = readLine()!!.split(" ").map { it.toInt() }

    val mem = Array(2019) { IntArray(2019) { 0 } }

    for (i in 0 until 2019) {
        for (j in 0 until 2019) {
            mem[i][j] = i * j % 2019
        }
    }

    val cnt = IntArray(2019) { 0 }
    var loop = 0
    for (i in l..r) {
        cnt[i%2019] += 1
        loop += 1
        if (loop >= 4038) {
            break
        }
    }

    var ans = 2020
    for (i in 0 until 2019) {
        for (j in 0 until 2019) {

            if (i == j) {
                if(cnt[i]==2) {
                    ans = Math.min(ans, mem[i][j])
                }

                continue
            }

            if (cnt[i] > 0 && cnt[j] > 0){
                ans = Math.min(ans, mem[i][j])
            }
        }
    }

    println(ans)
}

Measured memory_bytes: 53916
n = int(input())
if n==1:
    print('Yes')
    print(2)
    print(1, 1)
    print(1, 1)
    exit(0)
for i in range(2, 1000):
    if i*(i+1)//2>n:
        print('No')
        exit(0)
    if i*(i+1)//2==n:
        break
q = list(range(n, 0, -1))
ans = []
for j in range(i+1):
    tmp = []
    for k in ans:
        tmp.append(k[j-1])
    for _ in range(i-j):
        tmp.append(q.pop())
    ans.append(tmp)
print('Yes')
print(i+1)
for j in ans:
    tmp = [i]+j
    print(*tmp)

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

int main(void) {

  char s[1000000+10];
  scanf("%s", s);
  int length = strlen(s);
  int num;
  long bill_a = 0;
  long bill_b = 1;
  long case1,case2,case3,case4;
  for (int i = 0; i < length; i++) {
    num = s[i]-'0';
    case1 = bill_a+num;
    case2 = bill_b+10-num;
    case3 = bill_a+(num+1);
    case4 = bill_b+10-(num+1);
    bill_a = case1;
    if (case2 < bill_a) {
      bill_a = case2;
    }
    bill_b = case3;
    if (case4 < bill_b) {
      bill_b = case4;
    }
  }
  printf("%ld\n", bill_a);

  return 0;
}

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

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

    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }

    vector<int> ans(n);
    for(int i = 0; i < n; i++){
        ans.at(a.at(i) - 1) = i + 1;
    }
    for(int i = 0; i < n; i++){
        cout << ans.at(i) << endl;
    }
    return 0;
}

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



struct unionfind{
    vector<int> parent;
    vector<int> rank;
    vector<int> size;

    unionfind (int N) {
        parent = vector<int>(N);
        iota(parent.begin(), parent.end(), 0);
        rank = vector<int>(N, 0);
        size = vector<int>(N, 1);
    }
    int root(int x) {
        if (parent[x] == x) return x;
        parent[x] = root(parent[x]);
        return parent[x];
    }
    
    bool same(int x, int y){
        return root(x) == root(y);
    }
    
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] > rank[y]) {
            parent[y] = x;
            size[x] += size[y];
        }
        else {
            parent[x] = y;
            size[y] += size[x];
            if (rank[x] == rank[y]) rank[y] += 1;
        }
    }
};

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> fr(N+1, 0);
    vector<int> blk(N+1, 0);
    unionfind uf(N+1);
    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        fr[A]++;
        fr[B]++;
        uf.unite(A, B);
    }
    for (int i = 0; i < K; i++) {
        int C, D;
        cin >> C >> D;
        if (uf.same(C, D)){
            blk[C]++;
            blk[D]++;
        }
    }
    for (int i = 1; i <= N; i++) {
        cout << uf.size[uf.root(i)] - blk[i] - fr[i] - 1;
        if (i < N) cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2816
def main():
    N, K = map(int, input().split())

    np = 0
    for x in range(1, N + 1):
        p = 1
        while x < K:
            p *= 1 / 2
            x *= 2
        np += p

    ans = np / N

    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 2940
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
N, M, K = map(int, input().split())
num_fri = [0] * N
union = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    num_fri[a] += 1
    num_fri[b] += 1
    union.union(a, b)
for i in range(K):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if union.same(a, b):
        num_fri[a] += 1
        num_fri[b] += 1
for i in range(N):
    print(union.size(i) - 1 - num_fri[i], end=' ')

Measured memory_bytes: 8684
#include<stdio.h>
#include<stdlib.h>
int inc(const void *a, const void *b)
{
	return *(int *)a-*(int *)b;
}
int main()
{
	int n,a[10000],l=0,r=1,m,cnt=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	qsort(a,n,sizeof(int),inc);
	m=2;
	for(int i=0;i<n-2;i++)
	{
		for(int j=i+1;j<n-1;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				if(a[i]+a[j]>a[k])cnt++;
			}
		}
	}
	printf("%d\n",cnt);
}

Measured memory_bytes: 256
import math
n, m = map(int, input().split())
mod = 10 ** 9 + 7

if n == m:
  res = 2 * math.factorial(n) * math.factorial(m)
  print(res % mod)
elif abs(n - m) == 1:
  res = math.factorial(n) * math.factorial(m)
  print(res % mod)  
else:
  print(0)

Measured memory_bytes: 11084
# Problem C - Colon

import math

# input
A, B, H, M = map(int, input().split())

# initialization
hour_kakudo = 360*(H/12) + 30*(M/60)
minute_kakudo = 360*(M/60)
kakudo = min(abs(hour_kakudo-minute_kakudo), 360-abs(hour_kakudo-minute_kakudo))
radian = math.radians(kakudo)

# calc
ans = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(radian))

# output
print(ans)


Measured memory_bytes: 9380
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

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

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

	cin >> N >> K;
	if (N % 2 == 0) {
		cout << N / 2;
		for (int i = 1; i < K; i++) {
			cout << " " << N ;
		}
		cout << endl;
		return 0;
	}
	if (N == 1) {
		for (int i = 0; i < (K+1) / 2; i++) {
			cout << N << " ";
		}
		cout << endl;
		return 0;
	}
	vector<int>ans(K,N/2+1);
	M = K / 2;
	while (M) {
		for (int i = K - 1; i >= 0; i--) {
			if (ans[i]) {
				ans[i]--;
				if (ans[i]) {
					for (int j = i + 1; j < K; j++) {
						ans[j] = N;
					}
				}
				break;
			}
		}
		M--;
	}
	for (int i = 0; i < K; i++) {
		if (ans[i] == 0) {
			break;
		}
		cout << ans[i] << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 100010
ll p[M];
ll find(ll v){
	return (v==p[v]) ? v : p[v]=find(p[v]);
}
void join(ll a,ll b){
	a=find(a),b=find(b);
	if(rand()%2)swap(a,b);
	p[b]=p[a];
}
int main(){
	IOS;
	ll n,m;cin>>n>>m;
	rep(i,0,n)p[i]=i;
	rep(i,0,m){
		ll x,y,z;cin>>x>>y>>z;x--,y--;
		join(x,y);
	}
	ll con=0;
	rep(i,0,n)if(i==find(i))con++;
	cout<<con;
	return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main() {
	double D, T, S, Tu;
	cin >> D >> T >> S;
	Tu = D / S;
	if (T >= Tu) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

const int INF = 1001001001;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

i64 dp[101][2][4];

void solve() {
  string s;
  int k;
  cin >> s >> k;
  int n = sz(s);
  dp[0][0][0] = 1;
  rep(i, n) rep(j, 2) repc(k, 3) rep(d, 10) {
    int dig = s[i] - '0';
    if (j == 0 && dig < d) continue;
    int nj = 1, nk = k;
    if (j == 0 && dig == d) nj = 0;
    if (k == 3 && d > 0) continue;
    if (d > 0) nk += 1;
    dp[i + 1][nj][nk] += dp[i][j][k];
  }
  cout << dp[n][0][k] + dp[n][1][k] << endl;
}


Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Chars;
fn main() {
    input!{
        h: usize,
        w: usize,
        k: usize,
        c: [Chars; h],
    };
    let mut cnt = 0;
    let mut ans = 0;
    for hi in 0..1 << h {
        for wi in 0..1 << w {
            for i in 0..h {
                for j in 0..w {
                    if hi >> i & 1 == 1 {
                        continue;
                    }
                    if wi >> j & 1 == 1 {
                        continue;
                    }
                    if c[i][j] == '#' {
                        cnt += 1;
                    }
                }
            }
            // eprintln!("hi = {:#010b} wi = {:#010b} cnt = {}", hi, wi, cnt);
            if cnt == k {
                ans += 1;
            }
            cnt = 0;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2164
#include<bits/stdc++.h>
using namespace std;
int main(){
    
    int n,m,x;
    cin >> n >> m >> x;
    
    vector<int> a(m);
    for(int i=0;i<m;i++){
        cin >> a.at(i);
    }
    int i;
    for(i=0;i<m;i++){
        if(a.at(i)>=x){
            break;
        }
    }
    cout << (i>m/2?m-i:i) << endl;
    
}


Measured memory_bytes: 256
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)

const bs = (arr, x) => {
    let l = -1
    let r = arr.length
    while(r-l >1){
        let mid = Math.floor((l+r)/2)
        if(arr[mid] >= x){
            r = mid
        }else{
            l = mid
        }
    }
    return r
}

const bs2 = (arr, x) => {
    let l = -1
    let r = arr.length
    while(r-l >1){
        let mid = Math.floor((l+r)/2)
        if(arr[mid] <= x){
            l = mid
        }else{
            r = mid
        }
    }
    return l
}

const Main = () => {
    const n = nextInt()
    let l = nextIntArray()
    l.sort((a,b)=>a-b)
    let cnt = 0
    for(let i = 0; i<l.length-2;i++){
        for(let j = i+1; j < l.length-1; j++){
            const gte = l[j] - l[i] + 1
            const lte = l[j] + l[i] - 1
            let firstIdx = bs(l, gte)
            let lastIdx = bs2(l, lte)
            firstIdx = Math.max(j+1, firstIdx)
            lastIdx = Math.min(l.length, lastIdx)
            if(firstIdx <= lastIdx){
                cnt += lastIdx - firstIdx + 1
            }
        }
    }
    console.log(cnt)
}
Main()


Measured memory_bytes: 33116
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
    string S;
    cin >> S;
    if(S=="SAT"){
        cout << 1 << endl;
    }else if(S=="FRI"){
        cout << 2 << endl;
    }else if(S=="THU"){
        cout << 3 << endl;
    }else if(S=="WED"){
        cout << 4 << endl;
    }else if(S=="TUE"){
        cout << 5 << endl;
    }else if(S=="MON"){
        cout << 6 << endl;
    }else if(S=="SUN"){
        cout << 7 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d%d",&x,&y)
#define siii(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld%lld",&x,&y)
#define slll(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
 
#define ll long long
#define mp make_pair
#define pb push_back
#define nl printf("\n");
#define pf printf
#define rep(i,n) for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int>
#define tci int t;scanf("%d",&t);while(t--)
const int maxn=10e6+4;

int len(ll n)
{
    int c=0;
    while(n)
    {
        n=n/10;
        c++;
    }
    return c;
}


int main()
{
    ifstream myFile("task.in");
    if(!myFile.fail())
    {
        assert(freopen("task.in", "r", stdin));
    }
    int per[1000000];
    rep(i,1000)
        per[i*i]=1;

    ll a,b;
    sll(a,b);
    int l=len(b);

    a=a*pow(10,l) + b;
    // cout<<a;
    if(per[a]==1)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 3968
import java.util.*;

public class Main {
        public static void main(String[] args){
            Scanner sc =new Scanner(System.in);
            int a = sc.nextInt();
            int b = sc.nextInt();
            int sum =0;
            for(int i=0;i<2;i++) {
                if (a > b) {
                    sum += a;
                    a--;
                } else {
                    sum += b;
                    b--;
                }
            }
            System.out.println(sum);
        }

        }



Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int n,ans=0,mx=0;
	cin>>n;
	if(n<1000){
	    cout<<"ABC";
	}
	else{
	    cout<<"ABD";
	}
	return 0;
}


Measured memory_bytes: 256
import Data.List
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as B

p2s = map (2^) [1..32]
main=do
    _<-getLine
    as<-foldl' (\m a->M.insertWith (+) a 1 m) M.empty.unfoldr (B.readInt.B.dropWhile(==' '))<$>B.getLine
    print $ sum $ unfoldr s as
s as
    | M.null as = Nothing
    | fcc == k  = Just(a`div`2, as')
    | otherwise = case M.lookup fcc as' of
        Nothing -> Just(0, as')
        Just b  -> if b<=a
                    then Just(b, M.delete fcc as')
                    else Just(a, M.insert fcc (b-a) as')
    where
        ((k,a), as') = M.deleteFindMax as
        fc = head $ dropWhile (<k) p2s
        fcc = if fc==k then k else fc-k

Measured memory_bytes: 36220
#include<cstring>
#include<cstdio>
#include<algorithm>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;i++)
#define fd(i,a,b)for(int i=b,_e=a;i>=_e;i--)
#define ll long long
#define max(a,b)(a>b?a:b)
using namespace std;
const int N=2e5+5,mo=1e9+7;
int n,g;
char c[N];
ll ans;
int main(){
	scanf("%s",c+1);n=strlen(c+1);
	fd(i,1,n){
		if(c[i]=='W')g++;
		else ans+=g;
	}
	printf("%lld",ans);
}

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

int N, A, B, C;
int l[8];

int dfs(int cur, int a, int b, int c)
{
    if(cur == N){
        if(min({a,b,c}) > 0){
            return abs(a-A) + abs(b-B) + abs(c-C) - 30;
        }else{
            return 1e9+7;
        }
    }
    int ret0 = dfs(cur+1, a, b, c);
    int ret1 = dfs(cur+1, a+l[cur], b, c) + 10;
    int ret2 = dfs(cur+1, a, b+l[cur], c) + 10;
    int ret3 = dfs(cur+1, a, b, c+l[cur]) + 10;
    return min({ret0, ret1, ret2, ret3});
}

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

    cin >> N >> A >> B >> C;

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

    cout << dfs(0,0,0,0) << endl;
    return 0;
}


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

namespace ABC042A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            if ((a == 5) && (b == 5) && (c == 7))
            {
                Console.WriteLine("YES");
            }
            else if ((a == 5) && (b == 7) && (c == 5))
            {
                Console.WriteLine("YES");
            }
            else if ((a == 7) && (b == 5) && (c == 5))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N , M , K , A , ans ;
  cin >> N >> M ;
  vector<int> vec(M) ;
  for(int i=0 ; i<N ; i++){
    cin >> K ;
    for(int j=0 ; j<K ; j++){
      cin >> A ;
      vec.at(A-1)++;
    }
  }
  for(int k=0 ; k<M ; k++){
    if(vec.at(k)==N)
      ans++;
  }
  cout << ans << endl;
}

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

int main() {
  string n;
  cin >> n;
  ll ans = 0;
  for (auto c : n) ans+= (c - '0');
  cout << (ans % 9 == 0 ? "Yes" : "No") << endl; 
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


 
signed main() {
    string S;
    int w;
    cin >> S >> w;
    
    rep(i, (S.length()+w-1)/w){
        cout << S[i*w];
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

ll A[MAXN];
ll B[MAXN];
ll ans[MAXN];

void solve(int n,int k)
{
    if(n==1){
        for(int i=1;i<=k;i++)
            ans[i] = 1;
        return;
    }

    solve((n>>1),k);

    for(int i=1;i<=k;i++){
        A[i] = ans[i];
    }

    for(int i=1;i<=k;i++){
        for(int j=(i<<1);j<=k;j+=i){
            A[i]+=A[j];
            if(A[i]>=MOD)A[i]-=MOD;
        }
        B[i] = A[i];
    }

    for(int i=1;i<=k;i++){
        ans[i] = (A[i]*B[i])%MOD;
    }

    for(int i=k;i>=1;i--){
        for(int j=(i<<1);j<=k;j+=i){
            ans[i]+=(MOD-ans[j]);
            if(ans[i]>=MOD)ans[i]-=MOD;
        }
    }

    if(n&1){
        for(int i=1;i<=k;i++){
            A[i] = ans[i];
            B[i] = k/i;
        }

        for(int i=1;i<=k;i++){
            for(int j=(i<<1);j<=k;j+=i){
                A[i]+=A[j];
                if(A[i]>=MOD)A[i]-=MOD;
            }
        }

         for(int i=1;i<=k;i++){
            ans[i] = (A[i]*B[i])%MOD;
        }

        for(int i=k;i>=1;i--){
            for(int j=(i<<1);j<=k;j+=i){
                ans[i]+=(MOD-ans[j]);
                if(ans[i]>=MOD)ans[i]-=MOD;
            }
        }
    }

    return;
}

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>k;

    solve(n,k);

    ll res = 0;

    for(int i=1;i<=k;i++){
        res+=(ll)i*ans[i];
    }

    res%=MOD;

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 5944
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n= int(input(''))

plist = prime_factorize(n)

import collections
c = collections.Counter(plist)

#print(c)
cnt=0
for k,v in c.items():
    cnt2=0
    idx=0
    while True:
        idx+=1
        cnt2+=idx
        if cnt2 > v:
            break
        else:
            cnt+=1
#        print("{}:{}  {} <= {}".format(k,v,cnt,cnt2))        

print(cnt)

Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int dx = x2-x1, dy = y2-y1;

  int x3 = x2 - dy;
  int y3 = y2 + dx;
  int x4 = x3 - dx;
  int y4 = y3 - dy;

  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  
  return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    ws = list(map(int, input().split()))

    score = float('inf')
    for i in range(n):
        if i == 0:
            continue
        # print(ws[:i])
        current = abs(sum(ws[:i]) - sum(ws[i:]))
        if current < score:
            score = current

    print(score)


main()

Measured memory_bytes: 2940
N = int(input())
A = list(map(int, input().split()))

a = A[0]
# equal: 0, inc: 1, dec: -1
state = 0
ans = 1
for i in range(1, N):
    if state == 0:
        if a < A[i]:
            state = 1
        elif a > A[i]:
            state = -1
    elif state == 1:
        if a > A[i]:
            ans += 1
            state = 0
    else:
        if a < A[i]:
            ans += 1
            state = 0
    a = A[i]

print(ans)


Measured memory_bytes: 62704
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <cctype>
//小文字を大文字 c-0x20;


#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define vvll(z,a,b) vector<vector<ll>>z(a,vector<ll>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
using namespace std;


int main(){
  vi abc(27);
  while(1){
 string s;
 getline(cin,s);
 if(s=="\0")break;
 size_t su=s.length();
 rep(i,su){
   if(s[i]>='A'&&s[i]<='Z')s[i]+=0x20;
   for( int j=0;j<26;j++){
     char hu='a'+j;
      if(hu==s[i])abc.at(j)+=1;
    
   }
 }
  }
 for(int j=0;j<26;j++){
   char hu='a'+j;
   cout<<hu<<" "<<":"<<" "<<abc.at(j)<<endl;
 }

}


Measured memory_bytes: 3160
// at_abc152c.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n;cin >> n;
    int ans = 0;
    int mincur = 1e9;
    for (int i = 0;i < n;i++) {
        int temp;cin >> temp;
        mincur = min(mincur, temp);
        if (mincur >= temp) {
            ans++;
        }
    }
    cout << ans << "\n";
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  string s;
  cin>>s;
  int ans=1;
  if(s=="SUN") ans=7;
    if(s=="MON") ans=6;
    if(s=="TUE") ans=5;
    if(s=="WED") ans=4;
    if(s=="THU") ans=3;
    if(s=="FRI") ans=2;
  cout<<ans<<endl;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <string.h>
int main (void)
{
    int k;
    char s[100];
    int len;
    int i;
    
    scanf("%d", &k);
    scanf("%s",&s);

    len = strlen(s);
    
    if(k >= len){
        printf("%s",s);
    }else{
        for(i=0;i<k;i++)
            printf("%c",s[i]);
        printf("...");
    }

    return 0;
}

Measured memory_bytes: 1692
n,k=map(int,input().split())
p=list(map(int,input().split()))
a=[0]+p
flag=0
bef=1
town=[1]
town_set=set(town)
cnt=0
while flag==0 and cnt<k:
    if not a[bef] in town_set:
        town.append(a[bef])
        town_set.add(a[bef])
        bef=a[bef]
    else:
        flag=1
        memo=a[bef]
        break
    cnt+=1
if cnt==k:
    print(bef)
    exit()
for j in range(len(town)):
    if town[j]==memo:
        num=j
        break
x=len(town)-num
y=(k-num)%x
print(town[num+y])


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

using namespace std;

#define P pair < int,int >

int main(){
	
	int N,W;
	
	cin>>N>>W;
	
	vector <P> w_v(N);
	
	int sum = 0;
	
	for(int i=0; i<N; i+=1){
		
		cin>>w_v[i].second>>w_v[i].first;
		
		sum += w_v[i].first;
	}
	
	sort(w_v.rbegin(),w_v.rend());
	
	int dp[sum+1];
	
	for(int i=0; i<=sum; i+=1){
		
		dp[i] = W+1;
	}
	
	dp[0] = 0;
	
	for(int i=N-1; i>=0; i-=1){
		
		for(int j=sum; j>=w_v[i].first; j-=1){
			
			dp[j] = min(dp[j] , w_v[i].second+dp[j-w_v[i].first]);
		}
	}
	
	for(int i=sum; i>=0; i-=1){
		
		if(dp[i]<=W){
			
			cout<<i;
			
			break;
		}
	}
}

Measured memory_bytes: 640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x1 = sc.nextInt();
    int y1 = sc.nextInt();
    int x2 = sc.nextInt();
    int y2 = sc.nextInt();
    System.out.print(y1-y2+x2);
    System.out.print(" ");
    System.out.print(x2-x1+y2);
    System.out.print(" ");
    System.out.print(y1-y2+x1);
    System.out.print(" ");
    System.out.print(x2-x1+y1);
  }
  

  
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    vector<ll> abc(3);
    rep(i, 3)cin >> abc[i];
    sort(all(abc));
    if(abc[2]%2 == 1) {
        ll r = abc[0] * abc[1] * (abc[2] / 2 + 1);
        ll b = abc[0] * abc[1] * (abc[2] / 2);
        cout << r - b << endl;
    }
    else {
        cout << 0 << endl;
    }

    return 0;
}

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

using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/

#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second

#define what_is(x)     cerr << #x << " is " << x << endl;

///*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)
{
    cout << endl ;
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
int ini()
{
    int x;
    scanf("%d",&x);
    return x;
}
long long inl()
{
    long long x;
    scanf("%lld",&x);
    return x;
}

const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);

int main()
{
    int n,k;
    n=ini();
    k=ini();
    
    if(n==1){
        if(k==0){
            cout<<0<<" "<<0<<" "<<1<<" "<<1<<endl;
        }
        else{
            cout<<"-1"<<endl;
        }
    }
    else{
        int m=1<<n;
        if(k<m){
            for(int i=0;i<m;i++){
                if(i!=k)cout<<i<<" ";
            }
            cout<<k<<" ";
            for(int i=m-1;i>=0;i--){
                if(i!=k)cout<<i<<" ";
            }
            cout<<k<<endl;
        }
        else{
            cout<<"-1"<<endl;
        }
    }


    return 0;
}


Measured memory_bytes: 1792
END { load __FILE__ unless $stdin.eof? }

n, k = gets.split.map!(&:to_i)
a    = gets.split.map!(&:to_i)

a1 = a[0, n - k]
a2 = a[-n + k, n - k]

a1.zip(a2) { |x, y| puts (x < y) ? :Yes : :No }


Measured memory_bytes: 27888
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdio.h>
#define X first
#define Y second

#define _ << " " <<
#define debug(x) #x << " = " << x

#define ll long long
#define ull unsigned long long

using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

int main()
{
    std::ios::sync_with_stdio(false);

    int n;
    std::cin >> n;

    int a[n], b[n], c[n];

    for (int i = 0; i < n; i++) std::cin >> a[i];
    for (int i = 0; i < n; i++) std::cin >> b[i];
    for (int i = 0; i < n; i++) std::cin >> c[i];

    std::sort(a, a + n);
    std::sort(b, b + n);
    std::sort(c, c + n);

    int l = -1;
    int r = 0;

    ll ans = 0;

    /*
    for (int i = 0; i < n; i++)
        std::cout << a[i] << " ";
    std::cout << std::endl;
    for (int i = 0; i < n; i++)
        std::cout << b[i] << " ";
    std::cout << std::endl;
    for (int i = 0; i < n; i++)
        std::cout << c[i] << " ";
    std::cout << std::endl;
    */


    for (int i = 0; i < n; i++)
    {
        while(l + 1 < n && a[l + 1] < b[i]) l++;
        if (a[l] >= b[i]) l++;

        while(r < n && b[i] >= c[r]) r++;
        //std::cout << debug(i) _ debug(l) _ debug(r) << std::endl;

        if (l >= 0 && r <= n - 1)
            ans += 1ll * (l + 1) * (n - r);
    }
    std::cout << ans << std::endl;


    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define pb emplace_back
#define ll long long
#define mp make_pair
#define PI acos(-1)
using namespace std;
ll dp[200005],a[200005],n;
ll solve(ll idx,ll k)
{
    if(idx>=n-1)
        return 0;
    if(dp[idx]!=-1)
        return dp[idx];
    ll res=INT_MAX;
    for(ll i=1; i<=k; i++)
    {
        if(idx+i<n)
            res=min(res,abs(a[idx+i]-a[idx])+solve(idx+i,k));
    }
    return dp[idx]=res;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i,j,k,x,y,z,m,t,l,r;
    cin>>n>>k;
    for(i=0; i<n; i++)
        cin>>a[i];
    memset(dp,-1,sizeof dp);
    cout<<solve(0,k)<<'\n';
}









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

using namespace std;

int main()
{
  int a,b,c,d;
  int left, right;
  
  cin >> a >> b >> c >> d;
 
  left = a + b;
  right = c + d;
  
  if(left > right){
    cout << "Left" << endl;
  }
  else if(left < right){
    cout << "Right" << endl; 
  }
  else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
import math 
n = int(input())
x = []
y = []
ans = 0
for i in range(n):
    i, j = input().split()
    x.append(int(i))
    y.append(int(j))
for i in range(n):
   for j in range(n):
      t = abs((x[i] - x[j])*(x[i] - x[j])+(y[i] - y[j])*(y[i] - y[j]))
      ans += math.sqrt(t)
print(ans/n)                         

Measured memory_bytes: 3064
N, M = map(int, input().split())

H = list(map(int, input().split()))
d = {}

for i in range(N):
    d[i+1] = []
for i in range(M):
    a, b = map(int, input().split())
    d[a].append(b)
    d[b].append(a)
ans = 0
for k, v in d.items():
    flag = False
    if len(v) == 0:
        ans += 1
        continue
    for y in v:
        if H[k-1] <= H[y-1]:
            flag = True
    if flag == False:
        ans += 1

print(ans)

Measured memory_bytes: 94828
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  int N;
  cin>>N;
  
  vector<int> A(N);
  vector<int> b(N+1);
  for(int i=1;i<N;++i){
    cin>>A[i];
    ++b[A[i]];
  }
  
  
  for(int i=1;i<=N;++i){
    cout<<b[i]<<endl;
  }
  
  
}


Measured memory_bytes: 4792
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

MAX = 0
for i in range(N-K+1):
    if i == 0:
        SUM = 0
        for j in range(K):
            SUM += (A[i+j]+1)/2

    else:
        SUM += (A[i+K-1]+1)/2
        SUM -= (A[i-1]+1)/2
    
    if MAX < SUM:
        MAX = SUM

print(MAX)

Measured memory_bytes: 25188
N=int(input())
A=list(map(int,input().split()))
import statistics
B=[0]*N
answer=0
for i in range(N):
	B[i]=A[i]-(i+1)
med=int(statistics.median(B))

for i in range(N):
	answer+=(abs(B[i]-med))
print(answer)

Measured memory_bytes: 26836
package main
import . "fmt"
import "bytes"
func main() {
  var o,e string
  var no,ne int
  Scan(&o)
  Scan(&e)
  var buf bytes.Buffer
  no = len(o)
  ne = len(e)
  for i:=0;i<ne;i++ {
    buf.WriteString(o[i:i+1])
    buf.WriteString(e[i:i+1])
  }
  if no > ne { buf.WriteString(o[len(o)-1:len(o)]) }
  Println(buf.String())
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,m,n) for(int i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;


int main(){
  ll n,m;
  cin >> n >> m;
  vector<ll>a(m);
  rep(i,m)cin >> a[i];
  ll sum=0;
  rep(i,m)sum+=a[i];
  if(n>=sum)cout << n-sum << endl;
  else cout << -1 << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;

int power(int base, int exp, int p){
    int ret = 1;
    while(exp > 0){
        if(exp % 2 == 0){
            base *= base;
            exp /= 2;
            base %= p;
        }
        else{
            ret *= base;
            exp -=1;
            ret %= p;
        }
    }
    return ret;
}

int inv(int a, int p){
    return power(a, p-2, p);
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, P;
    string S;
    cin >> N >> P;
    cin >> S;
    ll ret = 0;
    if(P != 2 && P != 5){
        unordered_map<int,int> sub;
        int tmp = 0;
        sub[0] = 1;
        for(int i = 0 ; i < N ; ++i){
            int digit = S[i] - '0';
            int cur = ( digit * power(inv(10, P),i, P) ) % P;
            tmp += cur;
            tmp %= P;
            if(sub.count(tmp) > 0){
                ret += sub[tmp];
            }
            sub[tmp] += 1;
        }
    }
    else{
        for(int i = 0 ; i < N ; ++i){
            int digit = S[i] - '0';
            if(digit % P == 0){
                ret += (i+1);
            }
        }
    }

    cout << ret << endl;


    return 0;
}

Measured memory_bytes: 916
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	int l;
	int j_max, m_max, j_page, m_page;
	int i;
	
	cin >> l >> j_page >> m_page >> j_max >> m_max;

	
	for(i = 0; ; i++){
		j_page -= j_max;
		m_page -= m_max;
		
	//	cout << j_page << " " << m_page << endl;
		
		if(j_page <= 0 && m_page <= 0){
			i++;
			break;
		}
	}
	cout << l-i << endl;
	
	return 0;
}

	
	

Measured memory_bytes: 1160
/* it was worth becoming a chemist */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const int inf = 1e9;
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

int n, k;
int lvl[MAXN];
map<pair<int, int>, bool> was;

int main() {
	//freopen(NAME".in", "r", stdin);
	//freopen(NAME".out", "w", stdout);

	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		lvl[n - i + 1] = i;
	}
	int tt = n - 1;
	while (tt--) {
		int ct = 0;
		was.clear();
		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				if (abs(lvl[i] - lvl[j]) == 2 || lvl[i] == lvl[j]) ct++;
			}
		}
		if (ct > k) {
			for (int i = 1; i <= n; i++) {
				for (int j = i + 1; j <= n; j++) {
					if (ct == k) break;
					if (lvl[i] == lvl[j]) {
						ct--;
						was[mp(i, j)] = 1;
						was[mp(j, i)] = 1;
					}
				}
			}
		}

		if (ct == k) {
			for (int i = 1; i <= n; i++) {
				for (int j = i + 1; j <= n; j++) {
					if (lvl[i] + 1 == lvl[j] || lvl[i] == lvl[j] + 1) {
						was[mp(i, j)] = 1;
						was[mp(j, i)] = 1;
					}					
				}
			}	
		    vector<pair<int, int>> v;
			for (int i = 1; i <= n; i++) {
				for (int j = i + 1; j <= n; j++) {
					if (was[mp(i, j)] || was[mp(j, i)]) {
						v.pb(mp(i, j));
						was[mp(i, j)] = was[mp(j, i)] = 0;
					}					
				}
			}
			cout << sz(v) << '\n';
			for (auto i : v) {
				cout << i.F << ' ' << i.S << '\n';
			}
			return 0;			
		}
		int mx = 0;
		for (int i = 1; i <= n; i++) {
			mx = max(mx, lvl[i]);
		}
		for (int i = 1; i <= n; i++) {
			if (lvl[i] == mx) lvl[i]--;
		}
	}
	cout << -1;
	return 0;	
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main(){
  int n, k, d=1, ans=0;
  cin >> n >> k;
  while(n>=d){
    d*=k; 
    ans++;
  }
  cout << ans << endl;
  return 0;
}

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

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

	ld a, b, c;
	cin >> a >> b >> c;

	if (a + b + sqrt(a*b) + sqrt(a*b) < c) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 256
#include<stdio.h>
int max(int a,int b){return a>b?a:b;}
int main(){
	int n,m;
	int i,j;
	scanf("%d %d",&n,&m);
	int ans=0;
	for(i=0;i<n;i++){
		int res=0;
		for(j=0;j<m;j++){
			int x;
			scanf("%d",&x);
			if(x==1)res++;
		}
		ans=max(ans,res);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1028