akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
int main (){
	char kataA[11];
	char kataB[11];
	char kataC[11];
	
	scanf("%s %s %s", &kataA, &kataB, &kataC);
	
	int panjangA = strlen (kataA);
	int panjangB = strlen(kataB);
	
	if(kataA[panjangA-1] == kataB[0] && kataB[panjangB-1] == kataC[0]){
		puts("YES");
	}
	else{
		puts("NO");
	}
	
	return 0;
}

Measured memory_bytes: 1604
object Main extends App {
  val sc = new java.util.Scanner(System.in) 
  var n = sc.nextInt()
  var x = sc.nextInt()
  sc.useDelimiter("\n")
  val a = sc.next().split(" ").map(_.toInt).toList.sorted
  
  def calc (x: Int, a: List[Int], acc: Int): Int = {
    a match {
      case h::Nil => {
        if (x - h == 0) {
          acc + 1
        } else {
          acc
        }
      }
      case h::t => {
        if (x >= h) {
          calc(x-h, t, acc+1)
        } else {
          acc
        }
      }
    }
  }
  println(calc(x, a, 0))
}

Measured memory_bytes: 55520
#include <cstdio>
#include <cstring>

const int MN = 105;

int N;
char s[MN], t[MN];

int main() {
	scanf("%d%s%s", &N, s + 1, t + 1);
	for (int i = N + 1; i >= 1; --i)
		if (!strncmp(t + 1, s + N - i + 2, i - 1))
			return printf("%d\n", N + N - i + 1), 0;
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// ****************************************CODE***************************************//


int n, k;
int h[110000];
ll dp[110000];

int main() {
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }

    for(int i = 0; i < 110000; i++){
        dp[i] = inf;
    }


    dp[0] = 0;

    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k; j++){
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1784
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int n, sum;
        int[] s;
        double dev;
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        while (n != 0) {
            s = new int [n];
            sum = 0;
            for (int i = 0; i < n; i++) {
                s[i] = sc.nextInt();
                sum += s[i];
            }
            dev = 0;
            for (int i = 0; i < n; i++) 
                dev += (s[i] - ((double)sum / n)) * ((double)s[i] - (sum / n));
            System.out.printf("%.9f\n", Math.sqrt(dev / n));
            n = sc.nextInt();
        }
    }
}


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

ll getKthNum(string N, int k){
    return N[k] - '0';
}

int main(){
    string N;  ll K;
    cin >> N >> K;
    ll L = N.length();
    vector<vector<ll>> dp0(L+1, vector<ll>(K+1, 0));
    vector<vector<ll>> dp1(L+1, vector<ll>(K+1, 0));
    dp1[0][0] = 1;
    for(int i=1; i<=L; i++) for(int j=0; j<=K; j++){
        ll val = getKthNum(N, i-1);
        if(val == 0){
            dp1[i][j] += dp1[i-1][j];
        }else if(j > 0){
            dp1[i][j] += dp1[i-1][j-1];
        }

        dp0[i][j] += dp0[i-1][j];
        if(val > 0){
            dp0[i][j] += dp1[i-1][j];
        }
        if(j>0){
            dp0[i][j] += dp0[i-1][j-1]*9 + dp1[i-1][j-1]*max(0ll, val - 1);
        }
        // cout << i << " " << j << " " << dp0[i][j] << " " << dp1[i][j] << endl;
    }
    cout << dp0[L][K] + dp1[L][K] << endl;
}


Measured memory_bytes: 256
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort(reverse=True)
F.sort()

l = -1
r = A[0] * F[-1]
while l+1 < r:
    c = (l + r) // 2
    practice = 0
    for i in range(N):
        practice += max(math.ceil(A[i] - c / F[i]), 0)
    if practice <= K:
        r = c
    else:
        l = c
print(r)

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

#define f first
#define s second
#define p pair<int,int>
#define P pair<ll,ll>
#define pb push_back
#define ll long long
#define db double
#define zero(a) memset(a,0,sizeof(a))
#define inff(a,n) fill(a,a+n+1,inf)
#define all(a) a.begin(),a.end()
#define sz(a) int((a).size())
#define read(x) scanf("%lld",&x)
#define read2(x,y) scanf("%lld%lld",&x,&y)
#define write(x) printf("%lld\n",x)

const int maxn=2e6+10;
const ll inf=1e9;

ll n,m,ans,sum,num,a[maxn],b[maxn],vis[maxn];
string s,t,s1,s2;

int main()
{
    read(n);
    for(int i=0;i<n;i++)
    {
        read(a[i]);
        vis[a[i]]++;
        vis[a[i]+1]++;
        if(a[i]-1>=0)vis[a[i]-1]++;
    }
    write(*max_element(vis,vis+maxn));
    return 0;
}

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

const string NO = "IMPOSSIBLE";

void solve(long long A, long long B)
{
    if (A == B)
    {
        cout << 0 << endl;
    }
    else if (A != B)
    {
        if (abs(A - B) % 2 == 0)
        {
            cout << (A + B) / 2 << endl;
        }
        else
        {
            cout << NO << endl;
        }
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
data = [int(i) for i in input().split()]
data.sort()
count = 0

if (data[1] - data[0]) % 2 == 1:
    data[1] += 1
    data[2] += 1
    count += 1
count += int((data[1] - data[0]) / 2) + (data[2] - data[1])

print(count)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
  int i, n, a;
  int max=0, min=1001;

  scanf("%d", &n);

  for(i=0;i<n;i++){
    scanf("%d", &a);
    if(a>max)
    max=a;
    if(a<min)
    min=a;
  }

  printf("%d\n", max-min);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,j,m,o=0;
	cin>>n;
	for(i=1;i<10;i++){
		for(j=1;j<10;j++)
		{
			m=i*j;
			if(n==m){
				o++;
			}
		}
	}
	if(o>0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var cash = int.Parse(Console.ReadLine());
            var yen = int.Parse(Console.ReadLine());
 
            var money = cash % 500;
 
            if(money <= yen)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 11092
import java.util.*;

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

        int ID = sc.nextInt();
        int gate = sc.nextInt();

        int[] minid = new int[gate];
        int[] maxid = new int[gate];

        for(int i = 0;i<gate;i++){
          minid[i] = sc.nextInt();
          maxid[i] = sc.nextInt();
        }


        int max      = minid[0];

        for (int index = 1; index < minid.length; index ++) {
            max = Math.max(max, minid[index]);
        }

        int min = maxid[0];

        for (int j = 1; j < minid.length; j ++) {
            min = Math.min(min, maxid[j]);
        }
        int ans = min-max+1;
        if(ans > 0){
        System.out.println(ans);
      }else{
        System.out.println(0);
      }


    }
}


Measured memory_bytes: 83172
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    int a,b,p,m,k;
    
    cin >> a >> b;
    
    p = a+b;
    m = a-b;
    k = a*b;
    
    if (p>=m && p>=k){
    
    cout << p << endl;
    
    }else if (m>=p && m>=k){
    
    cout << m << endl;
    
    }else {
    
    cout << k << endl;
    
    }
    
/////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
n = int(input())
a = input()
b = input()
c = input()

res = 0
for i in range(n):
    chrs = set([a[i], b[i], c[i]])
    if len(chrs) == 1:res += 0
    if len(chrs) == 2:res += 1
    if len(chrs) == 3:res += 2

print(res)
    
    

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>     
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#define INF 2000000
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define mk make_pair
#define en endl
#define RE return 0
//#define int ll
#define P pair<int,int>
using namespace std;
int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}
int lcm(int a,int b){if(a==0){return b;} return a/gcd(a,b)*b;}    

int main(){
	string S;
	cin>>S;
	
	for(int i=0; i<S.size(); i++){
		if(S[i]=='?')  S[i]='D';
	}
	cout<<S<<endl;
}



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

class Combination {
    /*
        :)
    */
   public :

    const int mod = 1e9 + 7;

    ll add(ll x, ll y) {
        x += y;
        if (x >= mod) return x - mod;
        return x;
    }
    ll sub(ll x, ll y) {
        x -= y;
        if (x < 0) return x + mod;
        return x;
    }
    ll mult(ll x, ll y) {
        return (x * y) % mod;
    }
    ll bin_pow(ll x, ll p) {
        if (p == 0) return 1;
        if (p & 1) return mult(x, bin_pow(x, p - 1));
        return bin_pow(mult(x, x), p / 2);
    }
    ll rev(ll x) {
        return bin_pow(x, mod - 2);
    }
    ll fact(ll a) {
        ll S = 1;
        for (ll I = 1 ; I <= a; I++)S = S *  I % mod;
        return S;
    }
    ll Combin(ll x, ll y) {
        return mult(fact(x), rev(mult(fact(sub(x, y)), fact(y))));
    } 
};
int main () {
    ios_base::sync_with_stdio(false), cin.tie(0);
    Combination cm;
    ll ans = 0;
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &x : a) cin >> x;
    ll araysum = 0;
    for (int i = 0 ; i < n; i++) araysum = cm.add(araysum, a[i]);
    ll S = cm.mult(araysum, araysum);
    ll Si = 0;
    for (int i = 0 ; i < n; i++) {
      Si = cm.add(Si, cm.mult(a[i], a[i])); 
    }
    ans = cm.mult(cm.sub(S, Si), cm.rev(2));
    cout << ans ;
}

Measured memory_bytes: 3920
import sys
input = lambda: sys.stdin.readline().rstrip()

N = int(input())

l = []

for i in range(N):
    v = list(map(int, input().split()))
    l.append(v)

    # 高さ0の時は下で使う式変形が成り立たないので、高さがある時のものを使う。
    # 全部0のパターンはありえない。なぜなら全部0としたとき、高さが1で調査していない座標を中心としたものが複数条件を
    # 満たしてしまうので、中心が一個に特定されるという条件に反するため。
    if v[2]:
        x,y,h = v[0], v[1], v[2]

for X in range(101):
    for Y in range(101):
        H = h + abs(x-X) + abs(y-Y)
        if all(h == max(H - abs(x-X) - abs(y-Y), 0) for x,y,h in l):
            print(X,Y,H)
            exit()

Measured memory_bytes: 74820
#define HAVE_STRUCT_TIMESPEC
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200000 + 5;
ll pre[N];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
    cout.tie(NULL);
	ll n,d,a;
	cin >> n >> d >> a;
	vector< pair<ll, ll> > v;
	for(int i = 1; i <= n; ++i){
		ll x,y;
		cin >> x >> y;
		ll z = (y-1) / a + 1;
		v.push_back({x,z});
	}
	sort(v.begin(),v.end());
	ll ans = 0,sum = 0;
	int r = 1;
	for(int i = 0; i < n; ++i){
		while(r < n && v[r].first <= v[i].first + 2 * d)
			++r;
		sum -= pre[i];
		v[i].second -= sum;
		if(v[i].second <= 0)
			continue;
		sum += v[i].second;
		pre[r] += v[i].second;
		ans += v[i].second; 
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(),a.end());
	if(a[0] + a[1] == a[2]) 
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


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

string A,B;
int main() {
	int ans = 0;
	cin >> A >> B;
	int l = A.length();
	for(int i=0; i<l; i++) ans += (A[i] == B[i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;

namespace AOJ_Hello_World {
	class Program {
		static void Main (string[] args) {
			var sab = Console.ReadLine();
			long[] a = new long[2];
			for (int i = 0;i < 2;i++) {
				a[i] = long.Parse( sab.Split(' ')[i]);
			}

			string sgn = "";
			if (a[0] < a[1])
				sgn = "<";
			else if (a[0] == a[1])
				sgn = "==";
			else if (a[0] > a[1])
				sgn = ">";


			Console.WriteLine("a {0} b",sgn);
		}
	}
}

Measured memory_bytes: 5336
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

int main(){
  int A,B,C;

  cin>>A>>B>>C;

  FOR(i,1,B+1){
    if ((A*i)%B == C) {
      cout<<"YES"<<endl;
      return 0;
    }
  }

  cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 256
def dfs(i, f):
    global ans
    if i == len(s) - 1:
        ans += sum(map(int, f.split("+")))
        return 0
    dfs(i +1, f + "+" + s[i + 1])
    dfs(i +1, f+ s[i + 1])

s = input()
ans = 0
dfs(0, s[0])
print(ans)

Measured memory_bytes: 3060
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

    multiset<ll> st;
    st.insert(A[0]);
    for (ll i = 1; i < N; i++) {
        auto itr = st.lower_bound(A[i]);
        if (itr == st.begin()) {
            st.insert(A[i]);
        } else {
            itr--;
            st.erase(itr);
            st.insert(A[i]);
        }
    }

    cout << st.size() << endl;
}

Measured memory_bytes: 5760
#include <stdio.h>

int main(void){
    int h,w;   
    scanf("%d %d",&h,&w);
    int cnt[h][w];
    char s[h][w];
    for(int i = 0;i < h;i++)    scanf("%s",s[i]);
 
    cnt[0][0] = (s[0][0] == '#') ? 1:0;
    for(int i = 1;i < h;i ++) cnt[i][0] = cnt[i-1][0] + ((s[i][0] != s[i-1][0])?1:0);
    for(int i = 1;i < w;i ++) cnt[0][i] = cnt[0][i-1] + ((s[0][i] != s[0][i-1])?1:0);
    
    int from_up,from_side;
    for(int i = 1;i<h;i++)
        for(int j = 1; j < w;j++){
            from_up = cnt[i][j-1] + ((s[i][j] != s[i][j-1])?1:0);
            from_side = cnt[i-1][j] + ((s[i][j] != s[i-1][j])?1:0);
            cnt[i][j] = (from_side < from_up)?from_side:from_up;
        } 
    printf("%d\n",(cnt[h-1][w-1]+1)/2);
}

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

int main() {
  int n;
  int l;

  cin >> n;

  int res[n];

  for(int i=1;i<=n;i++) {
    cin >> l;
    res[l] = i;
  }

  for(int i=1;i<=n;i++){
    cout << res[i] << endl;
  }
  return 0;
}


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

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int a=A+B;
  int b=C+D;
  if(a>b){
    cout<<"Left"<<endl;
  }else if(a==b){
    cout<<"Balanced"<<endl;
  }else{
    cout<<"Right"<<endl;
  }
}


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

int main(void){
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    cout<<(a[0]!=a[1] ? a[0] : a[2])<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int read(){
	int sum=0,f=1;
	char s=getchar();
	while (s<'0' or s>'9'){
		if (s=='-')f=-1;
		s=getchar();
	}
	while (s>='0' and s<='9'){
		sum=sum*10+s-'0';
		s=getchar();
	}
	return sum*f;
}
int cnm(int n,int m)
{
	if(m>n/2)
	m=n-m;
	int a=1,b=1;
	for(int i=1;i<=m;i++)
	{
		a*=n+1-i;
		b*=i;
		if(a%b==0)
		{
			a/=b;
			b=1;
		}
	}
	return a/b;
}
int main(){
	int n,m;
	n=read();
	m=read();
	int ans=0;
	if (n>=2){
		ans+=cnm(n,2);
	}
	if (m>=2){
		ans+=cnm(m,2);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())

    c = collections.Counter()

    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                c[x * x + y * y + z * z + x * y + y * z + z * x] += 1

    for i in range(1, N + 1):
        print(c[i])


if __name__ == '__main__':
    main()



Measured memory_bytes: 78940
A, B, C = map(int, input().split())
lst = [A, B, C]
lst.sort()

ans = 0
if((lst[1]-lst[0])%2==0):
    ans += (lst[1]-lst[0])//2+lst[2]-lst[1]
else:
    if((lst[2]-lst[0])%2 != 0):
        ans += (lst[2]-lst[1])//2+(lst[2]+1-lst[0])//2+1
    elif((lst[2]-lst[1])%2 != 0):
        ans += (lst[2]-lst[0])//2+(lst[2]+1-lst[1])//2+1
print(ans) 

Measured memory_bytes: 3064
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      hs: [usize; n],
    }
    let mut hs = hs;
    let mut ans = 0;
    while hs.iter().sum::<usize>() > 0usize {
        let mut mode = true;
        for i in 0..n {
            if hs[i] > 0 {
                hs[i] -= 1;
                if mode {
                    ans += 1;
                    mode = false;
                }
            } else {
                mode = true;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <stdlib.h>

using namespace std;
int main(){

    int k,input,j;
    int flag = 1;
    vector<int> v;

    for(int i=0; i<5; i++){
        cin >> input;
        v.push_back(input);
    }

    cin >> k;

    for(int i=0; i<5; i++){
        j = i+1;
        while(j<5){
            if(abs(v[j]-v[i]) > k){
                flag = 0;
            }
            j++;
        }
    }

    if(flag == 1){
        cout << "Yay!" << endl;
    }
    else{
        cout << ":(" << endl;
    }


    return 0;
}

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

typedef long long int in;


int main() 
{
	string s,t;
    cin>>s>>t;

    if((in)(s.size())+1!=(in)(t.size()))
    {
        cout<<"No";
        return 0;
    }

    for(in i=0;i<(in)(s.size());++i)
    if(s[i]!=t[i])
    {
        cout<<"No";
        return 0;
    }

    cout<<"Yes";

	return 0;
}





Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int n, m, r, a[20000], b[20000], c[20000], l[10];
int s[202][202], ans = INF;
bool use[10] = {0};

void dfs(int x, int k, int sum){
	if(k == r){
		ans = min(ans, sum);
		return;
	}
	for(int i = 1; i <= r; i++){
		if(!use[i]){
			use[i] = 1;
			if(x == 0) dfs(i, k+1, 0);
			else dfs(i, k+1, sum + s[l[x]][l[i]]);
			use[i] = 0;
		}
	}
}

int main(){
	for(int i = 0; i < 202; i++){
		for(int j = 0; j < 202; j++){
			s[i][j] = INF;
		}
		s[i][i] = 0;
		s[0][i] = 0;
	}
	cin >> n >> m >> r;
	for(int i = 1; i <= r; i++){
		cin >> l[i];
	}
	l[0] = 0;
	for(int i = 1; i <= m; i++){
		cin >> a[i] >> b[i] >> c[i];
		s[a[i]][b[i]] = c[i];
		s[b[i]][a[i]] = c[i];
	}
	
	for(int k = 1; k <= n; k++){
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				s[i][j] = min(s[i][j], s[i][k] + s[k][j]);
			}
		}
	}
	dfs(0,0,0);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
from operator import mul
from functools import reduce
from functools import lru_cache

@lru_cache(maxsize=1000)
def cmb(n,r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N, K = map(int, input().split())
R = N - K

print(R + 1)
for i in range(2, K + 1):
    if R + 1 < i:
        print(0)
        continue
    tmp = cmb(R + 1, i)
    tmp2 = cmb(K - 1, K - i)
    print((tmp % (10**9 + 7) * tmp2 % (10**9 + 7)) % (10**9 + 7))

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

int main(){
    int N, M, A, B;
    scanf("%d %d\n%d %d", &N, &M, &A, &B);
    if (B == 1) printf("1\n");
    else printf("0\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()


int main() {
	ll N, M;
	cin >> N >> M;
	ll ans = 0;
	ford(i, 1, M / N + 1) {
		if (M % i == 0) {
			ll tmp = M / i;
			if (N <= tmp) {
				ans = i;
				break;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repr(i, m, n) for (int (i)(m - 1); (i)>=(n); --(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vpii = vector<pii>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

int main() {
	ll x[100001];
	ll nl[100001];
	ll nr[100001];
	ll xl[100001];
	ll xr[100001];
	ll n, k;
	cin >> n >> k;
	int left = n;
	rep(i, 0, n) {
		cin >> x[i];
		if (x[i] > 0 && left == n) {
			left = i;
		}
	}
	nl[0] = 1;
	nr[0] = 1;
	xl[0] = -x[left - 1];
	if (left < n) {
		xr[0] = x[left];
	}
	rep(i, 1, left) {
		xl[i] = -x[left - i - 1];
		nl[i] = nl[i - 1] + 1;
	}
	rep(i, 1, n - left) {
		xr[i] = x[i + left];
		nr[i] = nr[i - 1] + 1;
	}
	ll time = 1e11;
	rep(i, 0, left) {
		if (k == nl[i]) {
			time = min(time, xl[i]);
		}
		else if (k > nl[i] && k-nl[i]-1 < n - left) {
			time = min(time, 2*xl[i]+xr[k-nl[i]-1]);
		}
	}
	rep(i, 0, n - left) {
		if (k == nr[i]) {
			time = min(time, xr[i]);
		}
		else if (k > nr[i] && k-nr[i]-1 < left) {
			time = min(time, 2*xr[i]+xl[k-nr[i]-1]);
		}
	}
	cout << time << endl;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
    int array[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;

    cin >> K;

    cout << array[K-1];

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
using namespace std;
const int mo=1000000007;
const int N=10000005;
const int M=5005;
int fac[N],inv[N],Inv[N];
int n,m,f[M][M],g[M][M];
void init(){
	fac[0]=inv[0]=inv[1]=Inv[0]=1;
	For(i,2,N-1) inv[i]=1ll*inv[mo%i]*(mo-mo/i)%mo;
	For(i,1,N-1) Inv[i]=1ll*Inv[i-1]*inv[i]%mo;
	For(i,1,N-1) fac[i]=1ll*fac[i-1]*i%mo;
}
int C(int x,int y){
	return 1ll*fac[x]*Inv[y]%mo*Inv[x-y]%mo;
}
int main(){
	init();
	scanf("%d%d",&n,&m);
	For(i,0,m) f[i][0]=1ll*fac[i+n-m-1]*i%mo;
	For(i,0,m) For(j,1,m-i){
		int val=1ll*f[i][0]*C(i+j,i)%mo;
		f[i+j][0]=(f[i+j][0]+mo-val)%mo;
		f[i+j][j]=val;
	}
	For(i,1,m) For(j,0,m-i){
		g[i][j]=f[i-1][j];
		g[i][j]=(g[i][j]+1ll*g[i-1][j]*(n-m+i-(j+1)))%mo;
		g[i][j]=(g[i][j]+1ll*g[i-1][j+1]*(j+1))%mo;
	}
	int ans=(g[m][0]+f[m][0])%mo;
	cout<<ans<<endl;
}
/*
>_<
*/



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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int n;
vector<pair<int, int>>  vv;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int x;
		scanf("%d", &x);
		vv.push_back(make_pair(x, i));
	}
	sort(vv.begin(), vv.end());
	int cnt = 0;
	for (int i = 0; i < n; i += 2) {
		if (vv[i].second % 2 != 0)
			++cnt;
	}
	cout << cnt << "\n";
	return 0;
}




Measured memory_bytes: 1400
#!/usr/bin/env python3
import sys
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    rem = M
    ret = 0
    for a, b in sorted(zip(A, B)):
        ret += a * min(b, rem)
        rem -= min(b, rem)
        if rem == 0:
            break
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]" 
    B = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    result = solve(N, M, A, B)
    print(result)

if __name__ == '__main__':
    main()


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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline LL rd() {
	char ch=nc(); LL i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}
inline void W(LL x) {
	static int buf[50];
	if(!x) {putchar('0'); return;}
	if(x<0) {putchar('-'); x=-x;}
	while(x) {buf[++buf[0]]=x%10; x/=10;}
	while(buf[0]) putchar(buf[buf[0]--]+'0');
}

const int N=233, mod=1e9+7;
LL f[N],n;
vector <pii> g[N];

inline LL calc(pii v,LL X,LL Y) {
	LL ret=0;
	if(X>=v.second && Y>=v.first+v.second) ret=(ret+(Y-v.first)/v.second)%mod;
	if(Y>=v.second && X>=v.first+v.second) ret=(ret+(X-v.first)/v.second)%mod;
	return ret;
}
int main() {
	f[0]=f[n=1]=1;
	while(f[n]<=4e18) ++n, f[n]=f[n-1]+f[n-2];
	for(int i=1;i<=f[2];i++) g[0].push_back(pii(0,i));
	for(int i=0;i<n-2;i++) 
		for(auto j:g[i]) {
			LL x=j.first, y=j.second;
			x+=y;
			while(x<=f[i+3]+f[i]) {
				if(x>y) g[i+1].push_back(pii(y,x));
				x+=y;
			}
		}
	int Q=rd();
	while(Q--) {
		LL X=rd(), Y=rd();
		if(X<Y) swap(X,Y);
		LL ans=1, sum=0;
		for(;f[ans+2]<=X && f[ans+1]<=Y;++ans);	
		if(ans==1) {sum=X*Y%mod;}
		else for(auto v:g[ans-1]) (sum+=calc(v,X,Y))%=mod;
		W(ans), putchar(' '), W(sum), putchar('\n');
	}
}


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

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

    vector<ll> cand;

    for (int i = 1; i <= sqrt(total); ++i) {
        if(total%i==0){
            cand.push_back(i);
            cand.push_back(total/i);
        }
    }

    priority_queue<ll> ans;

    for(auto X:cand){
        vector<ll> r(N),ruisekil(N+1,0ll),ruisekir(N+1,0ll);
        for (int i = 0; i < N; ++i) {
            r[i]=a[i]%X;
        }

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

        for (int i = 0; i < N; ++i) {
            ruisekil[i+1]=ruisekil[i]+r[i];
        }

        for (int i = N-1; i >=0 ; --i) {
            ruisekir[i]=ruisekir[i+1]+(X-r[i])%X;
        }

        for (int i = 1; i < N ; ++i) {
            if(abs(ruisekil[i]-ruisekir[i])%X==0ll){
                ll ope=max(ruisekil[i],ruisekir[i]);
                if(ope<=K){
                    ans.push(X);
                    break;
                }
            }
        }
    }

    cout<<ans.top()<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N (int)2e5
int n, m;
int a[N], ans[N + 1];
int main(){
    cin >> n;
    for(int i = 0; i < n - 1; i++){
        cin >> a[i];
        ans[a[i]]++;
    }
    for(int i = 0; i < n; i++){
        cout << ans[i + 1] << endl;
    }
}

Measured memory_bytes: 5084
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 305
#define LL long long
LL dis[N][N];
int ans[N][N];
int main()
{
	int n,m,L,Q,i,j,k,u,v,w;
	scanf("%d%d%d",&n,&m,&L);
	memset(dis,0x3f,sizeof(dis));
	for(i=1;i<=m;i++){
		scanf("%d%d%d",&u,&v,&w);
		dis[u][v]=dis[v][u]=w;
	}
	for(k=1;k<=n;k++)
		for(i=1;i<=n;i++)if(i!=k)
			for(j=1;j<=n;j++)if(j!=k&&j!=i)
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
	memset(ans,0x3f,sizeof(ans));
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(dis[i][j]<=L)
				ans[i][j]=1;
	for(k=1;k<=n;k++)
		for(i=1;i<=n;i++)if(i!=k)
			for(j=1;j<=n;j++)if(j!=k&&j!=i)
				ans[i][j]=min(ans[i][j],ans[i][k]+ans[k][j]);
	scanf("%d",&Q);
	for(i=1;i<=Q;i++){
		scanf("%d%d",&u,&v);
		if(ans[u][v]==0x3f3f3f3f) printf("-1\n");
		else printf("%d\n",ans[u][v]-1);
	}
}

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

using namespace std;

int n, d;
int x[10][10];
bool good(int i, int j) {
    int sum = 0;
    for (int k=0; k<d; k++) {
        int dif = x[i][k] - x[j][k];
        sum += dif * dif;
    }
    int root = (int)sqrt(sum);
    cerr << root << ' ' << sum << '\n';
    return sum == root * root;
}

int main() {
    cin >> n >> d;
    for (int i=0; i<n; i++) {
        for (int j=0; j<d; j++) {
            cin >> x[i][j];
        }
    }
    int cnt = 0;
    for (int i=0; i<n; i++) {
        for (int j=0; j<i; j++) {
            if (good(i, j)) cnt++;
        }
    }
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>

int main()
{
    double r, a, l;

    std::cin>>r;

    a = pow(r, 2)*M_PI;
    l = 2 * r * M_PI;

    std::cout<<std::fixed<<std::setprecision(6)<<a<<" "<<std::fixed<<std::setprecision(6)<<l<<std::endl;

    return 0;
}


Measured memory_bytes: 3244
#include<iostream>
#include<stdio.h>
#include<queue>
using namespace std;
int main(){
	for(;;)
	{
		queue<pair<int,int> > que;
		int x,y,f[18][18],n,m,ans=0;
		pair<int,int> g,p,ex;
		scanf("%d %d",&x,&y);
		if(x==0&&y==0)
		{
			break;
		}
		g.first=x;
		g.second=y;
		ex.first=1;
		ex.second=1;
		que.push(ex);
		for(n=0;n<=x+1;n++)
		{
			for(m=0;m<=y+1;m++)
			{
				if(n==0||n>x||m==0||m>y)
				{
					f[n][m]=1;
				}
				else
				{
					f[n][m]=0;
				}
			}
		}
		scanf("%d",&n);
		for(m=0;m<n;m++)
		{
			scanf("%d %d",&x,&y);
			f[x][y]=1;
		}
		while(!que.empty())
		{
			p=que.front();
			if(f[p.first+1][p.second]==0)
			{
				ex.first=p.first+1;
				ex.second=p.second;
				if(ex==g)
				{
					ans=ans+1;
				}
				else
				{
				que.push(ex);
				}
			}
			if(f[p.first][p.second+1]==0)
			{
				ex.first=p.first;
				ex.second=p.second+1;
				if(ex==g)
				{
					ans=ans+1;
				}
				else
				{
				que.push(ex);
				}
			}
			que.pop();
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 9176
import numpy as np
n,k = map(int, input().split())
p = np.array(list(map(int, input().split())))
m = (p+1)/2
s = sum(m[:k])
r = s
for i in range(n-k):
    s -= m[i]
    s += m[i+k]
    r = max(r,s)
print(r)

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

int pcount(int x){
  return __builtin_popcount(x);
}

int f(int x){
  int ans=1;
  int tmp;
  if(x==0){
    return ans;
  }
  while(x){
    tmp=pcount(x);
    x%=tmp;
    ans++;
  }
  return ans;
}

int main(){
  int n;cin>>n;
  string s;cin>>s;
  reverse(s.begin(),s.end());
  int p1=0;
  int p2,p3;
  vector<int>amari2(n);
  vector<int>amari3(n);
  for(int i=0;i<n;i++){
    if(s.at(i)=='1'){
      p1++;
    }
  }
  p2=p1+1;
  p3=p1-1;
  if(p3!=0){
    for(int i=0;i<n;i++){
      if(i==0){
        amari2.at(i)=1%p2;
        amari3.at(i)=1%p3;
      }
      else{
        amari2.at(i)=amari2.at(i-1)*2%p2;
        amari3.at(i)=amari3.at(i-1)*2%p3;
      }
    }
  }
  else{
    for(int i=0;i<n;i++){
      if(i==0){
        amari2.at(i)=1%p2;
        amari3.at(i)=0;
      }
      else{
        amari2.at(i)=amari2.at(i-1)*2%p2;
        amari3.at(i)=0;
      }
    }
  }
  int x02=0;
  int x03=0;
  if(p2!=0&&p3!=0){
    for(int i=0;i<n;i++){
      if(s.at(i)=='1'){
        x02+=amari2.at(i);
        x02%=p2;
        x03+=amari3.at(i);
        x03%=p3;
      }
    }
  }
  else if(p2==0&&p3!=0){
    for(int i=0;i<n;i++){
      if(s.at(i)=='1'){
        x03+=amari3.at(i);
        x03%=p3;
      }
    }
    x02=0;
  }
  else if(p3==0&&p2!=0){
    for(int i=0;i<n;i++){
      if(s.at(i)=='1'){
        x02+=amari2.at(i);
        x02%=p2;
      }
    }
    x03=0;
  }
  for(int i=n-1;i>=0;i--){
    int x=0;
    if(s.at(i)=='1'){
      bool zero=true;
      for(int j=0;j<n;j++){
        if(j==i)continue;
        if(s.at(j)=='1'){
          zero=false;
          break;
        }
      }
      if(zero){
        cout <<0<<endl;
        continue;
      }
      x+=x03;
      x-=amari3.at(i);
      if(x<0){
        x+=p3;
      }
      x%=p3;
      if(x==0){
        cout <<1<<endl;
      }
      else{
        int anss=f(x);
        cout <<anss<<endl;
      }
    }
    else if(s.at(i)=='0'){
      x+=x02;
      x+=amari2.at(i);
      x%=p2;
      if(x==0){
        cout <<1<<endl;
      }
      else{
        int anss=f(x);
        cout <<anss<<endl;
      }
    }
  }
}

Measured memory_bytes: 5232
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;

const int MaxN = 3e5;
int n, a[MaxN + 5];;
int succ_cnt[MaxN + 5];
int cnt[30];
int nxt[MaxN + 5][30];
int now[30];
int ans[MaxN + 5];
char s[MaxN + 5];

void Init()
{
	n = strlen(s);
	for (int i = 0; i < n; i++) a[i + 1] = s[i] - 'a';
	int need = 0;
	memset(succ_cnt, 0, sizeof(succ_cnt));
	memset(cnt, 0, sizeof(cnt));
	for (int i = n; i >= 1; i--) {
		cnt[a[i]]++; int sum = 0;
		for (int j = 0; j < 26; j++) sum += (int)(cnt[j] > 0);
		if (sum == 26) {
			memset(cnt, 0, sizeof(cnt));
			succ_cnt[i] = succ_cnt[i + 1] + 1;
		}
		else succ_cnt[i] = succ_cnt[i + 1];
	}
	memset(nxt, -1, sizeof(nxt));
	memset(now, -1, sizeof(now));
	a[0] = 28;
	for (int i = n; i >= 0; i--) {
		for (int j = 0; j < 26; j++)
			nxt[i][j] = now[j];
		now[a[i]] = i;
	}
}

void Solve()
{
	int len = succ_cnt[1] + 1;
	//printf("%d\n", len);
	memset(ans, 0, sizeof(ans));
	int last = 0;
	for (int i = 1; i <= len; i++) {
		int pos;
		for (int j = 0; j < 26; j++) {
			pos = nxt[last][j];
			if (pos == -1 || succ_cnt[pos + 1] < len - i) {
				ans[i] = j;
				break;
			}
		}
		last = pos;
	}
	for (int i = 1; i <= len; i++) printf("%c", (char)(ans[i] + 'a'));
	printf("\n");
}

int main()
{
	while (~scanf("%s", s)) {
		Init();
		Solve();
	}
	return 0;
}

Measured memory_bytes: 39168
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001;
#define LLINF 1001001001001001001001;
#define LL long long

int main(){
    long long int A,B,K;
    scanf("%lld %lld %lld",&A,&B,&K);
    vector<long long int> ans;
    rep(i,K){
        if(A+i<=B)ans.push_back(A+i);
        if(B-i>=A)ans.push_back(B-i);
    }
    sort(ans.begin(),ans.end());
    ans.erase( unique(ans.begin(),ans.end() ),ans.end() );
    rep(i,ans.size()){
        printf("%lld\n",ans[i]);
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second 
#define ll long long 
#define _for(i,j,k) for(int i=j;i<k;i++)
#define endl  '\n'
#define inf 1<<29
const int mod=1e9+7;
const int MAX=1e6+5;
// ll a[MAX]; 
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes";
	else cout<<"No";
	
	
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
    long N;
    scanf("%ld", &N);
    long S = 0;
    long i;
    for (i = 1; i < N+1; i++) {
        S += (i%3!=0)&&(i%5!=0)? i: 0;
    }

    printf("%ld", S);

    return 0;
}

Measured memory_bytes: 1728
//
//  main.cpp
//  A
//
//  Created by Hashizo on 2019/12/28.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
int main(int argc, const char * argv[]) {
	ll ans = 0;

	ll n, a, b;
	cin >> n >> a >> b;

	if(((a+b) % 2 ) == 0) {
		ans = b - ((a+b) / 2);
	}
	else {
		ans = min(max(a-1,b-1),max(n-a,n-b));
		
		
		if(a-1 <= n-b) {
//			if ((((b-(a-1)) + 1) % 2) == 0) {
				ans = min(ans, (a-1) + ((b-(a-1)) - ((b-(a-1)) + 1) / 2));
//			}
		}
		else {
//			if((((a+(n-b))+n) % 2 ) == 0) {
				ans = min (ans ,(n-b) + (n - (((a+(n-b))+n) / 2)));
//			}
//			else {

//			}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, l, r;
    cin >> n;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> l >> r;
        sum += (r-l)+1;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			String s = in.next();
			int a = Integer.MAX_VALUE;
			int z = 0;
			for(int i = 0; i < s.length(); i++) {
				if(s.charAt(i) == 'A') {
					a = Math.min(a, i);
				} else if(s.charAt(i) == 'Z'){
					z = i;
				}
			}
			out.println(z - a + 1);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

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

		public char nextChar() {
			return next().charAt(0);
		}

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

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

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

	}
}


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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  int flag = 0;
  if(s[0] == 'B') flag = 1; 
  rep(i,s.size() - 1){
    char tmp = s[i+1];
    int num = 0;
    if(tmp == 'W') num = 0;
    if(tmp == 'B') num = 1;
    if(flag ^ num){
      ans++;
      flag = num;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
/* 
Rohit645
Rohit Kumar 
*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using db = double;
using pll = pair < ll, ll >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end() 
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;

int main() {
	fastIo();
	ll n; cin >> n;
	double a[n];
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	double ans=0;
	for (ll i = 0; i < n-1; i++) {
		ans = (a[i] + a[i + 1])*1.0 / 2;
		a[i+1] = ans;
	}
	cout << fixed;
	cout << setprecision(12) << a[n-1];
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    double a[n];
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    double ans = a[0];
    rep(i,n)ans = (ans + a[i])/2;
    cout<<fixed<<setprecision(12)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

public class AtCoder_150_B
{
    public static void Main()
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        int num = int.Parse(Console.ReadLine());
        string str = Console.ReadLine();

        int count = 0;
        for (int i = 0; i < num - 2; i++)
        {
            if (str[i] == 'A' && str[i + 1] == 'B' && str[i + 2] == 'C')
            {
                count++;
            }
        }
        Console.WriteLine(count.ToString());
    }
}


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

int main() {
    int n, m;
    int s[5];
    char c[5];
    cin >> n >> m;
    for (int i = 0; i < m; i++) cin >> s[i] >> c[i];

    if (n == 1 && m == 0) {
        cout << 0 << endl;
        return 0;
    }

    if (m == 0) {
        cout << pow(10, n - 1) << endl;
        return 0;
    }

    int ans = 1000;
    if (n == 1) {
        for (int i = 0; i < m; i++) {
            if (s[i] == 1 && c[i] == '0') ans = 0;
            else break;
        }
    }
    if (ans != 1000) {
        cout << 0 << endl;
        return 0;
    }

    for (int i = pow(10, n - 1); i < pow(10, n); i++) {
        string str = to_string(i);
        for (int j = 0; j < m; j++) {
            if (str.at(s[j] - 1) != c[j]) break;
            if (j == m - 1) ans = i;
        }
        if (ans == i) {
            cout << ans << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 4116
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;

int dp[1030][1030];
char fi[1010][1010];

constexpr int mod=1e9+7;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h,w; cin >> h >> w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> fi[i][j];
        }
    }
    dp[0][0]=1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(fi[i][j]=='.'){
                if(i-1>=0){
                    (dp[i][j]+=dp[i-1][j])%=mod;
                }
                if(j-1>=0){
                    (dp[i][j]+=dp[i][j-1])%=mod;
                }
            }
        }
    }
    cout << dp[h-1][w-1] << endl;
}


Measured memory_bytes: 8524