akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

map <int, ll> mp;

void solve(void){
    int N;
    cin >> N;
    rep(N, i) {
        int d; cin >> d;
        mp[d]++;
    }
    ll ans = 0LL;
    for (auto p : mp) {
        if (p.first > p.second) ans += p.second;
        else ans += -p.first + p.second;
    }
    cout << ans << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 6272
f=lambda:map(int,input().split())
n, m = map(int, input().split())
l=list(map(int, input().split()))
t=[1]*n
for _ in range(m):
  a,b = map(int, input().split())
  if l[a-1]<=l[b-1]:
    t[a-1]=0
  if l[b-1]<=l[a-1]:
    t[b-1]=0
print(sum(t))


Measured memory_bytes: 19984
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;

int main(void){
  int a,b;
  cin>>a>>b;
  if(a%3==0||b%3==0||(a+b)%3==0) cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int a = stdIn.nextInt();
    int b = stdIn.nextInt();
    if(n*a<=b) {
      System.out.println(n*a);
    } else {
      System.out.println(b);
    }
  }
  }


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

const int MOD=1e9+7;
int n,ans;
int C[2005][2005];

int main(){
	C[0][0]=1;
	for(int i=1;i<=2000;i++) for(int j=0;j<=i;j++){
		if(j==0||j==i) C[i][j]=1;
		else C[i][j]=(1ll*C[i-1][j]+C[i-1][j-1])%MOD;
	}
	scanf("%d",&n);
	for(int i=1;i*3<=n;i++) ans=(1ll*ans+C[n-i*2-1][i-1])%MOD;
	printf("%d\n",ans);
	return 0;
}

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

int main(){
  int z;
  cin>>z;
  int d=z%10;
  z/=10;
  int c=z%10;
  z/=10;
  int b=z%10;
  z/=10;
  int a=z%10;
  bool t=true;
  if(a+b+c+d==7){
    cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7";
    t=false;
  }
  if(a+b+c-d==7&&t){
    cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7";
    t=false;
  }
  if(a+b-c+d==7&&t){
    cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7";
    t=false;
  }
  if(a-b+c+d==7&&t){
    cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7";
    t=false;
  }
  if(a+b-c-d==7&&t){
    cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7";
    t=false;
  }
  if(a-b+c-d==7&&t){
    cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7";
    t=false;
  }
  if(a-b-c+d==7&&t){
    cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7";
   t=false; 
  }
  if(a-b-c-d==7&&t){
    cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7";
  }
}


Measured memory_bytes: 256
import sys
N,Y=map(int,input().split())

for i in range(N+1):
  for j in range(N+1-i):
    k=N-i-j
    if 10000*i+5000*j+1000*k==Y:
      print(i,j,k)
      sys.exit(0)
else:
  print(-1,-1,-1)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>

using namespace std;

typedef struct {
  int A;
  int B;
} Job;

bool comp(const Job &a, const Job &b) { return a.A < b.A; }

void solve(int N, int M, vector<Job> jobs) {
  priority_queue<int> que;
  int ans = 0;
  int i = 0;
  for (int m = 0; m <= M; m++) {
    while (jobs[i].A <= m && i < N) {
      que.push(jobs[i].B);
      i++;
    }
    if (!que.empty()) {
      int b = que.top();
      que.pop();
      ans += b;
    }
  }
  printf("%d\n", ans);
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<Job> jobs(N);
  for (int i = 0; i < N; i++) {
    int A, B;
    cin >> A >> B;
    Job job = {A, B};
    jobs[i] = job;
  }
  sort(jobs.begin(), jobs.end(), comp);
  solve(N, M, jobs);
  return 0;
}

Measured memory_bytes: 2428
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int main() {
	ll a, b, x;
	cin >> a >> b >> x;
	printf("%lld\n", b / x - (a - 1) / x + (a == 0 && x != 1));
	return 0;
}

Measured memory_bytes: 256
/* atcoder */
#include "bits/stdc++.h"
using namespace std;

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* stringstream */
stringstream ss;
stringstream init_ss; // save default formatting

/* main */
void Main(void)
{
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '?')
        {
            s[i] = 'D';
        }
    }
    cout << s << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();

    return 0;
}


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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

int main() {
	ll n,k,p;
	cin >> n >> k;
	V<double> e;

	REP(i,n) {
		cin >> p;
		e.push_back((p+1)/(double)2);
	}

	double ans = 0;
	double ma = 0;
	int cnt = 0;
	REP(i,n) {
		ans += e[i];
		cnt++;
		if(cnt >= k) {
			ans -= e[i-k];
		}
		if(ma < ans) {
			ma = ans;
		}
	}
	printf("%.7f\n", ma);
}



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

int main() {
	int n, m;

	cin >> n >> m;

	int correct = n - m;

	int t = correct * 100 + m * 1900;

	for (int i = 0; i < m; i++) {
		t *= 2; 
	}
	cout << t  << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  long X, Y;
  cin >> X >> Y;
  vector<long> vc;
  long val = X;
  while (true)
  {
    vc.push_back(val);
    val *= 2;
    if (Y < val)
      break;
  }
  cout << vc.size() << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;



int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code
    int N;
    scanf("%d",&N);
    
    if(N % 2 == 0)
        N /= 2;
    printf("%d",N*2);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

#define OBLONG 0 //長方形
#define RHOMBUS 1 //菱形

struct rectangle
{
	int edge1;
	int edge2;
	int diagonal;
};

void find_rectangle(int edge1, int edge2, int diagonal, int result[]);

main()
{
	int result[2] = {0, 0};
	
	while(1)
	{
		struct rectangle input = {0, 0, 0};
		if(scanf("%d,%d,%d", &input.edge1, &input.edge2, &input.diagonal) == EOF)
		{
			break;
		}
		find_rectangle(input.edge1, input.edge2, input.diagonal, result);
	}
	printf("%d\n%d\n", result[OBLONG], result[RHOMBUS]);
	return 0;
}

void find_rectangle(int edge1, int edge2, int diagonal, int result[])
{
	//printf("edge1 = %d edge2 = %d, diagonal = %d\n", edge1, edge2, diagonal);
	//printf("");
	if(edge1 == edge2)
	{
		result[RHOMBUS]++;
	}
	else if(pow(diagonal, 2) == (pow(edge1, 2) + pow(edge2, 2)))
	{
		result[OBLONG]++;
	}
	return;
}

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

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

#define F first
#define S second
#define make_pair MP

const int MAX = 1e5+9;
const ll MOD = 1e9+7;

int a[205];

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < 2*n; i++)
		cin >> a[i];
	sort(a, a + 2*n);
	int res = 0;
	for (int i = 0; i < 2*n; i+=2)
		res += a[i];
	cout << res << "\n";
}

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

        #define ll long long
        #define pb push_back
        #define printV(v) for(int i=0;i<(int)v.size();i++){cout << v[i]<< " ";} cout << endl
        #define printRev(v) for(int i=(int)v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
        #define sortV(v) sort(v.begin(),v.end())
        #define revV(v) reverse(v.begin(),v.end())
    

        ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,p,q,y;
        string str = "";
        ll mod = 1e9 + 7;
        const int N = 3009;
           
        void solve(){
            cin >> str;
            int sz = str.size();
            if(str[sz-1] == 's') str += "es";
            else str.pb('s');
            cout << str << endl;
        }

      
 
        int main(){
            ios_base::sync_with_stdio(false);

            
         
            int cases = 1;
            //cin >> cases;

            while(cases--) solve();
            return 0;

        }


Measured memory_bytes: 3652
#include <iostream>
using namespace std;
#define rep(i,n) for ( int i = 0; i < (n); ++i)
static const int N = 100;

int main()
{
    int n, u, k, v;
    int M[N][N];


    cin >> n;
    rep(i, n) rep(j, n) M[i][j] = 0;

    rep(i, n){
        cin >> u >> k;
        --u;
        rep(j, k){
            cin >> v;
            --v;
            M[u][v] = 1;
        }
    }

    rep(i, n){
        rep(j, n){
            if(j) cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }

    return 0;

}


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

main()
{
    int n,m; cin>>n>>m;
    vector<int> h(n);
    for(auto &x: h) cin>>x;
    vector<int> vis(n);
    vector g(n,vector<int>());
    for(int i=0; i<m; ++i)
    {
        int a,b; cin>>a>>b; --a,--b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    int ans=0;
    for(int i=0; i<n; ++i)
    {
        int f=1;
        for(int x: g[i]) if(h[x]>=h[i]) f=false;
        ans+=f;
        continue;

        if(vis[i]) continue;
        queue<int> que;
        int nowh=0;
        que.emplace(i);
        vis[i]=1;
        bool flag=true;
        while(!que.empty())
        {
            int f=que.front(); que.pop();
            if(nowh==h[f]) flag=0;
            else if(nowh<h[f])
            {
                flag=1;
                nowh=h[f];
            }

            for(int v: g[f])
            {
                if(vis[v]) continue;
                que.emplace(v);
                vis[v]=1;
            }
        }
        ans+=flag;
    }
    cout << ans << "\n";
}

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

typedef long long ll;

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

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

//入力
int N;
ll a[100010][3];   //幸福度
ll dp[100010][3];  //DPテーブル

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> a[i][j];
        }
    }

    //既に0に初期化済み
    //初期条件も0

    //ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if(j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    //答え
    ll res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 8280
mod = 10**9 + 7
fac = []
pw = []

fac.append(1 % mod)
pw.append(1 % mod)
for i in range(1, 2000):
    fac.append(fac[i-1]*i % mod)

for i in range(1, 1001):
    pw.append(pow(fac[i], mod-2, mod))

n, k = [int(s) for s in input().split()]

print(fac[n+k-1]*pw[n]*pw[k-1] % mod)



Measured memory_bytes: 5628
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

unordered_map<ll, unordered_set<ll>> joint;
unordered_set<ll> scanned;
unordered_map<ll, ll> black;
unordered_map<ll, ll> white;

void rec(ll current) {
  scanned.insert(current);
  ll w = 1;
  ll b = 1;
  for (auto it: joint[current]) {
    if (scanned.count(it)) continue;
    rec(it);
    b *= white[it];
    b %= MOD;
    w *= (black[it] + white[it]);
    w %= MOD;
  }
  black[current] = b;
  white[current] = w;
}

void solve() {
  ll N;
  cin >> N;
  rep (i, N-1) {
    ll x, y;
    cin >> x >> y;
    joint[x].insert(y);
    joint[y].insert(x);
  }
  rec(1);
  ll ans = black[1] + white[1];
  ans %= MOD;
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


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

int main() {
  int X, Y, ans;
  ans =0;
  cin >> X >> Y;
  
  for(int i = 0; i<=X; i++){
    if(4*i+2*(X-i)==Y){
      ans++;
    }
  }
  
  if(ans==0){
    cout << "No" << endl;
  }
  else{cout<<"Yes" << endl;}
}

Measured memory_bytes: 3632
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
ll dist[100010] = {};
vector<lpair> edge[100010];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K;
    cin >> K;
    rep(i,0,K){
        ll after = (i+1) % K;
        edge[i].push_back(make_pair(after, 1));
        after = i * 10 % K;
        edge[i].push_back(make_pair(after, 0));
    }
    fill(dist, dist+K, INF);
    dist[1] = 0;
    priority_queue<lpair, vector<lpair>, greater<lpair> > pq;
    rep(i,0,K) pq.push(make_pair(dist[i], i));
    while(not pq.empty()){
        lpair l1 = pq.top();
        pq.pop();
        if(dist[l1.second] < l1.first) continue;
        for(auto &e: edge[l1.second]) {
            if(dist[e.first] > dist[l1.second] + e.second){
                dist[e.first] = dist[l1.second] + e.second;
                pq.push(make_pair(dist[e.first], e.first));
            }
        }
    }
    print(dist[0] + 1);
    
}

Measured memory_bytes: 14068
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#define mod 1000000007
#define pb push_back
using namespace std;
int main(){
	long long a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k%2==0){ cout<<a-b<<endl;}
	else{cout<<b-a<<endl;}
	return 0;
}

Measured memory_bytes: 768
import collections
from operator import mul
from functools import reduce

def C(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


n = input()
n = int(n)
x = []
for i in range(n):
  l = input()
  x.append(''.join(sorted(l)))

c = collections.Counter(x)
values, counts = zip(*c.most_common())
sum = 0
for i in range(len(counts)):
  if counts[i] > 1:
    sum += C(counts[i], 2)

print(sum)

Measured memory_bytes: 31896
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  ll n,x;cin >> n >> x;
  vector<ll> v(n);
  for (int i=0;i<n;++i){
    cin >> v[i];
  }
  ll out =0;
  for (int i=0;i<n-1;++i){
    if(v[i]+v[i+1]>x){
      out += min(v[i]+v[i+1]-x, v[i+1]);
      v[i+1] -= min(v[i]+v[i+1]-x, v[i+1]);
    }
    if(v[i]+v[i+1]>x){
      out += min(v[i]+v[i+1]-x, v[i]);
      v[i] -= min(v[i]+v[i+1]-x, v[i]);
    }
  }
  cout << out << endl;
  return 0;
}


Measured memory_bytes: 1024
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
n,m = LI()
a = LI()
b = LI()
li = list(set(a)|set(b))
li2 = list(set(a)&set(b))
li.sort()
li2.sort()
print(len(li2),len(li))
for i in li2:
    print(i)
for i in li:
    print(i)
#B

#C

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T



Measured memory_bytes: 41848
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int INF = (int)1e9;
const int N = 2020;
char s[N];
vector<int> g[N];
int dp[N][3];
int n;
int ans = INF;

void dfs(int v, int par) {
	dp[v][0] = dp[v][1] = dp[v][2] = 0;
	if (s[v] == '1')
		dp[v][0]++;
	pii b = mp(0, 0);
	for (int u : g[v]) {
		if (u == par) continue;
		dfs(u, v);
		dp[v][0] += dp[u][0];
		pii t = mp(dp[u][2] + dp[u][0], dp[u][1] + dp[u][0]);
		dp[v][2] += t.first;
		b = max(b, t);
	}
	if (b.second > dp[v][2] - b.first) {
		dp[v][1] = b.second - (dp[v][2] - b.first);
	} else {
		dp[v][1] = dp[v][2] & 1;
	}
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	scanf("%s", s);
	for (int i = 1; i < n; i++) {
		int v, u;
		scanf("%d%d", &v, &u);
		v--;u--;
		g[v].push_back(u);
		g[u].push_back(v);
	}
	for (int v = 0; v < n; v++) {
		dfs(v, -1);
		if (dp[v][1] == 0)
			ans = min(ans, dp[v][2]);
	}
	if (ans == INF)
		printf("-1\n");
	else
		printf("%d\n", ans / 2);

	return 0;
}


Measured memory_bytes: 512
line_list = []

for i in range(3):
    a, b = map(int, input().split())
    line_list.append([a, b])
    line_list.append([b, a])

ans = 'YES'

for now_point in [1, 2, 3, 4]:
    count = 0
    for i in range(len(line_list)):
        if line_list[i][0] == now_point:
            count += 1
    if count == 3:
        ans = 'NO'
        break

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


int main() {
    string s;
    cin >> s;
    char h = s[0];
    int ans = 0;
    for (auto c : s) {
        if (c != h) {
            ans++;
            h = c;
        }
    }
    cout << ans;
}


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

bool is_pallindrome(string s){
      int len = s.size();
      int lwr = 0, upr = len-1;
      while(lwr<=upr){
            if(s[lwr]!=s[upr]){
                  return false;
            }
            lwr++;
            upr--;
      }
      return true;

}

int main(){

      string s;
      cin >> s;
      int n = s.size();
      int one = (n-1)/2;
      int two = (n+3)/2;
      // cout << s.substr(0, one) << " " << s.substr(two-1, (n-5)/2) << endl; 
      if(is_pallindrome(s) and is_pallindrome(s.substr(0, one)) and is_pallindrome(s.substr(two-1, (n-1)/2))){
            cout << "Yes\n";
      }
      else cout << "No\n";
      return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

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

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

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  string s; cin >> s;
  
  if(s.size() == 2) cout << s << endl;
  else{
    reverse(all(s));
    cout << s << endl;
  }
  
  
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int k;
    cin>>k;
    if(k==1)cout<<"ACL"<<endl;
    else if(k==2)cout<<"ACLACL"<<endl;
    else if(k==3)cout<<"ACLACLACL"<<endl;
    else if(k==4)cout<<"ACLACLACLACL"<<endl;
    else if(k==5)cout<<"ACLACLACLACLACL"<<endl;
}


Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())
S = input().strip()
Q = int(input())
n = 1
while n < N:
    n *= 2
T = [0] * (2 * n)

def update(k, a):
    k += n-1
    T[k] = 1 << ord(a) - 97
    while k > 0:
        k = (k - 1) // 2
        T[k] = T[k*2+1] | T[k*2+2]

def query(a, b, k, l, r):
    # print(a, b, k, l, r)
    if r <= a or b <= l:
        # print('  ', set())
        return 0
    if a <= l and r <= b:
        # print('  ', T[k])
        return T[k]
    else:
        vl = query(a, b, k*2+1, l, (l+r)//2)
        vr = query(a, b, k*2+2, (l+r)//2, r)
        return vl | vr

for i in range(N):
    update(i, S[i])

for q in range(Q):
    f, i, c = [x for x in input().strip().split()]
    if f == '1':
        # print(T,T[int(i)-1])
        update(int(i)-1, c)
    elif f == '2':
        # print(int(i)-1, int(c)-1)
        tmp = query(int(i)-1, int(c), 0, 0, n)
        ans = 0
        for i in range(26):
            ans += tmp >> i & 1
         
        print(ans)


Measured memory_bytes: 87368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n, k;
  string s;
  cin >> n >> k >> s;

  vll p(0);
  ll cnt = 1;
  for (ll i = 1; i < n; i++) {
    if (s[i] == s[i - 1]) cnt++;
    else {
      p.push_back(cnt);
      cnt = 1;
    }
    if (i == n - 1) p.push_back(cnt);
  }

  ll m = p.size();
  if (k * 2 <= m - 2) cout << n - (m - k * 2) << endl;
  else cout << n - 1 << endl;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
int vis[200005],a[200005];
vector<int>v;
int main(){
	int n;ll k;
	scanf("%d%llu",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int tmp=1;
	int tot=0;
	while(1){
		if(vis[tmp]) break;
		vis[tmp]=1;
		v.push_back(tmp);
		tmp=a[tmp];
	}
	int sz=v.size();
	for(tot=0;tot<sz;tot++) if(v[tot]==tmp) break;
	if(k<=tot){
		printf("%d\n",v[k]);
		return 0;
	}
	int rot=sz-tot;
	int rmd=(k-tot)%rot+tot;
	printf("%d\n",v[rmd]);
}

Measured memory_bytes: 5912
package main

import (
	"fmt"
	"strings"
)

func main() {
	var N int
	var S string
	fmt.Scan(&N, &S)
	split := strings.Split(S, "")
	count := 0
	for i := 0; i < 1000; i++ {
		targets := strings.Split(fmt.Sprintf("%03d", i), "")
		index := 0
		for j := 0; j < N; j++ {
			if targets[index] == split[j] {
				index++
			}
			if index >= 3 {
				count++
				break
			}
		}
	}

	fmt.Println(count)

}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back  
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
#define int ll    

int cnt[60][60];

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); 
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int pos = -1;
    for (int j = 0; j < SZ(s); j++) {
      if (s[j] == '.') {
        pos = j;
      }
    }
    int add;
    if (pos == -1) {
      add = 9;
    }
    else {
      add = 9 - (SZ(s) - 1 - pos);
    }
    int val = 0;
    for (auto it : s) {
      if (it == '.') {
        continue;
      }
      val = val * 10 + (it - '0');
    }
    for (int j = 0; j < add; j++) {
      val *= 10;
    }
    int cnt2 = 0, cnt5 = 0;
    while (val % 2 == 0) {
      cnt2++;
      val /= 2;
    }
    while (val % 5 == 0) {
      cnt5++;
      val /= 5;
    }
    //cout << cnt2 << ' ' << cnt5 << '\n';
    cnt[cnt2][cnt5]++;
  }
  int ans = 0;
  for (int i = 0; i < 60; i++) {
    for (int j = 0; j < 60; j++) {
      for (int i2 = 0; i2 < 60; i2++) {
        for (int j2 = 0; j2 < 60; j2++) {
          if (i + i2 >= 18 && j + j2 >= 18 && make_pair(i, j) >= make_pair(i2, j2)) {
            if (i == i2 && j == j2) {
              ans += cnt[i][j] * (cnt[i][j] - 1) / 2;
            }
            else {
              ans += cnt[i][j] * cnt[i2][j2];
            }
          }
        }
      }
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3632
S=input()
T=input()

lt=len(T)
ls=len(S)
if ls<lt:f=0
else:
 for i in range(ls-lt,-1,-1):
  f=1
  for s,t in zip(S[i:i+lt],T):
    if s=='?' or s==t: continue
    f=0
  if f:break
print((S[0:i]+T+S[i+lt:ls]).replace('?','a') if f else 'UNRESTORABLE')

Measured memory_bytes: 9108
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		long[] a = new long[N];
		int count4 = 0,count2 = 0;
		for( int i=0; i<N; i++ ){
			a[i] = sc.nextLong();
			if( a[i]%4==0 ){
				count4++;
			}
			if( a[i]%4!=0 && a[i]%2==0 ){
				count2++;
			}
		}
		if( count4>=N/2 ){
			System.out.println("Yes");
		}else if( count2>=N-(count4*2) ){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  ll a,b,k;
  cin>>a>>b>>k;
  ll c=a-k;
  if(c<0){
    b+=c;
    cout<<max(c,0ll)<<" "<<max(b,0ll)<<endl;
  }
  else{
    cout<<c<<" "<<b<<endl;
  }

}

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

using namespace std;

using ll = long long;

const int N = 200200;

ll a[N];
ll b[N];

int main() {
   ios_base::sync_with_stdio(false);
   int n;
   cin >> n;
   for (int i = 0; i < n; ++i) {
      cin >> a[i];
   }
   for (int i = 0; i < n; ++i) {
      cin >> b[i];
   }
   set<pair<ll, int>> st;
   for (int i = 0; i < n; ++i) {
      st.emplace(b[i], i);
   }
   ll ans = 0;
   while (!st.empty()) {
      auto v = *st.rbegin();
      st.erase(v);
      int i = v.second;
      if (b[i] < a[i]) {
         puts("-1");
         return 0;
      }
      if (b[i] == a[i]) {
         continue;
      }
      ll sm = b[(i - 1 + n) % n] + b[(i + 1) % n];
      ll nx = max({a[i] + sm - 1, b[(i - 1 + n) % n], b[(i + 1) % n]});
      ll cnt = (b[i] - nx + sm - 1) / sm;
      ans += cnt;
      b[i] -= sm * cnt;
      if (cnt == 0) {
         puts("-1");
         return 0;
      }
      st.emplace(b[i], i);
   }
   cout << ans << "\n";
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll,ll>
#define pint pair<int,int>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 1000010
#define endl '\n'
#define mp make_pair
#define INF INT_MAX
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define setbits(x) __builtin_popcountll(x)			//counts no of ones in binary representation
#define w(t) 	int t; cin>>t; while(t--)
#define pi 3.141592653589793238
#define sortt(v)  sort(v.begin(),v.end())
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;

int main(){
	fast;
	char c;
	cin>>c;
	if(c>='a'&&c<='z')		cout<<'a';
	else	cout<<'A';
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;

int ball[100010];
bool red[100010];

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

  for(int i=1;i<=N;i++)ball[i] = 1;
  red[1] = true;

  for(int i=0;i<M;i++){
    int x, y;
    cin >> x >> y;

    --ball[x];
    ++ball[y];

    red[y] |= red[x];
    if(ball[x] == 0){
      red[x] = false;
    }
  }

  int res = 0;
  for(int i=1;i<=N;i++){
    if(red[i]){
      ++res;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> v;
    for(int i=1;i<=sqrt(m);i++){
        if(m%i==0){
            v.push_back(make_pair(i,m/i));   
        if(i!=m/i) v.push_back(make_pair(m/i,i));
        }
    } 
    sort(v.begin(),v.end());
  //  for(int i=0;i<v.size();i++)
   // cout<<v[i].first<<" "<<v[i].second<<"    ";
   // cout<<endl;
    for(int i=0;i<v.size();i++){
        if(v[i].first>=n){
            cout<<v[i].second;
            return 0;
        }
    }
}


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

using vi=vector<int>;
using vvi=vector<vi>;
using ll=long long;

int main() {
  string S; cin >>S;
  ll ans=0;
  ll all=1<<(S.size()-1);
  rep(bit,0,all) {
    string temp="";
    rep(i,0,S.size()) {
      temp+=S[i];
      if (bit>>i&1) {
        ans+=stoll(temp);
        temp="";
      }
    }
    ans+=stoll(temp);
  }
  cout <<ans <<endl;
}


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

typedef long long ll;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	} 
	ll sum = 0;
	rep(i, n) {
		sum += a[i];
	}
	set<ll> candidates;
	for(int i = 1; i*i <= sum; i++){
		if(sum % i == 0) {
			candidates.insert(i);
			candidates.insert(sum/i);
		}
	}
	ll ans = 1;
	for(ll x :candidates) {
		ll need;
		{
			vector<ll> r(n);
			rep(i, n) r[i] = a[i]%x;
			sort(r.begin(),r.end());
			ll tot = 0;
			rep(i, n) tot += r[i];
			int l = n - tot /x;
			need = 0;
			rep(i, l) need += r[i];
		}
		if (need <= k) ans = max(ans, x);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int n,k; cin >> n >> k;
    int c = 0;
    while(n != 0){
        c++;
        n/=k;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
#include<queue>
#include<map>
 
using namespace std;

int main(){
    int min = 200000;
    int ans;
    int x, n;
    cin >> x >> n;
    
    if(n == 0){
        cout << x << endl;
        return 0;
    }

    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    sort(p.begin(), p.end());

    int idx = 0;
    for(int i=0;i<102;i++){
        if(p[idx] == i){
            idx++;
            continue;
        }
        if(abs(x-i) < min){
            ans = i;
            min = abs(x-i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void){
	char g[9][9];
	int i , j;
	for(i=0;i<8;i++){
		scanf("%s" , g[i]);
	}
	printf("%d\n", 90);
	for(i=0;i<8;i++){
		for(j=7;j>=0;j--){
			printf("%c" , g[j][i]);
		}
		printf("\n");
	}
	printf("%d\n", 180);
	for(i=7;i>=0;i--){
		for(j=7;j>=0;j--){
			printf("%c" , g[i][j]);
		}
	printf("\n");
	}
		printf("%d\n", 270);
	for(i=7;i>=0;i--){
		for(j=0;j<8;j++){
			printf("%c" , g[j][i]);
		}
	printf("\n");
	}
	return 0;
}

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

using namespace std;

int main() {
    string s1,s2;
    cin >> s1 >> s2;
    reverse(s1.begin(), s1.end());

    if (s1 == s2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

/*
 * pot
 * top
 *
 * pot
 * top
 *
 */

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>

int main(int argc, char* argv[])
{
  int H, W;
  std::vector< std::string > v_grid;

  std::cin >> H >> W;
  for (int i = 0; i < H; i++) {
    std::string str;
    std::cin >> str;
    v_grid.push_back(str);
  }

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

  bool is_able_to = true;
  for (int x = 0; x < W; x++) {
    for (int y = 0; y < H; y++) {
      if (v_grid[y][x] == '#') {
	bool is_ok = false;
	for (int axis = 0; axis < 4; axis++) {
	  if (x+dx[axis] >= 0 &&
	      x+dx[axis] <  W &&
	      y+dy[axis] >= 0 &&
	      y+dy[axis] <  H &&
	      v_grid[y+dy[axis]][x+dx[axis]] == '#') {
	    is_ok = true;
	  }
	}
	if (!is_ok) {
	  is_able_to = false;
	}
      }
    }
  }

  std::cout << (is_able_to ? "Yes" : "No") << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, A, B, C;
  C=0;
  cin >> K >> A >> B;
  string D="NG";
 while(C<1001){
     C+=K;
     if(C>=A && C <=B){D="OK"; break;}
 }
  cout << D << endl;
}

Measured memory_bytes: 3572
<?php
//error_reporting(0);
//$N = explode(" ",trim(fgets(STDIN)));
list($N,$M) = explode(" ",trim(fgets(STDIN)));
/*
for($i=0;$i<$N;$i++) {
  $a[]=array_fill(0,$M,0);
}
for($i=0;$i<$N;$i++) {
  for($j=0;$j<$M;$j++) {
    setflip($i,$j);
  }
}
p();
$res=0;
for($i=0;$i<$N;$i++) {
  $x = array_count_values($a[$i]);
  $res += $x[1];
}
printf("%d\n",$res);
*/
//どちらかが2の場合はすべて表
//それ以外は一番外側のみ表で残る
if ($M ==2 || $N == 2) {
  printf("%d\n",0);
  exit;
}
//どちらかが1の場合
if ($M == 1 || $N == 1) {
  $m = $M - 2;
  $n = $N - 2;
  printf("%d\n",max($m,$n,1));
  exit;
}

printf("%d\n",(($M-2)*($N-2)));

function setflip($i,$j) {
  global $a,$N,$M;
  for($ii=$i-1;$ii<=$i+1;$ii++) {
    for($jj=$j-1;$jj<=$j+1;$jj++) {
      if (!isset($a[$ii][$jj])) continue;
      if ($a[$ii][$jj]==0) {
        $a[$ii][$jj]=1;
      }
      else {
        $a[$ii][$jj]=0;
      }
    }
  }
}
function p() {
  global $a,$N,$M;
  for($i=0;$i<$N;$i++) {
    for($j=0;$j<$M;$j++) {
      printf("%d",$a[$i][$j]);
    }
    printf("\n");
  }
    printf("\n");
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int K,N;
int x[55],y[55];
int sx[55] , sy[55];
const int INF = 1e9 + 7;
LL ans = 4234567890123456789;

int main(){
	cin >> N >> K;
	repp(i,0,N) cin >> x[i] >> y[i];
	repp(i,0,N) sx[i] = sy[i] = i;
	sort(sx,sx+N,[&](const int p , const int q){return x[p] < x[q];});
	sort(sy,sy+N,[&](const int p , const int q){return y[p] < y[q];});
	repp(xi,0,N) repp(xj,xi,N) repp(yi,0,N) repp(yj,yi,N){
		int z = 0;
		repp(p,0,N) if(x[sx[xi]] <= x[p] && x[p] <= x[sx[xj]] && y[sy[yi]] <= y[p] && y[p] <= y[sy[yj]]) ++z;
		if(z >= K) ans = min(ans , (LL)(x[sx[xj]]-x[sx[xi]])*(y[sy[yj]]-y[sy[yi]]));
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define int long long

void solve() {
    int x;
    cin >> x;
    for (int i = -2000; i <= 2000; ++i) {
        int val = i * i * i * i * i + x;
        int l = -2000, r = 2000;
        while (l < r - 1) {
            int m = (l + r) / 2;
            if (m * m * m * m * m <= val) l = m;
            else r = m;
        }
        if (l * l * l * l * l == val) {
            cout << l << ' ' << i;
            return;
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>

int *s;
int *t;

int binarysearch(int key,int n)//見つかれば1,でなければ0を返す
{
	int i=0;
	int left=0,right=n,mid;
	while(left<right){
		mid=(left+right)/2;//中間を求める
		if(s[mid]==key) return 1;
		else if(key<s[mid]) right=mid;//左側なら探索範囲を左側に変更
		else left=mid+1; //右側なら探索範囲を右側に変更
	}
	return 0;
}

int main(void)
{
	int i;
	int n,q;
	int cnt=0;
	scanf("%d",&n);
	s=(int*)malloc(sizeof(int)*n);//s読み込み
	for(i=0;i<n;i++) scanf("%d",&s[i]);
	scanf("%d",&q);
	t=(int*)malloc(sizeof(int)*q);
	for(i=0;i<q;i++) scanf("%d",&t[i]);//t読み込み
	for(i=0;i<q;i++) cnt+=binarysearch(t[i],n);//cntに返り値を加算
	printf("%d\n",cnt);
	free(s);
	free(t);
}


Measured memory_bytes: 2100
import java.util.Scanner;

class Main {

        public static void main(String[] args) {
        
        Scanner scan = new Scanner (System.in);
            
        long n = scan.nextLong();
        long i;
        long d = 1;
        for(i=1;i<=n;i++ ){
        d = d*i;
        }
        System.out.println(d);
       

        }
    }



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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int a, b;
    int ans = 0;
    cin >> a >> b;
    if(a == 1){
        if(b >= a) cout << 1 << endl;
        else cout << 0 << endl;
    }
    else{
        if(b >= a) cout << a << endl;
        else cout << a - 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	Yes(0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h);
	return 0;
}


Measured memory_bytes: 3116