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

struct UnionFind{
  vector<int> par;

  UnionFind(int n): par(n){
    for (int i = 0; i < n; i++)
      par[i] = i;
  }

  int root(int n){
    if (par[n] == n)
      return n;
    par[n] = root(par[n]);
    return par[n];
  }

  void unite(int x, int y){
    x = root(x);
    y = root(y);
    if (x == y) return;
    par[x] = y;
  }

  bool same(int x, int y){
    return root(x) == root(y);
  }
};

int main(){
  int n, m;
  cin >> n >> m;
  int p[n];
  for (int i = 0; i < n; i++)
    cin >> p[i];

  int x, y;
  UnionFind tree(n);
  for (int i = 0; i < m; i++){
    cin >> x >> y;
    tree.unite(x - 1, y - 1);
  }
  int answer = 0;
  for (int i = 0; i < n; i++)
    if (tree.same(i, p[i] - 1))
      answer++;
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

using i64=long long;
using vx=vector<i64>;

const i64 MOD=1e9+7;

i64 modpow(i64 b, i64 p, i64 m=MOD) {
    /* Exponentiation by squaring */
    // returns n == b**p (mod m)
    i64 n=1, a=b%m;
    while (p) {
        if (p & 1)
            (n *= a) %= m;

        (a *= a) %= m;
        p >>= 1;
    }
    return n;
}

i64 modinv(i64 a, i64 p=MOD) {
    // returns n == a**-1 (mod p)
    return modpow(a, p-2, p);
}

i64 moddiv(i64 a, i64 b, i64 p=MOD) {
    // returns n == a b**-1 (mod p)
    return a*modpow(b, p-2, p) % p;
}

i64 modsub(i64 a, i64 b, i64 p=MOD) {
    // returns n == a-b (mod p)
    return ((a-b)%p+p) % p;
}

void table_modfact(int n, vx &ftable, int p=1e9+7) {
    // returns {i! mod p; for i in [0, n)}
    ftable.assign(n, 0); ftable[0]=1;

    int ub=min(n, p);
    for (int i=1; i<ub; ++i)
        ftable[i] = (ftable[i-1]*i) % p;
}

void table_modfactinv(int n, vx &itable, i64 factn=-1, i64 p=1e9+7) {
    // returns {i!**-1 mod p; for i in [0, n)}
    itable.assign(n, 0);

    if (n >= p)
        n = p-1;

    if (factn == -1) {
        factn = 1;
        for (int i=1; i<n; ++i)
            factn = (factn*i) % p;
    }
    itable[n-1] = modinv(factn);
    for (int i=n-1; i--;)
        itable[i] = (itable[i+1]*(i+1)) % p;
}

i64 modchoose(i64 n, i64 r, const vx &ftable, const vx &itable, i64 p=MOD) {
    if (n<0 || n<r || r<0) return 0;

    return (ftable[n]*itable[r]%p)*itable[n-r] % p;
}

int main() {
    i64 H, W, A, B;
    scanf("%lld %lld %lld %lld", &H, &W, &A, &B);

    vx ftable; table_modfact(H+W-1, ftable);
    vx itable; table_modfactinv(H+W-1, itable, ftable[H+W-2]);

    i64 res=0;
    for (int i=B; i<W; ++i) {
        i64 former=modchoose(H-A-1+i, i, ftable, itable);
        i64 latter=modchoose(W+A-2-i, A-1, ftable, itable);
        (res += former*latter%MOD) %= MOD;
    }

    printf("%lld\n", res);
    return 0;
}



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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

int main() {
  int a, b;
  cin >> a >> b;

  FOR(i, 1, 10000) {
    int tmp_a = floor(i * 0.08);
    int tmp_b = floor(i * 0.10);
    if (tmp_a == a && tmp_b == b) {
      ANS(i);
      return 0;
    }
  }

  ANS(-1);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

string gets(int n) {
  string s;
  rep(i, 5) {
    char c = (n % 10) + '0';
    s += c;
    n /= 10;
  }
  return s;
}

bool check(string s) {
  rep(i, 3) {
    if (s[i] != s[4 - i]) return false;
  }
  return true;
}

int main() {
  int a, b;
  cin >> a >> b;

  int ans = 0;
  FOR(i, a, b + 1) {
    string s = gets(i);
    if (check(s)) ans++;
  }
  cout << ans << endl;


  
  return 0;
}

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

int main (void){
      
   char s[128];
   char t[128];
   
   scanf("%s", s);
   scanf("%s", t);
    
   int lens = strlen(s);
   int lent = strlen(t);
   //bubble sort
   for(int i = 0; i < lens; i++){

        for(int j = i+1; j < lens; j++){
          
          if(s[i] > s[j]){
            char tmp = s[i];
            s[i] = s[j];
            s[j] = tmp;
          }
             
        }
   }
    
   for(int i = 0; i < lent; i++){

        for(int j = i+1; j < lent; j++){
         
          if(t[i] < t[j]){
            char tmp = t[i];
            t[i] = t[j];
            t[j] = tmp;
          }
             
        }
   }

    if(strcmp(s,t) < 0)    
      printf("Yes");
    else
      printf("No");
   return 0;
    
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mem(v,x) memset(v,x,sizeof(v))
#define N 100005

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n;
	cin>>n;
	double p[n+1];
	double pp = 1;
	double prod[n];
	for(int i=1;i<=n;i++){
        cin>>p[i];
	}
	double dp[n+1][n+1];
	mem(dp, 0);
	dp[0][0] = 1;
	for(int i=1;i<=n;i++){
        dp[i][0] = dp[i-1][0]*(1-p[i]);
	}
	for(int j=1;j<=n;j++){
        for(int i=1;i<=n;i++){
            dp[i][j] = dp[i-1][j]*(1-p[i]) + dp[i-1][j-1]*p[i];
        }
	}
	double ans = 0;
	for(int i=n/2+1;i<=n;i++){
        ans += dp[n][i];
	}
	cout<<setprecision(15)<<ans;
	return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
int N;
const int M=1000001;
int cnt[M];
int gcd(int a,int b){return a?gcd(b%a,a):b;}

main()
{
    cin>>N;
    int g=0;
    bool ok=true;
    for(int i=0;i<N;++i){
        int A;cin>>A;
        g=gcd(g,A);
        ++cnt[A];
    }
    for(int i=2;i<M;++i){
        int s=0;
        for(int j=i;j<M;j+=i)s+=cnt[j];
        if(s>1)ok=false;
    }
    cout<<(ok?"pairwise coprime":g==1?"setwise coprime":"not coprime")<<endl;
}

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

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int main(){
  int N;
  cin >> N;
  long long L[90];
  L[0] = 2;
  L[1] = 1;
  for(int i = 2; i < 90; i++){
    L[i] = L[i-1] + L[i-2];
  }
  cout << L[N] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main( void )
{
    int a;
    int b;
    int area;
    int len;
    
    scanf("%d%d",&a,&b);
    
    area = a*b;
    len = ( a + b ) * 2;
        
    printf("%d %d\n",area,len);
    
    return 0;
}

Measured memory_bytes: 1792
// AOJ 2260: (iwi)
// 2017.10.11 bal4u@uu

#include <stdio.h>
#include <string.h>

char s[12];

int main()
{
	int n, ans;
	char *p, *q;

	scanf("%s", s); n = strlen(s);
	ans = 0; p = s, q = s+n-1;
	while (p < q) {
		if      (*p == '(') { if (*q != ')') ans++; }
		else if (*p == ')') { if (*q != '(') ans++; }
		else                { if (*p != *q)  ans++; }
		p++, q--;
	}
	if (n & 1 && (*p == '(' || *p == ')')) ans++; 
	printf("%d\n", ans);
	return 0;
}

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

int main() {
  vector<int> vec(32);
  vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << vec.at(k-1);
  return 0;
}

Measured memory_bytes: 3632
N = int(input())
s = list(map(int, input().split()))
Q = int(input())
t = list(map(int, input().split()))
count = 0


def b_search(x, y):
    a = 0
    b = len(x)
    if y > x[b-1] or y < x[a]:
        return 0
    while b - a > 1:
        c = (a + b) // 2
        if x[c] == y:
            return 1
        elif y < x[c]:
            b = c
        else:
            a = c
    return 0


for i in range(len(t)):
    count += b_search(s, t[i])

print(count)



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

int main()
{
	int n,ans=0;
	string a,b;
	cin>>a>>n;
	for(int i=0;i<n;i++){
		cin>>b;
		b+=b;
		if(b.find(a)!=string::npos) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1212
#!/user/bin/python
# coding: UTF-8

x, y = map(str, raw_input().split())

def hex(X):
    if X == 'A':
        X = 11
    elif X == 'B':
        X = 12
    elif X == 'C':
        X = 13
    elif X == 'D':
        X = 14
    elif X == 'E':
        X = 15
    elif X == 'F':
        X = 16
    return X

X = hex(x)
Y = hex(y)
if X > Y:
    ans = '>'
elif X == Y:
    ans = '='
elif X < Y:
    ans = '<'

print ans

Measured memory_bytes: 2696
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <math.h>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <string>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <utility>
#include <vector>
#include <stdio.h>
#include <numeric>
#include <array>

using namespace std;

#define REP(i,from,to) for( long long int i = (from); i < (to); i++ )
#define REV(v) for (auto itr = v.rbegin(); itr != v.rend(); itr++)
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define SORT(v) sort( ALL(v) );
#define LAST(v) v[v.size()-1]
#define ZERO(a) memset(a,0,sizeof(a));
#define MINUS(a) memset(a,-1,sizeof(a));
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pi pair<int, int>
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define IIN(a) int a; cin >> a;
#define LIN(a) ll a; cin >> a;
#define SIN(a) string a; cin >> a;
#define VL(v,n) vector<ll> v(n);
#define Read_VL(v,n) vector<ll> v(n);REP(i,0,n)cin>>v[i];
#define sumV(v,n) Vl(acm,n) REP(i,0,n) acm[i] = v[i] + ( i == 0 ? 0 : acm[i - 1]);
#define EPS (1e-10)
#define INF 1000000000000LL

void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}


template <typename ELEMENT_TYPE>
struct _setfillw {
    ELEMENT_TYPE c;
    std::streamsize w;
    _setfillw(ELEMENT_TYPE c, std::streamsize w) : w(w), c(c) {}
};

template <typename ELEMENT_TYPE>
inline _setfillw<ELEMENT_TYPE> setfillw(ELEMENT_TYPE c, std::streamsize w) {
    return _setfillw<ELEMENT_TYPE>(c, w);
}

template <typename ELEMENT_TYPE>
inline std::ostream& operator << (std::ostream& os, const _setfillw<ELEMENT_TYPE>& manip)
{
    return os << std::setw(manip.w) << std::setfill(manip.c);
}

template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		REP(i,0,n)for(auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};


bool length_cmp( string &a, string &b ){
  return a.size() < b.size();
}

ll StoLL( string s )
{
	ll num=0;
  REP( i, 0, s.size() ){
    num = num * 10 + ( s[i] ^ 48 );
  }
  return num;
}

ll CtoLL( char c )
{
	if( 'a' <= c && c <= 'z'){
		return (ll)( c ^ 96 ) ;
	}
	else if( 'A' <= c && c <= 'Z'){
		return (ll)( c ^ 64 );
	}
  return 0;
}

ll MOD=1000000007;
ll dx[4] = { 1, 0, -1, 0 };
ll dy[4] = { 0, 1, 0, -1 };


signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
  LIN(n) Read_VL(arr,n)
  SORT(arr) 
  puta( LAST(arr) - arr[0] );
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
int main()
{
    int h,a,c=0;
    cin>>h>>a;
    while(h>0)
    {
        h=h-a;
        c++;
    }
    cout<<c<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
FO
void solve(){
    ll n,m,ans=0,cur=0,k;
    cin>>n>>m>>k;
    ll A[n+1],B[m+1],fro;
    A[0]=0;B[0]=0;
    for(ll i=1;i<=n;i++){
        cin>>fro;
        A[i]=A[i-1]+fro;
    }
    for(ll i=1;i<=m;i++){
        cin>>fro;
        B[i]=B[i-1]+fro;
    }
    ll j=m;
    for(ll i=0;i<=n;i++){
        if(A[i]>k) continue;
        while(A[i]+B[j]>k) j--;
        ans=max(ans,i+j);
    }
    cout<<ans;
    return;
}
int main(){
    //IO FO
    //TEST
    solve();
    return(0);
}


Measured memory_bytes: 6732
def main():
    s = input()
    K = int(input())
    lst = sorted(set(s))
    ans = []

    def dfs(c):
        if len(ans) < K:
            ans.append(c)
            for li in lst:
                if c + li in s:
                    dfs(c + li)

    for li in lst:
        dfs(li)
    print(ans[-1])
    return


main()


Measured memory_bytes: 3060
function main (input){
	const inputs = input.split(' ');
	const total = inputs.reduce(function (accumulator, currentValue) {
		return Number(accumulator) + Number(currentValue);
	});

	console.log((total < 22)? 'win' : 'bust');
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int ll
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define ll long long
#define pi pair<int,int> 
#define pii pair<pi,int>
#define vi vector<int>
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
const int maxn = 1e5 + 10;
vi v[maxn];
bool vis[maxn];
void dfs(int u){
	vis[u] = 1;
	for(auto x:v[u]){
		if(!vis[x]){
			dfs(x);
		}
	}
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin>>n>>m;
	rep(i,m){
		int x,y;
		cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}
	int c = 0;
	repa(i,1,n+1){
		if(!vis[i]){
			dfs(i);
			c++;
		}
	}
	cout<<c-1;
	return 0;
}

Measured memory_bytes: 10432
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
ll modpow(ll a, ll b)
{
    if (b == 0)
        return 1;
    else if (b % 2 == 0)
    {
        ll d = modpow(a, b / 2) % MOD;
        return (d * d) % MOD;
    }
    else
    {
        return (a * modpow(a, b - 1)) % MOD;
    }
}

const int MAX_N = 100010;

ll fact[MAX_N], finv[MAX_N];
ll comb(int n, int r)
{
    if (n < r || r < 0)
        return 0;
    return fact[n] * finv[n - r] % MOD * finv[r] % MOD;
}

void calc(int n)
{
    fact[0] = finv[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        fact[i] = (fact[i - 1] * i) % MOD;
        finv[i] = modpow(fact[i], MOD - 2);
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    calc(1e5);
    k--;
    V vec(n);
    rep(i,n){
        cin >> vec[i];
    }
    sort(all(vec));
    ll res = 0;
    rep3(i,k,n){
        ll temp = comb(i, k);
        temp*=vec[i];
        temp%=MOD;
       // cout<<i<<" "<<k<<" "<<res<<endl;
        res += temp;
        res %= MOD;
    }
  //  cout<<res<<endl;
    for (int i = 0; n - i - 1 >= k;i++){
        ll temp = comb(n-i-1, k);
        
        temp*=vec[i];
       // cout<<i<<" "<<k<<" "<<temp<<endl;
        temp%=MOD;
        res = (res + MOD - temp) % MOD;
        res %= MOD;
    }
    cout << res << endl;
}


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

int main() {
    std::ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    int H,W;
    cin>>H>>W;
    char s[H][W];
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            cin>>s[i][j];
        }
    }
    int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
    bool ans=true;
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            if (s[i][j]=='#') {
                bool found=false;
                for (int k=0; k<4; k++) {
                    int x=i+dx[k];
                    int y=j+dy[k];
                    if (x>=0&&x<H&&y>=0&&y<W&&s[x][y]=='#') {
                        found=true;
                    }
                }
                if (!found) {
                    ans=false;
                }
            }
        }
    }
    cout<<(ans?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
sum_a = sum(a)

ca = [0 for _ in range(10 ** 5 + 1)]

for i in a:
    ca[i] += 1

q = int(input())
for _ in range(q):
    b, c = map(int, input().split())

    sum_a += (c-b) * ca[b]
    print(sum_a)

    ca[c] += ca[b]
    ca[b] = 0


Measured memory_bytes: 21504
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,d;
  cin>>n>>d;
  vector<int64_t>vec1 (n);
  vector<int64_t>vec2(n);
  int x=0;
  for(int i=0;i<n;i++){
    cin>>vec1.at(i)>>vec2.at(i);
    if (d*d>= (vec1.at(i)*vec1.at(i)) +( vec2.at(i)*vec2.at(i))){
      x+=1;}

  }
  cout<<x<<endl;}


Measured memory_bytes: 6360
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = []
for a in A:
    B.append(-a)

# 最大値を取り出せば良い → プライムキュー
import heapq
heapq.heapify(B)
for i in range(M):
    b = heapq.heappop(B)
    b = -b // 2
    b = -b
    heapq.heappush(B, b)

res = -sum(B)
print(res)

Measured memory_bytes: 73212
#include <atcoder/maxflow>
#include <iostream>
using namespace std; using namespace atcoder;

int main() {
  int n,m; cin>>n>>m;
  mf_graph<int> gr(n*m+2);
  
  string s[n];
  for(int i=0;i<n;i++) cin>>s[i];
  
  for(int i=0;i<n;i++) {
    for(int j=0;j<m-1;j++) {
      if (s[i][j] == '#' || s[i][j+1] == '#') continue;
      if ((i+j)%2 == 0) gr.add_edge(i*m+j,i*m+j+1,1);
      else gr.add_edge(i*m+j+1,i*m+j,1);
    }
  }
  
  for(int i=0;i<n-1;i++) {
    for(int j=0;j<m;j++) {
      if (s[i][j] == '#' || s[i+1][j] == '#') continue;
      if ((i+j)%2 == 0) gr.add_edge(i*m+j,(i+1)*m+j,1);
      else gr.add_edge((i+1)*m+j,i*m+j,1);
    }
  }
  
  for(int i=0;i<n;i++) {
    for(int j=0;j<m;j++) {
      if ((i+j)%2 == 0) gr.add_edge(n*m, i*m+j, 1);
      else gr.add_edge(i*m+j, n*m+1, 1);
    }
  }
  
  cout << gr.flow(n*m, n*m+1) << endl;
  
  auto edges = gr.edges();
  for(auto e : edges) {
    if (e.from == n*m || e.to == n*m+1 || e.flow == 0) continue;
    int x0 = e.from / m;
    int y0 = e.from % m;
    int x1 = e.to / m;
    int y1 = e.to % m;
    
    // 横
    
    if (x0 == x1) {
      //cout<<x0<<" "<<y0<<" "<<x1<<" "<<y1<<endl;
      if (y0<y1) swap(y0,y1);
      //if (y0 < 16)
      s[x0][y0] = '<';
      s[x1][y1] = '>';
    } else {
      if (x0<x1) swap(x0,x1);
      s[x0][y0] = '^';
      s[x1][y1] = 'v';
    }
  }
  
  for(int i=0;i<n;i++) {
    cout<<s[i]<<endl;
  }
}

/*
20 18
#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..
####..####..####..####..####..####..####..####..####..####..
..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#
#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..
####..####..####..####..####..####..####..####..####..####..
..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#
#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..
####..####..####..####..####..####..####..####..####..####..
..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#
#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..
####..####..####..####..####..####..####..####..####..####..
..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#
#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..
####..####..####..####..####..####..####..####..####..####..
..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#
#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..
####..####..####..####..####..####..####..####..####..####..
..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#
*/


Measured memory_bytes: 5660
#include<stdio.h>
#include<math.h>
int main()
{
  int N,D;
  double A;
  scanf("%d %d",&N,&D);
  A = (double)N/(2*D+1);
  int B = A;
  if(B!=A)
  {
    A = round(A+0.5);
  }
  else
  {
    A = B;
  }
  printf("%.f",A);
}

Measured memory_bytes: 128
# https://atcoder.jp/contests/abc045/tasks/arc061_a

s = input()

length = len(s)
if length == 1:
    print(s)
else:
    ans = 0
    for i in range(2 << length - 2):
        temp = []
        for j in range(length):
            t = (i >> j) & 1
            temp.append(s[j])
            if t:
                temp.append('+')
        ans += eval(''.join(temp))
    print(ans)

Measured memory_bytes: 73908
A, B = map(int, input().split())
if A % 2 == 0 and B % 2 == 0:
    print(((B - A) // 2 % 2) ^ B)
elif A % 2 == 0 and B % 2 == 1:
    print(((B - A + 1) // 2 % 2))
elif A % 2 == 1 and B % 2 == 0:
    print(A ^ ((B - A - 1) // 2 % 2) ^ B)
elif A % 2 == 1 and B % 2 == 1:
    print(A ^ ((B - A) // 2 % 2))

Measured memory_bytes: 3064
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
#define db double
int main(){
	db ans=0.0;
	int n,k;
	cin>>n>>k;
	for (int i=1;i<=n;i++){
		int ld=0;
		int t=i;
		while (t<k) t<<=1,ld++;
		db qb=1.0;
		while (ld--) qb/=2.0;
		ans+=qb/(db)(n); 
	}
	printf("%.10lf",ans);
}

Measured memory_bytes: 256
/* Caracal vs Monster */

#include <iostream>
#include <cmath>
using namespace std;

int main(){
  int i=0;
  long long h,cnt=1;
  cin >> h;

  while(1){
    i++;
    if(h==1){
      cout << cnt << endl;
      break;
    }
    else{
      h/=2;
      cnt+=pow(2,i);
    }
  }

}


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

#define int long long
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()

const int mod = 1e9+7;
const int inf = 2e18;

const int maxn = 1e5+5;

vector<int> v[maxn];
int dp[maxn][2];
//0 is black,1 is white

void dfs(int node,int par)
{
	dp[node][0]=1;
	dp[node][1]=1;
	for(int i:v[node])
	{
		if(i==par)continue;
		dfs(i,node);
		dp[node][1] = (dp[node][1]*((dp[i][0]+dp[i][1])%mod))%mod;
		dp[node][0] = (dp[node][0]*(dp[i][1]%mod))%mod;
	}
}

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

	int n;
	cin>>n;
	int m = n-1;	
	while(m--)
	{
		int x,y;
		cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}	
	dfs(1,-1);
	cout<<(dp[1][1]+dp[1][0])%mod<<'\n';
	return 0;
}	

Measured memory_bytes: 14208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 6, MOD = 1e9 + 7;
ll f[N], fi[N];
ll c(ll n, ll k)
{
    return f[n] * fi[k] % MOD * fi[n - k] % MOD;
}
ll inv(ll x)
{
    ll a = x, b = MOD - 2, r = 1;
    for (; b; b >>= 1, a = a * a % MOD)
        if (b & 1)
            r = r * a % MOD;
    return r;
}
int n, sz[N];
vector<int> g[N];
ll dp[N], ans[N];
void dfs(int u, int p)
{
    sz[u] = 1;
    dp[u] = 1;
    for (int v : g[u])
        if (v != p) {
            dfs(v, u);
            sz[u] += sz[v];
            dp[u] = dp[u] * c(sz[u] - 1, sz[v]) % MOD * dp[v] % MOD;
        }
}
void go(int u, int p, ll pw = 1)
{
    ans[u] = dp[u];
    if (u != 1)
        ans[u] = ans[u] * c(n - 1, n - sz[u]) % MOD * pw % MOD;
    for (int v : g[u])
        if (v != p) {
            go(v, u, ans[u] * inv(dp[v] * c(n - 1, sz[v]) % MOD) % MOD);
        }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    f[0] = f[1] = fi[1] = fi[0] = 1;
    for (int i = 2; i < N; ++i)
        f[i] = i * f[i - 1] % MOD;
    for (int i = 2; i < N; ++i)
        fi[i] = (MOD - MOD / i) * fi[MOD % i] % MOD;
    for (int i = 2; i < N; ++i)
        fi[i] = fi[i] * fi[i - 1] % MOD;
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(1, 1);
    go(1, 1);
    for (int i = 1; i <= n; ++i)
        cout << ans[i] << '\n';
}


Measured memory_bytes: 20980
<?php

fscanf(STDIN, "%d", $N);
$w_list = explode(" ", trim(fgets(STDIN)));

$sum1 = 0;
$sum2 = 0;
$m = [];



for ($i = 0; $i < $N; $i++) {
 for ($j = 0; $j <= $i; $j++) {
  $sum1 += $w_list[$j];
 }
 for ($j = $i + 1; $j < $N; $j++) {
  $sum2 += $w_list[$j];
 }
 $m[] = abs($sum1 - $sum2);
 $sum1 = 0;
 $sum2 = 0;
}


echo min($m) . "\n";


Measured memory_bytes: 4856
#include <cstdio>
#include <iostream>
#include <math.h>

using namespace std;

typedef long long ll;

int main(){
	double x,h;
	double sum_pow;
	double height,sum;

	cin >> x >> h;

	while(x != 0 && h != 0){
		sum_pow = (x/2)*(x/2) + h*h;
		height = sqrt(sum_pow);
		sum = x * x + x * height * 2;

		printf("%lf\n",sum);

		cin >> x >> h;
	}

}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

int main(void){
  int n,x;
  cin >> n >> x;
  int ans = 1;
  int boal = 0;
  int l;
  rep(_,n){
    cin >> l;
    boal += l;
    ans += (boal <= x);
  }
  cout << ans << endl;
}

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

class Point {
public:
  Point() {}
  Point(double x, double y, double z) {
    c[0] = x;
    c[1] = y;
    c[2] = z;
  }
  double c[3];
};

class Dist {
public:
  Dist() {}
  Dist(double d, int s2, int t2) {
    dist = d;
    s = s2;
    t = t2;
  }
  double dist;
  int s, t;
};

bool operator < (const Dist& a, const Dist& b) {
  return a.dist < b.dist;
}

double CalcDist(const Point& a, const Point& b) {
  double res = 0;
  for(int i = 0; i < 3; ++i) {
    res += (a.c[i] - b.c[i]) * (a.c[i] - b.c[i]);
  }
  return sqrt(res);
}

std::vector<Dist> dists;
std::vector<std::pair<Point, double> > points;

int n;

int parent[128];

void Init() {
  dists.clear();
  points.clear();
  for(int i = 0; i < 128; ++i) {
    parent[i] = i;
  }
}

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

bool Same(int x, int y) {
  x = Find(x);
  y = Find(y);
  return x == y;
}

void Union(int x, int y) {
  x = Find(x);
  y = Find(y);
  if( x == y ) return;
  if( rand() % 2 ) std::swap(x, y);
  parent[x] = y;                     
}


int main() {
  for(;;) {
    Init();
    scanf("%d", &n);
    if( n == 0 ) break;
    for(int i = 0; i < n; ++i) {
      double x, y, z, r;
      scanf("%lf %lf %lf %lf", &x, &y, &z, &r);
      points.push_back(std::pair<Point, double>(Point(x, y, z), r));
    }
    for(int i = 0; i < n; ++i) {
      for(int j = i + 1; j < n; ++j) {
        double d = CalcDist(points[i].first, points[j].first);
        d = std::max(0.0, d - points[i].second - points[j].second);
        dists.push_back(Dist(d, i, j));
      }
    }
    std::sort(dists.begin(), dists.end());
    double res = 0.0;
    for(int i = 0; i < (int)dists.size(); ++i) {
      int x = dists[i].s;
      int y = dists[i].t;
      double d = dists[i].dist;
      if( Same(x, y) ) continue;
      res += d;
      Union(x, y);
    }    
    printf("%.3lf\n", res);
  }
    
  return 0;
}

Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    short N;
    string S;

    cin >> N;
    cin >> S;

    short counter = 0;

    for(short i=0; i<N-2; i++){
        if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C'){
            counter++;
        }
    }

    cout << counter << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

/**
 * Created by Ayushi on 05 Jul 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        StringTokenizer st;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        st = new StringTokenizer(br.readLine(), " ");
        int n = Integer.parseInt(st.nextToken());
        br.close();
        int m = n % 1000;
        if (m == 0) System.out.println(0);
        else System.out.println(1000 - m);
    }
}


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

int main() {

    string S;

    cin >> S;

    for (int i = 1; i < S.size(); i++)
    {
        if(S[i-1]!=S[i]){
            cout << "Yes" << endl;
            return 0; 
        }
    }

    cout << "No" << endl;
    return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    lint K;
    cin >> K;

    lint m = 0;
    for (int i = 0; i < 1000000; i++) {
        m = (m * 10) % K;
        m = (m + 7) % K;

        if (m == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll N,A,B;
    cin >> N >> A >> B;
    ll count = (N / (A + B)) * A;
    count += min(N % (A + B),A);
    cout << count << endl;


}


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

int main()
{
  	int Num = 0;
	std::cin >> Num;
 	std::vector<int> InCharacter(26,0xFF);

  	for(int i = 0; i< Num;i++)
    {
      std::string str;
      std::cin >> str;
      std::vector<int> Count(26,0);
      for(const auto& ch : str)
      {
        Count[ch-'a']++;
      }
      for(auto chari=0; chari < Count.size();chari++)
      {
        InCharacter[chari] = std::min( InCharacter[chari],Count[chari]);
      }
    }
    char OutputStr = 'a';
	for (auto&& StrNum : InCharacter)
	{
		for (int i = 0; i < StrNum ; i++)
		{
			std::cout << OutputStr;
		}
		OutputStr++;
	}
  
    std::cout <<std::endl;
      
   	return 0;

}

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

int main() {
  int n;
  cin>>n;
  string s;
  cin >> s;
  int ans=0;
  rep(i,n-2){
    if (s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
      ans+=1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from math import factorial, ceil, floor # 階乗/切り上げ/切り捨て
from operator import itemgetter as ig
from collections import defaultdict as dd
# 定数
INF = float("inf")
MOD = int(1e9 + 7)
# 最大公約数 / 最小公倍数
def gcd(v1, v2):
    if v2 == 0:
        return v1
    return gcd(v2, v1 % v2)
def lcm(v1, v2):
    return (v1 // gcd(v1, v2)) * v2

# エントリーポイント
def main():
    A, B, C, D = map(int, input().split())
    def solve(v1, v2, d):
        return B // d - (A - 1) // d
    print((B - A + 1) - (solve(A, B, C) + solve(A, B, D) - solve(A, B, lcm(C, D))))

main()


Measured memory_bytes: 3360
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define mod1 998244353
#define timepass 1073741824
#define MAXN 200000 + 5
#define LOGN 20
#define over ((1ll << 32))
using namespace std;
#define N 2005
 
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define int ll 
#define all(arr) arr.begin() , arr.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i , a , n) for(int i = a ; i < n ; i++)
#define rrep(i , n , a) for (int i = n - 1 ; i >= a ; i--)
#define ms(arr , val) memset(arr , val , sizeof(arr))
#define sp(a , x) cout << fixed << setprecision(a) << x << endl; 
#define siz(temp) (ll)temp.size()
#define len(temp) (ll)temp.length()
#define s(arr) sort(all(arr))
#define r(arr) reverse(all(arr))
#define rs(arr) s(arr) ; r(arr)
#define pi acos(-1)
#define con continue
#define endl "\n"
#define w(q) while(q--)
 
//debug
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace7(a, b, c, d, e, f , g) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<< f << " | "<< #g <<": "<<g<<endl
#define trace8(a, b, c, d, e, f , g , h) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<< f << " | " << #g <<": "<< g <<" | "<<#h<< ": " << h << endl
 
typedef pair<int , int> pii;
typedef pair<int , pii> piii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<piii> vpiii;


signed main()
{
    int n;
    cin >> n;
    int odd = n / 2 + n % 2;
    int even = n - odd;
    ld ans = odd / (n * 1.0);
    cout << fixed << setprecision(9) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<string>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<array>
#include<vector>
#include<cctype>
#include <chrono>
#define long long ll

#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
int main()
{
    int i,j=1,c=2,k=0,n=20,m;
int a;
double s;
 cin>>a;
 s=a+pow(a,2)+pow(a,3);
 cout<<s;

}



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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

char s[50][50];
int h, w;
bool black(int y, int x);
int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    cin >> h >> w;
    rep(i, h)
    {
        rep(j, w)
        {
            cin >> s[i][j];
        }
    }
    vector<bool> flg(h * w, true);
    rep(i, h)
    {
        rep(j, w)
        {
            if (s[i][j] == '#')
            {
                flg[i * w + j] = black(i, j);
            }
        }
    }
    if (count(All(flg), true) == h * w)
    {
        c("Yes");
    }
    else
    {
        c("No");
    }

    return 0;
}
bool black(int y, int x)
{
    bool flg = false;
    for (int dy = -1; dy <= 1; dy += 2)
    {
        int ny = y + dy;
        if (0 <= ny && ny < h)
            if (s[ny][x] == '#')
                flg = true;
    }
    if (flg)
        return flg;
    for (int dx = -1; dx <= 1; dx += 2)
    {
        int nx = x + dx;
        if (0 <= nx && nx < w)
        {
            if (s[y][nx] == '#')
                flg = true;
        }
    }
    return flg;
}

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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    vector<vector<int>> edges(n);
    for(int i = 0; i < m; ++i){
        cin >> a[i] >> b[i];
        --a[i], --b[i];
        edges[a[i]].emplace_back(b[i]);
    }
    
    vector<int> v;
	bitset<1000> bs;
    function<bool(int)> f = [&](int x){
        v.emplace_back(x);
		bs.set(x);
        for(auto& y : edges[x]){
            if(v[0] == y)
                return true;
			if(bs[y])
                continue;
            if(f(y))
                return true;
        }
        v.pop_back();
        return false;
    };
    
    bool fl = false;
    for(int i = 0; i < n; ++i){
		bs.reset();
        if(f(i)){
            fl = true;
            break;
        }
    }
    if(!fl){
        cout << -1 << endl;
        return 0;
    }
    
    auto g = [&](){
        vector<int> idx(n, -1);
        for(int i = 0; i < v.size(); ++i)
            idx[v[i]] = i;
        for(int i = 0; i < m; ++i){
            int ai = idx[a[i]];
            int bi = idx[b[i]];
            if(ai != -1 && bi != -1){
                if(abs(ai - bi) <= 1)
                    continue;
                if(min(ai, bi) == 0 && max(ai, bi) == v.size() - 1)
                    continue;
                vector<int> w;
                if(ai < bi){
                    for(int i = 0; i <= ai; ++i)
                        w.emplace_back(v[i]);
                    for(int i = bi; i < v.size(); ++i)
                        w.emplace_back(v[i]);
                }
                else{
                    for(int i = bi; i <= ai; ++i)
                        w.emplace_back(v[i]);
                }
                v = move(w);
                return true;
            }
        }
        return false;
    };
    
    while(g());
    cout << v.size() << endl;
    for(auto& x : v)
        cout << x + 1 << endl;
    
    return 0;
}



Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ITP1_10_A
{
    class Program
    {
        static void Main(string[] args)
        {
            // 2点間の距離を求めるプログラム
            // 点P1の座標：x1, y1 点P2の座標：x2, y2
            // x1 y1 x2 y2 が1行に与えられる

            // 2点間の距離は三平方の定理で求められる

            double[] cord = (Console.ReadLine().Split(' ').Select(double.Parse).ToArray());
            double x1 = cord[0];
            double y1 = cord[1];
            double x2 = cord[2];
            double y2 = cord[3];

            double ans = System.Math.Sqrt(System.Math.Pow((x2 - x1),2) + System.Math.Pow((y2 - y1),2));
            Console.WriteLine(ans);
        }
    }
}



Measured memory_bytes: 18456
import sys
input = sys.stdin.readline

N,M,C=[int(_) for _ in input().split()]
aB=[int(_) for _ in input().split()]
def sumArr(aB,C,aA):
    if 0 < sum(map(lambda x:x[0]*x[1],zip(aB,aA))) + C  :
        return 1
    else:
        return 0
print(sum(sumArr(aB,C,(int(_) for _ in input().split())) for _ in range(N)))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using node = pair<string,ll>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9+7;

int n;
ll accm[1000100];
ll accc[1000100];
ll mcbegin[1000100];
ll mcend[1000100];

int clamp(int i){
  return min(max(0, i), n+1);
}

int main(void){
  string s;
  cin >> n;
  cin >> s;
  fill(accm, accm + 1000100, 0LL);
  fill(accc, accc + 1000100, 0LL);
  fill(mcbegin, mcbegin + 1000100, 0LL);
  fill(mcend, mcend + 1000100, 0LL);
  for(int i = 1;i <= n;++i){
    accm[i] = accm[i-1];
    mcend[i] = mcend[i-1];
    if(s[i-1] == 'M'){
      accm[i]++;
    }else if(s[i-1] == 'C'){
      mcend[i] += accm[i-1];
    }
  }
  accm[n+1] = accm[n];
  mcend[n+1] = mcend[n];
  for(int i = n;i >= 1;--i){
    accc[i] = accc[i+1];
    mcbegin[i] = mcbegin[i+1];
    if(s[i-1] == 'C'){
      accc[i]++;
    }else if(s[i-1] == 'M'){
      mcbegin[i] += accc[i+1];
    }
  }
  accc[0] = accc[1];
  mcbegin[0] = mcbegin[1];
  ll mc = mcbegin[1];
  int q;
  cin >> q;
  for(int i = 0;i < q;++i){
    int k;
    cin >> k;
    ll res = 0;
    for(int a = 1;a <= n;++a){
      if(s[a-1] == 'D'){
        res +=
          mcbegin[clamp(a+1)]
          + mcend[clamp(a+k-1)]
          + (accm[clamp(a-1)] * accc[clamp(a+k)])
          - mc;
      }
    }
    cout << res << endl;
  }
  return 0;
}


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

using ll = long long; 

int main() {
  string s;
  cin >> s;

  bool YES = false;
  if (s.at(2)==s.at(3)){
    if (s.at(4)==s.at(5)){
      YES = true;
    }
  }

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

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
    int a;
    scanf("%d", &a);
    char str[a];
    scanf("%s", str);
    int flag = 1;
    if(a%2 != 0){
        flag = 0;
    }
    else{
        for(int i = 0, j=a/2;  i<a/2; i++, j++){
            if(str[i] != str[j]){
                flag = 0;
                break;
            }
        }
    }
    
    flag ? printf("Yes\n") : printf("No\n");
    
    return 0;
}

Measured memory_bytes: 1660
#include "bits/stdc++.h"

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

// #define int long long
#define YES "Yes"
#define NO  "No"

using namespace std;

signed main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  bool flag = false;
  int num = 0;

  string s; cin >> s;

  flag = true;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] != s[s.length() - (i + 1)]) flag = false;
  }
  
  // cout << num << endl;
  cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

int main() {
	int N, X, ans;
	int mn = INF;
	scanf("%d %d", &N, &X);
	ans = N;
	for (int i = 1; i <= N; i++) {
		int t;
		scanf("%d", &t);
		X -= t;
		mn = min(mn, t);
	}
	return !printf("%d\n", ans + X / mn);
}

Measured memory_bytes: 256
import sys
N, M = [int(i) for i in sys.stdin.readline().split()]
v = [0] * N
for _ in range(M):
    a, b = map(int, sys.stdin.readline().split())
    v[a - 1] ^= 1
    v[b - 1] ^= 1
print("NO" if 1 in v else "YES")

Measured memory_bytes: 41452