akhauriyash/Code-Regression huggingface dataset:
class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x


N, M, K = map(int, input().split())
uf = UnionFind(N)
direct = [set() for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    uf.union(a, b)
    direct[a].add(b)
    direct[b].add(a)
for _ in range(K):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    if uf.find(a) == uf.find(b):
        direct[a].add(b)
        direct[b].add(a)
ans = []
for i in range(N):
    cnt = -uf.parents[uf.find(i)] - 1
    cnt -= len(direct[i])
    ans.append(cnt)

print(*ans)


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

ll ch1(ll a,ll b){
    if(a>b)swap(a,b);
    ll s=sqrt((long double)a*b-1);
    if(s==0)return 0;
    ll mx=(a*b-1)/s;
    ll ans=2*s;
    if(mx==s)ans--;
    if(a<=s)ans--;
    return ans;
}

signed main(){
  ll q,a,b;
  cin>>q;
  while(q--){
    cin>>a>>b;
    cout<<ch1(a,b)<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int i, j, n, m;
    i = j = n = m = 0;

    int a[100][100] = { 0 };
    int b[100] = { 0 };
    int c[100] = { 0 };

    cin >> n >> m;


    while (i < n) {
        cin >> a[j][i];

        j++;

        if (j == m) {
            j = 0;
            i++;
        }

    }

    for (i = 0; i < m; i++) {
        cin >> b[i];
    }

    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            c[i] += a[j][i] * b[j];
        }
        cout << c[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3144
// author-Shivam gupta

#include <bits/stdc++.h>


using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))

#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define IN(A, B, C) assert( B <= A && A <= C)

#define MP make_pair
#define FOR(i,a) for(int i=0;i<a;i++)

#define FOR1(i,j,a) for(int i=j;i<a;i++)

#define EB emplace_back

#define INF (int)1e9

#define EPS 1e-9

#define PI 3.1415926535897932384626433832795

#define MOD 1000000007

#define read(type) readInt<type>()
#define max1 100001
#define out(x) cout<<x<<'\n'
#define out1(x) cout<<x<<" "
#define END cout<<'\n'
const double pi=acos(-1.0);

typedef pair<int, int> PII;

typedef vector<int> VI;

typedef vector<string> VS;

typedef vector<PII> VII;

typedef vector<VI> VVI;

typedef map<int,int> MPII;

typedef set<int> SETI;

typedef multiset<int> MSETI;

typedef long int li;

typedef unsigned long int uli;

typedef long long int ll;

typedef unsigned long long int  ull;

bool isPowerOfTwo (int x)
{
  /* First x in the below expression is
    for the case when x is 0 */
  return x && (!(x&(x-1)));
}
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
const int nm = 3002;
const int mod = 998244353;

int g[nm][nm];

int main() {

int n,m;

	cin>>n>>m;
	int a[n+1];

	for (int i = 1; i <= n; ++i) {
		cin>>a[i];
	}
	g[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		g[i][0] = (g[i - 1][0] * 2) % mod;
		for (int j = 1; j <= m; ++j) {
			g[i][j] = (g[i - 1][j] * 2) % mod;
			if (a[i] <= j) {
				g[i][j] = (g[i][j] + g[i - 1][j - a[i]]) % mod;
			}
		}
	}
	out(g[n][m]);
}





Measured memory_bytes: 38836
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

typedef vector <int> VI;
typedef vector <VI> VVI;

int main( void )
{
	int datacases; cin >> datacases;
	for ( int lpc = 0; lpc < datacases; lpc++ )
	{
		int n; cin >> n;

		VVI books( 2, VI( 2*n, 0 ) );
		for ( int i = 0; i < 2; i++ ) for ( int j = 0; j < 2*n; j++ )
		{
			char book; cin >> book;
			if ( book == 'Y' ) books[i][j] = 1;
		}

		VVI routes( 2, VI( n+1, 0 ) );
		for ( int i = 0; i < 2; i++ )
		{
			for ( int j = 0; j < 2*n; j++ )
			{
				routes[i][(int)floor((j+1)/2)] |= books[i][j];
			}
		}

		VI left( 2, -1 );
		VI right( 2, -1 );
		for ( int i = 0; i < 2; i ++ )
		{
			for ( int j = 0; j < n+1; j++ )
			{
				if ( routes[i][j] )
				{
					left[i] = j;
					break;
				}
			}
			for ( int j = n; j >= 0; j-- )
			{
				if ( routes[i][j] )
				{
					right[i] = j;
					break;
				}
			}
		}

		int answer = 0;
		for ( int i = 0; i < 2; i++ ) for ( int j = 0; j < n+1; j++ )
		{
			if ( routes[i][j] ) answer++;
		}

		answer += n;

		if ( left[1] != -1 )
		{
			if ( left[1] < left[0] ) answer++;
			if ( right[0] < right[1] ) answer++;
		}

		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
long long read()
{
	char ch=getchar();long long x=0,ff=1;
	while(ch<'0'||ch>'9') {if(ch=='-') ff=-ff;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*ff;
}
void write(long long aa)
{
	if(aa<0) putchar('-'),aa=-aa;
	if(aa>9) write(aa/10);
	putchar(aa%10+'0');
	return;
}
long long n,cnt,L,R,ans;
long long a[105],md[205];
long long l[205],r[205],no[205],yes[205],vis[205];
long long tot,head[205],nx[400005],to[400005];
void add(long long aa,long long bb)
{
	tot++;
	nx[tot]=head[aa];
	to[tot]=bb;
	head[aa]=tot;
	return;
}
long long ok(long long aa,long long bb)
{
	long long len=abs(md[aa]-md[bb]);if(len==1) return 0;
	for(long long i=2;i*i<=len;++i) if(len%i==0) return 0;
	return 1;
}
long long dfs(long long rt)
{
	for(long long i=head[rt];i;i=nx[i])
	{
		long long yy=to[i];
		if(vis[yy]) continue;vis[yy]=1;
		if(!no[yy]||dfs(no[yy])) {no[yy]=rt;yes[rt]=yy;return 1;}
	}
	return 0;
}
int main()
{
	n=read();a[0]=-10;
	for(long long i=1;i<=n;++i) a[i]=read();
	for(long long i=1;i<=n;++i) 
	{
		if(a[i]!=a[i-1]+1) md[++cnt]=a[i]-1;
		if(a[i]+1!=a[i+1]) md[++cnt]=a[i];
	}
	for(long long i=1;i<=cnt;++i) 
	if(md[i]%2==0) l[++L]=i;
	else r[++R]=i;
	for(long long i=1;i<=L;++i) for(long long j=1;j<=R;++j) 
	if(ok(l[i],r[j])) add(l[i],r[j]);//,cout<<l[i]<<" "<<r[j]<<endl;
	for(long long i=1;i<=L;++i) if(!yes[l[i]])
	{
		memset(vis,0,sizeof(vis));
		if(dfs(l[i])) ans++;
	}
	long long ls=L-ans,rs=R-ans;
	ans+=ls/2*2;ans+=rs/2*2;
	if(ls%2==1) ans+=3;
	write(ans);
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>

#define FOR(i,a,b) for(long long int i =(a); i <(b);i++)
#define REP(i,N)   FOR(i,0,N)
#define debug(x)   cout << #x << " = " << x << endl;

using namespace std;

int card[100001];

int main(void){

    int N;
    cin >> N;

    int ans = 0;
    REP(i,N){
        int tmp;
        cin >> tmp;
        if(card[tmp] == 0){
            ans++;
        }
        card[tmp]++;
    }

    if(ans % 2 == 0){
        cout << ans - 1 << endl;
    }else{
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main() {
	int l, r, d;
	scanf("%d%d%d", &l, &r, &d);
	int ans = 0;
	for (int i = l; i <= r; i++) {
		if (i % d == 0) {
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1708
[N,K]=[int(i) for i in input().split()]
lis=[0 for i in range(N)]
ans=0
for i in range(K):
  x=int(input())
  y=[int(i) for i in input().split()]
  for j in y:
    lis[j-1]+=1
for i in lis:
  if i==0:ans+=1
print(ans)

Measured memory_bytes: 67644
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    long long N;
    cin >> N;
    long long A[N+2],B[N+2];
    for(long long i=0; i<N+1; i++){
        cin >> A[i];
    }
    for(long long i=0; i<N; i++){
        cin >> B[i];
    }
    B[N]=0;
 
    long long ans=0;
    long long Bp=0;
    for(long long i=0; i<N+1; i++){
        long long temp=A[i];
        A[i] = max(A[i]-Bp,0LL);
        ans += min(Bp,temp);
        ans += min(A[i],B[i]);
        //cout << "i Bp ans " << i << " " << Bp << " " << ans << endl;
        Bp = max(B[i]-A[i],0LL);
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long ll;
const ll DAT_SIZE=(1<<19)-1;

ll data[DAT_SIZE],datb[DAT_SIZE];
void add(ll a,ll b,ll x,ll k,ll l,ll r){
  if(a<=l&&r<=b){
    data[k]+=x;
  } 
  else if(l<b&&a<r){
    datb[k]+=(min(b,r)-max(a,l))*x;
    add(a,b,x,k*2+1,l,(l+r)/2);
    add(a,b,x,k*2+2,(l+r)/2,r);
  }
}
ll sum(ll a,ll b,ll k,ll l,ll r){
  if(b<=l||r<=a){return 0;}
  else if(a<=l&&r<=b){return data[k]*(r-l)+datb[k];}
  else{
    ll res=(min(b,r)-max(a,l))*data[k];
    res+=sum(a,b,k*2+1,l,(l+r)/2);
    res+=sum(a,b,k*2+2,(l+r)/2,r);
    return res;
  }
}
//v[i]<=xとなる最大のiを返す
ll binsearch(vector<long>&v,long x){
  long l=0,r=v.size();
  if(v[0]>x)return -1;
  while(r-l!=1){
    long z=(l+r)/2;
    if(v[z]<=x)l=z;
    else r=z;
  }
  return l;
}


int main(){
  
  
  ll N,D,A;
  cin>>N>>D>>A;
  ll N_=1<<18;
  vector<pair<long,long>>XH(N,pair<long,long>(0,0));
  for(ll i=0;i<N;i++)cin>>XH[i].first>>XH[i].second;

  sort(XH.begin(),XH.end());
  for(ll i=0;i<N;i++){
    add(i,i+1,XH[i].second,0,0,N_);
  }
  
  
  vector<long>X(N);
  for(long i=0;i<N;i++)X[i]=XH[i].first;
  
  
  
  ll l=0;
  ll ans=0;
  while(1){
     
    while(l<N&&sum(l,l+1,0,0,N_)<=0)l++;
    if(l==N)break;
    ll h=sum(l,l+1,0,0,N_);
    ll t=h/A+(h%A!=0);
    ll r=binsearch(X,X[l]+2*D);
    add(l,r+1,-A*t,0,0,N_);
    ans+=t;
    /*
    for(long i=0;i<N;i++)cout<<sum(i,i+1,0,0,N_)<<" ";
    cout<<endl;*/
  }
  cout<<ans;
  
}

/*



*/

Measured memory_bytes: 10624
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
#define forloop for(int i = 0; i < n; i++)
#define ll long long

int main(){
	int t; cin >> t;
	int arr[50];
	int sum = 0;
	for (int i = 0; i < t; i++){
		int sayi; cin >> sayi;
		arr[i] = sayi;
		sum += sayi;
	}
	ll res = 0;
	for (int i = 0; i < t; i++){
		res += arr[i] * (sum - arr[i]);
		sum -= arr[i];
	}
	cout << res;
	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;
    vector<pair<string, int>> vec;
    REP(n, N) {
        string name;
        int time;
        cin >> name >> time;
        vec.pb({name, time});
    }
    string key;
    cin >> key;

    bool flag = false;
    ll ans = 0;
    for (auto e: vec) {
        if (flag) ans += e.second;
        if (e.first == key) flag = true;
    }
    cout << ans << endl;

    return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

void func(long long n, std::vector<long long> A, std::vector<long long> B){

    SORT(A);
    SORT(B);

    if(n%2==1){
        cout<<abs(A[n/2]-B[n/2])+1<<endl;
    }
    else{
        cout<<B[n/2]+B[n/2-1]-A[n/2]-A[n/2-1]+1<<endl;
    }

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    func(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 6432
import sys
readline = sys.stdin.buffer.readline

def dfs(s):
    stack = [s]
    used = set(s)
    dist = [0]*N
    while stack:
        vn = stack.pop()
        for vf in Edge[vn]:
            if vf not in used:
                used.add(vf)
                dist[vf] = 1 + dist[vn]
                stack.append(vf)

N = int(readline())

zero = N//3
one = N//3 + int(N%3 >= 1)
two = N - zero - one



Edge = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, readline().split())
    a -= 1
    b -= 1
    Edge[a].append(b)
    Edge[b].append(a)



root = 0
col = [0]*N

stack = [root]
used = set(stack)
while stack:
    vn = stack.pop()
    for vf in Edge[vn]:
        if vf not in used:
            used.add(vf)
            col[vf] = 1 - col[vn]
            stack.append(vf)

if 2*sum(col) < N:
    col = [1-c for c in col]
black = sum(col)
white = N - black

Ans = [None]*N
remain = set(range(1, N+1))
if N <= 3:
    Ans = list(range(1, N+1))

elif white <= zero:
    zb = [i for i in range(1, N+1) if i%3 == 0]
    rb = [i for i in range(1, N+1) if i%3 != 0]
    for i in range(N):
        if col[i] == 0:
            Ans[i] = zb.pop()
    rb += zb
    for i in range(N):
        if col[i] == 1:
            Ans[i] = rb.pop()

elif one <= black and two <= white:
    zb = [i for i in range(1, N+1) if i%3 == 0]
    ob = [i for i in range(1, N+1) if i%3 == 1]
    tb = [i for i in range(1, N+1) if i%3 == 2]
    for i in range(N):
        if col[i] == 1:
            if ob:
                Ans[i] = ob.pop()
            else:
                Ans[i] = zb.pop()
        else:
            if tb:
                Ans[i] = tb.pop()
            else:
                Ans[i] = zb.pop()
else:
    assert False,''
print(*Ans)
    

Measured memory_bytes: 80604
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

vector<vector<int>> edge(100005);
int v[100005];
vector<int> ans;
int flag;

int dfs(int crt){
    ans.push_back(crt);
    v[crt] = 1;
    for (auto i : edge[crt]){
        if (!v[i] && !flag){
            dfs(i);
        }
    }
    if (!flag) flag = 1;

    return 0;
}

int dfs2(int crt){
    v[crt] = 1;
    for (auto i : edge[crt]){
        if (v[i] == 0){
            ans.push_back(i);
            dfs2(i);
        }
    }

    cout << ans.size() << endl;
    for (auto i : ans){
        cout << i << " ";
    }
    cout << endl;
    exit(0);

    return 0;
}


int main(){
    cin.tie(0);

    Int N, M; cin >> N >> M;
    for (int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;

        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    dfs(1);
    reverse(ans.begin(), ans.end());
    dfs2(1);
    
}


Measured memory_bytes: 10104
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9 + 7;


void main() {
    auto s = readln.split.map!(to!int);
    auto R = s[0];
    auto C = s[1];
    auto N = readln.chomp.to!int;
    auto A = new Tuple!(int, long)[][](R);

    foreach (i; 0..N) {
        s = readln.split.map!(to!int);
        auto r = s[0] - 1;
        auto c = s[1] - 1;
        auto a = s[2].to!long;
        A[r] ~= tuple(c, a);
    }
    foreach (i; 0..R) A[i].sort!"a[0] < b[0]";

    auto G = new Tuple!(int, long)[][](C);

    foreach (i; 0..R) {
        foreach (j; 0..A[i].length.to!int-1) {
            G[A[i][j][0]] ~= tuple(A[i][j+1][0], A[i][j+1][1] - A[i][j][1]);
            G[A[i][j+1][0]] ~= tuple(A[i][j][0], A[i][j][1] - A[i][j+1][1]);
        }
    }

    auto used = new bool[](C);
    auto vals = new long[](C);

    bool dfs(int n, long x) {
        if (used[n]) return vals[n] == x;
        used[n] = true;
        vals[n] = x;
        foreach (m; G[n]) if (!dfs(m[0], x+m[1])) return false;
        return true;
    }

    foreach (i; 0..C) if (!used[i] && !dfs(i, 0)) {writeln("No"); return;}

    used.fill(false);
    auto mins = new long[](C);
    int[] g;

    long dfs2(int n, long x) {
        if (used[n]) return x;
        x = min(x, vals[n]);
        used[n] = true;
        g ~= n;
        foreach (m; G[n]) x = min(x, dfs2(m[0], x));
        return x;
    }

    foreach (i; 0..C) {
        if (used[i]) continue;
        g = [];
        auto m = dfs2(i, 1L<<59);
        foreach (j; g) mins[j] = m;
    }

    foreach (i; 0..R) {
        foreach (a; A[i]) {
            auto m = mins[a[0]];
            auto x = a[1] - (vals[a[0]] - mins[a[0]]);
            if (x < 0) {
                writeln("No");
                return;
            }
        }
    }

    writeln("Yes");
}


Measured memory_bytes: 27004
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
	    String[] array = str.split(" ");
		int a = Integer.parseInt(array[0]);
		int b = Integer.parseInt(array[1]);
		System.out.println(a*b+" "+(2*a+2*b));
	}
}

Measured memory_bytes: 24188
#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>
#include<stdio.h>
#include <cstdint>
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 n;

int main() {

	cin >> n;

	if (n < 1000)cout << "ABC" << endl;
	else cout << "ABD" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;


int main() {

    string s; cin >> s;
    ll n = s.size();
    ll k; cin >> k;
    ll tail = 0;
    ll ans = 0;
    ll count = 0;
    ll front = 0;
    ll tc = 0;
    ll cw = 0;
    char prev,cur;

    if(s[0] == s[n-1]){
        count = 2;
        front = 1;
        tc = 1;
        tail = n-2;

        while(front < n && s[front] == s[0]){
            front ++;
            count ++;
        }
        while(tail > 0 && s[tail] == s[0]){
            tail --;
            tc ++;
            count ++;
        }
        if(count >= n) count = n;
    }


    cw = count;
    if(count == n){
        cout << n*k/2;
    }else if(count == 0){
        rep(i,s.size()){
            cur = s[i];
            if(i == 0) {
                count ++;
                prev = s[i];
            }
            else{
                if(cur == prev) count ++;
                else{
                    ans += count/2;
                    count = 1;
                    prev = cur;
                }
            }
        }
        ans +=  count/2;
        ans *= k;
        cout << ans;
    }else{
        count = 0;
        for(int i = front; i <= tail; i ++){
            cur = s[i];
            if(i == front) {
                count ++;
                prev = s[i];
            }
            else{
                if(cur == prev) count ++;
                else{
                    ans += count/2;
                    count = 1;
                    prev = cur;
                }
            }
        }
        ans +=  count/2;
        ans *= k;
        ans += front/2;
        ans += tc/2;
        ans += (k-1)*(cw/2);
        cout << ans;
    }





    return 0;
}


Measured memory_bytes: 3592
import java.util.*;
public class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int w = sc.nextInt();
	int h = sc.nextInt();
	int x = sc.nextInt();
	int y = sc.nextInt();
	int r = sc.nextInt();
	
	if(x - r < 0 || x + r > w || y - r < 0 || y + r > h ){
		System.out.println("No");	 
	}
	else System.out.println("Yes");
	}
}

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

ll n, a, b;

int main()
{
    cin >> n >> a >> b;
    if(a < b) swap(a, b);
    if((a-b)%2 == 0){
        cout << (a-b)/2 << endl;
        return 0;
    }
    ll ans = min(n-a, b-1)+1, c = a-b-1;
    cout << ans+c/2 << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var ary = ToIntArray(input.ReadLine(), n);

        int c = 0;
        while (true) {
            for(int i=0; i<n; i++) {
                if(ary[i] % 2 != 0) goto BREAKS;
                ary[i] /= 2;
            }
            c++;
        }

        BREAKS:

        return c;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }

}


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

#define ll long long
#define inf 0x3f3f3f3f
const int maxn=1e5+5;
#define mod 1000000007

int main()
{
    int a,b;
    cin>>a>>b;
    if(a!=1&&b!=1)cout<<"1"<<endl;
    else if(a!=2&&b!=2) cout<<"2"<<endl;
    else cout<<"3"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        for (int i = 1; i <= n; i += 2) {
            int tmp = 0;
            for (int j = 1; j < i; j += 2) {
                if(i % j == 0) {
                    tmp++;
                }
            }
            if(tmp == 7) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35700
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
#define PI acos(-1)
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll n,ans;

void solve(){
	ll m;
	cin>>n>>m;
	priority_queue<int,VI,less<int> > q;
	rep(i,0,n){
		int t;
		cin>>t;
		q.push(t); 
	} 
	while(m--){
		int t = q.top();
		q.pop();
		t>>=1;
		q.push(t);
	}
	while(!q.empty()){
		int t = q.top();
		ans+=t;
		q.pop();
	} 
	cout<<ans;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 892
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    /**
     * @param args
     * @throws IOException
     * @throws NumberFormatException
     */
    public static void main(String[] args) throws NumberFormatException,
            IOException {

        BufferedReader reader = new BufferedReader(new InputStreamReader(
                System.in));

        int len = Integer.parseInt(reader.readLine());
        int[] arr = new int[len];

        String line;

        for (int i = 0; i < len; i++) {
            line = reader.readLine();
            arr[i] = Integer.parseInt(line);
        }
        
        int resultCount = 0;
        for (int j = 0; j < arr.length; j++) {
            if (isPrime(arr[j])) {
                resultCount++;
            }
        }

        System.out.println(resultCount);

    }

    
//  ??????function prime(n) {
//  ????????????if (n <= 3) return 0; ????????????if ((n % 2) == 0) return 0;
//  ????????????for(i=3; i<=Math.sqrt(n); i++) {
//  ??????????????????if ((n % i) == 0) return 0;
//  ????????????}
//  ????????????return 1;
//  ??????}
    private static boolean isPrime(int value) {

        if(value == 2) return true;
        if(value ==  3) return true;
        if(value ==  5) return true;
        if(value ==  7) return true;
        
        if(value % 2 == 0) return false;
        if(value % 3 == 0) return false;
        if(value % 5 == 0) return false;
        if(value % 7 == 0) return false;

        int max = (int) Math.sqrt(value);
        
        
        for (double i = 8; i <= max; i ++ ) {
//            System.out.println("value:"+ value +" i:" + i +" r " + (value % i));
            if (value % i == 0) return false;
        }
        
        return true;
    }

}

Measured memory_bytes: 11000
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  string s;cin>>s;
  ll digit=s.size();
  ll tmp,sum=0;
  for(int i=0;i<(1<<(digit-1));i++){
    tmp=s[0]-'0';
    for(int j=0;j<digit-1;j++){
      if(i&(1<<j)){
        sum+=tmp,tmp=0;
      }
      tmp=10*tmp+(s[j+1]-'0');
    }
    sum+=tmp;
  }

  out(sum);

  return 0;
}


Measured memory_bytes: 384
s = input()
p = 0
cnt = 0
for i in s:
    if i == 'g':
        if p > 0:
            cnt += 1
            p -= 1
        else:
            p += 1
    elif i == 'p':
        if p > 0:
            p -= 1
        else:
            cnt -= 1
            p += 1
print(cnt)

Measured memory_bytes: 39664
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分
vector<int> p(40000);

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}


bool S(ll n){
    bool a = true;
    if(n == 1){
        a = false;
    }
    for(int i = 2; i*i <= n; i++){
        if(n % i == 0){
            a = false;
        }
    }
    return a;
}


int main(void){
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, MOD-2) % MOD; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    
    
    int N;
    cin >> N;
    ll M;
    cin >> M;
    ll M_copy = M;
    vector<ll> sosuu(0);
    
    for(int i = 2; i < 40000; i++){
        if(S(i)){
            sosuu.push_back(i);
        }
    }
    
    
    for(int i = 0; i < sosuu.size(); i++){
        while(M % sosuu.at(i) == 0){
            M /= sosuu.at(i);
            p.at(sosuu.at(i))++;
        }
    }
    
    ll ans = 1;
    for(int i = 0; i < 40000; i++){
        if(p.at(i) == 0)continue;
        ans *= comb(p.at(i) + N - 1, p.at(i));
        ans %= MOD;
    }
    if(S(M)){
        ans *= comb(1 + N - 1, 1);
    }
    
    ans %= MOD;
    cout << ans << endl;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) {
        if(a[i] > i) {
            cout << -1 << endl;
            return 0;
        }
    }
    ll ans = a.back();
    REPR(i, n-1, 1) {
        if(a[i]+1 == a[i+1]) continue;
        if(a[i]+1 < a[i+1]) {
            cout << -1 << endl;
            return 0;
        }
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cmath>

using namespace std;


int main()
{
    //string S, T, U;
    int K, X;
//    int count = 0;

    //double K, S;
    //double x, y, z;


    cin >> K >> X;

  
    if (X <= K*500) { 
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    
    }
    

     return 0;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define endl            "\n"
#define forn(i,n)       for(int i=0; i<n; i++)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void zeus()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}





int32_t main()
{
    //zeus();

    int n; cin >> n;

    int h[n];

    forn(i, n) {
        cin >> h[i];
    }

    int x[n];

    x[0] = 0;
    x[1] = abs(h[1] - h[0]);

    for (int i = 2; i < n; i++) {
        x[i] = min(x[i - 1] + abs(h[i] - h[i - 1]), x[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << x[n - 1] << endl;



}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    char a;
    cin>>a;
    if(a=='A') cout<<"T"<<endl;
    else if(a=='T') cout<<'A'<<endl;
    else if(a=='C') cout<<'G'<<endl;
    else cout<<'C'<<endl;
    return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n, a, b;
    cin >> n >> a >> b;
    vector<int32> h(n);
    REP(i,n)cin >> h[i];
    int32 l = 0;
    int32 r = 1e9;
    while(l < r - 1){
        int32 m = (l + r) / 2;
        int32 cnt = 0;
        REP(i,n){
            cnt += max<int32>(h[i] - b * m + a - b - 1, 0) / (a - b);
        }
        if(cnt > m){
            l = m;
        }else{
            r = m;
        }
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++)
  {
    cout << "x";
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		String s = sc.next();
		sb.append(s);
		
		while(true){
			int i = sb.indexOf(sb.substring(0, 1),1);
			if(i==-1){
				System.out.println("No");
				break;
			}
			sb.deleteCharAt(i);
			sb.deleteCharAt(0);
			if(sb.length()==0){
				System.out.println("Yes");
				break;
			}
		}
		
	}

}

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

int main() {
	int h, w, dd[] = {0, 1, 0, -1, 0};
	cin >> h >> w;
	auto inside = [&](int a, int b) {
		return 0 <= a && a < h && 0 <= b && b < w;
	};
	int count = 0;
	string s[h];
	for (auto &t : s) {
		cin >> t;
		for (auto &c : t) {
			if (c == '#') {
				count++;
			}
		}
	}
	int dist[h][w];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			dist[i][j] = -1;
		}
	}
	queue<pair<int, int>> q;
	q.push({0, 0});
	dist[0][0] = 1;
	while (!q.empty()) {
		int x = q.front().first;
		int y = q.front().second;
		q.pop();
		for (int i = 0; i < 4; i++) {
			int nx = x + dd[i], ny = y + dd[i + 1];
			if (!inside(nx, ny) || s[nx][ny] == '#' || (0 <= dist[nx][ny] && dist[nx][ny] <= dist[x][y] + 1)) {
				continue;
			}
			dist[nx][ny] = dist[x][y] + 1;
			q.push({nx, ny});
		}
	}
	if (dist[h - 1][w - 1] < 0) {
		cout << -1 << endl;
		return 0;
	}
	cout << h * w - count - dist[h - 1][w - 1] << endl;
	return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    rep(i, 2*n) {
        if (i % 2 == 0) cout << s[i/2];
        else cout << t[i/2];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    set<string> itms;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        itms.insert(s);
    }
    cout<<itms.size()<<endl;
    return 0;
}


Measured memory_bytes: 19176
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <iomanip>
#include <queue>
#include <algorithm>

using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926535;

class UnionFind {
	std::vector<int> p;

public:
	UnionFind(int n) : p(n, -1) {}

	int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); }

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

	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (p[y] < p[x]) std::swap(x, y);
		if (p[x] == p[y]) --p[x];
		p[y] = x;
		return true;
	}
};
ll fast(ll n, ll k) {
	if (k == 0) {
		return 1;
	}
	if (k == 1) {
		return n;
	}
	if (k % 2 == 0) {
		ll tmp = fast(n, k / 2);
		return tmp * tmp % MOD;
	}
	else {
		ll tmp = fast(n, k / 2);
		tmp = tmp * tmp % MOD;
		return n * tmp % MOD;
	}
}

int main() {

	ll X;
	cin >> X;

	map<ll, ll> mp;

	for (ll i = -1e3; i <= 1e3; i++)
	{
		mp[i] = i * i * i * i * i;
	}

	ll ans_a = 0;
	ll ans_b = 0;

	for (ll i = -1000; i <= 1000; i++)
	{
		for (ll j = i + 1; j <= 1000; j++)
		{
			ll x = mp[j] - mp[i];
			if (x == X) {
				ans_a = j;
				ans_b = i;
				break;
			}
		}
	}
	cout << ans_a << " " << ans_b << endl;
	//UnionFind* tree = new UnionFind(N);
	//for (ll i = 0; i < M; i++)
	//{
	//	ll a, b;
	//	cin >> a >> b;
	//	tree->unite(a - 1, b - 1);
	//}

	//vector<vector<ll>> sames(N);

	//for (ll i = 0; i < N; i++)
	//{
	//	ll root = tree->root(i);
	//	sames[root].push_back(i);
	//}

	//ll ans = 0;
	//for (auto&& e : sames)
	//{
	//	if (e.size() == 0) {
	//		continue;
	//	}
	//	if (e.size() == 1) {
	//		ans++;
	//	}
	//	else {
	//		sort(e.begin(), e.end(), greater<ll>());
	//		cout << e[0] << "," << e[1] << "," << e[2] << endl;
	//		if (e[0] != e[1]) {
	//			ans++;
	//		}
	//	}
	//}
	//cout << ans << endl;
}

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

const double PI=acos(-1.0);

string s;

int main() {
    cin >> s;
    int n = s.size();

    ll ans = 0;
    rep(i, 1 << (n - 1)) {
        ll sum = 0;
        ll a = s[0] - '0';
        rep(j, n - 1) {
            if(i & (1 << j)) {
                sum += a;
                a = 0;
            }
            a = a*10 + (s[j + 1] - '0');
        }
        sum += a;
        ans += sum;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll gcd(ll a2,ll b2){
	ll t;
	while(b2!=0){
		t=a2%b2;
		a2=b2;
		b2=t;
	}
	return a2;
}

int main() {

	ll q;
	cin>>q;

	vector<ll> vec;

	rep(i,q){
		ll a,b;
		cin>>a;
		if(a<2)cin>>b;
		if(a==0)vec.push_back(b);
		if(a==1)cout<<vec[b]<<endl;
		if(a==2)vec.pop_back();
	}

	return 0;
}



Measured memory_bytes: 4908
program main
implicit None
	integer(8)::n,k,i,p,s,u,f,q
	integer(8),allocatable::t(:),d(:),c(:),e(:)
	
	read*,n,k
	allocate(t(n),d(n),c(n),e(n))
	
	do i = 1,n
		read*,t(i),d(i)
		e(t(i)) = e(t(i))+1
	enddo
	
	call h2(d,t,n)
	d(1:n) = d(n:1:-1)
	t(1:n) = t(n:1:-1)
	
	p =0
	c =0
	do i = 1,k
		p = p + d(i)
		c(t(i)) = c(t(i)) + 1
	enddo
	
	s = 0
	do i = 1,n
		if(c(i) > 0) s = s+1
	enddo
	q = p +s*s
	
	u = k
	f = k+1
	
	do i = f,n
		if(c(t(i)) /= 0)cycle
		do
			if(u == 0)exit
			if(c(t(u)) == 1)then
				u = u-1
				else
				exit
			endif
		enddo
		if(u == 0)exit
			c(t(u)) = c(t(u))-1
			c(t(i)) = c(t(i))+1
			p = p-d(u)+d(i)
			s = s+1
			u = u-1
		if(q < p+s*s) q = p+s*s
	enddo
	
	print "(i0)",q
end program main

subroutine h2(a,b,n)
implicit None
	integer(8)::a(n),b(n),x,y
	integer(8)::n,i,ie,i0,i1,i2
	
	do i = n/2,1,-1
		x = a(i);y = b(i);ie = n + 1; i0 = i; i1 = i0 * 2
		do while(i1 < ie)
			i2 = i1 + 1
			if(i2 < ie .and. a(i1) < a(i2)) i1 = i2
			if(a(i1) > x)then
				a(i0) = a(i1);a(i1) = x
				b(i0) = b(i1);b(i1) = y
				else
				exit
			endif
			i0 = i1;i1 = i0 *2
		enddo
	enddo
	do ie = n,2,-1
		x = a(ie);y = b(ie)
		a(ie) = a(1);b(ie) = b(1)
		a(1) = x;b(1) = y
		i0 =1;i1 =2
		do while(i1 <ie)
			i2 = i1 +1
			if(i2 < ie .and. a(i1) < a(i2)) i1 = i2
			if(a(i1) > x)then
				a(i0) = a(i1);a(i1) = x
				b(i0) = b(i1);b(i1) = y
				else
				exit
			endif
			i0 = i1;i1 = i0 *2
		enddo
	enddo
end subroutine h2

Measured memory_bytes: 4088
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int r;
    cin >>r;
    cout << 2*PI*r ENDL;
    
    return 0;
}

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

long long power(long long a,long long x){
    long long ans = 1 ;
    for(long long i=0;i<x;i++){
        ans *= a ;
    }
    return ans ;
}

int main(){
    string s ;
    cin >> s ;
    int len = (int) s.size() ;
    vector<long long> v(len+len-1);
    for(long long i=0,j=0;i<len;i++,j+=2){
        v[j] = s[i]-'0';
        if ( j+1 != v.size() )
            v[j+1] = 0 ;
    }
    long long n = len - 1 ;
    long long total = 0 ;
    for(long long mask=0;mask<(1LL<<n);mask++){
        vector<long long> tmp(v.begin(),v.end());
        long long cur = 1 ;
        for(long long i=0;i<n;i++){
            if ( (1LL<<i) & mask ){
                tmp[cur] = -1;
            }
            cur+=2;
        }
        vector<long long> ans ;
        long long res = 0 ;
        long long cnt = 0 ;
        for(long long i=tmp.size()-1;i>=0;i--){
            if ( tmp[i] == 0 ) continue ;
            if ( tmp[i] == -1 ){
                //cout << res << endl;
                ans.push_back(res);
                res = 0 ;
                cnt = 0 ;
                continue ;
            }
            res += tmp[i]*power(10,cnt++);
        }
        ans.push_back(res);
        for(long long x : ans){
            total += x ;
        }
    }
    cout << total << endl;
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vec vector
#define vi vec<int>
#define vvi vec<vec<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [](auto& i)
#define compare(i, j) [](auto& i, auto& j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

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

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  string s;
  int ans = 0;

  cin >> s;
  int n = SZ(s);
  REP(i, n) {
    if (s[i] == 'A') {
      ans = i;
      break;
    }
  }
  RREP(i, n) {
    if (s[i] == 'Z') {
      cout << i - ans + 1 << endl;
      return;
    }
  }
  // vi v(n);
  // REP(i, n) {
  //   cin >> v[i];
  // }

  cout << ans << endl;
  // REP(i, n) {
  //   cout << v[i];
  // }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


Measured memory_bytes: 720