akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

int a[MAXN], b[MAXN];

void read(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		b[i] = a[i];
	}
}

void solve(){
	sort(b + 1, b + n + 1);
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		int p = lower_bound(b+1, b+n+1, a[i]) - b;
	//	cout<<i<<' '<<p<<endl;
		if ((p & 1) ^ (i & 1)) cnt++;
	}
	cout<<cnt/2<<endl;
}


void printans(){

}
	

int main(){
	int T = 1;
//	cin>>T;
	while(T--){
		read();
		solve();
		printans();
	}
	return 0;
} 


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <string>
#include <stdexcept>
#include <set>

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define phb push_back
#define ppb pop_back
using namespace std;

int N;
string D[20];
vector< string > S;

vector< string > t;
vector< int > mtc, res;
int tbl[128], clv[128];

bool read();
void solve();

void dfs(int);

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

bool read() {
	string str, ln;
	istringstream iss;
	
	getline(cin, ln), iss.clear(), iss.str(ln);
	if (iss >> N, N == 0)
		return false;
	
	for (int i = 0; i < N; ++i)
		getline(cin, D[i]);
	
	getline(cin, ln), ln.back() = ' ', iss.clear(), iss.str(ln);
	S.clear();
	while (iss >> str)
		S.phb(str);
	
	return true;
}

void solve() {
	t.clear();
	for (int i = 0; i < sz(S); ++i)
		if (find(all(t), S[i]) == t.end())
			t.phb(S[i]);
	
	auto cmpf = [&] (const string &ra, const string &rb) -> bool {
		set< char > sa, sb;
		
		for (int i = 0; i < sz(ra); ++i)
			sa.insert(ra[i]);
		for (int i = 0; i < sz(rb); ++i)
			sb.insert(rb[i]);
		
		return sz(sa) > sz(sb);
	};
	
	sort(&D[0], &D[N], cmpf);
	sort(all(t), cmpf);
	
	fill(&tbl[0], &tbl[128], 0);
	fill(&clv[0], &clv[128], -1);
	mtc.clear(), res.clear();
	
	try {
		dfs(0);
		for (int i = 0; i < sz(S); ++i) {
			int k = int(find(all(t), S[i]) - t.begin());
			cout << D[res[k]] << (i + 1 == sz(S) ? "." : " ");
		}
	}
	catch (...) {
		cout << "-.";
	}
	cout << "\n";
}

void dfs(int u) {
	if (u == sz(t)) {
		if (!res.empty())
			throw exception();
		res = mtc;
	}
	else {
		for (int i = 0; i < N; ++i)
			if (sz(D[i]) == sz(t[u])) {
				int j = 0, c1, c2;
				
				while (j < sz(D[i])) {
					c1 = int(D[i][j]), c2 = int(t[u][j]);
					if ((tbl[c1] != 0 && tbl[c1] != c2) || (tbl[c2] != 0 && tbl[c2] != c1))
						break;
					if (tbl[c1] == 0)
						tbl[c1] = c2, tbl[c2] = c1, clv[c1] = clv[c2] = u;
					++j;
				}
				
				if (j == sz(D[i])) {
					mtc.phb(i);
					dfs(u + 1);
					mtc.ppb();
				}
				
				while ((--j) >= 0) {
					c1 = int(D[i][j]), c2 = int(t[u][j]);
					if (clv[c1] == u)
						tbl[c1] = tbl[c2] = 0, clv[c1] = clv[c2] = -1;
				}
			}
	}
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
using namespace std;
int main () {
 int N,M,C;cin>>N>>M>>C;
 vector <int>B(M);
   for ( int i = 0; i < M ; ++ i ) {
     cin >> B [ i ];
   }
 vector <vector <int>> A(N,vector <int>(M));
   for(int i=0;i<N;i++){
     for(int j=0;j<M;j++){
        cin>>A[i][j];
     }
   }
 int count=0;
 for(int i=0;i<N;i++){
   int X=0;
    for(int j=0;j<M;j++){
       X+=A[i][j]*B[j];
    }
   if(X+C>0){
     count++;
   }
 }
  cout<<count<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long int64;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second

signed main(){
    lint N; cin>>N;
    vector<lint> V(N);
    vector<lint> C(N);
    REP(i, N) cin>>V[i];
    REP(i, N) cin>>C[i];
    vector<lint> A(N);
    REP(i, N) A[i] = V[i]-C[i];
    lint res = 0;
    REP(i, N){
        if(A[i]>0) res += A[i];
    }
    cout << res <<endl;
    return 0;
}

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

int asort(const void *A,const void *B){
    return *(long long*)A>*(long long*)B?1:0;
}

int main(void){
    long long n;
    scanf("%lld",&n);
    long long d[n];
    for (int i=0; i<n; i++){
        scanf("%lld",&d[i]);
    }
    qsort (d,n,sizeof(long long),asort);
    printf("%lld\n",d[n/2]-d[n/2-1]);
    return 0;
}

Measured memory_bytes: 1788
object Main extends App {
  import scala.collection.mutable
  val n: Int = io.StdIn.readLine().toInt
  val buf: mutable.ArrayBuffer[Int] = mutable.ArrayBuffer.empty[Int]
  val (x, len) = ((0,0) /: io.StdIn.readLine()){(n, c) =>
    if (c == ' ') {buf += n._1; (0, if (n._1 > n._2) n._1 else n._2)}
    else (n._1*10 + c.toInt-48, n._2)
  }
  val arr: Array[Int] = (buf += x).toArray
  val count: Array[Int] = Array.fill(len+1)(0)
  val result: Array[Int] = Array.fill(n)(0)

  for (i <- arr) count(i) += 1
  for (i <- 1 until count.length) count(i) += count(i-1)
  for (i <- n-1 to 0 by -1) {
    result(count(arr(i))-1) = arr(i)
    count(arr(i)) -= 1
  }

  println(result.mkString(" "))
}

Measured memory_bytes: 496224
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define ordered_set                            \
    tree<ll, null_type, less<ll>, rb_tree_tag, \
         tree_order_statistics_node_update>

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n, m;
    cin >> n >> m;

    ll ans = ((n) * (n - 1)) / 2;
    ans += ((m) * (m - 1)) / 2;

    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
	 int N;
     cin>>N;

     cout<<N*800-N/15*200<<endl;
}

Measured memory_bytes: 3556
/*
[abc128] C - Switches
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_M = 10;

int N, M;
int s[MAX_M];
int p[MAX_M];

bool can(int pat) {
    for (int i = 0; i < M; i++) {
        int b = pat & s[i];
        int cnt = 0;
        for (int j = 0; j < N; j++) {
            if (b & (1 << j)) {
                cnt++;
            }
        }
        if (cnt % 2 != p[i]) {
            return false;
        }
    }

    return true;
}

ll solve() {
    int ans = 0;
    for (int pat = 0; pat < (1 << N); pat++) {
        if (can(pat)) {
            ans++;
        }
    }

    return ans;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int sij;
            cin >> sij;
            s[i] = s[i] | (1 << (sij - 1));
        }
    }
    for (int i = 0; i < M; i++) {
        cin >> p[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cassert>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    string s, t;
    cin >> s >> t;

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

    vector<int> sa(n + 1), sb(n + 1);
    vector<int> ta(n + 1), tb(n + 1);

    rep(i, n){
        sa[i + 1] = s[i] == 'A';
        sb[i + 1] = s[i] == 'B';
        sa[i + 1] += sa[i];
        sb[i + 1] += sb[i];
    }

    rep(i, m){
        ta[i + 1] = t[i] == 'A';
        tb[i + 1] = t[i] == 'B';
        ta[i + 1] += ta[i];
        tb[i + 1] += tb[i];
    }

    int q;
    cin >> q;
    vector<bool> ans;

    while(q--){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        --a;
        --c;
        int tsa = sa[b] - sa[a];
        int tsb = sb[b] - sb[a];
        int tta = ta[d] - ta[c];
        int ttb = tb[d] - tb[c];
        int ms = ((tsa - tsb) % 3 + 3) % 3;
        int mt = ((tta - ttb) % 3 + 3) % 3;
        ans.emplace_back(ms == mt);
    }

    rep(i, ans.size()){
        if(ans[i]){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2512
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    string S,T;
    cin >> S >> T;
    ll min_num = INF;
    for(size_t i=0;i<=S.size() - T.size(); i++)
    {
        string s = S.substr(i, T.size());
        cerr << s << endl;
        ll count = 0;
        for(size_t j=0;j<T.size(); j++)
        {
            if(s[j] == T[j]) count++;
        }
        min_num = min(min_num, ll(T.size() - count));
    }
    cout << min_num << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int a,b,c,k;
int ans;
int main(){
	cin>>a>>b>>c>>k;
	if(k<=a){
		cout<<k<<endl;
		return 0;
	}
	if(k>=a)k-=a,ans+=a;
	if(k<=b){
		cout<<ans<<endl;
		return 0;
	}
	else k-=b;
	cout<<ans-k<<endl;
	return 0;
}

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

#define ll long long
#define all(it) it.begin(), it.end()
#define FOR(i, n) for(int i = 0; i < n; i++)
#define FORU(i, a, b, s) for(int i = a; i < b; i += s)
#define FORD(i, a, b, s) for(int i = a; i > b; i -= s)
#define endl "\n"
ll INF = 2e18;
ll MOD = 1e9 + 7;

int i, j, k, t;

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

    unordered_set<int> m;
    FOR(i, N) {
        cin >> t;
        if(m.find(t) == m.end()) {
            m.insert(t);
        } else {
            m.erase(t);
        }
    }
    cout << distance(all(m)) << endl;
}

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

using namespace std;

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

    int n, k;
    cin >> n >> k;

    vector<int> prices;
    for (int i = 0; i < n; i ++) {
        int t;
        cin >> t;
        prices.push_back(t);
    }

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

    int summ = 0;
    for (int i = 0; i < k; i ++)
        summ += prices[i];
    
    cout << summ;
    return 0;
}

Measured memory_bytes: 3656
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

struct state {
	int s;
	string r;
	vi n;
	state(int s, string r, vi n) : s(s), r(r), n(n) {};
	bool operator<(const state &o)const {
		return s<o.s;
	}
};

int main() {
	int t;
	string num;
	
	while(cin >> t >> num, t) {
		stack<state> S;
		S.push(state(0, num, vi()));
		vector<state> res;
		while(!S.empty()) {
			state st = S.top();
			S.pop();

			if(t < st.s) {
				continue;
			}
			
			if(st.r.size() == 0) {
				res.push_back(st);
				continue;
			}

			int size = st.r.size();
			//if(st.r[0] == '0') {
			//	vi nn = st.n;
			//	nn.push_back(0);
			//	S.push(state(st.s, st.r.substr(1, size), nn));
			//	continue;
			//} else {
				FOR(i, 1, size) {
					vi nn = st.n;
					string nr = st.r.substr(i);
					int ns = st.s + toInt(st.r.substr(0, i));
					nn.push_back(toInt(st.r.substr(0, i)));
					S.push(state(ns, nr, nn));
				}
			//}
		}

		sort(RALL(res));
		if(res.size() == 0) {
			cout << "error" << endl;
		} else if(res.size() > 1 && res[0].s == res[1].s) {
			cout << "rejected" << endl;
		} else {
			cout << res[0].s;
			REP(i, res[0].n.size()) {
				cout << " " << res[0].n[i];
			}
			cout << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1268
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()

ans = 0
for i in range(1,n+1,2):
    temp = 0
    for j in range(1,i+1):
        if i%j == 0:
            temp += 1
            
    if temp == 8:
        ans += 1
        
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	string s; cin >> s;
	while(1){
		int l = s.size();
		if(s.size() >= 5){
			string t(s.end() - 5, s.end());
			if(t == "dream" || t == "erase") s.erase(s.end() - 5, s.end());
		}
		if(s.size() >= 6){
			string t(s.end() - 6, s.end());
			if(t == "eraser") s.erase(s.end() - 6, s.end());
		}
		if(s.size() >= 7){
			string t(s.end() - 7, s.end());
			if(t == "dreamer") s.erase(s.end() - 7, s.end());
		}
		if(l == s.size()) break;
	}
	cout << (s.empty() ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define PB push_back
#define F first
#define S second
#define MP m ake_pair
#define LB lower_bound
#define UB upper_bound

using namespace std;
typedef long long ll;
typedef pair<int , int> pii;
typedef long double DB;

const int N = 200100;
int a[N] , lst[N];

int main(){

	ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);

	int n;
	ll ans(0);
	cin >> n;

	for(int i = 0 ; i < n ; i++){
	   	 cin >> a[i];
		 if(!a[i] && i){
			if(!a[i-1])
			   lst[i] = lst[i-1];
			else
			   lst[i] = i;
		 }
	}
	
	for(int i = 0 ; i < n ; i++){
	   int sum(a[i]) , xr(a[i]) , pt(i);

	   while(pt > -1 && sum == xr){
		   pt--;
		   if(pt > -1){
				if(!a[pt])
				   pt = lst[pt] - 1;
				
				if(pt > -1)
				   sum += a[pt] , xr ^= a[pt];				   
		   }
	   }
	   
	   ans += (i - pt);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>

using namespace std;

const int BALL_NUM = 10;

int ball[BALL_NUM];

bool dfs(int i, int left, int right) {
    if (i == BALL_NUM) { return true; }
    bool ans = false;
    if (left < ball[i]) {
        ans = dfs(i + 1, ball[i], right);
    }
    if (right < ball[i]) {
        ans = dfs(i + 1, left, ball[i]);
    }
    return ans;
}

int main() {
    long n;
    scanf("%ld", &n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < BALL_NUM; j++) {
            scanf("%d", &ball[j]);
        }
        if (dfs(0, 0, 0)) { printf("%s\n", "YES"); }
        else { printf("%s\n", "NO"); }
    }

    return 0;
}

Measured memory_bytes: 2488
#include<iostream>
#include<ctime>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<climits>
#include<cstring>
#include<iomanip>
#include<string>
#include<bitset>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<algorithm>
#include<functional>
#include<chrono>
#include<random>

#define y0 asdahsdlkahsdad
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define taskname "C"
#define BeztDonkey

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

const int nAlpha = 'z' - 'a' + 1, maxN = 2e5 + 1;

deque<int> pos[nAlpha];
static int p[maxN], lab[maxN], n, mid;
ll ans = 0;
string s;

inline void Update(int i, int val) { for (; i <= n; i += i & -i) lab[i] += val; }
inline int Get(int i) { int res = 0; for (; i > 0; i &= i - 1) res += lab[i]; return res; }


int main()
{
    #ifdef BeztDonkey
    auto start = chrono::steady_clock::now();
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen(taskname".inp", "r", stdin);
    //freopen(taskname".out", "w", stdout);

    cin >> s;
    n = s.size();
    for (int i = 0; i < n; ++i) pos[s[i] -= 'a'].push_back(i + 1);
    int dem = 0;
    for (int c = 0; c < nAlpha; ++c)
        if (pos[c].size() & 1) ++dem, mid = pos[c][pos[c].size() >> 1];
    if (dem > 1) return cout << -1, 0;
    for (int i = 1; i <= n; ++i)
        if (i != mid) Update(i, 1);
    for (int i = 1; i <= n; ++i)
    {
        auto &v = pos[s[i - 1]];
        if (v.back() <= i) continue;
        p[i] = v.back();
        ans += Get(n) - Get(v.back());
        Update(i, -1);
        Update(v.back(), -1);
        v.pop_back();
    }
    if (n & 1)
        for (int i = 1; i <= n; ++i)
            ans += p[i] && (i < mid && p[i] < mid || i > mid && p[i] > mid);
    cout << ans;

    #ifdef BeztDonkey
    auto end = chrono::steady_clock::now();
    cerr << "In milliseconds : "
         << chrono::duration_cast<chrono::milliseconds>(end - start).count();
    cerr << '\n' << "In seconds : "
         << chrono::duration_cast<chrono::seconds>(end - start).count() << '\n';
    #endif
    return 0;

}


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

int calcLCS(string s, string t) {
    if (s.length() < t.length()) {
        string temp = s;
        s = t;
        t = temp;
    }

    int table[s.length()+1][t.length()+1];
    for (int i=0; i<=s.length(); i++) {
        table[i][0] = 0;
    }
    for (int j=0; j<=t.length(); j++) {
        table[0][j] = 0;
    }

    for (int i=1; i<=s.length(); i++) {
        for (int j=1; j<=t.length(); j++) {
            if (s.at(i-1) == t.at(j-1)) {
                table[i][j] = table[i-1][j-1] + 1;
            } else {
                table[i][j] = max(table[i][j-1], table[i-1][j]);
            }
        }
    }

    return table[s.length()][t.length()];
}

int main() {
    int n;
    cin >> n;
    for (int i=0; i<2*n; i+=2) {
        string x, y;
        cin >> x >> y;

        cout << calcLCS(x, y) << endl;
    }

    return 0;
}



Measured memory_bytes: 7056
//BISMILLAHIR RAHMANIR RAHEEM
                                      //ALLAH IS WATCHING ME

//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█


#include<bits/stdc++.h>

#define ull    unsigned long long
#define ll   long long
#define ses   "\n"

using namespace std;

//main function is here........
int main(){
string s;
cin>>s;
for(ll i=0;i<=s.size();i++){
    if(s[i]=='R' && (i+1)%2==0){
        cout<<"No";return 0;
    }
    if(s[i]=='L' && (i+1)%2!=0){
        cout<<"No";return 0;
    }
}
cout<<"Yes";
}

//Alhamdulillah


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n, h,a,ans = 0;
	scanf("%d%d",&h,&n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		ans += a;
	}
	if (ans >= h)	printf("Yes");
	else
	{
		printf("No");
	}
	


	return 0;
}


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

typedef long long ll;

ll N;

int digit(ll x){
    int res = 0;
    while(x){
        x /= 10;
        res++;
    }
    return res;
}

//length of FizzBuzz String until x
ll f(ll x){
    if(x == 0) return 0;
    
    ll res = 0;
    
    int d = digit(x);
    ll t = 1;
    for(int i=0; i<d-1; i++)
        t *= 10;
    t--;
    
    res += (x-t - (x/5 + x/3 - x/15 - (t/5 + t/3 - t/15))) * d;
    res += (x/5 + x/3 - (t/5 + t/3)) * 4;
    res += f(t);
    
    return res;
}

string ltos(ll x){
    string res = "";
    while(x){
        res += '0' + x%10;
        x /= 10;
    }
    reverse(res.begin(), res.end());
    return res;
}

int main(){
    cin >> N;
    ll lb = 0, ub = 100000000000000000L;
    while(ub - lb > 1){
        ll mid = (lb + ub)/2;
        if(f(mid) >= N){
            ub = mid;
        }else{
            lb = mid;
        }
    }
    
    string s = "";
    for(ll i=ub; i<ub+25; i++){
        if(i%15 == 0){
           s += "FizzBuzz";
        }
        else if(i%3 == 0){
            s += "Fizz";
        }
        else if(i%5 == 0){
            s += "Buzz";
        }
        else{
            s += ltos(i);
        }
    }
    
    cout << s.substr(N-f(lb)-1, 20) << endl;
    
    return 0;
}

Measured memory_bytes: 3212
#include<iostream>
using namespace std;
int main()
{
	string s[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
	int count = 0;
	string a;
	cin>>a;
	int i;
	for(i=0;i<10;i++)
	{
		if(a==s[i]) break;
	}
	int sum = 7-i;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
	int N;
	
	public void solve() {
		while(true){
			int two = 0;
			int five = 0;
			N = nextInt();
			if(N==0)break;
			for(int i = N;i >= 2;i--){
				int j = i;
				while(j%2==0){
					j/=2;
					two++;
				}
				
				while(j%5==0){
					j/=5;
					five++;
				}
			}
			
			out.println(Math.min(two,five));
		}
	}
 
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}
		/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 24212
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

typedef vector<vector<long long>> Matrix;

const long long INF = 1000000000000000;
int N;
Matrix d;

void warshall_floyd()
{
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      for (int k = 0; k < N; k++)
      {
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
      }
    }
  }
}

int main()
{
  long long result = 0;
  cin >> N;
  d = Matrix(N, vector<long long>(N, INF));
  vector<vector<long long>> A(N, vector<long long>(N));
  Matrix exist = Matrix(N, vector<long long>(N, true));
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      cin >> A[i][j];
      d[i][j] = A[i][j];
    }
  }

  warshall_floyd();

  ////////////////////////////////////////////
  for (int i = 0; i < N; i++)
  {
    for (int j = i + 1; j < N; j++)
    {
      if (A[i][j] > d[i][j])
      {
        cout << -1 << endl;
        return 0;
      }
      for (int k = 0; k < N; k++)
      {
        if (k != i && k != j)
        {
          if (d[i][j] == (d[i][k] + d[k][j]))
          {
            exist[i][j] = exist[j][i] = false;
          }
        }
      }
    }
  }
  for (int i = 0; i < N; i++)
  {
    for (int j = i + 1; j < N; j++)
    {
      if (exist[i][j])
        result += d[i][j];
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 2432
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }



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

	if (c >= a && c <= b)
		cout << "Yes";
	else
		cout << "No";
	cout << endl;

}


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

int main() {
	int deg[ 5 ] = { 0 };
	for ( int i = 0 ; i < 3 ; ++ i ) {
		int a, b; scanf( "%d%d", &a, &b );
		deg[ a ]++, deg[ b ]++;
	}
	sort( deg + 1, deg + 5 );
	if ( deg[ 1 ] != 1 or deg[ 2 ] != 1 or deg[ 3 ] != 2 or deg[ 4 ] != 2 )
		puts( "NO" );
	else puts( "YES" );
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	while(1){
		int n,m,t,pos=1,count=0;
		scanf("%d%d",&n,&m);
		if(!n&&!m) break;
		int a[1002];
		for(int i=1;i<=n;i++){
			scanf("%d",&t);
			a[i]=t;
		}
		for(int i=0;i<m;i++){
			scanf("%d",&t);
			if(pos<n){
				pos+=t+a[t+pos];
				count++;
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int dp[1005][1005];

int main(){
    int n,m;
    while(cin >> n >> m){
        rep(i,1005){
            rep(j, 1005){
                dp[i][j] = 2 << 24;
            }
        }
        rep(i,m){
            int a, b, c ,d;
            scanf("%d%*c%d%*c%d%*c%d",&a, &b, &c, &d);
            dp[a][b] = c;
            dp[b][a] = d;
        }
        int st, ed, in, out;
        scanf("%d%*c%d%*c%d%*c%d",&st, &ed, &in, &out);
        rep(k,n + 1){
            rep(i,n + 1){
                rep(j,n + 1){
                    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
                }
            }
        }
        cout << in - out - dp[st][ed] - dp[ed][st] << endl;
    }
}

Measured memory_bytes: 5184
#include<bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
#define fo(i,s,e_ex) for(i=s;i<e_ex;i++)
#define Fo(i,k,n) for(i=k;k<n?i<=n:i>=n;k<n?i+=1:i-=1)
#define endl '\n'
#define MOD 1000000007//998244353
#define pbb push_back
#define mpp make_pair
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define mset(arr,val) memset(arr,val,sizeof(arr))
ll n;
ll arr[105];
int dp[100005][2];
bool play(ll k,int pl){//biased for pl=0
	if(dp[k][pl]!=-1) return dp[k][pl];
	bool ans=pl;
	ll i;
	fo(i,0,n){
		if(k>=arr[i]){
			bool myans=play(k-arr[i],1-pl);
			if(pl==0&&myans) ans=true;
			else if(pl==1&&!myans) ans=false;
		}
	}
	return dp[k][pl]=ans;
}
void solve(ll caseno){
	ll i,j,k;
	cin>>n>>k;
	fo(i,0,n) cin>>arr[i];
	mset(dp,-1);
	cout<<(play(k,0)?"First":"Second")<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll t=1;
	//cin>>t;
	for(ll i=1;i<=t;i++){
		solve(i);
	}
	return 0;
}


Measured memory_bytes: 10616
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    // int a,b,c,d;
    // cin >> a >> b >> c >> d;

    int s,w;
    cin >> s >> w;
    cout << ((w>=s)?"unsafe":"safe") << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int n, k, a[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    int cnt = 0;
    FOR(i,1,n) {
        int x;
        cin >> x;
        while (x % 2 == 0) {
            x /= 2;
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int a, b;

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


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int x,y;
    while(1){
        scanf("%d%d",&x,&y);
        if(x==0&&y==0){
            break;
        }
        else if(x<y||x==y){
            printf("%d %d\n",x,y);
        }
        else{
            printf("%d %d\n",y,x);
        }
    }
    return 0;
}


Measured memory_bytes: 1972
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	int K = Integer.parseInt(reader.readLine());
	String S = reader.readLine();
	int len = S.length();
	if(len<=K){
	System.out.println(S);
	}
	else{
		String h = "";
		for(int i = 0;i<K;i++){
			h+=S.charAt(i);
		}
		h+="...";
		System.out.println(h);
	}
	}
}


Measured memory_bytes: 37232
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    vector<pair<int, int> > pa(n);
    for (int i = 0; i < n; ++i) {
      int p, d1, d2;
      cin >> p >> d1 >> d2;
      pa[i].first = d1 + d2;
      pa[i].second = p;
    }
    sort(pa.begin(), pa.end(), greater<pair<int, int> >());
    cout << pa[0].second << " " << pa[0].first << endl;
  }
  return 0;
}

Measured memory_bytes: 984
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(ReadLine());
        string S = ReadLine();
        string reS = S.Replace("ABC", "0");
        int ans = 0;
        foreach(char s in reS)
        {
            if(s == '0')
            {
                ans++;
            }
        }
        WriteLine(ans);
    }
}

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

using namespace std;

int main() {
	int n;
	int low, high;
	int limit = 99*100*1000;
	cin >> n;

	vector<int> x(n);

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

	low = x[0]; high = x[0];
	for(int i=0; i< n; i++) {
		low = min(low, x[i]);
		high = max(high, x[i]);
	}

	int total = 0;
	for(int i = low; i <= high; i++) {
		for(int j=0; j< n; j++) {
			total += (x[j] - i) * (x[j] - i);
		}
		limit = min(limit, total);

		total = 0;

	}

	cout << limit << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int cnt[11]={};
  cnt[a]++,cnt[b]++,cnt[c]++;
  cout<<(cnt[5]==2&&cnt[7]?"YES":"NO")<<endl;
  return 0;
}


Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())

a1 = A * X + B * Y

a2 = min(X, Y) * 2 * C
if X >= Y:
    a2 += (X - Y) * min(A, 2 * C)
else:
    a2 += (Y - X) * min(B, 2 * C)

ans = min(a1, a2)
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll n,m;
  cin >> n >> m;
  vl a;
  inputv(a,m);
  a.push_back(INF);
  
  
  vl s(n+1,0);
  s[0] = 1;
  ll point = 0;
  if(a[0] == 1){
    s[1] = 0;
    point++;
  } else {
    s[1] = 1;
  }
  for(ll i=2; i<=n; i++){
    if(a[point] == i){
      s[i] = 0;
      point++;
    } else {
      s[i] = (s[i-1] + s[i-2])%MOD;
    }
  }
  cout << s[n];
 return 0;
}

Measured memory_bytes: 1908
import math
primes=[2]
top=2
nlist=[2*x-1 for x in range(2,2**14)]
while top<math.sqrt(2**15):
    top=nlist[0]
    primes.append(top)
    newnlist=[]
    for i in nlist:
        if i%top!=0:
            newnlist.append(i)
    nlist=newnlist
primes=primes+nlist
while(1):
    n=int(raw_input())
    if n==0:
        break
    else:
        sum=0
        for i in range(2,n/2+1):
            if i in primes and n-i in primes:
                sum=sum+1
        print sum

Measured memory_bytes: 5276
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC70(void);
void ABC71(void);
void ABC72(void);
void ABC73(void);
void ABC74(void);
void ABC75(void);
void ABC76(void);
void ABC77(void);
void ABC78(void);
void ABC79(void);

int main(void){
    ABC75();
}

void ABC75(){
    int h,w,i,j,n,m;
    cin>>h>>w;
    char c,s[h][w];
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cin>>c;
            if(c=='.')s[i][j]='0';
            if(c=='#')s[i][j]='#';
        }
    }
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(s[i][j]=='#'){
                for(n=i-1;n<=i+1;n++){
                    for(m=j-1;m<=j+1;m++){
                        if(n>=0&&n<h&&m>=0&&m<w){
                            if(s[n][m]!='#')s[n][m]++;
                        }
                    }
                }
            }
        }
    }
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cout<<s[i][j];
        }
        cout<<endl;
    }
}

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

ll dp[102][100005];
const int totval = 1e5;

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

  int n;
  ll totwt;
  cin >> n >> totwt;
  ll w[102], v[102];
  for (int i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= totval; j++) {
      dp[i][j] = 1e18;
    }
  }
  dp[n][0] = 0;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j <= totval; j++) {
      dp[i][j] = dp[i + 1][j];
      if (j >= v[i]) {
        dp[i][j] = min(dp[i][j], dp[i + 1][j - v[i]] + w[i]);
      }
    }
  }

  for (int j = totval; j >= 0; j--) {
    if (dp[0][j] <= totwt) {
      cout << j << '\n';
      return 0;
    }
  }

  return 0;
}

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

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
*/

using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod = 1e9 + 7;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

//#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}

const int N = 1e5 + 10;

int main()
{
	#ifdef LOCAL_TEST
	freopen("in.txt","r",stdin);
	//freopen("out.txt", "w", stdout);
	#else
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	#endif
	int a,b,c;
	cin>>a>>b>>c;

	if(a == b && b == c)cout << "Yes\n";
	else cout << "No\n";
	return 0;	
}

Measured memory_bytes: 256
require 'pp'

N = readline.chomp.to_i
S = readline.chomp

idx = S.index('#')

if idx
  sub = S[idx..-1] + '#'
  n_w = S[idx..-1].count('.')
  n_b = 0
  min = n_w + n_b
  sub[1..-1].each_char.with_index do |c,i|
    if c == '#'
      n_b += 1
      min = n_w + n_b if min > n_w + n_b
    else
      n_w -= 1
    end
  end
  #min = n_w + n_b if min > n_w + n_b
  puts min
else
  puts 0
end


Measured memory_bytes: 2936
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
bool  Array_check(ll y, ll x,ll d,ll w) {
	if (x < 0 || x >= w || y<0 || y>=d) {
		return false;
	}
	else {
		return true;
	}
	
}

//小文字=大文字+32

int main() {
	int a, b;
	cin >> a >> b;
	if (a % 2 == 0 || b % 2 == 0) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}

}
	



Measured memory_bytes: 3636
/*----------------by syr----------------*/
/*

         iii                  ii
     rBQBBBBBBE       BBR iBBBBQBBL     XBBBBBBQBBBBB
   iBBQJ    7BBB      BBsSBBr   BBQ      i      cBBB
  rBBU       iBBw     BBBQi     HBBi           KBBi
  BBH         BB5    iBBB       isL          wBB5
 GBB         iBBi    6BB                   iBBB
 BBQ         BQB     BBD                  QBBi
 BBB        BQB     iQBi                1BBv
 sBBg     wBBB      QBB               iBBB
  7BBBBBBBBBi       BBR              wBBBBBBBBBBBBB
     irvi           ii               ii    i i iii
                i5U
               BBB
               BB7
              1BB
      iPBBBBBKBBR    JBR1       rQBO   BR  UBQP  iBBQi
    7BBBGs7sXBBBi     QBBr     gBBE   rBB BB2BB7HBZQBB
   QBBi      sBQ       BBB   iBBB     SQBBR  BBBB  cBQ
  gBQ        BBg        BBB KBBi      MBBH   BBB   BBs
 iBBv       iBBi         QBBBL        BBR   pBB   iBB
 pBB        BBB         iBBBB        iBB    BBL   KBB
 MBB       BBBR        BBB JBBi      DBR   iBQ    BBL
 GBB     7BBBB2      PBBH   BBBi     BQr   DBB   iBB
  BQBXwgBBP BB7    1BBB      BBQ7   1BB    BBc   BBB
   2BBBBw   BB    EBBS        QBBi  HBa   iBB    BB7
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;
const int maxn = 2e3 + 5;

int n, m;
int a[maxn], b[maxn];
ll dp[maxn][maxn];

int main(){
	scanf("%d%d", &n, &m);
	REP(i, 1, n)
		scanf("%d", a + i);
	REP(i, 1, m)
		scanf("%d", b + i);
	REP(i, 0, n) REP(j, 0, m){
		if(!i || !j)
			dp[i][j] = 1;
		else
			dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] + (a[i] == b[j]) * dp[i - 1][j - 1] - dp[i - 1][j - 1] + INF) % INF;
	}
	printf("%lld\n", dp[n][m]);
	return 0;
}



Measured memory_bytes: 31616