akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#include<fstream>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint()
{
	int x=0,p=1;char c=getchar();
	while (c<=32)c=getchar();
	if(c==45)p=-p,c=getchar();
	while (c>32)x=x*10+c-48,c=getchar();
	return x*p;
}
using namespace std;
//
const int maxn=1e6+100;
int n,m,dis[maxn],cnt,was[maxn],good[maxn],iter[maxn];
vector<int>G[maxn],id[maxn];
vector<pii >g[maxn];
//
int main()
{
	n=getint();m=getint();
	rep(i,m)
	{
		int x=getint()-1,y=getint()-1,z=getint();
		g[x].push_back(mp(z,y));
		g[y].push_back(mp(z,x));
		id[z].push_back(x);
		id[z].push_back(y);
	}
	rep(i,n)sort(g[i].begin(),g[i].end());
	cnt=n;
	memset(was,-1,sizeof(was));
	rep(i,maxn)if(id[i].size())
	{
		rep(j,id[i].size())
		{
			//cout<<j<<endl;
			int x=id[i][j];
			if(was[x]==i)continue;
			was[x]=i;
			int b=0,e=1;
			good[0]=x;
			while(b<e)
			{
				int u=good[b];
				while(iter[u]<g[u].size())
				{
					int to=g[u][iter[u]].second,co=g[u][iter[u]].first;	
			//		cout<<to<<'h'<<endl;
					if(co!=i)break;
					iter[u]++;
					if(was[to]==i)continue;
					good[e]=to;
					was[to]=co;
					e++;
				}
				b++;
			}
			cnt++;
			rep(k,e)
			{
				int x=good[k];
				G[x].push_back(cnt-1);
				G[cnt-1].push_back(x);
			}
		}
	}
	rep(i,maxn)dis[i]=-2;
	int b=0,e=1;
	good[b]=0;
	dis[b]=0;
	while(b<e)
	{
		int u=good[b];
		rep(i,G[u].size())
		{
			int to=G[u][i];
			if(dis[to]==-2)
			{
				dis[to]=dis[u]+1;
				good[e++]=to;
			}
		}
		b++;
	}
	printf("%d\n",dis[n-1]/2);
	return 0;
}


Measured memory_bytes: 103296
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin >> a;
  for(int i=0;i<3;i++){
    if (a[i]=='1'){
      a[i]='9';
    }
    else {
      a[i]='1';
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
N, D = gets.split.map(&:to_i)
X    = N.times.map{ gets.split.map(&:to_i) }

cnt = 0
0.upto(N-1) do | i |
  (i+1).upto(N-1) do | j |
    a = 0
    0.upto(D-1) do | k |
      a += (X[i][k] - X[j][k]).abs ** 2
    end
    cnt += 1 if Math.sqrt(a).to_i ** 2 == a
  end
end
p cnt

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>
#define N 100005
#define F first
#define S second
using namespace std;
typedef pair<int,int> PR;

int n, mx, mi;
bool vt[N];
PR a[N];
vector<PR> gr[N];
queue<PR> qu;

int main() {
	int i, k, no, u, v;
	cin >> n;
	for(i=1; i<=n-1; i++) {
		scanf("%d%d", &u, &v);
		a[i].F = i;
		gr[u].push_back({v, i});
		gr[v].push_back({u, i});
	}
	for(i=1; i<=n; i++) {
		if(gr[i].size() > mx) {
			mx = gr[i].size();
			mi = i;
		}
	}
	qu.push({mi, 0});
	while(!qu.empty()) {
		PR t = qu.front(); qu.pop();
		no = a[t.S].S;
		k = 0;
		for(auto x:gr[t.F]) {
			if(x.S == t.S) continue;
			++k;
			if(k==no) ++k;
			a[x.S].S = k;
			qu.push({x.F, x.S});
		}
	}
	cout << mx << endl;
	for(i=1; i<n; i++) printf("%d\n", a[i].S);
	return 0;
}


Measured memory_bytes: 7424
#define _GLIBCXX_DEBUG
#include <iostream>
using namespace std;

int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    if(a==b && a!=c || b==c && b!=a || c==a && c!=b) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

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

int n, m, ans;
int num[100005], f[100005], x, y;

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
        num[i] = 1;
    }
    f[1] = 1;
    for (int i = 1; i <= m; i++) {
        scanf("%d%d", &x, &y);
        num[x]--, num[y]++;
        if (f[x] == 1) f[y] = 1;
        if (num[x] == 0) f[x] = 0;
    }
    for (int i = 1; i <= n; i++)
        if (f[i]) ans++;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

LL n, k;

void solve() {
  cin >> n >> k;
  double res = 0;
  FOR(i, 1, n+1) {
    LL now = i;
    double p = 1.0/n;
    while(now < k) {
      p /= 2;
      now *= 2;
    }
    res += p;
  }
  printf("%.10f\n", res);
}

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


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

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

    ll ans = 0;
    ll x = 10;
    for (ll i = 0; i < 5; i++) {
        ans += (A[i] + 9) / 10 * 10;
        ll t = A[i] % 10;
        if (t == 0) t = 10;
        x = min(x, t);
    }

    cout << ans - (10 - x) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 1e6;
int a[maxn];
int b[maxn];
int main(void){
	int n;
	cin>>n;
	for(int i = 0;i<n;++i) scanf("%d",a+i);
	for(int i = 0;i<n;++i){
		b[a[i]-1] = i+1;
	}
	for(int i = 0;i<n;++i) cout<<b[i]<<" ";
	return 0;
}

Measured memory_bytes: 5248
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <ext/random>
#include <ext/rope>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  os << '{';
  for (size_t i = 0; i < vec.size(); ++i) {
    os << vec[i];
    if (i != vec.size() - 1) os << ',';
  }
  os << '}';
  return os;
}
template<typename T, typename U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '{' << p.first << " " << p.second << '}';
}
// constant
const int INF = (1<<30) - 1;  // 1.073741823e9
const int64 INF64 = (1LL<<62) - 1;  // 4.611686018427387903e18
const int MOD = 1000000007;

struct Red {
  int x, y;
};

struct Blue {
  int x, y;
};

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

  int n; cin >> n;
  vector<Red> r;
  vector<Blue> b;
  rep(i, n) {
    int a, b; cin >> a >> b;
    r.push_back({a, b});
  }
  rep(i, n) {
    int c, d; cin >> c >> d;
    b.push_back({c, d});
  }

  sort(b.begin(), b.end(), [](const Blue& p, const Blue& q) {
    return p.x < q.x;
  });

  sort(r.begin(), r.end(), [](const Red& p, const Red& q) {
    return p.y > q.y;
  });

  bool used[n] = {};

  int ans = 0;

  rep(i, n) {
    rep(j, n) {
      if (used[j]) continue;
      if (r[j].x < b[i].x && r[j].y < b[i].y) {
        ++ans;
        used[j] = true;
        break;
      }
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MOD 1000000007

using namespace std;

int main() {
    int A,B; cin >> A >> B;
    for (int i = 1; i < 10000; i++)
    {
        double C,D;
        C = floor(i*0.08);
        D = floor(i*0.1);
        if(C == A && D == B){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

def my_sign(x):
    return (x > 0) - (x < 0)

N = I()
a = III()

max_val = 0
max_sign = 0
max_index = -1
for i,a0 in enumerate(a):
    if abs(a0)>max_val:
        max_val = abs(a0)
        max_sign = my_sign(a0)
        max_index = i

if max_sign==0:
    print(0)
elif max_sign==1:
    print(2*N-1)
    for i in range(N):
        print(max_index+1,i+1)
    for i in range(N-1):
        print(i+1,i+2)
else:
    print(2*N-1)
    for i in range(N):
        print(max_index+1,i+1)
    for i in range(1,N)[::-1]:
        print(i+1,i)

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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int s, w; cin >> s >> w;

    if (w >= s) {
        cout << "unsafe" << endl;
    } else {
       cout << "safe" << endl;
    }
    return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				double v = sc.nextDouble();
				double t = v / 9.8;
				double y = 4.9 * t * t;
				int N = 1;
				while(true) {
					if(5 * N - 5 >= y) {
						System.out.println(N);
						break;
					}
					N++;
				}
			}
		}
	}
}



Measured memory_bytes: 27488
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int n,k;
    cin >> n >> k;
    if(k==1){
        cout << 0 << endl;
        return 0;
    }
    cout << n-(k-1) - 1 << endl;


    return 0;
}

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

int n, a[2][100], ans = 0;

int main() {
	cin >> n;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
			if (j != 0) {
				a[i][j] += a[i][j - 1];
			}
		}
	}

	ans = a[0][0] + a[1][n - 1];
	for (int i = 1; i < n; i++) {
		ans = max(ans, a[0][i] + a[1][n - 1] - a[1][i-1]);
		//cout << a[0][i] + a[1][n - 1] - a[1][i-1] << endl;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import sys

def wfs(queue, S, step, goal):
    next_queue = set()
    for q in queue:
        if q == goal:
            return step+1

        i, j = q[0], q[1]
        S[i][j] = '#'

        if S[i+1][j] == '.':
            next_queue.add((i+1, j))
        if S[i-1][j] == '.':
            next_queue.add((i-1, j))
        if S[i][j+1] == '.':
            next_queue.add((i, j+1))
        if S[i][j-1] == '.':
            next_queue.add((i, j-1))

    if len(next_queue) == 0:
        return -1
    else:
        return wfs(next_queue, S, step+1, goal)


def main():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    S = []
    black = 0
    for _ in range(H):
        s = [c for c in input().strip()]
        black += sum([c == '#' for c in s])
        S.append(['#'] + s + ['#'])
    S = [['#'] * (W+2)] + S + [['#'] * (W+2)]
    init = set([(1, 1)])
    minstep = wfs(init, S, 0, (H, W))
    if minstep == -1:
        print(-1)
    else:
        print(H*W - minstep - black)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int r = 0, g = 0, b = 0;
  rep(i,n) {
    if (s[i] == 'R') r++;
    if (s[i] == 'G') g++;
    if (s[i] == 'B') b++;
  }
  ll ans = (ll)r*g*b;
  srep(i,0,n)srep(j,i+1,n) {
    int k = 2*j - i;
    if (!isin(k,j+1,n)) continue;
    if (s[i]!=s[j] && s[j]!=s[k] && s[k]!=s[i]) ans--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
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;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int main()
{
    cin.tie(nullptr);
    //ios::sync_with_stdio(false);


    int N, M;
    cin >> N >> M;

    vi P(M) ,Y(M);
    vi yd[100001];

    REP(i,M) {
        cin >> P[i] >> Y[i];
        yd[P[i]].emplace_back(Y[i]);
    }
    REP(i,N)sort(ALL(yd[i+1]));

    REP(i,M) {
        ll ans = ll(P[i])*1000000+int(lower_bound(ALL(yd[P[i]]), Y[i]) - yd[P[i]].begin())+1;
        string s = to_string(ans);
        while (s.length() != 12){
            if (s.length() > 12) {
                cerr << "TOO LONG ANS" << endl;
                break;
            }
            s = '0'+s;
        }

        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 7808
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt();
      if(k%2==0)
      for(int i = 0;i < k;i+=2){
      	if(a%2==0){
          b = b+a/2;
          a/=2;
        }
        else{
          a--;
          b = b+a/2;
          a/=2;
        }
        if(b%2==0){
          a = a+b/2;
          b/=2;
        }
        else{
          b--;
          a = a+b/2;
          b/=2;
        }
      }
      else{
      for(int i = 0;i < k-1;i+=2){
      	if(a%2==0){
          b = b+a/2;
          a/=2;
        }
        else{
          a--;
          b = b+a/2;
          a/=2;
        }
        if(b%2==0){
          a = a+b/2;
          b/=2;
        }
        else{
          b--;
          a = a+b/2;
          b/=2;
        }
      }
        if(a%2==0){
          b = b+a/2;
          a/=2;
        }
        else{
          a--;
          b = b+a/2;
          a/=2;
        }
      }
      
      System.out.println(a+" "+b);
    }
}


Measured memory_bytes: 21844
#include<cstdio>
#include<algorithm>
using namespace std;
int l[51],dp[51];
int main(void)
{
	int n,MIN,sum,lsum,i,j,k,ans,MAX2,a;
	scanf("%d",&n);
	lsum=0;
	MAX2=0;
	ans=50001;
	for(i=0;i<n;i++){
		scanf("%d",&l[i]);
		lsum+=l[i];
		MAX2=max(MAX2,l[i]);
	}
	for(i=MAX2;i<lsum;i++){
		for(j=0;j<n;j++){
			dp[j]=0;
		}
		sum=0;
		for(j=0;j<n;j++){
			sum+=l[j];
			if(sum>i){
				break;
			}
			dp[j]=sum;
		}
		for(j=0;j<n;j++){
			sum=0;
			for(k=j+1;k<n;k++){
				sum+=l[k];
				if(sum>i){
					break;
				}
				a=min(sum,dp[j]);
				dp[k]=max(a,dp[k]);
			}
		}
		ans=min(ans,i-dp[n-1]);
	}
	printf("%d\n",ans);
	return 0;
}
	


Measured memory_bytes: 2756
n=int(input())
lists=list(map(int,input().split()))
a=sum(lists)//n
b=0
c=0
d=0
for i in range(n):
    b+=(lists[i]-a+1)**2
    c+=(lists[i]-a)**2
    d+=(lists[i]-a-1)**2
print(min(b,c,d))

Measured memory_bytes: 3064
#include <iostream>
#include <array>
#include <string>
#include <vector>
#include <cstdint>

uint32_t
search_this_and_that(uint32_t const a, std::vector<std::string> const& len4words)
{
	using namespace std;

	char const ciphered_t = ('t' - 'a') * a % 26;
	char const ciphered_h = ('h' - 'a') * a % 26;
	char const ciphered_a = ('a' - 'a') * a % 26;
	char const ciphered_i = ('i' - 'a') * a % 26;
	char const ciphered_s = ('s' - 'a') * a % 26;

	for (string const& word : len4words) {
		if ((word[0] + 26 - word[1]) % 26 == (ciphered_t + 26 - ciphered_h) % 26) {
			if (word[0] == word[3] &&
					(word[1] + 26 - word[2]) % 26 == (ciphered_h + 26 - ciphered_a) % 26) {
				return (word[0] - 'a' + 26 - ciphered_t) % 26;
			}
			else if ((word[1] + 26 - word[2]) % 26 == (ciphered_h + 26 - ciphered_i) % 26 &&
					(word[2] + 26 - word[3]) % 26 == (ciphered_i + 26 - ciphered_s) % 26) {
				return (word[0] - 'a' + 26 - ciphered_t) % 26;
			}
		}
	}
	return 26;
}

int main()
{
	using namespace std;

	string input;
	getline(cin, input);
	uint32_t const n = stoul(input);

	for (uint32_t i = 0; i < n; ++i) {
		getline(cin, input);

		vector<string> len4words;
		string::size_type pos = 0;
		string::size_type next_pos = 0;
		while ((next_pos = input.find(' ', pos)) != string::npos) {
			if (next_pos - pos == 4) {
				len4words.push_back(input.substr(pos, 4));
			}
			pos = next_pos + 1;
		}
		if (input.size() - pos == 4) {
			len4words.push_back(input.substr(pos, 4));
		}

		for (uint32_t a = 1; a < 26; a += 2) {
			if (a == 13) {
				continue;
			}

			uint32_t const b = search_this_and_that(a, len4words);
			if (b != 26) {
				std::array<char, 26> ciphered_to_org;
				for (char c = 'a'; c < 'z' + 1; ++c) {
					ciphered_to_org[(a * (c - 'a') + b) % 26] = c;
				}
				for (char c : input) {
					if (c == ' ') {
						cout << c;
					}
					else {
						cout << ciphered_to_org[c - 'a'];
					}
				}
				cout << endl;
				break;
			}
		}
	}
}

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

int main() {
    int a,p;
    cin >> a >> p;
    p += a*3;
    cout << p/2 << endl;
}

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

int main() {
  string sunuke;
  cin>>sunuke;
  for(int i=0;i<sunuke.size(); i++){
    if(sunuke[i]=='1'){
      sunuke[i]='9';
    }
    else{
      sunuke[i]='1';
    }
  }
  cout<< sunuke <<endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
int D[31][31];
int c[510][510];
int cnt[3][31];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, C;
    cin >> N >> C;
    
    
    rep(i, C) rep(j, C) cin >> D[i][j];
    
    rep(i, N) rep(j, N) cin >> c[i][j];
    rep(i, N) rep(j, N) c[i][j]--;
    rep(i, N) {
        rep(j, N) {
            cnt[(i + j) % 3][c[i][j]]++;
        }
    }
    int ans = INF;
    rep(i, C) {
        rep(j, C) {
            rep(k, C) {
                if(i == j || j == k || i == k)continue;
                int cost = 0;
                rep(s, C) {
                    cost += cnt[0][s] * D[s][i];
                    cost += cnt[1][s] * D[s][j];
                    cost += cnt[2][s] * D[s][k];
                }
                //cout << i << " " << j << " " << k << " " << cost << endl;
                ans = min(ans, cost);
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
const int nax=1e3+5;

int main()
{
    ll H,W;
    cin >> H >> W;
    ll dp[nax][nax]={0};
    dp[0][0]=1;
    char v[H][W];
    
    for(int i=0;i<H;++i)
    {
        for(int j=0;j<W;++j)
        {
            cin >> v[i][j];
        }
    }
    
    for(int i=0;i<H;++i)
    {
        if(v[i][0]=='#')
        break;
        else 
        dp[i][0]=1;
    }
    for(int j=0;j<W;++j)
    {
        if(v[0][j]=='#')
        break;
        dp[0][j]=1;
    }
    
    for(int i=1;i<H;++i)
    {
        for(int j=1;j<W;++j)
        {
            if(v[i][j]=='.' )
            dp[i][j]=(dp[i-1][j]+dp[i][j-1]) % mod;
                
        }
    }
    
    cout << dp[H-1][W-1] % mod << endl;
    return 0;
}


Measured memory_bytes: 12492
#pragma comment (linker, "/STACK:526000000")
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()
unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x^(x << 11));
    x = y; y = z; z = w;
    return (w = (w^(w >> 19))^(t^(t >> 8)));
}
void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(100);
}
#define int ll
void solve() {
    int h;
    cin >> h;
    int ans = 0;
    int now = 1;
    while (h != 0) {
        h /= 2;
        ans += now;
        now *= 2LL;
    }
    cout << ans << endl;
    return;
}
#undef int
int main() {
    init();
    solve();
}

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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;

    //a
    ans += (a <= k ? a : k);
    k = max(0, k - a);

    //b
    k = max(0, k - b);

    //c
    ans -= (c <= k ? c : k);

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


Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(10**7)
import math

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

X, Y = map(int, input().split())
x = (-X+2*Y)/3
y = (2*X-Y)/3
if x.is_integer() and y.is_integer() and x>=0 and y>=0:
    x = int(x)
    y = int(y)
    maximam = max(x,y)
    minimam = min(x,y)
    mod = 10**9+7 #出力の制限
    N = x+y
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル
    for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )
    print(cmb(x+y,minimam,mod))
else:
    print(0)

Measured memory_bytes: 118764
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define prique2(T) priority_queue<T>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
const int mod2 = 998244353;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
		fact_memo[i + 1] = ans;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

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

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

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

map<int, int>factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			n /= i;
			ans[i]++;
		}
	}
	if (n != 1) ans[n]++;
	return ans;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

int n, q;
int mp[200020];
int cnt[200020];
vector<int>v[200020];
queue<int>que;
bool used[200020];
signed main() {
	scanf("%lld %lld", &n, &q);
	rep(i, n - 1) {
		int a, b;
		scanf("%lld %lld", &a, &b);
		a--; b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	rep(i, q) {
		int p, x;
		scanf("%lld %lld", &p, &x);
		p--;
		cnt[p] += x;
	}
	que.push(0);
	mp[0] = cnt[0];
	used[0] = true;
	while (!que.empty()) {
		int p = que.front(); que.pop();
		vector<int> k = v[p];
		rep(i, k.size()) {
			if (used[k[i]]) continue;
			mp[k[i]] = mp[p] + cnt[k[i]];
			que.push(k[i]);
			used[k[i]] = true;
		}
	}
	rep(i, n) {
		printf("%lld ", mp[i]);
	}
	printf("\n");
}

Measured memory_bytes: 19796
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int q = Integer.parseInt(br.readLine());
      EzDeque<String> edq = new EzDeque<>(q, "");

      String[] query;
      int op,accessWay,index;
      for ( int i=0; i<q; i++ ){
        query = br.readLine().split(" ");
        op  = Integer.parseInt(query[0]);

        switch( op ) {
          case 0 :
            accessWay = Integer.parseInt(query[1]);
            if ( accessWay == 0 )
              edq.addFirst(query[2]);
            else
              edq.addLast(query[2]);
            break;
          case 1 :
            System.out.println( edq.get(Integer.parseInt(query[1])) );
            break;
          case 2 :
            accessWay = Integer.parseInt(query[1]);
            if ( accessWay == 0 )
              edq.removeFist();
            else
              edq.removeLast();
            break;
          default:
        }
      }
    }
  }
}

class EzDeque<E> {

  private Object[] array;
  private int iHead;
  private int iTail;

  public EzDeque(int size, E init) {
    array = new Object[size*2];
    Arrays.fill(array, init);
    iHead = iTail = size;
  }

  public void addFirst(E val) {
    array[iHead--] = val;
  }
  public void addLast(E val) {
    array[++iTail] = val;
  }
  public void removeFist() {
    iHead++;
  }
  public void removeLast() {
    iTail--;
  }
  @SuppressWarnings("unchecked")
  public E get(int index) {
    index += (iHead+1);
    return ( E ) array[index];
  }
}


Measured memory_bytes: 124248
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<string> ss(4);
    ss[0] = "AC";
    ss[1] = "WA";
    ss[2] = "TLE";
    ss[3] = "RE";
    int n;
    cin >> n;
    vint cnt(4,0);
    REP(i,n){
        string s;
        cin >> s;
        REP(j,4){
            if(s==ss[j])cnt[j]++;
        }
    }
    REP(i,4){
        printf("%s x %d\n", ss[i].c_str(), cnt[i]);
    }

    return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int ss=s.size();
  while(true){
    ss-=2;
    if(s.substr(0,ss/2)==s.substr(ss/2,ss/2)){
      cout<<ss;
      return 0;
    }
  }
}

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

int main() 
{
    string s, t;
    cin >> s >> t;
    
    string ok = "Yes";
    rep(i,s.size()) {
        if (s[i] != t[i]) ok = "No";
    }

    cout << ok << endl;
    return 0;
}


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

typedef long long LL;
const int maxn = 1e5 + 10;
int n;
int a[maxn];

int main(){
	cin >> n;
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	LL ans = 0;
	for(int i = 1; i <= n; i++){
		ans += a[i]/2;
		if((a[i] % 2) && a[i+1]){
			ans++; a[i+1]--;
		}
	}
	return 0*printf("%lld\n", ans);
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
//#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

int n;
mp dat[1005];
int dp[1005];

int main(void){
	for(;;){
		scanf("%d",&n);
		if(n==0)break;
		int s=0,w=0;
		rep(i,n){
			int a,b;
			scanf("%d%d",&a,&b);
			dat[i]=mp(a,b);
			s+=a; w+=b;
		}
		sort(dat,dat+n,greater<mp>());
		int x=dat[0].fir*2-s;
		if(x<=0){
			printf("%d\n",s+w); 
			continue;
		}
		//printf("%d %d %d %d\n",s,w,x,dat[0].fir);
		memset(dp,0,sizeof(dp));
		dp[0]=1;
		reg(i,1,n-1){
			ireg(j,dat[i].sec,x){
				if(dp[j-dat[i].sec]==0)continue;
				dp[j]=1;
			}
		}
		ireg(i,0,x){
			if(dp[i]==1){
				printf("%d\n",s+w+x-i); 
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1040
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int N;
    int A[100];
    double sum = 0;

    cin >> N;

    rep (i, N)
    {
        cin >> A[i];
        sum += (double)1.0 / (double)A[i];
    }

    cout << std::setprecision(10) << (double)1.0 / (double)sum << "\n";

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
int main()
{
    int h, w;
    cin >> h >> w;
    queue<pair<int,int>> next;
    int s[h + 2][w + 2];
    rep(i,h+2){
        rep(j,w+2){
            s[i][j] = -1;
        }
    }
    rep(i, h)
    {
        rep(j, w)
        {
            char c;
            cin >> c;
            if (c == '.')
            {
                s[i + 1][j + 1] = 0;
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= h;i++){
        for (int j = 1; j <= w;j++){
            rep(k, h)
            {
                rep(l, w)
                {
                    if (s[k+1][l+1]!=-1)
                    {
                        s[k + 1][l + 1] = 0;
                    }
                }
            }
            int tmp = 1;
            if(!s[i][j]){
            next.push({i, j});
            s[i][j] = 1;
            while(!next.empty()){
                pair<int, int> now = next.front();
                next.pop();
                if (!s[now.first-1][now.second])
                {
                    s[now.first - 1][now.second] = s[now.first][now.second] + 1;
                    next.push({now.first-1, now.second});
                }
                if (!s[now.first][now.second - 1])
                {

                    s[now.first][now.second - 1] = s[now.first][now.second] + 1;
                    next.push({now.first, now.second - 1});
                }
                if(!s[now.first+1][now.second]){
                    s[now.first + 1][now.second] = s[now.first][now.second] + 1;
                    next.push({now.first + 1, now.second});
                }
                if(!s[now.first][now.second+1]){
                    s[now.first][now.second + 1] = s[now.first][now.second] + 1;
                    next.push({now.first, now.second + 1});
                }
                tmp = max(s[now.first][now.second],tmp);
             }
            }
            ans = max(tmp, ans);
 
        }
    }
    cout << ans-1 << endl;
}

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


int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> s(h,vector<char>(w));
    rep(i,h)rep(j,w) cin >> s[i][j];
    vector<vector<bool>> check(h,vector<bool>(w,false));
    rep(i,h){
        rep(j,w){
            int dx[4]={1,0,-1,0};
            int dy[4]={0,1,0,-1};
            rep(k,4){
                if(i==0 && k==3) continue;
                if(i==h-1 && k==1) continue;
                if(j==0 && k==2) continue;
                if(j==w-1 && k==0) continue;
                if(s[i+dy[k]][j+dx[k]] == '#') check[i][j]=true;
            }
        }
    }
    rep(i,h)rep(j,w) if(s[i][j]=='#' && check[i][j]==false){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<vector>

using namespace std;


int main()
{
    int M1,D1,M2,D2;

    cin >> M1 >> D1 >> M2 >> D2;

    if(D2==1) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}

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

public class Main {
	
	String[][] colorMtr;
	int h;
	int w;
	int k;

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		h = fs.nextInt();
		w = fs.nextInt();
		k = fs.nextInt();
		
		colorMtr = new String[h][];
		for(int i = 0 ;i < h; i++) {
			colorMtr[i] = fs.next().split("");
		}
		
		int hPattern = pow(2, h);
		int wPattern = pow(2, w);
		
		int ans = 0;
		
		for(int i = 0; i < hPattern; i++) {
			for(int j = 0; j < wPattern; j++) {
				if(judge(i,j)) {
					ans++;
				}
			}
		}
		
		System.out.println(ans);
	}
	
	
	boolean judge(int hPattern, int wPattern) {
		
		int[] hBitArr = new int[h];
		int[] wBitArr = new int[w];
		
		for(int i = 0; i < h; i++) {
			if(((hPattern >> i) & 1) == 1) {
				hBitArr[i] = 1;
			}
		}
		
		for(int i = 0;i < w; i++) {
			if(((wPattern >> i) & 1) == 1) {
				wBitArr[i] = 1;
			}
		}
		
		int black = 0;
		
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				if(hBitArr[i] == 1 || wBitArr[j] == 1) {
					continue;
				}
				
				if(colorMtr[i][j].equals("#")) {
					black++;
				}
			}
		}
		
		if(black == k) {
			return true;
		}else {
			return false;
		}
	}

	public int pow(int base, int n) {
		int retVal = 1;
		while (n > 0) {
			if ((n & 1) == 1) {
				retVal *= base;
			}
			n >>= 1;
			base *= base;
		}
		return retVal;
	}
	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 33924
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    try (Scanner scanner = new Scanner(System.in)) {
      int n = scanner.nextInt();
      List<Long> lists = new ArrayList<>();
      for (int i = 0; i < n; i++) {
        lists.add(scanner.nextLong());
      }
      long min = lists.stream().mapToLong(Main::toInt).min().getAsLong();
      long max = lists.stream().mapToLong(Main::toInt).max().getAsLong();
      long sum = lists.stream().mapToLong(Main::toInt).sum();
      System.out.printf("%d %d %d\n", min, max, sum);
    }
  }

  private static long toInt(Long integer) {
    return integer;
  }
}

Measured memory_bytes: 45220
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

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

int N;
string ans;

int N2;
int FN = 0;

int main() {
  cin >> N;
  
  N2 = N;
  while (N2 != 0) {
    FN += N2%10;
    N2 /= 10;
  }

  if (N%FN == 0) {
    ans = "Yes";
  } else {
    ans = "No";
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>
#include <queue>
 

using namespace std;

int main() {
    int x, n;
    cin>>x>>n;
    vector<int> a(n);

    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    int q=1e9, w=1e9;
    for(int e=0;e<100;e++){
        int ans1=0;
        for(int j=0; j<n; j++){
            if((x+e)!=a[j]){
                ans1++;
            }
        }
        if(ans1==n){
            q=x+e;
            break;
        }
    }
    for(int e=0; e<100; e++){
        int ans2=0;
        for(int j=0; j<n; j++){
            if((x-e)!=a[j]){
                ans2++;
            }
        }
        if(ans2==n){
            w=x-e;
            break;
        }
    }
    if((q-x)<(x-w)){
        cout<<q<<endl;
    }
    else cout<<w<<endl;

    return 0;
 }

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005

void solve(){
    char s;
    cin >> s;
    if(isupper(s)){
        cout << "A";
    }
    else{
        cout << "a";
    }
}




int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);

        int tt;
        tt=1;
    //    cin >> tt;
        while(tt--){
            solve();
        }
        

}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD=1000000007;

int main() {
    int N,M; cin>>N>>M;
    vector<vector<int>> A(N+1);
    for(int i=0;i<M;i++){
        int a,b; cin>>a>>b;
        A[a-1].push_back(b-1);
        A[b-1].push_back(a-1);
    }
    queue<int> que;
    que.push(0);
    vector<int> count(N,-1);
    count[0]=0;
    while(!que.empty()){
        int x=que.front();
        que.pop();
        for (auto itr:A[x]) {
            if(count[itr]==-1) {
                que.push(itr);
                count[itr] = count[x] + 1;
            }
        }
    }
    if(count[N-1]==2){
        cout<<"POSSIBLE";
    }
    else{
        cout<<"IMPOSSIBLE";
    }
    return 0;
}

Measured memory_bytes: 13936