akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<unistd.h>

using namespace std;
int main() {
        vector<string>VS{ "Opened by ","Closed by ","Unknown " };
        set<string>SS;
        int N;
        cin >> N;
        for( size_t i = 0; i < N; i++ ) {
                string S;
                cin >> S;
                SS.insert( S );
        }
        cin >> N;
        bool x = 0;
        for( size_t i = 0; i < N; i++ ) {
                string S;
                cin >> S;
                if( SS.end() == find( SS.begin(), SS.end(), S ) ) {
                        cout << VS[2] << S << endl;
                } else {
                        cout << VS[x] << S << endl;
                        x = 1 - x;
                }
        }
        sleep(1);
        return 0;
}

Measured memory_bytes: 3212
#include <cstdio>

int main(){
    int A, B, C, D;
    scanf("%d%d%d%d", &A, &B, &C, &D);
    if(A+B>C+D) printf("Left\n");
    else if(A+B<C+D) printf("Right\n");
    else printf("Balanced\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    ll n,k,i,j;
    cin>>n>>k;
    vector<ll> a(n);
    for(i=0;i<n;i++) cin>>a[i];
    sort(all(a));
    if(k>=n) cout<<0;
    else
    {
        ll sum = 0;
        for(i=0;i<n-k;i++) sum+=a[i];
        cout<<sum;
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;

int main(void) {
    int a, b, k;
    cin >> a >> b >> k;
    int t = 0;
    repeat_reverse_from_to (i, min(a, b), 1) {
        if (a % i == 0 and b % i == 0) {
            ++t;
            //dump(t); dump(i); el;
            if (t == k) {
                cout << i << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
""" AtCoder """

import collections

n = int(input())
v = list(map(int, input().split()))
a = []
b = []
for i in range(0, n, 2):
    a.append(v[i])
    b.append(v[i + 1])

aa = collections.Counter(a)
bb = collections.Counter(b)

ans = aa.most_common()[0][1] + bb.most_common()[0][1]

if aa.most_common()[0][0] == bb.most_common()[0][0]:
    if len(aa.most_common()) == 1:
        ans = aa.most_common()[0][1]
    elif len(bb.most_common()) == 1:
        ans = bb.most_common()[0][1]
    else:
        ans = max(aa.most_common()[1][1] + bb.most_common()[0][1], aa.most_common()[0][1] + bb.most_common()[1][1])

print(len(a) + len(b) - ans)


Measured memory_bytes: 20568
import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [-a for a in A]
heapq.heapify(A)
for _ in range(M):
  p = heapq.heappop(A)
  p = -p
  p //= 2
  p = -p
  heapq.heappush(A, p)
print(-sum(A))

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int a, b, c;cin >> a >> b >> c;
    string ans = a <= c && c <= b ? "Yes" : "No";
    cout << ans << endl;
    return 0;
}


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

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

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int N, A, B, C;
vector<int> L;

int dfs(int idx = 0, int a = 0, int b = 0, int c = 0) {
    if (idx == N) {
        if (a > 0 && b > 0 && c > 0) return abs(A - a) + abs(B - b) + abs(C - c) - 30;
        else return (1 << 30);
    }
    return min({
        dfs(idx + 1, a, b, c),
        dfs(idx + 1, a + L[idx], b, c) + 10,
        dfs(idx + 1, a, b + L[idx], c) + 10,
        dfs(idx + 1, a, b, c + L[idx]) + 10,
    });
}

int main() {
    cin >> N >> A >> B >> C;
    L.resize(N);
    REP(i, 0, N) cin >> L[i];
    cout << dfs() << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        int max = sc.nextInt();

        main:
        for(int i = 1; i <= max; i++){
            //multiples of 3
            if(i % 3 == 0){
                sb.append(" " + i);
                continue main;
            }

            int keta = (int)Math.log10(i);
            int tmp = i;

            for(int j = keta; j >= 0; j--){
                int zeros = (int)Math.pow(10 , j);
                int kurai = tmp/zeros;
                
                if(kurai == 3){
                    sb.append(" " + i);
                    continue main;
                }

                tmp -= zeros*kurai;
            }
            
        }

        System.out.println(sb);
    }
    
}

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

int main(){
  int A, B;
  cin >> A >> B;

  if (A == B){
    cout << 2 * A << endl;
  }
  else if (A > B){
    cout << 2 * A - 1 << endl;
  }
  else
  {
    cout << 2 * B - 1 << endl;
  }
  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 n, s = 0;
    std::cin >> n;
    std::vector<i64> a(n);
    for (auto &e : a) {
        std::cin >> e;
        s += e;
    }
    i64 m = n * (n + 1) / 2;
    if (s % m) {
        std::cout << "NO" << std::endl;
        return 0;
    }
    i64 k = s / m;
    for (int i = 0; i < n; i++) {
        auto d = a[(i + 1) % n] - a[i] - k;
        if (d > 0 || d % n != 0) {
            std::cout << "NO" << std::endl;
            return 0;
        }
    }

    std::cout << "YES" << std::endl;

    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

vector<ll> vec;
vector<ll> sum, sum2;

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

	if(K > N){
		cout << 1 << endl;
		return 0;
	}

	vec.resize(N+1);
	for(ll i = 0; i < N+1; i++){
		vec[i] = i; 
	}
	
	ll front_sum = 0;
	rep(i,K){
		front_sum = (front_sum + vec[i]) % MOD7;
	}
	ll back_sum = 0;
	rep(i,K){
		back_sum = (back_sum + vec[N-i]) % MOD7;
	}
	ll total = (back_sum - front_sum + 1) % MOD7;

	for(int i = K; i <= N; i++){
		front_sum = (front_sum + vec[i]) % MOD7;
		back_sum = (back_sum + vec[N-i]) % MOD7;
		total = (total + (back_sum - front_sum + 1 + MOD7) %MOD7) %MOD7 ;
		//cout << total << endl;
	}
	cout << total << endl;

}

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

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

    bool can=false;
    for(int i=0;i<n-2;i++){
        if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2]) can=true;
    }

    if(can) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
int main() { 
  int N;
  cin >> N;
  int a = N/1000;
  int b = (N-1000*a) / 100;
  int c = (N-1000*a-100*b) / 10;
  int d = N%10;
  
  if(a==b&&b==c||b==c&&c==d){
    cout << "Yes" << endl;}
  else{
  cout << "No" << endl;}
}

Measured memory_bytes: 256
import sys
import numpy as np

input = sys.stdin.readline

N = int(input())
A = np.fromstring(input(), dtype=int, sep=' ')
A = A[A % 2 == 0]
if np.all((A % 3 == 0) | (A % 5 == 0)):
    print('APPROVED')
else:
    print('DENIED')



Measured memory_bytes: 12488
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  abc=sort(pM(split(readline())))
  println(abc[3]%2==0 ? 0 : abc[1]*abc[2])
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

Measured memory_bytes: 114924
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanLines)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	for i := 1; i < n+1; i++ {
		if i%3 == 0 {
			fmt.Printf(" %d", i)
			continue
		}
		if strings.Contains(strconv.Itoa(i), "3") {
			fmt.Printf(" %d", i)
		}
	}
	fmt.Println()
}



Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
using namespace std;

#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=21,P=1e9+7;

int mul(int a,int b){ return 1ll*a*b%P; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
void upd(int &a,int b){ a=add(a,b); }

bool del[N][N][2];
int ans,n,m,q,f[N][1<<N],nxt[1<<N][N];

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);
#endif
	read(n),read(m),read(q); 	
	--n;
	rep(k,1,q){
		int a,b,c;
		read(a),read(b),read(c); 
		del[a][b-1][!c]=1;
	}
	lop(s,0,(1<<n)){
		lop(j,0,n){
			if((s>>j&1)==0){
				int k=j,t=s;
				for(;k<n&&!((s>>k)&1);++k); 
				if(k<n)t-=(1<<k);
				nxt[s][j]=t+(1<<j); 
			}
		}
	}
	f[n][0]=1;
	rep(i,1,m){
		memcpy(f[0],f[n],sizeof(f[0])); 
		lop(j,0,n){
			int nj=j+1;
			mem(f[nj],0); 
			lop(s,0,(1<<n)){
				rep(num,0,1)if(!del[i][j][num]){
					if(((s>>j&1)==1)&&!num)continue;
					int t=(s>>j&1)==num?s:nxt[s][j];
					upd(f[nj][t],f[j][s]); 
				}
			}
		}
	}
	lop(s,0,(1<<n))ans=add(ans,f[n][s]); 
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 211200
N, M, K = map(int, input().split())
flag = False

for i in range(N + 1):
    for j in range(M + 1):
        black = N*j + M*i - i*j*2
        if K == black:
            flag = True
            break

if flag:
    print("Yes")
else:
    print("No")

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

int main()
{
    int n;
    cin >> n;
    int a[n];
    
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int j = n-1; j >= 0; j--) {
        if(!j) {
            cout << a[j] << endl;
        }else {
            cout << a[j] << ' ';
        }
    }
    return 0;
    
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


int main() {
  ll n,k;cin >> n >> k;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  ll moremin=0;
  ll cnt=0;
  rep(i,n){
    rep(j,n){
      if(i<j&&a[i]>a[j])cnt++;
      if(a[i]>a[j])moremin++;
    }
  }
  
  ll ans=0;
  ans+=cnt*k%1000000007;
  if(k%2==0)
  ans+=(moremin%1000000007)*((k/2)*(k-1)%1000000007);
  else ans+=(moremin%1000000007)*((k)*((k-1)/2)%1000000007);
  cout << ans%1000000007 << endl;
}

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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

const int MAXN = 100;
const LL INF = 0x7fffffffffffffff;
int n, m;
LL ans, v[MAXN + 5], f[MAXN + 5][MAXN + 5], g[MAXN + 5][MAXN + 5];

int main() {
	read(n), read(m);
	for (int i = 1; i <= n; ++i) read(v[i]);
	for (int i = 1; i <= min(n, m); ++i)
		for (int j = 0; j <= i && i + j <= m; ++j) {
			f[i][j] = -INF;
			if (j >= 1) f[i][j] = max(f[i][j], f[i - 1][j - 1]);
			if (j <= i - 1) f[i][j] = max(f[i][j], f[i - 1][j] + v[i]);
		}
	reverse(v + 1, v + n + 1);
	for (int i = 1; i <= min(n, m); ++i)
		for (int j = 0; j <= i && i + j <= m; ++j) {
			g[i][j] = -INF;
			if (j >= 1) g[i][j] = max(g[i][j], g[i - 1][j - 1]);
			if (j <= i - 1) g[i][j] = max(g[i][j], g[i - 1][j] + v[i]);
		}
	for (int i = 0; i <= min(n, m); ++i)
		for (int j = 0; j <= i; ++j)
			for (int k = 0; k <= min(n, m); ++k)
				for (int l = 0; l <= k; ++l) {
					if (i + j + k + l > m || i + k > n) break;
					ans = max(ans, f[i][j] + g[k][l]);
				}
	write(ans);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 384
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
tmp = [0 for _ in range(N)]
# bagに入る要素が多すぎてエラーが出ている

spot = 1
road = [1]
tmp[0] = 1
for _ in range(K):
    n_s = A[spot-1]
    if not tmp[n_s-1] == 1:
        road.append(n_s)
        tmp[n_s-1] = 1
        spot = n_s
    else:
        spot = n_s
        break

till_loop = road.index(spot)
# print(till_loop)
loop = road[till_loop:]
# print(loop)
cycle_len = len(road) - road.index(spot)
# print(cycle_len)
answer = loop[(K-till_loop) % cycle_len]

print(answer)


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

// types
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<pll> vpl;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

const ull B = 100000007;
bool contain(string a, string b){
  ll al = a.size(), bl = b.size();
  if(al > bl)
    return false;

  ull t = 1;
  REP(i, al)
    t *= B;
  ull ah = 0, bh = 0;
  REP(i, al)
    ah = ah*B + a[i];
  REP(i, al)
    bh = ah*B + b[i];

  for(ll i = 0; i + al <= bl; i++){
    if(ah == bh)
      return true;
    if(i+al < bl)
      bh = bh*B + b[i+al]-b[i]*t;
  }
}

struct RollingHash{
  static const ll base1 = 1007, base2 = 1009;
  static const ll mod1 = 1e9+7, mod2 = 1e9+9;
  vll hash1, hash2, power1, power2;
  RollingHash(string s){
    ll n = s.size();
    hash1.assign(n+1, 0);
    hash2.assign(n+1, 0);
    power1.assign(n+1, 1);
    power2.assign(n+1, 1);
    for(int i = 0; i<n; i++){
      hash1[i+1] = (hash1[i]*base1+s[i])%mod1;
      hash2[i+1] = (hash2[i]*base2+s[i])%mod2;
      power1[i+1] = (power1[i]*base1)%mod1;
      power2[i+1] = (power2[i]*base2)%mod2;
    }
  }

  inline pair<ll, ll> get(ll l, ll r){
    ll res1 = hash1[r] - hash1[l]*power1[r-l]%mod1;
    if(res1<0)
      res1 += mod1;
    ll res2 = hash2[r] - hash2[l]*power2[r-l]%mod2;
    if(res2<0)
      res2 += mod2;
    return {res1, res2};
  }
};

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

  ll n;
  cin >> n;
  string s;
  cin >> s;

  RollingHash rh(s);
  ll ans = 0;
  REP(l, n){
    for(ll r=l+1; r<n; r++){
      ll ok = 0;
      ll ng = n/2+1;
      //cout << l << ":" << r << endl;
      while(ng-ok>1){
        ll mid = (ok+ng)/2;
        if(rh.get(l,l+mid) == rh.get(r, r+mid))
          ok = mid;
        else
          ng = mid;
      }
      //cout << ok << endl;

      ans = max(ans, min(ok, r-l));
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();

		for (int i = 0; i < n; i++) {
			x = Math.max(x, sc.nextInt());
		}
		for (int i = 0; i < m; i++) {
			y = Math.min(y, sc.nextInt());
		}

		System.out.println(x < y ? "No War" : "War");

		sc.close();
	}

}


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

int main() {
        int N, M;
        cin >> N >> M;
        vector<int> x(M), y(M);
        for(int i = 0; i < M; ++i) {
                cin >> x[i] >> y[i];
                x[i]--;
                y[i]--;
        }
        vector<bool> red(N, false);
        vector<int> ball(N, 1);
        red[0] = true;

        for(int i = 0; i < M; ++i) {
                if (!ball[x[i]]) continue;
                if (red[x[i]]) {
                        if(ball[x[i]] == 1) {
                                red[x[i]] = false;
                                red[y[i]] = true;
                        } else {
                                red[y[i]] = true;
                        }
                }
                ball[x[i]]--;
                ball[y[i]]++;
        }

        int result = 0;
        for(int i = 0; i < N; ++i) {
                if (ball[i] && red[i]) {
                        result++;
                }
        }
        cout << result << endl;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+ 5;
const int M = 1e7 + 5;
const int INF=1e9+7;
const int mod=1e9+7;
const double eps=1e-9;
typedef long long ll;
typedef pair<int,int>pi;

vector <ll> solve(vector <ll> a){
    ll n = a.size();
    vector <ll> pref(n+2, 0);
    for(int i = 0; i < n; i++){
        int l = max(0LL,i-a[i]);
        int r = min(n-1LL, i+a[i]);
        pref[l]++;
        pref[r+1]--;
    }
    for(int i = 0; i < n; i++){
        if(i) pref[i] += pref[i-1];
        a[i] = pref[i];
    }
    return a;
}

int check(vector <ll> a){
    int n = a.size();
    for(int i = 0; i < n; i++){
        if(a[i] != n) return 0;
    }
    return 1;
}


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

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

    while(k--){
          a = solve(a);
          if(check(a)) break;
    }
    for(auto x:a) cout << x << " ";
}

Measured memory_bytes: 8012
cols = int(input())
mat = [[int(tok) for tok in input().split()] for _ in range(2)]

for i in range(1, cols):
  mat[0][i] += mat[0][i - 1]
  
mat[1][0] += mat[0][0]
for i in range(1, cols):
  mat[1][i] += max(mat[1][i - 1], mat[0][i])
  
print(mat[-1][-1])

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 567890;
char s[MAXN];
set<int> st[26];

int main() {
    int N;
    scanf("%d", &N);
    scanf("%s", s + 1);
    for (int i = 1; i <= N; i++) {
        int cur = s[i] - 'a';
        st[cur].insert(i);
    }
    for (int i = 0; i < 26; i++)
        st[i].insert(N + 1);
    int Q;
    scanf("%d", &Q);
    for (int i = 0; i < Q; i++) {
        int cmd;
        scanf("%d", &cmd);
        if (cmd == 1) {
            int idx;
            char c;
            scanf("%d %c", &idx, &c);
            st[s[idx] - 'a'].erase(idx);
            st[c - 'a'].insert(idx);
            s[idx] = c;
        } else {
            int l, r;
            scanf("%d %d", &l, &r);
            int ans = 0;
            for (int i = 0; i < 26; i++) {
                auto it = *st[i].lower_bound(l);
                if (it <= r) ans++;
            }
            printf("%d\n", ans);
        }
    }
    return 0;
}


Measured memory_bytes: 26240
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		WriteLine(I[1] + Min(I[0] + I[1] + 1, I[2]));
	}
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S; cin >> S;
  vector<string> s = {"dream",  "eraser", "erase"};
  bool j1 = true;
  for(int i = 0; i < S.size();) {
    bool j2 = false;
    for(int j = 0; j < 3; j++) {
      string t = s.at(j);
      if(S.substr(i, t.size()) == t) {
        j2 = true;
        i += t.size();
        if(j == 0) {
          if(i == S.size()) break;
          if(S.substr(i, 3) == "ere" || S.substr(i, 3) == "erd" ||
            (S.size() - i == 2 && S.substr(i, 2) == "er")) i += 2;
        }
        break;
      }
    }
    if(!j2) {
      j1 = false;
      break;
    }
  }
  cout << (j1 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 512
S = input()
ans = [0, 0]

for i in range(len(S)):
    if (i % 2 == 0 and S[i] != '1') or (i % 2 == 1 and S[i] != '0'):
        ans[0] += 1
    if (i % 2 == 0 and S[i] != '0') or (i % 2 == 1 and S[i] != '1'):
        ans[1] += 1
    
print(min(ans))


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

int main()
{
  int64_t N, a, b;
  cin >> N;
  vector<int64_t> A(N), B(N);
  vector<pair<int64_t, int64_t>> vp(N);
  for (int i = 0; i < N; i++)
  {
    cin >> a >> b;
    A.at(i) = a * 2;
    B.at(i) = b * 2;
    vp.at(i) = make_pair(a * 2, b * 2);
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  int64_t mi, ma;
  if (N % 2)
  {
    mi = A.at((N - 1) / 2), ma = B.at((N - 1) / 2);
  }
  else
  {
    mi = (A.at(N / 2 - 1) + A.at(N / 2)) / 2;
    ma = (B.at(N / 2 - 1) + B.at(N / 2)) / 2;
  }
  int64_t l1 = 0, r1 = mi;
  while (r1 - l1 > 1)
  {
    int64_t m = (l1 + r1) / 2;
    int64_t s = 0, in = 0, l = 0;
    for (int i = 0; i < N; i++)
    {
      if (vp.at(i).first <= m && m <= vp.at(i).second)
        in++;
      else if (m < vp.at(i).first)
        l++;
      else
        s++;
    }
    if (in > 0 && s == l)
      r1 = m;
    else
      l1 = m;
  }
  int64_t l2 = ma, r2 = 2000000010;
  while (r2 - l2 > 1)
  {
    int64_t m = (l2 + r2) / 2;
    int64_t s = 0, in = 0, l = 0;
    for (int i = 0; i < N; i++)
    {
      if (vp.at(i).first <= m && m <= vp.at(i).second)
        in++;
      else if (m < vp.at(i).first)
        l++;
      else
        s++;
    }
    if (in > 0 && s == l)
      l2 = m;
    else
      r2 = m;
  }
  if (N % 2)
  {
    cout << (l2 / 2) - (r1 / 2) + 1 << endl;
  }
  else
  {
    cout << l2 - r1 + 1 << endl;
  }
}

Measured memory_bytes: 9516
import kotlin.math.*

fun str() = readLine()!!
fun int() = readLine()!!.toInt()

fun main() {
	val blue = Array(int()) {str()}
	val red = Array(int()) {str()}

	val r = blue.map {b->
		blue.count {b==it}-red.count {b==it}
	}.max()!!
	println(max(r,0))
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

ll func(ll n){
    if(n < 2) return 1;
    else return n * func(n-2);
}

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

    if(N%2){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    ll x = 5;
    while(1){
        ll add = N / x;
        if(add == 0)
            break;
        ans += add/2;
        x *= 5;
    }

    cout << ans << endl;
    return 0;
}


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

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

int main() {
  int H,W; cin>>H>>W;
  pair<int, int> start,goal;
  cin>>start.first>>start.second;
  cin>>goal.first>>goal.second;
  start.first--;start.second--;goal.first--;goal.second--;
  vector<string> S(H);
  for(int i=0; i<H; ++i) cin>>S[i];
  // 二度塗りでどうだ
  // 最初に歩きパターンを見てから、次にワープパターンを見る
  vector<vector<int>> Graph(H,vector<int>(W,-1));
  vector<vector<bool>> isSeen(H,vector<bool>(W,false));
  int count = 0;
  queue<pair<int,int>> que,que2;
  Graph[start.first][start.second]=count;
  que.push(start);
  isSeen[start.first][start.second]=true;
  while(!que.empty() || !que2.empty()) {
    while(!que.empty()) {
      auto v = que.front();
      que.pop();
      que2.push(v);
      for(int dir=0; dir<4; ++dir) {
        int nh=v.first+dx[dir];
        int nw=v.second+dy[dir];
        if(nh<0||nh>=H||nw<0||nw>=W) continue;
        if(S[nh][nw]=='#') continue;
        if(!isSeen[nh][nw]) {
          isSeen[nh][nw]=true;
          Graph[nh][nw]=count;
          que.push({nh,nw});
        }
      }
    }
    count++;
    while(!que2.empty()) {
      auto v = que2.front();
      que2.pop();
      for(int i=-2; i<=2; ++i) {
        for(int j=-2; j<=2; ++j) {
          int nh=v.first+i;
          int nw=v.second+j;
          if((abs(i)<=1 && j==0) || (abs(j)<=1 && i==0)) continue;
          else {
            if(nh<0||nh>=H||nw<0||nw>=W) continue;
            if(S[nh][nw]=='#') continue;
            if(!isSeen[nh][nw]) {
              Graph[nh][nw]=count;
              isSeen[nh][nw]=true;
              que.push({nh,nw});
            }
          }
        }
      }
    }
  }
  cout << Graph[goal.first][goal.second] << endl;
}


Measured memory_bytes: 9628
#include<stdio.h>

int main(){
    int a,b,c,e,i;

    scanf("%d %d %d", &a,&b,&c);
    for(i=a;i<=b;i++){
        if(c%i==0){
            e++;
        }
    }
    printf("%d\n",e);
    
    return 0;
}




Measured memory_bytes: 2148
n,k = map(int, input().split())
p = [int(e) for e in input().split()]
s = sum(p[0:k])
max = s
for i in range(n-k):
  s = s - p[i] + p[i+k]
  if max < s:
    max = s
    
ex = (max+k)/2.0
print(ex)


Measured memory_bytes: 25188
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;
ll INF=1e10;

int main(){
    string s,t; cin>>s>>t;
    ll ans=0;
    rep(i,s.size()){
        if(s[i]!=t[i])ans++;
    }
    cout<<ans<<endl;
}





























































































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

int main(){
  double ans;
  double l;
  cin >> l;
  ans = l*l*l/27;
  cout << setprecision(17) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  string s;
  cin >> s;
  int n = s.size();
  int sum = 0;
  REP(i, n) {
    sum += s[i] - '0';
    if (sum >= 9) sum %= 9;
  }
  if (sum == 0) cout << "Yes" << endl;
  else {
    cout << "No" << endl;
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3708
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int M1 = 0, D1 = 0, M2 = 0, D2 = 0;
	scanf("%d %d", &M1, &D1);
	scanf("%d %d", &M2, &D2);
	if (M1 == M2) {
		printf("0\n");
	} else {
		printf("1\n");
	}
    return 0;
}


Measured memory_bytes: 256
require 'prime'
P = Hash.new
def prime_division(i)
  Prime.prime_division(i).each{|k, v|
    P[k] = 0 if !P.key?(k)
    P[k] += v
  }
end
def prime_division_reverse(i)
  return i if P.size == 0
  ret = 1
  Prime.prime_division(i).each{|k, v|
    if !P.key?(k) then
      ret *= (k ** v)
    elsif P[k] <= v then
      ret *= (k ** (v - P[k]))
      P.delete(k)
    else
      P[k] -= v
    end
  }
  ret
end

N, M, K = gets.chomp.split(" ").map(&:to_i);

CD = 10 ** 9 + 7

s = 0
(0...M).each{|j|
  (0...N).each{|i|
    if j == 0 then
      s += (i + j) * (N - i) * (M - j)
    else
      s += (i + j) * (N - i) * (M - j) * (i == 0 ? 1 : 2)
    end
  }
}

a = N * M - 2
b = K - 2
c = 1
b = a - b if a < 2 * b
if b != 0 then
  bb = b.downto(1).to_a
  aa = (a-b+1..a).to_a
  c = 1
  #r = a / b
  (0...b).each{|i|
    r = (a - b) / bb[i] + 1
    break if r > 20
    while(r * bb[i] < a)
      j = r * bb[i]
      if j == aa[j - (a-b+1)]
        aa[j - (a-b+1)] = r
        bb[i] = 1
        break
      end
      r += 1
    end
  }
  bb.delete(1)
  
  bb.each{|i|
    prime_division(i)
  }

  aa.each{|i|
    c *= prime_division_reverse(i)
    c %= CD if c > CD && P.size == 0
  }
end

puts (c * (s % CD)) % CD


Measured memory_bytes: 9272
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define SC(x) scanf("%d",&x);
#define pr(x)  cout << x << endl;
#define mem(arr,v) memset(arr,v,sizeof arr);
#define bug(x) cout << "#x = " << x <<endl;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
typedef long long ll;
using namespace std;
int a[maxn];
stack<int> s[2];

bool dfs(int pos) {
//	bug(pos)
	if(pos == 10) return true;
	int cur = a[pos];
	for(int i = 0; i < 2 ; i++) {
		if(s[i].empty() || s[i].top() <= cur) {
			s[i].push(cur);
			if(dfs(pos + 1)) return true;
			s[i].pop();
		}
	}
	return false;
}

int main() {
	int t;
	cin >> t;
	while(t--) {
		for(int i =0 ; i < 2; i++)
			while(!s[i].empty())
				s[i].pop();
		for(int i = 0 ; i < 10 ; i++)
			cin >> a[i];
		if(dfs(0))
			puts("YES");
		else
			puts("NO");
	}
}

Measured memory_bytes: 3080
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

public class Main {
    public static void main(String[] args){
        try{
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            int n=Integer.parseInt(br.readLine());
            String ss=br.readLine();
            char[] c=ss.toCharArray();
            long ans=0;
            long[][] arr=new long[3][n];
            long r=0,g=0,b=0;
            HashSet<Integer> R=new HashSet<>(),G=new HashSet<>(),B=new HashSet<>();
            for(int i=n-1;i>=0;i--){
                if(c[i]=='R'){
                    r++;
                    R.add(i);
                }else if(c[i]=='G'){
                    g++;
                    G.add(i);
                }else{
                    b++;
                    B.add(i);
                }
                arr[0][i]=r;
                arr[1][i]=g;
                arr[2][i]=b;
            }
            for(int i=0;i<n;i++){
                for(int j=i+1;j<n-1;j++){
                    if(c[i]==c[j]){
                        continue;
                    }
                    int u=j+(j-i);
                    if((c[i]=='R' && c[j]=='G') || (c[i]=='G' && c[j]=='R')){
                        ans+=arr[2][j+1];
                        if(B.contains(u)){
                            ans--;
                        }
                    }else if((c[i]=='R' && c[j]=='B') || (c[i]=='B' && c[j]=='R')){
                        ans+=arr[1][j+1];
                        if(G.contains(u)){
                            ans--;
                        }
                    }else if((c[i]=='G' && c[j]=='B') || (c[i]=='B' && c[j]=='G')){
                        ans+=arr[0][j+1];
                        if(R.contains(u)){
                            ans--;
                        }
                    }
                }
            }

            System.out.println(ans);

        }catch(Exception e){
            System.out.println("KKKK "+e.getMessage());
        }
    }
    static int gcd(int a,int b){
        if(a==0){
            return b;
        }
        if(b==0){
            return a;
        }
        if(a>b){
            return gcd(a%b,b);
        }
        return gcd(a,b%a);

    }
}


Measured memory_bytes: 54080
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int n, k; cin >> n >> k;
  if (k == 1) cout << 0 << endl;
  else cout << n-k << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <cstring>
#include <string>
#include <cctype>
#include <iostream>
using namespace std;

char f[16][16];
int fx,fy,N;
int dx[] = {0, 0, -1, 1, 0};
int dy[] = {0, -1, 0, 0, 1};

class Ghost
{
public:
	int x[3],y[3],c;
	bool r;
	
	Ghost(int* i, int* j, int c, bool r)
	:r(r),c(c)
	{
		for(int k=0; k<3; k++)
		{
			x[k]=i[k];
			y[k]=j[k];
			
		}
	}
};

bool move(int x, int y, int p)
{
	if(p>=N) return true;
	if(x<0||y<0||x>=fx||y>=fy) return false;
	if(f[x][y]=='#') return false;
	
	return true;
}

bool crash(int* x, int* y, int* gx, int* gy, int p)
{
	if(p<N) return false;
	for(int i=0; i<p; i++)
	for(int j=i+1; j<p; j++)
	{
		if(x[i]==x[j]&&y[i]==y[j]) return true;
		if(x[i]==gx[j]&&y[i]==gy[j]&&gx[i]==x[j]&&gy[i]==y[j]) return true;
	}
	return false;
}

unsigned char h[256][256][256][2];

int main()
{	
	while(scanf("%d%d%d",&fx,&fy,&N), (fx||fy||N))
	{
		int sx[3]={0},sy[3]={0},gx[3]={0},gy[3]={0};
		memset(h,0,sizeof(h));
			
		string s;
		
		getchar();
		for(int i=0; i<fy; i++)
		{
			getline(cin, s);
			for(int j=0; j<fx; j++)
			{
				if(islower(s[j]))
				{
					sx[s[j]-'a']=j;
					sy[s[j]-'a']=i;
				}
				if(isupper(s[j]))
				{
					gx[s[j]-'A']=j;
					gy[s[j]-'A']=i;
				}
				
				f[j][i]=s[j];
			}
		}
		
		queue<Ghost> q;
		q.push(Ghost(sx,sy,1,0));
		q.push(Ghost(gx,gy,1,1));
		
		int th[3];
		for(int l=0; l<3; l++)
		{
			th[l]=(sx[l]<<4)+sy[l];
		}
		h[th[0]][th[1]][th[2]][0]=1;
		for(int l=0; l<3; l++)
		{
			th[l]=(gx[l]<<4)+gy[l];
		}
		h[th[0]][th[1]][th[2]][1]=1;
		
		while(!q.empty())
		{
			Ghost g=q.front(); q.pop();
			
			int th[3];

			for(int l=0; l<3; l++)
			{
				th[l]=(g.x[l]<<4)+g.y[l];
			}

			if(h[th[0]][th[1]][th[2]][!g.r])
			{
				printf("%d\n", g.c+h[th[0]][th[1]][th[2]][!g.r]-1);
				break;
			}
			
			
			int tx[3],ty[3];
			for(int i=0; i<3; i++)
			{
				tx[i]=g.x[i];
				ty[i]=g.y[i];
				
			}
			
			for(int i=0; i<5; i++)
			{
				tx[0]=g.x[0]+dx[i], ty[0]=g.y[0]+dy[i];
				if(!move(tx[0],ty[0],0))
				{
					tx[0]=g.x[0];
					ty[0]=g.y[0];
					continue;
				}
				
				for(int j=0; j<(N>1?5:1); j++)
				{
					tx[1]=g.x[1]+dx[j], ty[1]=g.y[1]+dy[j];
					if(N>=2)
					{
						if(!move(tx[1],ty[1], 1) || (crash(tx,ty,g.x,g.y,2)))
						{
							tx[1]=g.x[1];
							ty[1]=g.y[1];
							continue;
						}
					}
					
					for(int k=0; k<(N>2?5:1); k++)
					{
						tx[2]=g.x[2]+dx[k], ty[2]=g.y[2]+dy[k];
						if(N>=3)
						{
							if(!move(tx[2],ty[2], 2) || (crash(tx,ty,g.x,g.y,3)))
							{
								tx[2]=g.x[2];
								ty[2]=g.y[2];
								continue;
							}
						}
						for(int l=0; l<3; l++)
						{
							th[l]=(tx[l]<<4)+ty[l];
						}
	
						if(h[th[0]][th[1]][th[2]][g.r])
						{
							tx[2]=g.x[2];
							ty[2]=g.y[2];
							continue;
						}
						h[th[0]][th[1]][th[2]][g.r]=g.c;
					
						
						q.push(Ghost(tx, ty, g.c+1,g.r));
					}
				}
			}
		}
	}
}

Measured memory_bytes: 35000
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

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


#define X real()
#define Y imag()
typedef complex<double> P;

int main(){
	
	typedef pair<int,string> pis;
	vector<pis> a;
	vector<pis> b;
	
	map<string,int> m;
	
	string str;
	while(cin>>str){
		a.push_back( pis((int)str.size(),str) );
		m[str]++;
	}
	
	map<string,int>::iterator it=m.begin();
	while(it!=m.end()){
		b.push_back(pis(-it->second,it->first));
		it++;
	}
	
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	
	cout<<b[0].second<<" "<<a[a.size()-1].second<<endl;
	
	
}

Measured memory_bytes: 1208
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N), B(N);
	for(int i = 0; i < N; ++i) cin >> A[i];
	for(int i = 0; i < N; ++i) cin >> B[i];
	int cnt = 0;
	function<void(int, int, int, int)> dfs = [&](int la, int ra, int lb, int rb) {
		if(la == ra) return;
		int sep = find(B.begin(), B.end(), A[la]) - B.begin();
		dfs(la + 1, la + 1 + (sep - lb), lb, sep);
		dfs(la + 1 + (sep - lb), ra, sep + 1, rb);
		cout << A[la] << (++cnt != N ? ' ' : '\n');
	};
	dfs(0, N, 0, N);
	return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define index ffff
using namespace std;

int d[10],ans;
int index[10];
int M;

int cal(int a,int b,int c){
  
  return (index[a]+index[b]+index[c])%M;
  
}


bool check(){
  
  M=index[9];
  
  int X=cal(0,1,2);
  
  if(X!=cal(3,4,5))return false;
  
  if(X!=cal(6,7,8))return false;

  if(X!=cal(0,3,6))return false;

  if(X!=cal(1,4,7))return false;
  
  if(X!=cal(2,5,8))return false;
  
  if(X!=cal(0,4,8))return false;
  
  if(X!=cal(2,4,6))return false;

  return true;
  
}

void solve(){
  

  for(int i=0;i<10;i++) index[i]=i+1;


  do{
    int f=0;
    
    for(int i=0;i<10;i++)
      if(d[i]!=0&&d[i]!=index[i]){
	f=1;
	break;
      }

    if(f)continue;
    
    if(check())ans++;
        
  }while(next_permutation(index,index+10));
  
}


int main(){

  while(1){
    
    for(int i=0;i<10;i++) cin>>d[i];
    
    if(d[0]<0)break;

    ans=0;
    
    solve();
    
    cout<<ans<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3016
#include<stdio.h>

int main(void){
    
    int N,D,look;

    scanf("%d %d",&N,&D);

    look = 2*D+1;

    if(N % look == 0){
        printf("%d",N/look);
    }else{
        printf("%d",(N/look)+1);
    }
    return 0;
}

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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

int main(){
  int x,y;
  cin >> x >> y;
  cout << x + (y/2) << endl;
}


Measured memory_bytes: 256
/*---> 11 May 2020 <--- > 02:02:52 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=2e5+5;
int adj[N],dep[N],vis[N];
int32_t main(){__
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>adj[i];
	int cur=1,here=0;
	while(!vis[cur] && k>0){
		dep[cur]=here++;
		vis[cur]=1;
		cur=adj[cur];
		k--;
	}
	if(k==0){
		return cout<<cur<<"\n",0;
	}
	int cl=here-dep[cur];
	if(cl==0){
		return cout<<cur<<"\n",0;
	}
	k%=cl;
	while(k>0){
		cur=adj[cur];
		k--;
	}
	cout<<cur<<"\n";
return 0;
}

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

using namespace std;

int main(){

	int a,b;
	char op;


	while (1){
		cin >> a >> op >> b;
		if (op == '?') break;

		switch (op)
		{
		case '+':
			cout << a + b << endl;
			break;
		case '-':
			cout << a - b << endl;
			break;
		case '*':
			cout << a * b << endl;
			break;
		case '/':
			cout << a / b << endl;
			break;
		default:
			break;
		}
	}

	return 0;
}

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

using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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 max_len;
struct DirectedGraph{
    int V;

    vector<vector<int>> to;
    vector<vector<int>> from;

    vector<int> vs;
    vector<int> depth;
    vector<bool> used;
    vector<int> cmp;

    void dfs(int v){
        used[v]=true;
        for(auto t:to[v]) if(!used[t]) dfs(t);
        vs.push_back(v);//帰りがけ
    }
    //k:始点,rdfsがkに戻る→強連結成分
    int r_dfs(int v,int k){
        int ret=0;
        used[v]=true;
        cmp[v]=k;
        for(const auto t:from[v]){
            if(!used[t]) r_dfs(t,k);
            depth[v]=max(depth[v],depth[t]+1);
        }
    }
    DirectedGraph(int V) : V(V),
        to(vector<vector<int>>(V)),
        from(vector<vector<int>>(V)),
        cmp(vector<int>(V)),
        depth(vector<int>(V))
        {}
    
    void add_edge(int from_,int to_){
        to[from_].push_back(to_);
        from[to_].push_back(from_);
    }


    //強連結成分:任意の2頂点を行き来できる部分グラフ
    //          1点だけのも競連結成分
    //順方向帰りがけdfsと逆方向行き止まりまでdfs
    //強連結成分分解O(|V|+|E|)
    int scc_num=-1;
    //scc_num:強連結成分の個数を返す
    int scc(){
        used=vector<bool>(V,false);
        vs.clear();
        for(int v=0;v<V;v++) if(!used[v]) dfs(v);
        used=vector<bool>(V,false);
        scc_num=0;
        for(int i=vs.size()-1;i>=0;i--)if(!used[vs[i]]){
            max_len=max(max_len,r_dfs(vs[i],scc_num++));
        }
        return scc_num;
    }

    bool isCyclic(){
        //強連結成分が全部1点だけのものであれば
        //強連結成分の数は点数と一致し、閉路はない
        return (scc_num!=V);
    }

    //sccの後潰してトポロジカル順序のグラフを作る
    //デバッグとかしてないし試したことない知らん
    DirectedGraph makeTopologicalGraph(){
        DirectedGraph TG(scc_num);
        rep(s,V) for(auto t:to[s]){
            if(cmp[s]!=cmp[t]) TG.add_edge(cmp[s],cmp[t]);
        }
        return TG;
    }
};


int main(){
    int n,m;
    cin>>n>>m;
    DirectedGraph g(n);

    rep(i,m){
        int x,y;
        cin>>x>>y;
        x--,y--;
        g.add_edge(x,y);
    }
    int s=g.scc();

    cout<<*max_element(ALL(g.depth))<<endl;
    return 0;
}


Measured memory_bytes: 13696