akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;

class Dice{
public:
    int number[6];   
    int work[6];

    void setLabel(int index,int num){
        number[index] = num; 
    };

    void roll(char tokn){
        for(int i=0;i<6;i++) work[i] = number[i];
        switch(tokn){
            case 'E':
                setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
                break;
                
            case 'S':
                setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
                break;
                
            case 'N':
                setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
                break;
                
            case 'W':
                setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
                break;
        }
    }
    int returnTop(){
        return number[0];
    }
    int returnFront(){
        return number[1];
    }
    int returnLeft(){
        return number[3];
    }
    int returnRight(){
        return number[2];
    }
    int returnBack(){
        return number[4];
    }

private:
    void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
        number[0] = n0;
        number[1] = n1;
        number[2] = n2;
        number[3] = n3;
        number[4] = n4;
        number[5] = n5;
    }

};


int main() {
    Dice Dice;
    int label;
    for(int i=0;i<6;i++) {
        cin >> label;
        Dice.setLabel(i,label);
    }
    int n;
    cin >> n;
    int t,f;
    while(n){
        cin >> t >> f;
        if(Dice.returnLeft() == t) Dice.roll('E');
        else if(Dice.returnRight() == t) Dice.roll('W');
        else while(Dice.returnTop() != t) Dice.roll('S');
       
        if(Dice.returnLeft()==f) cout << Dice.returnFront() << endl;
        else if(Dice.returnRight()==f) cout << Dice.returnBack() << endl;
        else if(Dice.returnFront()==f) cout << Dice.returnRight() << endl;
        else cout << Dice.returnLeft() << endl;
        n--;
    }
    return 0;
}



Measured memory_bytes: 3080
N = int(input())
A = [int(a)-1 for a in input().split()]
X = [0] * N
for a in A:
    X[a] += 1
s = 0
for x in X:
    s += x * (x-1) // 2

for a in A:
    print(s - (X[a] - 1))

Measured memory_bytes: 26140
H, W = [int(s) for s in input().split()]
S = []
for _ in range(H):
    S.append(input())


def check(h, w):
    if S[h][w] != '#':
        return True
    ps = [(h, w-1), (h+1, w), (h, w+1), (h-1, w)]
    ps = [p for p in ps if p[0] in range(H) and p[1] in range(W)]
    if any(S[p[0]][p[1]] == '#' for p in ps):
        return True
    else:
        return False

if any(not check(h, w) for h in range(H) for w in range(W)):
    print('No')
else:
    print('Yes')


Measured memory_bytes: 3064
def main():
    S = input()
    ans = 0
    prev = ""
    i = 0
    while i < len(S):
        if S[i] == prev:
            prev = S[i:i+2]
            i += 2
        else:
            prev = S[i]
            i += 1
        if i <= len(S):
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


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

#define ABS(x) ((x) > 0 ? (x) : -(x))
#define POS(x) ((x) > 0 ? (x) : 0)
using namespace std;

const int ARR_SIZE = 5e3+5;

int P[ARR_SIZE];
long long C[ARR_SIZE];

int parent[ARR_SIZE];

int Find(int x) {
  if (parent[x] == -1) {
    return x;
  }
  return parent[x] = Find(parent[x]);
}

void Union(int x, int y) {
  int px = Find(x), py = Find(y);
  if (px != py) {
    parent[py] = px;
  }
}



int main() {
  int n, k;
  scanf("%d%d", &n, &k);

  memset(parent, -1, sizeof(parent));

  for (int i = 1; i <= n; ++i) {
    scanf("%d", P+i);
    Union(i, P[i]);
  }

  for (int i = 1; i <= n; ++i) {
    scanf("%lld", C+i);
  }

  // from parent to scores
  unordered_map<int, long long> ringScore;
  unordered_map<int, int> ringSize;
  for (int i = 1; i <= n; ++i) {
    ringScore[Find(i)] += C[i];
    ringSize[Find(i)]++;
  }

  long long ans = LONG_LONG_MIN;

  for (int i = 1; i <= n; ++i) {
    int j = P[i], nMove = 0, rSize = ringSize[Find(i)];
    long long tot = 0, rScore = POS(ringScore[Find(i)]);
    
    if (k >= rSize) {
      ans = max(ans, (k-nMove)/rSize*ringScore[Find(i)]);
    }

    while (j != i) {
      tot += C[j];
      nMove++;
      
      ans = max(ans, tot + (k-nMove)/rSize*rScore);
      if (nMove >= k) break;
      j = P[j];
    }
  }
  printf("%lld\n", ans);



  return 0;
}

Measured memory_bytes: 3924
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string.h>
#include <vector>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <queue>
using namespace std;
typedef unsigned long long ui64;
typedef long long i64;

void AtCoderExpress2() {
	int N, M, Q;
	cin >> N >> M >> Q;
	int d[503][503];
	memset(d, 0, sizeof(d));
	for (size_t i = 0; i < M; i++)
	{
		int l, r;
		cin >> l >> r;
		d[l][r]++;
	}
	
	for (size_t i = N; i > 0; i--)
	{
		for (size_t j = N - 1; j > 0; j--)
		{
						
			d[j][i] += d[j + 1][i];
		}
	}

	for (size_t i = 1; i <= N; i++)
	{
		for (size_t j = 2; j <= N; j++)
		{
			d[i][j] += d[i][j - 1];
		}
	}

	for (size_t i = 0; i < Q; i++)
	{
		int p, q;
		cin >> p >> q;
		cout << d[p][q] << "\n";
	}

}

int main() {
	AtCoderExpress2();
	return 0;
}

Measured memory_bytes: 1920
import Control.Applicative ((<$>))
import Control.Monad (replicateM)

main :: IO ()
main = do
  n <- readLn
  solve <$> replicateM n (map read <$> words <$> getLine) >>= mapM_ print

solve :: [[Int]] -> [Int]
solve = map ((md -) . day)
  where md = day [1000, 1, 1]

day :: [Int] -> Int
day [y, m, d] = 195 * y' + y' `div` 3 * 5 + 20 * m' - (ly y') * (m' `div` 2) + d'
  where ly y = if y `mod` 3 == 2 then 0 else 1
        y' = y-1
        m' = m-1
        d' = d-1



Measured memory_bytes: 4144
#include <iostream>

int main(void){
    int N, tmp_h, tmp=0, ans=0;
    std::cin >> N >> tmp_h;

    for(int i=1; i<N; ++i){
        int h;
        std::cin >> h;
        if (h <= tmp_h){
            ++tmp;
            tmp_h = h;
        } else {
            if (tmp > ans) ans = tmp;
            tmp = 0;
            tmp_h = h;
        }
    }

    if (tmp > ans) ans = tmp;

    std::cout << ans << std::endl;

    return 0;
}


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

int main(){
  int64_t N,A,B,C;
  cin >> N >> A >> B >> C;
  vector<string> S(N);
  vector<char> Ans(N);
  for(int64_t i=0;i<N;i++){
    cin >> S.at(i);
  }
  for(int64_t i=0;i<N;i++){
    if(S.at(i)=="AB"){
      if(A==0&&B==0){
        cout << "No" << endl;
        return 0;
      }else if(A==1&&B==1){
        if(i!=N-1){
          if(S.at(i+1)=="AB"||S.at(i+1)=="AC"){
            A++;
            B--;
            Ans.at(i)='A';
          }else{
            A--;
            B++;
            Ans.at(i)='B';
          }
        }else{
          A++;
          B--;
          Ans.at(i)='A';
        }
      }else{
        if(A>B){
          A--;
          B++;
          Ans.at(i)='B';
        }else{
          A++;
          B--;
          Ans.at(i)='A';
        }
      }
    }else if(S.at(i)=="AC"){
      if(A==0&&C==0){
        cout << "No" << endl;
        return 0;
      }else if(A==1&&C==1){
        if(i!=N-1){
          if(S.at(i+1)=="AB"||S.at(i+1)=="AC"){
            A++;
            C--;
            Ans.at(i)='A';
          }else{
            A--;
            C++;
            Ans.at(i)='C';
          }
        }else{
          A++;
          C--;
          Ans.at(i)='A';
        }
      }else{
        if(A>C){
          A--;
          C++;
          Ans.at(i)='C';
        }else{
          A++;
          C--;
          Ans.at(i)='A';
        }
      }
    }else{
      if(B==0&&C==0){
        cout << "No" << endl;
        return 0;
      }else if(B==1&&C==1){
        if(i!=N-1){
          if(S.at(i+1)=="AB"||S.at(i+1)=="BC"){
            B++;
            C--;
            Ans.at(i)='B';
          }else{
            B--;
            C++;
            Ans.at(i)='C';
          }
        }else{
          B++;
          C--;
          Ans.at(i)='B';
        }
      }else{
        if(B>C){
          B--;
          C++;
          Ans.at(i)='C';
        }else{
          B++;
          C--;
          Ans.at(i)='B';
        }
      }
    }
  }
  cout << "Yes" << endl;
  for(int64_t i=0;i<N;i++){
    cout << Ans.at(i) << endl;
  }
    

}

Measured memory_bytes: 6412
#include<iostream>
using namespace std ;
#define ll long long int
#define maxn  1000000007
#include<cstring>
int main()
{

    ll n ;
    cin>> n ;
    string s ;
    cin>>s ;
    ll dp[n+1][n+1] ;
    memset(dp, 0, sizeof((dp)) )  ;
    dp[0][1] =1 ;


    for( int i =0 ; i < n ;i++)
    {
        if(s[i]=='<')
        {

            ll sum[i+3]   ;
            memset(sum , 0 , sizeof( sum)) ;
            for(int j = 1 ;  j<= i+1 ;j++)
            {

                sum[j] = (sum[j-1]+ dp[i][j] ) %maxn   ;
            }

            for( ll j = 1 ;j <= i+2 ; j++ )
            {
                dp[i+1][j] = sum[j-1] ;


            }

        }else
        {




            ll sum[i+3]   ;
            memset(sum , 0 , sizeof( sum)) ;
            for(int j = 1+i ;  j>= 1 ;j--)
            {

                sum[j] = (sum[j+1]+ dp[i][j] )%maxn  ;
            }

            for( ll j = 1 ;j <= i+1 ; j++ )
            {
                dp[i+1][j] = sum[j] ;


            }

        }


    }














    ll ans =0 ;
    for( int i = 1 ;i <= n ;i++)
    {

        ans= (ans + dp[n-1][i] )%maxn ;
    }
    cout<<ans ;

}


Measured memory_bytes: 70656
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(1000000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline--------------------------------------------
    n,k = map(int,input().split())
    mk = (n-1)*(n-2)//2
    if k > mk:
        print(-1)
    else:
        rest = mk - k
        print(n-1+rest)
        for i in range(n-1):
            print(1,i+2)
        t = [2,3]
        for i in range(rest):
            if t[1] <= n:
                print(t[0],t[1])
                t[1] += 1
            else:
                t = [t[0]+1,t[0]+2]
                print(t[0],t[1])
                t[1] += 1
if __name__ == "__main__":
    main() 
    
#endline===============================================
    

Measured memory_bytes: 13748
#include <iostream>
#include <string>
using namespace std;
int main(){
int a[4];
int b[4];
int c;
int d;
int e;
int f;
while(cin >>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
e=0;
f=0;
c=0;
while(c<4){
d=0;
while(d<4){
if(a[c]==b[d]){if(c==d){e=e+1;} else{f=f+1;}}
d=d+1;}
c=c+1;}
cout <<e<<" "<<f<<endl;
}}

Measured memory_bytes: 1160
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Collections;

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());
            Integer a[] = new Integer[n];
            long sum = 0;
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
                sum += a[i];
            }
            long ans = 0;
            Arrays.sort(a, Collections.reverseOrder());

            for (int i = 0; i < n; i++) {
                if (a[i] * 4 * m >= sum) ans++;
            }

            // 出力
            if (ans >= m) {
                out.println("Yes");
            } else {
                out.println("No");
            }

        }

    }
}



Measured memory_bytes: 23124
#include <cstdio>
#include <algorithm>
using namespace std;
const long long mod = 1000000007;
long long mp(long long b, long long e) {
	if (e == 0) return 1;
	long long ans = mp(b, e / 2);
	ans = ans * ans % mod;
	if (e % 2) ans = ans * b % mod;
	return ans;
}
int main() {
	int N;
	scanf("%d", &N);
	long long x[N], ans = 0, fac = 1, mi[N], var = 0;
	for (int i = 0; i < N; ++i) scanf("%lld", &x[i]);
	for (int i = 1; i < N; ++i) fac = (fac * i) % mod;
	for (int i = 1; i < N; ++i) mi[i] = mp(i, mod - 2);
	for (int i = 1; i < N - 1; ++i) var -= mi[i] * mi[i + 1], var %= mod;
	for (int i = 0; i < N - 1; ++i) {
		ans = (ans + fac * var % mod * x[i] % mod) % mod;
		ans = (ans + fac * mi[N - i - 1] % mod * (x[N - 1] - x[i]) % mod) % mod;
		var += mi[N - 2 - i] * mi[N - 1 - i];
		var %= mod;
		var += mi[i + 1] * mi[i + 2];
		var %= mod;
	}
	/*for (int i = 0; i < N - 1; ++i) {
		for (int j = 1; i + j < N - 1; ++j) ans = (ans + fac * mi[j] % mod * mi[j + 1] % mod * (x[i + j] - x[i]) % mod) % mod;
		ans = (ans + fac * mi[N - i - 1] % mod * (x[N - 1] - x[i]) % mod) % mod;
	}*/
	printf("%lld", (ans + mod) % mod);
	return 0;
}

Measured memory_bytes: 1664
#include<cstdio>
#include<cstring>
#include<cassert>
#include<iostream>
#include<algorithm>

using namespace std;

#define Whats(x) cout<<#x<<" is "<<(x)<<endl
#define Divhim() cout<<">>>>>>>>>>>>>>>"<<endl
#define Divher() cout<<"<<<<<<<<<<<<<<<"<<endl
#define Oops() cout<<"!!!!!!!!!!!!!!!"<<endl

template<typename T> bool GetMin(T &a,T b)
{
	return ((a<=b)?false:(a=b,true));
}

template<typename T> bool GetMax(T &a,T b)
{
	return ((a>=b)?false:(a=b,true));
}

/*
	 -<Unlimited Blade Works>-
 */

#define LL long long

const int N=1e6+10;
const LL INF=0x3f3f3f3f3f3f3f3f;

int n;LL c;
LL dp[N];
LL ki[N<<4],bi[N<<4];

LL Ask(int p,int o=1,int l=1,int r=N)
{
	if(!ki[o])
		return INF;
	if(l==r)
		return ki[o]*p+bi[o];
	int mid=(l+r)>>1,lc=o<<1,rc=lc^1;
	//Whats(ki[o]);
	//Whats(p);
	//Whats(ki[o]*p+bi[o]);
	if(p<=mid)
		return min(ki[o]*p+bi[o],Ask(p,lc,l,mid));
	else
		return min(ki[o]*p+bi[o],Ask(p,rc,mid+1,r));
}

void Update(LL k,LL b,int o=1,int l=1,int r=N)
{
	if(!ki[o])
	{
		ki[o]=k;
		bi[o]=b;
		return;
	}
	if(ki[o]==k)
	{
		GetMin(bi[o],b);
		return;
	}
	int mid=(l+r)>>1,lc=o<<1,rc=lc^1;
	if((k*mid+b)<(ki[o]*mid+bi[o]))
	{
		swap(k,ki[o]);
		swap(b,bi[o]);
	}
	if(l==r)
		return;
	if((k*l+b)<(ki[o]*l+bi[o]))
		Update(k,b,lc,l,mid);
	else
		Update(k,b,rc,mid+1,r);
}

int main()
{
	scanf("%d%lld",&n,&c);
	for(int i=1;i<=n;++i)
	{
		LL h;
		scanf("%lld",&h);
		if(1<i)
			dp[i]=Ask(h)+h*h;
		Update(-2*h,dp[i]+c+h*h);
	}
	printf("%lld",dp[n]);
	return 0;
}

Measured memory_bytes: 38016
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int a,b,h;
  cin>>a>>b>>h;
  cout<<(a+b)*h/2<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a[31]={0};
    int ans[31]={0};
    int i;

    for(i = 0;i < 28; i++){
        scanf("%d",&a[i]);
        ans[a[i]] += 1;
    }

    for(i = 1;i <= 30; i++){
        if(ans[i] != 1){
            printf("%d\n",i);
        }
    }
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e5 + 11;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


string s;

main () {
	cin >> s;
	cout << s.substr(0, 3);
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios::sync_with_stdio(0),cin.tie(0);
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
	int n=0;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
		s[i] == '+' ? ++n : --n;
	cout << n;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
H, N = map(int, input().split())
A = list(map(int, input().split()))

if H <= sum(A) :
  print ("Yes")
else :
  print ("No")






Measured memory_bytes: 14524
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int F[50];
    F[0] = F[1] = 1;
    for (int i = 2; i <= n; i++) {
        F[i] = F[i - 2] + F[i - 1];
    }
    cout << F[n] << endl;
    return 0;
}

Measured memory_bytes: 3076
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
#include <bits/stdc++.h>

using namespace std;
using Int = long long;

signed main(){
    Int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    string sub = s.substr(k-1, 1);
    transform(sub.begin(), sub.end(), sub.begin(), ::tolower);
    cout << s.replace(k-1, 1, sub) << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }


int main() {
	string s;
	cin >> s;
	vector<int> c(26, 0);
	REP(i, s.size()) {
		c[s[i] - 'A']++;
	}
	bool flag = true;
	REP(i, 26) {
		if (c[i] != 0 && c[i] != 2) {
			flag = false;
		}
	}
	if (flag) {
		put("Yes");
	}
	else {
		put("No");
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>
 
using namespace std;
typedef long long ll;


ll ans,mx,mn,sum;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b && b==c) cout<<1;
	else if(a==b&&b!=c) cout<<2;
	else if(a!=b&&b==c) cout<<2;
	else if(a==c&&b!=c) cout<<2;
	else cout<<3;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
   
  #define ll long long
  #define pb push_back
  #define mp make_pair
  #define ff first
  #define ss second

int pal(string s){
  string t=s;
  reverse(s.begin(),s.end());
  if(t==s)
    return 1;
  else 
    return 0;
}
   
void func(){

string s;
cin>>s;

ll n=s.length();

ll l=s.length()/2;

if(pal(s)==0){
  cout<<"No"<<endl;
  return;
}

if(pal(s.substr(0,l))==0){
  cout<<"No"<<endl;
  return;
}

if(pal(s.substr(n/2+1,l))==0){
  cout<<"No"<<endl;
  return;
}
cout<<"Yes"<<endl;
}
   
   
  int main(){
          ios_base::sync_with_stdio(false);
          cin.tie(0);
          cout.tie(0);
   
       /* #ifndef ONLINE_JUDGE
        freopen("input.txt", "r" , stdin);
        freopen("output.txt", "w" , stdout);
        #endif*/
   
     ll t=1;
     //cin>>t;
     while(t--)
     func();
   }

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int q;
  cin >> q;
  REP(i, q) {
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    int dp[1010][1010] = {};
    REP(i, n) REP(j, m) {
      if (s[i] == t[j]) {
        dp[i + 1][j + 1] = dp[i][j] + 1;
      } else {
        dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
      }
    }
    cout << dp[n][m] << endl;
  }
  return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);

  string s;
  cin >> s;
  if (s == "SUN") {
    cout << 7;
  } else if (s == "SAT") {
    cout << 1;
  } else if (s == "FRI") {
    cout << 2;
  } else if (s == "THU") {
    cout << 3;
  } else if (s == "WED") {
    cout << 4;
  } else if (s == "TUE") {
    cout << 5;
  } else if (s == "MON") {
    cout << 6;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   string S;
  int N,K,M;
  cin >> N >> K >> S;
  M=K-1;
  for(int i=0;i<N;i++){
    if(i==M && S.at(i)=='A'){
      cout << 'a';
      continue;
    }
        if(i==M && S.at(i)=='B'){
      cout << 'b';
          continue;
    }
        if(i==M && S.at(i)=='C'){
      cout << 'c';
          continue;
    }
    else{cout << S.at(i);}	      
    }
}

Measured memory_bytes: 256
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::HashSet;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    l: f64,
    }

     println!("{}", (l/3_f64)*(l/3_f64)*(l/3_f64));
}


Measured memory_bytes: 2208
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	N += 2;
	vector<int> card(N);
	cin >> card[0] >> card[1];
	
	for(int i=2;i<N;++i){
		cin >> card[i];
	}
	
	if( N == 3 ){
		cout << abs(card[N-1]-card[1]) << endl;
	}else{
		cout << max( abs(card[N-1]-card[1]),abs(card[N-2]-card[N-1]) ) << endl;
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,x,r,l,t[105];
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		t[x]++,r=max(r,x);
	}
	l=r+1>>1;
	for(int i=l+1;i<=r;i++){
		if(t[i]<2){
			printf("Impossible");
			return 0;
		}
	}
	if(r&1){
		if(t[l]<2){
			printf("Impossible");
			return 0;
		}
		t[l]-=2;
	} 
	else {
		if(t[l]<1){
			printf("Impossible");
			return 0;
		}
		t[l]-=1;
	}
	for(int i=1;i<=l;i++)
		if(t[i]){
			printf("Impossible");
			return 0;
		}
	printf("Possible");
}

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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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;
}

set<int> a;
vector<int> dp(100010);
int main()
{
    int N, M;
    cin >> N >> M;
    rep(i, M)
    {
        int input;
        cin >> input;
        a.insert(input);
    }

    dp.at(0) = 1;
    dp.at(1) = 1;
    for (int i = 2; i < N + 1; i++) {
        if (!a.count(i - 1)) {
            dp[i] += dp[i - 1];
        }
        if (!a.count(i - 2)) {
            dp[i] += dp[i - 2];
        }
        dp[i] = dp[i] % MOD;
    }

    cout << dp.at(N) << endl;
}

Measured memory_bytes: 5376
N, M = map(int, input().split())
A = list(map(int, input().split()))

s = sum(A)
A.sort(reverse=True)

for i in range(N):
    if i == M - 1:
        if (s / (4 * M)) > A[i]:
            print('No')
        else:
            print('Yes')


Measured memory_bytes: 9176
def readInt():
  return int(input())


def readInts():
  return [int(i) for i in input().split()]


N = readInt()
AS = readInts()

flag = True
cnt = 0
i = 0
while flag:
    flag = False
    for i in reversed(range(i + 1, N)):
        if AS[i] < AS[i - 1]:
            AS[i - 1], AS[i] = AS[i], AS[i - 1]
            cnt += 1
            flag = True

print(*AS)
print(cnt)



Measured memory_bytes: 5608
class SegTree:
    X_unit = 0
    X_f = max

    def __init__(self, N):
        self.N = N
        self.X = [self.X_unit] * (N + N)

    def build(self, seq):
        for i, x in enumerate(seq, self.N):
            self.X[i] = x
        for i in range(self.N - 1, 0, -1):
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def set_val(self, i, x):
        i += self.N
        self.X[i] = x
        while i > 1:
            i >>= 1
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def fold(self, L, R):
        L += self.N
        R += self.N
        vL = self.X_unit
        vR = self.X_unit
        while L < R:
            if L & 1:
                vL = self.X_f(vL, self.X[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.X_f(self.X[R], vR)
            L >>= 1
            R >>= 1
        return self.X_f(vL, vR)


def main():
    N = int(input())
    A = [int(input()) for i in range(N)]
    seg = SegTree(N)
    seg.build(A)

    for i in range(N):
        print(max(seg.fold(0, i), seg.fold(i+1, N)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 96968
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100100;
const long long MOD = 1000000007;
typedef pair<long long,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

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



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N;cin >> N;
    string S;cin >> S;
    int b = 0,r = 0;
    for(int i = 0;i<S.size();i++) if(S.at(i) == 'R')r++;else b++;
    if(b >= r) cout << "No" << endl;
    if(b < r) cout << "Yes" << endl;
}


Measured memory_bytes: 3636
#include<stdio.h>

struct Card{
  char suit;
  char value;
};


int main(){
  struct Card C1[101], C2[101];
  int n, i,j,tmpn,min,count=0;
  char ch,tmpc;

  scanf("%d%c", &n,&ch);
  for ( i = 0; i < n; i++ ){
    scanf("%c%c%c", &C1[i].suit, &C1[i].value, &ch);
  }

  for(i=0; i<n; i++){
    C2[i].suit=C1[i].suit;
    C2[i].value=C1[i].value;
  }

  for(i=0; i<n-1; i++){
    for(j=n-1; j>i;j--){
      if(C1[j].value<C1[j-1].value){
	tmpn=C1[j-1].value;
	tmpc=C1[j-1].suit;

	C1[j-1].value=C1[j].value;
	C1[j-1].suit=C1[j].suit;

	C1[j].value=tmpn;
	C1[j].suit=tmpc;
      }
    }
  }

  for(i=0; i<n-1; i++){
    min=i;
    for(j=i; j<n; j++){
      if(C2[j].value<C2[min].value)
	min=j;
    }
    tmpn=C2[i].value;
    tmpc=C2[i].suit;

    C2[i].value=C2[min].value;
    C2[i].suit=C2[min].suit;

    C2[min].value=tmpn;
    C2[min].suit=tmpc;
  }
 

	for(i=0; i<n-1; i++)
	  printf("%c%c ",C1[i].suit,C1[i].value);
	printf("%c%c\nStable\n",C1[n-1].suit,C1[n-1].value);

	for(i=0; i<n-1; i++)
	  printf("%c%c ",C2[i].suit,C2[i].value);
	printf("%c%c",C2[n-1].suit,C2[n-1].value);
       
	for(i=0; i<n; i++){
	  if(C1[i].suit==C2[i].suit && C1[i].value==C2[i].value)
	    count++;
	}

	if(count==n)printf("\nStable\n");
	else printf("\nNot stable\n");      

  return 0;
}

Measured memory_bytes: 608
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

int main(){
    int x, y;
    scanf("%d%d", &x, &y);
    for(int i=0; i<=x; i++){
        if(2*i + 4*(x-i) == y){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
}

Measured memory_bytes: 1648
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe





int s(int n){
	int sum=0;
	while(n!=0){
		sum+=n%10; 
		n=n/10;
	}
	return sum;
}

int main(void){ios::sync_with_stdio(false);cin.tie(0);
///////////////////////////////////////////////////////
int n,a;
cin >> n;
a = s(n);
if(n%a==0){
	cout << "Yes" << endl;
}
else{
	cout << "No" << endl;
}




///////////////////////////////////////////////////////
return 0;}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	int n ;
	cin >> n ;
	vector<int> a(26,100);
	
	rep(i,n){
		string s;
		cin >> s;
		vector<int> now(26,0);
		rep(j,s.size()){
			int c =s[j] -'a' ;
			now[c] ++ ;
		}
		rep(j,26){
			chmin(a[j],now[j]);
		}
	}
	int ans = 0 ;
	rep(i,26){
		char c = 'a' + i;
		rep(j,a[i]) cout << c ;
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin >> N;
int M = N;
int x = 0;
while(M !=0){
  x += M%10;
  M = M/10;
}
if(N%x ==0) cout <<"Yes" << endl;
else cout << "No"<< endl;
}

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

using namespace std;
typedef long long ll;

int main(){    
    int K, N; cin >> N >> K;
    vector<int> p(N);

    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
    }

    sort(p.begin(), p.end());

    int ans = 0;

    for (int i = 0; i < K; i++)
    {
        ans += p[i];
    }

    cout << ans << endl;
    
    
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<int,int>cnt;
    map<int,int>::iterator I;
    int i,n,m,j,res=0;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>m;
        cnt[m]++;
    }
    for(I=cnt.begin(); I!=cnt.end(); I++)
    {
        if(I->first<I->second)
        {
            res=res+(I->second-I->first);
        }
        if(I->first>I->second)
        {
            res=res+I->second;
        }
    }
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 4736
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		double sum = 0.;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}
		sum /= (4. * m);
		int count = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] >= sum) {
				++count;
			}
		}
		if (count >= m) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23764
n = int(input())
lis = [int(x) for x in input().split()]
lis.sort()
nas = 0
ans = 0
for i in range(n-2):
  for y in range(i+1, n-1):
    for z in range(y+1,n):
      if lis[i] != lis[y] and lis[y] != lis[z] and lis[i] != lis[z] and lis[i]+lis[y] > lis[z]:
        ans += 1

print(ans)

Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define OK { cout << "OK" << endl; return 0; }
#define NG { cout << "NG" << endl; return 0; }
#define sz(v) ((int)(v).size())
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void out(T a){cout << a << endl;}
template<class T>void die(T a){cout << a << endl; exit(0);}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

#define SIZE 200005
#define MOD 1000000007
 
typedef pair <int,int> P;
 
ll inv[SIZE], fac[SIZE], finv[SIZE];
void make(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<SIZE; i++)
	{
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
    return ;
}
ll comb(int a,int b){
	if(a < b) return 0;
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}



ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    int N,M; ll K;cin>>N>>M>>K;
    vl A(N), B(M); vin(A); vin(B);

    vl suma(N+1,0), sumb(M+1,0);

    rep(i,N) suma[i+1] += suma[i] + A[i];
    rep(i,M) sumb[i+1] += sumb[i] + B[i];

    int ans = 0;
    rep(i,N+1){
      ll now = K - suma[i]; 
      if(now < 0) break;
      //if(upper_bound(all(B), now) - B.begin() == 0) break;
      int id = upper_bound(all(sumb), now) - sumb.begin() - 1;
      int tmp = i + id;
      chmax(ans, tmp);
    }
    out(ans);

  
	
}

Measured memory_bytes: 9536
H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]

state = []
# 初期状態
for h in range(H):
    for w in range(W):
        if field[h][w] == "#":
            state.append([w, h])

tmp = []
ret = 0
while len(state) > 0:
    tmp = list()
    ret += 1
    for x, y in state:
        for nx, ny in ((1,0), (-1,0), (0,1), (0,-1)):
            nx += x
            ny += y
            if nx < 0 or ny < 0 or nx >= W or ny >= H:
                continue

            if field[ny][nx] == ".":
                field[ny][nx] = "#"
                tmp.append([nx, ny])
    state = tmp

print(ret-1)


Measured memory_bytes: 178560
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from fractions import gcd
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()


def main():
    n = int(input())
    a = sorted(readlist())

    gcd_arr = [0] * (n + 1)
    for i in range(n):
        gcd_arr[i + 1] = gcd(gcd_arr[i], a[i])

    gcd_arr_rev = [0] * (n + 1)
    for i in reversed(range(n)):
        gcd_arr_rev[i] = gcd(gcd_arr_rev[i + 1], a[i])

    res = 0
    for i in range(n):
        res = max(res, gcd(gcd_arr[i], gcd_arr_rev[i + 1]))
    print(res)


# region template

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._buffer = BytesIO()
        self._fd = file.fileno()
        self._writable = "x" in file.mode or "r" not in file.mode
        self.write = self._buffer.write if self._writable else None

    def read(self):
        if self._buffer.tell():
            return self._buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

    def flush(self):
        if self._writable:
            os.write(self._fd, self._buffer.getvalue())
            self._buffer.truncate(0), self._buffer.seek(0)


class ostream:
    def __lshift__(self, a):
        if a is endl:
            sys.stdout.write(b"\n")
            sys.stdout.flush()
        else:
            sys.stdout.write(str(a))
        return self


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
cout, endl = ostream(), object()

readline = sys.stdin.readline
readlist = lambda var=int: [var(n) for n in readline().split()]
input = lambda: readline().rstrip(b"\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 50200
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    string s;
    cin >> s;
    if (s[0]==s[1] && s[1]==s[2]) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
A = [int(a) for a in input().split()]
ans = A[0]

if 0 in A:
    print(0)
    exit()

for i in range(1, len(A)):
    if A[i] != 1:
        ans *= A[i]
    if ans > 10**18:
        print(-1)
        exit()

print(ans)


Measured memory_bytes: 40092
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  int a,b;
  cin >> a >> b;
  rep(i,1001){
    if((i*8)/100==a&&i/10==b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left


def solve(string):
    a, b, q, *stx = map(int, string.split())
    s = [-10**10] + stx[:a] + [2 * 10**10]
    t = [-10**10] + stx[a:a + b] + [2 * 10**10]
    ans = []
    for _x in stx[-q:]:
        i_s, i_t = bisect_left(s, _x), bisect_left(t, _x)
        ls, rs = s[i_s - 1], s[i_s]
        lt, rt = t[i_t - 1], t[i_t]
        r_max = max(rs, rt)
        l_min = min(ls, lt)
        ans.append(
            str(
                min([
                    r_max - _x, _x - l_min, rt - ls + min(rt - _x, _x - ls),
                    rs - lt + min(rs - _x, _x - lt)
                ])))
    return "\n".join(ans)


if __name__ == '__main__':
    n, m, l = map(int, input().split())
    print(solve('{} {} {}\n'.format(n, m, l) + '\n'.join([input() for _ in range(n + m + l)])))


Measured memory_bytes: 39512
use std::io;
use std::io::Read;

fn main() {
    let mut buffer = String::new();

    io::stdin().read_to_string(&mut buffer).unwrap();

    let mut lines = buffer.lines();
    let a = lines.next().unwrap();
    let b = lines.next().unwrap();

    let a2 = a.split_whitespace().map(|s|s.parse::<i32>().unwrap()).collect::<Vec<i32>>();
    let b2 = b.split_whitespace().map(|s|s.parse::<i32>().unwrap()).collect::<Vec<i32>>();

    let hp = a2[0];
    let sum = b2.into_iter().fold(0, |acc, x| acc + x);
    if hp <= sum {
        println!("Yes");
    }else{
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <stdlib.h>
#include <algorithm>

#define rep(i,s,t) for(int i=s;i<t;i++)
#define mp(a,b) make_pair(a,b)
#define mii map<int,int>

using namespace std;

int main(void){
	map<pair<int,int>,int> d;
	rep(h,1,150){
		rep(w,h+1,151){
			d[mp(h*h+w*w,h)]=w;
		}
	}

	int h,w;
	while(true){
		cin >> h >> w;
		if(h==0 && w==0) break;

		map<pair<int,int>,int>::iterator it = d.find(mp(h*h+w*w,h));
		int a_h,a_w;
		it++;
		a_h=(*it).first.second;
		a_w=(*it).second;

		cout << a_h << " " << a_w << endl;

	}
	

	return 0;
}

Measured memory_bytes: 1896