akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
typedef long long ll;
using namespace std;

const ll MAXN = 200000;

ll N, ans=1, tmp=0;
vector<ll> A;

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) {
        ll a1;
        cin >> a1;
        A.push_back(a1);
    }
    sort(A.begin(), A.end());
    for(int i=0;i<N;i++) {
        if(A[i]==0) {
            cout << 0 << endl;
            return 0;
        }
        ll b;
        if((ll)pow(10,18)%A[i]==0) {
            b = (ll)pow(10,18)/A[i];
            if(ans>b) {
                cout << -1 << endl;
                return 0;
            }
            else ans*=A[i];
        }
        else {
            b = (ll)pow(10,18)/A[i];
            b++;
            if(ans>=b) {
                cout << -1 << endl;
                return 0;
            }
            else ans*=A[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4248
n,m=map(int,input().split())
lists=[]
for _ in range(m):
    a,b=map(int,input().split())
    lists.append([a,b])

answer=0

for some  in range(m):
    ans=0
    for i in range(1,n+1):
        cnt=0
        for _ in lists:
            if _[0]==i or _[1]==i:
                cnt+=1
                index=lists.index(_) 
        if cnt==1:
            ans+=1
            del lists[index]
        else:
            ans+=0
            continue
    answer+=ans
print(answer) 

Measured memory_bytes: 3188
// https://beta.atcoder.jp/contests/abc109

#define SUBMIT

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

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    stringstream stream(R"(50
)");
#endif
    int A, B;
    stream >> A >> B;
    if (A % 2 == 1 && B % 2 == 1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N, K;
    cin >> N >> K;
    set<int> A;
    int tmp;
    for (int i = 0; i < K; i++) {
        cin >> tmp;
        A.insert(tmp);
    }
    bool check;
    int t;
    for (int i = N; i < 1000005; i++) {
        tmp = i;
        check = true;
        while(tmp > 0){
            t = tmp % 10;
            if(A.count(t)){
                check = false;
            }
            tmp = tmp / 10;
        }
        if(check){
            printf("%d\n", i);
            return 0;
        }
    }

}

Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring>
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));

template<typename T>
struct SegmentTree{
private:
    int n;
    vector<T> node;
public:
    T merge(T x,T y){
        return x+y;
    }
    SegmentTree(vector<T> v){
        int sz=(int)v.size();
        n=1; while(n<sz)n*=2;
        node.resize(2*n-1,0);
        for(int i=0;i<sz;i++) node[i+n-1]=v[i];
        for(int i=n-2;i>=0;i--){
            node[i]=merge(node[2*i+1],node[2*i+2]);
        }
    }
    void update(int x,T val){
        x+=(n-1);
        node[x]+=val;
        while(x>0){
            x=(x-1)/2;
            node[x]=merge(node[2*x+1],node[2*x+2]);
        }
    }
    T query(int a,int b,int idx=0,int l=0,int r=-1){ /* get [a,b) */
        if(r<0) r=n;
        if(r<=a||b<=l) return 0;
        if(a<=l&&r<=b) return node[idx];
        T vl=query(a,b,2*idx+1,l,(l+r)/2);
        T vr=query(a,b,2*idx+2,(l+r)/2,r);
        return merge(vl,vr);
    };
};
signed main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    int n,q; cin >> n >> q;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    SegmentTree<ll> seg(a);
    rep(i,q){
        int x; cin >> x;
        if(x==0){
            int p,y; cin >> p >> y;
            seg.update(p,y);
        }else{
            int l,r; cin >> l >> r;
            cout << seg.query(l,r) << endl;
        }
    }
}




Measured memory_bytes: 19280
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    S = _S()
    print("Yes" if not(S=="AAA" or S=="BBB") else "No")

main()



Measured memory_bytes: 12220
//////////////////////////
//////////////////////////
////Please give me AC!////
////Please give me AC!////
//////////////////////////
//////////////////////////
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll N;
  cin>>N;
  vector<ll> A(N);
  vector<ll> B(N);
  for(ll i=0;i<N;i++){
    cin>>A.at(i);
    cin>>B.at(i);
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  if(N%2==0){
    ll a=A.at(N/2-1)+A.at(N/2);
    ll b=B.at(N/2-1)+B.at(N/2);
    cout<<b-a+1<<endl;
  }
  else{
    ll a=A.at(N/2);
    ll b=B.at(N/2);
    cout<<b-a+1<<endl;
  }
}

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

const int END = -1;
struct StNod
{
  int m_nParnt;
  int m_nLeft;
  int m_nRigt;

  StNod() :
     m_nParnt(END), m_nLeft(END), m_nRigt(END)
  { }
};

enum EnDir
{
  D_Left,
  D_Right,
};

void fnInput(vector<int>& rvnPodr, vector<int>& rvnIodrSeq)
{
  int nMaxSiz;

  cin >> nMaxSiz;
  rvnPodr.resize(nMaxSiz);
  rvnIodrSeq.resize(nMaxSiz + 1);

  for (int i = 0; i < nMaxSiz; i++)
    cin >> rvnPodr[i];

  int nNode;
  for (int i = 1; i < nMaxSiz + 1; i++)
  {
    cin >> nNode;
    rvnIodrSeq[nNode] = i;
  }
}

void fnStructTree(const vector<int>& cnrvnPodr, const vector<int>& cnrvnIodrSeq, vector<StNod>& rvoNod)
{
  for (int i = 1; i < cnrvnPodr.size(); i++)
  {
    int nParnt = END;
    int nx = cnrvnPodr[0];
    EnDir enDir;
    while (nx != END)
    {
      nParnt = nx;
      if (cnrvnIodrSeq[ cnrvnPodr[i] ] < cnrvnIodrSeq[nx])
      {
        nx = rvoNod[nx].m_nLeft;
        enDir = D_Left;
      }
      else
      {
        nx = rvoNod[nx].m_nRigt;
        enDir = D_Right;
      }
    }

    rvoNod[ cnrvnPodr[i] ].m_nParnt = nParnt;
    if (enDir == D_Left)
      rvoNod[nParnt].m_nLeft = cnrvnPodr[i];
    else
      rvoNod[nParnt].m_nRigt = cnrvnPodr[i];
  }
}

void fnPostOrder(const vector<StNod>& cnrvoNod, int nx)
{
  static int stnPrt = 0;
  if (nx == END)  return;

  fnPostOrder(cnrvoNod, cnrvoNod[nx].m_nLeft);
  fnPostOrder(cnrvoNod, cnrvoNod[nx].m_nRigt);

  if (stnPrt++) cout << " ";
  cout << nx;
}

void fnResult(const vector<StNod>& cnrvoNod)
{
  int nx = 1;
  while (cnrvoNod[nx].m_nParnt != END)
    nx = cnrvoNod[nx].m_nParnt;

  fnPostOrder(cnrvoNod, nx);
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnPodr, vnIodrSeq;
  fnInput(vnPodr, vnIodrSeq);

  StNod oNod;
  vector<StNod> voNod(vnIodrSeq.size(), oNod);
  fnStructTree(vnPodr, vnIodrSeq, voNod);
  
  fnResult(voNod);
  return 0;
}

Measured memory_bytes: 3192
#include<stdio.h>
#include<string.h>

int main(void){
  char *s1 = "ABC";
  char *s2 = "ARC";
  char str[8];
  scanf("%s",str);
  if(strcmp(str,s1)==0){
    printf("ARC\n");
  }else{
    printf("ABC\n");
  }
  
  return 0;
}

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

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

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
int getFormer(const vector<T> &vec, T x) {
    return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}

template <typename T>
int getLatter(const vector<T> &vec, T x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

void solve(long long b) {
    for (int k = 1e5; k > -1; k--) {
        if (2 * b % k != 0) continue;
        long long n = 2 * b / k - (k - 1);
        if (n < 1 || n % 2 != 0) {
            continue;
        }
        cout << n / 2 << " " << k << endl;
        break;
    }
}

int main() {
    long long b;
    while (cin >> b && b) {
        solve(b);
    }
}


Measured memory_bytes: 3096
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]


n, m = map(int, input().split())
uf = UnionFind(n+1)
for _ in range(m):
    a, b = map(int, input().split())
    uf.union(a,b)

ans = 0
for i in range(n):
    ans = max(ans, uf.size(i))

print(ans)



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

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

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

template<class T1, class T2>
void in(pair<T1, T2>& p) {
	in(p.first);
	in(p.second);
}

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

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N, K;
	cin >> N >> K;
	VLL A(N + 2, 0), AA(N + 2, 0);
	for (LL n = 1; n <= N; n++) {
		cin >> A[n];
		if (A[n] >= 0)AA[n] = AA[n - 1] + A[n];
		else AA[n] = AA[n - 1];
		A[n] += A[n - 1];
	}
	AA[N + 1] = AA[N];
	A[N + 1] = A[N];
	LL ans = 0;
	for (LL n = K; n <= N; n++) {
		ans = max(ans, AA[n - K] + (AA[N] - AA[n]));
		ans = max(ans, AA[n - K] + (A[n] - A[n - K]) + (AA[N] - AA[n]));
	}
	cout << ans << "\n";
}

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

const int MAXN = 1e5+5;
const int INF = 1e9+7;
#define ll long long
#define pb push_back
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

ll MOD(ll a){
    return ((a%INF)+INF)%INF;
}

ll inv(ll a){
    return poww(a,INF-2,INF);
}

vector<int> adjList[MAXN];
ll dp[MAXN][2];

void dfs(int start,int par){
    dp[start][0] = 1,dp[start][1] = 1;
    int cnts=0;
    for(auto u : adjList[start]){
        if(u != par){
            ++cnts;
            dfs(u,start);
            dp[start][0] = MOD(dp[start][0] * (dp[u][0] + dp[u][1]));
            dp[start][1] = MOD(dp[start][1] * dp[u][0]);
        }
    }
}

int main()
{
    fast_io;
    //cout << fixed << setprecision(15);

    int n;cin >> n;
    for(int i=0;i<n-1;++i){
        int c,d;cin >> c >> d;
        adjList[c].pb(d);
        adjList[d].pb(c);
    }

    dfs(1,-1);
    cout << MOD(dp[1][0] + dp[1][1]);
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll INF = 1LL << 62;
const int inf = 1 << 30;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string in; cin >> in;
    int cnt = 0;
    int res = 0;
    for(auto& e : in){
        if(e == 'p'){
            if(cnt == 0) cnt++, res--;
            else cnt--;
        }
        else {
            if(cnt > 0) cnt--, res++;
            else cnt++;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 512
n = gets.chomp.to_i
ans = Array.new(10002,0)
def cul(x,y,z)
    return x**2 + y**2 + z**2 + x*y + y*z + z*x
end
a,b,c = 1
for a in 1..99
    for b in 1..99
        for c in 1..99
            num = cul(a,b,c)
            if num < 10002
                ans[(num-1)] += 1
            end
        end
    end
end
i = 0
while true
    puts ans[i]
    i += 1
    if i == n
        break
    end
end

Measured memory_bytes: 14440
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int);
void init(void);
void printList(void);
void deleteNode(NodePointer);
void deleteFirst(void);
void deleteLast(void);
void delete(int);
void insert(int);


int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;

  scanf("%d", &n);

  init();

  for(i = 0; i < n; i++){
    scanf("%s%d", com, &key);

    if(com[0] == 'i'){
      insert(key);
      np++;
      size++;
    }
    
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
	if(com[6] == 'F') deleteFirst();
	else if(com[6] == 'L') deleteLast();
      }

      else{
	delete(key);
	nd++;
      }
      size--;
    }
  }


  printList();

  return 0;
}


NodePointer listSearch(int key){
  NodePointer t;

  t = nil->next;

  while(t != nil && t->key != key){
    t = t->next;
  }

  if(t == nil) return NULL;
  
  return t;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;

  while(1){
    if(cur == nil) break;
    if(isf == 0) printf(" ");

    printf("%u", cur->key);

    cur = cur->next;
    isf = 0;
  }

  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;

  if(t == nil) return;

  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;

  if(t == nil) return;

  deleteNode(t);
}

void delete(int key){
  NodePointer t;
  
  t = listSearch(key);

  if(t != NULL) deleteNode(t);
}

void insert(int key){
  NodePointer t;

  t = malloc(sizeof(struct node));
  t->key = key;
  
  t->next = nil->next;
  nil->next->prev = t;
  nil->next = t;
  t->prev = nil;
}



Measured memory_bytes: 33012
#include<iostream>
#include<cstdio>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<cmath>
#include<list>
#include<algorithm>
using namespace std;
#define inf 0x3f3f3f3f
typedef long long ll;
const int maxn = 100000 + 8;

int n,a[maxn];
int Partition(int a[],int p,int r)
{
    int last_element = a[r];
    int i = p-1;
    for(int j = p; j < r; ++j)
    {
        if(a[j] <= last_element)
        {
            i++;
            swap(a[i],a[j]);
        }
    }
    swap(a[i+1],a[r]);
    return i+1;
}
int main()
{
    scanf("%d",&n);
    fill(a,a+n,0);
    for(int i = 0; i < n; ++i)
    {
        scanf("%d",&a[i]);
    }
    int pos = Partition(a,0,n-1);
    for(int i = 0;i < n; ++i){
        if(i == pos) printf("");
        printf("%s%s%d%s", i==0?"":" ",i == pos?"[":"",a[i],i == pos?"]":"");
    }
    printf("\n");
    return 0;
}



















///*
//const int maxn = 1e5 + 8;
//
//int n,k,w[maxn];
//
//int check(ll P)
//{
//    for(int i = 0; i < n; ++i){
//
//    }
//}
//ll BinarySearch()
//{
//    ll left = 0;
//    ll right = maxn * maxn;
//    while(left <= right)
//    {
//        ll mid = (left + right) / 2;
//        int r = check(mid);
//        if(r >= n)  ;
//        else ;
//    }
//    return right;
//}
//int main()
//{
//    scanf("%d%d",&n,&k);
//    fill(w,w+n,0);
//    for(int i = 0; i < n; ++i) scanf("%d",&w[i]);
//    ll ans = BinarySearch();
//}
//
/*
#include <iostream>
#include <deque>
#include <string>
#include <vector>
#include <queue>
#include <cstdio>
#include <stack>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <iomanip>

using namespace std;

int tile = 0;
int Board[8][8];

void ChessBoard(int tr,int tc,int dr,int dc,int size){
    if(size == 1)return ;
    int t = tile++;
    int s = size / 2;
    if(dr < tr + s && dc < tc + s){
        ChessBoard(tr,tc,dr,dc,s);
    }
    else{
        Board[tr + s - 1][tc + s - 1] = t;
        ChessBoard(tr,tc,tr + s - 1, tc + s - 1,s);
    }

    if(dr < tr + s && dc >= tc + s){
        ChessBoard(tr,tc + s,dr,dc,s);
    }
    else{
        Board[tr + s - 1][tc + s] = t;
        ChessBoard(tr,tc+s,tr + s - 1, tc + s,s);
    }

    if(dr >= tr + s && dc < tc + s){
        ChessBoard(tr+s,tc,dr,dc,s);
    }
    else{
        Board[tr + s][tc + s - 1] = t;
        ChessBoard(tr+s,tc,tr + s, tc + s - 1,s);
    }

    if(dr >= tr + s && dc >= tc + s){
        ChessBoard(tr+s,tc+s,dr,dc,s);
    }
    else{
        Board[tr + s][tc + s] = t;
        ChessBoard(tr+s,tc+s,tr + s, tc + s,s);
    }

}

void Print(){
    for (int i = 0; i < 8; ++i) {
        for (int j = 0; j < 8; ++j) {
            cout << setw(3) << Board[i][j];
        }
        cout << endl;
    }
    cout << endl;
}

int main(){
    memset(Board,0,sizeof Board);
    ChessBoard(0,0,0,1,8);
    Print();
}
*/

Measured memory_bytes: 3492
from collections import deque
h,w=map(int,input().split())
S=[input() for _ in range(h )]
inf=float("inf")
ans=0
for i in range(h):
    for j in range(w):
        if S[i][j]=="#":
            continue
        else:
            D=[[inf for _ in range(w)]for _ in range(h)]
            D[i][j]=0
            que=deque([(i,j)])
            while que:
                si,sj=que.popleft()
                for ni,nj in [(si+1,sj),(si-1,sj),(si,sj+1),(si,sj-1)]:
                    if 0<=ni<h and 0<=nj<w and S[ni][nj]!="#":
                        if D[ni][nj]>D[si][sj]+1:
                            D[ni][nj]=D[si][sj]+1
                            ans=max(ans,D[si][sj]+1)
                            que.append((ni,nj))
print(ans)

Measured memory_bytes: 48348
#include <bits/stdc++.h>
typedef long long       ll;
#define PI                acos(-1)
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define fore(i,b,e)		  for(int i=(int)b;i<(int)e;++i)
#define forr(i,b,e)		  for(int i=(int)b;i<(int)e;++i)
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;

typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
const int INF = 1234567890;

ll toLL(string s) {
	ll res = 0;
	fore (i,0,s.length()) {
		res *= 10LL;
		res += s[i] - '0';
	}
	return res;
}

ll pot[45][20][10];

int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    int n;
    cin >> n;
    ll res = 0;
    fore(i, 0, n) {
    	string s;
    	cin >> s;
    	int decimal = 0;
    	fore(j, 0, s.length()) {
    		decimal++;
    		if (s[j] == '.') {
    			decimal = 0;
    		}
    	}
    	if (decimal == (int)s.length()) {
    		decimal = 0;
    	}
    	string s2 = "";
    	fore(j, 0, s.length()) {
    		if (s[j] != '.') {
    			s2 += s[j];
    		}
    	}
    	ll a = toLL(s2);
    	int p2 = 0, p5 = 0;
    	while (a%2 == 0) {
    		p2++;
    		a /= 2;
    	}
    	while (a%5 == 0) {
    		p5++;
    		a /= 5;
    	}
    	//cout << "2^" << p2 << " 5^" << p5 << " con " << decimal << " decimales" << endl << endl;
		pot[p2][p5][decimal]++;
		//if (min(p2, p5) >= decimal*2) res--;
    }
    ll ans = 0;
    res = 0;
    fore(a, 0, 45) {
    	fore(b, 0, 20) {
    		fore(c, 0, 10) {
    			fore(x, 0, 45) {
    				fore(y, 0, 20) {
    					fore(z, 0, 10) {
    						if (x == a && y == b && z == c) {
    							if (pot[a][b][c] > 1 && min(2*a, 2*b) >= 2*c) {
    								ans += pot[a][b][c] * (pot[a][b][c]-1) / 2;
    							}
    						}
    						else if ( min( a+x, b+y ) >= c + z ) {
    							res += pot[a][b][c] * pot[x][y][z];
    						}
    					}
    				}
    			}
    		}
    	}
    }
    cout << res/2 + ans << '\n';
    return 0; 
}
// PLUS ULTRA!

Measured memory_bytes: 3632
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <tuple>
#include <set>
#include <map>

#define FOR0(var, max) for (ul (var) = 0; (var) < (max); ++(var))
#define FORi(var, min, max) for (ul (var) = (min); (var) < (max); ++(var))
#define FORi_INV(var, min, max) for (ul (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

template <class T>
T gcd(T a, T b) {
  while (b) {
    T t = a % b;
    a = b;
    b = t;
  }
  return a;
}

/* (identity element, operation) */
template <class T>
using Monoid = pair<T, function<T(T, T)>>;

template <class T, ul K>
class SegmentTree {
  const Monoid<T> monoid;
  const ul N = (1 << K);
  T tree[2 * (1 << K) - 1];

  ui parent(ui i) {
    if (i == 0) {
      return 0;
    }
    return (i - 1) / 2;
  }

  ui child1(ui i) {
    return i * 2 + 1;
  }

  ui child2(ui i) {
    return i * 2 + 2;
  }

  bool is_leaf(ui i) {
    return (N - 1 <= i);
  }

  void propagate_from_leaf(ui i) {
    ui cur = N - 1 + i;
    while (cur != 0) {
      cur = parent(cur);
      auto x1 = tree[child1(cur)];
      auto x2 = tree[child2(cur)];
      tree[cur] = monoid.second(x1, x2);
    }
  }

  T query_impl(ui a, ui b, ui k, ui l, ui r) {
    if (r <= a || b <= l) {
      return monoid.first;
    } else if (a <= l && r <= b) {
      return tree[k];
    } else {
      auto ta = query_impl(a, b, child1(k), l, (l + r) / 2);
      auto tb = query_impl(a, b, child2(k), (l + r) / 2, r);
      return monoid.second(ta, tb);
    }
  }
public:
  /* Initialize Segment Tree with Monoid `_monoid` */
  SegmentTree(const Monoid<T>& _monoid) : monoid(_monoid) {
    FOR0(i, 2 * (1 << K) - 1) {
      tree[i] = monoid.first;
    }
  }

  void update(ui i, T x) {
    tree[N - 1 + i] = x;
    propagate_from_leaf(i);
  }

  // [a, b)
  T query(ui a, ui b) {
    return query_impl(a, b, 0, 0, N);
  }
};

const static ui NMAX = 100000;
const static ui MMAX = 100000;
const static ui AiMAX = 1000000000;

static ui N, M;
static ui Ai[NMAX];

static priority_queue<ui> que;

void solve(void) {
  FOR0(i, N) {
    que.push(Ai[i]);
  }

  ui remain_M = M;

  while (remain_M > 0) {
    ui t = que.top();
    que.pop();
    que.push(t / 2);
    remain_M--;
  }

  ul res = 0;
  while (!que.empty()) {
    res += que.top();
    que.pop();
  }
  cout << res << endl;
}

int main(void) {
  cin >> N >> M;
  FOR0(i, N) {
    cin >> Ai[i];
  }
  solve();
  return 0;
}

Measured memory_bytes: 1276
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int x, y;
  cin >> x >> y;
  if (y & 1) {
    cout << "No\n";
  } else {
    y /= 2;
    if (y < x) {
      cout << "No\n";
    } else {
      int b = y - x;
      cout << (x >= b ? "Yes\n" : "No\n");
    }
  }
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef set<int> si;
typedef string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N,D;
int X[11][11];
vi root(){
  vi res;
  rep1(i,200){
    res.pb(i*i);
  }
  return res;
}
int main(){
  cin>>N>>D;
  rep(i,N){
    rep(j,D){
      cin>>X[i][j];
    }
  }
  vi rt=root();
  int rs=rt.size();
  int cnt=0;
  rep(i,N){
    rep(j,N){
      if(i<=j) continue;
      int dis=0;
      rep(k,D){
	dis+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
      }
      bool f=false;
      rep(k,rs){
	if(dis==rt[k]){
	  f=true;
	  break;
	}
      }
      if(f) cnt++;
    }
  }
  prin(cnt);
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define rep(i,n) REP(i,n);
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep(i,n) RREP(i,n)
#define mp make_pair
#define fi first
#define sc second
ll n;
int main(){
	cin >> n;
	cout << n * (n + 1) / 2 << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
	int k, t;
	cin >> k >> t;
	int ma = 0;
	for (int i = 0; i < t; i++) {
		int x;
		cin >> x;
		ma = max(ma, x);
	}
	if (k % 2 == 0) {
		if (k / 2 >= ma) {
			cout << 0 << endl;
			return 0;
		}
		else {
			cout << (ma - k / 2) * 2 - 1 << endl;
			return 0;
		}
	}
	else {
		if ((k+1) / 2 >= ma) {
			cout << 0 << endl;
			return 0;
		}
		else {
			cout << (ma - (k+1) / 2) * 2 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int n, r;
  cin >> n >> r;
  if (n >= 10) {
    cout << r << endl;
  } else {
    cout << r + 100 * (10 - n) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#define ll long long

using namespace std;

int main()
{
    int n;
    ll ans(0);
    string s;
    cin >> n >> s;
    map <pair <string, string>, int> mp;
    for(int i = 0; i < (1 << n); i++)
    {
        string a = "", b = "";

        for(int j = 0; j < n; j++)
            if((i & (1 << j)) != 0)
                a += s[j];

        for(int j = n - 1; j >= 0; j--)
            if((i & (1 << j)) == 0)
                b += s[j];
        mp[{a, b}]++;
    }

    for(int i = 0; i < (1 << n); i++)
    {
        string a = "", b = "";

        for(int j = 0; j < n; j++)
            if((i & (1 << j)) != 0)
                a += s[n + j];

        for(int j = n - 1; j >= 0; j--)
            if((i & (1 << j)) == 0)
                b += s[n + j];
        ans += mp[{b, a}];
    }
    cout << ans;
}


Measured memory_bytes: 91904
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,ans=1;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        if(ans>k) ans+=k;
        else ans*=2;
    }
    cout<<ans<<endl;
    return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll H[100005];

int main()
{
    ll N;
    cin >> N;
    REP(i, N)
    {
        cin >> H[i];
    }

    bool f = true;
    REP(i, N - 1)
    {
        if (i == 0 || H[i - 1] < H[i])
            H[i]--;
        if (H[i] > H[i + 1])
            f = false;
    }

    if (f)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  long long K;
  cin >> K;
  vector<long long> A, F;
  int p;
  for (int i = 0; i < N; i++){
    cin >> p;
    A.push_back(p);
  }
  for (int i = 0; i < N; i++){
    cin >> p;
    F.push_back(p);
  }
  //Sort A and F
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  sort(F.begin(),F.end());
  //A is in descending order
  //F is in ascending order
  //Binary search for minimum time
  long long pos,npos;
  npos = -1;
  pos = A[0]*F[N-1]+1;
  while (pos - npos > 1){
    long long mid = (npos + pos)/2;
    long long c = 0;
    for (int i = 0; i < N; i++){
      if (A[i]*F[i]>mid){
        c += A[i]-mid/F[i];
      }
    }
    if (c > K){
      //Impossible
      npos = mid;
    } else {
      //Possible
      pos = mid;
    }
  }
  cout << pos;
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int[] w = new int[n];
        int s2 = 0;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            s2 += w[i];
        }
        int s1 = 0;
        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            s1 += w[i];
            s2 -= w[i];
            ans = Math.min(ans, Math.abs(s1 - s2));
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

int a[10];
string dp[10005];

void cmp(string& a, string b){
    if(a == "+"){
        a = b;
    }else if(a.size() < b.size()){
        a = b;
    }else if(a.size() == b.size() && a < b){
        a = b;
    }
}

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

    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        cin >> a[i];
    }
    int b[11] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

    dp[0] = "";
    dp[1] = "+";
    for(int i = 2; i <= n; ++i){
        dp[i] = "+";
        for(int j = 0; j < m; ++j){
            if(i >= b[a[j]]){
                if(dp[i - b[a[j]]] == "+")continue;
                cmp(dp[i], dp[i - b[a[j]]] + (char)('0' + a[j]));
            }
        }
        //cout << i << " " << dp[i] << "\n";
    }

    cout << dp[n] << "\n";
    return 0;
}


Measured memory_bytes: 41600
#include<iostream>
#include<algorithm>
#define maxn 200005
using namespace std;
typedef long long ll;
ll n,a[maxn],s[maxn];
ll ans,res;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	
	sort(a+1,a+1+n);
	ans = 0;
	
	s[1] = a[1];
	for(int i=2;i<=n;i++){
		s[i] = s[i-1] + a[i];
		s[i] %= 1000000007;
	}
	for(int i=2;i<=n;i++){
		ans = (ans+a[i] * s[i-1])%1000000007; 
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6772
#include<stdio.h>
#define N 1000

int main(){
  int n,u,k,v,m[N][N],i,j;
  scanf("%d",&n);
  for(i=0 ; i<N ; i++){
    for(j=0 ; j<N ; j++){
      m[i][j]=0;
    }
  }  
  for(i=0 ; i<n ; i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=0 ; j<k ; j++){
      scanf("%d",&v);
      m[u][v]=1;
    }
  }
  for(i=1 ; i<n+1 ; i++){
    for(j=1 ; j<n+1 ; j++){
      if(j<n) printf("%d ",m[i][j]);
      else printf("%d",m[i][j]);
    }
    printf("\n");
  }
  return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; ++i) cin >> d.at(i);
  
  sort(d.begin(), d.end());
  int K = d.at(N/2) - d.at(N/2-1);
  
  cout << K << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n, x; cin >> n >> x;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a.at(i);
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++) {
		x -= a.at(i);
		if (x < 0) {
			cout << i << endl;
			return 0;
		}
		else if (x == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	cout << n - 1 << endl;
}

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

vector<int> prime(int N) {
  vector<bool> a(N, true);
  for(int i=1; i<sqrt(N); i++) {
    if(a[i]) for(int k=2; (i+1)*k-1<N; k++) a[(i+1)*k-1] = false;
  }
  vector<int> p;
  rep(i, N) if(a[i]) p.push_back(i+1);
  p.erase(p.begin());
  return p;
}

signed main() {
  int H, N; cin >> H >> N;
  vector<int> A(N), B(N);
  rep(i, N) cin >> A[i] >> B[i];
  
  vector<int> dp(H+1, 0);
  
  rep(i, H+1) {
    if(i == 0) continue;
    int a = dp[i-1] + 100000;
    rep(j, N) {
      if(i < A[j]) a = min(a, B[j]);
      else a = min(a, dp[i-A[j]]+B[j]);
    }
    dp[i] = a;
  }
  
  cout << dp[H] << endl;

}

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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

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

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  string b[h];
  rep(i, h) cin >> b[i];
  rep(i, h) rep(j, w) {
    if(b[i][j] == '.')
      continue;
    bool flag = false;
    rep(dir, 4) {
      int ni = i + dy[dir];
      int nj = j + dx[dir];
      if(ni >= 0 && nj >= 0 && ni < h && nj < w && b[ni][nj] == '#') {
        flag = true;
      }
    }
    if(flag == false) {
      cout << "No"
           << "\n";
      return 0;
    }
  }
  cout << "Yes"
       << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<vector<int>> graph;
vector<int> down, up;
int recur1(int node, int prev)
{
    long long a = 1;
    for (int next : graph[node]) {
        if (next == prev) continue;
        a = a * recur1(next, node) % M;
    }
    return down[node] = (a + 1) % M;
}
void recur2(int node, int prev)
{
    if (prev == -1) up[node] = 1;
    vector<int> C, A, L, R;
    for (int next : graph[node]) {
        if (next == prev) continue;
        C.push_back(next);
        A.push_back(down[next]);
    }
    int n = A.size();
    L.resize(n+2), R.resize(n+2);
    L[0] = L[n+1] = R[0] = R[n+1] = 1;
    for (int i = 0; i < n; i++) {
        L[i+1] = (long long)A[i] * L[i] % M;
    }
    for (int i = n-1; i >= 0; i--) {
        R[i+1] = (long long)A[i] * R[i+2] % M;
    }
    for (int i = 0; i < n; i++) {
        up[C[i]] = ((long long)up[node] * L[i+1-1] % M * R[i+1+1] + 1) % M;
    }
    for (int next : C) {
        recur2(next, node);
    }
}
int main()
{
    cin >> N >> M;
    graph.resize(N);
    for (int i = 0; i < N-1; i++) {
        int x, y; cin >> x >> y; x--, y--;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    down.resize(N), up.resize(N);
    recur1(0, -1);
    recur2(0, -1);
    for (int i = 0; i < N; i++) {
        cout << (down[i] + M - 1LL) * up[i] % M << endl;
    }
    return 0;
}


Measured memory_bytes: 30080
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

int main() {
  ll K, A, B;
  cin >> K >> A >> B;

  ll ans = 0;
  FOR(i, A, B + 1) {
    if (i % K == 0)
      ans = 1;
  }
  if (ans)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;

  return 0;
}

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

int main() {
  int H, W;
  string s;
  cin >> H >> W;
  for(int i = 0; i < W + 2; i++){
    cout << "#";
  }
  cout << endl;
  for(int i = 0; i < H; i++){
   cin >> s;
    cout << "#" << s << "#" << endl;
  }
  for(int i = 0; i < W + 2; i++){
  cout << "#";
  }
}


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

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

int main(){
  int n; cin >> n;
  for (int i = 0; i < n; i++) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a < b) {
      cout << "No" << endl;
      continue;
    }
    if (d < b) {
      cout << "No" << endl;
      continue;
    } else if (d == b) {
      if (a % b > c) cout << "No" << endl;
      else cout << "Yes" << endl;
      continue;
    } else {
      long long u = d - b;
      if (b-1 <= c) cout << "Yes" << endl;
      else {
        long long g = gcd(b, u);
        long long v = a % b;
        long long x = ((c+1-v)+(g-1)) / g;
        long long y = ((b-v)+(g-1)) / g;
        //cout << g << "\t" << x << y << "\t" << y - x << endl;
        if (abs(y - x) > 0) cout << "No" << endl;
        else cout << "Yes" << endl;
      }
      continue;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <map>

using namespace std;

int main()
{
    // 整数の入力
    long long N,ai,i,bar1,bar2;
    map<long long,long long> numCount;
    bar1 = 0;
    bar2 = 0;
    cin >> N;
    for (i= 0;i<N;i++){
        cin >> ai;
        if (numCount.count(ai) > 0){
            numCount[ai] += 1;
        }else{
            numCount[ai] = 1;
        }
        if (numCount.count(ai+1) > 0){
            numCount[ai+1] += 1;
        }else{
            numCount[ai+1] = 1;
        }
        if (numCount.count(ai-1) > 0){
            numCount[ai-1] += 1;
        }else{
            numCount[ai-1] = 1;
        }
    }
    int max = 0;
    for(auto itr = numCount.begin(); itr != numCount.end(); ++itr) {
        if (itr->second > max){
            max = itr->second;
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 6144
# -*- coding utf-8 -*-
##################
# pass test case but it still have 3/25 wa
##################

MAX_DIGIT = 40

n, k = map(int, input().split())
an = list(map(int, input().split()))

digit = [1 << i for i in range(MAX_DIGIT)]

sum_d = [[0] * 2 for _ in range(MAX_DIGIT)]
for ai in an:
    for i in range(MAX_DIGIT):
        d = (ai >> i) & 1
        sum_d[i][d] += digit[i]
# print(sum_d)

sum_max = [0] * MAX_DIGIT
sum_max[0] = max(sum_d[0])
for i in range(MAX_DIGIT - 1):
    sum_max[i + 1] = sum_max[i] + max(sum_d[i + 1])
# print(sum_max)

dp = [-1] * MAX_DIGIT
# dp[0] = sum_d[0][1]
dp[0] = sum_d[0][0 if (k & 1) == 1 else 1]
for i in range(MAX_DIGIT - 1):
    d = k >> (i + 1) & 1
    if d == 0:    # i+1 bit目が1のsum + 今までの最大
        dp[i + 1] = sum_d[i + 1][1] + dp[i]
    if d == 1:    # (i+1 bit目が0のsum + 今までの最大) or (i+1 bit目が1のsum + i bitまで任意)
        dp[i + 1] = max(sum_d[i + 1][0] + dp[i], sum_d[i + 1][1] + sum_max[i])
    # print(i, d, dp[i], dp[i + 1])
# print(dp)
print(dp[-1])


Measured memory_bytes: 14620