akhauriyash/Code-Regression huggingface dataset:
s = list(input())
n = len(s)
k = int(input())
alphabet = [chr(i) for i in range(97, 97+26)]
al_d = {}
for i in range(26):
    al_d[alphabet[i]] = i
for i in range(n):
    tobe_a = 26 - al_d[s[i]]
    if tobe_a <= k:
        tobe_a %= 26
        k -= tobe_a
        s[i] = 'a'
remain = k % 26
s[-1] = alphabet[al_d[s[-1]]+remain]
print(''.join(s))
# あー！最後にするんじゃなくてaでまとめられる場所があるならそうした方がいい？
# ただそれがあるならそれより前にaにしてるはず

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

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

    if(s=="SAT") cout<<1<<endl;
    else if(s=="FRI") cout<<2<<endl;
    else if(s=="THU") cout<<3<<endl;
    else if(s=="WED") cout<<4<<endl;
    else if(s=="TUE") cout<<5<<endl;
    else if(s=="MON") cout<<6<<endl;
    else cout<<7<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;

template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}

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

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

  int ans = 0;
  repi(i, 1, n + 1)
  {
    int count = 0;
    for (int j = 1; j * j < i; j++)
    {
      if (i % j == 0)
        count += 2;
    }

    if (i % 2 == 1 && count == 8)
    {
      ans++;
    }
  }

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


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n,a,b,c,d[100];
    int i,maxi;
    double max,cal[100],tmp;

    scanf("%d%d%d%d",&n,&a,&b,&c);
    for(i=0;i<n;i++){
        scanf("%d",&d[i]);
        cal[i]=(double)d[i]/(double)b;
    }


    tmp=(double)c/(double)a;
    int j=1;
    while(++j){
        for(maxi=-1,max=tmp,i=0;i<n;i++){
            if(max<cal[i]){
                max=cal[i];
                maxi=i;
            }
        }
        if(maxi==-1)break;
        tmp=(tmp*(a+(j-2)*b)+cal[maxi]*b)/(a+(j-1)*b);
        cal[maxi]=0;
    }
    printf("%.0f\n",tmp-0.5);
    return 0;
}

Measured memory_bytes: 632
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  map<int, int> mp1, mp2;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if (i & 1) {
      mp1[x]++;
    } else {
      mp2[x]++;
    }
  }
  vector<pair<int, int>> v1, v2;
  for (map<int, int>::iterator it = mp1.begin(); it != mp1.end(); it++) {
    v1.push_back(make_pair(it->second, it->first));
  }
  for (map<int, int>::iterator it = mp2.begin(); it != mp2.end(); it++) {
    v2.push_back(make_pair(it->second, it->first));
  }
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  reverse(v1.begin(), v1.end());
  reverse(v2.begin(), v2.end());
  int ans = n / 2 - v1[0].first + n / 2 - v2[0].first;
  if ((int) v1.size() == 1) {
    v1.push_back(make_pair(0, -1));
  }
  if ((int) v2.size() == 1) {
    v2.push_back(make_pair(0, -1));
  }
  if (v1[0].second == v2[0].second) {
    ans = min(n / 2 - v1[1].first + n / 2 - v2[0].first, n / 2 - v1[0].first + n / 2 - v2[1].first);
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 6136
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll n; cin>>n;
    vector<ll>a(n);
    ll sum=0;
    map<ll,ll>mp;
    rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
        sum+=a[i];
    }
    ll q; cin>>q;
    vector<ll>b(q),c(q);
    rep(i,q){
        cin>>b[i]>>c[i];
    }
    ll cnt;
    rep(i,q){
        cnt=mp[b[i]];
        sum-=b[i]*cnt;
        mp[b[i]]=0;
        sum+=cnt*c[i];
        mp[c[i]]+=cnt;
        cout<<sum<<endl;
    }

}








Measured memory_bytes: 11348
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <string>
#include <stack>
#include <cstring>
#include <set>
#include <map>
#include <climits>
#include <cassert>

#define LEN 100005
using namespace std;

typedef struct pp{
	char name[100];
	int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue() {
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int main() {
	int elaps = 0, c;
	int i, q;
	P u;
	cin >> n >> q;

	for (int i = 1; i < n+1; i++) {
		cin >> Q[i].name;
		cin >> Q[i].t;
	}

	head = 1; tail = n + 1;

	while (tail != head) {
		u = dequeue();
		c = min(q, u.t);
		u.t -= c;
		elaps += c;
		if (u.t > 0) {
			enqueue(u);
		}
		else {
			cout << u.name <<" "<< elaps;
			cout << endl;
		}
	}
}

Measured memory_bytes: 13212
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	map<string,string>q;
	q["bg"]=q["gb"]="rr";
	q["gr"]=q["rg"]="bb";
	q["rb"]=q["br"]="gg";
	string s;
	while(cin>>s,s!="0"){
		char qqq=s[0];
		bool h=true;
		rep(i,s.size())if(s[i]!=qqq)h=false;
		if(h){cout<<0<<endl;continue;}
		vector<string>in;
		map<string,bool>tmp;
		in.pb(s);
		int co=0;
		while(1){
			vector<string>out;
			bool h=false;
			rep(i,in.size()){
				string s=in[i];
				tmp[s]=true;
				//h=true;
				//char qq=in[i][0];
				//rep(j,s.size())if(qq!=in[i][j])h=false;
				//if(h)break;
				rep(j,s.size()-1)if(s[j]!=s[j+1]){
					string www=s.substr(j,2);
					string w=q[www];
					string ww=s;
					ww[j]=w[0];ww[j+1]=w[1];
					h=true;
					char qq=ww[0];
					rep(k,ww.size())if(qq!=ww[k])h=false;
					if(h)break;
					if(!tmp[ww]){out.pb(ww);tmp[ww]=true;}
				}
				if(h)break;
			}
			//cout<<endl;
			//rep(i,out.size())cout<<out[i]<<endl;
			//cout<<tmp.size()<<endl;
			//cout<<out.size()<<endl;
			if(h)break;
			co++;
			in=out;
			//cout<<" "<<in.size()<<endl;
			if(co==100)break;
		}
		if(co==100)cout<<"NA"<<endl;
		else cout<<co+1<<endl;
	}
}

Measured memory_bytes: 2648
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define TRACE(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << endl;}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "[" << *it << " = " << a << "]";
	err(++it, args...);
}

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define LOG(x) if(DEBUG) cerr << x << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

vector<ll> v;

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll n;
	cin >> n;

	ll t = 2;
	while(t*t <= n && n > 1)
	{
		ll ct=0;
		while(n%t==0) 
		{
			n/=t;
			ct++;
		}
		if(ct)
			v.pb(ct);
		t++;
	}
	if(n > 1) 
		v.pb(1);

	ll ans = 0;
	for (ll x : v)
	{
		ll k = 1;
		while(k*(k+1) <= 2*x) k++;
		ans += (k-1);
	}

	cout << ans << endl;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

Measured memory_bytes: 3588
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair < ll, ll >&a, const pair < ll, ll >&b){
    return ((a.ss < b.ss) || (a.ss == b.ss && a.ff < b.ff));
}

signed main(){ 
    IOS
    //io_set();
    ll n, m, c;
    cin >> n >> m >> c;
    ll a[n][m], b[m];
    rep(i, m){
        cin >> b[i];
    }
    ll k = 0;
    rep(i, n){
        ll s = c;
        rep(j, m){
            cin >> a[i][j];
            s += (a[i][j] * b[j]);
        }
        if(s > 0){
            k++;
        }
    }
    cout << k << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int N; cin >> N;
	vector<string> S;
	rep (i, 3){
		string s; cin >> s;
		S.push_back(s);
	} // end rep

	int res = 0;
	rep (i, N){
		set<char> same; same.clear();
		rep (j, 3){
			char c = S[j][i];
//			cerr << "c: " << c << endl;
			same.insert(c);
		} // end rep
		res += (int)same.size() - 1;
	} // end rep

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int r1 = sc.nextInt();
		int c1 = sc.nextInt();
		int r2 = sc.nextInt();
		int c2 = sc.nextInt();
		sc.close();

		int mod = 1000000007;
		long[] p = new long[2000003];
		long[] pi = new long[2000003];
		p[0] = 1;
		pi[0] = 1;
		for (int i = 1; i < p.length; i++) {
			p[i] = p[i - 1] * i % mod;
			pi[i] = modinv(p[i], mod);
		}

		long v1 = nCr(r2 + c2 + 2, r2 + 1, mod, p, pi);
		long v2 = nCr(r1 + c2 + 1, r1, mod, p, pi);
		long v3 = nCr(r2 + c1 + 1, c1, mod, p, pi);
		long v4 = nCr(r1 + c1, r1, mod, p, pi);
		long ans = v1 - v2 - v3 + v4;
		while (ans < 0) {
			ans += mod;
		}
		ans %= mod;
		System.out.println(ans);
	}

	static long nCr(int n, int r, int m, long[] p, long[] pi) {
		return p[n] * pi[r] % m * pi[n - r] % m;
	}

	static long modinv(long a, int m) {
		long b = m;
		long u = 1;
		long v = 0;
		long tmp = 0;

		while (b > 0) {
			long t = a / b;
			a -= t * b;
			tmp = a;
			a = b;
			b = tmp;

			u -= t * v;
			tmp = u;
			u = v;
			v = tmp;
		}

		u %= m;
		if (u < 0) u += m;
		return u;
	}
}


Measured memory_bytes: 56020
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;


int main(){
        ll n,m; cin>>n>>m;
    Graph G(n);
    rep(i,m){
        ll a,b; cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<ll>ans(n,-1);
    queue<ll>q;
    q.push(0);
    vector<bool>bb(n,false);
    while(!q.empty()){
        ll v=q.front();
        bb[v]=true;
        q.pop();
        for(auto nv:G[v]){
            if(bb[nv]==true||ans[nv]!=-1)continue;
            q.push(nv);
            ans[nv]=v+1;
        }
    }
    cout<<"Yes"<<endl;
    for(int i=1;i<n;i++){
        cout<<ans[i]<<endl;
    }
}








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

int main(){
	int b,r,g,c,s,t;
	while(scanf("%d %d %d %d %d %d",&b,&r,&g,&c,&s,&t),b+r+g+c+s+t){
		int medal = 100;
		medal += (15 - 2) * (b * 5 + r * 3); //bonus
		medal += 15 * (b + r); //nomal big & regular
		medal += g * 7; //grape
		medal += (2) * c; // cherry
		medal -= (t - s - b * 5 - r * 3) * 3; //star
		printf("%d\n",medal);
	}
}

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

#define int long long int
#define double long double
#define pb push_back
#define fi first
#define se second
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pq priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define mem(a,k) memset(a,k,sizeof(a))
#define ub upper_bound
#define lb lower_bound
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define inf LLONG_MAX


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

	int n,x,ans=inf,y=1;
	cin>>x>>n;
	set<int> s;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		s.insert(x);
	}
	for(int i=0;i<=101;i++)
	{
		if(s.count(i)==0)
		{
			if(abs(x-i)<ans)
			{
				ans=abs(x-i);
				y=i;
			}
		}
	}
	cout<<y;
	return 0;
}


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

using namespace std;

#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()

const int MX = (int)1e5 + 10;
const int mod = (int)1e9 + 7;

int main(){

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

    double a, b, x;
    cin >> a >> b >> x;

    const double PI = acos(-1);
    double l = 0, r = 90;
    int it = 50;
    while(it--){
        double md = (l + r) / 2;

        double angle = PI * md / 180.0;
        double ratio = tan(angle);
        double heightRem = a * ratio;

        if(heightRem >= b){
            double angle = 90 - md;
            double ratio = tan(angle * PI / 180.0);
            double org_base = b * ratio;
            double otherArea = 0.5 * org_base * b;
            if(otherArea * a >= x) l = md;
            else r = md;
            continue;
        }

        double areaExtra = 0.5 * a * heightRem;
        double ExtraVol = areaExtra * a;
        double rem = a * a * b - ExtraVol;

        if(rem >= x) l = md;
        else r = md;
    }
    
    cout << fixed << setprecision(6) << (l + r) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
/******************************************
* AUTHOR : GURUTEJA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second

void debug(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 

}

  int main() {
    debug();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,sum1=0,sum2=0;
    cin>>n;
    int a[n];
     bool flag=true;
    for (int i = 0; i<n; ++i)
    {
    	cin>>a[i];
    }
    

    sort(a,a+n);

    for(int i=n-1; i>=0; i--){
    	if(flag){
    		sum1+=a[i];
    		flag=false;
    	}else{
    		sum2+=a[i];
    		flag=true;
    	}
    }

    cout<<sum1-sum2<<endl;
    return 0;
  }

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG



int main() {
    using vi = vector<int>;
    
    int n,m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
#include <complex>
using namespace std;
int main()
{
    int n,i,ans=0;
    cin>>n;
    vector <int> s(n,0);
    for(i=0;i<n;i++) cin>>s[i];
    sort(s.begin(),s.end());
    int cnt=s[0];
    for(i=1;i<n;i++)
    {
        if(cnt==s[i]) s[i]=0;
        else cnt=s[i];
    }
    for(i=0;i<n;i++) if(s[i]!=0) ans++;
    cout<<ans;
    system ("pause"); 
    return 0;
}

Measured memory_bytes: 504
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
ans = "War"
for z in range(max(X, Y)+1):
    if X < z <= Y and len([i for i in x if i < z]) == len(x) and len([i for i in y if i >= z]) == len(y):
        ans = "No War"
        break
print(ans)



Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int r,g,b,n,i,j,ans=0;
  
  cin >> r >> g >> b >> n;
  
  for (i=0;i*r<=n;i++) for (j=0;i*r+j*g<=n;j++){
    if ((n-i*r-j*g)%b==0) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

using ld = long double;

int main() {
    ll N, K;
    cin >> N >> K;
    V<ld> P(N);
    for (auto &e : P) cin >> e;
    ld sum = 0;
    V<ld> ex(N);
    for (ll i = 0; i < N; i++) ex[i] = (P[i] + 1) / 2;
    V<ld> sum_v(N + 1);
    for (ll i = 0; i < N; i++) sum_v[i + 1] = sum_v[i] + ex[i];
    ld ans = 0;
    for (ll i = 0; i + K <= N; i++) {
        ld tmp = sum_v[i + K] - sum_v[i];
        chmax(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9652
//#include<bist_stdc++.h>
#include <iostream>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;

int main() {
    int data[4][3][10];
    rep(i, 4) {
        rep(j, 3) {
            rep(k, 10) { data[i][j][k] = 0; }
        }
    }
    int n, a, b, c, v;
    cin >> n;
    rep(i, n) {
        cin >> a >> b >> c >> v;
        data[a - 1][b - 1][c - 1] += v;
    }
    rep(i, 4) {
        rep(j, 3) {
            rep(k, 10) cout << " " << data[i][j][k];
            cout << endl;
        }
        if(i != 3) {
            cout << "####################" << endl;
        }
    }
}



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

int main() {

    int N;

    cin >> N;

    int AC=0, WA=0, TLE=0, RE=0;

    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;
        if (S == "AC") {
            AC++;
        }
        else if (S == "WA") {
            WA++;
        }
        else if (S == "TLE") {
            TLE++;
        }
        else {
            RE++;
        }
    }
    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
}

Measured memory_bytes: 3600
N, H = map(int, input().split())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

a = max(A)
B.sort(reverse=True)

ans = 0
for b in B:
    if b < a:
        break
    H -= b
    ans += 1
    if H <= 0:
        print(ans)
        exit()

import math
ans += math.ceil(H / a)

print(int(ans))


Measured memory_bytes: 11276
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())



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

ll X,Y,Z,K;
ll pmax = 30000000000;
vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }




int main() {



  ll a,b,t;

  cin >> a >>b>>t;

  ll ans=0;
  ll cnt = 1;

  rep(i,t){
    if((i+1)%(a*cnt)==0){
      cnt++;
      ans += b;
    }
  }

  cout << ans << endl;



}

















//


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define FORN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define FORR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n;
	cin >> n;

	co(n*(n-1)/2-n/2);

	repn(i, n-1){
		FORN(j, i+1, n){
			if(n%2 && i+j == n) continue;
			else if(!(n%2) && i+j == n+1) continue;
			cosp(i); co(j);
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n;
  char m[1000][1001];
  while(cin>>n&&n){
    int a=0;
    for(int i=0;i<n;++i) cin>>m[i];
    for(int i=0;i<n-a;++i){
      for(int j=0;j<n-a;++j){
	if(m[i][j]=='.'){
	  bool f=true;
	  for(int k=1;f;++k){
	    for(int l=k;l>=0;--l){
	      if(m[i+l][j+k]!='.'){
		a=max(a,k);j+=k;f=false;break;
	      }
	      if(m[i+k][j+l]!='.'){
		a=max(a,k);j+=l;f=false;break;
	      }
	    }
	  }
	}
      }
    }
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 2140
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

long int combination(long int n, long int r);

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(data, 10, sizeof(int), compare_int)

long int combination(long int n, long int r)
{
	if(r>n-r) r = n-r;
	if(r == 0) return 1;
	else if(r == 1) return n;
	return (combination(n-1, r) + combination(n-1, r-1));
	//大きくなるとき
	/*
	long int tmp1, tmp2, tmp3;
	tmp1 = combination(n-1, r);
	if(tmp1>=MOD) tmp1 = tmp1%MOD;
	tmp2 = combination(n-1, r-1);
	if(tmp2>=MOD) tmp2 = tmp2%MOD;
	tmp3 = tmp1+tmp2;
	if(tmp3>=MOD) tmp3 = tmp3%MOD;
	return (tmp3);
	*/
}


int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	int a[n], b[n], c[m], d[m];
	for(int i=0; i<n; i++){
		scanf("%d%d", &a[i], &b[i]);
	}
	for(int i=0; i<m; i++){
		scanf("%d%d", &c[i], &d[i]);
	}

	int min, point, manhattan;
	for(int i=0; i<n; i++){
		min = 500000000;
		for(int j=0; j<m; j++){
			manhattan = abs(a[i]-c[j]) + abs(b[i]-d[j]);
			if(min > manhattan){
				min = manhattan;
				point = j;
			}
		}
		printf("%d\n", point+1);
	}

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int sum = 0;

        for(int i=1; i<n+1; i++){
            int c1 = i % 10;
            int p = c1;
            if(i-c1 != 0){
                int c2 = (i-c1) % 100;
                p = p + c2/10;
                if(i-(c2+c1) != 0){
                    int c3 = (i-(c2+c1)) % 1000;
                    p = p + c3/100;
                    if(i-(c1+c2+c3) != 0){
                        int c4 = (i-(c2+c1+c3)) % 10000;
                        p = p + c4/1000;
                        if(i-(c1+c2+c3+c4) != 0){
                            int c5 = (i-(c2+c1+c3+c4));
                            p = p + c5/10000;
                        }
                    }
                }
            }
            if(p >= a && p <= b ){
                sum = sum + i;
            }
        }

        System.out.println(sum);


    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
constexpr int N_MAX = 200000;

vector<int> graph[N_MAX];
vector<ll> counter(N_MAX, 0);

void dfs(int node, int par, ll x) {
    for(int child: graph[node]) {
        if(child == par) continue;
        dfs(child, node, x+counter[node]);
    }
    counter[node] += x;
}

int main() {
    std::ios::sync_with_stdio(false); cin.tie(0);
    int n, q, a, b, p;
    ll x;
    cin >> n >> q;
    for(int i=0;i<n-1;++i){
        cin >> a >> b;
        --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    for(int i=0;i<q;++i) {
        cin >> p >> x;
        --p;
        counter[p] += x;
    }
    dfs(0, -1, 0);

    for(int i=0;i<n-1;++i) {
        cout << counter[i] << " ";
    }
    cout << counter[n-1] << endl;
}


Measured memory_bytes: 30592
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e2+5;

long long all;
long long n;
map < long long , int > cnt;

void gen(long long mine , int a , int b , int c){
    if(mine > n){
        return;
    }
    if(!cnt[mine] && a && b && c){
        all++;
        //cout << mine << endl;
        cnt[mine]++;
    }
    gen(mine * 10 + 7 , a + 1 , b , c);
    gen(mine * 10 + 5 , a , b + 1 , c);
    gen(mine * 10 + 3 , a , b , c + 1);
}

int main(){
    cin >> n;
    gen(0 , 0 , 0 , 0);
    cout << all << endl;
}





Measured memory_bytes: 2048
#pragma GCC target("avx")
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define PA pair<LL,LL>
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define EB emplace_back
#define TS to_string
#define TU to_ullong
#define BPL __builtin_popcountll
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORR(i,a,n) for(i=n-1;i>=a;i--)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FORR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
#define NUM 200010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL dig(LL n){LL ret=0;while(n)n/=10,ret++;return ret;}
LL LBn(VL &v,LL a){LL mx=v.size(),mn=-1,md;while(mx-mn>1){md=(mx+mn)/2;if(v[md]<a)mn=md;else mx=md;}return mx;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a%m<0)return a%m+abs(m);else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}
template<typename T>bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  FAST;
  LL i,ans=0,N,A,B;
  cin>>N>>A>>B;

  cout<<min(A,B)<<" "<<max(0LL,A+B-N)<<endl;
}


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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const ll INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int h, n;
    cin >> h >> n;
    vector<int> a(n), b(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
    }

    vector<int> dp(h + 1, INF);
    dp[0] = 0;

    rep(i, n) {
        rep(j, h) {
            dp[min(j + a[i], h)] = min(dp[min(j + a[i], h)], dp[j] + b[i]);
        }
    }
    cout << dp[h] << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, i;
    cin >> n;
    vll a(n);
    for(i = 0; i < n; i++)
        cin >> a[i];
    ll as = 0;
    for(i = 0; i < n - 1; i++)
    {
        if(i & 1)
            as -= a[i];
        else
            as += a[i];
    }
    ll v = (a[n - 1] + as) / 2;
    cout << 2 * v << ' ';
    for(i = 0; i < n - 1; i++)
        cout << 2 * (a[i] - v) << ' ', v = a[i] - v;
    cout << endl;
    return 0;
}

Measured memory_bytes: 2176
h, w = map(int, input().split())
s = [input() for _ in range(h)]
sy = [0] * w
ret = 0
for y in range(h):
    seqx = 0
    seqy = 0
    for x in range(w):
        if s[y][x] == '.':
            if sy[x] == 0:
                yy = y
                while yy < h and s[yy][x] != '#':
                    yy += 1
                sy[x] = yy - y
            seqx += 1
            seqy = max(seqy, sy[x])
            ret = max(ret, seqx + seqy - 1)
        else:
            seqx = 0
            seqy = 0
            sy[x] = 0
print(ret)


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

long long gcd(long long a,long long b){
    if(a < b)swap(a,b);
    if(b == 0)return a;
    else return gcd(b, a % b);
}

int main(){
    long long a,b,g,buf;
    set<long long> cd;
    cin >> a >> b;
    g = gcd(a,b);

    buf = g;
    for(long long i = 2;i * i <= g;i++){
        if(buf % i == 0){
            cd.insert(i);
            while(buf % i == 0)buf /= i;
        }
    }
    if(buf != 1)cd.insert(buf);
    cd.insert(1);
    
    cout << cd.size() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
void solve()
{
	int n;
	cin>>n;
	vector<pair<int, int>> vect(n);
	float ans = 0;
	REP(i,n)
	{
		cin>>vect[i].first>>vect[i].second;
	}
	REP(i,n)
	{
		for(int j=i+1; j<n;j++)
		{
			ll x1 = vect[i].first;
			ll y1 = vect[i].second;
			ll x2 = vect[j].first;
			ll y2 = vect[j].second;
			ans+= sqrt((x2-x1)*(x2-x1) + (y1-y2)*(y1-y2));
//			ans+= hypot((vect[i].first-vect[j].first)*1.0, (vect[i].second-vect[j].second) *1.0);
		}
	}
	ans = 2*ans*1.0/n;
	cout<<fixed<<setprecision(10)<<ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
const int maxn=105;
int a[maxn],b[maxn];
using namespace std;
int main(){
	int T,n=0,x=0;
	bool fal=true;
	cin>>T;
	while(T--){
		cin>>a[n];
		cin>>b[n];
		n++;
	} 
	for(int i=0;i<n;i++){
		if(a[i]==b[i])  x++;
		else x=0;
		if(x==3) {
		fal=false;
		break;
		} 
	}
	if(fal==false) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 3152
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 998244353; //1000000007;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void A();

int main()
{
	A();
	fflush(stdout);
	return 0;
}

static void A()
{
	int N;
	get(N);

	const char* ans = "Yes\n";
	std::vector<LLONG> ai(N), bi(N);
	for (int i = 0; i < N; i++) {
		get(ai[i]);
	}
	for (int i = 0; i < N; i++) {
		get(bi[i]);
	}
	LLONG sum = 0, plus = 0, minus = 0;
	for (int i = 0; i < N; i++) {
		LLONG diff = bi[i] - ai[i];
		sum += diff;
		if (diff < 0) {
			minus -= diff;
		}
		else {
			plus += (diff + 1) / 2;
		}
	}
	if (std::max(plus, minus) > sum) {
		ans = "No\n";
	}

	printf(ans);
}


Measured memory_bytes: 3884
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scanf("%s\n%s\n", &s, &t)

	max := 0
	for i := 0; i < len(s)-len(t)+1; i++ {
		tmp := 0
		for j := 0; j < len(t); j++ {
			if s[i+j] == t[j] {
				tmp++
			}
		}
		if max < tmp {
			max = tmp
		}
	}

	fmt.Println(len(t) - max)

}


Measured memory_bytes: 1852
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"
string s;

int solve(int a){
  bool b=false;
  for(int i=a+1;;i++){
    if(s[i]=='B'){
      break;
    }
    else if(s[i]=='W'){
      continue;
    }
    else{
      b=true;
      break;
    }
  }
  for(int i=a-1;;i--){
    if(s[i]=='B'){
      break;
    }
    else if(s[i]=='W'){
      continue;
    }
    else{
      b=true;
      break;
    }
  }
  if(b==false)return -1;
  int ans=0;
  for(int i=a+1;;i++){
    if(s[i]=='B'){
      ans++;
    }
    else if(s[i]=='W'){
      break;
    }
    else{
      ans=0;
      break;
    }
  }
  int ans2=0;
  for(int i=a-1;;i--){
    if(s[i]=='B'){
      ans2++;
    }
    else if(s[i]=='W'){
      break;
    }
    else{
      ans2=0;
      break;
    }
  }
  return max(ans2,ans);
  
}


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  cin>>s;
  s="A"+s+"A";
  int cnt=0;
  int ans=0;
  lp(i,n+1){
    if(i==0)continue;
    if(s[i]=='.')
      ans=max(ans,solve(i));
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

vector<string> split(const string &str, char sep){
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while( getline(ss, buffer, sep ) ) v.pb(buffer);
  if(str[str.size()-1] == sep) v.pb("");
  return v;
}

bool solve(int g, vector<int> &v){
  set<int> s;
  s.insert(0);
  for(auto d : v){
    set<int> nxt;
    for(auto &pre : s){
      nxt.insert(pre+d);
      nxt.insert(pre-d);
    }
    swap(nxt, s);
  }
  return s.find(g) != s.end();
}

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

  int x,y;
  cin>>x>>y;

  auto vec = split(s, 'T');

  vector<int> v[2];
  rep(i,1,vec.size()){
    v[i%2].pb(vec[i].size());
  }

  if(solve(x-vec[0].size(), v[0]) && solve(y, v[1])) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;

typedef long long ll;

int main(){

    int n;
    cin >> n;

    cout << (n + 1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll a,b,x;cin>>a>>b>>x;
    ll res=b/x-a/x;
    if(a%x==0)res++;
    cout<<res<<endl;
}

Measured memory_bytes: 3676
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;
using LLONG = long long;

int N;
vector<map<string, int>> memo;

const bool IsOK(const string last4)
{
    if (last4.find("AGC") != -1)
    {
        return false;
    }
    for (int i = 0; i < 3; ++i)
    {
        string str = last4;
        char tmp = str[i];
        str[i] = str[i + 1];
        str[i + 1] = tmp;
        if (str.find("AGC") != -1)
        {
            return false;
        }
    }
    return true;
}

const int DFS(int cur, string last3)
{
    if (memo[cur].find(last3) != memo[cur].end())
    {
        return memo[cur][last3];
    }
    if (cur == N)
    {
        return 1;
    }
    int ret = 0;
    for (const char ch : {'A', 'C', 'G', 'T'})
    {
        if (IsOK(last3 + ch))
        {
            ret = (ret + DFS(cur + 1, last3.substr(1, 2) + ch)) % 1000000007;
        }
    }
    memo[cur][last3] = ret;
    return ret;
}

int main()
{
    cin >> N;
    memo = vector<map<string, int>>(N + 1);
    cout << DFS(0, "TTT") << endl;;
}


Measured memory_bytes: 896
void main() {
  problem();
}

void problem() {
  auto a = scan!long;

  string solve() {
    return a >= 30 ? "Yes" : "No";
  }

  solve().writeln;
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

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


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

ans=sum(b)

for i, aa in enumerate(a):
  if i==n-1:
    break
  if a[i]+1==a[i+1]:
    ans+=c[a[i]-1]

print(ans)



Measured memory_bytes: 61836
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ji=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R')
        ji++;
    }
    int he=0;
    for(int i=0;i<ji;i++){
        if(s[i]=='R')
            he++;
    }
    cout<<ji-he<<endl;
}

Measured memory_bytes: 3684
def main():
    n = int(input())
    S = input()

    ans = 0
    for i in range(1,n-1):
        l = S[:i]
        r = S[i:]
        ans = max(ans, len(set(l) &set(r)))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <stdio.h>
int main()
{
	long long int n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	long long int count=0;
	count=n/(a+b)*a;
	if(n%(a+b)>=a) count+=a;
	else count=count+n%(a+b);
	printf("%lld",count);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int h,w,i,j;
  while(1){
  scanf("%d %d", &h, &w);
    if( h ==0 && w == 0)break;
    for(i = 0; i < h; i++){
      for( j = 0; j < w; j++){
	if( i == 0){
	  printf("#");
	}
	else if( j == 0){
	  printf("#");
	}
	else if( i == h - 1){
	  printf("#");
	}
	else if( j == w - 1){
	  printf("#");
	}
	else{
	  printf(".");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

    

  
    
    



Measured memory_bytes: 2088
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
tHalf = 1900
tFull = 100

ans_f = 0.0
for i in range(1,10000):
    ans_f += (tFull * max([N-M,0]) + tHalf * M) * i * ((1.0 - 0.5 ** M) ** (i-1)) * (0.5 ** M)

print(int(ans_f + 0.000001))


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
#define pil pair <int, ll>
#define X first
#define Y second

using namespace std;

const int MAXN = 100010;
int sub[MAXN];
ll arr[MAXN];
vector <pair <int, ll> > ve[MAXN];
int n;
vector <int> cent;

void dfs(int x, int p) {
  int m = 0;
  for (pil tr : ve[x]) {
    int y = tr.X;

    if (y == p) continue;
    dfs(y, x);
    sub[x] += sub[y];
    m = max(m, sub[y]);
  }

  if (max(m, n - sub[x] - 1) <= n / 2) cent.push_back(x);
  sub[x]++;

  return;
}

ll out = 0;
void rek(int x, int p) {
  for (pil tr : ve[x]) {
    int y = tr.X;

    if (y == p) continue;
    rek(y, x);
    sub[x] += sub[y];
    out += tr.Y * sub[y] * 2;
  }
  sub[x]++;

  return;
}

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

  cin >> n;
  REP(i, n - 1) {
    int a, b; ll c;
    cin >> a >> b >> c;
    ve[a - 1].push_back({b - 1, c});
    ve[b - 1].push_back({a - 1, c});
  }
  dfs(0, 0);
  
  memset(sub, 0, sizeof sub);
  rek(cent[0], cent[0]);

  if (cent.size() == 1) {
    ll m = 1e9;
    for (pil tr : ve[cent[0]]) {
      m = min(m, tr.Y);
    }
    out -= m;
  } else {
    for (pil tr : ve[cent[0]]) {
      if (tr.X == cent[1]) out -= tr.Y;
    }
  }
  
  cout << out << "\n";

  return 0;
}

Measured memory_bytes: 13568
num = gets.chomp.to_i
N = num.to_s.split("").map { |e| e.to_i }

flag = 0
for i in 1..N.length-1 do
  if N[i] != 0
    flag = 1
  elsif flag == 1
    break
  end
end

if flag == 1 #キリがいい数字じゃない
  count = 0
  for i in 0..N.length-1 do
    count += N[i]
  end
elsif N.length-1 == 2
  count = num
elsif N[0] == 1
  count = N[0]*10
else
  count = N[0]
end

puts count


Measured memory_bytes: 1788