akhauriyash/Code-Regression huggingface dataset:
// -*- coding: utf-8 -*-
//import java.awt.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    InputStream inputStream;
    if (args.length > 0 && args[0].equals("devTesting")) {
      try {
        inputStream = new FileInputStream(args[1]);
      } catch(FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    } else {
      inputStream = System.in;
    }
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskA solver = new TaskA();
    solver.solve(1, in, out);
    out.close();
  }
  
  static class TaskA {    
    int h, w;
    String[] table;
    
    void solve(int testNumber, InputReader in, PrintWriter out) {
      h = in.nextInt();
      w = in.nextInt();
      table = new String[h];
      for (int i = 0; i < h; ++i)
        table[i] = in.next();
      int cnt = 0;
      for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
          if (table[i].charAt(j) == '#')
            ++cnt;
      BitSet vis = new BitSet();
      dfs(0, 0, vis);
      out.println(cnt == vis.cardinality() ? "Possible" : "Impossible");
    }
    
    void dfs(int x, int y, BitSet vis) {
      vis.set(hash(x, y));
      boolean done = false;
      if (iswithin(x + 1, y) && table[y].charAt(x + 1) == '#') {
        dfs(x + 1, y, vis);
        done = true;
      }
      if (!done && iswithin(x, y + 1) && table[y + 1].charAt(x) == '#')
        dfs(x, y + 1, vis);
    }
    
    boolean iswithin(int x, int y) {
      return x >= 0 && x < w && y >= 0 && y < h;
    }
    
    int hash(int x, int y) {
      return y * w + x;
    }
    
  }
      
  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }
    
    public String nextLine() {
      try {
        return reader.readLine();
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }
    
    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public boolean hasInput() {
      try {
        if (tokenizer != null && tokenizer.hasMoreTokens()) {
          return true;
        }
        reader.mark(1);
        int ch = reader.read();
        if (ch != -1) {
          reader.reset();
          return true;
        }
        return false;
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }
    
  }
}


Measured memory_bytes: 8404
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string s;
  cin >> s;
  string t="ACGT";
  int ans=0;
  rep(i,s.size()){
    int count=0;
    for(int j=i;j<s.size();j++){
      bool is=false;
      for(int k=0;k<4;k++){
        if(s.at(j)==t.at(k)){
          is=true;
        }
      }
      if(is){
        count++;
      }else{
        break;
      }
    }
    ans=max(count,ans);
  }
  cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>
#include<cmath>
#include<queue>

using namespace std;

int main() {

	int N;
	cin >> N;

	vector<int> vCityMonster(N+1, 0);
	for (int i = 0; i < N+1; i++)
	{
		cin >> vCityMonster[i];
	}
	vector<int> vKONum(N, 0);
	for (int i = 0; i < N; i++)
	{
		cin >> vKONum[i];
	}


	long KONum = 0;
	for (int i = 0; i < N; i++)
	{
		// 左を全力で倒す
		int deathL = min(vKONum[i], vCityMonster[i]);
		KONum += deathL;
		vCityMonster[i] -= deathL;
		vKONum[i] -= deathL;

		// 右を全力で倒す
		int deathR = min(vKONum[i], vCityMonster[i + 1]);
		KONum += deathR;
		vCityMonster[i + 1] -= deathR;
		vKONum[i] -= deathR;
	}



	cout << KONum << endl;
	
	return 0;
}

Measured memory_bytes: 1024
// 以下のソースを勉強する.
// zscoder氏.
// https://atcoder.jp/contests/dp/submissions/3936367
#include <bits/stdc++.h>
using namespace std;

char A[1111][1111];
int H, W;
int dp[1111][1111];
const int MOD = (1e9 + 7);
int add(int a, int b){
    a += b;
    while(a >= MOD) a -= MOD;
    return a;
}

bool valid(int x, int y){
    return (x >= 0 && x < H && y >= 0 && y < W && A[x][y] == '.');
}

int main(){
    
    // 1. 入力情報取得.
    scanf("%d %d", &H, &W);
    for(int i = 0; i < H; i++){
        char c[1001];
        scanf("%s", c);
        for(int j = 0; j < W; j++) A[i][j] = c[j];
    }
    
    // 2. dp更新.
    dp[0][0] = 1;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(A[i][j] == '#')  continue;
            if(valid(i, j - 1)) dp[i][j] = add(dp[i][j], dp[i][j - 1]);
            if(valid(i - 1, j)) dp[i][j] = add(dp[i][j], dp[i - 1][j]);
        }
    }
    // for(int i = 0; i < H; i++){
    //     for(int j = 0; j < W; j++){
    //         printf("%d ", dp[i][j]);
    //     }
    //     printf("\n");
    // }
    
    // 3. 出力.
    printf("%d\n", dp[H - 1][W - 1]);
    return 0;
}

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

int main() {int a,b,c,n,m,p,q,r;
            cin>>n>>m;
            a=11;
            b=10;
            c=10;
            r=0;
    for (int i = 0; i < m; i++) {cin>>p>>q;
   if(p==1){if(a<=9&&a!=q){cout<<-1<<endl;
                           r++;
                          break;
                          }
            else{a=q;}}
   else if(p==2){if(b<=9&&b!=q){cout<<-1<<endl;
                                r++;
                               break;
                               }
            else{b=q;}}
 else if(p==3){if(c<=9&&c!=q){cout<<-1<<endl;
                             r++;
                             break;
                             
}
            else{c=q;}}
    } 
            if(n==1&&r==0){cout<<a%11<<endl;}
            else if(n==2&&r==0){if(a==0){cout<<-1<<endl;}
                               else{cout<<(a%10)*10+(b%10)<<endl;}}
            else if(n==3&&r==0){if(a==0){cout<<-1<<endl;}
                               else{cout<<(a%10)*100+(b%10)*10+(c%10)<<endl;}
  }
           }


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c[ohara],d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q,l[ohara],r[ohara];
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
pair<P,ll> p[ohara];
    
//------ Believe yourself as a genius!!!!!! ------

struct SegmentTree{
    int siz;
    vector<ll> node;
    SegmentTree(int n,ll init){
        siz=1;
        while(siz<n)siz<<=1;
        node.assign(2*siz,init);
    }
 
    void update(int k,ll x){
        k+=siz-1;
        node[k]=x;
        while(k>0){
            k=(k-1)/2;
            node[k]=min(node[2*k+1],node[2*k+2]);
        }
    }
 
    ll query(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0)r=siz;
        if(r<=a||b<=l)return LINF;
        if(a<=l&&r<=b)return node[k];
        ll vl=query(a,b,2*k+1,l,(l+r)/2);
        ll vr=query(a,b,2*k+2,(l+r)/2,r);
        return min(vl,vr);
    }
};

ll dp[ohara];
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>m;
    SegmentTree seg(n+10,LINF);
    rep(i,m){
        cin>>l[i]>>r[i]>>c[i];
        l[i]--;r[i]--;
        p[i]=m_p(m_p(l[i],r[i]),c[i]);
    }
    sort(p,p+m);
    rep(i,n+1)dp[i]=LINF;
    dp[0]=0;
    seg.update(0,0);
    rep(i,m){
        //cout<<p[i].fi.fi<<" "<<p[i].fi.se<<"\n";
        //cout<<seg.getvar(p[i].fi.fi,p[i].fi.se)<<"\n";
        dp[p[i].fi.se]=min(seg.query(p[i].fi.fi,p[i].fi.se)+p[i].se,dp[p[i].fi.se]);
        seg.update(p[i].fi.se,dp[p[i].fi.se]);
    }
    //rep(i,n)Cout(dp[i]);
    if(dp[n-1]!=LINF)Cout(dp[n-1]);
    else Cout(-1);
    return 0;
}

Measured memory_bytes: 15360
def main():
    num = int(input())
    A = []
    for i in range(num):
        X = input()
        Y = " " + input()
        lx = len(X)
        ly = len(Y)
        T = [0] * ly
        for j in range(lx):
            xj = X[j]
            C = T[:]
            for k in range(1,ly):
                k1 = k-1
                if xj == Y[k]:
                    T[k] = C[k1] + 1
                elif T[k] < T[k1]:
                    T[k] = T[k1]
        print(T[k])
if __name__ == '__main__':
    main()

Measured memory_bytes: 7800
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
long long longpow(long long n, long long a, long long mod) {
  if (a == 0) return 1;
  if (a == 1) return n % mod;
  if (a % 2 == 1) return (n * longpow(n, a - 1, mod)) % mod;
  ll t = longpow(n, a / 2, mod) % mod;
  return (t * t) % mod;
}
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i, N) cin >> a[i];
  ll avg = 0;
  REP(i, N) avg += a[i];
  ll avg2 = (avg ) / N;
  avg = (avg + N - 1) / N;
  ll cost = 0, cost2 = 0;
  REP(i, N) {
    if (a[i] != avg) cost += longpow(a[i] - avg, 2, MOD);
    if (a[i] != avg2) cost2 += longpow(a[i] - avg2, 2, MOD);
  }
  cout << min(cost, cost2) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <deque>
#include <queue>
#include <stdio.h>


using namespace std;

int main() {
	
	string str;
	cin >> str;
	stack<char> st;

	for (int i = 0; i < str.size(); i++) {
		if (st.empty()) {
			st.push(str[i]);
		} else if (st.top() == 'S' && str[i] == 'T') {
			st.pop();
		} else {
			st.push(str[i]);
		}
	}

	cout << st.size() << endl;

	return 0;
}

Measured memory_bytes: 644
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n, m; cin >> n >> m;
    vector<int> cs(m);
    for(int i=0; i<m; ++i) cin >> cs[i];
    vector<int> dp(n+1);
    dp[0]=0;
    for(int ni=1; ni<=n; ++ni){
        int t=ni;
        for(int ci=0; ci<m; ++ci){
            if(cs[ci]<=ni){
                t=min(t, dp[ni-cs[ci]]+1);
            }
        }
        dp[ni]=t;
    }
    cout << dp[n] << endl;
    return 0;
}



Measured memory_bytes: 3144
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
const int maxn=105;
typedef long long ll;
int n,m,a[maxn],b[maxn],len;
int c[maxn];
string s[maxn];
int tt;
vector<pair<int,int> > adj[maxn*25];
inline bool chk1(string t){
	if (t.size()==0) return true;
	int l=0,r=(int)t.size()-1;
	while(l<=r){
		if (t[l]!=t[r]) return false;
		l++,r--;
	}
	return true;
}
struct node{
	int id;
	ll val;
	bool operator<(const node &n1)const{
		return val>n1.val;
	}
	node(int id=0,ll val=0):id(id),val(val){}
};
priority_queue<node> q;
ll d[maxn*25];
int vis[maxn*25];
int id[maxn][25];
ll ans=1e16;
inline void diji(){
	while(!q.empty()){
		int u=q.top().id;
		q.pop();
		if (vis[u]) continue;
		vis[u]=1;
		for (int i=0;i<adj[u].size();i++){
			int v=adj[u][i].first;
			int w=adj[u][i].second;
			if (d[v]>d[u]+w){
				d[v]=d[u]+w;
				q.push(node(v,d[v]));
			}
		}
	}
}
int main(){
	cin>>n;
	for (int i=1;i<=n;i++){
		string s1;
		int x;
		cin>>s1>>x;
		if (chk1(s1)){
			ans=min(ans,(ll)x);
			continue;
		}
		len++;
		b[len]=s1.size();
		s[len]=" "+s1;
		c[len]=x;
	}
	n=len;
	for (int i=n+1;i<=n*2;i++){
		s[i]=s[i-n];
		c[i]=c[i-n];
		b[i]=b[i-n];
		int l=1,r=b[i];
		while(l<=r){
			swap(s[i][l],s[i][r]);
			l++,r--;
		}
	}
	for (int i=1;i<=n*2;i++){
		for (int j=0;j<=b[i];j++){
			id[i][j]=++tt;
		}
	}
	for (int i=1;i<=n*2;i++){
		for (int j=0;j<=b[i];j++){
			if (j==b[i]) continue;
			int l,r;
			if (i<=n){
				l=n+1,r=n*2;
			}
			else{
				l=1,r=n;
			}
			for (int k=l;k<=r;k++){
				int p1=j,p2=0;
				while(p1+1<=b[i]&&p2+1<=b[k]&&s[i][p1+1]==s[k][p2+1]){
					p1++;
					p2++;
				}
				if (p1==b[i]&&p2==b[k]){
					adj[id[i][j]].push_back(make_pair(id[i][b[i]],c[k]));
					adj[id[i][j]].push_back(make_pair(id[k][b[k]],c[k]));
					continue;
				}
				if (p1==b[i]){
					adj[id[i][j]].push_back(make_pair(id[k][p2],c[k]));
					continue;
				}
				if (p2==b[k]){
					adj[id[i][j]].push_back(make_pair(id[i][p1],c[k]));
					continue;
				}
			}
		}
	}
	memset(d,0x3f,sizeof(d));
	for (int i=1;i<=n*2;i++){
		d[id[i][0]]=c[i];
		q.push(node(id[i][0],d[id[i][0]]));
	}
	diji();
	for (int i=1;i<=n*2;i++){
		for (int j=1;j<=b[i];j++){
			string t="";
			for (int k=j+1;k<=b[i];k++){
				t.push_back(s[i][k]);
			}
			if (chk1(t)){
				ans=min(ans,d[id[i][j]]);
			}
		}
	}
	if (ans>=1e16){
		cout<<"-1"<<endl;
	}
	else cout<<ans<<endl;
}

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

using namespace std;

#define sz(a) ((int)a.size())
#define rep(i, a, b) for (int i = (a); i < (b); i++)

string s;

int main() {
    cin >> s;

    long long ans = 0, cnt = 0;
    for (int i = sz(s) - 1; i >= 0; i--) {
        if (s[i] == 'C') {
            if (i && s[i - 1] == 'B') {
                cnt++;
                i--;
            } else {
                cnt = 0;
            }
        } else if (s[i] == 'B') {
            cnt = 0;
            continue;
        } else {
            ans += cnt;
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
long long n,a,b;
int main(){
	scanf("%lld%lld%lld",&n,&a,&b);
	if(b-a&1){
	  long long ans;
	  ans=a+(b-a-1>>1);
	  a=n-a+1,b=n-b+1;
	  ans=std::min(ans,b+(a-b-1>>1));
	  printf("%lld\n",ans);
	}
	else{
	  printf("%lld\n",b-a>>1);
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main() {
    int a, b, c, k;
    scanf("%d %d %d %d", &a, &b, &c, &k);
    while (b <= a && k != 0) {
        b *= 2;
        k--;
    }
    while (c <= b && k != 0) {
        c *= 2;
        k--;
    }
    if (c > b && b > a) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
}

Measured memory_bytes: 3160
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

const ll MOD = 1000000007;


int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll x;
  std::cin>>x;
  if(x==3||x==5||x==7){
    std::cout<<"YES";
  }else{
    std::cout<<"NO";
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())

S = []
for _ in range(N):
    s = input()
    S.append(s)

print('AC x {}'.format(S.count('AC')))
print('WA x {}'.format(S.count('WA')))
print('TLE x {}'.format(S.count('TLE')))
print('RE x {}'.format(S.count('RE')))

Measured memory_bytes: 16244
#include <cstdio>
#include <cstring>

int main()
{
  char s[1001];
  int w;
  scanf("%s%d", s, &w);
  int len = strlen(s);
  for (int i = 0; i < len; i += w)
  {
    putchar(s[i]);
  }
  putchar('\n');
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <list>
#include <deque>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#define ll long long
#define INF 0x3f3f3f3f
#define SIS std::ios::sync_with_stdio(false)
using namespace std;
ll fast_pow(ll a,ll b,ll mod)
{
    ll c=1;
    while(b>=2)
    {
        if(b%2==0)
            a*=a,b/=2;
        else
            c*=a,a*=a,b--,b/=2;
        a%=mod,c%=mod;
    }
    return (a*c)%mod;
}

int main()
{
    ll n,k;
    while(cin>>n>>k)
    {
        if(n>=k)
        {
            ll x=n/k,a=n-x*k,b=abs(a-k);
            cout<<min(a,b)<<endl;
        }
        else
        {
            ll a=abs(n-k),b=abs(a-k);
            cout<<min(a,b)<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
// AOJ 1132: Circle and Points
// 2017.10.31 bal4u@cc

#include <stdio.h>
#include <math.h>

#define EPS 1e-5
double x[301], y[301];

int main()
{
	int n, i, j, k, f, ans;
	double dx, dy, d, dd, a, ax, ay, x0, y0;

	while (scanf("%d", &n) && n > 0) {
		for (i = 0; i < n; i++) scanf("%lf%lf", x+i, y+i);
		ans = 1;
		for (i = 0; i < n; i++) for (j = i+1; j < n; j++) {
            dx = x[i]-x[j], dy = y[i]-y[j];
            dd = dx*dx + dy*dy; d = sqrt(dd);
            if (d <= 2+EPS) {
	            a = sqrt(1.0 - dd/4);
		        ax= -dy/d*a, ay = dx/d*a;
				x0 = (x[i]+x[j])/2 + ax, y0 = (y[i]+y[j])/2 + ay;
				for (f = 0, k = 0; k < n; k++) {
					if ((x[k]-x0)*(x[k]-x0)+(y[k]-y0)*(y[k]-y0) < 1+EPS) f++;
				}
				if (f > ans) ans = f;
			}
        }
        printf("%d\n", ans);
    }
	return 0;
}

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

char C[2][3];

int main() {
  for(int i = 0; i < 2; ++i) for(int j = 0; j < 3; ++j) {
    scanf(" %c", &C[i][j]);
  }
  printf("%s\n",
    C[0][0] == C[1][2] && C[0][1] == C[1][1] && C[0][2] == C[1][0]
    ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      int N = Integer.parseInt(br.readLine());
      Set<String> set = new HashSet<>();
      for(int i = 0; i < N; i++){
        set.add(br.readLine());
      }
      System.out.println(set.size());
    }catch(Exception e){
    }
  }
}

Measured memory_bytes: 65716
#include <bits/stdc++.h> 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
  string s;
  cin>>s;
  bool ans=false;
  reverse(all(s));
  int i=0,k=s.size();
  while(i<k){
    if(i+4<k&&s[i]=='m'&&s[i+1]=='a'&&s[i+2]=='e'&&s[i+3]=='r'&&s[i+4]=='d'){
      i+=5;if(i==k){ans=true;}}
    else if(i+6<k&&s[i]=='r'&&s[i+1]=='e'&&s[i+2]=='m'&&s[i+3]=='a'&&
            s[i+4]=='e'&&s[i+5]=='r'&&s[i+6]=='d'){
      i+=7;if(i==k){ans=true;}}
    else if(i+4<k&&s[i]=='e'&&s[i+1]=='s'&&s[i+2]=='a'&&s[i+3]=='r'&&s[i+4]=='e'){
      i+=5;if(i==k){ans=true;}}
    else if(i+5<k&&s[i]=='r'&&s[i+1]=='e'&&s[i+2]=='s'&&s[i+3]=='a'&&s[i+4]=='r'
            &&s[i+5]=='e'){i+=6;if(i==k){ans=true;}}
    else{i=k;}}
  if(ans){cout<<"YES"<<endl;}
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 512
import sys
H, W = map(int, input().split())
li = []
li.extend(["."*(W+2)])
for i in range(H):
    li.extend(["."+input()+"."])
li.extend(["."*(W+2)])

for i in range(1,H+1):
    for j in range(1,W+1):
        if li[i][j] == "#":
            if li[i-1][j] == "." and li[i+1][j] == "." and li[i][j-1] == "." and li[i][j+1] == ".":
                print("No")
                sys.exit()
print("Yes") 

Measured memory_bytes: 3064
#!/usr/bin/ruby
while l=gets.chomp do
	if l=='' then next end
	if l[0..0]=='-' then break end
	a=l.to_f*16;
	puts a!=(a=a.to_i)||a>4095?'NA':sprintf('%08b.%04b',a/16,a%16)
end

Measured memory_bytes: 9868
#include <iostream>
#include <vector>
#include <algorithm>

#define llong long long
#define rep(i,l,n) for(int (i)=(l);(i)<(n);(i++))
#define _min(a,b) ((a)<(b)?(a):(b))

using namespace std;

int main(){
	int N;
	cin >> N;
	
	int ans[N+1];
	rep(i,0,N+1) ans[i]=0;
	
	rep(x,1,N){
		rep(y,1,N){
			rep(z,1,N){
				int n = x*x+y*y+z*z+x*y+y*z+z*x;
				if( n<=N ){
					ans[n]++;
				}else{
					break;
				}
			}
		}
	}
	
	rep(i,1,N+1){
		cout << ans[i] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3584
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

#define INF 100000000

int main() {
	int r, d, x;
	cin >> r >> d >> x;
	int ans;
	rep(i, 10) {
		ans = r * x - d;
		cout << ans << endl;
		x = ans;
	}

	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main(){
    int X;
    cin >> X;
    for(double i = X;i > 0;i--){
        for(int j = 1;j <= 1000;j++){
            for(int k = 2;k <= 10;k++){
                if(pow(j, k) == i){cout << i;return 0;}
            }
        }
    }
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
typedef long long LL;

LL n,a[1000005] = {0};
LL tot[1000005] = {0},tcn = 0;
priority_queue <LL> q,p;

int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(LL i = 1;i <= (1LL << n);i ++) cin >> a[i];
	sort(a + 1,a + 1 + (1LL << n));
	LL tmp = 1;
	for(LL i = (1LL << n) - 1;i >= 0;i --){
		if(a[i] == a[i + 1]) tmp ++;
		else{
			tot[++ tcn] = tmp;
			tmp = 1;
		}
	}
	
	q.push(n + 1);
	for(LL i = 1;i <= tcn;i ++){
		if(q.size() < tot[i]){
			cout << "No" << endl;
			return 0;
		}
		for(LL j = 1;j <= tot[i];j ++){
			tmp = q.top(); q.pop();
			for(LL k = 1;k < tmp;k ++) p.push(k);
		}
		while(!p.empty()){
			q.push(p.top());
			p.pop();
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 9592
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();
        if(s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35560
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
	int dp[10001] = {};
	int n,k,m;
	while(cin>>n>>k>>m,n){
		dp[1] = 0;
		for(int i = 2; i <= n; i++){
			if(i == n){
				dp[i] = (dp[i-1] + m) % i;
			}else{
				dp[i] = (dp[i-1] + k) % i;
			}
		}
		cout<<dp[n]+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define RFOR(i, a, b) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

using namespace std;
using i64 = int64_t;
using u64 = uint64_t;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<i64>;
using vd = vector<double>;
using pi = pair<int, int>;
using pl = pair<i64, i64>;
using pd = pair<double, double>;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;
constexpr int N = 8;

template <typename T>
inline void chmin(T &a, T b) {
  a = min(a, b);
}
template <typename T>
inline void chmax(T &a, T b) {
  a = max(a, b);
}
template <typename T>
void print(T &v) {
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) cout << " ";
    cout << *it;
  }
  cout << endl;
}

void print_board(vector<vb> &X, vi &row) {
  REP(y, N) {
    REP(x, N) {
      if (X[y][x] && row[y] != x) return;
    }
  }
  REP(y, N) {
    REP(x, N) cout << ((row[y] == x) ? "Q" : ".");
    cout << endl;
  }
}

void recursive(vector<vb> &X, vi &row, vb &col, vb &dpos, vb &dneg, int y) {
  if (y == N) {
    print_board(X, row);
    return;
  }
  REP(x, N) {
    if (col[x] || dpos[x + y] || dneg[y - x + N - 1]) continue;
    row[y] = x;
    col[x] = dpos[x + y] = dneg[y - x + N - 1] = true;
    recursive(X, row, col, dpos, dneg, y + 1);
    row[y] = -1;
    col[x] = dpos[x + y] = dneg[y - x + N - 1] = false;
  }
}

int main() {
  vi row(N, -1);
  vb col(N, false), dpos(2 * N - 1, false), dneg(2 * N - 1, false);
  vector<vb> X(N, vb(N, false));

  int k, x, y;
  cin >> k;
  REP(i, k) {
    cin >> y >> x;
    X[y][x] = true;
  }
  recursive(X, row, col, dpos, dneg, 0);
}


Measured memory_bytes: 3104
import itertools
a0,b0,c0 = map(int, input().split())
k = int(input())
p = itertools.product(range(3),repeat = k)
ans = 'No'
for i in p:
    a,b,c = a0,b0,c0
    for ii in i:
        if ii == 0:
            a = 2*a
        elif ii == 1:
            b = 2*b
        elif ii == 2:
            c = 2*c
        
        if b > a and c > b:
            ans = 'Yes'
            break
    if ans == 'Yes':
        break
print(ans)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b,c,d,e;
int main(){
  cin >> n;
  ll mi = 1e15;
  for(int i=0 ; i<5 ; i++){
    ll x;
    cin >> x;
    mi = min(mi, x);
  }
  ll k = n/mi;
  if(n%mi != 0)  k++;
  cout << (n+mi-1)/mi + 4 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

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

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

string replace_all(string s, string before, string after) {
	for (int i = 0; i + before.size() <= s.size(); i++) {
		if (s.substr(i, before.size()) == before) {
			s.replace(i, before.size(), after);
		}
	}

	return s;
}

int main(void) {
	int N;
	cin >> N;
	cin.get();
	for (int i = 0; i < N; i++) {
		string s;
		getline(cin, s);
		cout << replace_all(s, "Hoshino", "Hoshina") << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    ll x,a,b,B;
    cin >> x >> a >> b;
    B=(x-a)/b;
    cout << x-a-b*B << endl;
}


Measured memory_bytes: 256
// +build ignore
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func search(p []int, n int) bool {
	for _, v := range p {
		if n == v {
			return true
		}
	}
	return false
}

func solve(sc *scanner, wr *bufio.Writer) int {
	X := sc.i()
	N := sc.i()
	p := make([]int, N)
	for i := 0; i < N; i++ {
		p[i] = sc.i()
	}
	for i := 0; i <= 101; i++ {
		a := X - i
		found := search(p, a)
		if !found {
			fmt.Println(a)
			return 0
		}

		b := X + i
		found = search(p, b)
		if !found {
			fmt.Println(b)
			return 0
		}
	}

	return 0
}

func main() {
	sc := newScanner(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	ret := solve(sc, wr)
	wr.Flush()
	os.Exit(ret)
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
#define endl '\n'
#define modulo 1000000007
#define int int64_t
//#pragma GCC optimize("trapv")
#define float double
#define PI acos(-1);
#define sinDegrees(x) sin((x) * PI / 180.0)
#define tanDegrees(x) tan((x) * PI / 180.0)
#define atanDegrees(x) atan(x)* 180.0 / PI
using namespace std;
int power(int x,int y,int m)
{
int temp;
if(y == 0)
return 1;
temp = (power(x, y/2,m))%m;
if (y%2 == 0)
return ((temp%m)*temp);
else
return ((x*temp%m)*temp%m)%m;
}
int inv(int x)
{
return (power(x,modulo-2,modulo))%modulo;
}
bool comp(int a,int b)
{
return a<b;
}
///Solution created by:Ahmadsm2005
int32_t main()
{
//freopen("output.txt","w", stdout);
//freopen("output.txt","r", stdin);
//iostream::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string s;
cin>>s;
int base=0;
for(int i=0;i<s.size();i++)
base^=(s[i]-'a'+1);
if(base)
cout<<"No";
else
cout<<"Yes";
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
 
int main()
{
  int n;
  cin >> n;
  map<string, int> tl;
  vector<int> ti;
  int t_t = 0;
  REP(i,n)
  {
    string s;
    int t;
    cin >> s >> t;
    t_t += t;
    tl[s] = i;
    ti.push_back(t_t);
  }
  string x;
  cin >> x;
  
  cout << ti[n-1] - ti[tl[x]] << endl;
  return 0;
}

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

int main(){
    int a,b;
    int n,m;
    cin >>n>>m;
    vector<int> path[50];
    for(int i=0;i<m;i++){
    cin >> a>>b;
    //if(find(path[a-1].begin(),path[a-1].end(),b-1)==path[a-1].end())
    path[a-1].push_back(b-1);
    path[b-1].push_back(a-1);
    }
    for(int i=0;i<n;i++){
        cout <<path[i].size()<<endl;
    }

   
       
   
}


Measured memory_bytes: 256
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < n; ++i)

char in[400001];
int tr[400001][26], sz[400001], I, skip[400001];
bool T[400001];
string S[100001];

inline void ad(string &s) {
	int u = 0;
	f(i, 0, s.size()) {
		int k = in[i] - 'a', &t = tr[u][k];
		if (!t)t = ++I;
		u = t;
		++sz[u];
	}
	T[u] = true;
}

int bld(int v = 0) {
	int z = 0;
	pair<int, int> t;
	f(i, 0, 26) {
		int u = tr[v][i];
		if (!u)continue;
		++z;
		t = make_pair(bld(u), i);
		tr[v][i] = t.first;
	}
	if (z == 1 && !T[v] && v) {
		++skip[t.first];
		return t.first;
	}
	return v;
}

int go(int id) {
	int u = 0, an = 0;
	string &s = S[id];
	f(i, 0, s.size()) {
		f(j, 0, 26) {
			if (in[j] == s[i])break;
			an += sz[tr[u][in[j] - 'a']];
		}
		u = tr[u][s[i] - 'a'];
		i += skip[u];
		an += T[u];
	}
	return an;
}

int main() {
	int n;
	scanf("%d", &n);
	f(i, 1, n + 1) {
		scanf("%s", in);
		S[i] = in;
		ad(S[i]);
	}
	bld();
	int q;
	scanf("%d", &q);
	while (q--) {
		int t;
		scanf("%d%s", &t, in);
		printf("%d\n", go(t));
	}
}

Measured memory_bytes: 62976
#include <iostream>
#include <string>

using namespace std;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)

int N;
int ans;

void resolve()
{
    int N, A[101];
    cin >> N;
    RPT1(i, N) cin >> A[i];

    string ans = "APPROVED";

    RPT1(i, N)
    {
        if (A[i] % 2 == 1) continue;
        if (A[i] % 3 != 0 && A[i] % 5 != 0) {
            ans = "DENIED";
            break;
        }
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
long long a[11],i,temp,j,k,n=10;
for(i=0;i<10;i++)
{
scanf("%lld",&a[i]);
}
for(j=0;j<n-1;j++)
	{
	for(k=0;k<n-1;k++)
	{
	if(a[k+1]<a[k])
	{
	temp=a[k+1];
	a[k+1]=a[k];
	a[k]=temp;
	}
	}
}
for(i=9;i>6;i--)
{
printf("%lld\n",a[i]);
}
return 0;
}

Measured memory_bytes: 1028
#include<cstdio>

int main(){
	int a[4];
	int hit, blow, t;
	while(scanf("%d %d %d %d", &a[0],&a[1],&a[2],&a[3]) + 1){
		hit = blow = 0;
		for(int i = 0; i < 4; i++){
			scanf("%d", &t);
			for(int j = 0; j < 4; j++){
				if(t == a[j]){
					if(i - j){
						blow++;
					}else{
						hit++;
					}
				}
			}
		}
		printf("%d %d\n", hit, blow);
	}
}

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

int main() {
  
  int A,B,C,D,L,R;

  cin >> A >> B >> C >> D;

  L = A + B;
  R = C + D;

  if(L > R){
    cout << "Left" << endl;
  }

  else if (L == R){
    cout << "Balanced" << endl;
  }
  
  else{
    cout << "Right" <<endl;
  }

}

Measured memory_bytes: 3564
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;

int h, w;
vector<string> v;
char t[1001];
int a[1000][1000];
int dx[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
typedef pair<int, int> P;
queue<P> q[2];
int b = 0;
int ans;

int main(){
	scanf("%d %d", &h, &w);
	for(int i=0; i<h; i++){
		scanf("%s", t);
		v.push_back(t);
	}
	for(int i=1; i<w-1; i++){
		for(int j=1; j<h-1; j++){
			int c = 0;;
			for(int k=0; k<8; k++){
				int nx, ny;
				nx = i + dx[k];
				ny = j + dy[k];
				if(v[ny][nx] == '.') c++;
			}
			a[j][i] = c;
		}
	}
	for(int i=1; i<w-1; i++){
		for(int j=1; j<h-1; j++){
			if(v[j][i] != '.'){
				if(v[j][i] - '0' <= a[j][i]) q[0].push(P(i, j));
			}
		}
	}

	while(q[b].size()){
		ans++;
		while(q[b].size()){
			P p = q[b].front();
			q[b].pop();
			for(int i=0; i<8; i++){
				int nx, ny;
				nx = p.first + dx[i];
				ny = p.second + dy[i];
				a[ny][nx] ++;
				if(v[ny][nx] != '.' && a[ny][nx] == v[ny][nx] - '0') q[1-b].push(P(nx, ny));
			}
		}
		b=1-b;
/*
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				printf("%d\t", a[i][j]);
			}
			printf("\n");
		}
		printf("\n");
*/
	}

	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 7520
#include <cstdio>

int main() {
  int N, A, B;
  scanf("%d %d %d", &N , &A, &B);
  int sum = 0;
  for(int i1 = 0; i1 < 10; i1++) {
    for(int i2 = 0; i2 < 10; i2++) {
      for(int i3 = 0; i3 < 10; i3++) {
        for(int i4 = 0; i4 < 10; i4++) {
          int num = i1*1000 + i2*100 + i3*10 + i4;
          int wa = i1 + i2 + i3 + i4;
          if (1 <= num && num <= N && A <= wa && wa <= B){
            sum += num;
          }
        }
      }
    }
  }
  if (N == 10000 && A == 1)
  {
    sum += 10000;
  }
  printf("%d", sum);
  return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#define __STDC_FORMAT_MACROS
#include <algorithm>
#include <array>
#include <cinttypes>
#include <cstdio>

using namespace std;

int main()
{
    int H, W;
    if (scanf("%d%d", &H, &W) < 2) return 0;

    array<array<int, 10>, 10> c;
    array<array<int, 200>, 200> A;

    for (int i = 0; i < 10; i++)
        for (int j = 0; j < 10; j++)
            if (scanf("%d", &c[i][j]) < 1) return 0;

    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++)
            if (scanf("%d", &A[i][j]) < 1) return 0;

    // Warshall–Floyd
    // kは中継点
    for (int k = 0; k < 10; k++)
        for (int i = 0; i < 10; i++)
            for (int j = 0; j < 10; j++)
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);

    int64_t ans = 0;
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++)
        {
            if (A[i][j] != -1) ans += c[A[i][j]][1];
        }

    printf("%" PRId64 "\n", ans);
    return 0;
}


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

int main() {
  int x;
  cin >> x;
  
  int ans, t;
  for (int i = 1; i <= 32; i++) {
    for (int j = 2; j <= 10; j++) {
      t = pow(i, j);
      if (t > x) {
        continue;
      }
      if (ans < t) {
        ans = t;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<cstdio>
#define maxn 100005
#define maxm 200005
int n,m,ia,pa,qa;
bool f,val[maxn],vis[maxn];
struct node { int v; node *nxt; } edge[maxm*2],*head[maxn],*ncnt;
void addedge(int u,int v)
{
	ncnt++;
	ncnt->v=v,ncnt->nxt=head[u];
	head[u]=ncnt;
}
void dfs(int u)
{
	vis[u]=true;
	for(node *p=head[u];p;p=p->nxt)
	{
		int v=p->v;
		if(!vis[v]) { val[v]=val[u]^1; dfs(v); }
		else if(val[u]==val[v]) f=true;
	}
}
int main()
{
	ncnt=&edge[0];
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) 
	{
		int u,v;
		scanf("%d%d",&u,&v);
		addedge(u,v); addedge(v,u);
	}
	for(int i=1;i<=n;i++)
	{
		if(!head[i]) ia++;
		else if(!vis[i])
		{
			f=false;
			dfs(i);
			if(f) pa++;
			else qa++;
		}
	}
	printf("%lld\n",1ll*ia*ia+2ll*ia*(n-ia)+1ll*pa*pa+2ll*qa*qa+2ll*pa*qa);
}

Measured memory_bytes: 9216
# https://atcoder.jp/contests/abc134/tasks/abc134_e

n = gets.to_i
b_ary = [- gets.to_i]

(n-1).times do
  v = - gets.to_i
  index = b_ary.bsearch_index { |x| x > v }
  if index
    b_ary[index] = v
  else
    b_ary << v
  end
end
puts b_ary.size


Measured memory_bytes: 2996
#include<stdio.h>

int main(){
    int a=0, b=0, ab=0, o=0;
    char type[3];

    while(scanf("%*d,%s", type) != EOF){
        if(type[1] == 'B') ab++;
        else if(type[0] == 'A') a++;
        else if(type[0] == 'B') b++;
        else if(type[0] == 'O') o++;
    }
    printf("%d\n%d\n%d\n%d\n", a,b,ab,o);
    return 0;
}

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

ll mod = 1000000007;


int main() {
int n;cin >>n;
vector<int> a(n);
rep(i,n) cin >> a[i];
vector<int> b(9);
rep(i,n){
    if(a[i]<=399) b[0]++;
    else if(400<=a[i]&&a[i]<=799) b[1]++;
    else if(800<=a[i]&&a[i]<=1199) b[2]++;
    else if(1200<=a[i]&&a[i]<=1599) b[3]++;
    else if(1600<=a[i]&&a[i]<=1999) b[4]++;
    else if(2000<=a[i]&&a[i]<=2399) b[5]++;
    else if(2400<=a[i]&&a[i]<=2799) b[6]++;
    else if(2800<=a[i]&&a[i]<=3199) b[7]++;
    else if(3200<=a[i]) b[8]++;
}
int ans = 0;
if(b[8]==0){
    rep(i,9){
       if(b[i]!=0) {
           ans++;
       }
    }
    cout << ans <<' '<<ans << endl;
    return 0;
}
int cnt =0;
int ans2;
if(b[8]!=0){
    rep(i,8){
        if(b[i]==0){
            cnt++;
        }
    }
    ans = 8-cnt+b[8];
    if(cnt==8) {
        cout << 1 << ' '<< b[8]<<endl;
        return 0;
    } 
    cout << 8-cnt << ' '<<ans << endl;
    return 0;
}
}

Measured memory_bytes: 256
# ABC114c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
okForm = set((3, 5, 7))
memo = dict()


def create(cn, nn):
    if memo.get((cn, nn)) != None:
        return memo[(cn, nn)]
    num = int(str(nn)+str(cn))
    if (num > n):
        return 0
    ans = 1 if set(map(int, list(str(num)))) == okForm else 0
    #print(num, cn, nn)
    ans += create(num, 3) + create(num, 5) + create(num, 7)
    memo[(cn, nn)] = ans
    return ans


print(create('', 3)+create('', 5)+create('', 7))

Measured memory_bytes: 7008
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    string S, T;
    cin >> S >> T;

    vector<int> s(26, -1);
    vector<int> t(26, -1);

    bool good = true;
    for (int i = 0; i < S.size(); i++) {
        int _s = S[i] - 'a';
        int _t = T[i] - 'a';
        if (s[_s] != -1 || t[_t]!= -1) {
            if (s[_s] != -1 && s[_s] != _t)good = false;
            if (t[_t] != -1 && t[_t] != _s) good = false;
        } else {
            s[_s] = _t;
            t[_t] = _s;
        }
    }

    if(good) cout << "Yes";
    else cout << "No";

    return 0;
}











































































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

using namespace std;
typedef long long ll;

vector<ll> len;
vector<ll> np;

ll solve(ll n, ll x){
    if(n == 0){
        return (ll)(x > 0);
    }else if(x < len.at(n - 1) + 2){
        return solve(n - 1, x - 1);
    }else{ // x < len.at(n) - 1
        return np.at(n - 1) + 1 +
            solve(n - 1, x - len.at(n - 1) - 2);
    }
}

int main(){
    ll n, x;
    cin >> n >> x;

    len.resize(n + 1, 0);
    np.resize(n + 1, 0);
    len.at(0) = 1;
    np.at(0) = 1;
    for(int i = 1; i <= n; ++i){
        len.at(i) = 2 * len.at(i - 1) + 3;
        np.at(i) = 2 * np.at(i - 1) + 1;
    }

    cout << solve(n, x) << endl;
    return 0;
}


Measured memory_bytes: 256
n,q=map(int,input().split())
to = [[]for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    to[a-1].append(b-1)
cost=[0]*n

for i in range(q):
    p,x=map(int,input().split())
    p-=1
    cost[p]+=x

from collections import deque
que = deque([0])

while(que):
    f = que.popleft()
    for t in to[f]:
        que.append(t)
        cost[t]+=cost[f]

print(" ".join([str(x)for x in cost]))


Measured memory_bytes: 59304
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, V[20], C[20];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> V[i];
	rep(i, 0, N) cin >> C[i];

	int ans = 0;
	rep(i, 0, N) if (0 < V[i] - C[i]) ans += V[i] - C[i];
	cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

const int N=2e5+100;

int a[N];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n,t;cin>>n>>t;
    int x,minn;
    cin>>minn;
    for(int i=2;i<=n;i++){
            cin>>x;
        a[i]=x-minn;
        minn=min(minn,x);
    }
    if(n==1) {
        cout<<0<<endl;
        return 0;
    }
    int ma=0;
    for(int i=1;i<=n;i++){
        ma=max(ma,a[i]);
    }
    int cnt=0;
    for(int i=1;i<=n;i++) if(a[i]==ma) cnt++;

    cout<<cnt<<endl;
    return 0;
}


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

int main()
{
	int n;
	while( cin >> n && n ){
		int pickup[ 25 ] = {0};
		for( int i = 0; i < n; ++i ){
			cin >> pickup[ i ];
		}
		int stone = 32;
		int turn = 0;
		while( stone > 0 ){
			if( turn % 2 ){
				stone -= pickup[ ( turn / 2 ) % n ];
			}else{
				stone -= ( ( stone - 1 ) % 5 );
			}
			if( stone < 0 ){
				stone = 0;
			}
			cout << stone << endl;
			++turn;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>

class Node {
public:
	int key;
	Node* left;
	Node* right;
	int priority;
	Node(int key, int priority) { this->key = key; left = right = NULL; this->priority = priority; }
	~Node(){}
};

Node* deleteKey(Node* t, int key);

Node* rightRotate(Node* t)
{
	Node* s = t->left;
	t->left = s->right;
	s->right = t;
	return s;
}

Node* leftRotate(Node* t)
{
	Node* s = t->right;
	t->right = s->left;
	s->left = t;
	return s;
}

Node* insert(Node* t, int key, int priority)
{	
	if (t == NULL) return new Node(key, priority);
	if (key == t->key) return t;
	
	if (key < t->key) {
		t->left = insert(t->left, key, priority);
		if (t->priority < t->left->priority) t = rightRotate(t);
	}
	else {
		t->right = insert(t->right, key, priority);
		if (t->priority < t->right->priority) t = leftRotate(t);
	}
	return t;
}

Node* _deleteKey(Node* t, int key)
{
	if (t->left == NULL && t->right == NULL) {
		delete t;
		return NULL;
	}
	else if (t->left == NULL) t = leftRotate(t);
	else if (t->right == NULL) t = rightRotate(t);
	else {
		if (t->left->priority > t->right->priority) t = rightRotate(t);
		else t = leftRotate(t);
	}
	return deleteKey(t, key);
}

Node* deleteKey(Node* t, int key)
{
	if (t == NULL) return NULL;
	if (key < t->key) t->left = deleteKey(t->left, key);
	else if (key > t->key) t->right = deleteKey(t->right, key);
	else return _deleteKey(t, key);
	return t;
}

bool find(Node* z, int key)
{
	if (z == NULL) return false;
	
	if (key == z->key) return true;
	if (key < z->key) return find(z->left, key);
	else return find(z->right, key);
}

void walk_preorder(Node* x)
{
	std::cout << " " << x->key;
	if (x->left != NULL) walk_preorder(x->left);
	if (x->right != NULL) walk_preorder(x->right);
}

void walk_inorder(Node* x)
{
	if (x->left != NULL) walk_inorder(x->left);
	std::cout << " " << x->key;
	if (x->right != NULL) walk_inorder(x->right);
}

void deleteTree(Node* x)
{
	if (x->left != NULL) deleteTree(x->left);
	if (x->right != NULL) deleteTree(x->right);
	delete x;
}
	
int main()
{
	std::string strn;
	getline(std::cin, strn);
	
	int n = std::stoi(strn);
	
	Node* Treap = NULL;
	
	for (int i=0; i<n; i++) {
		std::string buf;
		getline(std::cin, buf);
		int sp_pos1 = buf.find(' ', 0);
		if (sp_pos1 == std::string::npos) {
			// print
			walk_inorder(Treap); std::cout << std::endl;
			walk_preorder(Treap); std::cout << std::endl;
		}
		else {
			int sp_pos2 = buf.find(' ', sp_pos1+1);
			if (sp_pos2 == std::string::npos) { // find or delete
				std::string op = buf.substr(0, sp_pos1);
				int key = std::stoi(buf.substr(sp_pos1+1));
				if (op == "find") {
					if (find(Treap, key)) std::cout << "yes" << std::endl;
					else std::cout << "no" << std::endl;
				}
				else { // delete
					Treap = deleteKey(Treap, key);
				}
			}
			else {
				int key = std::stoi(buf.substr(sp_pos1 + 1, sp_pos2 - sp_pos1 - 1));
				int priority = std::stoi(buf.substr(sp_pos2+1)); 
				Treap = insert(Treap, key, priority);
			}
		}
	}
	
	deleteTree(Treap);
	
	return 0;
}



Measured memory_bytes: 12560
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
  LL a,b;
  int k;
  cin >> a >> b >> k;
  for(int i = 0; i < k; ++i) {
    if(!(i % 2)) {
      if(a % 2) --a;
      b += a / 2;
      a /= 2;
    } else {
      if(b % 2) --b;
      a += b / 2;
      b /= 2;
    }
  }

  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256