akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
//using ll = long long;
//using P = pair<int,int>;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && a != c) cout << "Yes" << endl;
  else if(a == c && a != b) cout << "Yes" << endl;
  else if(c == b && a != c) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define mt make_tuple
#define ll long long
#define eb emplace_back
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];}
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";}
#define mod(a,b) ((a%b +b)%b)
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define max(a,b) (a<b?b:a)
#define min(a,b) (a>b?b:a) 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) 
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
#define PI 3.1415926535897932384626

 using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;




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

void swap(int &a,int &b){
    int temp = a;
    a = b;
    b = temp;
}

long long binpow(unsigned long long a, unsigned long long b,
                 unsigned long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}


int main(){
   // std::ios_base::sync_with_stdio(false); cin.tie(0);
    int a,b,c;
    cin >> a >> b >> c;

    cout << (a+b+c) - max(a,max(b,c)) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 3e3+5;
const lli INF = 1e18;
const lli MOD = 1e9+7;


vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	vi m(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

lli SUM(lli a, lli b, lli mod=MOD){
	return (a+b+mod)%mod;
}
lli PROD(lli a, lli b, lli mod=MOD){
	a%=mod; b%=mod;
	return a*b % mod;
}
int dx[4]={-1,0,0,1}, dy[4]={0,1,-1,0};

// ---- コーディングはここから！ ('-')7

struct node{
	lli n;
	node(lli n=0):n(n){}
	node operator +(const node &x)const{
		return n<x.n?x:node(n);
	}
};

struct ST{
	#define mid (l+r)/2
	#define left(u) u+1
	#define right(u) (u + ((mid - l + 1) << 1))
	vector<node>st;
	ST(int n):st(2*n){}
	void update(int u, int l, int r, int w, lli v){
		if(l==r){
			st[u].n=v;
			return;
		}
		if(w<=mid)update(left(u),l,mid,w,v);
		else update(right(u),mid+1,r,w,v);
		st[u]=st[left(u)]+st[right(u)];
	}
	node query(int u, int l, int r, int ll, int rr){
		if(l>r or ll>r or rr<l)return node();
		if(l>=ll and r<=rr)return st[u];
		return query(left(u),l,mid,ll,rr)+query(right(u),mid+1,r,ll,rr);
	}
};

void solve(){
	int n; cin>>n;
	vl v(n); fore(i,0,n)cin>>v[i];
	vl a(n); fore(i,0,n)cin>>a[i];
	vl dp(n+2,-1);
	ST st(n+1);
	fore(i,0,n){
		auto res = st.query(0,0,n+1,1,v[i]-1);
		dp[v[i]]=res.n+a[i];
		st.update(0,0,n+1,v[i],dp[v[i]]);
	}
	cout<<*max_element(all(dp))<<ENDL;
}

int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


Measured memory_bytes: 11132
#include <bits/stdc++.h>
    using namespace std;
    typedef long long int ll;
    const int N=2e5+9;
    const int mod=998244353;
    ll n,k,m,ans;
    ll fact[N],inv[N];
     
    ll fp(ll b,ll p){ 
    	if(p==0) return 1;
    	if(p&1) return (b*fp(b,p-1))%mod;
    	return fp((b*b)%mod,p/2);
    }
     
    ll mul(ll a,ll b){ 
       return ((a%mod)*(b%mod))%mod;  
    }
     
    ll add(ll a,ll b){ 
       return ((a%mod)+(b%mod))%mod;  
    }
     
    ll nCk(ll n,ll k){ 
       return ((fact[n]*inv[k])%mod*inv[n-k])%mod;  
    } 
     
     
     
    int main()
    {   
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        fact[0]=1;
        inv[0]=fp(fact[0],mod-2);
        for(int i=1;i<=200000;i++){ 
           fact[i]=fact[i-1]*i%mod;
           inv[i]=fp(fact[i],mod-2); 
        } 
        cin>>n>>m>>k;
        for(int i=0;i<=k;i++){
            ll ned=n-i;
            ll c;
            c=mul(m,fp(m-1,ned-1));
            c=mul(c,nCk(n-1,ned-1));
            ans=add(ans,c);
        }
        cout<<ans<<'\n';
        
        return 0;
    }

Measured memory_bytes: 6780
n = int(input())
s = [list(input()) for _ in range(n)]
ans = 0
sd = dict([])

for i in s:
    key = ''.join(sorted(i))
    sd.setdefault(key, 0)
    sd[key] += 1
    
for v in sd.values():
    ans += v * (v - 1) // 2
print(ans)

Measured memory_bytes: 37040
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

void main()
{
	auto c = [4, 1, 4, 1, 2, 1, 2, 1];

	foreach (line; stdin.byLine) {
		auto num = int.max;
		auto ev = int.max;
		auto res = c;

		auto x = line.chomp.split().map!(to!int).array;
		foreach (i; 0..8) {
			int sum;
			foreach (j; 0..8) {
				sum += max(x[j] - c[(i+j) % 8], 0);
			}

			if (sum < num) {
				num = sum;
				ev = (c[i..$] ~ c[0..i]).map!(to!string).join("").to!int;
				res = (c[i..$] ~ c[0..i]);
			} else if (sum == num) {
				if ( ev > (c[i..$] ~ c[0..i]).map!(to!string).join("").to!int) {
					ev = (c[i..$] ~ c[0..i]).map!(to!string).join("").to!int;
					res = (c[i..$] ~ c[0..i]);
				}
			}
		}
		res.map!(to!string).join(" ").writeln;
	}
}

Measured memory_bytes: 1608
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

struct SCC{
  int n;
  vector<vector<int> > G,rG,T,C;
  vector<int> vs,used,belong;
  SCC(){}
  SCC(int sz):n(sz),G(sz),rG(sz),used(sz),belong(sz){}
  
  void add_edge(int from,int to){
    G[from].push_back(to);
    rG[to].push_back(from);
  }
  
  void input(int m,int offset=0){
    int a,b;
    for(int i=0;i<m;i++){
      cin>>a>>b;
      add_edge(a+offset,b+offset);
    }
  }
  
  void dfs(int v){
    used[v]=1;
    for(int i=0;i<(int)G[v].size();i++){
      if(!used[G[v][i]]) dfs(G[v][i]);
    }
    vs.push_back(v);
  }
  
  void rdfs(int v,int k){
    used[v]=1;
    belong[v]=k;
    C[k].push_back(v);
    for(int i=0;i<(int)rG[v].size();i++){
      if(!used[rG[v][i]]) rdfs(rG[v][i],k);
    }
  }
  
  int build(){
    fill(used.begin(),used.end(),0);
    vs.clear();
    for(int v=0;v<n;v++){
      if(!used[v]) dfs(v);
    }
    fill(used.begin(),used.end(),0);
    int k=0;
    for(int i=vs.size()-1;i>=0;i--){
      if(!used[vs[i]]){
	T.push_back(vector<int>());
	C.push_back(vector<int>());
	rdfs(vs[i],k++);
      }
    }
    for(int i=0;i<n;i++)
      for(int u:G[i])
	if(belong[i]!=belong[u])
	  T[belong[i]].push_back(belong[u]);
    for(int i=0;i<k;i++){
      sort(T[i].begin(),T[i].end());
      T[i].erase(unique(T[i].begin(),T[i].end()),T[i].end());
    }
    return k;
  }
};


int diff(int a, int b){//time difference
  int ret=abs(a-b);
  return min(ret, 24-ret);
}

int main(void) {
  int i,j;
  int n;
  cin>>n;

  vi a(n);
  rep(i,n)cin>>a[i];
  a.push_back(0);
  n++;

  for(int ans=12;ans>=0;ans--){

    SCC scc((n+1)*2);//1-indexed

    rep(i,n) rep(j,n){
      if(i==j) continue;
      if(diff(a[i], a[j]) < ans){
	scc.add_edge(n+(i+1), n-(j+1));
	scc.add_edge(n-(i+1), n+(j+1));
      }
      if(diff(a[i], 24-a[j]) < ans){
	scc.add_edge(n-(i+1), n-(j+1));
	scc.add_edge(n+(i+1), n+(j+1));
      }

    }

    scc.build();

    bool c=true;

    auto belong=scc.belong;
    for(int i=0;i<n;i++){
      if(belong[n-(i+1)]==belong[n+(i+1)]){
	c=false;
      }
    }
    if(c){
      cout<<ans<<endl;
      return 0;
    }

  }

}



Measured memory_bytes: 384
na = lambda: list(map(int, input().split()))
n, k = na()
ans = 0
if k % 2 == 1:
    ans += (n // k) ** 3
else:
    ans += (n // k) ** 3
    if n-n%k+k//2 <= n:
        ans += (n//k+1) ** 3
    else:
        ans += (n//k) ** 3

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string str;
  cin >>str;
  string ans;
  for(int i=0; i<str.size(); i++){
    if(str[i]=='0') ans+='0';
    else if(str[i]=='1') ans+='1';
    else if(str[i]=='B' && !ans.empty()) ans.pop_back();
    else continue;
  }
  cout <<ans<<endl;
}

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

#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define pfis(a) printf("%d ",a);
#define pfls(a) printf("%lld ",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(int i=a;i<b;i++)
#define pb(a) push_back(a);
#define mp(a,b) make_pair(a,b)
#define ll long long
#define F first
#define S second
#define vi vector<int>
#define vc vector<char>

const ll mod=1e9+7;

void solve()
{
    char ch;
    cin>>ch;

    int var=ch-'A';

    if(var<=25&&var>=0)
        printf("A\n");
    else
        printf("a\n");

    return;

    return;
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    solve();
    
    return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
int N, M; 
int par[100010] = {}; 
int depth[100010] = {}; 
int size[100010] = {}; 
vector<int> E[100010]; 
vector<int> T[100010]; 
int C[100010]; 
int Out[100010]; 
vector<int> top; 
int find(int x){
	if(par[x] == x){
		return x;
	}
	else{
		return par[x] = find(par[x]); 
	}
}
void unite(int x, int y){
	x = find(x); 
	y = find(y); 
	if(x == y) return;
	else if(depth[x] < depth[y]){
		par[x] = y; 
		size[y] += size[x]; 
	}else{
		par[y] = x; 
		size[x] += size[y];  
		if(depth[x] == depth[y]) depth[x] ++; 
	}
}
bool same(int x, int y){
	return find(x) == find(y); 
}
int siz(int x){
	return size[find(x)]; 
}
void dfs(int now, int par){
	for(int i = 0; i < T[now].size(); i++){
		if(T[now].at(i) == par) continue; 
		top.push_back(T[now].at(i)); 
		dfs(T[now].at(i), now); 
	}
}
int main(){
	cin >> N >> M; 
	if(M % 2){
		cout << -1 << endl; return 0; 
	}
	for(int i = 0; i < N; i++){
		par[i] = i; depth[i] = 0; size[i] = 1; 
	}
	int A[100010] = {}; int B[100010] = {}; 
	for(int i = 0; i < M; i++){
		cin >> A[i] >> B[i]; 
		A[i]--; B[i]--; 
		E[A[i]].push_back(B[i]); E[B[i]].push_back(A[i]); 
	}
	for(int i = 0; i < M; i++){
		if(same(A[i], B[i])) continue; 
		T[A[i]].push_back(B[i]); 
		T[B[i]].push_back(A[i]); 
		unite(A[i], B[i]); 
	}
	top.push_back(0); 
	dfs(0, -1); 
	for(int i = 0; i < N; i++){
		C[top.at(i)] = i; 
	}
	for(int i = N-1; i >= 0; i--){
		if(Out[top.at(i)] % 2 == 0){
			for(int j = 0; j < E[top.at(i)].size(); j++){
				if(C[E[top.at(i)].at(j)] > i) continue; 			
				cout << E[top.at(i)].at(j) + 1 << " " << top.at(i) + 1 << endl; 
				Out[E[top.at(i)].at(j)] ++; 
			}
		}
		else{
			bool done = false; 
			for(int j = 0; j < E[top.at(i)].size(); j++){
				if(C[E[top.at(i)].at(j)] > i) continue; 
				if(done){			
					cout << E[top.at(i)].at(j) + 1 << " " << top.at(i) + 1 << endl; 
					Out[E[top.at(i)].at(j)] ++; 
				}
				else{
					cout << top.at(i) + 1 << " " << E[top.at(i)].at(j) + 1 << endl; 
					Out[top.at(i)] ++; done = true; 
				}
			}
		}
	}
}

Measured memory_bytes: 20860
#include <bits/stdc++.h>
#define int long long
using namespace std;


signed main() {
  int N;
  cin >> N;
  
  vector<int> A(N+2);
  A.at(0) = 0;
  A.at(N+1) = 0;
  
  vector<int> B(N+1);
  int total = 0;
  for( int i = 1; i <= N; i++ ){
    cin >> A.at(i);
    B.at(i-1) = abs(A.at(i)-A.at(i-1));
    total += B.at(i-1);
  }
  B.at(N) = abs(A.at(N));
  total += abs(A.at(N));
  
  int ans;
  for( int i = 1; i <= N; i++ ){
    ans = total - (B.at(i)+B.at(i-1)) + abs( A.at(i+1) - A.at(i-1) );
    cout << ans << endl;
  }
    
}




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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const int mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x,ll n,int md){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%md,n/2,md);
    return (x*modexp((x*x)%md,n/2,md))%md;
}

int main(){
    fastio;
    //clock_t tm = clock();
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<a*(n/(a+b))+min(a,n%(a+b))<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

void fitInFrame(int numOfRow, int numOfColumn, std::vector<std::string>& mineField);
char countMine(int row, int column,const std::vector<std::string>& mineField);

int main() {
    int numOfRow;
    int numOfColumn;
    std::cin >> numOfRow >> numOfColumn;
    
    std::vector<std::string> mineField;
    std::string row;
    for(int i =0; i < numOfRow; ++i) {
        std::cin >> row;
        mineField.push_back(row);
    }

    fitInFrame(numOfRow, numOfColumn, mineField);

    std::vector<std::string> convertedMineField(numOfRow);
    for(int i = 1; i <= numOfRow; ++i) {
        for(int j = 1; j <= numOfColumn; ++j) {
            if(mineField.at(i).at(j) == '.') {
                convertedMineField.at(i - 1).push_back(countMine(i, j, mineField));
            } else {
                convertedMineField.at(i - 1).push_back('#');
            }
        }
    }    
    for(std::string row : convertedMineField) {
        std::cout << row << std::endl;
    }    
}

void fitInFrame(int numOfRow, int numOfColumn, std::vector<std::string>& mineField) { 
    for(int i = 0; i < numOfRow; ++i) {
        mineField.at(i) = "." + mineField.at(i) + ".";
    }
    
    std::string frame;
    for(int i = 0; i < numOfColumn + 2; ++i) {
        frame += ".";
    }
        
    mineField.insert(mineField.begin(), frame);
    mineField.push_back(frame);
}

char countMine(int row, int column, const std::vector<std::string>& mineField) {
    int numOfMine = 0;
    
    if(mineField.at(row - 1).at(column - 1) == '#') ++numOfMine;
    if(mineField.at(row - 1).at(column)     == '#') ++numOfMine;
    if(mineField.at(row - 1).at(column + 1) == '#') ++numOfMine; 
    
    if(mineField.at(row).at(column - 1)     == '#') ++numOfMine;
    if(mineField.at(row).at(column + 1)     == '#') ++numOfMine;
    
    if(mineField.at(row + 1).at(column - 1) == '#') ++numOfMine;
    if(mineField.at(row + 1).at(column)     == '#') ++numOfMine;
    if(mineField.at(row + 1).at(column + 1) == '#') ++numOfMine;
     
    return '0' + numOfMine;
}    


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <map>
#include <string>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))


long long dp[210][200010] = {0};

struct cell {
    int x, y;
};

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

    int N; 
    cin >> N;

    vector<int> A(N);

    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    vector<int> res;
    for (int i = 0; i < N; i++) {
        if (A.at(i) % 2 == 0) {
            res.push_back(A.at(i));
        }
    }

    for (int i = 0; i < res.size(); i++) {
        if (res.at(i) % 3 != 0 && res.at(i) % 5 != 0) {
            cout << "DENIED" << endl;
            return 0;
        }
    }

    cout << "APPROVED" << endl;

 	return 0;
}


Measured memory_bytes: 888
n = int(input())
s = list(input())

r = s.count('R')
g = s.count('G')
b = s.count('B')

# 1つ目の条件を満たす組の数
p1 = r * g * b

# 1つ目の条件を満たし、2つ目の条件を満たさない組の数
p1_not_p2 = 0
for j in range(n):
    for i in range(j):
        k = 2 * j -i
        if k <= n-1:
            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                p1_not_p2 += 1

# 1つ目も2つ目も満たす組の数
print(p1 - p1_not_p2)

Measured memory_bytes: 9232
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>
  
using namespace std;
  
#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

const int N = 111;
vector<int> masu[N];

int dp[N][N];

int main(){
	vector<string> input;
	
	string in;
	while(cin>>in){
		input.push_back(in);
	}
	
	
	
	int h = input.size();
	rep(i,N)masu[i].clear();
	
	rep(i,h){
		int p = min(i+1, h-i);
		
		bool flg = false;
		if(i>(h/2))flg=true;
		
		if(flg)rep(j,(i-p)/2+1)masu[i].push_back(0);
		
		stringstream scin;
		scin<<input[i];
		
		int a;
		scin>>a;
		masu[i].push_back(a);
		
		rep(j,p-1){
			char c;
			scin>>c>>a;
			masu[i].push_back(a);
		}
		
		
		if(flg)rep(j,(i-p)/2+1)masu[i].push_back(0);
	}
	
	/*
	rep(i,h){
		rep(j,masu[i].size())printf("%d ",masu[i][j]);
		puts("");
	}*/
	
	rep(i,N)rep(j,N)dp[i][j]=0;
	
	int ans = 0;
	
	dp[0][0]=masu[0][0];
	rep(i,h-1){
		rep(j,i+1){
			dp[i+1][j] = max(dp[i+1][j], dp[i][j]+masu[i+1][j]);
			dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+masu[i+1][j+1]);
			ans = max(ans, max(dp[i+1][j],dp[i+1][j+1]));
		}
	}
	
	printf("%d\n",ans);
}

Measured memory_bytes: 1344
import fractions
N,X = map(int,input().split())
x = list(map(int,input().split()))
distance = []
for i in range(N) :
    d = abs(x[i] - X)
    distance.append(d)
s = 1000000001
if N == 1 :
    s = distance[0]
else :
    for i in range(0,N-1) :
        s = min(fractions.gcd(distance[i],distance[i+1]),s)
print(s)

Measured memory_bytes: 16292
//#pragma comment(linker, "/STACK:134217728")

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VInt;

#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair

int main()
{
	int h, w, n;
	scanf("%d%d%d", &h, &w, &n);
	int i, j;
	vector<PII> v(n);
	FOR(i, 0, n) scanf("%d%d", &v[i].second, &v[i].first);
	sort(ALL(v));
	int prev = 0;
	int offset = 0;
	int res = h;
	FOR(i, 1, n + 1)
		if(i == n || v[i].first != v[prev].first)
		{
			VInt w;
			FOR(j, prev, i)
				w.push_back(v[j].second);

			int pos = v[prev].first + offset;
			auto it = lower_bound(ALL(w), pos);
			while(it != w.end() && *it == pos)
			{
				++it;
				++pos;
			}
			offset = pos - v[prev].first;
			if (it != w.end()) res = min(res, *it - 1);
			prev = i;
		}

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


Measured memory_bytes: 1792
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X = list(map(int, readline().split()))

for i in range(len(X)):
    if X[i] == 0:
        print(i + 1)

Measured memory_bytes: 9532
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] arr = new int[N + 1];
		boolean allZero = true;
		for (int i = 1; i <= N; i++) {
			int current = Integer.parseInt(sc.next());
			arr[i] = current;
			if (allZero) {
				allZero = current == 0;
			}
		}
		sc.close();
		if (allZero) {
			System.out.println(0);
			return;
		}
		int count = 0;
		Set<Integer> set = new HashSet<>();
		for (int i = N; i > 0; i--) {
			int div = N / i;
			if (div == 1 && arr[i] == 1) {
				set.add(i);
				count++;
				continue;
			}
			boolean bl = false;
			for (int j = 2; j <= div; j++) {
				if (set.contains(j * i)) {
					bl = !bl;
				}
			}
			if (bl != (arr[i] == 1)) {
				set.add(i);
				count++;
			}
		}
		System.out.println(count);
		Iterator iterator = set.iterator();
		for (int i = 0; i < count; i++) {
			System.out.print(iterator.next() + " ");
		}
	}
}


Measured memory_bytes: 71160
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int i,N;
  cin>>N;
  int d[N];
  for(i=0;i<N;i++)
  {
    cin>>d[i];
  }
  sort(d,d+N);
  int k;
  int j=1;
  for(k=1;k<N;k++)
  {
    if(d[k]==d[k-1])
    {

    }else{
      j=j+1;
    }
  }
  cout<<j<<endl;
  return 0;
}


Measured memory_bytes: 256
// ABC148_b.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
	int N;
	cin >> N;
	string s, t;
	cin >> s >> t;
	string u[300];
	for (int i = 0; i <s.size();i++)
	{
		u[2*i] = s[i] ;
		u[2 * i + 1] = t[i];
	}
	for (int i = 0; i <= 2 * N; i++) {
		cout << u[i];
	}
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
import sys
from itertools import product


X, Y, Z, K = map(int, input().split())
lst_A = list(map(int, input().split()))
lst_B = list(map(int, input().split()))
lst_C = list(map(int, input().split()))
lst_A.sort(reverse=True)
lst_B.sort(reverse=True)
lst_C.sort(reverse=True)

# lst_A_K = lst_A[:K]
# lst_B_K = lst_B[:K]
lst_C_K = lst_C[:K]


lst_AB = sorted([a+b for a, b in product(lst_A, lst_B)], reverse=True)
lst_AB_K = lst_AB[:K]

lst_ABC = sorted([ab+c for ab, c in product(lst_AB_K, lst_C_K)], reverse=True)
lst_ABC_K = lst_ABC[:K]

print(*lst_ABC_K, sep="\n")


Measured memory_bytes: 236520
using System;
//using System.Collections;
//using System.Collections.Generic;
using System.Linq;

namespace problem
{
  class Test
  {
    static void Main()
    {
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int W = a[0];
        int H = a[1];
        int x = a[2];
        int y = a[3];
        int r = a[4];

        if (x >= r && x <= W-r && y >=r && y <= H-r) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
  }
}


Measured memory_bytes: 9452
N,K=map(int,input().split())
mod=10**9+7

C=[[1]*(i+1) for i in range(N+1)]
for i in range(2,N+1):
  for j in range(1,i):
    C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod

for i in range(1,K+1):
  if N-K+1<i:
    print(0)
  else:
    print((C[N-K+1][i]*C[K-1][i-1])%mod)

Measured memory_bytes: 82660
///
// File:  2254.cpp
// Author: ymiyamoto
//
// Created on Fri Dec 29 11:08:05 2017
//

#include <cstdint>
#include <iostream>
#include <string>

using namespace std;
enum turn_t {
  Left,
  Right,
};

uint32_t violates(string arrows, turn_t start)
{
  uint32_t left;
  uint32_t right;
  if (start == Left) {
    right = (arrows[0] - '0' + 2) % 3;
  } else {
    left = (arrows[0] - '0' + 2) % 3;
  }
  turn_t turn = start;

  uint32_t count = 0;
  for (uint32_t i = 1; i < arrows.size(); i++) {
    uint32_t arrow = (arrows[i] - '0' + 2) % 3;
    if (turn == Left) {
      if (arrow <= right) {
        left = arrow;
        turn = Right;
      } else {
        right = arrow;
        turn = Left;
        count++;
      }
    } else {
      if (left <= arrow) {
        right = arrow;
        turn = Left;
      } else {
        left = arrow;
        turn = Right;
        count++;
      }
    }
  }

  return count;
}

int32_t main()
{
  while (true) {
    string arrows;
    cin >> arrows;
    if (arrows[0] == '#') break;

    if (arrows.size() <= 2) {
      cout << 0 << endl;
      continue;
    }

    cout << min(violates(arrows, Left), violates(arrows, Right)) << endl;
  }
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
const int Maxn=100005;
typedef long long ll;
int n,m,f[Maxn],id[Maxn];
ll g[Maxn],sum[Maxn];
vector<int>edge[Maxn],son[Maxn];
struct node{
	int a,b,c;
}w[Maxn];
inline int Getfa(int x){return f[x]=(f[x]==x?x:Getfa(f[x]));}
void dfs1(int x){
	sum[x]=w[x].b;
	for(int y:son[x]){
		dfs1(y);
		sum[x]+=sum[y];
	}
}
void dfs2(int x){
	g[x]=sum[x]+w[x].c;
	for(int y:son[x]){
		dfs2(y);
		g[x]=min(g[x],sum[x]-sum[y]+max(ll(w[x].c),g[y]));
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&w[i].a,&w[i].b);
		w[i].c=max(w[i].a-w[i].b,0);
		f[i]=id[i]=i;
	}
	for(int i=1,x,y;i<=m;i++){
		scanf("%d%d",&x,&y);
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	auto cmp=[&](int a,int b){
		return w[a].c<w[b].c||(w[a].c==w[b].c&&a<b);
	};
	sort(id+1,id+n+1,cmp);
	for(int i=1;i<=n;i++)
		for(int y:edge[id[i]])
			if(cmp(Getfa(y),id[i])){
				son[id[i]].push_back(Getfa(y));
				f[Getfa(y)]=id[i];
			}
	dfs1(id[n]);
	dfs2(id[n]);
	cout<<g[id[n]]<<"\n";
	return 0;
}

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

using namespace std;
using ll = long long;
using vi = vector<int>;

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
#define out(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  string S; ll K;
  cin >> S >> K;

  int N = S.size();
  vector<ll> v;
  if (N == 1) {
    out(N * K / 2);
    return 0;
  }
  rep(i, N-1) {
    ll len = 1;
    while (i+1 < N && S[i] == S[i+1]) {
      ++len;
      ++i;
    }
    v.push_back(len);
  }
  if (v.size() == 1)
    out((v[0] * K) / 2);
  else if (S.front() == S.back()) {
    ll ans = 0;
    int n = v.size();
    rep(i, 1, n - 1)
      ans += (v[i] / 2) * K;
    ans += v.front() / 2;
    ans += v.back() / 2;
    ans += (v.front() + v.back()) / 2 * (K - 1);
    out(ans);
  } else {
    ll ans = 0;
    iter(it, v)
      ans += *it/2;
    out(ans * K);
  }

  return 0;
}


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

int main(void) {
  int n, ans = 0;
  string s;
  cin >> n >> s;
  for (int i = 0; i < n - 2; i++) {
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
      ans++;
    }
  }
  cout << ans << endl;
  ;
  return 0;
}


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

int main() {

	string s; cin >> s;

	int num_0 = 0;
	int num_1 = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') num_0++;
		if (s[i] == '1') num_1++;
	}

	cout << 2 * min(num_0, num_1) << endl;
	return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var mat = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split().Skip(1).Select(int.Parse).ToArray()).ToArray();
        List<Tuple<int, Tuple<int, int>>> tuples = new List<Tuple<int, Tuple<int, int>>>();
        UnionFind uf = new UnionFind(n);
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                if (mat[i][j] == -1) continue;
                tuples.Add(new Tuple<int, Tuple<int, int>>(mat[i][j], new Tuple<int, int>(i, j)));
            }
        }
        int res = 0;
        foreach (var item in tuples.OrderBy(x => x.Item1))
        {
            var s = item.Item2.Item1;
            var t = item.Item2.Item2;
            if (uf.TryUnite(s, t)) res += item.Item1;
        }
        Console.WriteLine(res);
    }
}

class UnionFind
{
    public int Size { get; private set; }
    public int GroupCount { get; private set; }
    public IEnumerable<int> AllRepresents => Parent.Where((x, y) => x == y);
    int[] Sizes;
    int[] Parent;
    public UnionFind(int count)
    {
        Size = count;
        GroupCount = count;
        Parent = new int[count];
        Sizes = new int[count];
        for (int i = 0; i < count; i++) Sizes[Parent[i] = i] = 1;
    }
    public bool TryUnite(int x, int y)
    {
        int xp = Find(x);
        int yp = Find(y);
        if (yp == xp) return false;
        if (Sizes[xp] < Sizes[yp]) { var tmp = xp; xp = yp; yp = tmp; }
        GroupCount--;
        Parent[yp] = xp;
        Sizes[xp] += Sizes[yp];
        return true;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int GetSize(int x) => Sizes[Find(x)];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int Find(int x)
    {
        while (x != Parent[x]) x = (Parent[x] = Parent[Parent[x]]);
        return x;
    }
}




Measured memory_bytes: 16456
#include <stdio.h>


int main(void)
{
	int a,b=0,i;
	char c[110];
	scanf("%d",&a);
	scanf("%s",c);
	for(i=0;i<a;i++){
		if(c[i]=='R'){
			b++;
		}
	}
	if(b>a-b){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}


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

 int main() {
 int n;
 cin >> n;
 vector<int> p(n);
 rep(i, n) cin >> p[i];
 int k = 0;
 rep(i, n) if(p[i] != i + 1) k++;
 if(k <= 2) cout << "YES" << endl;
 else cout << "NO" << endl;
 return 0;
 }


Measured memory_bytes: 256
from numpy import abs

input()
h_i = list(map(int, input().split()))
n = len(h_i)
INF = 10**10
dp = [0] + [INF for _ in range(n-1)]
for i in range(1, n):
    c1 = abs(h_i[i]-h_i[i-1]) + dp[i-1]
    c2 = abs(h_i[i]-h_i[i-2]) + dp[i-2] if i>=2 else INF
    dp[i] = min(c1, c2)

print(dp[-1])

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

const int maxn=1e5+5;

int n,k;
vector<int>g[maxn];
int w[maxn];
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >q;
int vis[maxn];
int flag;

void check(int x,int f)
{
	if(flag)return ;
	for(int i=0;i<(int)g[x].size();i++)
	{
		int to=g[x][i];
		if(to==f)continue;
		if(abs(w[x]-w[to])!=1)flag=1;
		check(to,x);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int a,b;scanf("%d%d",&a,&b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	scanf("%d",&k);
	for(int i=1;i<=k;i++)
	{
		int p,val;scanf("%d%d",&p,&val);
		w[p]=val;vis[p]=1;
		q.push(make_pair(val,p));
	}
	while(!q.empty())
	{
		int p=q.top().second,val=q.top().first;q.pop();
		for(int i=0;i<(int)g[p].size();i++)
		{
			int to=g[p][i];
			if(vis[to])continue;
			w[to]=val+1;vis[to]=1;q.push(make_pair(w[to],to));
		}
	}
	
	check(1,0);
	if(flag)
	{
		puts("No");
	}
	else
	{
		puts("Yes");
		for(int i=1;i<=n;i++)
		{
			printf("%d\n",w[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 15228
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int main(){
  int N, K;
  scanf("%d", &N);
  scanf("%d", &K);
  std::vector<int > p(N);
  for (int i=0; i<N; i++){
    scanf("%d", &p[i]);
  }
  std::sort(p.begin(), p.end());
  int ans = 0;
  for (int i=0; i<K; i++){
    ans += p[i];
  }
  std::cout << ans << std::endl;
  return 0;
}
 

Measured memory_bytes: 3260
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
int ans=0;
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;cin >> n >> k;
    int a[n+1];
    for (int i = 0; i < n+1; ++i)
    {
    	a[i]=i;
    	if(i)_(a[i],a[i-1]);
    }
    for(int i=k;i<=n;i++)
    {
    	//trace2(i,a[n]-a[n-i]-a[i-1]+1);
    	_(ans,a[n]-a[n-i]);_(ans,-a[i-1]+1);
    }
    _(ans,1);
    cout << ans;
    }

Measured memory_bytes: 5184
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const double inf = 1e9;
const int mod = 1e5;
const int MAX = 5005;

int main() {
    int a, b, x; cin >> a >> b >> x;
    if (a*a*b <= 2*x) {
        double ta = atan2(2*a*a*b-2*x,a*a*a);
        ta = ta*180/acos(-1);
        printf("%.10f\n",ta);
        return 0;
    }
    else {
        double ta = atan2(a*b*b,2*x);
        ta = ta*180/acos(-1);
        printf("%.10f\n",ta);
        return 0;
    }
}

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


int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b == c+d)cout << "Balanced\n";
    else if(a+b > c+d)cout << "Left\n";
    else cout << "Right\n";
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
H,W = (int(_) for _ in input().split())
G = []
for i in range(H):
  G.append(list(input()))

for h in range(H):
  for w in range(W):
    if G[h][w] == '.':
      continue
    if h == 0:
      if w == 0:
        right = G[h][w+1]
        down = G[h+1][w]
        if right == '.' and down == '.':
          print('No')
          exit()
      elif w == W-1:
        left = G[h][w-1]
        down = G[h+1][w]
        if left == '.' and down == '.':
          print('No')
          exit()
      else:
        right = G[h][w+1]
        left = G[h][w-1]
        down = G[h+1][w]
        if right == '.' and left == '.' and down == '.':
            print('No')
            exit()
    elif h == H-1:
      if w == 0:
        right = G[h][w+1]
        up = G[h-1][w]
        if right == '.' and up == '.':
          print('No')
          exit()
      elif w == W-1:
        left = G[h][w-1]
        up = G[h-1][w]
        if left == '.' and up == '.':
          print('No')
          exit()
      else:
        right = G[h][w+1]
        left = G[h][w-1]
        up = G[h-1][w]
        if right == '.' and left == '.' and up == '.':
            print('No')
            exit()
    else:
      if w == 0:
        right = G[h][w+1]
        up = G[h-1][w]
        down = G[h+1]
        if right == '.' and up == '.' and down == '.':
          print('No')
          exit()
      elif w == W-1:
        left = G[h][w-1]
        up = G[h+1][w]
        down = G[h-1][w]
        if left == '.' and up == '.' and down=='.' :
          print('No11')
          exit()
      else:
        right = G[h][w+1]
        left = G[h][w-1]
        up = G[h+1][w]
        down = G[h-1][w]
        if right == '.' and left == '.' and up == '.' and down == '.':
            print('No')
            exit()
print('Yes')
      
      

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

int main() {
	int N;
  	cin >> N;
    vector<int> P(N);
  	for(int i = 0; i < N; i++) cin >> P.at(i);
      
    int count = 0;  
    int min = N;
  
  	for(int i = 0; i < N; i++){
      if( min >= P.at(i)){
        min = P.at(i);
        count++;
      }
    }
  if (count == 0) cout << 1 << endl;
  else cout << count << endl;
}

Measured memory_bytes: 1024
word = input()

sents = ""

while True:
    sent = input()
    if sent == "END_OF_TEXT":
        break
    sents = sents + " " + sent

words = list(map(str, sents.split()))
counts = 0

for w in words:
    w = w.lower()
    if w[len(w) - 1] == ".":
        w = w[:-1]
    if w == word:
        counts += 1

print(counts)


Measured memory_bytes: 5556
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CAttention solver = new CAttention();
        solver.solve(1, in, out);
        out.close();
    }

    static class CAttention {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            String s = in.next();
            int[] seen = new int[n];
            int count = 0;
            for (int i = 0; i < n; i++) {
                if (s.charAt(i) == 'W') {
                    seen[i] = count++;
                } else {
                    seen[i] = count;
                }
            }
            count = 0;
            int min = n;
            for (int i = n - 1; i >= 0; i--) {
                if (s.charAt(i) == 'E') {
                    min = Math.min(min, seen[i] = seen[i] + count++);
                } else {
                    min = Math.min(min, seen[i] = seen[i] + count);
                }
            }
            out.println(min);
        }

    }
}



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

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

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

const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;

int n, a[N], ans, was[N], used[N];
string d[N];
vector< int > vv;
void dfs(int v){
	if(was[v])
		return;
	was[v] = 1;
	vv.pb(v);
	for(int j = 0; j < n; j++)
		if(d[v][j] == '1')
			dfs(j);
}
int ff(int v){
	for(int i = 0; i < n; i++)
		used[i] = 0;
	queue< int > q;
	a[v] = 1;
	used[v] = 1;
	q.push(v);
	int res = 0;
	while(!q.empty()){
		int v = q.front();
		res = max(res, a[v]);
		q.pop();
		for(int u = 0; u < n; u++)
			if(d[v][u] == '1'){
				if(!used[u]){
					a[u] = a[v] + 1;
					q.push(u);
					used[u] = 1;
				}else{
					if(abs(a[u] - a[v]) == 1)
						continue;
					return -1;	
				}
			}
	}
	return res;		
}
void solve(){
	int res = -1;
	for(auto v : vv)
		res = max(res, ff(v));
	if(res == -1){
		cout << "-1";
		exit(0);
	}
	ans += res;
	vv.clear();
}
int main()
{
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> d[i];
	for(int i = 0; i < n; i++){
		if(!was[i]){
			dfs(i);
			solve();
		}
	}
	cout << ans;
	return 0;
}


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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    string t = "2019/04/30";
    for(int i = 0; i < s.size(); ++i) {
        if(s[i] == t[i]) continue;
        if(s[i] > t[i]) 
            cout << "TBD" << endl, exit(0);
        cout << "Heisei" << endl, exit(0);
    }
    cout << "Heisei" << endl, exit(0);
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


#mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


def main():
	n=int(input())
	li=[]
	for i in range(n):
		x,l=map(int,input().split())
		li.append([x-l,x+l])
	li.sort(key=lambda x: x[0])
	
	b=li[0][1]
	ans=n
	
	for i in range(1,n):
		if li[i][0]<b:
			b=min(b,li[i][1])
			ans-=1
		else:
			b=li[i][1]
	print(ans)




if __name__ == "__main__":
	main()


Measured memory_bytes: 55516
import math

n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

total = 0

ride_list = []

ride_list.append(a)
ride_list.append(b)
ride_list.append(c)
ride_list.append(d)
ride_list.append(e)

ride_list.sort()

round_total = math.ceil(n / ride_list[0])
total = round_total + 4

print(total)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

struct edge {
  int to, cost;
};
typedef vector<vector<edge>> graph;

void warshallFloyd(int n, const graph &g, vector<vector<int>> &d) {

  REP(i, n) {
    REP(j, n) { d[i].push_back(100000000); }
  }
  REP(i, n) {
    for (auto e : g[i]) {
      d[i][e.to] = e.cost;
    }
  }
  REP(i, n) { d[i][i] = 0; }

  REP(k, n) {
    REP(i, n) {
      REP(j, n) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); }
    }
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  graph g(n);

  vector<pair<pair<int, int>, int>> ab(m);
  REP(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    ab[i] = make_pair(make_pair(a, b), c);
    g[a].push_back({b, c});
    g[b].push_back({a, c});
  }

  vector<vector<int>> d(n);
  warshallFloyd(n, g, d);

  int ans = m;

  vector<bool> used(m, false);

  REP(i, n) {
    REP(j, n) {
      REP(k, m) {
        int a = ab[k].first.first;
        int b = ab[k].first.second;
        int c = ab[k].second;
        if (!used[k] && d[i][j] == d[i][a] + c + d[b][j]) {
          ans--;
          used[k] = true;
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define Mp make_pair
#define pb push_back

using ll = long long;
using db = double;
using pii = pair<int, int>;
using vi = vector<int>;

signed main() {
    int k; cin >> k;
    cout << 360 / __gcd(k, 360) << endl;
    fprintf(stderr, "time=%.4f\n", (db)clock()/CLOCKS_PER_SEC);
    return 0;
    /* 取模直接除，爆零两行泪
     * 不开ll见祖宗
     */
}

Measured memory_bytes: 3804
using System;
using System.Collections.Generic;

public class ABC164C {
	private static void Main(string[] args) {
		var n = ReadInt();
		var s = ReadStrLinesAsHashSet(n);

		var answer = s.Count;
		Console.WriteLine(answer);
	}

	private static int ReadInt() => int.Parse(Console.ReadLine().Trim());

	private static HashSet<string> ReadStrLinesAsHashSet(int numOfLines) {
		var hs = new HashSet<string>();
		for (int i = 0; i < numOfLines; i++) hs.Add(Console.ReadLine().Trim());
		return hs;
	}
}

Measured memory_bytes: 47168