akhauriyash/Code-Regression huggingface dataset:
import numpy as np

N = int(input())
nums = np.array([int(input()) for _ in range(N)])

# 最も大きな値を調べる
sorted_nums = sorted(nums, reverse=True)
max_num = sorted_nums[0]
# 2番目に大きな値を調べる
second_max_num = sorted_nums[1]

for i in range(N):
    # 除外する値を取得する
    exclude_num = nums[i]
    # 除外する値が最大値なら2番目の値を表示する
    if exclude_num == max_num:
        print(second_max_num)
    # それ以外なら最大値を表示する
    else:
        print(max_num)


Measured memory_bytes: 23860
from operator import sub, add
from itertools import product

a, b, c, d = map(int, input())

for op1, op2, op3 in product([sub, add], repeat=3):
    if op3(op2(op1(a, b), c), d) == 7:
        mark = lambda op: "+" if op == add else "-" 
        print(a, mark(op1), b, mark(op2), c, mark(op3), d, "=7", sep="")
        exit()

Measured memory_bytes: 3064
"use strict";
function main(input) {
  let s = 0;
  let w = 0;
  [s, w] = input[0].trim().split(" ").map(i => parseInt(i));
  
  console.log((s<=w)?"unsafe":"safe");
 
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

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

int main() {

	int n,k;
	cin>>n>>k;
	int a[n]; 
	for(int i=0;i<n;i++) cin>>a[i];
	int cnt=0;
	for(int i=0;i<n;i++) { if(a[i]>=k) cnt++; }
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 768
N, M = list(map(int, input().split()))
g = [[] for _ in range(N + 1)]  # 部屋mにつながっている部屋一覧
for m in range(M):
    a, b = list(map(int, input().split()))
    if a <= N and b <= N:
        g[a].append(b)
        g[b].append(a)

queue = [1]
d = [None] * (N + 1)
d[0] = 0
d[1] = 0
while queue:
    v = queue.pop(0)
    for i in g[v]:
        # print('g[v]',g[v])
        if d[i] is None:
            d[i] = v
            queue.append(i)
        # print('d[i]',d[i],'queue',queue)
for i in range(N + 1):
    if d[i] is None:
        print('No')
        exit()
print('Yes')
for i in range(2, N + 1):
    print(d[i])


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

int main()
{
	int i,n,max=0;
	int count[101]={0};

    while(cin >> n){
		if(cin.eof()){break;}
		count[n]++;  //count[n]の個数を数える
		if(max<count[n]){  //最頻値maxをcount[n]の個数が超えたときmaxを更新
			max=count[n];
		}
	}
	for(i=1;i<101;i++){  //count[i]の値がmaxのとき出力
		if(max==count[i]){
			cout << i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
    
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
const int INF = 1000*1000*1000;
const ll LINF = (ll)1e18;
int xv[4] = {-1, 1, 0, 0};
int yv[4] = {0, 0, -1, 1};

vector<vector<int>> mp(501, vector<int>(501,0));

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int H, W, K;
    cin >> H >> W >> K;
    if(W == 1){
        cout << 1 << endl;
        return 0;
    }
    vector<vector<int>> dp(H+1, vector<int>(W,0));
    dp[0][0] = 1;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < (1 << (W-1)); j++){
            int c = j;
            bool check = true;
            while(c > 0){
                if((c & 3) == 3){
                    check = false;
                    break;
                }
                c /= 2;
            }
            if(check){
                bool swap = false;
                for(int k = 0; k < W; k++){
                    if(j & (1 << k)){
//                        cout << "1";
                        if(k + 1 < W){
                            dp[i+1][k+1] += dp[i][k];
                            dp[i+1][k+1] %= MOD;
                            dp[i+1][k] += dp[i][k+1];
                            dp[i+1][k] %= MOD;
                            swap=true;
                        }
                    }else{
//                        cout << "0";
                        if(swap == false){
                            dp[i+1][k] += dp[i][k];
                            dp[i+1][k] %= MOD;
                        }
                        swap = false;
                    }
                }
//                cout << endl;
//                cout << j << endl;
            }
            
        }
    }
    cout << dp[H][K-1]%MOD << endl;
    return 0;
}


Measured memory_bytes: 1280
n=int(input())
s=input()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ct=r*g*b
for i in range(n-2):
    for j in range(i+1,n-1):
        k=2*j-i
        if k<=n-1:
            if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
                ct-=1
print(ct)

Measured memory_bytes: 68144
#!/usr/bin/env python3
N, A, B = map(int, input().split())
S = input()
nc = 0
bc = 1
for i in range(N):
    ans = False
    if S[i] == 'a' and nc < A + B:
        ans = True
        nc += 1
    elif S[i] == 'b' and nc < A + B and bc <= B:
        ans = True
        nc += 1
        bc += 1
    print('Yes' if (ans) else 'No')


Measured memory_bytes: 4024
#include <iostream>
using namespace std;
int main(void){
   int n, m, l;
   long long t;
   cin>> n >> m >> l;
   int A[n][m], B[m][l];
   for(int i=0;i<n;i++){
       for(int j=0;j<m;j++){
           cin>>A[i][j];
       }
   }
   for(int i=0;i<m;i++){
       for(int j=0;j<l;j++){
           cin>>B[i][j];
       }
   }
   for(int i=0;i<n;i++){
       for(int j=0;j<l;j++){
           t=0;
           for(int k=0;k<m;k++){
               t+=A[i][k]*B[k][j];
           }
           if(j==0) cout<<t;
           else cout<<" "<<t;
       }
       cout<<endl;
   }
   // Your code here!

}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {   if (y & 1)
        res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main()
{
   ll n;
   cin>>n;
   if(n==2)
   {
   	cout<<1;
   	return 0;
   }
   ll ans=2;
   for(ll i=2;i*i<=n;i++)
   {
   	  if(n%i==1)
   	  {
   	  	if(n/i!=i)
   	  	ans+=2;
   	  	else
   	  	ans++;
   	  }
   	  else if(n%i==0)
   	  {
   	      ll x=n;
			 while(x>=i&&x!=1)
			 {
			     if(x%i==0)
				 x/=i;
				 else
				 {
				    ll y=x/i;
					y=y*i;
					x-=y;
					if(x!=1)
					break;
				 }
			 }
				if(x==1)
				ans++;	
	  }
   }
   cout<<ans;
    
}

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

using ll = long long;

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

  vector<ll> w(N), v(N);
  for (int i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
  }

  // dp[i][j]はi番目までの品物から選択し、価値がj以下の時の最小のw
  vector<vector<ll>> dp(110, vector<ll>(100100, 1000000000000000));
  dp[0][0]=0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 100100; j++) {
      if(j>=v[i]) dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]]+w[i]); // i番目の商品を選ぶかどうかの判断
      else dp[i+1][j] = dp[i][j];
    }
  }


  ll ans=0;
  for (int i = 0; i < 100100; i++) {
    if(dp[N][i]<=W) ans = max(ans, (ll)i);
  }

  cout << ans << endl;
}


Measured memory_bytes: 87296
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

	string S;
	cin >> S;

	int count = 0;
	reple(i, 0, S.length() - 3)
	{
		if (S.substr(i, 3) == "ABC") count++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var r []rune
	for n > 0 {
		n--
		r = append([]rune{rune('a' + n%26)}, r...)
		n /= 26
	}
	fmt.Println(string(r))
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  vector<int> A(n);
  int p;
  rep(i, n) {
    cin >> A[i];
    if(A[i] == 1) p = i;
  }
  cout << (n-1+k-2)/(k-1) << endk;
  return 0;
}


Measured memory_bytes: 3700
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    string s;
    cin >> s;

    if (s == "AAA" || s == "BBB") {
        cout << "No" << '\n';
    } else {
        cout << "Yes" << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int  long long
#define tc(t)  int t; cin>>t; while(t--)
#define f(n)    for(int i=0;i<n;i++)
#define endl   "\n"





int common_sub(string first,string second,int i,int j,vector<vector<int>>&dp)

{
    if(i==first.size()||j==second.size()) return 0;

    if(dp[i][j]!=-1) return dp[i][j];
   // cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;

    if(first[i]==second[j]) dp[i][j]= 1+common_sub(first,second,i+1,j+1,dp);
    else{
        dp[i][j]=max(common_sub(first,second,i,j+1,dp),common_sub(first,second,i+1,j,dp));

    }
    return dp[i][j];





}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     string first,second;
     cin>>first>>second;
     int n=first.size();
     int m=second.size();
     vector<vector<int>>dp(n+1,vector<int>(m+1,0));

     //cout<<common_sub(first,second,0,0,dp)<<endl;
     string answer;
     for(int i=1;i<=n;i++)
     {
         for(int j=1;j<=m;j++)
         {
          if(first[i-1]==second[j-1]) {
              dp[i][j] = 1 + dp[i - 1][j - 1];

          }
          else {
              dp[i][j]=max(dp[i-1][j],dp[i][j-1]);

          }
         }

     }

     int i=n;int j=m;
     while(i>0&&j>0)
     {
         if(first[i-1]==second[j-1])
         {
             answer+=first[i-1];
             i--;
             j--;
         } else
         {
             if(dp[i-1][j]>dp[i][j-1])
             {
                 i--;
             }
             else j--;


         }





     }
     reverse(answer.begin(),answer.end());
     cout<<answer<<endl;







}

Measured memory_bytes: 73592
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>

using namespace std;

int main(){
	int a,b,k;
	cin>>a>>b>>k;
	int count=0;
	for(int i=min(a,b);i>=0;i--){
		if(a%i==0&&b%i==0){
			count++;
			if(count==k){
				cout<<i<<endl;
				break;
			}
		}
	}
	return 0;



}


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

int main() {
  int N,M;
  cin >> N;
  int ans,C = 0; //カウント保存用
  for(int i = 0; i < N; i++){
    M = i + 1;
    int count = 0;
    
    while (M % 2 == 0){
    count++;
    M /= 2;
    }
    if (count >= C){
      C = count;
      ans = i + 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC opatimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }

int main() {
//    freopen("in.txt","r", stdin);
//    freopen("out.txt","w", stdout);
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int n;
    cin >> n;
    vector<pair<int,int>> a(n);
    for (auto& pa : a) {
        cin >> pa.first >> pa.second;
        pa.first += pa.second;
    }

    sort(begin(a), end(a));

    vector<int> dp(n + 1, 0);
    for (int i = 0; i < n; ++i) {
        auto idx = upper_bound(begin(a), begin(a) + i, make_pair(a[i].first - 2 * a[i].second + 1, 0)) - begin(a);
        dp[i + 1] = max(dp[i], dp[idx] + 1);
    }
    cout << *max_element(begin(dp), end(dp)) << endl;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b+a); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

// 最大公約数: greatest common divisor
ll gcd(ll a, ll b) { if (b == 0) return a; else return gcd(b, a % b); }

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

  int k;
  cin >> k;

  ll sum = 0;

  rep(a,k) rep(b,k) rep(c,k) {
    ll aa;
    aa = gcd(a+1, b+1);
    aa = gcd(aa, c+1);
    sum += aa;
  }
  
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define lp(i, a, b) for (int i=a; i<(b); i++)
#define lpd(i,a,b) for (int i = (b)-1; i >= a; i--)
	
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
 
bool cmp(pi &a, pi &b){
    return (a.first < b.first);
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    string s;
    cin>>s;
    int one = 0, zero = 0;

    lp(i, 0, sz(s)){
        if (s[i] == '1') one++;
        else zero++;
    }

    cout<<2*min(zero, one)<<endl;
 
    return 0;
}

Measured memory_bytes: 512
import math
n = int(input())
ab=[]
m=10000
for i in range(1,int(math.sqrt(n))+1):
  if n%i==0:
    ab.append([i,int(n/i)])
f=[]
for i in ab:
  a=len(str(i[0]))
  b=len(str(i[1]))
  if a>b:
    f.append(a)
  else:
    f.append(b)
    
for i in f:
  if m>i:
    m=i
print(m)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define nl cout<<'\n' ; 
void speed() { ios_base::sync_with_stdio(false);cin.tie(NULL);}
const ll inf = 1e18L + 1 ;

void max_self(ll &a , ll b)
{
	a= max(a,b);
}

void solve()
{
	int n , w ; cin>>n>>w ; 
	
	vector<pair<int, int >> items ; 
	
	for(int i=0 ; i<n ; i++) 
	{
      int weight , val ; 
      cin>>weight>>val ; 
      items.push_back(make_pair(weight , val));
	}
	
	ll total_val =0 ; 
	for(int i=0 ; i<n ; i++) total_val+=items[i].second ; 
	vector<ll> dp(total_val+1 , inf); 
	
	// here dp means , for a certain value , what can be the minimum weight we can acheive 
	
	dp[0]=0 ;
	
	for(int ind=0 ; ind<n ; ind++)
	{
		for( int val = total_val ; val>=0 ; val--)
		{
		if(val + items[ind].second<=total_val)
		{
			dp[val+items[ind].second] = min(dp[val+items[ind].second] , dp[val] + items[ind].first);
		}	
		}	
	}
	
	ll answer =0 ; 
	for(ll i=0 ; i<=total_val ; i++)
	{
		if(dp[i]<=w)
		{
			answer = max(answer , i);
		}
	}
	
	cout<<answer ; 
	
	
}

int main()
{
	speed(); 
    int T = 1;
   // cin >> T;
    while (T--){
    solve();
}
}




Measured memory_bytes: 3992
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int H, W;
    cin >> H >> W;
    vector<int> sth[600], stw[600];
    for(int i = 0; i < H; i++){
        for(int j  = 0; j < W; j++){
            char s;
            cin >> s;
            if(s == '#') {
                sth[i+j].push_back(i-j+299);
                stw[i-j+299].push_back(i+j);
                //cout << i << ' ' << j << endl;
            }
        }
    }
    long ans = 0;
    for(int i = 0; i < H+W; i++){
        for(auto iter = sth[i].begin(); iter != sth[i].end(); iter++){
            int j = *iter;
            for(auto iter2 = iter; iter2 != sth[i].end(); iter2++){
                int k = *iter2;
                if(j == k) continue;
                //cout << (i+j-299)/2 << ' ' << (i-j+299)/2 << endl;
                if(i+k-j >= 0 && i+k-j < 600) {
                    auto l = lower_bound(sth[i+k-j].begin(), sth[i+k-j].end(), min(j, k));
                    auto r = upper_bound(sth[i+k-j].begin(), sth[i+k-j].end(), max(j, k));
                    ans += r-l;
                }
                if(i+j-k >= 0 && i+j-k < 600) {
                    auto l = lower_bound(sth[i+j-k].begin(), sth[i+j-k].end(), min(j, k));
                    auto r = upper_bound(sth[i+j-k].begin(), sth[i+j-k].end(), max(j, k));
                    ans += r-l;
                }
            }
        }
    }
    for(int i = 0; i <= H+299; i++){
        for(auto iter = stw[i].begin(); iter != stw[i].end(); iter++){
            int j = *iter;
            for(auto iter2 = iter; iter2 != stw[i].end(); iter2++){
                int k = *iter2;
                if(j == k) continue;
                //cout << (i+j-299)/2 << ' ' << (i-j+299)/2 << endl;
                if(i+k-j >= 0 && i+k-j < 600) {
                    auto l = upper_bound(stw[i+k-j].begin(), stw[i+k-j].end(), min(j, k));
                    auto r = lower_bound(stw[i+k-j].begin(), stw[i+k-j].end(), max(j, k));
                    ans += r-l;
                    //cout << *r << endl;
                    //if(r != stw[i+k-j].end() && *r == max(j, k)) ans--;
                }
                if(i+j-k >= 0 && i+j-k < 600) {
                    auto l = upper_bound(stw[i+j-k].begin(), stw[i+j-k].end(), min(j, k));
                    auto r = lower_bound(stw[i+j-k].begin(), stw[i+j-k].end(), max(j, k));
                    ans += r-l;
                    //if(*r == max(j, k)) ans--;
                    //if(r != stw[i+j-k].end() && *r == max(j, k)) ans--;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1280
# frozen_string_literal: true

d = gets.to_i
c = gets.split.map(&:to_i)
s = d.times.map { gets.split.map(&:to_i) }
# t = d.times.map { gets.to_i }
tt = []
sum = 0
l = Hash.new { 0 }
d.times do |i|
  max_t = -1
  max = -100000000000
  (1..26).each do |t|
    ll = l.dup
    sum += s[i][t - 1]
    ll[t] = i + 1
    c.each_index do |j|
      sum -= c[j] * (i + 1 - ll[j + 1])
    end
    if max < sum
      max = sum
      max_t = t
    end
  end
  tt.push max_t
  l[max_t] = i + 1
end
puts tt


Measured memory_bytes: 18248
//minamoto
#include<bits/stdc++.h>
#define R register
#define inline __inline__ __attribute__((always_inline))
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=25,L=(1<<21)+5;
int f[2][L],mp[N][N],Lg[L],n,t,lim;
int main(){
	scanf("%d",&n),lim=(1<<n);
	fp(i,1,n)fp(j,1,n)scanf("%d",&mp[i][j]);
	f[t=0][0]=1;
	fp(i,0,n-1)Lg[1<<i]=i+1;
	fp(i,1,n){
		memset(f[t^1],0,lim<<2);
		fp(s,0,lim-2)if(f[t][s])
			for(R int p=(lim-1)^s,k=p&-p;p;p-=k,k=p&-p)
				if(mp[i][Lg[k]])upd(f[t^1][s|k],f[t][s]);
		t^=1;
	}
	printf("%d\n",f[t][lim-1]);
	return 0;
}

Measured memory_bytes: 20736
#include <iostream>
#include <vector>

using namespace std;
int main(void){

    int N,l,a[100],b[100],cnt=0,tmp1,tmp2,out=0;
    
    cin >> N;

    while(cin>>l){
        a[cnt]=l;
         cnt++;
        if(cnt>N-1){
            break;
        }
    }

    for(int j=0; j<N; j++){
  
        for(int i=0; i<N-1; i++){
            tmp1 = a[i];
            tmp2 = a[i+1];

            if(a[i]<a[i+1]){
                
                a[i]=tmp2;
                a[i+1]=tmp1;

            }
   
        }
    }

        for(int i=0; i<N; i++){
            tmp1 = (i+1) % 2 ;

            if(tmp1 == 0){
                out=out - a[i]; 
            }else{
                out=out + a[i];
            }
    }

        cout << out << endl;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 = 1000000;

typedef pair<int, int> P;

int h, w;
char field[55][55];
int d[55][55];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void bfs(int y, int x){
	queue<P> que;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			d[i][j] = INF;
		}
	}
	que.push(P(x, y));
	d[y][x] = 0;
	while(que.size()){
		P p = que.front(); que.pop();
		for(int i = 0; i < 4; i++){
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if(nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
			if(field[ny][nx] == '#') continue;
			if(d[ny][nx] != INF) continue;
			que.push(P(nx, ny));
			d[ny][nx] = d[p.second][p.first] + 1;
		}
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> h >> w;
	int white = 0;
	rep(i,h)rep(j,w){
		cin >> field[i][j];
		if(field[i][j] == '.') ++white;
	}
	bfs(0, 0);
	if(d[h-1][w-1] == INF) cout << -1 << endl;
	else cout << white - d[h-1][w-1] - 1 << endl;
	return 0;
}


Measured memory_bytes: 3664
#include <iostream>
using namespace std;
int main (void){
  int n;
  cin >> n;
  
  string s = "No";
  for(int i = 1; i <10; i++){
    for(int j = 1; j <10; j++){
      if(n == i * j){
        s = "Yes";
      }
    }
  }
  cout << s;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int cnt[425252];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n;
  ll a[252521], b[252521];
  cin>>n;
  REP(i, n){
    cin>>a[i];
    b[i]=i-a[i];
    if(0<=b[i] && b[i]<=n*2){
      ++cnt[b[i]];
    }
  }
  ll ans=0;
  REP(i, n){
    if(a[i]<n){
      ans+=cnt[a[i]+i];
    }
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 5988
package main

import "fmt"

func main() {
	var A, B, C int
	fmt.Scan(&A, &B, &C)
	weekly := 7*A + B
	weeks := C / weekly
	tmp := C % weekly
	if tmp > 7*A {
		fmt.Println(weeks*7 + 7)
	} else {
		fmt.Println(weeks*7 + (tmp+(A-1))/A)
	}
}


Measured memory_bytes: 1180
N, K = map(int, input().split())
G = [[] for _ in range(N)]
for i, a in enumerate(map(int, input().split())):
    G[i] = a - 1
now = 0
seen = set()
#ループが始まる町とそれまでの移動回数iを求める
for i in range(1, K+1):
    seen.add(now)
    now = G[now]
    if now in seen:
        break
K -= i
if K > 0:
    #ループの移動回数jを求める。
    seen = set()
    for j in range(1,K+1):
        seen.add(now)
        now = G[now]
        if now in seen:
            break
    #ループの長さで割った余りｒを求める。
    r = K % j
    for _ in range(r):
        now = G[now]
print(now + 1)


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

typedef long long int ll;

ll MOD = 1000000007;
ll INF = 100000000;

int main(){
 int N,M;
 cin >> N >> M;
 vector<vector<pair<ll,ll>>> L(N);
 for(int i = 0;i < M;i++){
   int p,y;cin >> p >> y;
   p--;
   L[p].push_back(make_pair(y,i+1));
 }
 for(int i = 0;i < N;i++){
   sort(L[i].begin(),L[i].end());
 }
 vector<pair<ll,string>> Num;
 for(int i = 0;i < N;i++){
   int n = L[i].size();
   string t = to_string(i+1);
   int z = t.size();
   for(int j = 0;j < 6-z;j++){
     t = '0' + t;
   }
   for(int j = 0;j < n;j++){
     string s = to_string(j+1);
     int x = s.size();
     for(int k = 0;k < 6-x;k++){
       s = '0' +  s;
     }
     string ans = t + s;
     Num.push_back(make_pair(L[i][j].second,ans));
   }
 }
 sort(Num.begin(),Num.end());
 for(int i = 0;i < M;i++){
   cout << Num[i].second << endl;
 }
}


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

#include <fstream>
using namespace std;

int n;
bool bad = false;

int check(vector<pair<int, int>> p){
  sort(p.begin(), p.end());
  int sum = 0;
  for (int i = 0; i < n; i++) {
    auto x = p[i];
    int hituyo = x.first;
    int yojo = x.second;
    if (yojo >= 0) {
      if (hituyo <= sum) {
        sum += yojo;
      } else {
        bad = true;
        break;
      }
    }
  }
  return sum;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  cin >> n;
  vector<pair<int, int>> p1, p2;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int tmp = 0;
    int hituyo = 0;
    for (int j = 0; j < s.size(); j++) {
      if (s[j] == '(') {
        tmp++;
      } else {
        tmp--;
      }
      if ((-1) * tmp > hituyo) {
        hituyo = tmp * (-1);
      }
    }
    p1.emplace_back(hituyo, tmp);
    tmp = 0;
    hituyo = 0;
    for (int j = s.size() - 1; j >= 0; j--) {
      if (s[j] == ')') {
        tmp++;
      } else {
        tmp--;
      }
      if ((-1) * tmp > hituyo) {
        hituyo = tmp * (-1);
      }
    }
    p2.emplace_back(hituyo, tmp);
  }
  int sum1 = check(p1);
  int sum2 = check(p2);
  /*
  for (auto x : p) {
    cout << x.first << " " << x.second << endl;
  }
  //*/
  if (bad || sum1 != sum2) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 26760
#include <bits/stdc++.h>
using namespace std;
 
#define mod             1000000007
#define rep(i,n)        for (int i = 0; i < n; ++i)
#define REP(i,k,n)      for (int i = k; i < n; ++i)
#define REPR(i,k,n)     for (int i = k; i >= n; --i)
#define w(x)            int x; cin>>x; while(x--)
#define mk(arr,n,type)  type *arr=new type[n];
#define pii             pair<int,int>
#define mp              make_pair
#define inrange(i, a, b) ((i >= min(a, b)) && (i <= max(a, b)))
#define fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll              long long
#define w(x)            int x; cin>>x; while(x--)
#define mem(a, b)       memset(a, (b), sizeof(a))
#define setbits(x)      __builtin_popcountll(x)
  
void solve() {
   int n, m=0, ans=INT_MAX;
   cin>>n;
   int a[n];
   rep(i, n) {
       cin>>a[i];
       m=max(m, a[i]);
   }
   for(int i=1;i<=m;i++){
       int cur = 0;
       rep(j, n) cur+= (a[j] - i)*(a[j] - i);
       ans=min(ans, cur);
   }
   cout<<ans<<endl;
}
 
 
int main() {
    fast
    solve();
    return 0;
}


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

int N,H[21] = {};
int main(){
    cin >> N;
    for(int i=1;i<=N;i++){
        cin >> H[i];
    }
    int ans = 1;
    for(int i=2;i<=N;i++){
        bool judge =true;
        for(int j=1;j<i;j++) if(H[j]>H[i]) judge = false;
        ans += judge;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s,t;
  cin >> s >> t;
  int n,i,a;
  a = 0;
  n = size(s);
  for (i=0;i<n;i++){
    if (s.at(i)!=t.at(i)) {
      cout << "No" << endl;
      a+=1;
      break;
    }
  } 
  if (a==0) {
    cout << "Yes" << endl;
  }      
}  

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

int main() {

    int N, K;
    cin >> N >> K;

    int sum = 0;
    int h;
    rep(i, N) {
        cin >> h;
        if (h >= K) sum++;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)

int buy(int x, int y, int b, int p){
    int price = b * x + p * y;
    if(b >= 5 && p >= 2){
        return 0.8 * price;
    }
    return price;
}

int main(){
    int N;
    std::cin >> N;
    REP(i, N){
        int x, y, b, p;
        std::cin >> x >> y >> b >> p;

        std::cout << std::min(buy(x, y, b, p), buy(x, y, std::max(b, 5), std::max(p, 2))) << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1164
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>  
#include <iostream>  
#include <cstdlib>  
#include <cstring>  
#include <string>
#include <cstdio>  
#include <climits>
#include <cmath> 
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <sstream>
#define INF 0x3f3f3f3f
#define LL long long
#define fora(i,a,n) for(int i=a;i<=n;i++)
#define fors(i,n,a) for(int i=n;i>=a;i--)
#define sci(x) scanf("%d",&x);
#define scl(x) scanf("%lld",&x);
#define MAXN 100024
const double eps = 1e-8;
using namespace std;

int main() {
#ifdef DID
	freopen("in.txt", "r", stdin);
	//freopen("out.txt","w",stdout);
#endif
	char a, b;
	cin >> a >> b;
	if (a == 'H') cout << b << endl;
	else {
		if (b == 'H') cout << 'D' << endl;
		else cout << 'H' << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
set<pair<long long,long long>>s1,s2;
long long H,W,N;
long long ans[10];
int main(void)
{
	cin>>H>>W>>N;
    long long a,b;
	for(long long i=1;i<=N;i++)
	{
		cin>>a>>b;
        a--;
        b--;
		s1.insert(make_pair(a,b));

        s2.insert(make_pair(a-1,b-1));
        s2.insert(make_pair(a-1,b));
        s2.insert(make_pair(a-1,b+1));
		s2.insert(make_pair(a,b-1));
        s2.insert(make_pair(a,b));
        s2.insert(make_pair(a,b+1));
        s2.insert(make_pair(a+1,b-1));
		s2.insert(make_pair(a+1,b));
		s2.insert(make_pair(a+1,b+1));
	}
	long long cnt=0;
	for(auto ele:s2)
	{
		cnt=0;
		if(ele.first>=1&&ele.first<H-1&&ele.second>=1&&ele.second<W-1)
        {
            for(long long i=-1;i<=1;i++)
            {
                for(long long j=-1;j<=1;j++)
                {
                    if(s1.count(make_pair(ele.first+i,ele.second+j))==1)
                    {
                        cnt++;
                    }
                }
            }
            ans[cnt]++;
        }
	}
	long long sum=0;
	for(long long i=1;i<=9;i++)
    {
        sum+=ans[i];
    }
    ans[0]=(H-2)*(W-2)-sum;
	for(long long i=0;i<10;i++)
    {
        cout<<ans[i]<<endl;
    }
	return 0;
 }


Measured memory_bytes: 62720
import java.util.*;

public class Main {
	// from: http://amzn.asia/3MkgFHb p188
	static int MAX_V = 100;
	static int INF = 10000000;
	static ArrayList<ArrayList<Edge>> G = new ArrayList<ArrayList<Edge>>(MAX_V); // {{
//		for(int i=0; i<MAX_V; i++) {
//			G.add(new ArrayList<Edge>());
//		}
//	}};
	// TODO: https://stackoverflow.com/questions/8559092/create-an-array-of-arraylists
	// もっとマシな設計にできないか
	static boolean[] used = new boolean[MAX_V];
	
	static void add_edge(int from, int to, int cap) {
		G.get(from).add(new Edge(to, cap, G.get(to).size()));
		G.get(to).add(new Edge(from, 0, G.get(from).size()-1));
	}
	
	static int dfs(int v, int t, int f) {
		if(v==t) return f;
		used[v] = true;
		for(int i=0; i<G.get(v).size(); i++) {
			Edge e = G.get(v).get(i);
			if(!used[e.to] && e.cap > 0) {
				int d = dfs(e.to, t, Math.min(f, e.cap));
				if(d>0) {
					e.cap -= d;
					G.get(e.to).get(e.rev).cap += d;
					return d;
				}
			}
		}
		return 0;
	}
	
	static int max_flow(int s, int t) {
		int flow = 0;
		for(;;) {
			Arrays.fill(used, false);
			int f = dfs(s, t, INF);
			if(f==0) return flow;
			flow += f;
		}
	}
	
	static class Edge {
		int to, cap, rev;
		Edge(int to, int cap, int rev) {
			this.to = to; this.cap = cap; this.rev = rev;
		}
	}
	
	// VERIFIED at http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A&lang=jp
	static public void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int V = sc.nextInt();
		int E = sc.nextInt();
		int s = 0;
		int t = V-1;
		for(int i=0; i<MAX_V; i++) {
			G.add(new ArrayList<Edge>());
		}
		for(int i=0; i<E; i++) {
			int u = sc.nextInt(); int v = sc.nextInt(); int c = sc.nextInt();
			add_edge(u, v, c);
		}
		System.out.println(max_flow(s, t));
	}
}



Measured memory_bytes: 34992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A , B;
  cin >> A >> B;
  if(A >= 13){
    cout << B << endl;
  }
  if(A <=12 && A >= 6){
    cout << B/2 << endl;
  }
  if(A <= 5){
    cout << "0" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
const int Mod=998244353;
int n,K;
#define Maxn 305
char S[Maxn];
int a[Maxn],cnt=0;
int dp[Maxn][Maxn][Maxn];
int main(){
	scanf("%s",S+1);scanf("%d",&K);
	n=strlen(S+1);
	S[n+1]='0';
	n++;
	int lst=0;
	for(int i=1;i<=n;++i)
	    if(S[i]=='0'){
	    	a[++cnt]=i-lst-1;
	    	lst=i;
		}
	reverse(a+1,a+cnt+1);
	int sum=0;
	dp[0][0][0]=1;
	for(int i=0;i<cnt;++i){
		for(int j=0;j<=sum;++j)
		    for(int k=0;k<=j;++k){
		    	dp[i+1][j][k]=dp[i][j][k];
		    	if(k){
		    		dp[i+1][j][k]+=dp[i+1][j][k-1];
		    		if(dp[i+1][j][k]>=Mod)dp[i+1][j][k]-=Mod;
				}
			}
		for(int j=0;j<=sum;++j)
		    for(int k=0;k<=j;++k)
		        for(int l=1;l<=a[i+1];++l){
		        	dp[i+1][j+l][k]+=dp[i][j][k];
		        	if(dp[i+1][j+l][k]>=Mod)dp[i+1][j+l][k]-=Mod;
				}
		sum+=a[i+1];
	}
	int Ans=0;
	for(int i=0;i<=min(K,sum);++i){
		Ans+=dp[cnt][i][i];
		if(Ans>=Mod)Ans-=Mod;
	}
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 30304
#include<iostream>

using namespace std;

int main() {
    int S;
    cin >> S ;
    int h = S/3600 ;
    S = S%3600;
    int m = S/60;
    S = S%60;
    int s = S;
    cout << h << ":" << m  << ":" << s  << endl;
  
     return 0;
}  


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    
    int indexA = 0;
    int indexB = 0;
    int indexC = 0;
    
    auto next = a[indexA++];
    for(;;)
    {
        switch (next)
        {
            case 'a' :
                if (a[indexA] == '\0')
                {
                    printf("A\n");
                    return 0;
                }
                next = a[indexA++];
                break;
                
            case 'b' :
                if (b[indexB] == '\0')
                {
                    printf("B\n");
                    return 0;
                }
                next = b[indexB++];
                break;
            
            case 'c' :
                if (c[indexC] == '\0')
                {
                    printf("C\n");
                    return 0;
                }
                next = c[indexC++];
                break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<vector>

template<typename T>
struct cumulative_sum_2d {
    int h, w;
    T ZERO;
    std::vector<std::vector<T>> data;
    template<typename I> cumulative_sum_2d(I begin, I end, T ZERO = T())
        : h(end - begin), w(begin->end() - begin->begin()), ZERO(ZERO), data(h + 1, std::vector<T>(w + 1, ZERO)) {
        for (auto itr_y = begin, itr_data = data.begin() + 1; itr_y != end; itr_y++, itr_data++) {
            std::copy(itr_y->begin(), itr_y->end(), itr_data->begin() + 1);
        }
        for (int i = 1; i <= h; i++) {
            for (int j = 0; j < w; j++) { data[i][j + 1] += data[i][j]; }
        }
        for (int i = 0; i < h; i++) {
            for (int j = 1; j <= w; j++) { data[i + 1][j] += data[i][j]; }
        }
    }
    T get_sum(int y0, int x0, int y1, int x1) const {
        if (y0 >= y1 || y0 > h || y1 < 0) { return ZERO; }
        if (y0 < 0) { y0 = 0; }
        if (y1 > h) { y1 = h; }
        if (x0 >= x1 || x0 > w || x1 < 0) { return ZERO; }
        if (x0 < 0) { x0 = 0; }
        if (x1 > h) { x1 = w; }
        return data[y1][x1] - data[y1][x0] - data[y0][x1] + data[y0][x0];
    }
};

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

int main() {
    int N;
    cin >> N;
    vector<vector<int>> m(1001, vector<int>(1001));
    for (int i = 0; i < N; i++) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        m[y1][x1]++, m[y2][x1]--, m[y1][x2]--, m[y2][x2]++;
    }
    cumulative_sum_2d<int> cs(m.begin(), m.end());
    int ans = 0;
    for (int i = 1; i <= 1000; i++) {
        for (int j = 1; j <= 1000; j++) { ans = max(ans, cs.get_sum(0, 0, i, j)); }
    }
    cout << ans << endl;
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 3 == 0 or i % 5 == 0) continue;
    ans += i;
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;
 
int main(){
    int a=0,b=0;
    string o;
    cin>>o;
    int l=(int)o.size();
    
    rep(i, o.size()){
        if (o[i]=='A') {
            a = i;
            break;
        }
    }
    reverse(ALL(o));
    rep(j, o.size()){
        if (o[j]=='Z') {
            b = l - j;
            break;
        }
    }
    cout<<b-a<<endl;
        return 0;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

///////////////////////////////////////////////////////////////////////////////////////

ll N, sum;
ll A[MAX_10p5];

int main() {
	cin >> N;
	repi(i, 1, N + 1) cin >> A[i];
	A[0] = A[N + 1] = 0;
	repi(i, 1, N + 2) {
		sum += abs(A[i] - A[i - 1]);
	}
	repi(i, 1, N + 1) {
		ll ans = sum - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1]);
		wrln(ans);
	}
	return 0;
}


Measured memory_bytes: 2048
n,k=map(int,input().split())
l=list(map(int,input().split()))

d={}

for i in range(n):
  if l[i] not in d:
    d[l[i]]=(l[i]+1)/2

#print(d)

dp=[]
dp.append(d[l[0]])
for i in range(1,n):
  dp.append(dp[i-1]+d[l[i]])

#print("this is dp",dp)

mx=dp[k-1]
for i in range(n-k):
  we=dp[i+k]-dp[i]
  #print(we,dp)
  if we>=mx:
    mx=we
print(mx)


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

int32_t main()
{
    string s, t;
    cin>>s>>t;
    int ans = 0;
    for(int i=0;i<3;i++){
        if(s[i] == t[i]) ans++;
    }
    cout<<ans<<endl;
	return 0;
}

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

const int MOD = 1000000007;
const int INF = 1000000000;

//long long
using ll = long long;

const long long lINF= ll(1e18) + 5;

//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

// a = max(a, b), a = min(a, b)
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; }

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

/**
 *    author:  tourist
 *    created: 14.07.2019 15:46:31       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> cnt;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ++cnt[a[i]];
  }
  if (cnt[0] == n) {
    yes;
    return 0;
  }
  if (n % 3 != 0) {
    no;
    return 0;
  }
  vector<int> all;
  for (auto& p : cnt) {
    for (int i = 0; i < p.second / (n / 3); i++) {
      all.push_back(p.first);
    }
  }
  if (all.size() == 3 && (all[0] ^ all[1] ^ all[2]) == 0) {
    yes;
  } else {
    no;
  }
  return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;
 
struct Stack{
  ll table[1000];
  ll top;
  void init(){
    top=0;
  }
  bool empty(){
    return top==0;
  }
  void push(ll x){
    table[top]=x;
    top++;
  }
  ll pop(){
    if(empty())return 0;
    top--;
    return table[top];
  }
};
 
ll calc(ll x,string op,ll y){
  if(op=="+")return x+y;
  if(op=="-")return x-y;
  if(op=="*")return x*y;
}
 
 
int main(){
  string str;
  ll numA,numB;
  Stack stack;
  stack.init();
 
  while(cin>>str){
    if(str=="+"||str=="-"||str=="*"){
      numA=stack.pop();
      numB=stack.pop();
      stack.push(calc(numB,str,numA));
    }else{
      numA=0;
      for(int i=0;i<(int)str.size();i++){
    numA*=10;
    numA+=str[i]-'0';
      }
      stack.push(numA);
    }
  }
  cout<<stack.pop()<<endl;
  return 0;
}



Measured memory_bytes: 3152
#include <iostream>
#include <cstdlib>
#include<algorithm>
using namespace std;

int main()
{   
    int N;
    string S;
    std::cin >> N;
    std::cin >> S;

    long long a = 0;
    long long b = 0;
    long long c = 0;
    for(int i=0; i<N;i++){
        if(S[i]=='R') a++;
        if(S[i]=='G') b++;
        if(S[i]=='B') c++;
    }
    long long Tot = a*b*c;
    int k;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){           
            k = 2*j-i;
            if(k>=N)continue;
            if(S[i]+S[j]+S[k]=='R'+'G'+'B')Tot--;
        }
    }
 
    std::cout << Tot<< std::endl;
}


Measured memory_bytes: 3628
function main(input) {
    var S = input.trim();
    var move = 1000000;
    var squares = Array(S.length).fill(0);
    var rightIndex = 0;
    var leftIndex = 0;
    for (var i = 0; S.length > i; i++) {
        var j = i;
        var count = 0;

        if (S[j] === "R") {
            if (j < rightIndex) {
                j = rightIndex;
                count = j - i;
            }
        } else {
            if (j > leftIndex) {
                j = leftIndex;
                count = i - j;
            }
        }

        while (S[j] + S[j+1] !== "RL") {
            if (S[j] === "R") {
                j++;
            } else {
                j--;
            }

            count++;
        }

        if (j >= i) rightIndex = j;
        if (i >= j) leftIndex = j;

        var point = (move - count) % 2 === 0 ? j : j + 1;
        squares[point] += 1;
    }

    console.log(squares.join(" "));
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15436
// 白昼夢
#include <iostream>
#include <string>
using namespace std;

string s,t[4]={"dream","dreamer","erase","eraser"};
int len[4]={5,7,5,6};

int main(){
    cin>>s;
    int end=s.size();
    bool ok=true;
    while(end&&ok){
        ok=false;
        for(int i=0;i<4&&!ok;i++){
            for(int j=0;j<len[i];j++){
                if(s[end-len[i]+j]!=t[i][j]) break;
                if(j==len[i]-1){
                    end-=len[i];
                    ok=true;
                }
            }
        }
    }
    if(ok) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 512