akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int ch[12],one,two,g,q;

int DFS(int g){
if(g == 10)
    {
        q=0;
        return 1;
    }
else
{
    for(int i = g; i < 10; i++){
        for(int k = 1; k >= 0; k--)
        {
            if(q == 0) return 1;
            if(k && ch[i] > one)
                {
                    one = ch[i];
                    DFS(i+1);
                }
            else if(!k && ch[i] > two)
                {
                    two = ch[i];
                    DFS(i+1);
                }
            else if(ch[i] < two &&ch[i] < one)
                {
                    return 0;
                }
        }
    }
}
return 0;
}
int main()
{
    int n;
    cin >> n;
    while(n--){
     for(int i = 0; i < 10; i++)
        cin >> ch[i];
     one = ch[0];
     two = 0;
     q=1;
     if(DFS(1)) cout << "YES" << endl;
     else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

using namespace std;

int main(int argc, char *argv[]) {
    ll result = 0;
    ll N;
    cin >> N;
    vector<ll> p(N);
    
    rep(i, N){
        cin >> p[i];
    }
    vector<ll> pcopy = p;
    sort(ALL(pcopy));
    
    bool flag = false;
    ll temp = -1;
    rep(i, N){
        if(p[i] != pcopy[i]){
            if(flag){
                cout << "NO" << endl;
                return 0;
            }
            
            if(temp == -1){
                temp = p[i];
            } else {
                if(pcopy[i] == temp) {
                    flag = true;
                } else {
                    cout << "NO" << endl;
                    return 0;
                }
            }
        }
    }
    
    cout << "YES" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <limits>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define fi(i, n) for( int i=0 ; i<n ; i++ )
#define f(i, a, b) for( int i=a ; i<b ; i++ )
#define vi vector<int>
#define pb push_back
#define MOD 1000000007
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
ll fact(ll n)
{
    ll ans = 1e14;
    for(ll i = 1; i<=sqrt(n); i++)
    {
        if(n%i==0)
        {
            ll sol = (i - 1) + (n/i - 1);
            ans = min(ans,sol);
        }
    }
    return ans;
}
int visited[200000] = {0};
vector<vector<int> > v(200000);
int dfs(int x)
{
    int ans = 0;
    if(visited[x]==0)
    {
        visited[x] = 1;
        ans++;
        int a = v[x].size();
        for(int j = 0;j<a;j++)
        {
            int data = v[x][j];
            ans = ans + dfs(data);
        }
    }
    return ans;
}
void primefactors(int n)
{
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            cout << i << " ";
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        cout << n << " ";

}
double fib(int n)
{
    double sol1,sol2;
    sol1 = (1 + sqrt(5))/2;
    sol2 = (1 - sqrt(5))/2;
    sol1 = pow(sol1,n);
    sol2 = pow(sol2,n);
    double ans = sol1 - sol2;
    ans = ans/sqrt(5);
    //ans = int(ans);
    return ans;
}
int digits(ll n)
{
    return floor(log10(double(n))) + 1;
}
int main()
{
    int arr[3] = {0};
    int a,b;
    cin>>a>>b;
    arr[a - 1]++;
    arr[b - 1]++;
    fi(i,3)
    {
        if(arr[i]==0)
        {
            cout<<i+1;
        }
    }


}


Measured memory_bytes: 7804
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>
#pragma comment(linker, "/STACK:836777216")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))


int main(void) {
	int x;
	scanf("%d", &x);
	int cnt = x / 500 * 1000 + (x % 500) / 5 * 5;
	printf("%d\n", cnt);
	//scanf("%d", &x);
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e6 + 100, maxc = 256;
const ll inf = 2e18, mod = 1e9 + 7;

int n, pos[maxc], R[maxn], dest[maxn], par[maxn], fen[maxn * 2];
char s[maxn], t[maxn];
vector<int> vec[maxc];

void update(int x, int val)
{
	for (int ind = x + 1; ind < maxn * 2; ind += (ind & -ind))
		fen[ind] += val;
}

int query(int x)
{
	int res = 0;
	for (int ind = x + 1; ind; ind -= (ind & -ind))
		res += fen[ind];
	return res;
}

bool check(int H)
{
	memset(fen, 0, sizeof(fen));
	update(n, -H);
	update(0, H);

	int cut = 0;
	for (int i = n - 1; i >= 0; i--)
	{
		if (query(cut + i) == 0)
			return false;
		if (!i || t[i] != t[i - 1])
		{
			if (query(cut + i) < H)
				cut++;
			else
			{
				update(cut + i, -H);
				update(cut + i + 1, H);
			}
			update(par[i] + cut, -1);
			update(i + cut, 1);
		}
	}
	return true;
}

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

	for (int i = 0; i < maxc; i++)
		pos[i] = -mod;

	cin >> n >> s >> t;

	if (strcmp(s, t) == 0)
	{
		cout << 0 << endl;
		return 0;
	}

	int ind = 0;
	for (int i = 0; i < n; i++)
		if (t[i] != t[i - 1])
		{
			for (int j = ind; j < i; j++)
				R[j] = i - 1;
			ind = i;
		}
	for (int i = ind; i < n; i++)
		R[i] = n - 1;

	for (int i = 0; i < n; i++)
		vec[s[i]].pb(i);
	ind = n;
	for (int i = n - 1; i >= 0; i--)
	{
		while (ind - 1 > i)
		{
			ind--;
			//cerr << "ERASE " << t[ind] << endl;
			vec[s[ind]].popb();
		}
		if (!i || t[i] != t[i - 1])
		{
			if (vec[t[i]].empty())
			{
				//cerr << '#' << i << ' ' << t[i] << ' ' << ind << endl;
				cout << -1 << endl;
				return 0;
			}
			par[i] = vec[t[i]].back();
			for (int j = vec[t[i]].back(); j < ind; j++)
				vec[s[j]].popb();
			ind = par[i];
		}
	}
	for (int i = 0; i < n; i++)
		if (!i || t[i] != t[i - 1])
			for (int j = i; j <= R[i]; j++)
				par[j] = par[i];
	//for (int i = 0; i < n; i++)
	//	cerr << '_' << par[i];
	//cerr << endl;
	for (int i = 0; i < n; i++)
		if ((i && par[i] < par[i - 1]) || par[i] > i)
		{
			//cerr << "QUIT " << i << ' ' << par[i] << endl;
			cout << -1 << endl;
			return 0;
		}

	/*while (true)
	{
		int x;
		cin >> x;
		cerr << '#' << check(x) << endl;
	}*/
	int l = 0, r = n + 100, mid;
	while (r - l > 1)
	{
		mid = (l + r) / 2;
		if (check(mid))
			r = mid;
		else
			l = mid;
	}
	
	cout << r << endl;
}



Measured memory_bytes: 24908
N = int(input())
A = list(map(int, input().split()))

tn = N*(N+1)//2
ta = sum(A)


if ta % tn != 0:
  print('NO')
  exit()

num = ta // tn

count = 0
seq = [0]*N

for i in range(N):
  a = A[i-1]
  b = A[i]

  c = b-a - num
  if c % N != 0 or c > 0:
    print('NO')
    exit()
  else:
    t = -c//N
    seq[i] = t
    count += t

if count != num:
  print('NO')
else:
  print('YES')

Measured memory_bytes: 14488
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  string S; cin >> S;
  int n = S.size();
  rep(i, n - 1){
    if (S[i] == S[i + 1]) {cout << "Bad" << endl; return 0;}
  }
  cout << "Good" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <memory.h>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <time.h>
#include <assert.h>
#include <cmath>
#include <stack>
#include <string.h>
#include <sstream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll calc(vector<int> v) {
	for (int i = 1; i < v.size(); ++i)
		if (v[i] > v[i - 1] + 1) {
			puts("-1");
			exit(0);
		}
	if (v.back() == 0)
		return 0;
	ll res = 0;
	map<int, int> last;
	for (int i = 1; i < v.size(); ++i) {
		res += v[i];
		if (v[i] == v[i - 1] + 1)
			res -= v[i] - 1;
	}
	return res;
}
int main()
{
	int n;
	scanf("%d", &n);
	vector<int> v(n);
	for (auto &x : v)
		scanf("%d", &x);
	if (v[0] != 0) {
		puts("-1");
		return 0;
	}
	ll res = 0;
	for (int i = 0; i < n; ++i) {
		vector<int> cur;
		cur.push_back(v[i]);
		++i;
		while (i < n && v[i] != 0) {
			cur.push_back(v[i]);
			++i;
		}
		--i;
		res += calc(cur);
	}
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 2676
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define REP1(i,n) for(long long i=1;i<=(n);i++)
#define REP2D(i,j,h,w) for(long long i=0;i<(h);i++) for(long long j=0;j<(w);j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=(h);i++) for(long long j=1;j<=(w);j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) ((a).begin()),((a).end())
#define RANGE(a) (a),((a)+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define ENTER printf("\n")
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<(a)<<endl
#ifdef DEBUG
#define DBPRT(a) cout << "[Debug] - " << #a << " : " << (a) << endl
#define DBSTART if(1){
#define DBEND }
#else
#define DBPRT(a) do{}while(0)
#define DBSTART if(0){
#define DBEND }
#endif
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);

#define TOSUM(arr,sum,n) {sum[0]=arr[0];REP1(i,n-1) sum[i]=sum[i-1]+arr[i];}

#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 300005
#define MOD 1000000007
//---------------------
ll n;
ll a[MAXN];
ll ct[60];

int main(){
	cin >> n;
	ZERO(a);ZERO(ct);
	REP1(i,n) cin >> a[i];
	REP1(i,n){
		ll cn = a[i];
		REP(j,60){
			if( (cn>>j)&1 ) ct[j]++;
		}
	}

	ll base = 1;
	ll res = 0;
	REP(i,60){
		ll curres = ((n-ct[i])*(ct[i]))%MOD;
		res = (res + (curres * base)%MOD)%MOD;
		base = (base<<1)%MOD;
	}
	PRT(res);
	return 0;
}









Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
//入力
int H,W;
vector<vector<int>> field;

void dfs(int h,int w){
  field[h][w] = 0;
  // 八方向を探索
  for(int dh=-1;dh<=1;dh++){
    for(int dw=-1;dw<=1;dw++){
      int nh = h+dh,nw=w+dw;
      //場外アウトしたり、0だったりはスルー
      if(nh<0||nh>=H||nw<0||nw>=W) continue;
      if(field[nh][nw]==0) continue;
      dfs(nh,nw);//再帰的に探索
    }
  }
}

int main(){
  //入力受け取り
  while(cin >> W >> H){
    if(H==0||W==0) break;
    field.assign(H,vector<int>(W,0));
    for(int h=0;h<H;h++)for(int w=0;w<W;w++) cin >> field[h][w];
    int count = 0;
    for(int h=0;h<H;h++){
      for(int w=0;w<W;w++){
        if(field[h][w]==0) continue;//残島じゃなかったらスルー
        dfs(h,w);
        ++count;
      }
    }
    cout << count << endl;
  }
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N;
  cin >> N;
  vb check(N);
  rep(i,N) {
    int D,E;
    cin >> D >> E;
    check[i]=(D==E);
  }
  
  bool flag=false;
  rep(i,N-2) flag|=(check[i]&&check[i+1]&&check[i+2]);
  
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3628
//code_sm
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int>
#define msi multiset<int>
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu ((int)1e9+7)
//sieve generation begin
vi PRIME;
void sieve(int n)
{
	bool a[n+1];
	memset(a,0,sizeof(a));
	a[0]=1;
	a[1]=1;
	for(int i=2;i*i<=n;i++)
	{
		if(a[i]==0)
		{
			for(int j=i*i;j<=n;j+=i)
			a[j]=1;
		}
	}
	for(int i=2;i<=n;i++)
	{
		if(a[i]==0)
		PRIME.pb(i);
	}
}
//sieve generation end
ll gcd(ll a,ll b)
{
	while(b%a)
	{
		ll c=b;
		b=a;
		a=c%a;
	}
	return a;
}
ll bigpow(ll x,ll y)
{
	if(y==0)
	return 1;
	else if(y&1)
	{
		return (x*bigpow((x*x)%chotu,(y-1)/2))%chotu;
	}
	else 
	return bigpow((x*x)%chotu,y/2);
}
//fastio
/*void fastscan(int &number) 
{ 
    //variable to indicate sign of input number 
    bool negative = false; 
    register int c; 
  
    number = 0; 
    c = getchar(); 
    if (c=='-') 
    { 
        
        negative = true; 
  
        c = getchar(); 
    } 
    for (; (c>47 && c<58); c=getchar()) 
        number = number *10 + c - 48; 
    if (negative) 
        number *= -1; 
} 
*/
void solve()
{
	fastio
}
int main()
{
//code
fastio
int n;
cin>>n;
mii mp;
for(int i=0;i<n-1;i++)
{
	int c;
	cin>>c;
	mp[c]++;
}
for(int i=1;i<=n;i++)
{
	if(mp.find(i)!=mp.end())
	cout<<mp[i]<<'\n';
	else
	cout<<0<<'\n';
}
}

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

int main(){
  int n,t,s;
  while(cin >> n >> t >> s){
    int a[3000],b[3000],dp[2][3001],ans=0;
    for(int i=0;i<=t;i++) dp[1][i] = dp[0][i] = 0;
    for(int i=0;i<n;i++) cin >> a[i] >> b[i];

    for(int i=0;i<n;i++){
      for(int j=b[i];j<=s;j++) dp[1][j] = max(dp[0][j],dp[0][j-b[i]]+a[i]);
      for(int j=s+b[i];j<=t;j++) dp[1][j] = max(dp[0][j],dp[0][j-b[i]]+a[i]);

      for(int j=0;j<=t;j++){
	dp[0][j] = max(dp[0][j],dp[1][j]);
	ans = max(dp[0][j],ans);
	dp[1][j] = 0;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 872
# include<stdio.h>
 long GCD(long a,long b)
{
long temp;
while(b!=0)
{
temp=a%b;
a=b;
b=temp; 
}
return a;
}
int main()
{
long a,b,gcd,lcm;
while(scanf("%ld%ld",&a,&b)==2)
{
gcd=GCD(a,b);
lcm=(a/gcd)*(b/gcd)*gcd;
printf("%ld %ld\n",gcd,lcm);
}
return 0;
}

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

int main(){
long long int a[10],i,j,swap;
for(i=0;i<10;i++){
    cin>>a[i];
}
for(i=0;i<10-1;i++){
    for(j=0;j<10-i-1;j++){
        if(a[j]<a[j+1]){
            swap=a[j];
            a[j]=a[j+1];
            a[j+1]=swap;
        }
    }
}

for(i=0;i<3;i++){
    cout<<a[i]<<endl;
}
}

Measured memory_bytes: 1156
N = int(input())
List=list(map(int,input().split()))

arr = [0 for i in range(N+1)]

for i in range(len(List)):
  a = List[i]
  arr[a] += 1
  
ans1 = [0 for i in range(N+1)]
ans2 = [0 for i in range(N+1)]

for i in range(len(arr)):
  a = arr[i]
  b = int(a*(a-1)/2)
  if a == 0:
    c = 0
  else:
    c = int((a-1)*(a-2)/2)
    
  ans1[i] = b
  ans2[i] = c
    
total = sum(ans1)

for i in range(len(List)):
  a = List[i]
  print(int(total - ans1[a] + ans2[a]))

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

string Op(bool opt){
  if(opt)
    return "+";
  return "-";
}

int main(){
  string S;
  cin >> S;
  ll sum = 0;
  for(int i = 0; i < (1 << 4); i++){
    bitset<3> op(i);
    sum = S.at(0) - 48;
    int sc = 1;
    for(int j = 0; j < op.size(); j++){
      if(op.test(j)) sum += S.at(sc) - 48;
      else sum -= S.at(sc) - 48;
      sc++;
    }
    if(sum == 7){
      cout << S.at(0) << Op(op.test(0)) 
        << S.at(1) << Op(op.test(1))
        << S.at(2) << Op(op.test(2))
        << S.at(3) << "=7" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	if s == "zyxwvutsrqponmlkjihgfedcba" {
		fmt.Println(-1)
		return
	}
	if len(s) != 26 {
		no := 'a'
		for i := 'a'; i <= 'z'; i++ {
			a := false
			for _, v := range s {
				if i == v {
					a = true
					break
				}
			}
			if !a {
				no = i
				break
			}
		}
		fmt.Println(s + string(no))
		return
	}
	before := s[25]
	ind := -1
	for i := 24; i >= 0; i-- {
		if s[i] < before {
			ind = i
			break
		}
		before = s[i]
	}
	min := byte('z')
	for i := ind + 1; i < 26; i++ {
		if s[ind] < s[i] && s[i] < min {
			min = s[i]
		}
	}
	fmt.Println(s[0:ind] + string(min))
}


Measured memory_bytes: 512
s = input().strip()
agct = ['A', 'G', 'C', 'T']
counter = 0
counts = [0]

for c in s:
    if c in agct:
        counter += 1
    else:
        if max(counts) < counter:
            counts.append(counter)
        counter = 0


counts.append(counter)

print(max(counts))


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n >> k;
  vi a(n);
  REP(i,n) cin>>a[i];


  for(ll i=k;i<n;i++){
    if (a[i-k]<a[i])
    {
      cout<<"Yes"<<endl;
    }else
    {
      cout<<"No"<<endl;
    }
  }
  

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

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N, K; cin >> N >> K;
  vector<int> A(N); cin >> A;
  rep(_, min(K, 50)) {
    vector<int> acc(N + 1);
    rep(i, N) {
      acc[max(0, i - A[i])]++;
      acc[min(N, i + A[i] + 1)]--;
    }
    REP(i, 1, N + 1) {
      acc[i] += acc[i - 1];
    }
    rep(i, N) {
      A[i] = acc[i];
    }
  }
  rep(i, N) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << "\n";
}


Measured memory_bytes: 4836
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main(void) {
	int w, a, b, ans;
	scanf("%d%d%d", &w, &a, &b);
	if (a + w >= b && b + w >= a) {
		ans = 0;
	}
	else if (b > a + w) {
		ans = b - (a + w);
	}
	else {
		ans = a - (b + w);
	}
	printf("%d\n", ans);

}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
int main() {
	long long int n, k;
	cin >> n >> k;
	long long int ans = 0;
	while (n > 0) {
		n = n / k;
		ans++;
	}
	cout << ans;
}


Measured memory_bytes: 256
/**
*     => Md. Sajjat Hosen
*     => Department of Computer Science and Engineering
*     => Bangabandhu Sheikh Mujibur Rahman Science and Technology University
**/

/*..................! TRY ONCE MORE !..................*/

/*...Part - 01...*/

#include <bits/stdc++.h>
using namespace std ;

/*...Part - 02...*/

typedef long long               ll ;
typedef long double             ld ;
typedef unsigned long long      ull ;
typedef pair<int,int>           pii ;
typedef pair<ll,ll>             pll ;
typedef vector<int>             vi ;
typedef vector<ll>              vll ;
typedef vector<vector<int>>     vvi ;

int Int(){int x ; scanf("%d",&x) ; return x ;}
ll Long(){ll x ; scanf("%lld",&x) ; return x ;}
float Float(){float x ; scanf("%f",&x) ; return x ;}
double Double(){double x ; scanf("%lf",&x); return x;}

/*...Part - 03...*/
/*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

/*...Part - 04...*/
/*...Needed to change according to problem requirements...*/

const int N          = (int)2e5 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;

/*..........................................................*/
/*...Part - 05...*/

#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e))  ; i += 1 - 2 * ((b) > (e)))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)

/*...Part - 06...*/
/*...... ! Code start from here ! ......*/



int main(){
    //freopen("input.txt","r",stdin);
    int test = 1 , tc = 0 ;
    int h, a;
    while(test--){
        h = Int;
        a = Int;
        int ans = (h + a - 1) / a;
        printf("%d\n", ans);
    }
    return 0 ;
}

/*...Always look at the part - 04...*/
/*...............END................*/


Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d %d",$r,$c);
$sum_c=array_fill(0,$c,0);
for($i=0;$i<$r;++$i){
    $input=explode(" ",trim(fgets(STDIN)));
    for($j=0;$j<$c;++$j){
        $sum_c[$j]=$sum_c[$j]+$input[$j];
    }
    echo implode(" ",$input)," ",array_sum($input),PHP_EOL;
}
echo implode(" ",$sum_c)," ",array_sum($sum_c);
?>

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

typedef long long int in;

in n,k,l=1000000007;

struct mat
{
    in a[55][55];
};

mat e,d;

mat mul(mat r,mat y)
{
    in i,h,j;
    
    mat z;
    
    for(i=0;i<n;++i)
    for(j=0;j<n;++j)
    z.a[i][j]=0;
    
    for(i=0;i<n;++i)
    {
        for(j=0;j<n;++j)
        {
            for(h=0;h<n;++h)
            {
                z.a[i][j]=((z.a[i][j]%l)+(((r.a[i][h]%l)*(y.a[h][j]%l))%l))%l;
            }
        }
    }
    
    return z;
}

mat matrix(mat f,in k)
{
    if(k==0)
    return d;
    
    if(k%2==0)
    return matrix(mul(f,f),k/2);
    else
    return mul(f,matrix(mul(f,f),(k-1)/2));
}

int main() 
{
	in i,j,sum=0;
	cin>>n>>k;
	
	for(i=0;i<n;++i)
	d.a[i][i]=1;
	
	for(i=0;i<n;++i)
	for(j=0;j<n;++j)
	cin>>e.a[i][j];
	
	mat ans=matrix(e,k);
	
	for(i=0;i<n;++i)
	for(j=0;j<n;++j)
	sum=(sum+ans.a[i][j])%l;
	
	cout<<sum;
	
	return 0;
}


Measured memory_bytes: 10496
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////
const int MAX_N = 500000;
vector<int> par(MAX_N);
vector<int> Rank(MAX_N);
vector<int> gNum(MAX_N);

void init(int n) {
	for (int i = 0; i < n; ++i) {
		par[i] = i;
		Rank[i] = 0;
		gNum[i] = 1;
	}
}

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

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

void unite(int x, int y) {
	x = root(x);
	y = root(y);
	if (x == y)return;
	
	if (Rank[x] < Rank[y]) {
		par[x] = y;
		gNum[y] += gNum[x];
	}
	else {
		par[y] = x;
		if (Rank[x] == Rank[y]) {
			Rank[x]++;
		}
		gNum[x] += gNum[y];
	}
}
void solve() {
	int N, M, K;
	cin >> N >> M >> K;
	int a, b;
	init(N);
	vector<int> ans(N, -1);

	for (int i = 0; i < M; ++i) {
		cin >> a >> b; a--; b--;
		unite(a, b);
		ans[a]--;
		ans[b]--;
	}
	
	for (int i = 0; i < K; ++i) {
		cin >> a >> b; a--; b--;
		if (same(a, b)) {
			ans[a]--;
			ans[b]--;
		}
	}
	for (int i = 0; i < N; ++i) {
		if (i)cout << " ";
		cout << ans[i] + gNum[ root(i) ];
	}
	cout << endl;
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 7168
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0)
    return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1; // 分母
  ll numerator = 1;   // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
private:
  vector<ll> parents;

public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) {
    return root(x) == root(y);
  }

  bool merge(ll x, ll y) {
    if (issame(x, y))
      return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry])
      swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) {
    return -parents[root(x)];
  }

private:
  ll root(ll x) {
    if (parents[x] < 0)
      return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

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

  vector<ll> dp(N + 1, N + 1);

  dp[0] = 0;
  for (ll i = 0; i <= N; i++) {
    // 1
    if (i + 1 <= N) {
      dp[i + 1] = min(dp[i + 1], dp[i] + 1);
    }
    // 6*6
    ll n = 6;
    while (i + n <= N) {
      dp[i + n] = min(dp[i + n], dp[i] + 1);
      n *= 6;
    }
    // 9*9
    n = 9;
    while (i + n <= N) {
      dp[i + n] = min(dp[i + n], dp[i] + 1);
      n *= 9;
    }
  }

  cout << dp[N] << endl;
  return 0;
}


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

#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n);
	REP(i, n) cin >> v[i];
	map<int, int> mp;
	REP(i, n) {
		auto c = mp.lower_bound(v[i]);
		if (c == mp.begin()) {
			mp[v[i]]++;
		} else {
			c--;
			pii p = *c;
			mp[v[i]]++;
			if (--mp[p.first] == 0) mp.erase(p.first);
		}
	}
	int ans = 0;
	for (auto a : mp) {
		ans += a.second;
	}
	cout << ans << endl;
}

Measured memory_bytes: 5248
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[] s_array = sc.next().split("");
    int k = sc.nextInt();
    String target = s_array[k-1];
    StringBuilder sb = new StringBuilder();
    for(int i=0; i<n; i++){
      if(s_array[i].equals(target)){
        sb.append(s_array[i]);
      }else{
        sb.append("*");
      }
    }
    System.out.println(sb.toString());
  }
}

Measured memory_bytes: 22996
function down(a,b){
    return b-a;
}

function main(input){
    input = input.split('\n');
    inputA = input[0].split(' ');
    inputN = parseInt(inputA[0]);
    inputK = parseInt(inputA[1]);
    inputH = input[1].split(' ');
    enemy = Array(inputN);
    out = 0;

    for(i=0;i<inputN;i++){
        enemy[i]=parseInt(inputH[i]);
    }
    
    enemy = enemy.sort(down);

    for(i=inputK;i<inputN;i++){
        out=out + enemy[i];
    }

    console.log(out);
}

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

Measured memory_bytes: 34964
#include<cstdio>
#include<iostream>
using namespace std;
const int Maxn=10;
int s[Maxn],a[Maxn],b[Maxn];
bool vis[Maxn];
int l,r,tot,n;
bool check(int c[])
{
	for(int i=1;i<=n;++i)
	if(s[i]!=c[i])return 0;
	return 1;
}
void dfs(int x,int cur)
{
	if(cur==n)
	{
		++tot;
		if(check(a))l=tot;
		if(check(b))r=tot;
		return;
	}
	for(int i=1;i<=n;++i)
	{
		if(vis[i])continue;
		vis[i]=1,s[cur+1]=i;
		dfs(i,cur+1);
		vis[i]=0,s[cur+1]=0;
	}
}
int main()
{
//	freopen("in.txt","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	scanf("%d",a+i);
	for(int i=1;i<=n;++i)
	scanf("%d",b+i);
	dfs(0,0);
	if(l-r>=0)printf("%d\n",l-r);
	else printf("%d\n",r-l);
	return 0;
}

Measured memory_bytes: 256
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll p[30],in[30];

int main()
{
    IOS();
    string s,t;
    cin>>s>>t;
    FILL(p,-1);
    REP(i,SZ(s))
    {
      ll a = s[i] - 'a',b = t[i] - 'a';
      if(p[a] == -1)p[a] = b;
      else if(p[a] != b)
      {
        cout<<"No"<<endl;
        return 0;
      }
    }
    REP(i,26)if(p[i] != -1)in[p[i]] ++;
    bool fg = 1;
    REP(i,26)
    {
      if(in[i] > 1)fg = 0;
    }
    if(!fg)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

}


Measured memory_bytes: 916
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = n//11
b = n%11
res = 0
if b > 6:
    res = 2
elif b > 0:
    res = 1
else:
    res = 0
print(a*2 + res)

Measured memory_bytes: 64620
H, W = map(int, input().split())
S = [input() for _ in range(H)]
  
flag = True
cols = []
rows= []
  
for i in range(0, H):
  flag = True
  for j in range(0, W):
    if S[i][j] == '#':
      flag = False
  if flag:
    cols.append(i)

for i in range(0, W):
  flag = True
  for j in range(0, H):
    if S[j][i] == '#':
      flag = False
  if flag:
    rows.append(i)
      
for i in range(0, H):
  for j in range(0, W):
    if i not in cols and j not in rows:
      print(S[i][j], end="")
  if i not in cols:
    print()

Measured memory_bytes: 4468
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque};
fn main() {
    input!(a:char);
    if b'a' <= a as u8 && a as u8 <= b'z' {
        println!("a");
    }else{
        println!("A");
    }
}


Measured memory_bytes: 2176
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
#define int long long
const int N=1919810;
struct edge{
	int to,nxt,cap;
}e[N];
int head[233],cnt=1,T,n,iter[233],dep[N],ans;
inline void addedge(int u,int v,int w){
	e[++cnt]=(edge){v,head[u],w},head[u]=cnt;
	e[++cnt]=(edge){u,head[v],0},head[v]=cnt;
}
queue<int>q;
void bfs(){
	dep[0]=1;
	for(q.push(0);!q.empty();){
		int u=q.front();q.pop();
		for(int i=head[u];i;i=e[i].nxt)
			if(e[i].cap&&!dep[e[i].to]){
				dep[e[i].to]=dep[u]+1;
				q.push(e[i].to);
			}
	}
}
int dfs(int u,int f){
	if(!f||u==T)return f;
	for(int&i=iter[u];i;i=e[i].nxt)
		if(e[i].cap&&dep[e[i].to]>dep[u]){
			int d=dfs(e[i].to,min(f,e[i].cap));
			if(d){
				e[i].cap-=d,e[i^1].cap+=d;
				return d;
			}
		}
	return 0;
}
int dinic(){
	for(int flow=0;;){
		memset(dep,0,sizeof dep);
		bfs();
		if(!dep[T])return flow;
		memcpy(iter,head,sizeof head);
		while(int f=dfs(0,1145141919810))flow+=f;
	}
}
main(){
	scanf("%lld",&n);
	T=2*n+1;
	for(int i=1,x;i<=n;++i)
		scanf("%lld",&x),ans+=x,addedge(i,T,x+1e9);
	for(int i=1;i<=n;++i){
		addedge(0,i+n,1e9);
		for(int j=i;j<=n;j+=i)
			addedge(i+n,j,1145141919810);
	}
	printf("%lld\n",ans-dinic()+(int)1e9*n);
	return 0;
}

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

int main() {
    long long x, y, z;
    long long red, blue;
    cin >> x >> y >> z;

    long long minrect = min(x*y, y*z);
    minrect = min(minrect, z*x);
    long long maxside = max(x, y);
    maxside = max(maxside, z);

    blue = minrect * ((maxside / 2) + (maxside % 2));
    red = minrect * (maxside / 2);
    long long diff = blue - red;

    cout << diff << endl;
    return 0;

}

Measured memory_bytes: 256
// i_m_arin

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef priority_queue<ll> pqll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef map<ll,ll> mpll;
typedef set<ll> stll;

#define f(i, a, n) 	for(ll i=a; i<(ll)n; i++)
#define f2(i, a, b) for(ll i=a; i<=(ll)b; i++)
#define pb 			push_back
#define ff 			first
#define ss 			second
#define pf			push_front
#define mp			make_pair
#define all(a)		(a).begin(),(a).end()
#define decimal(x)	fixed<<setprecision(x)
#define fsort(a)	sort(all(a))
#define rsort(a)	sort(all(a),greater<>())
#define fast_io		ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem0(a)		memset(a,0,sizeof(a))
#define mem1(a)		memset(a,-1,sizeof(a))
#define lcm(a,b)	(a*b)/__gcd(a,b)
#define ub(v,x)		upper_bound(all(v),x)-v.begin()
#define lb(v,x)		lower_bound(all(v),x)-v.begin()

const ld PI  = acos(-1);
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;
const ll SIZE= 100000;


void solve(){

ll n;
cin>>n;
ll a[n];
f(i,0,n) cin>>a[i];
ll ans=0;
ll mx=a[0];
f(i,1,n){
	mx=max(mx,a[i]);
	ans+=mx-a[i];
}
cout<<ans<<endl;

}


int main(){
	fast_io;
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 5216
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.L;
		long ans=n/500;
		n-=ans*500;
		Console.WriteLine("{0}",ans*1000+(n-(n%5)));
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13140
from bisect import bisect_left, bisect_right
n = int(input())
a = list(map(int, input().split()))
a.append(1000000001)  # > 1,000,000,000
q = int(input())
for i in range(q):
    k = int(input())
    print(bisect_left(a, k), bisect_right(a, k))


Measured memory_bytes: 17212
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, a, n) for(ll i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    ll n, k;
    cin >> n >> k;
    cout << min(n % k, abs((n % k) - k)) << endl;
    return 0;
}


Measured memory_bytes: 256