akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (1000010)
#define P ()
#define M ()
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c) {
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
int n,he,ti,ans; char s[N],t[N];
queue<int> Q;
int main(){
	read(n),he=ti=n; bool fl=1;
	for(int i=1;i<=n;i++)readc(s[i]);
	for(int i=1;i<=n;i++)readc(t[i]),fl&=(s[i]==t[i]);
	if(fl)puts("0"),exit(0);
	while(ti){
		while(ti>1&&t[ti-1]==t[ti])ti--;
		while(he&&(he>ti||s[he]!=t[ti]))he--;
		if(he<=0)puts("-1"),exit(0);
		while(!Q.empty()&&Q.front()-Q.size()>=ti)Q.pop();
		if(he!=ti)Q.push(he);
		ans=max(ans,(int)Q.size()+1);
		ti--;
	}
	cout<<ans;
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define int ll 
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <ll, ll> pi;
typedef tuple<ll,ll,ll> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 500;
const long long oo = (ll)1e18 + 500;
template <typename T> void chmax(T& a, T b) { a = max(a, b); }
template <typename T> void chmin(T& a, T b) { a = min(a, b); }
const int MAXN = 200005;
#ifndef LOCAL
#define cerr if(0)cout
#endif
int H[MAXN], A[MAXN];

struct node {
	int s,e,m,val;
	node *l, *r;
	node (int _s, int _e) {
		s = _s, e = _e;
		m = (s+e)/2;
		val=0;
		if(s!=e) {
			l=new node(s,m);
			r=new node(m+1,e);
		}
	}
	void update(int x, int nval) {
		if(s==e){
			chmax(val,nval);
			return;
		}
		if(x<=m)l->update(x,nval);
		else r->update(x,nval);
		val=max(l->val,r->val);
	}
	int query(int x, int y) {
		if(s==x&&e==y){
			return val;
		}
		if(x>m)return r->query(x,y);
		else if(y<=m)return l->query(x,y);
		else return max(l->query(x,m), r->query(m+1,y));
	}
} *seg;
	

int32_t main() 
{
	IAMSPEED
	int n; cin >> n;
	FOR(i,1,n)cin>>H[i];
	FOR(i,1,n)cin>>A[i];
	seg=new node(0,MAXN);
	FOR(i,1,n){
		int val = seg->query(0,H[i]-1);
		val+=A[i];
		seg->update(H[i],val);
	}
	cout << seg->query(0,MAXN-1);
}



Measured memory_bytes: 31736
n=gets.to_i
a1s=gets.split.map(&:to_i)
a2s=gets.split.map(&:to_i)
now=a1s[0]+a2s.inject(:+)
ans=a1s[0]+a2s.inject(:+)
1.upto(n-1) do |i|
  now=now+a1s[i]-a2s[i-1]
  ans=[ans,now].max
end
puts ans


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 55;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

string arr[MX];
int it[MX];

string solve(string x, string y) {
    string res = "";
    F0R(i,sz(x)) {
        F0R(j,sz(y)) {
            if (x[i] == y[j]) {
                res += x[i]; y[j] = ' ';
                break;
            }
        }
    }
    return res;
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int N; cin >> N;

    F0R(i,N) {
        string x; cin >> x;
        arr[i] = x;
    }

    string res = arr[0];
    FOR(i,1,N) {
        res = solve(res,arr[i]);
    }

    sort(all(res));

    cout<< res << "\n";
}


Measured memory_bytes: 256
#!/usr/bin/env python3
 
import functools
 
MOD = 1000000007
fact = []
 
def main():
    h, w, a, b = map(int, input().split())
    init_fact(200000, MOD)
    mp = get_list_middle_points(h, w, a, b)
    res = 0
    for y, x in mp:
        res += count(1, 1, x, y) * count(x, y, w, h)
        res %= MOD
    print(res)
 
def count(x1, y1, x2, y2):
    dx = abs(x1 - x2)
    dy = abs(y1 - y2)
    count = combi(dx + dy, dx, MOD)
    return count
 
def get_list_middle_points(h, w, a, b):
    li = []
    y = h - a
    x = b + 1
    while (y >= 1 and x <= w):
        li.append((y, x))
        y -= 1
        x += 1
    return li
 
def combi(n, k, mod):
    numera = fact[n]
    denomi = (fact[n - k] * fact[k]) % mod
    return (numera * inv(denomi, mod)) % mod
 
def init_fact(maxn, mod):
    assert len(fact) == 0
    fact.append(1)
    for i in range(1, maxn + 1):
        fact.append((fact[i - 1] * i) % mod)
 
def inv(n, mod):
    return pow(n, mod - 2, mod)
 
def pow(n, p, mod):
    if p == 0:
        return 1
    elif p % 2 == 0:
        x = pow(n, p // 2, mod)
        return (x * x) % mod
    else:
        x = pow(n, p - 1, mod)
        return (x * n) % mod
 
main()

Measured memory_bytes: 56524
#include<iostream>
#include<deque>
#include<cmath>
using namespace std;

void RiffleShuffle(deque<int>& cards,int c)
{
  deque<int> A,B,C;
  int n = cards.size();
  for(int i=0;i<n/2;i++)
    B.push_back(cards[i]);
  for(int j=n/2;j<cards.size();j++)
    A.push_back(cards[j]);

  while(!A.empty() || !B.empty())
    {
      if(!A.empty())
	{
	  int s = A.size();
	  for(int i=0;i<min(c,s);i++)
	    C.push_back(A.front()),A.pop_front();
	}      
      if(!B.empty())
	{
	  int s = B.size();
	  for(int i=0;i<min(c,s);i++)
	    C.push_back(B.front()),B.pop_front();
	}
    }
  cards = C;
}

int main()
{
  int n,r,c;
  while(cin >> n >> r)
    {
      deque<int> cards;
      for(int i=0;i<n;i++)
	cards.push_back(i);
      for(int i=0;i<r;i++)
	{
	  cin >> c;
	  RiffleShuffle(cards,c);
	}
      cout << cards.back() << endl;
    }
  return 0;
}

Measured memory_bytes: 1220
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(A)		(A).begin(),(A).end()
#define DUMP(A)    cout<<#A<<"="<<(A)<< endl
#define SIZE(A)    (int)((A).size())
using namespace std;
typedef long long ll;

int main(){
    int n;
    scanf("%d",&n);
    int dist[100][100];
    const int INF=1000000;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            dist[i][j]=INF;
        }
    }
    for(int i=0;i<n;i++){
        int r,k,t;
        scanf("%d%d",&r,&k);
        r--;
        for(int j=0;j<k;j++){
            scanf("%d",&t);
            t--;
            dist[r][t]=1;
        }
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }
    int p;
    scanf("%d",&p);
    for(int i=0;i<p;i++){
        int s,d,v;
        scanf("%d%d%d",&s,&d,&v);
        s--;d--;
        if(dist[s][d]>=v) printf("NA\n");
        else printf("%d\n",dist[s][d]+1);
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}

int main() {
    fastio;
    ll ans=0;
    ll N,K;
    int r,s,p;
    cin >> N >> K;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    rep(j,K) {
        string a;
        for (int i=j; i < N; i += K) {
            a.push_back(t[i]);
        }
        vector<array<int,3>> dp(a.size()+2);
        int i=1;
        for (; i<=(int)a.size(); ++i) {
            rep(k,3) {
                if (k != 0) updmax(dp[i][0], dp[i-1][k] + (a[i-1] == 's' ? r : 0));
                if (k != 1) updmax(dp[i][1], dp[i-1][k] + (a[i-1] == 'p' ? s : 0));
                if (k != 2) updmax(dp[i][2], dp[i-1][k] + (a[i-1] == 'r' ? p : 0));
                updmax(dp[i][k], dp[i-1][k]);
            }
        }
        ans += max(max(dp[i-1][0],dp[i-1][1]),dp[i-1][2]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 4724
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <deque>

using namespace std;

int const N = 1e5+5;
long long res = 1e13;

int main(){
long long n;
cin>>n;
long long i;
for(i=1;i*i<=n;i++){
    if(n%i==0){
        res = min(res,i+n/i-2);
    }
}
cout<<res;


    return 0;

}

Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = []
count = 0
for _ in range(n):
    a = list(map(int, input().split()))

    sum_v = 0
    for j in range(m):
        sum_v += (a[j] * b[j])
    sum_v += c
    if sum_v > 0:
        count += 1
        
print(count)

Measured memory_bytes: 3064
S = input()
K = int(input())

sames = 1
ans = 0
prev = 'prev'

for s in S:
	if prev == s:
		sames+=1
	else:
		if sames > 1:
			ans+=(sames//2)
			sames = 1
	prev = s
ans+=(sames//2)

add_f = 0
add_b = 0
if S[0] == S[len(S)-1]:
	for s in S:
		if s == S[0]:
			add_f+=1
		else:
			break
	for sr in reversed(S):
		if sr == S[len(S)-1]:
			add_b+=1
		else:
			break
add = add_f+add_b

if len(set(list(S))) == 1:
	print(K*len(S)//2)
else:
	print(ans*K + (add//2)*(K-1) - (add_f//2)*(K-1) - (add_b//2)*(K-1))

Measured memory_bytes: 3064
I,i,H=input,int,range
n,L,R,A,C=i(I()),[0],[0],0,0
for _ in H(n):l,r=map(i,I().split());L+=[l];R+=[r]
L=sorted(L)[::-1];R.sort()
for j in H(n):C+=(L[j]-R[j])*2;A=max(A,C)
print(A)

Measured memory_bytes: 18420
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <limits>

using namespace std;

int N;
size_t MASK;
vector<vector<int>> v;
vector<int> dp;



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

  cin >> N;

  MASK = (1<<N) - 1;

  v = vector<vector<int>>(N, vector<int>(N));
  dp = vector<int>(1<<N, 0);
  auto bc = dp;  // bits count

  for (int i = 0; i < N; ++i)
  { 
    for (int j = 0; j < N; ++j)
    { 
      cin >> v[i][j];
    }
  }
  
  dp[MASK] = 1;

  for (int i = 1; i < (1<<N); ++i)
  {   
    bc[i] = bc[i & (i-1)] + 1;
  }
  
  for (int i = N-1; i >= 0; --i)
  {
    for (int mask = 0; mask < MASK; ++mask)
    {   
      if (bc[mask] != i) continue;
      size_t res = 0;
      for (int j = 0; j < N; ++j)
      {   
        if (v[i][j] && !(mask & (1<<j)))
        {   
          const size_t new_mask = mask | (1<<j);
          res += dp[new_mask];
          res %= 1000000007;
        }   
      }   
      dp[mask] = res;
    }   
  }

  cout << dp[0];

  return 0;
}

Measured memory_bytes: 16640
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <climits>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#define NDEBUG
#include <assert.h>
using namespace std;
const int INF=INT_MAX/4;
/*
Status:Writing
Type:Problemset/HB
Problem ID:Atcoder ARC B
Author:XIZCM
*/
int n,a,b;
vector<int> nei[100005];
//int dis[100005],rdis[100005];
vector<int> bfs(int start){
	vector<int> d(n,INF);
	d[start]=0;
	queue<int> q;
	q.push(start);
	while(!q.empty()){
		int t=q.front();
		q.pop();
		for(int i=0;i<nei[t].size();i++){
			int u=nei[t][i];
			if(d[u]>d[t]+1){
				d[u]=d[t]+1;
				q.push(u);
			}
		}
	}
	return d;
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		scanf("%d%d",&a,&b);
		a--;
		b--;
		nei[a].push_back(b);
		nei[b].push_back(a);
	}
	vector<int> dis=bfs(0);
	vector<int> rdis=bfs(n-1);
	int s=0,f=0;
	for(int i=0;i<n;i++){
		if(dis[i]>rdis[i]){
			s++;
		}
		else{
			f++;
		}
	}
	puts(f>s?"Fennec":"Snuke");
	return 0;
}


Measured memory_bytes: 6656
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

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

    if (A.size() > B.size()) {
        cout << "GREATER" << endl;
        return 0;
    }
    if (A.size() < B.size()) {
        cout << "LESS" << endl;
        return 0;
    }
    if (A == B){
        cout << "EQUAL" << endl;
        return 0;
    }
    ll cnt = 0;
    while (A[cnt] == B[cnt])
    {
        cnt += 1;
    }
    if (A[cnt] > B[cnt]) {
        cout << "GREATER" << endl;
    } else {
        cout << "LESS" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt();
        String ans = "AGC";
        if(n<1200){
            ans="ABC";
        }
        else if(n<2800)ans="ARC";

       
        out.println(ans);
        out.flush();
    }


    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

class P implements Comparable<P>{
    int id, d;
    P(int  id, int d) {
        this.id=id;
        this.d=d;
    }
    public int compareTo(P p){
        return Integer.compare(d,p.d); //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  while(1) {
    C -= B;
    if (C<=0) {
      cout << "Yes" << endl;
      break;
    }
    A -= D;
    if (A<=0) {
      cout << "No" << endl;
      break;
    }
    
  }
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

bool check(vector<ll> &v, ll mid) {
	vector<P> now;
	now.EB(0,-1);
	REP(i,v.size()){
		if(now.back().FI < v[i]){
			now.EB(v[i],0);
		}
		else {
			if(mid <= 1)return false;
			while(now.back().FI > v[i])now.pop_back();
			if(now.back().FI < v[i])now.EB(v[i],0);
			int tmp = now.back().FI;
			int top = now.back().FI;
			while(now.back().FI == top && now.back().SE == mid - 1){
				top = now.back().FI - 1;
				now.pop_back();
			}
			if(now.back().FI != top)now.EB(top,0);
			now.back().SE++;
			if(now.back().FI != tmp)now.EB(tmp,0);
			if(now.front().SE > -1)return false;
		}
		//REP(i,now.size())cout << "(" << now[i].FI << "," << now[i].SE << ") ";cout << endl;
	}
	return true;
}

int main(){
	
	ll n;cin >> n;
	vector<ll> v(n);
	REP(i,n)cin >> v[i];
	
	ll l = 0;
	ll r = LLINF;
	
	while(r - l > 1){
		ll mid = (l + r) / 2;
		//cout << l << " " << r << " " << mid << endl;
		if(check(v,mid))r = mid;
		else l = mid;
	}
	
	cout << r << endl;
	
	return 0;
}


Measured memory_bytes: 9092
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    int m;
    cin >> m;
    vector<string> t(m);
    for (int i = 0; i < m; ++i) {
        cin >> t[i];
    }
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    int cnt=0;
    int i,j,bi,bj;
    i = j = bi = bj = 0;

    int sum = 0;
    while(bi < s.size()) {
        if(i < s.size() && s[i] == s[bi]) {
            i++;
            continue;
        }
        int cnt = 0;
        for (int k = 0; k < t.size(); ++k) {
            if(s[bi] == t[k]) cnt++;
        }
        if(i-bi > cnt) sum = max(sum, i-bi - cnt);
        bi= i;

    }
    cout << sum << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
typedef long long ll;
using namespace std;
int main(void){
    ll h,w;cin>>h>>w;
    if(h==1||w==1){
        cout<<1<<endl;
        return 0;
    }
    ll res=h*w;
    if(res%2==1)res++;
    res/=2;
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int x, y;
    scanf("%d %d", &x, &y);
    
    if ( x < 1 || x > 9 || y > 9 || y < 1 )
        printf("-1\n");
        
    else
        printf("%d\n", x*y);
        
    

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void){
  int r;
  scanf("%d",&r);
  if(r<1200){
    printf("ABC\n");
  }else if((1200<=r) && (r<2800)){
    printf("ARC\n");
  }else{
    printf("AGC\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define lli long long int
#define ld long double
#define fop(i,m,n) for (int i=(m);i<(n);i++)
#define FOP(i,m,n) for (int i=(m)-1;i>=(n);--i)
#define test(x) cout << #x << ' ' << x << endl;
#define printv(a) {\
    for (auto y : a) cout << y << ' ';\
    cout << '\n';\
}
#define eb emplace_back
#define pb push_back
#define mp make_pair 
#define mt make_tuple
#define pii pair<int,int> 
#define pll pair<lli,lli>
#define tiii tuple<int,int,int>
#define all(a) a.begin(), a.end()
#define X first
#define Y second
#define oset tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update>
#define readfile freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); 
auto SEED = chrono::steady_clock::now().time_since_epoch().count();
mt19937 rng(SEED);
const int mod = 1e9 + 7, x = 864197532, N = 100000, logN = 17, K = 350;

int main () {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	map <pii, int> cnt;
	fop (i,0,n) {
		string s;
		cin >> s;
		bool is = false;
		lli need = 0, tmp = 0;
		for (char c : s) {
			if (c == '.') {
				is = true;
			} else {
				tmp = tmp * 10 + c - '0';
				if (is) need++;
			}
		}
		int a = -need, b = -need;
		while (tmp % 2 == 0) {
			tmp /= 2;
			a++;
		}
		while (tmp % 5 == 0) {
			tmp /= 5;
			b++;
		}
		cnt[{a, b}]++;
	}
	lli ans = 0;
	for (auto A : cnt) if (A.X.X >= 0 && A.X.Y >= 0) {
		ans += 1ll * A.Y * (A.Y - 1) / 2;
	}
	for (auto it = cnt.begin(); it != cnt.end(); it++) {
		for (auto it2 = it; it2 != cnt.end(); ++it2) if (it2 != it) {
			if (it->X.X + it2->X.X >= 0 && it->X.Y + it2->X.Y >= 0) {
				ans += 1ll * it->Y * it2->Y;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3644
N, K = [int(i) for i in input().split()]

import string

numbers = "0123456789"
alphabets = string.ascii_letters # a-z+A-Zをロード
characters = numbers + alphabets

def base_cvt(value, n=2):
    try:
        tmp = int(value)
    except:
        raise ValueError('Invalid value:', value)

    if n < 2 or n > len(characters):
        raise ValueError('Invalid n:', value)

    result = ''
    tmp = int(value)
    while tmp >= n:
        idx = tmp%n
        result = characters[idx] + result
        tmp = int(tmp / n)
    idx = tmp%n
    result = characters[idx] + result
    return result

print(len(base_cvt(N, K)))


Measured memory_bytes: 3960
from collections import deque

n = int(input())
a = list(map(int, input().split()))
b = []
if n >= 2:
    for i in range(n - 1):
        if a[i] != a[i + 1]:
            b.append(a[i])
    if b[len(b) - 1] != a[n - 1]:
        b.append(a[n - 1])
    l = len(b)
    m = 0
    ans = 1
    for i in range(l - 1):
        if m == 0:
            if b[i] < b[i + 1]:
                m = 1
            else:
                m = -1
        elif m == 1:
            if b[i] > b[i + 1]:
                ans += 1
                m = 0
        else:
            if b[i] < b[i + 1]:
                ans += 1
                m = 0
else:
    ans = 1
print(ans)

Measured memory_bytes: 14636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll nums[1010101];

bool divisor(ll n) {
    vector<ll> div;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            if (nums[i] > 0) return false;
            if (i != n / i) {
                if (nums[n / i] > 0) return false;
            }
        }
    }
    return true;
}

int main() {
    ll n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        nums[a[i]]++;
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        nums[a[i]]--;
        if (divisor(a[i])) ans++;
        nums[a[i]]++;
    }
    cout << ans << endl;
}

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

int main() {
	ll X,c=0;
	double r=100;
	cin >> X;

	while(r < X) {
		ll x = r*0.01;
		r += x;
		++c;
	}

	cout << c << endl;
}

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

int main(int argc, char const *argv[])
{
	int n;
	while(~scanf("%d",&n)){
		int a[n+5],b[n+5],c[n+5];
		for (int i = 1; i <= n; ++i)
		{
			scanf("%d",&a[i]);
		}
		for (int i = 1; i <= n; ++i)
		{
			scanf("%d",&b[i]);
		}
		for (int i = 1; i <= n-1; ++i)
		{
			scanf("%d",&c[i]);
		}
		int ans=b[a[1]],pre=a[1];
		for (int i = 2; i <= n ; ++i)
		{
			ans+=b[a[i]];
			//printf("ans==%d+=b[a[%d]]\n",ans,i);
			if (pre==a[i]-1)
			{
				ans+=c[a[i]-1];
				//printf("ans==%d+=c[a[%d]]\n",ans,i);
			}
			pre=a[i];
		}
		printf("%d\n",ans );
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;

/**
 * https://beta.atcoder.jp/contests/abc077/tasks/arc084_b
 */
public class Main {

	static Node nodes[];
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		nodes = new Node[N];
		for(int i=0; i<N; i++) {
			nodes[i] = new Node(i);
		}

		for(int i=0; i<N-1; i++){
			Node u = nodes[Integer.parseInt(sc.next()) - 1];
			Node v = nodes[Integer.parseInt(sc.next()) - 1];
			int w = Integer.parseInt(sc.next());
			u.neighbors.put(v.id, w);
			v.neighbors.put(u.id, w);
		}
		sc.close();
		
		nodes[0].ans = 0;
		setAns(nodes[0]);
		
		for(Node n: nodes) {
			System.out.println(n.ans);
		}
		
	}
	
	public static void setAns(Node node){
		for(Entry<Integer, Integer> entry : node.neighbors.entrySet()) {
			Node n = nodes[entry.getKey()]; 
			if (n.ans < 0) {
				if(entry.getValue()%2 == 0) {
					n.ans = node.ans;
				}else {
					n.ans = (node.ans+1)%2;
				}
				setAns(n);
			}
		}
	}
	
	static class Node{
		int id;
		int ans = -1;
		HashMap<Integer, Integer> neighbors = new HashMap<Integer, Integer>();
		Node(int id){
			this.id = id;
		}
	}

}

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    string s,p;
    cin >> s >> p;
    s=s+s;
    for(int i=0;i<s.size()/2;i++){
        if(s.substr(i,p.size())==p){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    
    return 0;
}


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

#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main() {
    fast;
    ll H, W, h, w;
    cin >> H >> W >> h >> w;
    ll tot = H*W;
    tot -= h*W;
    tot -= (H-h)*w;
    cout << tot << endl;
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
AB = []
money = 0
drinks = 0

for i in range(N):
  A,B = map(int,input().split())
  AB.append([A,B])

AB.sort()

for i in range(N):
  if 0 < M-drinks < AB[i][1]:
    money += (M-drinks)*AB[i][0]
    break
  elif AB[i][1] <= M-drinks:
    money += AB[i][1]*AB[i][0]
    drinks += AB[i][1]
  else:
    break
    
print(money)

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    map<string, int> money;
    int N, M;
    cin >> N;

    rep(i, N) {
        string t;
        cin >> t;
        auto itr = money.find(t);
        if (itr == money.end()) {
            money[t] = 1;
        }
        else {
            money[t] = money[t] + 1;
        }
    }

    cin >> M;
    rep(i, M) {
        string t;
        cin >> t;
        auto itr = money.find(t);
        if (itr == money.end()) {
            money[t] = -1;
        }
        else {
            money[t] = money[t] - 1;
        }
    }

    int ans = 0;
    for (auto itr = money.begin(); itr != money.end(); itr++) {
        ans = max(ans, itr->second);
    }

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

Measured memory_bytes: 256
#include <stdio.h>

char a[101];

int main()
{	 
	int n, i, j;
		
	scanf("%d", &n);
	scanf("%s", a);
	if(n & 1){
		puts("No");
		return 0;
	} 
	for(i = 0, j = n >> 1; j < n && a[i] == a[j]; i++, j++);
	if(j == n) puts("Yes");
	else puts("No");
		
	return 0;
}

Measured memory_bytes: 1612
N=input()

num=list(N)
sum=0;
for i in range(1 << len(num)-1):
    l=[]
    for j in range(len(num)):
        l+=num[j]
        if (j != len(num)-1):
            if (i & (1<<j)):
                l+=['+']
        
    sum+=eval("".join(l))
print(sum)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.BitSet;
public class Main {
	public static void main(String[] args) throws IOException {
		int n;
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String str;
		BitSet bs = new BitSet(1000000);
		bs.set(2,1000000,true);
		for(int i=2;i<=1000;i++){
			if(!bs.get(i))continue;
			for(int j=i*2;j<1000000;j+=i)bs.clear(j);
		}
		while((str=bf.readLine())!=null){
			n=Integer.parseInt(str);
			System.out.println(bs.get(1,n+1).cardinality());
		}
	}
}

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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  double a,b,x; cin >> a >> b >> x;

  double v = a * a * b;
  double pi = acos(-1);

  if(x < v * 0.5){
    double theta = atan(a * b * b / 2.0 / x);
    cout << theta * 180 / pi  << endl;
  } else { 
    double p = (v-x) / ( a * a * 0.5);
    double theta = atan(p/a);
    cout << theta * 180 / pi << endl;
  }
}


Measured memory_bytes: 4084
#include<stdio.h>

int main(void)
{
  int N;
  int i;
  int count = 0;
  int max = 1;
  
  scanf("%d", &N);

  if(N >= 2) max = 2;
  if(N >= 4) max = 4;
  if(N >= 8) max = 8;
  if(N >= 16) max = 16;
  if(N >= 32) max = 32;
  if(N >= 64) max = 64;
  
  printf("%d\n", max);
  
  return 0;
}
  
  

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

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

    vector<int> d(k);
    vector<vector<int>> a(k,vector<int>(n));
    vector<bool> check(n);

    for(int i=0; i<n; i++){
        check[i]=false;
    }

    for(int i=0; i<k; i++){
        cin>>d[i];
        for(int j=0; j<d[i]; j++){
            cin>>a[i][j];
            check[a[i][j]-1]=true;
        }
    }

    int count=0;
    for(int i=0; i<n; i++){
        if(check[i]==false){
            count++;
        }
    }

    cout<<count<<endl;
}

Measured memory_bytes: 3676
package main

import "fmt"

/*
展開図の展開の仕方を固定して、回転動作によってどのように展開図の数字が移るかを記録する。
展開図は次の通り。手前の目2番を中心に据える展開の仕方。
         ___
    ____|_1_|_______
    |_4_|_2_|_3_|_5_|
        |_6_|

サイコロの状態は上面と前面を指定することで一意に決定される。それぞれを指定された目に揃えて、
展開図の3番を出力すれば良い。
*/
type Dice struct {
	Nums []int
}

func (d *Dice) rotate(direction string) {
	switch direction {
	case "W":
		d.Nums[0], d.Nums[2], d.Nums[5], d.Nums[3] = d.Nums[2], d.Nums[5], d.Nums[3], d.Nums[0]
	case "E":
		d.Nums[0], d.Nums[2], d.Nums[5], d.Nums[3] = d.Nums[3], d.Nums[0], d.Nums[2], d.Nums[5]
	case "N":
		d.Nums[0], d.Nums[4], d.Nums[5], d.Nums[1] = d.Nums[1], d.Nums[0], d.Nums[4], d.Nums[5]
	case "S":
		d.Nums[5], d.Nums[1], d.Nums[0], d.Nums[4] = d.Nums[1], d.Nums[0], d.Nums[4], d.Nums[5]
	}
}

func (d *Dice) roll(direction string) {
	switch direction {
	case "R":
		d.Nums[3], d.Nums[1], d.Nums[2], d.Nums[4] = d.Nums[1], d.Nums[2], d.Nums[4], d.Nums[3]
	case "L":
		d.Nums[3], d.Nums[1], d.Nums[2], d.Nums[4] = d.Nums[4], d.Nums[3], d.Nums[1], d.Nums[2]
	}
}

func (d *Dice) printStatus() {
	status :=
`	　　　 _ _ _ _
     _ _ _|_%3d_|_ _ _ _ _ _
    |_%3d_|_%3d_|_%3d_|_%3d_|
 　       |_%3d_|
`
	fmt.Printf(status, d.Nums[0], d.Nums[3], d.Nums[1], d.Nums[2], d.Nums[4], d.Nums[5])
	fmt.Println()
}

func getIndex(nums []int, target int) (index int) {
	for i, v := range nums {
		if target == v {
			index = i
			break
		} else {
			index = -1
		}
	}
	return index
}

func main() {
	dice := Dice{
		make([]int, 6),
	}
	for i := 0; i < 6; i++ {
		var n int
		fmt.Scan(&n)
		dice.Nums[i] = n
	}
	var q int
	fmt.Scan(&q)
	for i := 0; i < q; i++ {
		var up, front int
		fmt.Scan(&up, &front)

		// 上面を揃える
		upIndex := getIndex(dice.Nums, up)
		switch upIndex {
		case 0: // もう揃ってる
			break
		case 1: // N方向に一回回転させて揃う
			dice.rotate("N")
		case 2: // W方向に一回回転させて揃う
			dice.rotate("W")
		case 3: // E方向に一回回転させて揃う
			dice.rotate("E")
		case 4: // S方向に一回回転させて揃う
			dice.rotate("S")
		default: // 初期状態の上面の対面を上面に指定する→適当な同一方向に二回転
			dice.rotate("N")
			dice.rotate("N")
		}
		// dice.printStatus()

		// 前面を揃える
		frontIndex := getIndex(dice.Nums, front)
		switch frontIndex {
		case 1: // もう揃ってる
			break
		case 2: // 右方向に一回回転させて揃う
			dice.roll("R")
		case 3: // 左方向に一回回転させて揃う
			dice.roll("L")
		case 4: // 上下面指定された後の状態の前面の対面を前面に指定する→適当な同一方向に二回転
			dice.roll("R")
			dice.roll("R")
		default: // あり得ない組み合わせの指定。たとえばup == 1 && front == 1。
			fmt.Println("Impossible order.")
		}
		// dice.printStatus()

		fmt.Println(dice.Nums[2])
	}
}



Measured memory_bytes: 1116
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    char s[100000];
    cin>>s;
    long long t=strlen(s);
    if(s[0]==s[strlen(s)-1]){
    	if(t%2==1) cout<<"Second"<<endl;
    	else cout<<"First"<<endl;
    }
    else{
        if(t%2==0) cout<<"Second"<<endl;
    	else cout<<"First"<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
using namespace std;
#define int long long
#define inf   1000000009
#define minf -1000000009

signed main() {
	int n, m;
	cin >> n >> m;

	int sum = m * 1900 + (n - m) * 100;
	cout << sum*(1 << m) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF=pow(2,31)-1;
const int MAXN=1<<17;
int maxn;
int dat[2*MAXN-1];

void init(int n) {
  maxn=1;
  while (maxn<n) {
    maxn*=2;
  }
  fill(dat,dat+2*maxn-1,INF);
}
void update(int i,int x) {
  i+=maxn-1;
  dat[i]=x;
  while (i>0) {
    i=(i-1)/2;
    dat[i]=min(dat[2*i+1],dat[2*i+2]);
  }
}
int find(int x,int y,int k=0,int l=0,int r=maxn) {
  if (r<=x || y<=l) {
    return INF;
  }
  if (x<=l && r<=y) {
    return dat[k];
  } else {
    int vl=find(x,y,2*k+1,l,(l+r)/2);
    int vr=find(x,y,2*k+2,(l+r)/2,r);
    return min(vl,vr);
  }
}
int main() {
  int n, q;
  cin >> n >> q;
  init(n);
  for (int i=0; i<q; i++) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com==0) {
      update(x,y);
    } else {
      printf("%d\n",find(x,y+1));
    }
  }
  return 0;
}

Measured memory_bytes: 4204
#include <iostream>
#include <cstdio>

using namespace std;

int dx[4] = {0, -1,  0, 1};
int dy[4] = {1,  0, -1, 0};
bool in_area(int x, int y, int W, int H){
  // cout << "in?" << endl;
  bool in;
  in = (0 <= x && x < W) && (0 <= y && y < H);
  return in;
}

string count_bomb_zone(string s[], int x, int y, int W, int H){
  // cout << "count" << y << "," << x << endl;
  int k, _x, _y, count = 0;
  if (s[y].at(x) == '.')
    return ".";
  for (k = 0; k < 4; k++){
    _x = x + dx[k];
    _y = y + dy[k];
    if (in_area(_x, _y, W, H) && s[_y].at(_x) == '#'){
      count ++;
      // cout << "find"<< s[_y].at(_x)<< _y << "," << _x << endl;
    }
  }
  return to_string(count);
}
int main(){
  int H, W, x, y;
  string S[50];
  bool can = true;
  cin >> H >> W;
  for (y = 0; y < H; y++){
    cin >> S[y];
  }

  for (y = 0; y < H; y++){
    for (x = 0; x < W; x++){
      // cout << count_bomb_zone(S, x, y, W, H);
      if (count_bomb_zone(S, x, y, W, H) == "0")
        can = false;
    }
  }
  if (can){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

namespace paiza
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var S = Console.ReadLine();

            //foreach (var (c, i) in S.Select((x, i) => (x, i)))
            for (var i = 0; i < NK[0]; i++)
            {
                Console.Write(i + 1 == NK[1] ? S[i].ToString().ToLower() : S[i].ToString());
            }
            Console.WriteLine();
            //    var xai = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            //    var N = int.Parse(Console.ReadLine());

            //    var p = new int[N];
            //    foreach (var i in Enumerable.Range(0, N))
            //    {
            //        p[i] = int.Parse(Console.ReadLine());
            //    }

            //    var reverses = new Dictionary<int, int>();

            //    for (var i = 0; i < 6; i++)
            //    {
            //        if (i % 2 == 0)
            //        {
            //            reverses.Add(xai[i], xai[i + 1]);
            //        }
            //        else
            //        {
            //            reverses.Add(xai[i], xai[i - 1]);
            //        }
            //    }

            //    var point = 0;
            //    var number = p[0];

            //    for (var i = 0; i < N - 1; i++)
            //    {
            //        if (reverses[number] == p[i + 1])
            //        {
            //            point += 2;
            //        }
            //        else if (number == p[i + 1])
            //        {

            //        }
            //        else
            //        {
            //            point += 1;
            //        }
            //        number = p[i + 1];
            //    }

            //    Console.WriteLine(point);
            //}
        }
    }
}

Measured memory_bytes: 13268
#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 = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

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

string s;

int main() {
  cin >> s;
  int begin = 0;
  int end = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'A') {
      begin = i;
      break;
    }
  }
  for (int i = s.size() - 1; i >= 0; --i) {
    if (s[i] == 'Z') {
      end = i;
      break;
    }
  }

  cout << end - begin + 1;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size() 
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ***********************************/

const int mod = 1e9 + 7;

const int N = 1e6 + 5;
ll fac[N+3], reFac[N+3];
ll power8[N+3];

ll power(ll a, ll b){
    ll res = 1;
    while(b){
        if(b & 1){
            (res *= a) %= mod;
        }
        (a *= a) %= mod;
        b >>= 1;
    }
    return res;
}

void calc() {
    fac[0] = 1;
    for (int i = 1; i <= N; ++i)
        fac[i] = (fac[i-1] * i) % mod;

    reFac[N] = power(fac[N], mod-2);
    for (int i = N; i > 0; --i){
        reFac[i-1] = (reFac[i] * i) % mod;
    }
}

ll modMul(ll a, ll b) {
    return (a  * b) % mod;
}

ll nCr(ll a, ll b) {
    return modMul(fac[a], modMul(reFac[b], reFac[a - b]));
}

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

    calc();

    ll n; cin >> n;
    if (n <= 1) {
        cout << 0;
        return 0;
    }
    power8[0] = 1;
    for (int i = 1; i <= n; ++i) {
        power8[i] = modMul(power8[i-1], 8);
    }

    ll ans = (power(10, n) - power(8, n) + mod) % mod;
    ll exclude = 0;
    for (int i = 1; i <= n; ++i) {
        exclude += modMul(nCr(n, i), power8[n - i]);
        exclude %= mod;
    }

    ans = (ans - (2 * exclude) % mod + mod) % mod;
    cout << ans;


    return 0;
}



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

int main() {
  int a,b;
  cin >> a >> b;
  if(b != 100){
    for(int i=0;i<a;i++){
    b *= 100;
    }
    cout << b << endl;
  }else{
    b++;
    for(int i=0;i<a;i++){
    b *= 100;
    }
    cout << b << endl;
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES // for C++  
#include <cmath> 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>
#include <functional>


using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (2*b==a+c)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}

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

int main() {
  while (1) {
    int n, x;
    cin >> n >> x;

    if (n == 0 && x == 0) break;

    int indices[n];
    for (int e = 0; e < n; e++) {
      indices[e] = e + 1;
    }

    int count = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        for (int k = j + 1; k < n; k++) {
          if (indices[i] + indices[j] + indices[k] == x) count ++;
        }
      }
    }

    cout << count << endl;
  }

  return 0;
}



Measured memory_bytes: 3096
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

typedef long long LL;

const int Mod = 1e9 + 7;
const int N = 3e6 + 10;

int n, m, k;
LL pw2[N], pw3[N], fac[N], inv[N];

LL Power(LL a, LL b) {
	LL c = 1;
	for (; b; b >>= 1, (a *= a) %= Mod)
		if (b & 1)
			(c *= a) %= Mod;
	return c;
}

void Init() {
	pw2[0] = pw3[0] = 1;
	fac[0] = inv[0] = 1;
	for (int i = 1; i < N; ++i) {
		pw2[i] = pw2[i - 1] * 2 % Mod;
		pw3[i] = pw3[i - 1] * 3 % Mod;
		fac[i] = fac[i - 1] * i % Mod;
	}
	inv[N - 1] = Power(fac[N - 1], Mod - 2);
	for (int i = N - 2; i; --i)
		inv[i] = inv[i + 1] * (i + 1) % Mod;
}

LL Binom(int m, int n) {
	if (n > m)
		return 0;
	return fac[m] * inv[n] % Mod * inv[m - n] % Mod;
}

void Solve() {
	scanf("%d %d %d", &n, &m, &k);
	LL fb = 0;
	LL fc = 0;
	LL ans = 0;
	for (int i = n; i <= n + m + k; ++i) {
		LL cnt = Binom(i - 1, n - 1);
		if (i - n == m + 1) 
			fb = 1;
		else if (i - n > m + 1) 
			fb = (fb * 2 + Binom(i - n - 1, m)) % Mod;
		if (i - n == k + 1)
			fc = 1;
		else if (i - n > k + 1)
			fc = (fc * 2 + Binom(i - n - 1, k)) % Mod;
		LL f = (pw2[i - n] - fb + Mod - fc + Mod) % Mod;
		(ans += f * cnt % Mod * pw3[n + m + k - i]) %= Mod;
	}
	printf("%lld\n", ans);
}

int main() {

	Init();
	Solve();

	return 0;
}


Measured memory_bytes: 94080
#include <iostream>

using namespace std;

int main(void){
    long long a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k==0)
        cout << 0;
    else if(k<=a)
        cout << k;
    else if(k<=(a+b))
        cout << a;
    else
        cout << (a-(k-a-b));
    return 0;
}

Measured memory_bytes: 3648
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::vec::Vec;

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

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

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

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

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

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

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

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

fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize,
    }
    if a % 2 == 0 || b % 2 == 0 || c % 2 == 0 {
        println!("0");
        return;
    }
    let mut smaller = vec![a, b, c];
    smaller.sort();
    let result = smaller[0] * smaller[1];
    println!("{}", result);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;
 
//DONT WASTE YOUR TIME
//prove yourself
//remember....fuck ps&&as hard....show them your are better then them
//Be confident.....dont lose hope.......You can do it.....
//dimaag  khoob h tere meh ....bas concentration ki kami h
//CONCENTRATE
//A,B,C dimaag nhi ...observation h .....zyaada mat sochna unme.....bas observe karna dhyaan se aur implement kar daal jitni jaldi ho sake
 
//capture it
 
const ll N= 1e6+55,mod = 1e9+7;
ll power(ll x,ll n){
	ll r=1;
	while(n>0){
		if(n%2==1){
			r=r*x;
		}
		n=n/2;
		x=x*x;
	}
	return r;
}
int main() {
 	//freopen("task.in","r",stdin);freopen("task.out","w",stdout);
	ll n,c,x,y,i,j;	
	sc(n);
	c=0;
	x=power(3,n);
	for(i=0;i<n;i++){
		sc(y);
		if(y%2==0)c++;
	}
	y=power(2,c);
	j=x-y;
	pr(j);
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int a, b; cin >> a >> b;
  if((a * b) % 2 == 0) cout << "Even" << endl;
  else cout << "Odd" << endl;
}

Measured memory_bytes: 256