akhauriyash/Code-Regression huggingface dataset:
x, y = map(int, input().split())

if ((y - 2 * x)/2) >= 0 and int((y - 2 * x)/2) == ((y - 2 * x)/2) and (4 * x - y)/2 >= 0 and int((4 * x - y)/2) == (4 * x - y)/2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9184
def caesarshift(sentence):
    abc = "abcdefghijklmnopqrstuvwxyz"
    bcd = abc[1:] + "a"
    return sentence.translate(str.maketrans(abc, bcd))

while True:
    try:
        sentence = input()
    except EOFError:
        break
    while True:
        if "the" in sentence or "this" in sentence or "that" in sentence:
            break
        sentence = caesarshift(sentence)
    print(sentence)

Measured memory_bytes: 7404
n = int(input())
a = list(map(int, input().split()))

ns = [0] * (n + 1)
for i in a:
    ns[i] += 1
ans = 0
for i in ns:
    if i > 1:
        ans += i * (i - 1) // 2
for i in a:
    print(min(ans - (ns[i] - 1), ans))


Measured memory_bytes: 100288
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(long i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n,m;
    cin >> n >> m;
    set<long long> st;
    map<long long ,long long> mp;
    long long a;
    rep(i,n){
        cin >> a;
        auto itr = mp.find(a);
        if(itr != mp.end()){
            mp[a]++;
        }
        else{
            mp[a] = 1;
        }
        st.insert(a);
    }
    long long b,c;
    rep(i,m){
        cin >> b >> c;
        auto itr = mp.find(c);
        if(itr != mp.end()){
            mp[c]+=b;
        }
        else{
            mp[c] = b;
        }
        st.insert(c);
    }
    long long ans = 0;
    for(auto itr = st.end();true;itr--){
        if(itr == st.end()){
            itr--;
        }
        if(mp[*itr] > n){
            ans+=*itr*n;
            break;
        }
        else{
            ans+=*itr*mp[*itr];
            n-=mp[*itr];
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){

  int n;
  cin >> n;
  vector<Pl> v(n);
  REP(i,n){
    int a,b;cin >> a >> b;
    v[i] = make_pair(a+b,b);
  }
  sort(ALL(v));
  ll k;
  k = v[0].first;
  ll res = 1;
  for(ll i = 1;i < n;i++){
    if(k > v[i].first-v[i].second*2)continue;
    k = v[i].first;
    res++;
  }
  cout << res << endl;

  


  

  return 0;
}


Measured memory_bytes: 1792
using System.Linq;
using System.Collections.Generic;
using System;

public class P
{
    public int r { get; set; }
    public int b { get; set; }
}

public class Hello
{
    const int MOD = 998244353;
    const int FMAX = 510000;

    public static void Main()
    {
        var fac = new long[FMAX];
        var finv = new long[FMAX];
        var inv = new long[FMAX];
        COMinit(fac, finv, inv);
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var a = long.Parse(line[1]);
        var b = long.Parse(line[2]);
        var k = long.Parse(line[3]);
        var ps = new List<P>();
        var rmax = k / a;
        var bmax = k / b;
        for (long i = 1; i <= rmax; i++)
        {
            var w = k - a * i;
            if (w % b == 0 && w / b >= 1 && w / b <= bmax)
                ps.Add(new P { r = (int)i, b = (int)(w / b) });
        }
        if (ps.Count() == 0) { Console.WriteLine(1); goto end; }
        var ret = 0L;
        foreach (var x in ps)
        {
            var w1 = (COM(fac, finv, inv, n, x.r) * COM(fac, finv, inv, n, x.b)) % MOD;
            ret += w1;
            ret %= MOD;
        }
        Console.WriteLine(ret);
        end:;
    }
    public static long COM(long[] fac, long[] finv, long[] inv, int n, int k)
    {
        if (n < k) return 0;
        if (n < 0 | k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
    public static void COMinit(long[] fac, long[] finv, long[] inv)
    {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < FMAX; i++)
        {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
}


Measured memory_bytes: 51496
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main(){
	string n,right,left;     //n=n枚のカード
	int num;      //num=シャッフル回数
	int num2 = 0; //num2=シャッフル枚数

	while (1){
		cin >> n;
		cin >> num;
		if (n == "-")break;
		for (int i = 0; i < num; i++){
			cin >> num2;
			left = n.substr(0, num2);
			right = n.substr(num2, n.size());
			n = right + left;
		}
		cout << n << endl;
	}
	return 0;
}



Measured memory_bytes: 3180
module M = Map.Make (struct type t = int let compare = compare end) ;;

Scanf.scanf "%d %d" (fun n w ->
    let vw = Array.init n (fun _ -> Scanf.scanf " %d %d" (fun w v -> w, v)) in
    let map = Array.fold_left (fun map (w0, v0) ->
        M.fold (fun ww vv newmap ->
            let key = ww + w0 in
            if key <= w then (
                try
                    let v1 = M.find key newmap in
                    if v1 < vv + v0 then M.add key (vv + v0) newmap else newmap
                with _ ->
                    M.add key (vv + v0) newmap
            ) else newmap
        ) map map
    ) (M.add 0 0 M.empty) vw
    in
    M.fold (fun _ vv acc -> max vv acc) map 0 |> Printf.printf "%d\n"
)

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

int main() {
    int N; cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; ++i) cin >> H[i];
    
    int res = 0;
    int current_max = 0;
    for (int i = 0; i < N; ++i) {
        // i 番目が、i-1 番目以前の最大値以上だったらカウント
        if (H[i] >= current_max) ++res;

        // これまでの最大値を新たに更新する
        if (current_max < H[i]) current_max = H[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = 998244353ll;

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll fc[3003003]={1ll},nv[3003003]={1ll};

ll rwpw(ll a, ll p){
	ll ret = 1ll;
	while(p){
		if(p&1){
			mul_mod(ret,a);
		}
		mul_mod(a,a);
		p >>= 1;
	}
	return ret;
}

ll c(int n, int k){
	ll ret;
	if(n<k){
		return 0ll;
	}
	ret = fc[n];
	mul_mod(ret,nv[k]);
	mul_mod(ret,nv[n-k]);
	return ret;
}

int main(void){
	int n,m,i,j,k,p;
	ll ans,tmp;
	for(i=1; i<3003003; ++i){
		fc[i] = fc[i-1];
		mul_mod(fc[i],i);
		nv[i] = rwpw(fc[i],MOD-2);
	}
	cin >> n >> m;
	for(i=0; i<=m; ++i){
		if((m*3-i)%2){
			continue;
		}
		p = (m*3-i)/2;
		tmp = c(n,i);
		mul_mod(tmp,c(p+n-1,n-1));
		add_mod(ans,tmp);
		// 1個がm*2+1以上
		if(i){
			p = (m-i)/2;
			tmp = c(p+n-1,n-1);
			mul_mod(tmp,c(n,i));
			mul_mod(tmp,c(i,1));
			add_mod(ans,MOD-tmp);
		}
		// 1個がm*2+2以上
		if(i<m){
			p = (m-i-2)/2;
			tmp = c(p+n-1,n-1);
			mul_mod(tmp,c(n,i));
			mul_mod(tmp,c(n-i,1));
			add_mod(ans,MOD-tmp);
		}
	}
	cout << ans << endl;
	return 0;
}


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

int N;
int A[101];

int main(){
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	long long dif = 1e9;

	for(int i = -100; i <= 100; i++){
		long long sm = 0;
		for(int j = 0; j < N; j++){
			sm += (A[j]-i)*(A[j]-i);
		}
		if(sm < dif){
			dif = sm;
		}
	}
	cout << dif << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n;

	scanf("%d", &n);
	printf(n % 4 == 0 || (n >= 7 && (n - 7) % 4 == 0) || (n >= 14 && (n - 14) % 4 == 0) || (n >= 21 && (n - 21) % 4 == 0) ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 128
import Data.List (unfoldr, nub)
import Control.Arrow ((&&&))

main:: IO ()
main = do
    s <- getLine
    print $ solve s

-- |
--
-- >>> solve "sevral"
-- 3
--
-- >>> solve "jackal"
-- 2
--
-- >>> solve "zzz"
-- 0
--
-- >>> solve "whbrjpjyhsrywlqjxdbrbaomnw"
-- 8
solve :: String -> Int
solve s = minimum [length $ unfoldr (next k) s | k <- ks]
  where ks = nub s

next :: Char -> String -> Maybe (String, String)
next k s
  | all (== k) s  = Nothing
  | otherwise     = Just (s, s')
  where s' = zipWith (union k) s (tail s)

union :: Char -> Char -> Char -> Char
union k c1 c2
  | c1 == k || c2 == k  = k
  | otherwise           = c1


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define se second
#define fi first
#define pb push_back
const int N =2e5 +5;
int freq[26];

int main(){

//	freopen("in.txt","r",stdin);

	string s;
	cin >>s;
	ll ans = (s.size() * 1LL* (s.size() -1))/2;
	for (int i=0;s[i] ; i++){
		ans -= freq[s[i] - 'a'];
		freq[s[i]-'a']++;
	}
	cout <<ans +1 <<endl;


}


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

int main(){
    int N; cin >> N;
    int A[N];
    for(int i=0;i<N;i++) cin >> A[i];
    sort(A,A+N);
    int max_m=0;
    for(int i=1;i<N;i++){
        A[i]=A[i]%A[0];
        max_m=max(max_m,A[i]);
    }
    while(true){
        if(A[0]>=max_m){
            A[0]-=max_m;
        }else{
            max_m-=A[0];
        }
        if(max_m<=0||A[0]<=0) break;
    }
    if(max_m<=0) cout << A[0] << endl;
    else cout << max_m << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
using namespace std;

int main(){
    string s;cin>>s;
    int K;cin>>K;
    int N=s.size();
    pair<char,int>p[5010];
    for(int i=0;i<N;i++){
        p[i].first=s[i];
        p[i].second=i;
    }
    sort(p,p+N);

    map<string,int>mp;
    int sum=0;
    for(int i=0;i<N;i++){
        string sub={p[i].first};
        mp[sub]++;
        sum++;
        int k=p[i].second+1;
        int length=1;
        while(k<=N-1 && length<K){
            sub=sub+s[k];
            mp[sub]++;
            sum++;
            k++;
            length++;
        }
        if(p[i].first!=p[i+1].first && sum>=K){
            int l=0;
            for(auto itr=mp.begin();itr!=mp.end();itr++){
                l++;
                if(l==K){
                    cout<<itr->first<<endl;
                    goto lol;
                }
            }
            
        }
    }
    lol:return 0;
}

Measured memory_bytes: 384
N = input()
K = int(input())

k = len(N)
ans = 0

if k < K:
    print(0)
    exit()


def solve(N,K):
    if len(N) < K:
        return 0
    if N[0] == '0':
        return solve(N[1:],K)
    if K == 1:
        return (len(N)-1)*9+int(N[0])
    res = 0
    if K == 2:
        res += (9**2)*(len(N)-1)*(len(N)-2)//2
        res += 9*(len(N)-1)*(int(N[0])-1)
        res += solve(N[1:],K-1)
    if K == 3:
        res += (9**3)*(len(N)-1)*(len(N)-2)*(len(N)-3)//6
        res += (9**2)*(len(N)-1)*(len(N)-2)//2*(int(N[0])-1)
        res += solve(N[1:],K-1)
    return res


print(solve(N,K))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (250010)
#define P ()
#define M ()
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c){
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
int p[N],cnt,n;
LL a[511][511]; bool isp[N*40];
int eular(int n){
	for(int i=2;i<=n;i++){
		if(!isp[i]){
			p[++cnt]=i;
			if(cnt==125000)return i;
		}
		for(int j=1;j<=cnt;j++){
			int t=p[j]*i; if(t>n)break;
			isp[t]=1; if(i%p[j]==0)break;
		}
	}
}
LL gcd(LL a,LL b){
	return b?gcd(b,a%b):a;
}
LL lcm(LL x,LL y){
	if(x==0||y==0)return x+y;
	return x/gcd(x,y)*y;
}
int main(){
	eular(2000000); read(n);
	if(n==2){
		puts("2 3\n5 16\n");
		return 0;
	}
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	if(((i+j)&1)==0)a[i][j]=1ll*p[(i+j)/2]*p[n+(i-j)/2+(n+1)/2];
//	puts("12345"); 
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	if(!a[i][j])a[i][j]=lcm(lcm(a[i][j+1],a[i+1][j]),lcm(a[i][j-1],a[i-1][j]))+1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)
		print(a[i][j]),spa; ent;
	}
	return flush(),0;
}

Measured memory_bytes: 13312
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
	int n,k,c;
    string s;
    cin>>n>>k>>c>>s;
    vector<int>L;
    vector<int>R;
    int x=1;
    REP(i,n){
        if(s[i]=='o'){
            L.push_back(i);
            i+=c;
            if(x++>=k)break;
        }
    }
    x=1;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='o'){
            R.push_back(i);
            i-=c;
            if(x++>=k)break;
        }
    }
    for(int i=0;i<min(SZ(L),SZ(R));i++){
        if(L[i]==R[k-i-1])OUT(L[i]+1);
    }
	return 0;
}

Measured memory_bytes: 3448
#include<bits/stdc++.h>
using namespace std;
long long a[99],n;
int main()
{
    cin>>n;
    a[0]=2;
    for(int i=1;i<=n;i++)
      a[i]=a[i-1]*2+2;
    cout<<a[n]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int x[101];
int main(){
    int n,k,sum=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>x[i];
    }
    for(int i=1;i<=n;i++){
        if(x[i]<=k/2) sum+=x[i]*2;
        else sum+=(k-x[i])*2;
    }
    cout<<sum<<endl;
    return 0;
}

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

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

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

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    unordered_map<ll, ll> mp;
    for (ll i = 0; i < N; i++) {
        ll a;
        cin >> a;
        ++mp[a];
    }

    ll ans = 0;
    Vl fs;
    for (auto [x, num] : mp) {
        fs.clear();
        for (ll i = 1; i * i <= x; i++) {
            if (x % i == 0) {
                fs.emplace_back(i);
                if (i * i != x) fs.emplace_back(x / i);
            }
        }
        bool ok = true;
        for (const auto& f : fs) {
            if (f == x && num == 1) continue;
            if (mp.find(f) != mp.end()) {
                ok = false;
                break;
            }
        }

        if (ok) ++ans;
    }

    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 11424
from fractions import gcd
from functools import reduce
inpl = lambda: list(map(int,input().split()))
def lcm(a,b):
    return a*b//gcd(a,b)
def lcm_list(numbers):
    return reduce(lcm, numbers)

N = int(input())
rate = []
rate.append(inpl())
rate.append(inpl())
AB = []
BA = []
for i in range(3):
    rA, rB = rate[0][i], rate[1][i]
    if rB > rA:
        AB.append((rA, rB))
    elif rA > rB:
        BA.append((rB, rA))
for l in [AB, BA]:
    l.sort(key=lambda x: -x[1]/x[0])

def buy_and_sell(N, cost_ret):
    if len(cost_ret) == 0:
        return N
    else:
        Nunit = lcm_list([ x[0] for x in cost_ret ])
        b0, s0 = cost_ret[0]
        q = N // b0
        n = max(0, q - (len(cost_ret)-1)*Nunit//b0)
        Ndp = N - n*b0
        dp = [0]*(Ndp+1)
        w = [0]*(len(cost_ret)+1)
        for i in range(1,Ndp+1):
            k = 1
            for cost, ret in cost_ret:
                if i >= cost:
                    w[k] = dp[i-cost] + ret
                    k += 1
            dp[i] = max(dp[i-1]+1, max(w))
        return s0*n + dp[-1]

M = buy_and_sell(N, AB)
L = buy_and_sell(M, BA)
print(L)

Measured memory_bytes: 84568
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n'
#define no cout<<"No"<<'\n'
using namespace std;

int main()
{
    godspeed
    ll  i,j,k,l,n,ans=0;
    string s;
    cin>>n;
    ll a[n+1];
    a[0]=2;
    a[1]=1;
    for(i=2;i<n+1;i++)
    {
        a[i]=a[i-2]+a[i-1];
     //   cout<<a[i]<<endl;
    }

    cout<<a[n]<<endl;
    return 0;
}





Measured memory_bytes: 3520
/*_firefox_*/


#include <bits/stdc++.h>
#include<list>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include <cstdlib>
#include<sstream>
#include<map>
#define ll long long
#include <cstdio>
#include <algorithm>
#include <deque>
#define mp make_pair
const int N=3e5+7;
using namespace std;
#define fastio ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main()
{

    string s;
    cin>>s;
    //int w=s.length();
    if(s[0]==s[1])
        cout<<"Bad";
    else if(s[1]==s[2])
        cout<<"Bad";
    else if(s[2]==s[3])
        cout<<"Bad";
    else
        cout<<"Good";
    return 0;
}


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

using namespace std;
const int MAXN = 1e5 + 10;
int a[MAXN];

int main() {
    int n, m, sum = 0;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    for (int i = 0; i < m; i++) {
        sum = sum + a[i];
    }
    cout << sum << endl;
}

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

using ll = long long;
using ld = long double;

const int N = 1e5 + 10;

vector<int> adj[N];
int dis[N], par[N];
bool vis[N];
int n;

int dfs(int v, int par) {
  int ret = 1;
  for(auto i : adj[v]) {
    if(i == par) continue;
    ret += dfs(i, v);
  }
  return ret;
}

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

  cin >> n;
  for(int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  queue<int> Q;
  Q.push(1);
  dis[1] = 0;
  vis[1] = true;
  bool ok = false;
  while(!Q.empty()) {
    int cur = Q.front();
    Q.pop();
    for(auto i : adj[cur]) {
      if(vis[i]) continue;
      vis[i] = true;
      par[i] = cur;
      dis[i] = dis[cur] + 1;
      if(i == n) {
        ok = true;
        break;
      }
      Q.push(i);
    }
    if(ok) break;
  }
  int lol = dis[n];
  int now = n;
  while(dis[now] != (lol / 2 + 1)) {
    now = par[now];
  }
  int cnt = dfs(now, par[now]);
  bool yes = ((cnt == n / 2 && (n % 2 == 0)) || cnt > n / 2);
  cout << (yes ? "Snuke" : "Fennec") << '\n';
  return 0;
}

Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

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

    for(lint a=1; a<=3500; a++)
    for(lint b=1; b<=3500; b++) {
        lint deno = 4 * a * b - n * b - n * a;
        if(deno <= 0)  continue;
        if(n * a * b % deno)  continue;
        cout << a  << " " << b <<  " " << n * a * b / deno << endl;
        return 0;
    }
}

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

typedef long long ll;
const ll mod = 1e9 + 7;

int main() {
	ll n, m;
	cin >> n >> m;
	vector<ll> x(n), y(m);
	for (auto&&xn:x) cin >> xn;
	for (auto&&ym:y) cin >> ym;
	sort(x.begin(), x.end()); sort(y.begin(), y.end());
	
	ll a = 0, b = 0;
	for (ll i = 0; i < n; i++) a -= x[i] * (n - 1 - i - i);
	for (ll i = 0; i < m; i++) b -= y[i] * (m - 1 - i - i);
	cout << (a % mod) * (b % mod) % mod << endl;
	
	return 0;
}


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

int index(int numToFind, std::vector<int> vectorToFindIn) {int len = vectorToFindIn.size();for (int i = 0; i < len; i++){if (vectorToFindIn[i] == numToFind){return i;}}return -1;}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int a,b;
	cin>>a>>b;
	cout<<max({a+b,a-b,a*b});
	return 0;
}

Measured memory_bytes: 256
// ABC073_C
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N;
    cin >> N;
    vector<ll> vec(N), count(N);
    REP(i, N) cin >> vec[i];
    sort(vec.begin(), vec.end());
    
    map<ll, ll> mp;
    REP(i, N) {
        auto iter = mp.find(vec[i]);
        if (iter != mp.end()) {
            mp[vec[i]]++;
        } else {
            mp[vec[i]] = 1;
        }
    }
    
    auto begin = mp.begin(), end = mp.end();
    ll res = 0;
    for (auto itr = begin; itr != end; itr++) {
        if (itr->second%2 != 0) res++;
    }
    
    cout << res << "\n";
    
    return 0;
}


Measured memory_bytes: 8064
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<iostream>
using namespace std;

inline int read()
{
	int x=0; bool f=1; char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=0;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(c^'0');
	if(f) return x;
	return -x;
}

const int N = 1e5;
const int lgM = 30;
int p[N+3],q[N+3],pp[N+3],qq[N+3];
int g[N+3],f[N+3],ff[N+3];
int tmp[N+3];
int aux[N+3];
int ans[N+3];
int a[7][N+3];
int n,m;

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1; i<=n; i++) scanf("%d",&p[i]),pp[p[i]] = i;
	for(int i=1; i<=n; i++) scanf("%d",&q[i]),qq[q[i]] = i;
	for(int i=1; i<=n; i++) a[1][i] = p[i],a[2][i] = q[i];
	for(int k=3; k<=6; k++)
	{
		for(int i=1; i<=n; i++) a[k][a[k-2][i]] = a[k-1][i];
	}
	for(int i=1; i<=n; i++) g[i] = q[pp[qq[p[i]]]],f[i] = i,tmp[i] = g[i];
	int nn = m%6==0?6:m%6; m = (m-1)/6;
	for(int i=0; m; i++)
	{
		if(m&(1<<i))
		{
			m-=(1<<i);
			for(int j=1; j<=n; j++) aux[j] = f[tmp[j]];
			for(int j=1; j<=n; j++) f[j] = aux[j];
		}
		for(int j=1; j<=n; j++) aux[j] = tmp[tmp[j]];
		for(int j=1; j<=n; j++) tmp[j] = aux[j];
	}
	for(int i=1; i<=n; i++) ff[f[i]] = i;
	for(int i=1; i<=n; i++) ans[i] = f[a[nn][ff[i]]];
	for(int i=1; i<=n; i++) printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    speed();
    int N, M; cin >> N >> M;
    int A[M] = {0};
    rep(i, 0, N) {
        int k; cin >> k;
        rep(j, 0, k) {
            int a; cin >> a;
            --a;
            ++A[a];
        }
    }
    int ans = 0;
    rep(i, 0, M) if (A[i] == N) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
	 int q=n%60;
	 int w=(n/60)%60;
	 int e=(n/3600);
	 printf("%d:%d:%d\n", e, w, q);
	
	}
  return 0;    
}


Measured memory_bytes: 2096
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long LL;
const LL N=100005;
LL x[N],v[N];
LL f[N];//正着走走到第i个的收益
LL g[N];//倒着走走到第i个的收益 
int main()
{
	LL n,c;
	scanf("%lld%lld",&n,&c);
	for (LL u=1;u<=n;u++)	scanf("%lld%lld",&x[u],&v[u]);
	LL now=0,lalal=0;
	LL ans=0;
	for (LL u=1;u<=n;u++)	{lalal=lalal+v[u]-(x[u]-now);now=x[u];f[u]=lalal;ans=max(ans,f[u]);}
	now=c,lalal=0;
	for (LL u=n;u>=1;u--)	{lalal=lalal+v[u]-(now-x[u]);now=x[u];g[u]=lalal;ans=max(ans,g[u]);}
	//printf("%lld\n",ans);
	LL mx=0;
	for (LL u=n-1;u>=1;u--)	
	{
		mx=max(mx,g[u+1]);
		ans=max(ans,mx+f[u]-x[u]);
	}
	mx=0;
	for (LL u=2;u<=n;u++)
	{
		mx=max(mx,f[u-1]);
		ans=max(ans,g[u]+mx-(c-x[u]));
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3328
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int c[] = fs.nextIntArray(n);
		Arrays.sort(c);
		
		int four[] = new int[n];
		four[0]=1;
		for(int i=0;i<n-1;i++) {
			four[i+1] = (int)mul(four[i],4); 
		}
		long ans = 0;
		for(int i=0;i<n;i++) {
			long d = mul(four[n-1],n-i+1);
			long tmp = mul(c[i],d);
			ans = plus(ans, tmp);
		}
		System.out.println(ans);
		
	}
	
	//reverseOrderSort : O(N)
	static void rsort(int[] ar){
		Arrays.sort(ar);
		int len = ar.length;
		for(int i=0;i<len/2;i++) {
			int tmp = ar[i];
			ar[i] = ar[len-1-i];
			ar[len-1-i] = tmp;
		}
	}
	static void rsort(long[] ar){
		Arrays.sort(ar);
		int len = ar.length;
		for(int i=0;i<len/2;i++) {
			long tmp = ar[i];
			ar[i] = ar[len-1-i];
			ar[len-1-i] = tmp;
		}
	}
	
	//MOD culculations
	static long plus(long x, long y) {
		x %= mod;
		y %= mod;
		long res = (x + y) % mod;
		return res;
	}

	static long suv(long x, long y) {
		x %= mod;
		y %= mod;
		long res = (x - y + mod) % mod;
		return res;
	}

	static long mul(long x, long y) {
		x %= mod;
		y %= mod;
		long res = x * y % mod;
		return res;
	}

	static long div(long x, long y) {
		x %= mod;
		y %= mod;
		long res = x * modpow(y, mod - 2) % mod;
		return res;
	}

	//modの元での高速pow()
	static long modpow(long a, long p) {
		if (p == 0)
			return 1;
		if (p % 2 == 0) {
			long halfP = p / 2;
			long root = modpow(a, halfP);
			return root * root % mod;
		} else
			return a * modpow(a, p - 1) % mod;
	}

}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

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

using namespace std;
const int MOD = 1000000007,MAX = 510000;
long int pow107 = (int)pow(10, 9) + 7,llimit = LONG_MAX,fac[MAX], finv[MAX], inv[MAX];
int ilimit = INT_MAX;

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

bool comp(pair<int, int> a, pair<int, int> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

long int Func2(long int n,long int m){
    long int s2 = 1,
        r = 1;
    for(long int i = 1; i <= m; ++i){
        s2 = (s2*(n - (i - 1))/i) % (pow107);
    }
    return s2;
}

bool secsort(pair<int, int> a, pair<int, int> b){
    if(a.second == b.second)return a.first > b.first;
    else return a.second > b.second;
}

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

long int LCM(long int a,long int b){
    return a/GCD(a,b)*b;
}

//long intの最大llimit
//intの最大ilimit
//10^9+7    pow107
//素数pn
//n乗jou
//階乗factorial
//コンビネーションFunc2
//コンビネーションCOMinit(),COM(n,m)

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    int cl = 0,cr = 0;
    for(int i = 0; i < m; ++i){
        int a;
        cin >> a;
        if(a < x)cl++;
        if(a > x)cr++;
    }
    if(cr < cl)cout << cr << endl;
    else cout << cl << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <algorithm>

using namespace std;

int solve(string s){
    typedef set<string> set_s;
    set_s S;
    for(int i=1;i<s.size();i++){
        string s1,s1r,s2,s2r,kouho1,kouho2,kouho3,kouho4,kouho5,kouho6,kouho7,kouho8;
        s1r = s.substr(0,i);
        reverse(s1r.begin(),s1r.end());
        s2r = s.substr(i);
        reverse(s2r.begin(),s2r.end());
        s1 = s.substr(0,i);
        s2 = s.substr(i);

        kouho1 = s1 + s2;
        kouho2 = s1 + s2r;
        kouho3 = s1r + s2;
        kouho4 = s1r + s2r;
        kouho5 = s2 + s1;
        kouho6 = s2 + s1r;
        kouho7 = s2r + s1;
        kouho8 = s2r + s1r;

        S.insert(kouho1);
        S.insert(kouho2);
        S.insert(kouho3);
        S.insert(kouho4);
        S.insert(kouho5);
        S.insert(kouho6);
        S.insert(kouho7);
        S.insert(kouho8);
    }
    return S.size();
}

int main(){
    int n;
    cin >> n;
    string s;
    for(int i=0;i<n;i++){
        cin >> s;
        cout << solve(s) << endl;
    }
}

Measured memory_bytes: 1304
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <cstdio>
using namespace std;

#define INF 1e9

int min(int a, int b){ return a < b ? a : b; }

int main(void){
  while(true){
    int n, m, p, a, b;
    cin >> n >> m >> p >> a >> b;
    if(n == 0 && m == 0 && p == 0 && a == 0 && b == 0){ break; }
    --a; --b;

    // ??¬??????????????±???????????????
    vector<int> t(n);
    for(int i = 0; i < n; i++){ cin >> t[i]; }

    // ???????????±???????????????
    int x, y, z;
    vector<vector<pair<int, int> > > adjlist(m);
    for(int i = 0; i < p; i++){
      cin >> x >> y >> z;
      --x; --y;
      adjlist[x].push_back(make_pair(z, y));
      adjlist[y].push_back(make_pair(z, x));
    }

    // ????????????????????????
    vector<vector<double> > result(m, vector<double>(1 << n, INF));
    priority_queue<pair<double, pair<int, int> > > wait;

    wait.push(make_pair(0, make_pair(0, a)));
    for(int i = 0; i < (1 << n); i++){ result[a][i] = 0; }

    while(!wait.empty()){
      double nowcost = -wait.top().first;
      int nowticket = wait.top().second.first;
      int nowpoint = wait.top().second.second;
      wait.pop();
      if(nowcost > result[nowpoint][nowticket]){ continue; }

      for(int i = 0; i < adjlist[nowpoint].size(); i++){
        int nextpoint = adjlist[nowpoint][i].second;
        for(int j = 0; j < n; j++){
          if((nowticket & (1 << j)) == 0){
            int nextticket = nowticket | (1 << j);
            double nextcost = nowcost + ((double)adjlist[nowpoint][i].first / t[j]);
            if(result[nextpoint][nextticket] > nextcost){
              result[nextpoint][nextticket] = nextcost;
              wait.push(make_pair(-nextcost, make_pair(nextticket, nextpoint)));
            }
          }
        }
      }
    }

    // ??????????¨????????????????
    double mincost = INF;
    for(int i = 0; i < (1 << n); i++){
      if(mincost > result[b][i]){ mincost = result[b][i]; }
    }
    if(mincost == INF){ cout << "Impossible" << endl; }
    else{ printf("%.4f\n", mincost); }
  }

  return 0;
}

Measured memory_bytes: 4528
from fractions import gcd

n = int(input())
*A, = map(int, input().split())
B = A[::-1]
L, R = [0]*(n+1), [0]*(n+1)
for i in range(n):
    L[i+1] = gcd(L[i], A[i])
    R[i+1] = gcd(R[i], B[i])
L, R = L[:n], R[:n][::-1]
print(max(gcd(l, r) for l, r in zip(L, R)))

Measured memory_bytes: 16064
N, A, B = gets.chomp.split.map(&:to_i)
hps = []
N.times{ hps << gets.chomp.to_i }
additional_damage = A - B
times = 1..hps.max
answer = times.bsearch do |t|
    additional_times = 0
    hps.each do |hp|
       additional_times += [hp - (B * t), 0].max.fdiv(additional_damage).ceil
    end
    additional_times <= t
end
puts answer


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef map<ll,ll> mll;
typedef vector<bool> vb;

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define endl "\n"
#define prina(arr,dau,cuoi) FTB(mmczmp,dau,cuoi)cout<<arr[mmczmp]<<" ";cout<<endl;
#define debug cout<<"debug\n"
#define pb push_back
#define pbg(ke,u,v) ke[u].pb(v);ke[v].pb(u);
#define fi first
#define se second
#define pi acos(-1.0)
#define lbnd(f,s,gt) lower_bound(f,s,gt)
#define ubnd(f,s,gt) upper_bound(f,s,gt)
#define all(s) s.begin(),s.end()
#define bitcount(n) __builtin_popcountll(n)
#define FTB(i,a,b) for(ll i=a,_b=b;i<=_b;i++)
#define FT(i,a,b) for(ll i=a,_b=b;i<_b;i++)
#define FGB(i,a,b) for(ll i=a,_b=b;i>=_b;i--)
#define FG(i,a,b) for(ll i=a,_b=b;i>_b;i--)
/////////////////////////////////////////////

ll n,dp[200005][3];
string s;

void Solve(){
    cin>>s;
    n=s.size();
    s=" "+s;
    if(n==1){
        cout<<1;
        return;
    }
    dp[1][1]=1;
    dp[2][2]=1;
    if(s[2]!=s[1]) dp[2][1]=2;
    FTB(i,3,n){
        if(s[i]==s[i-1]){
            dp[i][1]=dp[i-1][2]+1;
        }
        else{
            dp[i][1]=max(dp[i-1][1],dp[i-1][2])+1;
        }
        dp[i][2]=dp[i-2][1]+1;
    }
    cout<<max(dp[n][1],dp[n][2]);
}

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

    //freopen("1.in","r",stdin);
    //freopen("1.out","w",stdout);


    int Test_numbers=1;
    //int Test_numbers;cin>>Test_numbers;

    while(Test_numbers--) Solve();

    //cerr << "\nTime run: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

	return 0;
}


Measured memory_bytes: 5328
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, K;
    cin >> N >> K;
    vector<double> p(N);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
        p[i] = (p[i] + 1) / 2 ;
    }
    vector<double> sum(N+1);
    for (int i = 0; i < N; i++) sum[i+1] = sum[i] + p[i];
    double ans = 0.0;
    for (int i = K; i <= N; i++) ans = max(ans, sum[i] - sum[i-K]);
    cout << fixed << setprecision(10) << ans << '\n';
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N;
  cin>>N;
  ll ans=0;
  for(int i=1;i<=N;i++){
    if(i%3!=0&&i%5!=0)ans+=i;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3688
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

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

    int mmax = (n - 2) * (n - 1) / 2;
    if (mmax < k) {
        cout << -1 << endl;
        return 0;
    }

    vector<pair<int, int>> ans;

    for (int i = 1; i < n; i++) {
        ans.push_back({0, i});
    }

    int add = mmax - k;
    for (int i = 1; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (add == 0) {
                break;
            }

            ans.push_back({i, j});
            add--;
        }
    }

    cout << ans.size() << endl;
    for (auto &[x, y] : ans) {
        cout << x + 1 << ' ' << y + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        string S;
        cin >> N >> S;
        ll rcnt = 0;
        rep(i, 0, len(S)) {
                if (S[i] == 'R') ++rcnt;
        }

        ll sm = 0;
        rep(i, 0, rcnt) {
                if (S[i] == 'R') ++sm;
        }
        ll ans = rcnt - sm;
        cout << ans << endl;
}


Measured memory_bytes: 3708
x,y,a,b,c=map(int,input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p = sorted(p,reverse=True)
q = sorted(q,reverse=True)
r = sorted(r,reverse=True)

l = p[0:x] + q[0:y] + r[0:(x+y)]
l = sorted(l, reverse=True)
ans = 0
for i in range (0,(x+y)):
    ans = ans + l[i]

print(ans)

Measured memory_bytes: 22824
// Author : Nachiket Kanore
// Institute : PICT, Pune

/*
 * 	Heart beats fast
 * 		Colors and promises
 * 			How to be brave
 * 				How can I love when I am afraid to fall...
 */

#include <stdexcept>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstring>
#include <cstdarg>
#include <cstdio>
#include <memory>
#include <random>
#include <cmath>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
#include <limits>
#include <bitset>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <array>
#include <list>
#include <map>
#include <set>

using namespace std;

#define int long long
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcount(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
 
 
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
 
const int mod = 1e9+7;
const int inf = 1e18;
const int N = 2e5+20;
int ans;
string s;

int32_t main(){
    FAST;
    int n;  cin >> n;
    cin >> s;

    for(int x=0;x<n;x++){
        int one[26] = {0};
        int two[26] = {0};
        rep(i,0,x)
            one[s[i] - 'a']++;
        rep(i,x+1,n-1)
            two[s[i] - 'a']++;
        int cnt =0;
        rep(i,0,25)
            cnt += min(one[i],two[i]) > 0;
        ans = max(ans , cnt);
    }

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

Measured memory_bytes: 256
//https://www.geeksforgeeks.org/number-of-n-length-sequences-whose-product-is-m/

#include <bits/stdc++.h> 

using namespace std; 

const long long mod = 1e9 + 7ll ;
 
const int MAX = 4e5 + 5 ;

long long modpower(long long a , long long b)
{
    if(b == 0)
        return 1ll ;
    long long x = modpower(a , b / 2ll) ;
    x = (x * x) % mod ;
    if(b & 1)
        return (x * a) % mod ;
    return (x % mod) ;
}
 
struct combination
{
    vector<long long>fact , inv ;
    combination(int sz) : fact(sz + 1) , inv(sz + 1)
    {
        fact[0] = 1ll ;
        inv[0] = 1ll ;
        for(long long i = 1 ; i <= sz ; ++i)
        {
            fact[i] = (fact[i-1] * i) % mod ;
            inv[i] = modpower(fact[i] , mod - 2ll) ;
        }
    }
    long long choose(int n , int k) const
    {
        if(k < 0 || n < k)
            return 0 ;
        return ((((fact[n] * inv[k]) % mod) * inv[n - k]) % mod) ;
    }
};

combination table(MAX) ;

int NoofSequences(int N, int M) 
{ 
	map<int, int> prime; 
	for (int i = 2; i * i <= M; ++i) 
	{ 
		while (M % i == 0) 
		{ 
			prime[i]++; 
			M /= i; 
		} 
	} 
	if (M > 1) 
		prime[M] += 1; 
	long long ans = 1ll ;
	for (auto it : prime) 
	{
		ans = (ans * (table.choose(N + it.second - 1, N - 1))) % mod; 
		ans %= mod ;
	}
	return ans; 
} 

int main() 
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int n , m ;
	cin>>n>>m ;
	return cout<<NoofSequences(n, m) % mod<<"\n" , 0; 
} 


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

int calc(int a,int b) {
	return a*(100+b)/100;
}

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

	while(true) {
		int x,y,s;cin>>x>>y>>s;
		if(s==0) break;
		int ma=0;
		FOR(i,1,s) {
			FOR(j,1,s) {
				if(calc(i,x)+calc(j,x)!=s) continue;
				ma=max(ma,calc(i,y)+calc(j,y));
			}
		}
		cout<<ma<<endl;
	}

	return 0;
}



Measured memory_bytes: 3208
void main() {
	auto ip = readAs!(int[]), N = ip[0], K = ip[1];
	auto p = readAs!(int[]);
	auto arr = new real[](N);
	foreach(i; 0..N) {
		arr[i] = p[i] * (p[i] + 1) / 2. / p[i];
	}
	debug arr.writeln;
	auto arr2 = new real[](N);
	arr2[0] = arr[0];
	foreach(i; 0..N-1) arr2[i+1] = arr[i+1] + arr2[i];
	real res = 0;
	debug arr2.writeln;
	foreach(i; 0..N-K) res = max(res, arr2[i+K] - arr2[i]);
	if(N == 1) res = arr2[0];
	if(N == K) res = arr2.back;
	writefln("%.9f", res);
}

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

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 17960