akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader(); 
        int N = r.i();
        int[] A = r.ii();
        int[] memo = new int[N];
        for(int a : A)
            memo[a]++;
        boolean flag = true;
        if(N%2 == 1 && memo[0] != 1)
            flag = false;
        else
            for(int i = N%2+1; i < N; i += 2){
                if(memo[i] != 2){
                    flag = false;
                    break;
                }
            }
        println(flag ? power2(N/2) : 0);
    }
    static long power2(int n){
        if(n > 29)
            return (power2(n-30)*((1<<30)%1000000007))%1000000007;
        else
            return 1<<n;        
    }

    static void print(Object o){
        System.out.print(o.toString());
    }

    static void println(Object o){
        System.out.println(o.toString());
    }

    static int Int(String s){
        return Integer.parseInt(s);
    }

    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s() throws IOException{
            return readLine();
        }

        String[] ss() throws IOException{
            return s().split(" ");
        }

        int i() throws IOException{
            return Int(s());
        }

        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        long l() throws IOException{
            return Long(s());
        }

        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<ll>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el printf("\n")
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);

int main()
{
	IOS;
    cout.precision(30);
    ll n,m,k,a,b,c,x,y; string s,t;
    cin >> a >> b;
    ll ans=1,rep=0;
    if (b==1) return cout << 0,0;
    while(true)
    {
        rep++;
        if (ans-1+a>=b) break;
        ans+=a-1;
    }
    cout << rep;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;


int main(){
    string s;
    cin>>s;
    sort(all(s));
    if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 100005;
int n,m,a[MAXN],odd;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i){
		scanf("%d",a+i);
		if(a[i]&1)++odd;
	}
	if(m==1){
		if(a[1]==1)printf("1\n1\n1\n");
		else printf("%d\n2\n%d %d\n",a[1],a[1]-1,1);
		return 0;
	}
	if(odd>2)puts("Impossible");
	else{
		bool flag=false;
		for(int i=1;i<=m;++i)
			if(a[i]&1){
				if(!flag)swap(a[i],a[1]),flag=true;
				else {swap(a[i],a[m]);break;}								   
			}
		int lenb=m;
		if(a[1]==1)--lenb;
		for(int i=1;i<=m;++i){
			printf("%d%c",a[i],(i==m)?'\n':' ');
		}
		printf("%d\n",lenb);
		for(int i=1;i<=m;++i){
			if(i==1){
				if(a[i]>1)printf("%d%c",a[i]-1,(i==m)?'\n':' ');
			}else if(i==m){
				printf("%d%c",a[i]+1,(i==m)?'\n':' ');
			}else{
				printf("%d ",a[i]);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	int arr[200];
	int n;
	cin >> n;
    for(int i=0 ; i<n ; i++)
    cin >> arr[i];

	int ans = 0;
	while(1)
	{
		bool flag = false;
		for(int i=0 ; i<n ; i++)
		{
			if(arr[i]%2 == 0)	arr[i] = arr[i]/2;
			else{
				flag = true;
				break;
			}
		}


		if(flag)
			break;
		else
			ans++;
	}
	cout << ans;
	return 0;
}

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

public class Main{
  static final long MOD = 1_000_000_007;
  static int n, m;
  static long[] x, y;

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

    n = sc.nextInt();
    m = sc.nextInt();
    x = new long[n];
    for(int i = 0; i < n; i++){
      x[i] = sc.nextInt();
    }
    y = new long[m];
    for(int i = 0; i < m; i++){
      y[i] = sc.nextInt();
    }

    long sumX = 0;
    for(int i = 1; i <= n; i++){
      sumX = (((x[i - 1] * (2 * i - n - 1)) % MOD) + sumX) % MOD;
    }
    long sumY = 0;
    for(int i = 1; i <= m; i++){
      sumY = (((y[i - 1] * (2 * i - m - 1)) % MOD) + sumY) % MOD;
    }

    long ans = (sumX * sumY) % MOD;

    System.out.println(ans);
  }
}


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

int main() {
    ll x,a;
    cin>>x>>a;
    if(x<a){
        cout<<0<<endl;
    }else {
        cout<<10<<endl;
    }
}


Measured memory_bytes: 256
n, k = map(int, input().split())
s = str(input())
head = s[0]

counts = []
_hd = head
_cnt = 0
for _s in s:
  if _s == _hd:
    _cnt += 1
  else:
    counts.append(_cnt)
    _hd = _s
    _cnt = 1
else:
  counts.append(_cnt)

acc = [0]
for c in counts:
  acc.append(acc[-1] + c)
if s[-1] == '0':
  acc.append(acc[-1])

ans = 1
if len(counts) <= 2*k:
  ans = len(s)
else:
  if head == '1':
    for i in range(2*k+1, len(acc)+1, 2):
      p = acc[i] - acc[i - (2*k+1)]
      ans = max(ans, p)
  else:
    for i in range(2*k, len(acc)+1, 2):
      p = acc[i] - acc[max(0, i-(2*k+1))]
      ans = max(ans, p)

print(ans)

Measured memory_bytes: 7932
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD
#define MAX_N (ll)200001

using namespace std;

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

ll N, K, a[MAX_N];
ll s[MAX_N];
ll bit[MAX_N + 1];

void add(ll i, ll x) {
  while (i <= MAX_N) {
    bit[i] += x;
    i += i & -i;
  }
}

ll sum(ll i) {
  ll s = 0;
  while (i > 0) {
    s += bit[i];
    i -= i & -i;
  }
  return s;
}

int main() {
  s[0] = 0;
  cin >> N >> K;
  for (ll i = 1; i <= N; i++) {
    cin >> a[i];
    s[i] = s[i-1] + a[i];
  }

  pair<ll, ll> b[MAX_N];
  for (ll i = 0; i <= N; i++) {
    b[i] = make_pair(s[i] + K * (MAX_N - i), i);
  }
  sort(b, b + N + 1);

  ll c[MAX_N + 1];
  for (ll i = 0; i <= N; i++) {
    c[b[i].second] = i + 1;
  }

  ll ans = 0;
  for (ll i = 0; i <= N; i++) {
    ans += sum(c[i]);
    add(c[i], 1);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if((a<c&&c<b)||(b<c&&c<a)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll N, Q;
ll A[101010], B[101010], C[101010];
ll sum;
ll cnt[101010];

int main() {
  //
  cin >> N;
  rep(i, 0, N) {
    cin >> A[i];
    sum += A[i];
    cnt[A[i]]++;
  }
  cin >> Q;
  rep(i, 0, Q) { cin >> B[i] >> C[i]; }

  rep(i, 0, Q) {
    ll b = B[i];
    ll c = C[i];

    ll num = cnt[b];
    sum += num * (c - b);
    cout << sum << "\n";

    cnt[c] += cnt[b];
    cnt[b] = 0;
  }
}


Measured memory_bytes: 6728
#include<stdio.h>
#include<string.h>
int main()
{
    char s[11];
    scanf("%s", s);
    int i;
    char ans[11];
    i = 0;
    int n = 0;
    for (i = 0; i < strlen(s); i++)
    {
        if (s[i] != 'B')
        {
            ans[n] = s[i];
            n++;
        }
        else
        {
            
            if (n != 0)
                n--;
        }
    }
    ans[n] = '\0';
    printf("%s\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main()
{
    int d, l, a;
    
    scanf("%d %d", &d, &l);
    
    a = d % l;
    
    if (a == 0)
    {
        printf("%d\n", d / l);
    } else {
        printf("%d\n", a + d / l);
    }
    
    return 0;
}

Measured memory_bytes: 1824
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<tuple>
#include<ctime>
#include<functional>
#include<cmath>
#include<cassert>
#include<string.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p; 
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
    ll x,N,p[210]={0},cnt[210]={0},min=100000;
    cin>>x>>N;
    for(int i=1;i<=N;i++) cin>>p[i];
    for(int i=1;i<=N;i++){
        cnt[p[i]]++;
    }
for(int j=0;j<=200;j++){
    if(cnt[j]==0){
        if( abs(j-x)<min) min=abs(j-x);
    }
}

  if(cnt[x-min]==0)  p(x-min);
  else if(cnt[x+min]==0) p(x+min);
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int M=2e5+5;
struct node{
	int c,e;
	bool operator < (const node &_) const{
		return e!=_.e?e<_.e:c<_.c;
	}
}job[M];

int main(){
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		scanf("%d %d",&job[i].c,&job[i].e);
	}
	sort(job+1,job+n+1);
	int time=0;
	for(int i=1; i<=n; i++){
		time+=job[i].c;
		if(time>job[i].e) return !puts("No");
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fr first
#define sc second
#define pb push_back
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int> >
const int INF = 1e9+7;
const int MAXN = 3e5 + 200;
const  long double eps = 1e-16;
const long double pi = acos(-1.0);
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

struct point{
    long long x;
    long long h;
};

int N = 2e5 + 10;
long long d, a,n ;
point b[MAXN];
long long fen[MAXN];
void update(int ind, long long del){
    while (ind < N){
        fen[ind] += del;
        ind = ind | (ind + 1);
    }
}
long long sum(int ind){
    long long res = 0;
    while (ind >= 0){
        res += fen[ind];
        ind = (ind & (ind + 1)) - 1;
    }
    return res;
}
bool comp(point x, point y){
    return x.x < y.x;
}
void solve(){
    cin >> n >> d >> a;
    for (int i = 1; i <= n; i++){
        cin >> b[i].x >> b[i].h;
    }

    sort(b + 1, b + 1 + n, comp);
    long long ans = 0;
    int ind;
    for (int i = 1; i <= n; i++){
        long long H = b[i].h + sum(i);

        if (H <= 0) continue;
        if (b[i].x + d * 2 >= b[n].x) ind = n - i;

        else{
            int l = 0;
            int r = n + 1;
            while (r - l > 1){
                int m = (l + r) / 2;

                if (i + m > n) {
                    r = m;
                    continue;
                }
                if (b[i + m].x > 2 * d + b[i].x)
                    r = m;
                else
                    l = m;
            }
            ind = l;
        }
        //cout << i << " " << ind << " " << b[i].x + sum(i)<< endl;
        long long skok = (b[i].h + sum(i) )/ a;
        if ( (b[i].h + sum(i) )  % a) skok++;
        ans += skok;
        update(i, -skok * a);
        update(i + ind + 1, skok * a);
    }
    cout << ans << endl;

}



int main() {
ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
cout.setf(ios::fixed), cout.precision(7);
 //freopen("input.in", "r", stdin);
// freopen("output.out", "w", stdout);
 int step;
 step = 1;
  for (int i = 1; i <= step; i++){
         solve();
    }
}


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

using ll = long long;

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

    int ans = 0, sum = 0;
    while(n >= max(1LL, (sum + k - 1) / k)) {
        ans += 1;
        const ll add = max(1LL, (sum + k - 1) / k);
        sum += add;
        n -= add;
    }

    cout << ans << endl;
}



Measured memory_bytes: 3092
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))


ans = sum(b)

for i, j in zip(a[1:], a[:-1]):
    if i - j == 1:
        ans += c[i-2]
        
print(ans)

Measured memory_bytes: 3064
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
set<ll> s;
int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    cin>>m>>n;
    for(i=0;i<n;i++)
    {
        cin>>x;
        s.insert(x);
    }
    ll dis = inf;
    ll ans = inf;
    for(i=-200;i<=200;i++)
    {
        if(s.find(i)!=s.end())
            continue;
        if(abs(i-m)<dis)
        {
            dis =  abs(i-m);
            ans = i;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3648
import sys
import math

ct= 0
def insertion_sort(a, n, g):
    global ct
    for j in range(0,n-g):
        v = a[j+g]
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j-g
            ct += 1
        a[j+g] = v

n = int(input())
a = list(map(int, sys.stdin.readlines()))
b = 1
g = [1]
while True:
    b = 3 * b + 1
    if b > n:
        break
    g.append(b)
g = g[::-1]

for i in g:
    insertion_sort(a, n, i)

print(len(g))
print(*g, sep=" ")
print(ct)
print(*a, sep="\n")



Measured memory_bytes: 116492
# coding: utf-8
import sys
from fractions import gcd

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# A[i]の左までのgcdと右以降のgcdを保持
N = ir()
A = lr()

def calc(arr):
    ret = [arr[0]]
    g = arr[0]
    for x in arr[1:]:
        g = gcd(g, x)
        ret.append(g)
    return ret

g_left = calc(A)
g_right = calc(A[::-1])[::-1]

cand = [g_right[1]]
for i in range(1, N-1):
    temp = gcd(g_left[i-1], g_right[i+1])
    cand.append(temp)

cand.append(g_left[-2])
answer = max(cand)
print(answer)


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

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

template<typename T>
void cmpmax(T* reference, T value) {
	*reference = max(*reference, value);
}

template<typename T>
void cmpmin(T* reference, T value) {
	*reference = min(*reference, value);
}

const ll mod = 1000000007;

static const ll INF = 1e15;

int main() {
	ll a, b;
	cin >> a >> b;
	cout << a * b << endl;
	return 0;
}
	


Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>
#include <math.h>
#include <set>

#define inf 1e15
#define sz 1e5
using ll = long long int;
using namespace std;

int main() {
int n;
cin>>n;
int count=0;
bool ans=false;
    for (int i = 0; i < n; ++i) {
        int a,b;
        cin>>a>>b;
        if (a==b)count++;
        else count=0;
        if (count>=3)ans=true;
    }
    if (ans)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}

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

#include <atcoder/all>
using namespace atcoder;

int main() {
    int n, q;
    cin>>n>>q;

    dsu d(n);

    for (int i = 0; i < q; i++) {
        int t, u, v;
        scanf("%d %d %d", &t, &u, &v);
        if (t == 0) {
            d.merge(u, v);
        } else {
            if (d.same(u, v)) {
                printf("1\n");
            } else {
                printf("0\n");
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 4084
N=int(input())
ans=0
if N==1:
    print(0)
elif N==2:
    print(2)
else:
    """
    0,2-8だけで構成される個数（1 9 nasi）
    0,2-9だけで構成される個数(1 nasi)
    0-8で構成される個数(9 nasi)
    全部1の個数
    全部9の個数
    """
    a1=8**N
    a2=9**N
    a3=a2
    a4=0
    a5=0
    zentai=10**N
    ans=zentai -(a2+a3+a4+a5-a1)

    #ans= N*(N-1) * 9**(N-2) +(2**N - 2 )
    print(ans%(10**9+7))


Measured memory_bytes: 80384
s = list(input())
N = len(s)
start = 0
stop = N-1
for i in range(N):
    if s[i] == 'A':
        start = i
        break
for i in range(N-1,0,-1):
    if s[i] == 'Z':
        stop = i
        break
print(stop-start+1)

Measured memory_bytes: 4840
#!/usr/bin/env python
#-*- coding: utf-8 -*-

from collections import defaultdict
from math import factorial as f
from fractions import gcd as g

N = int (raw_input ())
l = [int (i) for i in raw_input ().split ()]

d = defaultdict (int)
c = 0
for i in l:
    if i < 400: d ["gray"] += 1
    elif i < 800: d ["brown"] += 1
    elif i < 1200: d ["green"] += 1
    elif i < 1600: d ["cyan"] += 1
    elif i < 2000: d ["blue"] += 1
    elif i < 2400: d ["yellow"] += 1
    elif i < 2800: d ["orange"] += 1
    elif i < 3200: d ["red"] += 1
    else: c += 1

print max (1, len (d.keys ())), len (d.keys ()) + c


Measured memory_bytes: 5288
{-# LANGUAGE ViewPatterns #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import qualified Data.IntMap as M
import Data.List

bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words

data Tree = Leaf Int Int [Int]
          | Node Int Tree Tree
            deriving(Show)
leafList :: Tree -> [Int]
leafList (Leaf _ _ lst) = lst

mkLeaf :: Int -> M.IntMap Int -> Int -> Int -> Tree
mkLeaf k im i num =
  Leaf i num $ take (num - (k-1)) $ sort [im M.! x | x <- [i .. i+num-1]]

bldNode :: Int -> Tree -> Tree -> Tree
bldNode idx (leafList -> []) (leafList -> []) = Leaf idx 0 []
bldNode _   (leafList -> []) right            = right
bldNode _   left             (leafList -> []) = left
bldNode idx left             right            = Node idx left right

nextTree :: Int -> M.IntMap Int -> Int -> Tree -> Tree
nextTree k im idx tr@(Leaf i num _)
  | i <= idx && idx < i + num
        = bldNode idx (mkLeaf k im i         (idx - i))
                      (mkLeaf k im (idx + 1) (num - (idx - i) - 1))
  | otherwise = tr
nextTree k im idx (Node i trL trR)
  | idx < i   = Node i (nextTree k im idx trL) trR
  | otherwise = Node i trL (nextTree k im idx trR)
  
allEff :: Tree -> [Int]
allEff (Leaf _ _ lst)      = lst
allEff (Node _ left right) = allEff left ++ allEff right

step :: Int -> Int -> M.IntMap Int -> Int -> Tree -> Maybe (Int, Tree)
step k q im idx tr
  = let eff = allEff tr
        y:_ = drop (q-1) (sort eff)
    in if length eff <= q-1 then Nothing
                            else Just (y - im M.! idx, nextTree k im idx tr)

mkrec :: Int -> Int -> M.IntMap Int -> [Int] -> Tree -> [Int]
mkrec k q im [] tree = []
mkrec k q im (idx : indices) tree =
  case step k q im idx tree of
  Nothing           -> []
  Just (y, newTree) -> y : mkrec k q im indices newTree

solve :: Int -> Int -> Int -> [Int] -> Int
solve n k q as =
  let ias = zip [0..] as 
      im = M.fromList ias
  in minimum $ mkrec k q im (map fst $ sortOn snd ias) $ mkLeaf k im 0 n

main :: IO ()
main = do
  conts <- B.getContents
  let n:k:q:as = bsReadInts conts
      answer = solve n k q as
  putStrLn (show answer)


Measured memory_bytes: 2428
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int len = scan.nextInt();
		String mozi = scan.next();

		int max = 0;

		for(int i=1;i<=len-1;i++) {

			int re = i;
			int count = 0;
			for(char c = 'a';c<='z';c++) {

				boolean left = false;
				boolean right = false;
				for(int j=0;j<re;j++) {
					if(mozi.charAt(j) == c) {
						left = true;
						break;
					}
				}
				for(int j=re;j<len;j++) {
					if(mozi.charAt(j) == c) {
						right = true;
						break;
					}
				}

				if(left && right) {
					count++;
				}
				max = Math.max(max, count);
				}
		}
		System.out.println(max);
		scan.close();
	}
}


Measured memory_bytes: 27680
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  string s, t;
  scanln(s, t);
  writeln(t~s);
}

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


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep) ~ "\n";
  static if (__VERSION__ >= 2071) {
    readf!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "readf(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


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

void solve(){
	ll n;
	cin>>n;
	ll k,p,x,ans;
	ans = (n*(n+1))/2;
    k = n/3;
    p = n/5;
    x = n/15;
    ans = ans - 3*(k*(k+1)/2) - 5*(p*(p+1))/2 + 15*(x*(x+1))/2;
    cout<<ans<<endl;
}
int main()
{

  solve();

return 0;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
 if(s=="SUN"){cout<<"7"<<endl;}
   if(s=="MON"){cout<<"6"<<endl;}
   if(s=="TUE"){cout<<"5"<<endl;}
   if(s=="WED"){cout<<"4"<<endl;}
   if(s=="THU"){cout<<"3"<<endl;}
   if(s=="FRI"){cout<<"2"<<endl;}
   if(s=="SAT"){cout<<"1"<<endl;}
}

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

int main(){
  int a,b;
  cin>>a>>b;
 
  if(a==b) cout<<"Draw"<<endl;
  else if(a==1) cout<<"Alice"<<endl;
  else if(b==1) cout<<"Bob"<<endl;
  else cout<<(a<b? "Bob":"Alice")<<endl;
  return 0;
}


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


int main(void) {
    string s,t;
    cin >> s >> t;
    bool flag = false;
    rep(i, s.size()){
        if(s==t)flag = true; 
        s = s.substr(1) + s[0];
    }
    cout << (flag ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
//--------------------

int main() {
	long res[400009] = {};
	long n; cin >> n;
	long a[200009] = {}; for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) res[i] = a[n - i + 1];
	for (int i = n + 1; i <= 2 * n; i++) res[i] = a[i - n];

	for (int i = 1; i <= 2 * n; i = i + 2) cout << res[i] << " ";
    cout << endl;
}

Measured memory_bytes: 6912
#include <stdio.h>

int main(void){
  int a,b,c,n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d",&a,&b,&c);
    if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a) printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String args[]) {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int[] tolls = new int[m];
        for (int i = 0; i < m; i++) {
            tolls[i] = sc.nextInt();
        }
        int costZero = 0;
        int costN = 0;
        for (int i = 0; i < m; i++) {
            if (tolls[i] < x) costZero++;
            else costN++;
        }
        int ans = Math.min(costZero, costN);
        System.out.println(ans);
    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21204
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){

    double r,a,b;
   
    cin >>r;
    a=r*r*3.141592653589;
    b=2.0*r*3.141592653589;
   printf("%f %f", a, b);
    return 0;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define INF 2147483640
using namespace std;
int h[100005],n,m,ans;
vector<int> G[200005];
int main()
{
	//freopen("out.txt","w",stdout);
	cin >> n >> m;
	for(int i=1; i<=n; i++) cin >> h[i];
	for(int i=0,a,b; i<m; i++)
	{
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for(int i=1; i<=n; i++)
	{
		int ok=1;
		for(auto j:G[i]) if(h[i] <= h[j]){ok=0; break;}
		if(ok) ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 11504
from collections import Counter

N = int(input())
s = [input() for _ in range(N)]
c = Counter(s)
print(f'AC x {c["AC"] if c["AC"] else 0}')
print(f'WA x {c["WA"] if c["WA"] else 0}')
print(f'TLE x {c["TLE"] if c["TLE"] else 0}')
print(f'RE x {c["RE"] if c["RE"] else 0}')

Measured memory_bytes: 16612
#include <stdio.h>

typedef struct tag_posn {
	double x;
	double y;
} posn;

typedef struct tag_vec {
	double e1;
	double e2;
} vec;

int is_cross(vec a, vec b) {
	if((a.e1 * b.e1) + (a.e2 * b.e2))
		return 0;
	return 1;
}

vec mkvec(posn a, posn b) {
	vec ret;
	
	ret.e1 = a.x - b.x;
	ret.e2 = a.y - b.y;

	return ret;
}

int main(void) {
	posn input[4];
	int i;
	vec vec1, vec2;

	while(scanf("%lf %lf", &input[0].x, &input[0].y) != EOF) {
		for(i = 1; i < 4; i++)
			scanf("%lf %lf", &input[i].x, &input[i].y);
		vec1 = mkvec(input[0], input[1]); 
		vec2 = mkvec(input[2], input[3]);
		if(is_cross(vec1, vec2))
			printf("YES\n");
		else
			printf("NO\n");
	}

	return 0;
}

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

int main() 
{
 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 cout.tie(nullptr);
 int n, x, t;
 cin >> n >> x >> t;
 int ans = 1;
 if(n % x) ans = n / x + 1;
 else ans = n / x;
 ans *= t;
 cout << ans << '\n';
}


Measured memory_bytes: 3584
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

# setrecursionlimit(10**7)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')
MOD = 10**9 + 7

def main():
	n = int(rl())

	dp = [[[0 for k in range(2)] for j in range(2)] for i in range(n+1)]
	dp[0][0][0] = 1

	for i in range(n):
		for j in range(2):
			for k in range(2):
				for d in range(10):
					nj = j or d == 0
					nk = k or d == 9
					dp[i+1][nj][nk] += dp[i][j][k]
					dp[i+1][nj][nk] %= MOD 

	ans = dp[n][1][1]
	print(ans)
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 393192
#include <iostream>
#include <string>

using namespace std;

int main() {
    int a, b, c;    cin >> a >> b >> c;
    int sum = a+b+c;
    if (sum >= 22) {
        cout << "bust" << endl;
    }
    else 
        cout << "win" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
	
int A,B,C,D;

Scanner sc = new Scanner(System.in);
 A = sc.nextInt();

 B = sc.nextInt();

 C = sc.nextInt();

 D = sc.nextInt();

do {
	
	
	C=C-B;
	if(C<=0) {
		System.out.println("Yes");
		System.exit(0);
	}
	A=A-D;
	if(A<=0) {
		System.out.println("No");
		System.exit(0);
	}
}
while(true);
	}
}

Measured memory_bytes: 35856
io = STDIN
n,m=io.gets.split.map(&:to_i)
x=io.gets.split.map(&:to_i).sort
if n>=m || m==1
  puts 0
else
  mid=x.each_cons(2).map{|i,j|j-i}.sort_by{|i|-i}
  take=mid.take(n-1)
  puts mid.inject(:+)-take.inject(0){|s,x|s+x}
end


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

int dp[2005][2005][4];
char grid[2005][2005];

const int LEFT = 0;
const int RIGHT = 1;
const int UP = 2;
const int DOWN = 3;

int main() {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  for(int i = 1; i <= N; i++)
    cin >> grid[i] + 1;

  for(int i = 1; i <= N; i++) {
    for(int j = 1; j <= M; j++) {
      dp[i][j][LEFT] = grid[i][j] == '.' ? dp[i][j-1][LEFT] + 1 : 0;
      dp[i][j][DOWN] = grid[i][j] == '.' ? dp[i-1][j][DOWN] + 1 : 0;
    }
  }

  for(int i = N; i > 0; i--) {
    for(int j = M; j > 0; j--) {
      dp[i][j][RIGHT] = grid[i][j] == '.' ? dp[i][j+1][RIGHT] + 1 : 0;
      dp[i][j][UP]    = grid[i][j] == '.' ? dp[i+1][j][UP] + 1 : 0;
    }
  }

  int ans = 0;
  for(int i = 1; i <= N; i++)
    for(int j = 1; j <= M; j++)
      ans = max(ans, dp[i][j][0] +dp[i][j][1] +dp[i][j][2] +dp[i][j][3]);
  cout << ans -3;
}




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

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

  int k, n;

  std::cin >> k >> n;

  int a[200000];
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
  }

  int ad_max = 0;
  for (int j = 0; j < n - 1; ++j) {
    int a_diff = a[j + 1] - a[j];
    if (ad_max < a_diff) {
      ad_max = a_diff;
    }
  }
  int an_diff = a[0] - a[n - 1] + k;
  if (ad_max < an_diff) {
    ad_max = an_diff;
  }

  std::cout << (k - ad_max) << std::endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<iomanip>
using namespace std;

int main()
{
	int n, input, max, min;
	long int sum;
	cin >> n;
	cin >> input;
	max = input;
	min = input;
	sum = input;
	for (int i=0; i < n-1; i++) {
		cin >> input;
		if (input > max) {
			max = input;
		}
		if (input < min) {
			min = input;
		}
		sum += input;
	}
	cout << min << " " << max << " " << sum << endl;

}


Measured memory_bytes: 3096
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long s = lread();
    long[] a = new long[](2000000);
    a[0] = s;
    foreach (i; 1 .. a.length)
    {
        if ((a[i - 1] & 1) == 0)
        {
            a[i] = a[i - 1] / 2;
        }
        else
        {
            a[i] = a[i - 1] * 3 + 1;
        }
    }
    bool[long] d;
    foreach (i, v; a)
    {
        if (v in d)
        {
            writeln(i + 1);
            return;
        }
        else
        {
            d[v] = true;
        }
    }
}


Measured memory_bytes: 17916
#include <iostream>

int main() {
    int cnta = 0, cntb = 0, cntab = 0, cntba = 0;

    int n; std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::string s; std::cin >> s;

        for (size_t j = 0; j < s.size() - 1; j++) {
            if (s[j] == 'A' && s[j+1] == 'B') {
                cntab++;
            }
        }
        if (s[0] == 'B' && s[s.size()-1] == 'A') {
            cntba++;
        } else if (s[0] == 'B') {
            cntb++;
        } else if (s[s.size()-1] == 'A') {
            cnta++;
        }
    }

    if (cntba == 0) {
        cntab += std::min(cnta, cntb);
    } else {
        if (cnta == 0 && cntb == 0) {
            cntab += cntba - 1;
        } else {
            cntab += (cntba + std::min(cnta, cntb));
        }
    }

    std::cout << cntab << std::endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(){
	int a[10000], min, max, n, i;
	long long sum = 0;
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
		sum += a[i];
	}
	max = min = a[0];
	for(i = 1; i < n; i++){
		if(a[i] > max)max = a[i];
		if(a[i] < min)min = a[i];
	}
	printf("%d %d %lld\n", min, max, sum);
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int n;
    cin >> n;
    int dp[n + 1];
    rep (i, n + 1) dp[i] = i;
    rep (i, n + 1) {
        for (int j = 1; i + j <= n; j *= 6) {
            dp[i + j] = min (dp[i + j], dp[i] + 1);
        }
        for (int j = 1; i + j <= n; j *= 9) {
            dp[i + j] = min (dp[i + j], dp[i] + 1);
        }
    }
    cout << dp[n] << "\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
string S,T;
vector<int> A;
vector<int> B;
//=============================
void input()
{
    cin>> N>>M;
}
//=============================
void func(){}
//=============================
void solve()
{
    cout<<(M==100 ? 101 : M);
    cout<<(N==0? "" : (N==1 ? "00" : "0000"))<<endl;
    
}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

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

long long int f(long long int sum, vector<int>& a, long long int n, long long int ans){
  int isum = sum;
  for (int i = 1; i < n; i++) {
    int temp = isum;
    isum += a[i];
    if (temp > 0) {
      if (isum >= 0) {
        ans += (1 + isum);
        isum = -1;
      }
    }
    else if(temp < 0) {
      if (isum <= 0) {
        ans += (1 + abs(isum));
        isum = 1;
      }
    }
  }
  return ans;
}
void solve() {
  long long int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0 ; i < n; i++) {
    cin >> a[i];
  }
  long long int p = 1;
  long long int ne = -1;
  long long int pans = 1;
  long long int nans = 1;
  if(a[0] > 0) {
    p = a[0];
    nans = a[0] + 1;
    pans--;
  }
  else if (a[0] < 0) {
    ne = a[0];
    nans--;
    pans = abs(a[0]) + 1;
  }
  cout << min(f(p, a, n, pans), f(ne, a, n, nans));
}


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


Measured memory_bytes: 640
n=int(input())
h=list(map(int,input().split()))
cnt=0
for _ in range(max(h)):
    for i in range(n):
        if i==n-1:
            if h[n-1]>0:
                h[n-1]-=1
                cnt+=1
        elif h[i]>0:
            h[i]-=1
            if h[i+1]==0:
                cnt+=1
print(cnt)


Measured memory_bytes: 3068
#include <iostream>

using namespace std;

int main()
{
    int n, sum=0;
    cin >> n;
    char s[n];
    for (int i=0 ; i<n ; i++)
        cin >> s[i];
    for (int i=0 ; i<n ; i++)
    {
        if (s[i]=='A')
            if (s[i+1]=='B')
                if (s[i+2]=='C')
                    sum++;
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
int read()
{
	int k=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) k=k*10+c-'0';return k*f;
}
int main()
{	
	int n=read();
	if(n>=30) puts("Yes");
	else puts("No");
	return  0;
} 

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int a, b;
    char c;
    cin >> a >> c >> b;
    if (c == '+')
        OP(a + b);
    else
        OP(a - b);
    return 0;
}

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

char field[8][8];
char tmp[8][8];
int angle = 90;

void rotate(){
	for(int i=0; i < 8; i++){
		for(int j=0; j < 8; j++){
			tmp[i][j] = field[i][j];
		}
	}

	for(int i=0; i < 8; i++){
		for(int j=0; j < 8; j++){
			field[i][j] = tmp[7-j][i];
		}
	}
}

void output(){
	cout << angle << endl;
	for(int i=0; i < 8; i++){
		for(int j=0; j < 8; j++){
			cout << field[i][j];
		}
		cout << endl;
	}
}

int main(){
	for(int i=0; i < 8; i++){
		for(int j=0; j < 8; j++){
			cin >> field[i][j];
		}
	}

	for(int i=0; i < 3; i++, angle += 90){
		rotate();
		output();
	}
}

Measured memory_bytes: 1140
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
using namespace std;
int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int ar[n];
    for(int i = 0; i<n; i++){
        cin >> ar[i];
    }
    sort(ar,ar+n);
    int last = -1;
    int count = 0;
    vector<int> li;
    for(int i = 0; i<n; i++){
        if(ar[i]!=last){
            last = ar[i];
            count=1;
            continue;
        }
        count++;
        if(count==2){
           li.push_back(last);
           count = 0;
        }
    }
    if(li.size()<2){
        cout << 0 << endl;
    }
    else{
        long long ans = (long long)li[li.size()-1]*(long long)li[li.size()-2];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define maxn 100001
#define maxa 2000005
#define MOD  998244353 //1000000007
#define INF 1000000000000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define mem(a, b) memset(a, b, sizeof(a))
#define sort(v) sort(v.begin(), v.end())
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout << setprecision(10) << fixed;
}
ll ceil(ll a, ll b){ return (a+ b-1)/b; }
void flaged(bool flag){
    if(flag) cout << "Yes\n";
    else cout << "No\n";
}
// power and modulo inverse
ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}
// factorial
ll fact[maxa], finv[maxa];
void calf(){
    fact[0] = finv[0] = 1;
    for(ll i = 1; i < maxa; i++){fact[i] = (fact[i-1]*i) %MOD;finv[i] = (finv[i-1]*power(i))%MOD;}
}
// nCr
ll ncr(ll N, ll R){ if(R > N) return 0; return (fact[N]*((finv[R]*finv[N-R])%MOD))%MOD;}

void solve(){
    ll a, b, c;
    cin >> b >> a >> c;
    if(c <= b){
        b -= c;
    }
    else{

        a -= (c-b);b = 0; a = max(a, 0ll);
    }
    cout << b << " " << a;
}

int main()
{
    fast();
    ll t = 1;//cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
 
int32_t main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int d,t,s;
	cin>>d>>t>>s;
	if(d<=s*t){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0; 
} 


Measured memory_bytes: 3580
Var a,b:Longint;
Begin
    Readln(a); Readln(b);
    If (a=1) and (b=2) or (a=2) and (b=1) then Writeln(3)
    Else If (a=1) and (b=3) or (a=3) and (b=1) then Writeln(2)
    Else Writeln(1);
End.

Measured memory_bytes: 128
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;
 
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  f              first                 
#define  s              second
#define  endl           "\n"
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;            
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,pll>  um;
typedef  vector<pll>           vpll;
 
const ll   N     =  3005;
const ll   mod   =  998244353;
const ll   INF   =  1e18;
const int  INFi  =  0x7f7f7f7f;

ll test = 1, n, dp[N][N], s, a[N];

void solve(){
    cin>>n>>s;
    for(int i = 1; i <= n; i++) cin>>a[i];
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= s; j++) dp[i][j] = (dp[i-1][j]*2)%mod;
        for(int j = 0; j <= s-a[i]; j++){
            dp[i][j+a[i]] += dp[i-1][j];
            dp[i][j+a[i]] %= mod;
        }
    }
    deb1(dp[n][s])
}

int main(){
    fastio;
    //cin>>test;
    for(int i = 1; i <= test; i++){
        solve();
    }
}

Measured memory_bytes: 74096