akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n; cin >> n;
	vector<string> s(n);
	rep(i,n) cin >> s[i];
	vvi a(n,vi(26));
	rep(i,n)rep(j,s[i].size()){
		int x = s[i][j] - 'a';
		a[i][x]++;
	}
	vi b(26,INF);
	rep(x,26){
		int mn = INF;
		rep(i,n) mn = min(mn,a[i][x]);
		b[x] = mn;
	}
	string ans;
	rep(x,26){
		char c = 'a'+x;
		int num = b[x];
		rep(i,num) ans += c;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

struct UnionFind {
    vector<int> parent; // parent[root] is the negative of the size.
    UnionFind(int n) : parent(n, -1) { };
    bool unite(int u, int v) {
        u = root(u); v = root(v);
        if (u == v) return false;
        if (parent[u] > parent[v]) swap(u, v);
        parent[u] += parent[v]; parent[v] = u;
        return true;
    }
    bool find(int u, int v) { return root(u) == root(v); }
    int root(int u) { return parent[u] < 0 ? u : parent[u] = root(parent[u]); }
    int size(int u) { return -parent[root(u)]; }
};



int main(){
    ll N, M; cin >> N >> M;
    UnionFind U(N);
    vector<PII> E(M);
    for(int i=0; i<M; i++){
        ll a, b; cin >> a >> b;
        a--; b--;
        E[i] = PII(a, b);
    }
    
    ll X = (N-1)*N/2;
    vector<ll> G(N);
    vector<ll> S(N, 1);
    vector<ll> Ans;
    
    for(ll i=M-1; i>=0; i--){
        Ans.push_back(X);
        ll a = E[i].first;
        ll b = E[i].second;
        if(U.root(a)!=U.root(b)){
            ll dec = U.size(a)*U.size(b);
            X -= dec;
            U.unite(a, b);
        }
    }
    
    for(int i=M-1; i>=0; i--)
        cout << Ans[i] << endl;
    
    return 0;
}


Measured memory_bytes: 4980
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
namespace Atcoder_0404
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = GetInput_long()[0];
            long maney = 100;

            long year = 0;
            while (true)
            {
                if (maney >= x) break;
                year++;
                double temp = maney * 1.01d;
                maney =(long)temp;
            }
            Console.WriteLine(year);
        }
        #region input
        

        static string[] GetInput_string()
        {
            var input = Console.ReadLine().Split(' ');
            return input;
        }

        static int[] GetInput_int()
        {
            var input = GetInput_string();
            var result = new int[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = int.Parse(input[i]);
            }
            return result;
        }
        static long[] GetInput_long()
        {
            var input = GetInput_string();
            var result = new long[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = long.Parse(input[i]);
            }
            return result;
        }
        #endregion
        #region sonota
        static void Swap_array<T>(T[] target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        static void Swap_list<T>(List<T> target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        /// <summary>
        /// 最大公約数
        /// </summary>
        public static int GCD(int a, int b)
        {

            /* 自然数 a > b を確認・入替 */
            if (a < b)
            {
                int tmp = a;
                a = b;
                b = tmp;
            }

            /* ユークリッドの互除法 */
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        public static int LCM(int a, int b)
        {
            int x = a * b;
            b = GCD(a, b);
            return x / b;

        }
        #endregion

        static long mod = 1000000000 + 7;
    }
}

Measured memory_bytes: 27376
#include<iostream>
#define int long long
#define inf 1e9+1
using namespace std;
int n, W;
int wt[101];
int val[101];
int maxVal;
int dp[101][100005];

//int dp[101][100005];
/*
int knapsack1(int i,int W){

	//Base Case
	if(i==0 || W==0)
	{
		dp[i][W]=0;
	}

	if(dp[i][W]!=-1)
		return dp[i][W];

	//Recursive Case
	if(wt[i-1]>W)
		return dp[i][W] = knapsack1(i-1,W);

	else
	{
		int op1 = val[i-1] + knapsack1(i-1,W-wt[i-1]);
		int op2 = knapsack1(i-1,W);
		return dp[i][W] = max(op1,op2);
	}

}*/

int knapsack1_bu(int n, int W) {

	int dp[n + 1][W + 1] = {0};

	for (int i = 0; i <= n; i++) {
		for (int w = 0; w <= W; w++) {
			if (i == 0 || w == 0)
				dp[i][w] = 0;
			else {

				dp[i][w] = dp[i - 1][w];
				if (wt[i - 1] <= w)
					dp[i][w] = max(dp[i][w], dp[i - 1][w - wt[i - 1]] + val[i - 1]);

			}
		}
	}

	return dp[n][W];


}



int knapsack2(int n, int W) {

		for(int j=1;j<=maxVal;j++)
			dp[1][j]=inf;

		dp[1][0]=0;
		dp[1][val[0]] = wt[0];



	for (int i = 2; i <= n; i++) {
		for (int v = 0; v <= maxVal; v++) {

				dp[i][v] = dp[i - 1][v];
				
				if (val[i - 1] <= v) {
					dp[i][v] = min(dp[i][v], (dp[i - 1][v - val[i - 1]] + wt[i - 1]));
				
			}
		}
	}


	int ans = 0;
	for (int i = 0; i <= maxVal; i++) {
		//cout<<dp[n][i]<<" ";
		if (dp[n][i] <= W)
			ans = max(ans, i);
	}

	return ans;
}





int32_t main() {

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	cin >> n >> W;
	/*
		for(int i=0;i<=n;i++)
			for(int j=0;j<=W;j++)
				dp[i][j]=-1;
	*/

	maxVal = 0;
	for (int i = 0; i < n; i++) {
		cin >> wt[i] >> val[i];
		maxVal += val[i];
	}

	cout << knapsack2(n, W) << endl;

}

Measured memory_bytes: 81716
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;cin >> n >> k;
  cout << n - k + 1 << endl;
  
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {

  string S;cin>>S;
  
  int ans=0;
  
  if(S.size()%2==0){
    for(int i=0;i<S.size()/2;i++){
      if(S.at(i)==S.at(S.size()-i-1)){
        ans += 0;
      }
      else{
        ans++;
      }
    }
  }
  
  else if(S.size()%2==1){
    for(int i=0;i<(S.size()-1)/2;i++){
      if(S.at(i)==S.at(S.size()-i-1)){
        ans +=0;
      }
      else{
        ans++;
      }
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
s = input()
if s == "SUN":
    print(7)
if s == "MON":
    print(6)
if s == "TUE":
    print(5)
if s == "WED":
    print(4)
if s == "THU":
    print(3)
if s == "FRI":
    print(2)
if s == "SAT":
    print(1)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define length(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, length(a))cin >> a[i]
#define ccin(i, j, a) rep(i, length(a))rep(j, length(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define sqrtl sqrt
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    intl a,b;
    cin >> a >> b;
    string s[a];
    rep(i,a){
        cin >> s[i];
    }
    rep(i,a){
        cout << s[i] << endl;
        cout << s[i] << endl;
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int answer = -1;
  vector<int> numbers(N);
  
  for (int i = 0; i < N; i++) cin >> numbers.at(i); 
  bool even = true;
  while (even){
    for (int i = 0; i < N; i++){
    if (numbers.at(i)%2 != 0) {
      even = false;
      break;
    }
    else numbers.at(i) /= 2;
    }
    answer++;
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ctype.h>
using namespace std;
 
int main() {
int x,y;
char Xs,Ys;
cin >> x >> y ;
vector<int> A{1,3,7,8,10,12};
vector<int> B {4,6,9,11};
vector<int> C{2};
for(int i=0;i<A.size();i++){
if(x == A.at(i)) Xs = 'A';
if(y == A.at(i)) Ys = 'A';
}
for(int i=0;i<B.size();i++){
if (x == B.at(i)) Xs = 'B';
if(y == B.at(i)) Ys ='B'; 
}
if(x == 2) Xs = 'C';
if(y == 2) Ys = 'C';
if(Xs == Ys)cout << "Yes" << endl;
else cout << "No" << endl;

}


Measured memory_bytes: 256
from math import isfinite
from itertools import dropwhile

n, knapsack = map(int, input().split())
dpn = n * 100  # MAX VALUE
dp = [float('inf')] * (dpn + 1)
dp[0] = 0
for i in range(n):
    value, weight = map(int, input().split())
    for j in range(dpn - value, 0, -1):
        if not isfinite(dp[j]):
            continue
        new_weight = dp[j] + weight
        if new_weight <= knapsack and dp[j + value] > new_weight:
            dp[j + value] = new_weight
    if weight <= knapsack and dp[value] > weight:
        dp[value] = weight

print(next(dropwhile(lambda i: not isfinite(dp[i]), range(dpn, -1, -1))))

Measured memory_bytes: 7852
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int m = sc.nextInt();
    	int x = sc.nextInt();
    	Map<Integer,Rikaido> map = new HashMap<>();
    	map.put(0,new Rikaido(m));
    	int base = 1;
    	int minCost = Integer.MAX_VALUE;
    	for(int i = 0; i < n; i++) {
    		int c = sc.nextInt();
    		int a[] = new int[m];
    		for(int j = 0; j < m; j++) {
    			a[j] = sc.nextInt();
    		}
    		for(int j = 0; j < base; j++){
    			if(map.containsKey(j)){
    				Rikaido rikaido = new Rikaido(map.get(j), a, x, c);
    				if(!rikaido.isOver){
    					map.put(base + j, rikaido);
    				}else{
    					minCost = minCost < rikaido.cost ? minCost : rikaido.cost;
    				}
    			}
    		}
    		base = base * 2;
    	}
    	if(minCost == Integer.MAX_VALUE){
    		minCost = -1;
    	}
    	System.out.println(minCost);
    }
}

class Rikaido{

	int[] rikaido;
	int cost;
	boolean isOver;
	Rikaido(int m){
		rikaido = new int[m];
	}
	Rikaido(Rikaido r, int[] a2, int x, int c){
		int[] a1 = r.rikaido;
		rikaido = new int[a1.length];
		isOver = true;
		for(int i = 0; i < a1.length; i++){
			rikaido[i] = a1[i] + a2[i];
			isOver = isOver && x <= rikaido[i];
		}
		cost = r.cost + c;
	}
}

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

using namespace std;

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < v.size();i++)

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long int;
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int main(){
	int n,m;
	int a,b;
	int ans=0;
	int max=0;
	cin>>n>>m;
	REP(i,m){
		cin>>a>>b;
		if(a<b){
			ans+=b-n;
		}
		if(b-n>max)max=b-n;
	}
	cout<<ans-max<<"\n";
	return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e18+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}

const int N = 1e5+3;
vector<ll> G[N];

ll saiki(int now){
  vector<ll> childs;
  rep(j,G[now].size()){
    int next = G[now][j];
    childs.push_back(saiki(next));
  }
  sort(all(childs));
  reverse(all(childs));
  rep(i,childs.size()){
    childs[i] += i+1;
  }
  sort(all(childs));
  reverse(all(childs));
  if(childs.size() == 0){
    return 0;
  }else{
    return childs[0];
  }
}

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

  ll n;cin>>n;
  reps(i,n-1){
    ll a; cin>>a;
    a--;
    G[a].push_back(i);
  }
  cout<<saiki(0)<<endl;
  return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i,a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll 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;}

int extgcd(int a, int b, int &x, int &y)
{
    int d = a;
    if (b != 0)
    {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    else
    {
        x = 1;
        y = 0;
    }
    return d;
}

int main()
{
    int k;
    cin >> k;
    ll ans=0;
    REP(i,k){
        REP(j,k){
            REP(x,k){
                int c,d;
                int tmp=extgcd(i+1,j+1,c,d);
                tmp = extgcd(tmp, x+1, c, d);
                ans+=tmp;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
import heapq
import sys 
input = sys.stdin.readline

def main():
    q=int(input())
    res = 0

    x=list(map(int,input().split()))
    a=x[1]
    res += x[2]
    asmall = [a*-1]
    alarge = [a]
    heapq.heapify(asmall)
    heapq.heapify(alarge)

    r1 = a
    r2 = a

    for _ in range(q-1):
        x=list(map(int,input().split()))
        if x[0] ==1:
            a = x[1]
            res += x[2]
            if r1 <= a and a <= r2: pass
            else: res += min(abs(a-r1),abs(a-r2))
            mid1 = asmall[0] * -1
            if mid1 > a:
                heapq.heappush(alarge,heapq.heappop(asmall) * -1)
                heapq.heappush(asmall,-a)
                heapq.heappush(asmall,-a)
            else:
                mid2 = alarge[0]
                if mid2 >= a:
                    heapq.heappush(asmall,-a)
                    heapq.heappush(alarge,a)
                else:
                    heapq.heappush(asmall,heapq.heappop(alarge) * -1)
                    heapq.heappush(alarge,a)
                    heapq.heappush(alarge,a)
            r1 = asmall[0] * -1
            r2 = alarge[0]
        if x[0] == 2:
            print(str(r1)+" "+str(res))

main()

Measured memory_bytes: 93272
using System;
using System.Linq;

namespace id_0587cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var countOfCars = int.Parse(Console.ReadLine());
            var maxCountOfCars = countOfCars;
            foreach(var i in Enumerable.Range(0,n))
            {
                var vs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                countOfCars += vs[0] - vs[1];
                if(countOfCars < 0)
                {
                    Console.WriteLine(0);
                    return;
                }
                if(maxCountOfCars < countOfCars)
                {
                    maxCountOfCars = countOfCars;
                }
                
            }
            Console.WriteLine(maxCountOfCars);
        }
    }
}



Measured memory_bytes: 9772
def examC():
    N = I()
    a = LI()
    lower = min(a)
    L = (max(a)-min(a))
    cur = [0]*L
    for i in range(L):
        for j in range(N):
            cur[i] +=(a[j]-(i+lower))**2
    if cur:
        ans = min(cur)
    else:ans = 0
    print(ans)

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()


Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;

#define MAX 200010
#define COL 200010

vector <int> a[MAX];

int sz[MAX];
void sz_dfs(int x, int papa){
  sz[x]=1;
  int nxt;
  for(int i=0; i<a[x].size(); ++i){
    nxt=a[x][i];
    if(nxt!=papa){
      sz_dfs(nxt, x);
      sz[x]+=sz[nxt];
    }
  }
}
int lst[200010], cnt[200010], col[200010];
ll ans[200010], n, nn[200010];
void dfs(int x, int pa){
	int tmp=lst[col[x]];
	lst[col[x]]=x;
	vector<ll> v;
	ll tmp1=0;
	for(int i=0; i<a[x].size(); ++i){
		if(a[x][i]==pa){
			continue;
		}
		dfs(a[x][i], x);
		v.push_back(sz[a[x][i]]-cnt[x]);
		tmp1+=sz[a[x][i]]-cnt[x];
		cnt[x]=0;
	}
	ll tmp2=tmp1;
	v.push_back(nn[col[x]]-tmp1-1);
	tmp1=nn[col[x]];
	for(auto it:v){
		// cout<<x<<" "<<col[x]<<" "<<it<<endl;
		ans[col[x]]+=it*(tmp1-it);
	}
	ans[col[x]]+=tmp1+1;
	lst[col[x]]=tmp;
	cnt[tmp]+=sz[x];
	nn[col[x]]-=tmp2+1;
}
int main(){
  int x, y;
  cin>>n;
  for(int i=1; i<=n; ++i){
    scanf("%d",&col[i]);
    nn[i]=n;
  }
  for(int i=0; i<n-1; ++i){
    scanf("%d%d",&x,&y);
    a[x].push_back(y);
    a[y].push_back(x);
  }
  sz_dfs(1,0);
  dfs(1,0);
  for(int i=1; i<=n; ++i){
  	ans[i]/=2;
    printf("%lld\n",ans[i]);
  }
  return 0;
}


Measured memory_bytes: 48924
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

X,A=MAP()

if X<A:
    print(0)
else:
    print(10)


Measured memory_bytes: 3064
import           Control.Exception           (assert)
import           Control.Monad
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

type Edge = (Int, Int, Int)
eFrm  (frm, _, _)  = frm
eTo   (_, to, _)   = to
eCost (_, _, cost) = cost

longestPath :: Int -> V.Vector (Int, Int, Int) -> Int
  -> IO (V.Vector Int)
longestPath s edges numV = do
  let numE = V.length edges
      inf = 10^18 :: Int

  d <- VM.new numV
  VM.set d (-inf)
  VM.write d s 0

  let loop :: Int -> IO ()
      loop i | i > 2*numV = return ()
             | otherwise = do update <- loop2 (i >= numV) 0 False
                              if update
                                then loop (i+1)
                                else return ()

      loop2 :: Bool -> Int -> Bool -> IO Bool
      loop2 cyc j upd
        | j == V.length edges = return upd
        | otherwise = do
            let e = edges V.! j
            d_frm <- VM.read d (eFrm e)
            d_to  <- VM.read d (eTo e)
            let ucond = d_frm /= (-inf) && d_to < d_frm + eCost e
                upd' = upd || ucond
            when (ucond && not cyc) $
              VM.write d (eTo e) (min inf (d_frm + eCost e))
            when (ucond && cyc) $ VM.write d (eTo e) inf
            loop2 cyc (j+1) upd'

  loop 0
  res <- V.freeze d
  return res

main = do
  [n, m, p] <- getIntList
  edges <- V.replicateM m $ do
    [a, b, c] <- getIntList
    return (a-1, b-1, c-p)

  costs <- longestPath 0 edges n

  let ans = costs V.! (n-1)
      inf = 10^18 :: Int

  print $ if ans == inf then (-1) else (max ans 0)

Measured memory_bytes: 1660
#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 prime[1001001];
bool is_prime[1001001];
int sieve(int n){
    int p = 0;
    for(int i=0; i<=n; i++)is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for(int i=2; i<=n; i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j = 2*i; j<=n; j+=i)is_prime[j] = false;
        }
    }
    return p;
}
ll n, ans = 0;
main(){
    scanf("%lld", &n);
    int x = sieve(1000000);
    for(int i=0; i<x; i++){
        int j = prime[i];
        while(n%prime[i] == 0){
            if(n%j==0){
                n/=j;
                ans++;
                j*=prime[i];
            }else {
                while(n%prime[i] == 0) n/=prime[i];
            }
        }
    }
    if(n>1)ans++;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3020
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> c(n);
    vector<ll> r(n);
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        c[i] = a % b;
        r[i] = b;
    }
    ll ans = 0;
    for (int i = n - 1; i >= 0; --i) {
        ans += (r[i] - (c[i] + ans) % r[i]) % r[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>


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

    ans = k;
    for (int i = 0; i < (n - 1); i++)
    {
	ans = ans * (k - 1);
    }

    printf("%d\n", ans);

    return 0;
}


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

int main() {
	int A, B, count = 0;
	cin >> A >> B;
	for(int i = A; i <= B; i++){
		int n = i, d1, d2, d3, d4, d5;
		for (int j = 0; n; n /= 10)
		{
			if(j == 0) d1 = n % 10;
			else if(j == 1) d2 = n % 10;
			else if(j == 2) d3 = n % 10;
			else if(j == 3) d4 = n % 10;
			else if(j == 4) d5 = n % 10;
			j++;
		}
		if(d1 == d5 && d2 == d4){
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
N,X = map(int,input().split())
L = list(map(int, input().split()))
a = 1
D = [0]*(N+1)
D[0] = 0
for i in range(N):
  D[i+1] = D[i] + L[i]
  if D[i+1] <= X:
    a += 1
print(a)

Measured memory_bytes: 3060
#include <stdio.h>

int main( void )
{
int i;
int j;

for( i = 0; i < 9; i++ )
{
for( j = 0; j < 9; j++ )
{
printf( "%dx%d=%d\n", (i + 1), (j + 1), (i + 1) * (j + 1 ) );
}
}

return (0);
}

Measured memory_bytes: 520
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "limits.h"
#include "bitset"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define ll long long int
#define sp ' '
using namespace std;

int n;
string s;
ll cnt[5];
ll ans;

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	ll g = gcd(x, y);
	return x / g * y;
}

int main(){
	lp(5)
		cnt[i] = 0;
	cin >> n;
	lp(n) {
		cin >> s;
		if (s[0] == 'M')cnt[0]++;
		if (s[0] == 'A')cnt[1]++;
		if (s[0] == 'R')cnt[2]++;
		if (s[0] == 'C')cnt[3]++;
		if (s[0] == 'H')cnt[4]++;

	}
	ans = 0;
	lp(3) {
		for (int j = i + 1; j < 4; j++) {
			for (int k = j + 1; k < 5; k++) {
				ans += cnt[i] * cnt[j] * cnt[k];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int64_t> a(N);
    for(int i=0; i<N; i++) {
        cin >> a[i];
    }

    partial_sum(a.begin(), a.end(), a.begin());

    int64_t ans = INT64_MAX;
    for(int i=0; i<N-1; i++) {
        ans = min(ans, abs(a[N-1] - 2*a[i]));
    }

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


Measured memory_bytes: 1792
import fractions

lst = []
for i in range(200):
    try:
        lst.append(input())
    except EOFError:
        break

nums = [list(map(int, elem.split(' '))) for elem in lst]

# gcd 
res_gcd = [fractions.gcd(num[0], num[1]) for num in nums]

# lcm
res_lcm = [nums[i][0] * nums[i][1] // res_gcd[i] for i in range(len(nums))]

for (a, b) in zip(res_gcd, res_lcm):
    print('{} {}'.format(a, b))

Measured memory_bytes: 10120
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+7;
int dp[3007][3007];
string s,t;
int solve(string s,string t,int n,int m){
    if(n==0||m==0)
        return 0;
    if(s[n-1]==t[m-1])
        return 1+solve(s,t,n-1,m-1);
    else{
        return max(solve(s,t,n-1,m),solve(s,t,n,m-1));
    }
}
int main(){

    //freopen("in","r",stdin);


    cin>>s>>t;
    int n=s.size();
    int m=t.size();

    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(i==0||j==0){
                dp[i][j]=0;
                continue;
            }
            if(s[i-1]==t[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }

    int taille = dp[n][m];
    string ans="";
    int i=n,j=m;
    while(taille>0){
        if(s[i-1]==t[j-1]){
            ans = s[i-1]+ans;
            --i;--j;
            taille--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1]){
                i--;
            }
            else{
                j--;
            }
        }
    }

    cout<<ans;



    return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}

signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,a[200010],All=0;
    cin>>n;
    rep(i,n){
        cin>>a[i];
        All^=a[i];
    }
    rep(i,n){
        if(i==n-1)cout<<(a[i]^All)<<endl;
        else cout<<(a[i]^All)<<" ";
    }
    return 0;
}

Measured memory_bytes: 5208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)


int main(){ 
  int h,w;
  cin >> h >> w;
  vector<string> s(h);

  for(auto &&x:s)cin >> x;

  ll dp[h][w] = {};
  dp[0][0] = s[0][0]=='#';
  FOR(i,0,h){
    FOR(j,0,w){
      if(i+j==0)continue;
      dp[i][j] = 100000000;
      if(i)dp[i][j] = min(dp[i][j],dp[i-1][j] + (s[i][j]=='#' &&s[i-1][j]=='.') );
      if(j)dp[i][j] = min(dp[i][j],dp[i][j-1] + (s[i][j]=='#' &&s[i][j-1]=='.') );
    }
  }

  cout << dp[h-1][w-1] << endl;
}


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

const int maxn = 1e5+5;
int K, N;

struct piece {
    int t,d;
    bool operator <(const piece& rh)const{
        return d>rh.d;
    }
};

piece pieces[maxn];
int choose[maxn];


int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>N>>K;
    set<int> totalt;
    for(int i = 0; i<N; i++){
        cin>>pieces[i].t>>pieces[i].d;
        totalt.insert(pieces[i].t);
    }
    
    int total_t = totalt.size();
    sort(pieces, pieces+N);
    
    ll ans = 0;
    ll dsum = 0;
    
    map<int, int> t_cnt;
    for(int i = 0; i<K; i++){
        t_cnt[pieces[i].t]++;
        choose[i] = 1;
        dsum += pieces[i].d;
    }
    
    ans = dsum + t_cnt.size()*t_cnt.size();
    
    int ti = K-1;
    int t_max = K-1;
    while(t_cnt.size()< total_t&&t_cnt.size()<K&&ti >=0){
        for( ;ti>= 0; ti--){
            if(choose[ti]&&t_cnt[pieces[ti].t]>1)break;
        }
        if(ti == -1 )break;
        choose[ti] = 0;
        t_cnt[pieces[ti].t] --;
        int oldi= ti;
        
        int i = t_max;
        i++;
        while(i<N&&t_cnt[pieces[i].t] != 0){
            i++;
        }
        if(i==N)break;
        t_max = i;
        choose[i] = 1;
        t_cnt[pieces[i].t]++;
        dsum = dsum - pieces[oldi].d + pieces[i].d;
        ans = ans> dsum + t_cnt.size()*t_cnt.size() ? ans:dsum + t_cnt.size()*t_cnt.size();
    }
    cout<<ans<<endl;
    
    return 0;
    
}


Measured memory_bytes: 8320
#include <map>
#include <string>
#include <iostream>
using namespace std;
struct er{
    string gengo;
    int start;
    int end;
};

int main(){
    int N,Q,i,f,t,y;
    string buf;
    map<int,er> mp;
    while(1){
        mp.clear();
        cin >> N >> Q;
        if(!N && !Q){break;}
        for(i=0;i<N;i++){
            cin >> buf >> f >> t;
            struct er e={buf,t-f+1,t};
            mp[t-f+1]=e;
        }
        for(i=0;i<Q;i++){
            cin >> y;
            auto itr=mp.upper_bound(y);
            if(itr!=mp.begin()){
                itr--;
            }
            if(itr->second.start <= y && itr->second.end >= y){
                cout << itr->second.gengo << " " << y-itr->first+1 << endl;
            }
            else{
                cout << "Unknown" <<endl;
            }
        }
    }
    return 0;
}


    



Measured memory_bytes: 3176
n, k = map(int, input().split())
mod = 10**9+7
data = [[] for j in range(n+1)]
done = [0]*(n+1)
colors = [k-1]*(n+1)

for i in range(n-1):
  a, b = map(int, input().split())
  data[min(a,b)].append(max(a,b))
  data[max(a,b)].append(min(a,b))

queue = [1]
ans = 1
colors[1] += 1
for d in data[1]:
  colors[d] += 1
while queue != []:
  idx = queue.pop(0)
  done[idx] = 1
  ans *= colors[idx]
  ans %= mod
  cnt = 0
  for i in range(len(data[idx])):
    if done[data[idx][i]]:
      continue
    cnt += 1
    colors[data[idx][i]] -= cnt
    queue.append(data[idx][i])

print(ans)
  
  

Measured memory_bytes: 31776
#include <iostream>
using namespace std;
int row,col;
char c[10001][10001],a[10001][10001];
int main(){
	int i,j,k,n,l;
	cin>>row>>col;
	for(i=1;i<=row;i++)
	for(j=1;j<=col;j++)cin>>c[i][j];
	for(i=1;i<=row;i++)
	for(j=1;j<=col;j++){
		if(c[i][j]=='.'){
			int s1=0;
			for(k=i-1;k<=i+1;k++)
			for(l=j-1;l<=j+1;l++)
			if(c[k][l]=='#')s1++;
			char p=s1;
			a[i][j]=(char)(s1)+48;
		}
		else a[i][j]='#';
	}
	for(i=1;i<=row;i++){
	    for(j=1;j<=col;j++)cout<<a[i][j];
	    cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 2560
# -*- coding: utf-8 -*-

S = input()
S[:2], S[2:]

def isM(str):
    return 1 <= int(str) <= 12

def isY(str):
    return True

def isYYMM(str):
    YY, MM = str[:2], str[2:]
    return isY(YY) and isM(MM)

def isMMYY(str):
    MM, YY = str[:2], str[2:]
    return isM(MM) and isY(YY)

if isYYMM(S) and isMMYY(S):
    print('AMBIGUOUS')
elif isYYMM(S):
    print('YYMM')
elif isMMYY(S):
    print('MMYY')
else:
    print('NA')


Measured memory_bytes: 38384
import heapq
from fractions import Fraction

n, m = list(map(int, input().split()))

a = list(map(lambda x: Fraction(1, int(x)), input().split()))

heapq.heapify(a)

for i in range(m):
    x = heapq.heappop(a)
    y = Fraction(x.numerator * 2, x.denominator)
    if y.numerator < y.denominator:
        heapq.heappush(a, y)
    elif len(a) == 0:
        break

s = 0


for j in range(len(a)):
    s += int(Fraction(a[j].denominator, a[j].numerator))

print(s)


Measured memory_bytes: 106920
// D - Flipping Signs
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;

	long long sum = 0, minus_count = 0, mini = LLONG_MAX;

	while(N--){
		long long a; cin>>a;
		if(a<0){ a = -a; ++minus_count; }
		mini = min(mini, a);
		sum += a;
	}

	sum -= minus_count%2 * mini*2;
	cout<< sum <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799;


int n;
int a[20], b[20], c[20];

int main(){
  cin >> n;
  int ans = 0;
  rep(i, n) cin >> a[i];
  rep(i, n){
    cin >> b[i];
    ans += b[i];
  }
  rep(i, n-1) cin >> c[i];
  rep(i, n-1){
    if(a[i+1] - a[i] ==1) ans += c[a[i]-1];
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
N=int(input())
A=[0]+list(map(int,input().split()))
B=[0 for i in range(N+1)]
ans=[]
for i in range(1,N+1):
    n=N+1-i
    cnt=0
    
    for j in range(1,2*10**5+1):
        #print(n,n*j)
        if n*j>N:
            break
        else:
            if B[n*j]==1:
                cnt+=1
    if cnt%2!=A[n]%2:
        B[n]=1
        ans.append(n)
ans.sort()
print(len(ans))
print(*ans)
#print(A)
#print(B)

Measured memory_bytes: 14060
a,b,k= map(int,input().split())


a_array = []
b_array = []

for i in range(1,a+1):
    if a % i == 0:
        a_array.append(i)


for i in range(1,b+1):
    if b % i == 0:
        b_array.append(i)


kyou_array = []

for i in a_array:
    if i in b_array:
        kyou_array.append(i)


print(kyou_array[-k])    


Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main(){
  string s;
  cin>>s;
  int len = s.length();
  int s_cnt = 0, del = 0;
  FOR(i,0,len)
  {
    if(s[i]=='S') s_cnt++;
    if(s[i]=='T' && s_cnt>0)
    {
      del += 2;
      s_cnt--;
    }
  }
  printf("%d\n", len-del);
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(i, e) cerr << #i << ' ' << i << e
void debug(auto L, auto R) { while (L < R) cerr << *L << " \n"[L+1==R], ++L; }
#else
#define DE(...) 0
void debug(...) {}
#endif
const int maxn = 300010;
int diff(string a, string b) {
	int res = 0;
	for (int i = 0;i < a.size();++i)
		res += a[i] != b[i];
	return res;
}
signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	string s, t;
	cin >> s >> t;
	int res = s.size();
	for (int i = 0;i + t.size() -1 < s.size(); ++i)
		res = min(res, diff(s.substr(i, t.size()), t));
	cout << res << '\n';

}



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

using namespace std;

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

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

int main() {

    int H, W;
    cin >> H >> W;

    vector<string> S(H);
    for (int i = 0; i < H; i++)cin >> S[i];

    bool ans = true;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '#') {
                bool good = false;
                for (int k = 0; k < 4; k++) {
                    int y = i + dy[k];
                    int x = j + dx[k];
                    if (y >= 0 && y < H && x >= 0 && x < W && S[y][x] == '#') good = true;
                }
//                for (int k = -1; k <= 1; k++) {
//                    for (int l = -1; l <= 1; l++) {
//                        if (k == 0 && l == 0) continue;
//                        int y = i + k;
//                        int x = j + l;
//                        if (y >= 0 && y < H && x >= 0 && x < W && S[y][x] == '#') good = true;
//                    }
//                }
                if (!good) ans = false;
            }
        }
    }

    cout << (ans ? "Yes" : "No") << endl;

}














































Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif
using namespace std;

ll solve() {
    ll N;
    cin >> N;
    auto mat = make_v<ll>(0, N, N);
    for(auto &&v : mat) for(auto &&ele : v) cin >> ele;
    auto dist = mat;
    for(ll k = 0; k < N; k++) for(ll i = 0; i < N; i++) for(ll j = 0; j < N; j++) chmin(dist[i][j], dist[i][k] + dist[k][j]);
    for(ll i = 0; i < N; i++) for(ll j = 0; j < N; j++) if(dist[i][j] != mat[i][j]) return -1;
    V<tuple<ll, ll, ll>> edges;
    for(ll i = 0; i < N; i++) for(ll j = i + 1; j < N; j++) edges.emplace_back(mat[i][j], i, j);
    sort(ALLR(edges));
    ll ans = 0;
    for(auto &&ele : edges) {
        ll cost, f, t;
        tie(cost, f, t) = ele;
        bool ok = false;
        for(ll k = 0; k < N; k++) {
            if(f == k || t == k) continue;
            if(mat[f][k] + mat[k][t] == mat[f][t]) ok = true;
        }
        if(!ok) ans += cost;
    }
    return ans;
}

int main() {
    cout << solve() << endl;
}


Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main() {
    int M1, M2, D1, D2; cin >> M1 >> D1 >> M2 >> D2;
    if (D2 == 1) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,a[100],flag=1;
    
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
        
    for(int i=0;i<n;i++){
        if(!(a[i]%2)){
               if(!(a[i]%3==0||a[i]%5==0)){flag=0;break;}
        }
    }
    
    if(flag){printf("APPROVED\n");}
    else {printf("DENIED\n");}
    
    return 0;
}


Measured memory_bytes: 128
from collections import defaultdict
n, m = map(int, input().split())
ac_set = set()
wa_dic = defaultdict(int)
wa_cnt = 0
for i in range(m):
    p, s = input().split()
    if s == 'AC':
        ac_set.add(p)
    else:
        if p not in ac_set:
            wa_dic[p] += 1
print(len(ac_set), sum(value for key, value in wa_dic.items() if key in ac_set))

Measured memory_bytes: 14312
def main():
    from collections import defaultdict
    from heapq import heappush, heappop
    import sys

    input = sys.stdin.readline

    x, y, z, k = map(int, input().split())
    A = sorted(map(int, input().split()), reverse=True)
    B = sorted(map(int, input().split()), reverse=True)
    C = sorted(map(int, input().split()), reverse=True)

    def calc(p, q, r):
        if p >= x or q >= y or r >= z:
            return 0
        return A[p] + B[q] + C[r]

    h = [(-calc(0, 0, 0), (0, 0, 0))]

    ret = []
    used = defaultdict(bool)
    for _ in range(k):
        v, t = heappop(h)
        ret.append(-v)
        for j in range(3):
            indices = list(t)
            indices[j] += 1
            indices = tuple(indices)
            if used[indices]:
                continue
            used[indices] = True
            heappush(h, (-calc(*indices), indices))

    print(*ret, sep='\n')


main()

# O(KlogK)
# https://img.atcoder.jp/abc123/editorial.pdf


Measured memory_bytes: 53720
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var ima = int.Parse(Console.ReadLine());
            var target = int.Parse(Console.ReadLine());

            Console.WriteLine(target * 2 - ima);
        }
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;
class Main{
  public static void main (String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    
    if(N==M){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21332