akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define N 100010
using namespace std;
int main()
{
	long long t[N],n,c,k,i,cur,ans=0;
	cin>>n>>c>>k;
	for(i=0;i<n;i++)
		cin>>t[i];
	sort(t,t+n);
	for(i=0;i<n;)
	{
		cur=i;
		while((i<n)&&(i<cur+c)&&(t[i]-t[cur]<=k))
			i++;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
import math

def is_prime(n:int):
    if n==1:
        return False
    for i in range(2,int(math.sqrt(n)+1)):
        if n%i==0:
            return False
    return True

all=[0]+[0]*(10**5+1)
for i in range(3,10**5):
    if is_prime((i)) and is_prime((i+1)//2) :
        all[i]=all[i-1]+1
    else:
        all[i]=all[i-1]



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

Measured memory_bytes: 76976
public class Main {
	public static void main(String[] args) {
		var sc = new java.util.Scanner(System.in);
		var S = sc.next();
		var T = sc.next();

		var res = T.length();
		for (var i = 0; i <= S.length() - T.length() ; i++) {
			var cnt = 0;
			for (var j = 0; j < T.length(); j++) {
				if (S.charAt(i + j) != T.charAt(j)) {
					cnt++;
				}
			}
			res = Math.min(res, cnt);
		}
		System.out.println(res);

	}
}


Measured memory_bytes: 35620
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
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; }

int main(){
  int n; cin >> n;
  vi a(n+1,1);
  for(int i = 2; i < sqrt(n); i++){
    if(a[i]){
      for(int j = 2; i*j <= n; j++){
        a[i*j] = 0;
      }
    }
  }
  vector<ll> cnt(n+1);
  for(int now = 2; now <= n; now++){
    int num = now;
    for(int i = 2; i <= now; i++){
      if(a[i]){
        while(num % i == 0){
          num /= i;
          cnt[i]++;
        }
      }
    }
  }
  ll ans = 1;
  for(int i = 0; i <= n; i++){
    if(cnt[i]) ans *= cnt[i]+1;
    ans %= 1000000007;
  }
  cout << ans%1000000007;
  cout << "\n";
  return 0;
}


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

int main(){
    while(1){
        int x, y;
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        
        if (x > y){
            int tmp = x;
            x = y;
            y = tmp; 
        }
        cout << x << " " << y << endl;
    }
    return 0;
}



Measured memory_bytes: 3092
# coding: utf-8
import sys


def main(argv=sys.argv):
  candy = list(map(int, input().split()))
  
  new_candy = sorted(candy)
  
  if new_candy[0] + new_candy[1] == new_candy[2]:
    print('Yes')
    
  else:
    print('No')

    
    
  return 0


if __name__ == '__main__':
  sys.exit(main())

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
typedef long long ll;
using namespace std;

int main(void){
  int N,M,Q,i,j;
  static int p[100000],q[100000];
  int l,r;
  static int dp[510][510],train[510][510];

  cin>>N>>M>>Q;
  for(i=0;i<N+1;i++){
    for(j=0;j<N+1;j++){
      train[i][j]=dp[i][j]=0;
    }
  }
  for(i=0;i<M;i++){
    cin>>l>>r;
    train[l][r]++;
  }
  
  for(i=0;i<Q;i++){
    cin>>p[i]>>q[i];
  }
  
  dp[1][1]=train[1][1];
  for(i=2;i<N+1;i++){
    dp[i][i]=train[i][i];
    for(j=i-1;j>0;j--){
      dp[j][i]=dp[j+1][i]+dp[j][i-1]+train[j][i]-dp[j+1][i-1];
    }
  }

  for(i=0;i<Q;i++){
    cout<<dp[p[i]][q[i]]<<endl;
  }

  return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main() {
  int N;
  cin >> N;

  vector<int> V(N);
  rep(i, N) cin >> V[i];

  vector<int> C(N);
  rep(i, N) cin >> C[i];

  int ans = 0;
  rep(i, N) { ans += max(0, V[i] - C[i]); }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    string S, T;
    cin >> S >> T;
    int ans = 0;
    REP(i, S.length()) {
        if(S[i] != T[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int price;
  if (A + B >= 2*C) {
    if (X > Y) {
      price += 2*C*Y;
      X -= Y;
      if (A >= 2*C) {
        price += 2*C*X;
      }
      else {
        price += A*X;
      }
    }
    else {
      price += 2*C*X;
      Y -= X;
      if (B >= 2*C) {
        price += 2*C*Y;
      }
      else {
        price += B*Y;
      }
    }
  }
  else {
    price += A*X + B*Y;
  }
  cout << price << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n,a,b,a1,b1;
    cin>>n>>a>>b;
    if (a<b)swap(a,b);
    a1=a;
    b1=b;
    if ((a-b)%2==0){
        cout<<(a-b)/2<<'\n';
    }
    else {
        long long ans=0,ans1=0;
        ans+=b-1;
        a-=(b-1);
        b=1;
        if ((a-b)%2==0){
            ans+=(a-b)/2;
        }
        else {
            ans+=(a-b)/2+1;
        }
        a=a1;
        b=b1;
        ans1+=n-a;
        //cout<<ans1<<'\n';
        b+=n-a;
        a=n;
        if ((a-b)%2==0){
            ans1+=(a-b)/2;
        }
        else {
            ans1+=(a-b)/2+1;
        }
        
        cout<<min(ans,ans1)<<'\n';
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ull unsigned long long


using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);	
    cin.tie(NULL); cout.tie(NULL);
    
    ll x; cin >> x;
    
    ll sum = 100;
    int counter = 0;
    while(sum < x)
    {
		counter++;
		sum = floor(sum*1.01);
		
	}
    
    cout << counter << '\n';
    
    return 0;
}



Measured memory_bytes: 3732
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;

vector<int> par; // 親ノード
vector<int> depth; // ランク


void init(int n = 1) {
    par.resize(n); depth.resize(n);
    for (int i = 0; i < n; ++i) par[i] = i, depth[i] = 0;
}

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

bool issame(int x, int y) {
    return root(x) == root(y);
}

bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (depth[x] < depth[y]) swap(x, y);
    if (depth[x] == depth[y]) ++depth[x];
    par[y] = x;
    return true;
}

int N, M;
int A[101], B[101];

int main(){
    cin >> N >> M;
    rep(i, M) cin >> A[i] >> B[i], A[i]--, B[i]--;

    int ans = 0;
    rep(i, M) {
        init(N);
        rep(j, M) if (j != i) merge(A[j], B[j]);
        int c = 0;
        rep(j, N) if (par[j] == j) c++;
        if (1 < c) ans++;
    }

    cout << ans << endl;
}


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

#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define wt(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

struct Trie {
  array<int, 26> value = {};
  array<unique_ptr<Trie>, 26> children = {};
};

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

  rd(int, n);

  V<string> s(n);
  rep(i, n) {
    cin >> s[i];
    reverse(all(s[i]));
  }

  Trie trie;
  function<bitset<26>(Trie&, const string&, int)> add_trie =
      [&](Trie& t, const string& si, int i) {
        bitset<26> have;
        if (i < si.size()) {
          if (t.children[si[i] - 'a'] == NULL) {
            t.children[si[i] - 'a'].reset(new Trie);
          }
          Trie& c = *t.children[si[i] - 'a'];
          have |= add_trie(c, si, i + 1);
          have.set((si[i] - 'a'));
        }
        if (si.size() - i >= 2) {
          rep(i, 26) if (have.test(i))++ t.value[i];
        }
        return have;
      };
  for (const auto& si : s) {
    add_trie(trie, si, 0);
  }
  ll ans = 0;
  for (const auto& si : s) {
    const Trie* t = &trie;
    rep(i, si.size() - 1) { t = t->children[si[i] - 'a'].get(); }
    ans += t->value[si.back() - 'a'];
  }
  wt(ans);
}


Measured memory_bytes: 419204
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
  for j in range(i+1, n):
    for k in range(j+1, n):
      x, y, z = sorted([l[i], l[j], l[k]])
      if x + y > z and x != y and y != z:
        ans += 1
print(ans)

Measured memory_bytes: 9192
N, K = map(int, input().split())
*A, = map(int, input().split())
dist = [-1]*(N+1)

d = {i:[] for i in range(1, N+1)}
for i, j in enumerate(A, start=1):
    d[i].append(j)

dist[1] = 0
q = [1]
cycle = 0
ls = 0
while q:
    a = q.pop()
    for b in d[a]:
        if dist[b]==-1:
            dist[b] = dist[a] + 1
            q.append(b)
        elif dist[b]==0 or dist[b]:
            cycle = dist[a] + 1 - dist[b]
            ls = b
            break

b = (K-dist[ls])%cycle if K>dist[ls] else K
c = dist[ls]+b if K>dist[ls] else K
for i, j in enumerate(dist):
    if j==c:
        print(i)
        break


Measured memory_bytes: 61120
from sys import exit

N, M = map(int, input().split())

shops = {}

for _ in range(N):
    A, B = map(int, input().split())
    if A in shops.keys():
        shops[A] += B
    else:
        shops[A] = B

shops = sorted(shops.items())
ans = 0

for k in shops:
    if M - k[1] <= 0:
        ans += k[0] * M
        break
    else:
        ans += k[0] * k[1]
        M -= k[1]

print(ans)


Measured memory_bytes: 23000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll ans=0;
	for(ll i=0;i<=999;i++){
		ll now=i;
		ll ch2[3];
		for(ll j=0;j<3;j++){
			ch2[j]=now%10;
			now/=10;
		}
		ll cnt=0;
		for(ll j=0;j<n;j++){
			if(ll(s[j]-'0')==ch2[cnt]){
				cnt++;
			}
			if(cnt==3){
				ans++;
				break;
			}
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll k,r;
	cin>>k>>r;
	if(k>=10){
		cout << r;
		return 0;
	}
	cout << r+100*(10-k);
	// your code goes here
	return 0;
}

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

using namespace std;

int n, a[100010], b[100010], c[100010], memo[100010][4];

int dp(int idx, int stats) {
	if(idx > n) {
		return 0;
	}
	if(memo[idx][stats] != -1) {
		return memo[idx][stats];
	}
	if(stats == 1) {
		memo[idx][stats] = a[idx] + max(dp(idx + 1, 2), dp(idx + 1, 3));
		return memo[idx][stats];
	}
	else if(stats == 2) {
		memo[idx][stats] = b[idx] + max(dp(idx + 1, 1), dp(idx + 1, 3));
		return memo[idx][stats];
	}
	else {
		memo[idx][stats] = c[idx] + max(dp(idx + 1, 1), dp(idx + 1, 2));
		return memo[idx][stats];
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	memset(memo, -1, sizeof(memo));
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	cout << max(max(dp(1, 1), dp(1, 2)), dp(1, 3)) << endl;
}


Measured memory_bytes: 7808
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <climits>
#include <ctime>
#include <random>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-9
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;

int main() {
	speed;
	int n, s = 0;
	cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		s ^= v[i];
	}
	for (int i = 0; i < n; ++i)
		cout << (v[i] ^ s) << ' ';
}

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

int main() {
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
  int64_t H,W;
  cin>>H>>W;
  int64_t n=H*W/2;
  if(H==1||W==1)
    cout<<1;
  else if(H%2==1&&W%2==1){
    n=n+1;
    cout<<n;
  }
  else 
    cout<<n;
}

Measured memory_bytes: 256
#include <stdio.h>

int gcd(int a, int b) {
	while (b > 0) {
		int r = a % b;
		a = b;
		b = r;
	}
	return a;
}

int main(void) {
	int A, B, C;
	int g;
	if (scanf("%d%d%d", &A, &B, &C) != 3) return 1;
	g = gcd(A, B);
	puts(A % g == C % g ? "YES" : "NO");
	return 0;
}

/*
A * n ≡ C (mod B) となる正の整数nがあるかを判定する

→ あればA*nを選べばおｋ

Cが0の時は、A*Bを選べばおｋ

Cが0でないとき、最大公約数の数のレーンで動く
*/


Measured memory_bytes: 128
#include <stdio.h>

int main(){

	char a[101];
	char b[101];
	char c[101];
	
	scanf("%s%s%s", a, b, c);
	
	int i;
	
	for (i = 0; a[i] != '\0'; ++i){
		;
	}
	
	if (b[0] == a[i-1]){
		for (i = 0; b[i] != '\0'; ++i){
			;
		}
		
		if (c[0] == b[i-1]){
			printf("YES\n");
		} else {
		printf("NO\n");
	}
	
	} else {
		printf("NO\n");
	}


	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define ALF "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define LLBIG 1999999999999999999LL
#define INTBIG 1111111111
#define MOD 1000000007
#define PI pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>

int N, M, C, B[25], ans = 0;

int main() {
	cin >> N >> M >> C;
	for (int i = 0; i < M; i++)cin >> B[i];
	for (int i = 0; i < N; i++) {
		int tmp = 0;
		for (int j = 0; j < M; j++) {
			int A; cin >> A;
			tmp += A * B[j];
		}
		if (tmp + C > 0)ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {
  deque<char> deq;
  int Q;
  string S;
  cin >> S >> Q;
  for (char c : S) {
    deq.push_back(c);
  }

  int order = 1;
  for (int i = 0; i < Q; i++) {
    int T;
    cin >> T;
    if (T == 1) {
      order *= -1;
    } else {
      int F;
      cin >> F;
      F = (F == 1) ? 1 : -1;
      char C;
      cin >> C;
      int place = order * F;
      if (place == 1) {
	deq.push_front(C);
      } else {
	deq.push_back(C);
      }
    }
  }

  string answer;
  if (order == 1) {
    for (int i = 0; i < deq.size(); i++) {
      answer += deq[i];
    }
  } else {
    for (int i = deq.size() - 1; i >= 0; i--) {
      answer += deq[i];
    }
  }
  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 1412
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	ac := make(map[int]bool)
	wa := make(map[int]int)
	var p int
	var s string
	for i := 0; i < m; i++ {
		fmt.Scan(&p, &s)
		if s == "AC" {
			ac[p] = true
		}

		if s == "WA" {
			if !ac[p] {
				wa[p]++
			}
		}
	}

	a := len(ac)
	w := 0
	for k, v := range wa {
		if ac[k] {
			w += v
		}
	}

	fmt.Printf("%d %d\n", a, w)
}


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

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(int i = f; i < (int)l; ++i)
#define repit(it, t) for(__typeof((t).begin()) it = (t).begin(); it != (t).end(); it++)
#define endl "\n"
#define pb emplace_back
#define lb lower_bound
#define int long long
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second
#define DBG0(x) { cout << #x << ": " << x << "\t"; }
#define DBG(x) {DBG0(x); cout << endl;}
#define DBG2(x, y) {DBG0(x); DBG(y);}
#define DBG3(x, y, z) {DBG0(x); DBG2(y, z);}
#define DBG4(w, x, y, z) {DBG0(w); DBG3(x, y, z);}

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;

signed main(void){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint h = vint(n);
    int ans = 0;
    rep(i, n) {
        cin >> h[i];
    }

    while(true) {
        bool term = true;
        rep(i, n) {
            term &= (h[i] == 0);
            if (!term) break;
        }
        if (term) break;

        bool water = false;
        rep(i, n) {
            if (h[i] > 0) {
                h[i]--;
                if (!water) {
                    ans++;
                }
                water = true;
            } else {
                water = false;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

div = factorization(int(input()))

cnt = 0
for d in div:
    if d[0] == 1: continue
    loo = d[1]
    i = 1
    while loo >= i:
        loo -= i
        i += 1
        cnt += 1
print(cnt)


Measured memory_bytes: 9504
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    double dp[n+1],p;
    dp[0]=0;
    for(int i=1;i<=n;i++){
    	cin>>p;
    	dp[i]=(p+1.0)/2+dp[i-1];
    }
    double ans=0;
    for(int i=k;i<=n;i++){
    	ans=max(ans,dp[i]-dp[i-k]);
    }
    doublecout(ans);
    return 0;
}


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

int main()
{
    int n;
    cin>>n;
    long long sum=0;
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0)sum+=i;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void print() { cout << "\n"; }
template <class T, class... Args>
void print(const T &x, const Args &... args) { cout << x << " "; print(args...);}
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n,k;
  cin >> n >> k;
  vector<int> cnt(n,0);
  rep(i,k) {
    int d;
    cin >> d;
    rep(j,d) {
      int a;
      cin >> a; a--;
      cnt[a]++;
    }
  }
  int ans = 0;
  rep(i,n) {
    if (cnt[i] == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3672
/*
AizuOnline A0127
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
char msg[401];
char cvtmsg[201];
//
conv(char n1,char n2)
{
  int r;
  if(n1 < '1' || n1 > '6' ||n2 < '1' ||n2 > '5')
    return(-1);
  r = ((n1-'0')-1)*5+(n2-'0'-1);
  if(r < 26)
    return('a'+r);
  else 
    return(".?! "[(n2-'2')]);
}
main()
{
  int i,j,l;
  char cvt;

  while(EOF!=scanf("%s ",msg))
    {
      memset(cvtmsg,0,sizeof(cvtmsg));
      l=strlen(msg);
      if((l % 2)==1)
	goto NA;
      for(i=0,j=0;i<l;i+=2)
	{
	  cvt=conv(msg[i],msg[i+1]);
	  if(cvt==-1)
	    goto NA;
	  cvtmsg[j++]=cvt;
	}
      cvtmsg[j]=0;
    
      printf("%s\n",cvtmsg);
      continue;
NA:
      printf("NA\n");
    }
return(0);
}

Measured memory_bytes: 528
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  cin>>x>>y;
  if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)){
    cout<<"Yes"<<endl;
  }else if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

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



struct Union_Find{
    vector<int> par, depth;
    Union_Find(int n){init(n);}
    void init(int n){
        par.resize(n); depth.resize(n);
        for(int i=0; i<n; i++){
            par[i]=i;
            depth[i]=0;
        }
    }

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

    void unite(int x, int y){
        x=find(x), y=find(y);
        if(x == y) return;

        if(depth[x] < depth[y]) par[x]=y;
        else{
            par[y]=x;
            if(depth[x] == depth[y]) depth[x]++;
        }
    }

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

struct edge{int u, v, cost;};

struct Kruskal{
    ll sum=0;
    int V, E;
    vector<edge> es;
    Kruskal(const vector<edge> &es_, int V_) : es(es_), V(V_) {init();}
    void init(){
        E=(int)es.size();
        sort(all(es), [](const edge &e1, const edge &e2)
        {return e1.cost < e2.cost;});
        Union_Find uf(V);
        for(int i=0; i<E; i++){
            edge e=es[i];
            if(uf.same(e.u, e.v)) continue;
            uf.unite(e.u, e.v);
            sum+=e.cost;
        }
    }
};

int main(){
    int N; cin >> N;
    vector<pii> x(N), y(N);
    for(int i=0; i<N; i++){
        int px, py; cin >> px >> py;
        x[i]=(pii){px, i};
        y[i]=(pii){py, i};
    }

    sort(all(x)), sort(all(y));
    vector<edge> es;
    for(int i=0; i<N-1; i++){
        int u1, x1, u2, x2;
        tie(x1, u1)=x[i], tie(x2, u2)=x[i+1];
        int v1, y1, v2, y2;
        tie(y1, v1)=y[i], tie(y2, v2)=y[i+1];
        es.push_back((edge){u1, u2, x2-x1});
        es.push_back((edge){v1, v2, y2-y1});
    }
    Kruskal kr(es, N);
    cout << kr.sum << endl;
    return 0;
}

Measured memory_bytes: 10304
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {

		InputStreamReader sr = null;
		Scanner sc = null;

		try {

			sc = new Scanner(sr = new InputStreamReader(System.in));

			String s;

			s = sc.nextLine();

				System.out.println(s.toUpperCase());

		}

		finally {
			sr.close();
			sc.close();
		}

	}
}

Measured memory_bytes: 17284
import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


immutable string YES = "Yes";
immutable string NO = "No";


auto solve(long N) {
    return cartesianProduct(iota(1, 10), iota(1, 10)).map!(t => t[0] * t[1]).canFind(N);
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(N);
    else {
        auto ans = solve(N);

        static if (isFloatingPoint!(ReturnType!solve))
            writeln(format("%.9f", ans));
        else static if (is(ReturnType!solve == bool))
            writeln(ans ? YES : NO);
        else
            writeln(ans);
    }
}


Measured memory_bytes: 256
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    b, c = map(int, input().split())

    if b % 3 ==0 or c % 3 == 0 or (b+c) %3 ==0:
        print("Possible")
    else:
        print("Impossible")

Measured memory_bytes: 3828
#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()

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

  int N,W;
  cin>>N>>W;
  vector<int>w(N),v(N);
  for(int i=0;i<N;i++)cin>>w[i]>>v[i];
  vector<vector<ll>>dp(N+1,vector<ll>(100001,INF/2));
  dp[0][0]=0;
  for(int i=1;i<=N;i++){
    for(int j=0;j<=100000;j++){
      if(0<=j-v[i-1])dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i-1]]+w[i-1]);
      else dp[i][j]=dp[i-1][j];
    }
  }
  ll ans=0;
  for(int i=0;i<=100000;i++){
    if(W>=dp[N][i]){
      ans=i;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

vector<ll> v[4];

int main() {
	ll n, W;
	cin >> n >> W;
	ll w, c;
	cin >> w >> c;
	v[0].push_back(c);
	rep(i, n - 1) {
		ll a, b;
		cin >> a >> b;
		rep(j, 4) {
			if (a == w + j) v[j].push_back(b);
		}
	}
	rep(i, 4) {
		sort(v[i].rbegin(), v[i].rend());
	}
	ll ans = 0;
	for (int i = 0; i <= v[0].size(); ++i) {
		for (int j = 0; j <= v[1].size(); ++j) {
			for (int k = 0; k <= v[2].size(); ++k) {
				for (int l = 0; l <= v[3].size(); ++l) {
					if(i + j + k + l > n) break;
					ll value = 0;
					ll weight = 0;
					rep(m, i) {
						value += v[0][m];
						weight += w;
					}
					rep(m, j) {
						value += v[1][m];
						weight += w+1;
					}
					rep(m, k) {
						value += v[2][m];
						weight += w+2;
					}
					rep(m, l) {
						value += v[3][m];
						weight += w+3;
					}
					if(weight <= W){
						ans = max(ans, value);
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int inputA = scanner.nextInt();
		int inputB = scanner.nextInt();
		scanner.close();

		String[][] s = new String[40][100];
		for (int i = 0; i < 20; i++) {
			Arrays.fill(s[i], "#");
		}
		for (int i = 20; i < 40; i++) {
			Arrays.fill(s[i], ".");
		}
		for (int i = 0; i < inputA - 1; i++) {
			s[i / 50 * 2][i % 50 * 2] = ".";
		}
		for (int i = 0; i < inputB - 1; i++) {
			s[i / 50 * 2 + 21][i % 50 * 2] = "#";
		}

		System.out.println("40 100");
		for (int i = 0; i < 40; i++) {
			for (int j = 0; j < 100; j++) {
				System.out.print(s[i][j]);
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 24404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  ll a,b;
  cin >> a >> b;
  rep(i,500000){
    if(i*8/100 == a && i*1/10 == b){
      cout << i << endl;
      return 0;
    }

  }
  cout << -1 << endl;

  
  return 0;
    

}


Measured memory_bytes: 256
W, H, N = map(int, input().split())

X = [[i+1, "w"] for i in range(W)]
Y = [[i+1, "w"] for i in range(H)]
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        for j in range(len(X)):
            if X[j][0] <= x:
                X[j][1] = "b"
    elif a == 2:
        for j in range(len(X)):
            if X[j][0] > x:
                X[j][1] = "b"
    elif a == 3:
        for j in range(len(Y)):
            if Y[j][0] <= y:
                Y[j][1] = "b"
    elif a == 4:
        for j in range(len(Y)):
            if Y[j][0] > y:
                Y[j][1] = "b"
x_w = 0
y_w = 0
for i in range(len(X)):
    if X[i][1] == "w":
        x_w += 1
for i in range(len(Y)):
    if Y[i][1] == "w":
        y_w += 1
print(x_w * y_w)


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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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

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

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

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

fn main() {
    input! {
        r: i64,
    }
    println!("{}", 3 * r * r);
}


Measured memory_bytes: 4352
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
using namespace std;

set<string> f;

int main(void)
{
    int n;
    string t;

    ios::sync_with_stdio(false);
    cin >> n;
    while(n --)
    {
        cin >> t;
        f.insert(t);
    }
    cout << f.size() << endl;

    return 0;
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  int n;cin>>n;
  int mx=0;
  int sum=0;
  REP(i,n){
    int l;cin>>l;
    sum+=l;
    mx=max(mx,l);
  }
  sum-=mx;
  cout << (sum>mx?"Yes":"No") << endl;
}


Measured memory_bytes: 256
from itertools import accumulate
N, C = map(int, input().split())
STC = [list(map(int, input().split())) for _ in range(N)]

M = 10**5+1
merge = [[0]*(M+1) for _ in range(31)]
for i in range(N):
    s, t, c = STC[i]
    merge[c][s] += 1
    merge[c][t+1] -= 1
for c in range(31):
    merge[c] = list(map(lambda x: int(bool(x)), accumulate(merge[c])))

ans = []
for i in range(M+1):
    res = 0
    for j in range(31):
        res += merge[j][i]
    ans.append(res)
print(max(ans))


Measured memory_bytes: 54752
A, B, C = map(int, input().split())
a = max(A, B, C)
c = min(A, B, C)
b = (A + B + C) - (a + c)

ans = (a - b) + (b - c) // 2
if (b - c) % 2 == 1:
    ans += 2

print(ans)


Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

ll l[1000000];
ll pref[1000000];
ll suff[1000000];
ll prefSum[1000000];
int n;

void solve() {
  int k;
  cin >> n >> k;
  for(int i = 0; i < n; i++) {
    cin >> l[i];
    prefSum[i+1] = prefSum[i] + l[i];
  }
  for(int i = 0; i < n; i++) {
    pref[i+1] = pref[i] + max(0LL, l[i]);
  }
  for(int i = n-1; i >= 0; i--) {
    suff[n-i] = suff[n-i-1] + max(0LL, l[i]);
  }
  ll ret = 0;
  for(int i = 0; i + k <= n; i++) {
    ll cand = pref[i] + suff[n-k-i];
    cand += max(0LL, prefSum[i+k] - prefSum[i]);
    ret = max(ret, cand);
  }
  cout << ret << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


Measured memory_bytes: 11264
abcd = str(input())
a = abcd[0]
b = abcd[1]
c = abcd[2]
d = abcd[3]

sign = ['+', '-']
for i in range(2):
    for j in range(2):
        for k in range(2):
            tmp = a + sign[i] + b + sign[j] + c + sign[k] + d  
            if eval(tmp) == 7:
                print(tmp+'=7')
                exit()

Measured memory_bytes: 38256
N = int(input())
A = list(map(int, input().split()))
B = [0 for n in range(N+1)]
x = []

for n in range(N):
  i = N-n
  # print(i)
  BB = B[::i]
  if (sum(BB))%2 == A[i-1]:
    B[i] = 0
  else:
    B[i] = 1
    # print(B)
  if B[i] == 1:
    x.append(str(i))
  
if len(x) == 0:
  print(0)
else:
  print(len(x))
  print(' '.join(x))

Measured memory_bytes: 18764
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    ll ans[20000];
    MEMSET(ans, 0);
    rep1(i, 200) rep1(j, 200) rep1(k, 200){
        if(i*i+j*j+k*k+i*j+j*k+k*i<=16000) ans[i*i+j*j+k*k+i*j+j*k+k*i]++;
        //if(i*i+j*j+k*k+1*j+j*k+k*i<=20) cout<<i<<sp<<j<<sp<<k<<sp<<i*i+j*j+k*k+1*j+j*k+k*i<<endl;
    }
    ll N;
    cin>>N;
    rep1(i, N){
        cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
class UnionFind
{
public:
  int par[100005];
  int depth[100005];
  int nGroup[100005];
 
  UnionFind(int n) {
    init(n);
  }
 
  void init(int n) {
    for(int i=0; i<n; i++) {
      par[i] = i;
      depth[i] = 0;
      nGroup[i] = 1;
    }
  }
 
  int root(int x) {
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[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(depth[x] < depth[y]) {
      par[x] = y;
      nGroup[y] += nGroup[x];
      nGroup[x] = 0;
    } else {
      par[y] = x;
      nGroup[x] += nGroup[y];
      nGroup[y] = 0;
      if(depth[x] == depth[y])
        depth[x]++;
    }
  }
};
const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
} 
int main(){
ll n; cin>>n;
ll a[n]={};
ll k = 0;
rep(i,n){
cin>>a[i];
if(a[i]>i+1) k++;
}
if(k>0) cout << -1 << endl;
else{
k = n;
ll b[n]={};
rep(i,n){
ll h = k - i;
for(ll j = n-1; j>=0; j--){
if(a[j]==h){
b[i]=h;
a[j]=0;
break;}
else if(a[j]==0) continue;
else h--;}
}
rep(i,n) cout << b[n-1-i] << endl;}
}


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

int main(){
	string s1;
	cin >> s1;
	if(s1 == "SUN"){
		printf("7\n");
	}
	else if(s1 == "MON"){
		printf("6\n");
	}
	else if(s1 == "TUE"){
		printf("5\n");
	}
	else if(s1 == "WED"){
		printf("4\n");
	}
	else if(s1 == "THU"){
		printf("3\n");
	}
	else if(s1 == "FRI"){
		printf("2\n");
	}
	else if(s1 == "SAT"){
		printf("1\n");
	}
	return 0;
} 

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

using Graph=vector<vector<int>>;
int main(){
    int n;
    cin>>n;
    int m;
    cin>>m;
    string s;
    cin>>s;
    Graph g(n);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> acnt(n);
    vector<int> bcnt(n);
    vector<int> ng(n,false);
    stack<int> ngs;
    for(int i=0;i<n;i++){
        for(int j=0;j<g[i].size();j++){
            if(s[g[i][j]]=='A') acnt[i]++;
            if(s[g[i][j]]=='B') bcnt[i]++;
        }
        if(acnt[i]==0 || bcnt[i]==0){
            ng[i]=true;
            ngs.push(i);
        }
    }
    
    while(!ngs.empty()){
        int v=ngs.top();
        ngs.pop();
        for(int i=0;i<g[v].size();i++){
            if(s[v]=='A'){
                if((--acnt[g[v][i]])==0 && !ng[g[v][i]]){
                    ng[g[v][i]]=true;
                    ngs.push(g[v][i]);
                }
                
            }
            if(s[v]=='B'){
                if((--bcnt[g[v][i]])==0 && !ng[g[v][i]]){
                    ng[g[v][i]]=true;
                    ngs.push(g[v][i]);
                }
            }
        }
    }    
    //cerr<<"#"<<endl;
    //for(int i=0;i<n;i++) cerr<<ng[i]<<endl;
    cout<<(accumulate(ng.begin(),ng.end(),0)==n ? "No" : "Yes")<<endl;
    
    return 0;
}

Measured memory_bytes: 12932
n=int(input())
a=input()
L=[]
for i in range(26):
    L.append(chr(65+i))
news=''
for i in range(len(a)):
    if L.index(a[i])+n>25:
        news+=L[L.index(a[i])+n-26]
    else:
        news+=L[L.index(a[i])+n]
        



print(news)


Measured memory_bytes: 9176
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#pragma 03
using namespace std;
using namespace __gnu_pbds;
int main(){
	vll lun, cur, tmp; 
	for (ll i = 1; i < 10; i++){
		lun.pb(i); cur.pb(i);
	}
	ll iterate = 9;
	while (iterate--){
		for (ll i = 0; i < cur.size(); i++){
			tmp.pb(cur[i] * 10 + cur[i] % 10);
			if (cur[i] % 10 < 9) tmp.pb(cur[i] * 10 + (cur[i] % 10 + 1));
			if (cur[i] % 10 > 0) tmp.pb(cur[i] * 10 + (cur[i] % 10 - 1));
		}
		cur.clear();
		for (ll i = 0; i < tmp.size(); i++){
			lun.pb(tmp[i]); cur.pb(tmp[i]);
		}
		tmp.clear();
	}
	sort(lun.begin(), lun.end());
	ll k; cin >> k;
	cout << lun[k - 1] << endl;
}

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

typedef long long int ll;
ll powk(ll a, ll n){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i = 0;i < n;i++){
        cin >> a[i];
    }

    sort(a.begin(),a.end());

    for(ll i = 0;i < a.size() - 1;i++){
        if(a[i] == a[i + 1]){
            cout << "NO";

            return 0;
        }
    }

    cout << "YES";

    return 0;
}

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

using namespace std;

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

	Int l = 0, r = s.size() - 1;
	while (l + 1 < s.size() && s[l] == s[l+1]) { ++l; }
	while (r - 1 >= 0 && s[r] == s[r-1]) { --r; }

	Int cnt = 0;
	for (int i = l + 1; i < r; ++i) {
		if (s[i] == s[i - 1]) {
			s[i] = '#';
			++cnt;
		}
	}
	Int ans = cnt * K;

	Int N = s.size();
	if (l < r) {
		l += 1;
		r = s.size() - r;
		ans += (l / 2 + r / 2);
		if (s[0] == s.back()) {
			ans += ((l + r) / 2) * (K - 1);
		} else {
			ans += (l / 2 + r / 2) * (K - 1);
		}
	} else {
		ans = (N * K / 2);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

string S(int t){
    string res;
    int a=t/3600;
    if(a<10) res+='0';
    res+=to_string(a);
    res+=':';
    
    t%=3600;
    int b=t/60;
    if(b<10) res+='0';
    res+=to_string(b);
    res+=':';
    
    int c=t%60;
    if(c<10) res+='0';
    res+=to_string(c);
    
    return res;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        vector<vector<int>> A(N);
        for(int i=0;i<N;i++){
            vector<int> t(3);
            for(int j=0;j<3;j++) cin>>t[j];
            sort(all(t));
            
            do{
                for(int j=0;j<60;j++){
                    int a=(t[0]+j)%60,b=(t[1]+j)%60,c=(t[2]+j)%60;
                    
                    if(a%5!=b/12) continue;
                    
                    A[i].push_back((a/5)*3600+b*60+c);
                }
                
            }while(next_permutation(all(t)));
            
            sort(all(A[i]));
            A[i].erase(unique(all(A[i])),A[i].end());
        }
        
        pair<int,int> res={INF,INF};
        
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(i==j) continue;
                
                for(int a:A[i]){
                    for(int b:A[j]){
                        if(a>b) continue;
                        
                        bool ok=true;
                        for(int k=0;k<N;k++){
                            if(k==i||k==j) continue;
                            auto x=lower_bound(all(A[k]),a);
                            if(x==A[k].end()||*x>b) ok=false;
                        }
                        if(ok){
                            chmin(res,mp(b-a,a));
                        }
                    }
                }
            }
        }
        
        cout<<S(res.se)<<" "<<S(res.fi+res.se)<<endl;
    }
}



Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

ll modinv(ll a, ll m) {
  ll b = m;
  ll u = 1;
  ll v = 0;
  
  while (b > 0) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  
  u %= m;
  if (u < 0) u += m;
  return u;
}

int main() {
  int N;
  ll M;
  cin >> N >> M;
  
  map<int, ll> m;
  ll x = M;
  ll j = 2;
  while (j <= x) {
    if (x % j == 0) {
      x /= j;
      m[j]++;
    } else {
      j++;
    }
  }
  
  ll ans = 1;
  for (auto e : m) {
    int p = e.second;
    for (int j = 1; j <= p; j++) {
      ans = ans * ((p + N - j) % mod) % mod;
      ans = ans * modinv(j, mod) % mod;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256