akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

ll n, m;
ll ans;

ll solve(){
    cin >> n >> m;
    if(n > m) swap(n, m);

    if(n == 1) return m == 1 ? 1 : m - 2;
    else if(n == 2) return 0;
    else return max(0ll, n - 2) * max(0ll, m - 2);
}

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

    cout << solve() << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <algorithm>
using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)n;(i)++)
#define foreach(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)

int n, s, dp[12][1<<10+1][400];

int rec(int k, int S, int sum) {
  //printf("%d %d %d\n", k, S, sum);

  int i, res = 0;
  if (sum >= 331 || sum < 0) return 0;
  if (dp[k][S][sum] >= 0) return dp[k][S][sum];
  if (k == n+1) {
    if (sum == 0) {
      res = 1;
    }
  } else {
    rep(i,10) if (!((1<<i)&S)) {
      res += rec(k+1, S|(1<<i), sum - i*k);
    }
  }
  dp[k][S][sum] = res;
  return res;
}

int main() {
  int i;
  while (EOF != scanf("%d%d",&n,&s)) {
    memset(dp, -1, sizeof dp);
    printf("%d\n", rec(1, 0, s));
  }
  return 0;
}

Measured memory_bytes: 0
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	[ a, b, c, k ] <- readInts
	let
		da = min a k
		k' = k - da
		db = min b k'
		k'' = k' - db
		dc = min c k''
	print $ da - dc
	

Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main(){
ll n;
cin>>n;
set<char>set;
char a;
for(int i=0;i<n;i++){
    cin>>a;
    set.insert(a);
}
if(set.size()==3){
    cout<<"Three"<<endl;
}else{
    cout<<"Four"<<endl;
}
}












Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
using namespace std;
using ll = long long;
#define rep(i,n) for(decltype(n) i=0; i<n; ++i)
inline constexpr ll Inf = (1ULL << 62) -1;

template <class T>
void updatemax(T& a, T b) { if (b > a) a = b; }

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    sort(A.rbegin(), A.rend());
    ll ans=A[0];
    for (ll i=0; i<N-2; ++i) {
        ans += A[i/2+1];
    }

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


Measured memory_bytes: 4368
x = gets.to_i

if x <= 599 then
	puts 8
elsif x <= 799 then
	puts 7
elsif x <= 999 then
	puts 6
elsif x <= 1199 then
	puts 5
elsif x <= 1399 then
	puts 4
elsif x <= 1599 then
	puts 3
elsif x <= 1799 then
	puts 2
elsif x <= 1999 then
	puts 1
end



Measured memory_bytes: 14428
#define L long long int
m[31][50];main(n,p,d,x){L a[50],b;for(;scanf("%d",&n),n;){memset(m,0,6200);for(p=0;p<n;a[p]=(L)1<<p,p++)for(scanf("%d",&x);x;x--)scanf("%d",&d),m[d][p]=1;for(d=1;d<31;d++){for(b=p=0;p<n;p++)if(m[d][p])b|=a[p];for(p=0;p<n;p++)if(m[d][p]&&(a[p]=b)==((L)1<<n)-1){printf("%d\n",d);goto s;}}puts("-1");s:;}return 0;}

Measured memory_bytes: 420
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int cnt[] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
  int N, M;
  cin >> N >> M;
  vi maxDigit(N+1, -1);
  unordered_set<int> s;
  rep(i, M) {
    int a; cin >> a; s.insert(a);
  }
  maxDigit[0] = 0;
  for (int i = 1; i <= N; i++) {
    for (int d = 1; d <= 9; d++) {
      if (s.find(d) == s.end()) continue;
      int c = cnt[d-1];
      if (i-c >= 0 && maxDigit[i-c] >= 0) {
        maxDigit[i] = max(maxDigit[i], maxDigit[i-c]+1);
      }
    }
  }
  int cur = N;
  string ans = "";
  while (cur > 0) {
    for (int d = 9; d >= 1; d--) {
      if (s.find(d) == s.end()) continue;
      int c = cnt[d-1];
      if (cur-c >= 0 && maxDigit[cur-c] == maxDigit[cur]-1) {
        // found
        ans = ans + to_string(d);
        cur = cur - c;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
#define ll long long 
#define pb push_back
int main(){	
	fast;
		ll n; cin>>n;
		vector<ll>v;
		ll c,cnt=0;
		for(ll i=0;i<n;i++){
			cin>>c;
			if(c%2==0) v.pb(c);
			}
		for(ll i=0;i<v.size();i++){
			if(v[i]%3==0 || v[i]%5==0) cnt++;
			}
		if(cnt==v.size()) cout<<"APPROVED";
		else cout<<"DENIED";
		}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    set<string> s;
    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;
        s.insert(S);
    }
    cout << s.size() << "\n";
    return 0;
}

Measured memory_bytes: 19224
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

X, Y = map(int, input().split())

s = [3*10**5, 2*10**5, 1*10**5]

if X == 1 and Y == 1:
    print(s[X-1] + s[Y-1] + 4*10**5)
elif X <= 3 and Y <= 3:
    print(s[X-1] + s[Y-1])
elif X <= 3 or Y <= 3:
    if X <= 3:
        print(s[X-1])
    else:
        print(s[Y-1])
else:
    print(0)

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

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    from functools import reduce
    xyz_list = [[0]*3]
    for a in A:
        xyz_list.append(xyz_list[-1][:])
        for i, v in enumerate(xyz_list[-1]):
            if v == a:
                xyz_list[-1][i] += 1
                break
    T = [xyz.count(a) for xyz, a in zip(xyz_list, A)]
    return reduce(lambda a,b: a*b%MOD, T)

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, A))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 35644
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

int main(void) {
    int a, b;
    std::cin >> a >> b;
    std::string s;
    std::cin >> s;
    for (int i = 0; i < a + b + 1; i++) {
        if ((i == a && s[i] != '-') || (i != a && !(s[i] >= '0' && s[i] <= '9'))) {
            std::puts("No");
            return 0;
        }
    }
    std::puts("Yes");
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            out.println(b + Math.min(c, a + b + 1));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

    }
}



Measured memory_bytes: 22868
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

int main()
{
	int64_t L, R;
	cin >> L >> R;

	int64_t res = 2020;
	for (int64_t l = L; l < R && l < L + 2020; l++) {
		for (int64_t r = l + 1; r <= R && r < L + 2020; r++) {
			res = min(res, (l * r) % 2019);
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

A,B,X=I()
print("YES" if A<=X<=A+B else "NO")


Measured memory_bytes: 10296
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;
 
 int main()
 { 
   int n;
   while(cin>>n)
   {
     int kk=n/3;
     cout<<kk<<endl;             
   }
   return 0;
 }
 

        



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i] >> y[i] ;

int main(){
  ll N,M ;
  cin >> N >> M;
  ll A[100000] ;
  ll B[100000] ;
  cinf(N,A,B) ;
  vector<pair<long long int,long long int>> pairs(N) ;
  rep(i,N)
    pairs[i] = make_pair(A[i],B[i]) ;
  sort(pairs.begin(),pairs.end()) ;
  ll sum=0;
  ll res =0 ;
  for(int i=0;i<N;i++){
    if(sum <M){
      sum += pairs[i].second ;
      res += (pairs[i].first)*(pairs[i].second) ;
    }
    if(sum == M){
      cout << res << endl;
      return 0;
    }
    if(sum > M){
      ll ans=res - (sum-M)*pairs[i].first ;
      cout << ans << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3328
#include<iostream>
#include<numeric>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int t[100];
	for (int i = 0; i < n; i++)
	{
		cin >> t[i];
	}
	int m;
	cin >> m;
	int p[100];
	int x[100];
	for (int i = 0; i < m;i++)
	{
		cin >> p[i] >> x[i];
	}
	int result[100];
	for (int j = 0; j < m;j++)
	{
		int temp = t[p[j]-1];
		t[p[j]-1] = x[j];
		int sum = 0;
		result[j] = accumulate(t, t + n, sum);
		t[p[j]-1] = temp;

	}
	for (int i = 0; i < m; i++)
	{
		cout << result[i];
		cout << "\n";
	}
	
	

	return 0;

}


Measured memory_bytes: 256
import sys


if __name__ == '__main__':
    n, y = map(int, input().split())
    for i in range(0, n+1):
        for j in range(0, n+1-i):
            k = n - (i + j)
            sum_price = 10000*i + 5000*j + 1000*k
            if k >= 0 and n == i + j + k and sum_price == y:
                print(i, j, k)
                sys.exit()
    print(-1, -1, -1)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<climits>
#include<set>
#include<map>
#include<stack>
#define ll long long
using namespace std;

int main() {
	ll a, b, c, d;
	string s;
	cin >>s;
	a = stoll(s.substr(0, 1));
	b = stoll(s.substr(1, 1));
	c = stoll(s.substr(2, 1));
	d = stoll(s.substr(3, 1));

	if (a + b + c+d == 7) {
		cout << a << "+" << b << "+" << c << "+" << d << "=" << 7 << endl;
	}
	else if (a + b + c - d == 7) {
		cout << a << "+" << b << "+" << c << "-" << d << "=" << 7 << endl;
	}
	else if (a + b - c + d == 7) {
		cout << a << "+" << b << "-" << c << "+" << d << "=" << 7 << endl;
	}
	else if (a + b - c - d == 7) {
		cout << a << "+" << b << "-" << c << "-" << d << "=" << 7 << endl;
	}
	else if (a - b + c + d == 7) {
		cout << a << "-" << b << "+" << c << "+" << d << "=" << 7 << endl;
	}
	else if (a - b - c + d == 7) {
		cout << a << "-" << b << "-" << c << "+" << d << "=" << 7 << endl;
	}
	else if (a - b + c - d == 7) {
		cout << a << "-" << b << "+" << c << "-" << d << "=" << 7 << endl;
	}
	else if (a - b - c - d == 7) {
		cout << a << "-" << b << "-" << c << "-" << d << "=" << 7 << endl;
	}
	
	
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int H, W, N;

void next(int &h, int &w){
    if(h % 2 == 0){
        if(w + 1 == W){
            h += 1;
            w = w;
        }
        else{
            w = w + 1;
        }
    }
    else if(h % 2 == 1){
        if(w == 0){
            h += 1;
            w = w;
        }
        else{
            w = w - 1;
        }
    }
}

int main(){

    cin >> H >> W >> N;

    vector<int> v(N);
    for(int i = 0; i < N; i++){
        cin >> v[i];
    }
    
    int h = 0;
    int w = 0;
    int ans[H][W];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < v[i]; j++){
            ans[h][w] = i + 1;
            next(h, w);
        }
    }

    for(int h = 0; h < H; h++){
        cout << ans[h][0];
        for(int w = 1; w < W; w++){
            cout << " " << ans[h][w];
        }
            cout << endl;
    }
}


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

int main(){
  int N;
  cin >> N;
  for(int i=0;4*i<=N;i++){
    for(int j=0;4*i+7*j<=N;j++){
      if(4*i+7*j == N){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

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


int main(){
   int a,b,c,d,e,k;
   int ma=0;
   vector<int>x(5);
   rep(i,5) cin >> x[i];
   cin >>k;
   for(int i=0;i<5;i++){
       for(int j=i+1;j<5;j++){
           int sub=x[j]-x[i];
           ma=max(ma,sub);
       }
   }
   if(ma<=k) cout <<"Yay!" << endl;
   else cout << ":(" << endl;

    return 0;
}


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

using namespace std;

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

int main(){
	while(1){
		int n, m;
		cin >> n >> m;
		if(!(n|m))break;

		vector<int> s1(n);
		int s1sum = 0;
		rep(i, n){
			cin >> s1[i];
			s1sum += s1[i];
		}

		vector<int> s2(m);
		int s2sum = 0;
		rep(i, m){
			cin >> s2[i];
			s2sum += s2[i];
		}

		map<int, pair<int, int> > sw;
		rep(i, n){
			rep(j, m){
				if(s1sum-s1[i]+s2[j] == s2sum-s2[j]+s1[i]){
					sw[s1[i]+s2[j]] = MP(s1[i], s2[j]);
				}
			}
		}

		if(sw.size() == 0){
			cout << -1 << endl;
		}else{
			cout << sw.begin()->second.first << ' ' << sw.begin()->second.second << endl;
		}
	}
}

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

int main(){
  int n;
  int i,j,k,l;
  char s[56][56];
  int cnt[56][28];
  int out[28];
  scanf("%d", &n);

  for(i = 0;i < n;i++) scanf("%s", s[i]);

  for(i = 0;i <= 26;i++){
    out[i] = 0;
    for(j = 0;j <= 55;j++){
      cnt[j][i] = 0;
    }
  }

  for(i = 0;i < n;i++){
    k = strlen(s[i]);
    for(j = 0;j < k;j++){
      cnt[i][s[i][j] - 'a']++;
    }
  }

  int mn;
  for(i = 0;i < 26;i++){
    mn = 100100100;
    for(j = 0;j < n;j++){
      if(mn > cnt[j][i]) mn = cnt[j][i];
    }

    out[i] = mn;
  }

  for(i = 0;i < 26;i++){
    if(out[i] != 0){
      for(j = 0;j < out[i];j++){
        printf("%c", 'a' + i);
      }
    }
  }

  printf("\n");

  return 0;
}


Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())
    cnt = [0] * (M+1)
    for _ in range(N):
        info = list(map(int, input().split()))
        for a in info[1:]:
            cnt[a] += 1
    ans = 0
    for m in range(M+1):
        if cnt[m] == N:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include <vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	ll n, x;
	cin >> n >> x;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	vsort(a);
	ll c = 0;
	rep(i, n) {
		x -= a[i];
		if (x >= 0) {
			c++;
		}
		else break;
	}
	if (x > 0) c--;
	cout << c << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	char str[9000];
	int i;

	fgets(str, 9000, stdin);
	for (i = 0; str[i] != '\0'; i++) {
		if ('a' <= str[i] && str[i] <= 'z') {
			str[i] -= 'a' - 'A';
		}
	}
	printf("%s", str);

	return (0);
}

Measured memory_bytes: 524
//
// Created by 27420 on 2020/8/22.
//

#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;

int checkIfCanBedivideBy9(string str)
{
    int n = str.length();

    int oddDigSum = 0, evenDigSum = 0;
    for (int i=0; i<n; i++)
    {
        if (i%2 == 0)
            oddDigSum += (str[i]-'0');
        else
            evenDigSum += (str[i]-'0');
    }
    return ((oddDigSum +evenDigSum) % 9 == 0);
}
int main(){
    string str;
    getline(cin,str);
    if(checkIfCanBedivideBy9(str)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}

Measured memory_bytes: 3860
n = int(input())
p = [int(input()) for _ in range(n)]

#dp[i]はiで終わる連続整数長
dp = [0 for _ in range(n+1)]
for i in range(n):
    dp[p[i]] = dp[p[i] - 1] + 1

print(n - max(dp))

Measured memory_bytes: 18856
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def foo(l,m):
    if m==0:
        return 1
    sm = foo(l,m-1)
    if l<9:
        sm += foo(l+1,m-1)
    if l>0:
        sm += foo(l-1,m-1)
    return sm

d = [[0]*10 for i in range(11)]
for m in range(11):
    for l in range(10):
        d[m][l] = foo(l,m)

#for i in range(11):
#    ddprint(d[i])

k = inn()
sm = 0
ans = []
for m in range(11):
    for l in range(1,10):
        sm += d[m][l]
        if sm>=k:
            break
    if sm>=k:
        break
# leftmost l, m digits
ans.append(l)
sm -= d[m][l]
for n in range(m-1,-1,-1):
    for ll in range(max(0,l-1), min(9,l+1)+1):
        sm += d[n][ll]
        if sm>=k:
            break
    sm -= d[n][ll]
    ans.append(ll)
    l = ll

print(''.join([str(x) for x in ans]))


Measured memory_bytes: 41980
import sys
sys.setrecursionlimit(100000)

def dfs(h, w):
    global fields
    if not (0 <= h < len(fields) and 0 <= w < len(fields[0])):
        return
    if fields[h][w] == "0":
        return
    fields[h][w] = "0"
    for dh in [-1, 0, 1]:
        for dw in [-1, 0, 1]:
            if dh == 0 and dw == 0:
                continue
            dfs(h + dh, w + dw)

while True:
    W, H = tuple(map(int, input().split(" ")))
    if (W, H) == (0, 0):
        break
    fields = []
    for _ in range(H):
        fields.append(input().split(" "))

    ans = 0
    for h in range(H):
        for w in range(W):
            if fields[h][w] == "1":
                dfs(h, w)
                ans += 1
    print(ans)



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

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	int ans = t.length();
	for (int i = 0; i < s.length() - t.length() + 1; i++) {
		int count = 0;
		for (int j = i; j < i + t.length(); j++) {
			if (s[j] != t[j - i]) {
				count++;
			}
		}
		ans = min(ans, count);
	}
	
	printf("%d\n", ans);
	
	return 0;
}

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

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

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

    vector<bool> abc(3, false);

    for(int i = 0; i < 3; i++){
        if(S[i] == 'a') abc[0] = true;
        if(S[i] == 'b') abc[1] = true;
        if(S[i] == 'c') abc[2] = true;
    }

    if(abc[0] && abc[1] && abc[2]) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 256
' Imports System.Collections.Generic
Imports System.IO
' Imports System.Linq
' Imports System.Text
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Sub Main()
        Dim sc As New FastScanner(Console.OpenStandardInput())
        Dim N As Integer = sc.nextInt()
        Dim K As Integer = sc.nextInt()
        Dim h() As Integer = sc.intArray(N)
        Console.WriteLine(h.Sum(Function(cur) If(K <= cur, 1, 0)))
        Return
    End Sub
End Class

' FastScanner start
Public Class FastScanner
    Public readonly str As Stream
    Private readonly buf(1024 - 1) As Byte
    Private len, ptr As Integer
    Public isEof As Boolean = False
    Public Sub New(stream As Stream)
        str = stream
        Exit Sub
    End Sub
    Private Function enumerateInt(n As Integer) As Integer()
        Dim a(n - 1) As Integer
        For i As Integer = 0 To n - 1
            a(i) = nextInt()
        Next
        Return a
    End Function
    Private Function enumerateLong(n As Integer) As Long()
        Dim a(n - 1) As Long
        For i As Integer = 0 To n - 1
            a(i) = nextLong()
        Next
        Return a
    End Function
    Private Function enumerateChar(n As Integer) As Char()
        Dim a(n - 1) As Char
        For i As Integer = 0 To n - 1
            a(i) = nextChar()
        Next
        Return a
    End Function
    Public Function nextChar() As Char
        Dim b As Byte = 0
        Do
            b = read()
        Loop While (b < 33 OrElse 126 < b) AndAlso Not isEof
        Return Convert.ToChar(b)
    End Function
    Public Function nextInt() As Integer
        Return if(isEof, Integer.MinValue, Ctype(nextLong(), Integer))
    End Function
    Public Function nextLong() As Long
        If isEof
            Return Long.MinValue
        End If
        Dim ret As Long = 0
        Dim b As Byte = 0
        Dim ng As Boolean = False
        Do
            b = read()
        Loop While b <> Asc("-"c) AndAlso (b < Asc("0"c) OrElse Asc("9"c) < b)
        If b = Asc("-"c)
            ng = true
            b = read()
        End If
        While True
            If b < Asc("0"c) OrElse Asc("9"c) < b
                Return If(ng, -ret, ret)
            Else
                ret = ret * 10 + b - Asc("0"c)
            End If
            b = read()
        End While
        Return ret
    End Function
    Public Function intArray(n As Integer) As Integer()
        Return enumerateInt(n)
    End Function
    Public Function longArray(n As Integer) As Long()
        Return enumerateLong(n)
    End Function
    Public Function charArray(n As Integer) As Char()
        Return enumerateChar(n)
    End Function
    Private Function read() As Byte
        If isEof
            Return 0
        End If
        If ptr >= len
            ptr = 0
            len = str.Read(buf, 0, 1024)
            If (len <= 0)
                isEof = True
                Return 0
            End If
        End If
        Dim bk As Integer = ptr
        ptr += 1
        Return buf(bk)
    End function
End Class
' FastScanner end

Measured memory_bytes: 26252
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println(solve(x, a, b));

        sc.close();
    }

    static String solve(int x, int a, int b) {
        return (Math.abs(x - a) < Math.abs(x - b)) ? "A" : "B";
    }
}

Measured memory_bytes: 21844
while True:
    H,W=map(int,input().split())
    if H==W==0:
        break
    i=1
    j=1
    for i in range(H):
        for j in range(W):
            if i%2>0:
                if j%2>0:
                    print('#',end='')
                else:
                    print('.',end='')
            else:
                if j%2>0:
                    print('.',end='')
                else:
                    print('#',end='')
        print()
    print()


Measured memory_bytes: 7000
import copy
from sys import stdin
n=int(input())
A=[int(stdin.readline().rstrip()) for _ in range(n)]
z=max(A)
B=sorted(A)
o=B[n-2]
for j in range(0,n):
    if A[j]<z:
       print(z)
    else:
        if B[n-2]==B[n-1]:
           print(z)
        else:
           print(o)

Measured memory_bytes: 14560
#include<stdio.h>
int main(){
  int a, b, i, j;
  char s[100][101];
  scanf("%d %d", &a, &b);
  for(i = 0; i < a; ++i){
    scanf("%s", s[i]);
  }
  for(i = 0; i < b + 2; ++i) printf("#");
  puts("");
  for(i = 0; i < a; ++i) printf("#%s#\n", s[i]);
  for(i = 0; i < b + 2; ++i) printf("#");
  puts("");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
using namespace std;

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

double dp[3][3][16];
int n;
char s,t,b;
int S,T,B;

double solve(int y,int x,int n){
  if(dp[y][x][n]!=-1.0)return dp[y][x][n];
  if(n==0)return dp[y][x][n]=(y*3+x==T?1.0:0.0);

  double sum=0.0;
  for(int i=0;i<4;i++){
    int ny=y+dy[i];
    int nx=x+dx[i];
    if(ny<0||nx<0)sum+=solve(y,x,n-1);
    else if(ny>=3||nx>=3)sum+=solve(y,x,n-1);
    else if(ny*3+nx==B)sum+=solve(y,x,n-1);
    else sum+=solve(ny,nx,n-1);
  }
  return dp[y][x][n]=sum/4.0;
}

void init(){
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      for(int k=0;k<16;k++)
	dp[i][j][k]=-1.0;
}

int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    cin>>s>>t>>b;
    init();
    S=s-'A';
    T=t-'A';
    B=b-'A';
    printf("%.8f\n",solve(S/3,S%3,n));
  }
  
  return 0;
}

Measured memory_bytes: 1188
n,m=map(int,input().split())
sc=[]
for i in range(m):
    sc.append(list(map(int,input().split())))

mm=10**(n-1)
if n==1:mm-=1
mmm=10**n
for i in range(mm,mmm):
    ok=True
    ii=str(i)
    for j in sc:
        ss=j[0]-1
        cc=j[1]

        if ii[ss]==str(cc):
            pass
        else:
            ok=False
            break
    if ok:
        print(i)
        quit()
print(-1)

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

using namespace std;

int main(int argc, char *argv[]) {
  string S;
  cin >> S;
  int a = (S[0] - '0') * 10 + S[1] - '0', b = (S[2] - '0') * 10 + S[3] - '0';
  int p = (a > 12 || a == 0) * 2 + (b > 12 || b == 0);
  if(p == 0) cout << "AMBIGUOUS" << endl;
  if(p == 1) cout << "MMYY" << endl;
  if(p == 2) cout << "YYMM" << endl;
  if(p == 3) cout << "NA" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
string operator*(string a,int k){
	string s;
	rep(i,k) s += a;
	return s;
}
string solve(int A,int B,int C,string a,string b,string c){
	// puts("-------------");
	// printf("A,B,C = %d,%d,%d\n",A,B,C);
	// show(a);
	// show(b);
	// show(c);
	// puts("-------------");
	if(B+C==0){
		return a*A;
	}
	if(A+C==0){
		return b*B;
	}
	if(B+A==0){
		return c*C;
	}
	if(A==0){
		return solve(B,C,0,b,c,"");
	}
	//aaa.aaa.aaa.aa.aa.
	int q = A/(B+C);
	int r = A%(B+C);
	string o = a*q;
	if(r<=C){
		return solve(r,B,C-r,o+a+c,o+b,o+c);
	}else{
		return solve(r-C,C,B-(r-C),o+a+b,o+a+c,o+b);
	}
}
int main(){
	int A,B,C;
	cin>>A>>B>>C;
	cout<<solve(A,B,C,"a","b","c")<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;



int main() {

	string s;
	cin >> s;

	int n = s.size();

	int count[2] = { 0 };

	//始まりが0の場合
	for (int i = 0; i < n; i++) {
		if ((i%2==0 && s[i]=='1')||(i % 2 == 1 && s[i] == '0'))
			count[0]++;

		if ((i % 2 == 0 && s[i] == '0') || (i % 2 == 1 && s[i] == '1'))
			count[1]++;
	}


	int ans = min(count[0], count[1]);
	cout << ans << endl;

	

	
	return 0;
}

Measured memory_bytes: 512
N = int(input())
src = [input() for i in range(N)]
def ctoi(c):
    return ord(c) - ord('a')
def itoc(i):
    return chr(ord('a') + i)

ans = [999] * 26
for s in src:
    tmp = [0] * 26
    for c in s:
        tmp[ctoi(c)] += 1
    for i,(a,b) in enumerate(zip(ans,tmp)):
        ans[i] = min(a,b)

t = ''
for i,a in enumerate(ans):
    t += itoc(i) * a
print(t)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

vector<ll> fac(MAX), finv(MAX), inv(MAX);

void comInit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(ll i=2; i<MAX; i++){
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}


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

int main(){
    string s; cin >> s;
    ll n = s.size();
    ll i = n-1;
    bool flag = true;
    while(i>=0){
        if(i >= 1 && s[i] == 'r' && s[i-1] == 'e'){
            if(i >= 6 && s[i-2] == 'm'){
                if(s[i-3]=='a'&&s[i-4]=='e'&&s[i-5]=='r'&&s[i-6]=='d'){
                    i -= 7;
                }else{
                    flag = false;
                    break;
                }
            }else if(i >= 5 && s[i-2] == 's'){
                if(s[i-3]=='a' && s[i-4]=='r' && s[i-5]=='e'){
                    i -= 6;
                }else{
                    flag = false;
                    break;
                }
            }else{
                flag = false;
                break;
            }
        }else if(i >= 4 && s[i] == 'e'){
            if(s[i-1]=='s'&&s[i-2]=='a'&&s[i-3]=='r'&&s[i-4]=='e'){
                i -= 5;
            }else{
                flag = false;
                break;
            }
        }else if(i >= 4 && s[i] == 'm'){
            if(s[i-1]=='a'&&s[i-2]=='e'&&s[i-3]=='r'&&s[i-4]=='d'){
                i -= 5;
            }else{
                flag = false;
                break;
            }
        }else{
            flag = false;
            break;
        }
    }
    if(flag) puts("YES");
    else puts("NO");
}

Measured memory_bytes: 12416
from collections import Counter

n = int(input())
w = [""] * n
for i in range(n):
    w[i] = list(input())
    w[i].sort()
    w[i] = "".join(w[i])

w = Counter(w)
ans = 0
for i in w.values():
    ans += i * (i - 1) // 2
print(ans)


Measured memory_bytes: 23984
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){
  int a,b;
  cin >> a >> b;
  cout << (a*b%2==0?"Even":"Odd") << endl;
  return 0;
}

Measured memory_bytes: 384
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;
int main() {
	int i, j;
	int N, M, X;
	int A[101];
	int goal0 = 0;
	int goalN = 0;
	int mincost = 99999;
	cin >> N >> M >> X;

	for (i = 0; i < M; ++i) {
		cin >> A[i];
	}

	//ゴール0
	for (i = X; i > 1; --i) {
		for (j = 0; j < M; ++j) {
			if (A[j] == i - 1) {
				++goal0;
			}
		}

	}

	//ゴールN
	for (i = X; i < N-1; ++i) {
		for (j = 0; j < M; ++j) {
			if (A[j] == i + 1) {
				++goalN;
			}
		}
	}

	mincost = min(goal0, goalN);

	cout << mincost<< endl;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for ( i = 0 ; i < (n); ++i)
#define rep(i,n) for ( int i = 0 ; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vint c(n);
    vector <vector<int> > a(n, vector<int>(m));
    rep(i,n){
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
    }

    vint bin(12);
    int ans=1e7;
    
    REP(bin[0],2){
        REP(bin[1],2){
            REP(bin[2],2){
                REP(bin[3],2){
                    REP(bin[4],2){
                        REP(bin[5],2){
                            REP(bin[6],2){
                                REP(bin[7],2){
                                    REP(bin[8],2){
                                        REP(bin[9],2){
                                            REP(bin[10],2){
                                                REP(bin[11],2){
                                                    int sum = 0;
                                                    vint vsum(m);
                                                    rep(i,n){
                                            
                                                        if(bin[i] == 1){
                                                            sum+=c[i];
                                                            rep(j,m) vsum[j]+=a[i][j];    
                                                        }
                                                        
                                                    }
                                                    bool is_ok = true;
                                                    rep(j,m){
                                                        if(vsum[j]<x){
                                                            is_ok = false;
                                                            break;
                                                        }
                                                    }
                                                    if(is_ok){
                                                        ans = min(ans, sum);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if(ans==1e7){
        cout << "-1" << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3540
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a.at(i);
	}
	int sum = 0;
	for (int i = 0; i < m; i++) {
		sum += a.at(i);
	}
	if (n >= sum) cout << n - sum << endl;
	else cout << "-1" << endl;

	return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
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); }

void solve(void)
{
  int H,W;
  cin>>H>>W;
  vector<vector<char> >  mat (H,vector<char>(W,0));
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
       cin>>mat[i][j];
    }
  }
  int ANS = 1;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      int check = 0;
      if(mat[i][j] == '.')continue;
      if(i != 0)if(mat[i-1][j] =='#')check = 1;
      if(i != H-1)if(mat[i+1][j] =='#')check = 1;
      if(j != 0)if(mat[i][j-1] =='#')check = 1;
      if(j != W-1)if(mat[i][j+1] =='#')check = 1;
      ANS *= check;
    }


  }
  if(ANS)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }

  return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}

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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define FORR(v, c) for (auto &v : c)
#define F first
#define S second
#define SQ(x) (x)*(x)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define dbg(x) cerr<<#x<<" = " << (x) << endl
#define pnl(x) cout << x << '\n'
#define pns(x) cout << x << ' '
#define read(x) cin >> x
#define read2(x,y) cin >> x >> y
#define read3(x, y, z) cin >> x >> y >> z
#define read4(a, b, c, d) cin >> a >> b >> c >> d
#define readv(v) FORR(c,v) read(c)

struct Arrete { int v, c;};
struct Point {int x, y; double distance(Point other) const {return sqrt(SQ(x-other.x)+SQ(y-other.y));}};

typedef	vector<int>	vi;
typedef pair<int,int>	ii;
typedef vector<string>	vs;
typedef vector<ii>	vii;
typedef vector<Arrete>	vg;
typedef vector<long long>	vl;
typedef	long long ll;

const int MAXN = 301;

int N;
long double dp[MAXN][MAXN][MAXN];

long double calc(int _1, int _2, int _3)
{
	if (_1 < 0 or _2 < 0 or _3 < 0)
		return -1;
	if (dp[_1][_2][_3] != -1)
		return dp[_1][_2][_3];
	dp[_1][_2][_3] = 1 + (_1 * calc(_1 - 1, _2, _3))/((long double)N) 
			+ (_2 * calc(_1+1, _2-1, _3))/((long double)N) 
			+ (_3 * calc(_1, _2 + 1, _3-1))/((long double)N);
	dp[_1][_2][_3] *= ((long double) N) / (_1 + _2 + _3);
	
	return dp[_1][_2][_3];
}

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

	FOR(i,0, MAXN) FOR(j,0, MAXN) FOR(k,0,MAXN)
		dp[i][j][k] = -1;
	dp[0][0][0] = 0;
	
	read(N);
	int _1(0), _2(0), _3(0);
	FOR(i,0, N)
	{
		int k;
		read(k);
		if (k==1) _1++;
		if (k==2) _2++;
		if (k==3) _3++;
	}
	cout << fixed << setprecision(15) << calc(_1, _2, _3) << endl;
}



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

int main() {
	int N; cin >> N;
	string S; cin >> S;
	char al[26];
	for(int i=0; i<26; ++i) al[i] = 'a'+i;
	int num[26]={0};
	for(int i=0; i<N; ++i) for(int j=0; j<26; ++j) if(S[i]==al[j]) ++num[j];
	int r[110]={0};
	for(int i=0; i<26; ++i){
	    if(num[i]>1){
	       int k=0;
	       while(S[k]!=al[i]) ++k;
	       for(int j=k; num[i]!=0; ++j){
	           ++r[j];
	           if(S[j]==al[i]) --num[i];
	       }
	    }
	}
	int M=0;
	for(int i=0; i<N; ++i) if(r[i]>M) M=r[i];
	cout << M << endl;
	return 0;
}


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

#define dump(x) cout << (x) << endl
#define Int int64_t
#define fi first
#define se second

Int mod = 1e9 + 7;
Int INF = 1e18;

int main() {
    Int a, b;
    cin >> a >> b;
    dump(max((Int)0, a - b * 2));
    return 0;
}

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

int main(void) {
	int A, B, C, K;
	std::cin >> A >> B >> C >> K;
	if (A >= B && A >= C) {
		std::cout << A * pow(2, K) + B + C << std::endl;
	}
	else if (B >= A && B >= C) {
		std::cout << B * pow(2, K) + A + C << std::endl;
	}
	else if (C > A && C > B) {
		std::cout << C * pow(2, K) + A + B << std::endl;
	}

	return 0;
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;


double w,h,x,y;

int main(){
  cin >> w >> h >> x >> y;
  double ans = (double)w*h/2.0;
  int cnt = 0;
  if(x==w/2 && y==h/2)cnt=1;
  cout.precision(9);
  cout << ans << " " << cnt << endl;
}

Measured memory_bytes: 256