akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
typedef pair<P,int>P2;
struct RSQ{
  int n=(1<<17),data[(1<<18)];
  RSQ(){
    memset(data,0,sizeof(data));
  }
  // 0 index
  void add(int i,int v){
    i++;
    while(i<=n){
      data[i]+=v;
      i+=i&-i;
    }
  }
  int sum(int i){
    int res=0;
    while(i>0){
      res+=data[i];
      i-=i&-i;
    }
    return res;
  }
  //[a,b) 
  int sum(int x,int y){
    return sum(y)-sum(x);
  }
};

struct Sweap{
    int n;
    vector<int>ye,ys,xs,xe;
    vector<P2>vx,vy;
    Sweap(vector<int>X1,vector<int>X2,vector<int>Y1,vector<int>Y2,int sz,int flag_zaatsu){
        n=sz;xs=X1;xe=X2;ys=Y1;ye=Y2;
        if(flag_zaatsu!=0)zaatsu();
        for(int i=0;i<n;i++){
            if(ys[i]>ye[i])swap(ys[i],ye[i]);
            if(xs[i]>xe[i])swap(xs[i],xe[i]);
            if(xs[i]==xe[i]){
                vx.push_back(P2(P(xs[i], 2), i));
                vy.push_back(P2(P(ys[i], 1), i));
                vy.push_back(P2(P(ye[i], 3), i));
            }
            else{
                vx.push_back(P2(P(xs[i], 1), i));
                vx.push_back(P2(P(xe[i], 3), i));
                vy.push_back(P2(P(ys[i], 2), i));
            }
        }
        sort(vx.begin(),vx.end());
        sort(vy.begin(),vy.end());
    }
    void zaatsu(){
        map<int,int>Mx,My;
        vector<int>tvx,tvy;
        for(int i=0;i<n;i++){
            tvx.push_back(xs[i]);
            tvx.push_back(xe[i]);
            tvy.push_back(ys[i]);
            tvy.push_back(ye[i]);
        }
        sort(tvx.begin(),tvx.end());
        sort(tvy.begin(),tvy.end());
        tvx.erase(unique(tvx.begin(),tvx.end()),tvx.end());
        tvy.erase(unique(tvy.begin(),tvy.end()),tvy.end());
        for(int i=0;i<tvx.size();i++)Mx[tvx[i]]=i;
        for(int i=0;i<tvy.size();i++)My[tvy[i]]=i;
        for(int i=0;i<n;i++){
            xs[i]=Mx[xs[i]];
            xe[i]=Mx[xe[i]];
            ys[i]=My[ys[i]];
            ye[i]=My[ye[i]];
        }
    }
    int build(){
        RSQ rsq;
        int sum=0;
        for(int i=0;i<vx.size();i++){
            int id=vx[i].second;
            int seed=vx[i].first.second;
            if(seed==1){
                rsq.add(ys[id],1);
            }
            else if(seed==3){
                rsq.add(ye[id],-1);
            }
            else{
                sum+=rsq.sum(ys[id],ye[id]+1);
            }
        }
        return sum;
    }
};
 
 
int main(){
    int n;
    scanf(" %d", &n);
    vector<int>X1(n),X2(n),Y1(n),Y2(n);
    for(int i = 0; i < n; i++)scanf("%d%d%d%d",&X1[i],&Y1[i],&X2[i],&Y2[i]);
    Sweap s(X1,X2,Y1,Y2,n,1);
    cout<<s.build()<<endl;
}


Measured memory_bytes: 13924
import java.io.*;
class Main
{
public static void main(String args[])throws IOException
{
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
while(true)
{
String str=input.readLine();
if(str.equals("END OF INPUT"))break;
String str_ary[]=str.split(" ");
for(int i=0;i<str_ary.length;i++)
{
System.out.print(str_ary[i].length());
}
System.out.println();
}
}
}

Measured memory_bytes: 16924
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	bool ok = false;
	REP(i, 0, b){
		if(a*i%b==c) ok = true;
	}
	if(ok) puts("YES");
	else puts("NO");
	return 0;
}



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


int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;

	vector<int> a(n);
	for (auto& e : a)
		cin >> e;

	cout << 1 + (n - k) / (k - 1) + ((n - k) % (k - 1) == 0 ? 0 : 1) << "\n";
}

Measured memory_bytes: 640
#include <cstdlib>
#include <iostream>
#include <algorithm>

#define rep(i, n) for(int i = 0; i < n; ++i)

using namespace std;

using ll = long long;

ll a, b;
int n;

int main(){
  cin >> a >> b >> n;
  ll ans = llabs(a - b);
  for(int j = 1; j <= n; ++j){
    if(b % j){
      continue;
    }
    ll x = b / j;
    for(int i = 1; i <= n; ++i){
      ans = min(llabs(x * i - a), ans);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF=1001001001;
 
int main() {
  int h,n;
  cin>>h>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  int ans=0;
  rep(i,n)ans+=a[i];
  if(ans>=h) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
 
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define maxn 202333
using namespace std;
int fa[maxn], siz[maxn];
int find(int x) {
	return fa[x] == x ? x : (fa[x] = find(fa[x]));
}
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++i) fa[i] = i, siz[i] = 1;
	for(int i = 1; i <= m; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		int x = find(a), y = find(b);
		if(x != y) {
			fa[x] = y;
			siz[y] += siz[x];
			siz[x] = 0;
		}
	}
	int Ans = 0;
	for(int i = 1; i <= n; ++i) Ans = max(Ans, siz[i]);
	printf("%d", Ans);
	return 0;
}

Measured memory_bytes: 5328
#include <stdio.h>

int main(){
  int n, prev, next;
  scanf("%d %d", &n, &prev);
  int way = 0, ans = 1;
  for(int i=1; i<n; i++){
    scanf("%d", &next);
    if(way == 0){
      if(prev == next)  way = 0;
      else if(prev < next)  way = 1;
      else  way = -1;
    }else if(way==1 && prev>next){
      way = 0;
      ans++;
    }else if(way==-1 && prev<next){
      way = 0;
      ans++;
    }
    prev = next;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>

using namespace std;
//数据范围
int main()
{
    long long a,b,c;
    scanf("%lld%lld%lld",&a,&b,&c);
    if(a%2==0||b%2==0||c%2==0)
    {
        printf("0");
        return 0;
    }
    long long Min = b*c;
    if(Min>a*b)
        Min = a*b;
    if(Min>a*c)
        Min = a*c;
    printf("%lld",Min);
    return 0;
}

Measured memory_bytes: 256
import bisect
X, N = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
s = set([i for i in range(102)])

for x in p:
    s.remove(x)

s = sorted(list(s))

id = bisect.bisect_left(s, X)
a = s[id-1]
b = s[id]
ans = a
if abs(a-X) > abs(b-X):
    print(b)
else:
    print(a)


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

int main(){
	for(int i=1;;i++){
	int x;
	cin>>x;
	if(x==0){
		break;
		}
		else{
			cout<<"Case "<<i<<":"<<" "<<x<<endl;
			
			}
	
	}
}



Measured memory_bytes: 3092
#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 998244353

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

int ch[111111];
int mp[111][111];
int used[111];
bool used_gyou[111];
int n, m;

void init(){
	int cou = 0;
	for(int i = 1;i < 111111;i++){
		ch[i] = cou;
		if(i % m == 0){
			cou++;
		}
	}

	REP(i, n){
		REP(j, m){
			cin >> mp[i][j];
		}
	}
}

bool check_gyou(int now_retsu, int now_gyou) {
	//cout << "check_gyou " << now_retsu << " " << now_gyou << endl;
	used_gyou[now_gyou] = true;
	for(int i = now_retsu; i < m;i++){
		if(used[ch[mp[now_gyou][i]]] == -1){
			used[ch[mp[now_gyou][i]]] = now_gyou;
			swap(mp[now_gyou][now_retsu], mp[now_gyou][i]);
			return true;
		}
	}

	for(int i = now_retsu; i < m;i++){
		if(!used_gyou[used[ch[mp[now_gyou][i]]]]){
			if(check_gyou(now_retsu, used[ch[mp[now_gyou][i]]])){
				used[ch[mp[now_gyou][i]]] = now_gyou;
				swap(mp[now_gyou][now_retsu], mp[now_gyou][i]);
				return true;
			}
		}
	}

	return false;
}

void seica_gyou(){
	REP(retsu, m){
		REP(i, 111){
			used[i] = -1;
		}

		REP(gyou, n){
			bool flag = false;
			for(int i = retsu;i < m;i++){
				//cout << "# " << gyou << " " << retsu << " " << i << " " << mp[gyou][i] << " " << used[ch[mp[gyou][i]]] << endl;
				if(used[ch[mp[gyou][i]]] == -1){
					used[ch[mp[gyou][i]]] = gyou;
					swap(mp[gyou][retsu], mp[gyou][i]);
					flag = true;
					break;
				}
			}

			if(flag){
				//cout << "A " << gyou << " " << retsu << " " << mp[gyou][retsu] << endl;
				continue;
			}

			REP(i, 111){
				used_gyou[i] = false;
			}
			for(int i = retsu;i < m;i++){
				if(check_gyou(retsu, used[ch[mp[gyou][i]]])){
					used[ch[mp[gyou][i]]] = gyou;
					swap(mp[gyou][retsu], mp[gyou][i]);
					flag = true;
					break;
				}
			}

			if(!flag){
				cout << "!!!" << endl;
				exit(1);
			}
			//cout << "B ";REP(i, gyou+1)cout << mp[i][retsu] << " ";cout << endl;
		}
		/*
		REP(i, n){
			REP(j, m){
				cout << mp[i][j] << " ";
			}
			cout << endl;
		}
		cout << endl;
		*/
	}
}

void seica_retsu() {
	REP(retsu, m){
		vector<int> v;
		REP(gyou, n){
			v.PB(mp[gyou][retsu]);
		}

		sort(ALL(v));
		REP(gyou, n){
			mp[gyou][retsu] = v[gyou];
		}
	}
}

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
	cin >> n >> m;
	init();
	seica_gyou();
	REP(i, n){
		REP(j, m){
			cout << mp[i][j] << " ";
		}
		cout << endl;
	}
	seica_retsu();
	REP(i, n){
		REP(j, m){
			cout << mp[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}


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

// abc086_c

int main()
{
    int N;
    int t[100001], x[100001], y[100001];
    
    t[0] = x[0] = y[0] = 0;

    std::cin >> N;
    for (int i = 0; i < N ; i++){ std::cin >> t[i+1] >> x[i+1] >> y[i+1]; }

    bool can = true;

    for (int i = 0; i < N; i++){
        int dt = t[i+1] - t[i];
        int dist = std::abs(x[i+1] - x[i]) + std::abs(y[i+1] - y[i]);

        if (dist > dt) {
            can = false;
            break;
        }
        if (dist % 2 != dt % 2){
            can = false;
            break;
        }
    }

    if(can){
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<string> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  const int N2 = 50, N5 = 50;
  int z = 0;
  vector<vector<int>> dp(N2, vector<int>(N5));
  for (auto s : a) {
    bool dot = false;
    long long x = 0;
    int num = 0;
    for (int i = 0; i < (int) s.length(); i++) {
      if (s[i] == '.') {
        dot = true;
        continue;
      } 
      if (dot) num++;
      x = 10 * x + (s[i] - '0');
    }
    num = 9 - num;
    while (num--) x *= 10;
    // cerr << x << '\n';
    if (x % int(1e9) == 0) z++;

    int cnt2 = 0, cnt5 = 0;
    while (x % 2 == 0) {
      cnt2++;
      x /= 2;
    }
    while (x % 5 == 0) {
      cnt5++;
      x /= 5;
    }
    dp[cnt2][cnt5]++;
  }

  long long ans = 0;
  for (int i = 0; i < N2; i++) {
    for (int j = 0; j < N5; j++) {
      for (int x = 0; x < N2; x++) {
        for (int y = 0; y < N5; y++) {
          if (i + x >= 18 && j + y >= 18) {
            ans += 1LL * dp[i][j] * dp[x][y];
          }
        }
      }
    }
  }
  cerr << ans << ' ' << z << '\n';
  ans = (ans - z) / 2;
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 9492
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int n, k;
	cin >> n >> k;
	if (k >= (1 << n)) {
		cout << -1 << endl;
		return 0;
	}
	if (n == 1) {
		if (k == 0) {
			cout << "0 0 1 1" << endl;
		} else {
			cout << -1 << endl;
		}
	} else {
		vector<int> ans = {0};
		for (int i = 1; i < (1 << n); i++) {
			ans.push_back(i);
		}
		ans.push_back(0);
		for (int i = (1 << n) - 1; i > 0; i--) {
			ans.push_back(i);
		}
		for (auto t : ans) {
			cout << (t ^ k) << ' ';
		}
		cout << endl;
	}
}


Measured memory_bytes: 2932
// Problem : A - Kth Term
// Contest : Panasonic Programming Contest 2020
// URL : https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()
using namespace std;
using namespace __gnu_pbds;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
template<class T> using ordered_set=tree<
T,
null_type,
less_equal<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int nxt()
{int x;cin>>x;return x;}
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
//create(tree,node,a,start,end)
//query(tree,node,start,end,l,r)
//update(tree,node,start,end,index,value)
void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k=nxt();
cout<<a[k-1];
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//t=nxt();
while(t--)
{
    solve();
}
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int h, w; read(h, w);

	vector<vector<char>> mp(h + 1, vector<char>(w + 1, 0));
	vector<vector<ll>> dp(h + 1, vector<ll>(w + 1, 0));

	rep(i, 1, h + 1) rep(j, 1, w + 1) read(mp[i][j]);

	dp[1][1] = 1;
	const ll mod = 1000000007;

	rep(i, 1, h + 1) rep(j, 1, w + 1) if (mp[i][j] != '#' && !(i == 1 && j == 1)) {
		dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
	}
	
	die(dp[h][w]);
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	ll N, sum = 0;  cin >> N;
	vector<int> place(N + 1);  place[0] = 0;
	for(int i = 1 ; i <= N ; i++){
	 cin >> place[i];
	 sum += abs(place[i] - place[i - 1]);
	}

	sum += abs(place[N]);
	for(int i = 1 ; i <= N - 1 ; i++)
	 cout << sum - abs(place[i] - place[i - 1]) - abs(place[i] - place[i + 1]) + abs(place[i - 1] - place[i + 1]) << endl;

	cout << sum - abs(place[N]) -abs(place[N - 1] - place[N]) + abs(place[N - 1]) << endl;

	return 0;
}

Measured memory_bytes: 1664
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;

  ll ans=-1e18;

  ans=max(ans,a*c);
  ans=max(ans,b*d);
  ans=max(ans,a*d);
  ans=max(ans,b*c);

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


Measured memory_bytes: 3628
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let s=read::<String>().chars().collect::<Vec<char>>();
    let mut a=-1_i32;
    let mut z=0_i32;
    for i in 0..s.len(){
        if a<0&&s[i]=='A'{a=i as i32}
        if s[i]=='Z'{z=i as i32}
    }
    println!("{}",z-a+1)
}


Measured memory_bytes: 4352
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int maxN = 205;
ll a[maxN];
const int BT = 62;
ll val[maxN];
int which[maxN];
int n;
int SZ = 0;
bool add(ll x) {
    for (int i = 0; i < SZ; i++) {
        if (x & (1LL << which[i])) {
            x ^= val[i];
        }
    }
    if (x == 0) return false;
    val[SZ] = x;
    int c = -1;
    for (int i = 0; i < 63; i++) {
        if (x & (1LL << i)) {
            c = i;
            break;
        }
    }
    assert(c != -1);
    which[SZ] = c;
    for (int i = 0; i < SZ; i++) {
        if (val[i] & (1LL << c)) {
            val[i] ^= x;
        }
    }
    SZ++;
    return true;
}
void solve() {
    SZ = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i - 1];
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    reverse(a, a + n);
    bool bad = false;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '0') {
            add(a[i]);
        }
        else {
            if (add(a[i])) {
                bad = true;
                cout << 1 << '\n';
                break;
            }
        }
    }
    if (!bad) {
        cout << 0 << '\n';
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    int tst;
    cin >> tst;
    while (tst--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>

int main() {
	int n;
	std::cin >> n;
	double v[50];
	for (int i = 0; i < n; i++) {
		std::cin >> v[i];
	}
	std::sort(v, v + n);
	for (int i = 1; i < n; i++) {
		v[i] = (v[i - 1] + v[i]) / 2;
	}
	std::cout << v[n - 1] << "\n";
	return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#include <array>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
using namespace std;
template <typename T> istream & operator >> (istream & is, vector<T> & vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;

int main() {
	int n; string s; CI n >> s;
	int white = 0,ans=1000000;
	string tmp = s;

	REP(i, n) {
		if (s[i] == '.')white++;
	}
	ans = min(ans, white);
	REP(i, n) {
		if (s[i] == '#')white++;
		if (s[i] == '.')white--;
		ans = min(ans, white);
	}

	CO ans EN;

	return 0;
}


Measured memory_bytes: 772
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
	T f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003, M = N << 2;

int n, k;
int h[N], dp[N];

int main()
{
	//File("");
	n = gi <int> (), k = gi <int> ();
	for (int i = 1; i <= n; i+=1) h[i] = gi <int> ();
	memset(dp, 0x3f, sizeof dp);
	dp[1] = 0;
	for (int i = 1; i < n; i+=1)
		for (int j = 1; j <= k; j+=1)
			if (i + j <= n)
				dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
	printf("%d\n", dp[n]);
	return 0;
}


Measured memory_bytes: 4544
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
typedef __int128_t lll;
using namespace std;

//-------------------------------------------------------------------
#define P 1000000007
#define N_MAX 10000000
typedef long long int ll;
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
  if(n<0||k<0||n<k) return 0;
  return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
  fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
  for(int i = 2; i <= N_MAX; i++){
    fac[i] = (fac[i-1]*i)%P;
    inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
    finv[i] = (finv[i-1]*inv[i])%P;
  }
}
ll pp(ll a, ll b){
  return (a * b)%P;
}
ll mpow(ll a, ll b, ll p = -1){
  ll ret = 1, num = a;
  if(p==-1){
    while(b>0){
      if(b%2) ret *= num;
      num = num * num;
      b /= 2;
    }
  }else{
    while(b>0){
      if(b%2) ret = (ret*num)%p;
      num = (num*num)%p;
      b /= 2;
    }
  }
  return ret;
}
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  init();
  ll n, k;std::cin >> n >> k;
  vll f(n+1, 1);
  for(ll i=1;i<n;i++) f[i] = (comb(n, i)*comb(n-1, i))%P;

  ll ans = 0;
  for(ll i=0;i<=min(n-1, k);i++) ans = (ans + f[i])%P;

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 236288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(i && a[i - 1] > a[i]) {
            ans += a[i - 1] - a[i];
            a[i] = a[i - 1];
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3956
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator

A = [input().split() for _ in range(3)]
c = Counter(Counter(chain(*A)).values())
print("YES" if c[1] == 2 else "NO")

Measured memory_bytes: 3572
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>
#include <set>
#include <iomanip>

using namespace std;

typedef long long ll;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N, W; cin >> N >> W;
  int v[N+1], w[N+1];
  for(int i=1;i<=N;i++){
    cin >> v[i] >> w[i];
  }
  int dp[N+1][W+1];
  for(int i=0;i<=W;i++) dp[0][i] = 0;
  for(int i=0;i<N;i++){
    for(int j=0;j<=W;j++){
      if(w[i+1] > W || (j-w[i+1]) < 0) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = max(dp[i][j-w[i+1]]+v[i+1], dp[i][j]);
    }
  }
  int maxdp = 0;
  for(int j=0;j<=W;j++) maxdp = max(dp[N][j], maxdp);
  cout << maxdp << endl;
}


Measured memory_bytes: 7160
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
//#include <ostream>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N)cin >> A[i];

  ll max = 100001;

  vector<ll> cnt(max,0);
  rep(i,N){
    cnt[A[i]]++;
  }

  ll sum = 0;
  rep(i,max)sum += i*cnt[i];

  auto change = [&](ll a,ll b){
    sum -= a*cnt[a];
    ll t = cnt[a];
    cnt[a] = 0;
    cnt[b] += t;
    sum += b*t;
  };

  ll Q;
  cin >> Q;
  vector<ll> C(Q),D(Q);
  rep(i,Q)cin >> C[i] >> D[i];

  rep(i,Q){
    change(C[i],D[i]);
    cout << sum << endl;
  }


}


Measured memory_bytes: 6412
#include <iostream>
#include<string>
using namespace std;
int main(){
    int N;
    cin>>N;
    int a[N];
    int count=0;
     for(int i=0; i<N; i++){
        cin>>a[i];
    }
    bool f = true;
    while(f){
        for(int j=0; j<N; j++){
            if(a[j]%2!=0){
                f = false;
                break;
            }
              else{
                  a[j]=a[j]/2;
              }
                if(j==N-1){
                    count++;
                }
        }
    }
    cout<<count<<endl;
}





Measured memory_bytes: 256
# require 'bigdecimal'
# require 'bigdecimal/util'

# a, b = gets.split.map(&:to_d)
# puts (a*b).floor

a, b = gets.split.map(&:to_s)
a = a.to_i
# そのまま(a*b).floorすると精度が足りずWAになる
# bをb*100して整数にしてから100で割る
# しかし，b*100するときにも誤差が出てしまう
# bを文字列として扱い，小数点の前後でsplitして計算する

# bを文字列にキャストして，小数点でsplitして，各要素をintegerに戻す
bb = b.split(".").map(&:to_i)
b = bb[0]*100 + bb[1]
puts a*b/100

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

#define int long long 

const int INF = 1e18;

signed main()
{
	int n;
	cin >> n;
	vector<int> dp(3,0);
	
	for(int day = 0; day < n; ++day)
	{
		vector<int> new_dp(3,0);
		
		vector<int> c(3);
		
		for(int i=0;i<3;++i)
		cin >> c[i];
		
		for(int i=0;i<3;++i)
		{
			for(int j=0;j<3;++j)
			{
				if(i!=j)
				{
					new_dp[j] = max(new_dp[j],dp[i] + c[j]);
				}
			}
		}
		
		dp = new_dp;
	}
	
	cout << max({dp[0],dp[1],dp[2]});
	
}



Measured memory_bytes: 256
from scipy.sparse.csgraph import dijkstra
N, M = map(int, input().split())
edge = [list(map(int, input().split())) for _ in range(M)]

graph = [[0] * (N + 1) for _ in range(N + 1)]
for a, b in edge:
  graph[a][b] = 1

answer = 0
INF = 10 ** 9
for a, b in edge:
  # a-bのedgeを取り除いた場合にa-bの距離を測る
  graph[a][b] = INF
  dist = dijkstra(graph, indices = a, directed = False)
  if dist[b] >= INF:
    answer += 1
  # a-bのedgeを戻す
  graph[a][b] = 1

print(answer)


Measured memory_bytes: 17488
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <queue>
using namespace std;

//Char[]→文字の長さ
int lenght(char* str){
  int i=0;
 while(str[i]){
     i++;
 }
 return i;
}

int main(){
  int H, W, M, ans = 1005, count = 0, lenS = 0, lenT = 0, bet = 0 ;
  char S[1001] = {}, T[1001] = {} ;
  cin >> S >> T ;
  lenT = lenght(T) ;
  lenS = lenght(S) ;
  bet = lenS - lenT + 1 ;
  for(int i=0;i<bet;i++){
    count = 0 ;
    for(int j=0;j<lenT;j++){
      if(S[i+j] != T[j] ) count++ ;
    }
    ans = min(ans,count) ;
  }
  cout << ans << endl ;
  return 0 ;
}  

Measured memory_bytes: 3632
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(N: int, K: int):
    dp = [[0 for _ in range (N+1)] for _ in range(N+1)]
    for i in range(N+1):
        dp[i][0] = 1

    for i in range(1,N+1):
        for j in range(0,(N+1)//2):
            dp[i][j] = (dp[i-1][j] + dp[i-1][j-1]) % MOD
            dp[i][i-j] = dp[i][j] 

    for i in range(1,K+1):
        print((dp[N-K+1][i]*dp[K-1][i-1]) % MOD)


    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


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

using namespace std;

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

	string s;
	cin >> s;

	if(s=="ABC")
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;

	return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
  int N,M;
  cin >> N >> M;
  vector<int> X(M);
  for (int i=0; i<M; i++) cin >> X[i];
  sort(X.begin(),X.end());
  vector<int> sa(M-1);
  for (int i=0; i<M-1; i++) {
    sa[i] = X[i+1] - X[i];
  }
  sort(sa.begin(),sa.end());
  int ans = 0;
  for (int i=0; i<=M-N-1; i++) {
    ans += sa[i];
  }
  cout << ans << endl;
}
   

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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/2;
const ll MOD = 1e9+7;


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,M;cin>>N>>M;
  ll S[N],T[M];
  for(ll i=0;i<N;i++)cin>>S[i];
  for(ll j=0;j<M;j++)cin>>T[j];
  ll dp[N+1][M+1]={};
  dp[0][0]=1;
  for(ll i=0;i<=N;i++){
    for(ll j=0;j<=M;j++){
      if(i>0)dp[i][j] = (dp[i][j]+dp[i-1][j])%MOD;
      if(j>0)dp[i][j] = (dp[i][j]+dp[i][j-1])%MOD;
      if(i>0&&j>0){
        dp[i][j] = (dp[i][j]-dp[i-1][j-1]+MOD)%MOD;
        if(S[i-1]==T[j-1])dp[i][j] = (dp[i][j]+dp[i-1][j-1])%MOD;
      }
    }
  }
  cout<<dp[N][M]<<endl;
  return 0;
}


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

using namespace std;

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

int a, b;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> a >> b;
    cout << 1LL * a * b / gcd(a, b) << "\n";
    return 0;
}


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

namespace competitive_programming
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int K = int.Parse(input[0]);
            int N = int.Parse(input[0]);

            int[] position = Console.ReadLine().Split(' ').Select(val => int.Parse(val)).ToArray();

            int[] distance = new int[position.Length];
            distance[0] = position[0] + K - position[position.Length - 1];
            for(int i = 1;i < distance.Length ;i++)
            {
                distance[i] = position[i] - position[i - 1];
                //Console.WriteLine(distance[i]);
            }
            Console.WriteLine(K - distance.Max());
        }
    }
}


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

int main() {
  ll Ans = 0;  // 回答：
  ll X; cin >> X; // 目標
  ll M=100; // 元金

  for(ll i =1;M<X; i++){
    M*=1.01;
    Ans = i;
  }
  cout << Ans << endl;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int h = 0;
		int answer = 0;

		for (int i = 0; i < N; i++) {
			h = sc.nextInt();
			if (K <= h) answer++;
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 46268
#include <bits/stdc++.h>
#define rep(i, f, n) for (ll i = (f); i < (ll)(n); i++)
#define repe(i, f, n) for (ll i = (f); i <= (ll)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
  int N;
  cin >> N;
  ll ans = 0;

  vector<ll> v(N + 1, 0);
  v[0] = 2;
  v[1] = 1;
  rep(i, 2, N + 1) v[i] = v[i - 2] + v[i - 1];

  cout << v[N] << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

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

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

long long plusL[100000];
long long plusR[100000];
long long minusL[100000];
long long minusR[100000];
long long a[100000];

int main()
{
	int n;
	cin >> n;
	int p[20];
	
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	
	int count = 0;
	for (int i = 1; i < n - 1; i++)
	{
		if (p[i - 1] < p[i] && p[i] < p[i + 1])
		{
			count++;
		}
		if (p[i - 1] > p[i] && p[i] > p[i + 1])
		{
			count++;
		}
	}
	cout << count;
}



Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
vi sk{0, 1, 2, 3, 4, 5, 6};
inline void roll(char c) {
	vi t(all(sk));
	switch (c) {
	case('E'):
		sk[1] = t[4];
		sk[4] = t[6];
		sk[6] = t[3];
		sk[3] = t[1];
		break;
	case('W'):
		sk[1] = t[3];
		sk[4] = t[1];
		sk[6] = t[4];
		sk[3] = t[6];
		break;
	case('N'):
		sk[1] = t[2];
		sk[2] = t[6];
		sk[6] = t[5];
		sk[5] = t[1];
		break;
	case('S'):
		sk[1] = t[5];
		sk[2] = t[1];
		sk[6] = t[2];
		sk[5] = t[6];
		break;
	}
}
int main() {
	rep(i, 1, 7) cin >> sk[i];
	string s; cin >> s;
	for(auto i : s) {
		roll(i);
	}
	P(sk[1]);
	return 0;
}

Measured memory_bytes: 3220
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
using namespace std;
using pint = pair<int,int>;
 
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
 
int H, W;
string fi[110];
int dist[110][110]; // BFS 用
 
int main() {
  cin >> H >> W;
  int wnum = 0;
  for(int i=0; i<H; i++){
    cin >> fi[i];
    for(int j=0; j<W; j++){
      if(fi[i][j] == '.') wnum++;
    }
  }
  
  memset(dist, -1, sizeof(dist));
  dist[0][0] = 1;
  queue<pint> que;
  que.push(pint(0, 0));
  while(!que.empty()){
    pint cur = que.front();
    que.pop();
    int x = cur.first;
    int y = cur.second;
    for(int dir=0; dir<4; dir++){
      int nx = x + dx[dir];
      int ny = y + dy[dir];
      if(nx<0 || nx>=H || ny<0 || ny>=W) continue;
      if(fi[nx][ny] == '#') continue;
      if(dist[nx][ny] == -1){
        dist[nx][ny] = dist[x][y] + 1;
        que.push(pint(nx, ny));
      }
    }
  }
  
  if(dist[H-1][W-1] == -1) cout << -1 << endl;
  else cout << wnum - dist[H-1][W-1] << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
double max(double a,double b){return a>b?a:b;}
int main(){
    int n,t;
    double ans=0,x,y;
    scanf("%d%d",&n,&t);
    while(n--){
        scanf("%lf%lf",&x,&y);
        ans=max(ans,y/x);
    }
    printf("%.20lf\n",ans*t);
}


Measured memory_bytes: 2744
s = input()[::-1]
x = ["dream", "dreamer", "erase", "eraser"]
can = True
i = 0
for a in range(4):
    x[a] = x[a][::-1]
while(True):
    if(i == len(s)):
        break
    can2 = False
    for j in range (4):
        if(s[i:i+len(x[j])] == x[j]):
            can2 = True
            i += len(x[j])
    if(can2 == False):
        can = False
        break
print("YES" if can == True else "NO")


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;
int T;
int card[9];
char color;
bool judge;

int is_win();
bool is_all_good_set();
bool is_good_set(int, int, int);
bool is_same_number(int,int, int);
bool is_sequence(int, int, int);

int main(){

  cin >> T;
  for (int j = 0; j < T; ++j){

    for (int i = 0; i < 9; ++i){
      cin >> card[i];      
    }

    for (int i = 0; i < 9; ++i){
      cin >> color;
      if(color == 'B') card[i] += 10;
      else if (color == 'G') card[i] += 20;
    }
    
    cout << is_win() << endl;

/*
    //test
    cout << is_sequence(1,2,3) << endl; 
    cout << is_sequence(3,4,5) << endl;
    cout << is_same_number(27,27,27) << endl;
for (int i = 0; i < 9; ++i)
  {
   cout << card[i]<< " ";
  }
  cout << endl;
  cout << "*********" << endl;    
  is_all_good_set();

*/

  }

return 0;

}

int is_win(){

  sort(card, card + 9);

  do{
/*
  for (int i = 0; i < 9; ++i)
  {
   cout << card[i];
  }
  cout << endl;
*/
    if(is_all_good_set()){
    return 1;
  }
  } while (next_permutation(card, card + 9));

  return 0;
}

bool is_all_good_set(){

  int judge = 0;
  for (int i = 0; i < 3; ++i)
  {
    judge += is_good_set(card[3*i], card[3*i+ 1], card[3*i + 2]);
  }

  if (judge == 3){
    
    return true;
  }

/*
  if(is_good_set(card[0],card[1],card[2]) && is_good_set(card[3],card[4],card[5]) && is_good_set(card[6],card[7],card[8]) ){
    return true;
  }
*/
  else return false;
}

/*
1
1 2 3 3 4 5 7 7 7
R R R R R R G G G
*/

bool is_good_set(int a, int b, int c){

   if(is_same_number(a,b,c) ||  is_sequence(a,b,c) ) return true;
   else return false;

}

bool is_same_number(int a, int b, int c){

  if(a == b && b == c) return true;
  else return false;

} 

bool is_sequence(int a, int b, int c){

  if( a + 2 == b + 1 && b +1 == c ) return true;
  else return false ;

}

Measured memory_bytes: 1180
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> PDL;
typedef pair<LD, LD> PDD;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

template<class T>
void in(T& x) {
	cin >> x;
}

template<class T>
void in(vector<T>& v,LL st=-1,LL en=-1) {
	if (st == -1) {
		st = 0;
		en = v.size() - 1;
	}
	for (LL n = st; n < en; n++) {
		in(v[n]);
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL H, W, h, w;
	in(H);
	in(W);
	in(h);
	in(w);
	cout << (H - h) * (W - w) << "\n";
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
    string s;
    int k, cnt = 0, tmp = 0;
    cin >> s >> k;
    if (s[0] != '1')cout << s[0] << endl;
    else {
        rep(i, s.size()) {
            if (s[i] == '1')cnt++;
            else
            {
                tmp = s[i] - '0';
                break;
            }
        }
        if (cnt >= k)cout << 1 << endl;
        else cout << tmp << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>

using namespace std;

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

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

int main() {
	string S;
	cin >> S;


	int a=stoi(S.substr(0,2));
	int b=stoi(S.substr(2,2));

	string ans;

	if(1<=a && a<=12 && 1<=b && b<=12) ans="AMBIGUOUS";
	else if((1<=a && a<=12) && (1>b || b>12)) ans="MMYY";
	else if((1>a || a>12) && (1<=b && b<=12)) ans="YYMM";
	else ans="NA";

	cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[20];
int i,n,x,y;
 
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for (i=1;i<=n;i++)
	{
		x+=s[i]-48;
	}
	y=s[1]-49+(n-1)*9;
	if(x>y)
	{
		printf("%d",x);
	}
	else
	{
		printf("%d",y);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int x,t;cin>>x>>t;
    cout<<max(0,x-t)<<endl;
}


Measured memory_bytes: 3576
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n;
	while(cin>>n,n) 
	{
		vector<int> a(n),b(n);
		for(int i = 0; i < n; ++i)
		{
			cin>>a[i];
		}
		int ans=0;

		while(1) 
		{
			for(int i = 0; i < n; ++i)
			{
				b[i]=0;
				for(int j = 0; j < n; ++j)
				{
					if(a[i]==a[j]) b[i]++; 
				}
			}

			if(a==b)
			{
				cout<<ans<<endl;
				for(int i = 0; i < n; ++i)
				{
					if(i!=0) cout<<" ";
					cout<<a[i];
				}
				cout<<endl;
				break;
			}
			else
			{
				a=b;
				ans++;
			}
		}
	}
  return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string.h>
#include<string>
#include<functional>
#include<set>
using namespace std;

#define INF 1<<21
#define DIV 1000000007
#define MAX 250000


int main(){
  int n;
  while (cin >> n, n) {
	int w[305];
	int dp[305][305];
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i < n; i++) {
	  cin >> w[i];
	}

	for (int i = 1; i < n; i++) {
	  for (int j = 0; j + i < n; j++) {


		for (int k = j; k < j + i; k++) {
		  dp[j][j + i] = max(dp[j][j + i], dp[j][k] + dp[k + 1][j + i]);
		}


		if (dp[j + 1][j + i - 1] == i - 1 && abs(w[j] - w[j + i])<2)dp[j][j + i] = i + 1;


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

Measured memory_bytes: 3408
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())

ans = 0
visited = [False] * (N + 1)

for i in range(N - 1):
    u, v = map(int, input().split())
    if u > v:
        u, v = v, u
    if not visited[u]:
        ans += u * (N - u + 1)
        visited[u] = True
    if not visited[v]:
        ans += v * (N - v + 1)
        visited[v] = True
    ans -= u * (N - v + 1)

print(ans if N != 1 else 1)

Measured memory_bytes: 10940
#include<cstdio>
#include<algorithm>
#include<cctype>
using namespace std;
#define G getchar()
int read()
{
	int x=0; char ch=G;
	for (;!isdigit(ch);ch=G);
	for (;isdigit(ch);ch=G) x=(x<<3)+(x<<1)+(ch^48);
	return x;
}
#undef G
typedef long long ll;
int Mod;
int fac[6010],inv[6010];

int n;
int dp[6010][9010],B=3000;
inline void add(int &x,ll y){x=(x+y)%Mod;}
int main()
{
	n=read()*3,Mod=read();
	fac[0]=1; for (int i=1;i<=n;i++) fac[i]=1LL*fac[i-1]*i%Mod;
	inv[1]=1; for (int i=2;i<=n;i++) inv[i]=1LL*(-Mod/i)*inv[Mod%i]%Mod;
	
	dp[0][B]=fac[n];
	for (int i=0;i<n;i++){
		for (int j=i+B;j>=0;j--){
			if (!dp[i][j]) continue;
			add(dp[i+1][j+1],1LL*dp[i][j]*inv[i+1]);
			if (i+2<=n&&j-1>=0) add(dp[i+2][j-1],1LL*dp[i][j]*inv[i+2]);
			if (i+3<=n) add(dp[i+3][j],1LL*dp[i][j]*inv[i+3]);
		}
	}
	int ans=0;
	for (int i=B;i<=n+B;i++) ans=(ans+dp[n][i])%Mod;
	printf("%d\n",(ans+Mod)%Mod);
	return 0;
}

Measured memory_bytes: 209664