akhauriyash/Code-Regression huggingface dataset:
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define ld             long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a[N], n, m, k;

void solve()
{
	int i, j;
	cin >> n >> m >> k;

	int x = (k + n - 1) / n;
	int y = (k + m - 1) / m;

	cout << min(x, y);

}

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


	cout << setprecision(9) << fixed;
	clock_t z = clock();
	solve();
	cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
          

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b , c , d;
    cin >> a >> b >> c >> d;
    if ( a * b == c * d ) cout << a * b;
    else cout << max( a * b , c * d );
}

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

int main(){
  string s;
  while(cin >> s){
    int n = s.size();
    string r = s;
    reverse(all(r));

    vector< vector<int> > dp(n+1,vector<int>(n+1,0));
    rep(i,n){
      rep(j,n){
	if(s[i] == r[j])dp[i+1][j+1] = dp[i][j]+1;
	else dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
      }
    }

    int m = (dp[n][n]+1)/2;
    string pal;
    int a = n, b = n;
    while(a!=0 && b!=0 && (int)pal.size()<m){
      if(a>0 && b>0 && dp[a][b] == dp[a-1][b-1]+1 && s[a-1]==r[b-1]){
	pal += s[a-1]; a--; b--;
      }else if(a>0 && dp[a][b] == dp[a-1][b]){
	a--;
      }else if(b>0 && dp[a][b] == dp[a][b-1]){
	b--;
      }else{
	exit(1);
      }
    }
    
    for(int i=dp[n][n]/2-1;i>=0;i--)pal += pal[i];
    cout << pal << endl;
  }
}

Measured memory_bytes: 16900
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#pragma comment(linker, "/STACK:400000000")

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(it=X.begin();it!=X.end();it++)
#define iss istringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sst stringstream
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int N,M,L,a[8],b[8],c[8],x[8];
ll ans;

ll nCk(int n,int k){
	if(n<k)return 0;
	ll res=1;
	rep2(i,n-k+1,n+1)res*=i;
	rep2(i,1,k+1)res/=i;
	return res;
}

void f(int cur,int blank){
	if(x[cur-1]>M)return;
	if(cur==L){
		int count[21]={};
		rep(i,cur)count[x[i]]++;
		rep(i,cur)rep(j,cur)rep(k,cur){
			int needed[21]={};
			rep(l,7){
				needed[x[i]+l]+=a[l];
				needed[x[j]+l]+=b[l];
				needed[x[k]+l]+=c[l];
			}
			ll res=1;
			rep(l,21)if(needed[l]>count[l])goto fail;
			rep(l,14)res*=nCk(N,count[l]);
			ans+=res*nCk(M-x[cur-1]+blank,blank);
			return;
			fail:;
		}
		return;
	}
	x[cur]=x[cur-1];
	f(cur+1,blank);
	x[cur]=x[cur-1]+1;
	f(cur+1,blank);
	x[cur]=x[cur-1]+2;
	f(cur+1,blank+1);
}

int main(){
	while(cin>>N>>M>>L && N){
		rep(i,7)a[i]=b[i]=c[i]=0;
		string h;
		rep(i,L){
			cin>>h;
			if(h[0]=='a')a[h.sz-1]++;
			if(h[0]=='b')b[h.sz-1]++;
			if(h[0]=='c')c[h.sz-1]++;
		}
		ans=0;
		x[0]=1;
		f(1,1);
		printf("%.11f\n",1.*ans/nCk(N*M,L));
	}
}

Measured memory_bytes: 972
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

int main()
{
    int n;
    while(cin >> n && n)
    {
        vector<int> t;
        int tt;
        REP(n){cin >> tt; t.push_back(tt);}
        
        long long ans = 0;
        sort(all(t), greater<int>() );
        REP(n)for(int j = i + 1;j<n;j++) ans += t[j];

        cout << ans << endl;

    }

    return 0;
}

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

using namespace std;

int main()
{
    int n, x;
    cin >> n;
    vector <int> a(n), b(n);
    for(int i = 0; i < n; i++)
        cin >> a[i];
    long long sum = 0, mn = 1e9;
    int negative = 0, zero = 0;
    for(int i = 0; i < n; i++)
    {
        sum += abs(a[i]);
        if(mn > abs(a[i]) && a[i] != 0)
            mn = abs(a[i]);
        if(a[i] < 0)
            negative++;
        else if(a[i] == 0)
            zero++;
    }

    if(!zero && (negative & 1))
        sum -= (2 * mn);
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N, A, B, C, D;
  string S;
  cin >> N >> A >> B >> C >> D >> S;
  bool AisOK = true, BisOk = true, croosisOK = true;
  for (int i = A - 1; i < C - 1; i++)
  {
    if (S[i] == '#' && S[i + 1] == '#')
      AisOK = false;
  }

  for (int i = B - 1; i < D - 1; i++)
  {
    if (S[i] == '#' && S[i + 1] == '#')
      BisOk = false;
  }

  if (D < C)
  {
    croosisOK = false;

    for (int i = B - 1; i <= D - 1; i++)
    {
      if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.')
        croosisOK = true;
    }
  }
  if (AisOK && BisOk && croosisOK)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 640
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<random>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#define endl "\n"
#define fi first
#define se second
#define db double
#define gcd __gcd
#define pb push_back
#define mp make_pair
#define lowbit(x) (x & (-x))
#define PII  pair<int, int> 
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << endl
#define rep(i, a, b) for(__typeof(b) i = a; i <= (b); i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i >= (b); i--)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template<class T> inline T qmin(T a, T b) { return a < b ? a : b; }
template<class T> inline T qmax(T a, T b) { return a > b ? a : b; }
typedef long long ll;
typedef unsigned long long ull;
const db eps = 1e-9;
const db PI = acos(-1);
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e5 + 5;//remember to modify it, No RE or MLE
const ll INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;
ll qpow(ll x, ll y) { ll ret = 1; for( ; y; y >>= 1, x = (x * x) % mod) if(y & 1) ret = (ret * x) % mod; return ret; }

inline int read(){
	char ch = getchar();
	int x = 0, f = 1;
	while(ch < '0' || ch > '9'){
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while('0' <= ch && ch <= '9'){
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}

int n, W;
int w[105], v[105];
ll dp[maxn];

int main()
{
	n = read(), W = read();
	rep(i, 1, n) w[i] = read(), v[i] = read();
	rep(i, 1, n){
		Rep(j, W, w[i]){
			dp[j] = qmax(dp[j], dp[j-w[i]] + v[i]);
		}
	}
	printf("%lld\n", *max_element(dp, dp + W + 1));
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

struct P {
  double x;
  double y1, y2;                // y1 < y2
  bool f;                       // 0:in, 1:out
  int id;
};
const bool operator<(const P &a, const P &b) {
  return a.x != b.x ? a.x < b.x : a.f < b.f;
}

typedef pair<double,double> pdd;
int main() {
  int n;
  int nn = 0;
  while(cin >> n, n) {
    vector<P> v;
    REP(i,n) {
      double x,y,r;
      cin >> x >> y >> r;
      v.push_back((P){x-r,y-r,y+r,0,i});
      v.push_back((P){x+r,y-r,y+r,1,i});
    }
    sort(ALL(v));
    double x = -INF;
    double res = 0;
    vector<pdd> ys(n);
    double dy = 0;
    FOR(it, v) {
//      printf("%f %f (%f,%f) %d\n", x,it->x,it->y1,it->y2,it->f);
      
      if (x == -INF) x = it->x;
      
      res += (it->x - x) * dy;
      
      x = it->x;
      
      if (it->f == 0)
        ys[it->id] = pdd(it->y1, it->y2);
      else {
        ys[it->id] = pdd(0,0);
      }

      // dy ÌvZ
      double y1=-INF,y2=-INF;       // »Ýl¦Ä¢éÍÍ
      dy = 0;
      vector<pdd> tmp = ys;
      sort(ALL(tmp));
      FOR(jt, tmp) {
        if (jt->first == 0 && jt->second == 0) continue;
        if (y2 <= jt->first) {
          dy += y2-y1;
          y1 = jt->first;
          y2 = jt->second;
        } else if (y2 <= jt->second) {
          y2 = jt->second;
        } else {      
        }
      }
      dy += y2-y1;
    }
    printf("%d %.2f\n", ++nn, res);
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        if(b > a){
            puts("No");
            continue;
        }else if(b > d){
            puts("No");
            continue;
        }else if(c >= b){
            puts("Yes");
            continue;
        }
        ll g = __gcd(b, d);
        ll q = b-c-g+a%g;
        puts(q <= 0 ? "Yes" : "No");
    }
    return 0;
}


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

int main(void){
	int N,M;
	while(cin>>N>>M,N|M){
		vector<int> h(N),w(M);
		rep(i,N)cin>>h[i];
		rep(i,M)cin>>w[i];
		map<int,int> mapH,mapW;
		rep(i,N){
			int sum=0;
			rep(j,N)if(i<=j){
				sum+=h[j];
				mapH[sum]++;
			}
		}
		rep(i,M){
			int sum=0;
			rep(j,M)if(i<=j){
				sum+=w[j];
				mapW[sum]++;
			}
		}
		int res=0;
		for(auto itH:mapH){
			int H=itH.first,cntH=itH.second;
			res += cntH*mapW[H];
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 34352
n,m = [int(x) for x in input().split()]
ks = []
for _ in range(m):
    ks.append([int(x) for x in input().split()])
p = [int(x) for x in input().split()]
ans = 0
for i in range(2**n):
    li = []
    flag = True
    for j in range(n):
        if (i>>j) & 1:
            li.append(1)
        else:
            li.append(0)
    
    for o,j in enumerate(ks):
        cnt = 0
        for l in range(1,j[0]+1):
            if li[j[l]-1]==1:
                cnt+=1
        if cnt%2!=p[o]:
            flag = False
    if flag:
        ans+=1
print(ans)

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(40)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

pll A[10];

double calc(vector<ll> &v) {
    ll N = v.size();
    double ret = 0;

    REP(i, N - 1) {
        ret += sqrt(pow(A[v[i]].first - A[v[i + 1]].first, 2) + pow(A[v[i]].second - A[v[i + 1]].second, 2));
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i].first >> A[i].second;
    }

    vector<ll> v;
    REP(i, N) {
        v.push_back(i);
    }

    double ans = 0;
    ll cnt = 0;
    do {
        ans += calc(v);
        cnt++;
    } while (next_permutation(v.begin(), v.end()));

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

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

int main() {
    long long int a, b, n;
    
    while (std::cin >> a >> b >> n) {
        long long int ans = 0;

        a %= b;

        for (long long int i = 0; i < n; ++i) {
            a *= 10.; 
            ans += (double) a / b;
            a %= b;
        }

        std::cout << ans << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1156
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

int sp[101][101];

main(){
	int e;
	cin>>e;
	int flag=0;
	while(e--){
		if(flag)puts("");
		++flag;
		int n;
		cin>>n;
		if(n==1){
			cout<<"#"<<endl;
			continue;
		}
		memset(sp,0,sizeof(sp));
		
		int y=n-1,x=0,d=0;
		int c=0;
		while(true){
			
			
			if(d==0){
				if(sp[y-1][x+1]==1)break;
				int cy=y;
				while(cy>=1){
					if(cy>=2 && sp[cy-2][x]==1)break;
					--cy;
				}
				if(y==cy)break;
				d=(d+1)%4;
				for(;cy<=y;y--)sp[y][x]=1;
				++y;
				continue;
			}
			
			if(d==1){
				if(sp[y+1][x+1]==1)break;
				int cx=x;
				while(cx<=n-2){
					if(cx<=n-3 && sp[y][cx+2]==1)break;
					++cx;
				}
				if(x==cx)break;
				d=(d+1)%4;
				for(;cx>=x;x++)sp[y][x]=1;
				--x;
				continue;
			}
			
			if(d==2){
				if(sp[y+1][x-1]==1)break;
				int cy=y;;
				while(cy<=n-2 && !(cy<=n-3 && sp[cy+2][x]==1))++cy;
				if(cy==y)break;
				d=(d+1)%4;
				for(;cy>=y;y++)sp[y][x]=1;
				--y;
				continue;
			}
			
			if(d==3){
				if(sp[y-1][x-1]==1)break;
				int cx=x;
				while(cx>=1 && !(cx>=2 && sp[y][cx-2]==1))--cx;
				if(x==cx)break;
				d=(d+1)%4;
				for(;cx<=x;x--)sp[y][x]=1;
				++x;
				continue;
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(sp[i][j])printf("#");
				else printf(" ");
			}
			puts("");
		}

	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <queue>

int main()
{
  long long q;
  scanf("%lld", &q);

  long long sum = 0;
  long long sumh = 0;
  long long B = 0;

  std::priority_queue<long long, std::vector<long long>, std::greater<long long>> gq;
  std::priority_queue<long long> sq;
  
  bool first = true;
  for (long long i = 0; i < q; ++i)
  {
    long long type;
    scanf("%lld", &type);
    if (type == 1)
    {
      long long a, b;
      scanf("%lld%lld", &a, &b);
      B += b;
      sum += a;
      if (first)
      {
        sumh += a;
        sq.emplace(a);
        first = false;
      }
      else if (gq.size() == sq.size())
      {
        if (gq.top() <= a)
        {
          sq.emplace(gq.top());
          sumh += gq.top();
          gq.pop();
          gq.emplace(a);
        }
        else
        {
          sq.emplace(a);
          sumh += a;
        }
      }
      else
      {
        if (sq.top() >= a)
        {
          gq.emplace(sq.top());
          sumh -= sq.top();
          sq.pop();
          sq.emplace(a);
          sumh += a;
        }
        else
        {
          gq.emplace(a);
        }
      }
    }
    else
    {
      printf("%lld %lld\n", sq.top(), (sq.size() - gq.size()) * sq.top() + sum - 2 * sumh + B);
    }
  }
  return 0;
}

Measured memory_bytes: 3828
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    map <int,int> c;
    int n,k; 
    cin >> n >> k ; 
    vi  dp(n+2,0),s,l(k),r(k),pref(n+1,0);
    for (int i=0;i<k;i++) 
        cin >> l[i] >> r[i] ; 
    pref[1] = dp[1] = dp[0] = 1 ; 
    for (int i=2;i<=n;i++){
        for (int j=0;j<k;j++){
            int ii = i - r[j] - 1 ; 
            int jj = i - l[j] ; 
            if (jj >= 1)  dp[i] += pref[jj] - pref[max(0LL,ii)] ; 
            dp[i] %= mod ; 
        }
        pref[i] = pref[i-1] + dp[i] ; 
    }
    co( dp[n] ) ; 
}

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


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

vector<long long>vec;

int main(){
	long long x,y,z,k;
	cin>>x>>y>>z>>k;
	long long a[x+1],b[y+1],c[z+1];
	
	for(int i=0;i<=x;++i)
		a[i]=0;
	for(int i=0;i<=y;++i)
		b[i]=0;
	for(int i=0;i<=z;++i)
		c[i]=0;
	
	for(int i=0;i<x;++i)
		cin>>a[i];
	for(int i=0;i<y;++i)
		cin>>b[i];
	for(int i=0;i<z;++i)
		cin>>c[i];
		
	sort(a,a+x,greater<long long>());
	sort(b,b+y,greater<long long>());
	sort(c,c+z,greater<long long>());
	
	for(long long i=0;i<x;++i)
		for(long long j=0;j<y;++j)
			for(long long l=0;l<z;++l){
				if((i+1)*(j+1)*(l+1)<=k){
					vec.push_back(a[i]+b[j]+c[l]);
					continue;}
				else break;
			}
	sort(vec.begin(), vec.end(), greater<long long>());
	for(long long i=0;i<k;++i)
		cout<<vec[i]<<endl;
	return 0;
}

Measured memory_bytes: 1400
import numpy as np
h,w,k=map(int,input().split())
c=[]
blacks=0
for hi in range(h):
    c.append(list(input()))
    blacks+=c[-1].count('#')
c=np.array(c)
#print(c)
x=h+w
bx=2**x
ans=0
max_ansi=0
for i in range(bx):
    bin_x=bin(i)[2:].zfill(x)
#    print(bin_x)
    line=[]
    row=[]
    ansi=0
    for j in range(h):
        if(bin_x[j]=='1'):
            line.append(j)
    for j in range(w):
        if(bin_x[h+j]=='1'):
            row.append(j)
    line=np.array(line)
    row=np.array(row)
    not_line=np.array(list(set([i for i in range(h)]) - set(line)))

    for j in range(x):
        if(bin_x[j]=='1'):
            if(j<h):
                ansi+=np.count_nonzero(c[j,:]=='#')
            elif(len(not_line)>0):
                m=j-h
                ansi+=np.count_nonzero(c[not_line[:],m]=='#')
    ansi=blacks-ansi
    if(ansi==k):
        ans+=1
#    print(ansi,ans,line,row,not_line)
print(ans)



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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using tsii = tuple<string, int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int a,b,ans=0, now=1;
    cin>>a>>b;
    while (now<b)
    {
        now+=a-1;
        ans++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
void irekae(int& a,int& b){
  if(a>b){
    int tmp;
    tmp=a;
    a=b;
    b=tmp;
  }
}
int san(int a,int b,int c){
  irekae(a,b);
  irekae(b,c);
  irekae(a,b);
  if(c-a-b<0){
    return 1;
  }
  else{
    return 0;
  }
}
int main (){
  int N,ans=0;
  cin>>N;
  if(N<=2){
    cout<<0;
    return 0;
  }
  vector<int>L(N);
  rep(i,N) cin>>L[i];
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      for(int k=j+1;k<N;k++){
        if(L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i]){
          ans+=san(L[i],L[j],L[k]);
        }
      }
    }
  }
  cout<<ans;
}

Measured memory_bytes: 3580
N=int(input())
dic={}

for x in map(int,input().split()):
    if dic.get(x,0)==0:
        dic[x]=1
    else:
        dic[x]+=1
arr=[]
for k in dic.keys():
    if dic[k] >=4:
        arr.append(k)
        arr.append(k)
    elif dic[k] >=2:
        arr.append(k)

arr=sorted(arr)
if len(arr) < 2:
    ans=0
else:
    ans=arr[-1]*arr[-2]
print(ans)

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

int main()
{
  int N, M;
  cin >> N >> M;
  vector<vector<int>> s(N);
  vector<int> p(M);
  for (int i = 0; i < M; i++) {
    int t;
    cin >> t;
    for (int j = 0; j < t; j++) {
      int k;
      cin >> k;
      s[k-1].emplace_back(i);
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int res = 0;
  for (int i = 0; i < 1 << N; i++) {
    vector<int> t(M, 0);
    for (int j = 0; j < N; j++) {
      if (((1 << j) & i) == 0) continue;
      for (auto x : s[j]) {
        t[x]++;
      }
    }
    for (int j = 0; j < M; j++) {
      if (t[j] % 2 != p[j]) {
        res--;
        break;
      }
    }
    res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

    static int N;
    static int M;
    static int A;
    static long B;
    static long C;
//    static int[][] map;
    static int min = 9999999;


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        N = scanner.nextInt();

        int ok = 0;
        for (int i = 0; i <= N; i++) {
            if(i % 4 != 0)continue;
            if(((N - i) % 7) != 0)continue;
            ok = 1;
        }

        if(ok == 1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }


    }




}



Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

mint dp[110][10];

int main() {
  ll h, w, k;
  cin >> h >> w >> k;
  dp[0][1] = 1;
  rep(i, h) rep(s, 1 << (w - 1)) {
    vl v(w + 1, 0);
    rep(j, w - 1) if(s >> j & 1) v[j + 1]++;
    bool ng = false;
    rep2(j, 1, w - 1) if(v[j] && v[j + 1]) ng = true;
    if(ng) continue;
    rep2(j, 1, w + 1) {
      if(v[j - 1])
        dp[i + 1][j - 1] += dp[i][j];
      else if(v[j])
        dp[i + 1][j + 1] += dp[i][j];
      else
        dp[i + 1][j] += dp[i][j];
    }
  }
  cout << dp[h][k] << endl;
}

Measured memory_bytes: 3616
lst = []

for i in range(20):
    r = int(input())
    lst.append(r)
    
for i in range(10):
    for j in range(9,i,-1):
        if lst[j] < lst[j-1]:
            lst[j],lst[j-1] = lst[j-1],lst[j]

for i in range(10,20):
    for j in range(19,i,-1):
        if lst[j] < lst[j-1]:
            lst[j],lst[j-1] = lst[j-1],lst[j]

W = lst[9]+lst[8]+lst[7]
K = lst[19]+lst[18]+lst[17]

print(W,K)


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

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

    int a0 = 0, b[3];
    b[0] = c[0][0] - a0;
    b[1] = c[0][1] - a0;
    b[2] = c[0][2] - a0;
    if(c[1][0] - b[0] == c[1][1] - b[1] && c[1][1] - b[1] == c[1][2] - b[2]) {
        if(c[2][0] - b[0] == c[2][1] - b[1] && c[2][1] - b[1] == c[2][2] - b[2]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int W, H, x, y, r;
    scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
    if(x <= W-r && x >= r && y >= r && y <= H-r){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)

typedef long long ll;
double EPS = 1e-6;
const double g = 9.8;
const int N = 50;
int n, v, X, Y;
int L[N], R[N], T[N], B[N];

//速度vyで上に打ち出した際のt秒後の位置を計算
double calc(double vy, double t) {
	return vy*t - g*t*t*0.5;
}

//aのlb,ubに対する相対位置関係(lbより下:-1, lb以上ub以下:0, ubより上:1)
int relPos(double lb, double ub, double a) {
	return a < lb+EPS ? -1 : (a > ub-EPS ? 1 : 0);
}

//点(x,y)を通るように打ち出したときに豚に卵をぶつけられるか判定
bool success(double x, double y) {
	double a = g*g*0.25, b = g*y-v*v, c = x*x+y*y;
	double D = b*b - a*c*4.0;

	if (D<0.0 && D>-EPS) D = 0.0;
	if (D<0.0) return false;

	for (int d=-1; d<=1; d+=2) {
		double t2 = (-b + d*sqrt(D)) / (a*2.0);
		if (t2<=0) continue;
		double t = sqrt(t2);
		double vx = x / t, vy = (y + g*t*t*0.5) / t;

		double yt = calc(vy, X / vx);
		if (yt < Y-EPS) continue;

		bool ok = true;
		for (int i=0; i<n; i++) {
			if (L[i]>=X) continue;

			if (L[i]<=X && X==R[i] && Y<=T[i] && B[i]<=yt) ok = false;
//			if (X==R[i] && Y<=T[i] && B[i]<=yt) ok = false;

			int yL = relPos(B[i], T[i], calc(vy, L[i]/vx));
			int yR = relPos(B[i], T[i], calc(vy, R[i]/vx));
			int xH = relPos(L[i], R[i], vx*(vy/g));
			int yH = relPos(B[i], T[i], calc(vy, vy/g));

			if (xH==0 && yH>=0 && yL<0) ok = false;
			if (yL*yR<=0) ok = false;
		}
		if (ok) return true;
	}
	return false;
}

int main() {

	scanf("%d%d%d%d ", &n, &v, &X, &Y);
	for (int i=0; i<n; i++)
		scanf("%d%d%d%d ", L+i, B+i, R+i, T+i);

	//爆撃成功後に障害物に当っても成功とみなすために
	//Xより右にある障害物を消す
	for (int i=0; i<n; i++)
		R[i] = min(R[i], X);

	bool ok = success(X, Y);

	for (int i=0; i<n; i++) {
		ok |= success(L[i], T[i]);
		ok |= success(R[i], T[i]);
	}

	puts(ok ? "Yes" : "No");
    
	return 0;
}

Measured memory_bytes: 1172
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




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

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}
bool graph[50][50];
bool reached[50];
ll n,m,ans=0;
void dfs(ll tmp){
  reached[tmp]=true;
  rep(i,n){
    if(!graph[tmp][i]) continue;
    if(reached[i]) continue;
    dfs(i);
  }
}
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  
  cin>>n>>m;
  
  vector<ll> a(m),b(m);
  rep(i,m){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
  }
  
  rep(i,m){
    rep(j,m) graph[a[j]][b[j]]=graph[b[j]][a[j]]=true;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
    rep(j,n) reached[j]=false;
    dfs(0);
    bool flag=true;
    rep(j,n) if(!reached[j]) flag=false;
    if(!flag) ans++;
  }
  cout<<ans<<endl;
}

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

int main() {
  string s;
  int ch;
  int n =0;
  cin >> s;
  ch = s.size();
  for (int i = 0; i < ch; i++){
    if (s.at(i)== '0'){
      n = n +1;
    }
  }
  if (n > ch-n){
    cout << (ch-n) *2 <<endl;
  }else{
    cout << n*2 <<endl;
  }

  
  
}

Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int x[210000];
int y[210000];
int cnt[210000];
pair<int,int>ev[410000];
int main(){
	int a;scanf("%d",&a);
	int xl=mod;
	int xr=0;
	int yl=mod;
	int yr=0;
	for(int i=0;i<a;i++){
		scanf("%d%d",x+i,y+i);
		if(x[i]>y[i])swap(x[i],y[i]);
		xl=min(xl,x[i]);
		xr=max(xr,x[i]);
		yl=min(yl,y[i]);
		yr=max(yr,y[i]);
		ev[i*2]=make_pair(x[i],i);
		ev[i*2+1]=make_pair(y[i],i);
	}
	std:;sort(ev,ev+a*2);

	long long ret=(long long)(xr-xl)*(yr-yl);
	//ret=min(ret,(long long)(yr-xl)*ABS(yl-xr));
	int left=0;
	int z=a;
	for(int i=0;i<a*2;i++){
		if(cnt[ev[i].second]==0)z--;
		cnt[ev[i].second]++;
		while(z==0){
			ret=min(ret,(long long)(yr-xl)*(ev[i].first-ev[left].first));
			cnt[ev[left].second]--;
			if(cnt[ev[left].second]==0)z++;
			left++;
		}
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 5760
n = int(input())
num = list(map(int, input().split()))

if n == 1:
    print(num[0])
else:
    counter = 0
    for i in (reversed(num)):
        if counter == 0:
            print(i, end="")
        elif counter == n-1:
            print(" {}".format(i))
        else:
            print(" {}".format(i), end="")
        counter += 1


Measured memory_bytes: 5608
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

x, y, a, b, c = LI()
p = LI()
q = LI()
r = LI()

p.sort(reverse=1)
q.sort(reverse=1)
A = p[:x] + q[:y] + r
A.sort(reverse=1)
print(sum(A[:x+y]))



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

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

  bool f = false;
  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      f = true;
      break;
    }
  }
  if (!f) {
    cout << "NG" << endl;
  } else {
    cout << "OK" << endl;
  }
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
string S;
map <int, int> mp;
int main(){
    long long int i, j, p=0, a, b, t;
    cin >> S;
    mp[0]=1;
    b = 0;
    a = 1;
    for(i = S.size()-1; i>=0;i-- ){
        b = (b+(S[i]-'0')*a)%2019;
        a = (a*10)%2019;
        p += mp[b];
        mp[b]++;
        //cout << b <<endl;
    }

    cout << p;
}


Measured memory_bytes: 3728
#include<iostream>
#include<stdlib.h>
using namespace std;

int main(){
	int r, c; //r:行数　c:列数
	int array[101][101];
	cin>>r>>c;

	//配列初期化
	for(int i=0; i<101; i++){
		for(int j=0; j<101; j++){
			array[i][j]=0;
		}
	}
	//配列入力
	for(int i=0; i<r; i++){
		for(int j=0; j<c; j++){
			cin>>array[i][j];
		}
	}
	//行の和
	for(int i=0; i<r; i++){
		for(int j=0; j<c; j++){
			array[i][c]+=array[i][j];
		}
	}
	//列の和
	for(int i=0; i<c; i++){
		for(int j=0; j<r; j++){
			array[r][i]+=array[j][i];
		}
	}
	for(int i=0; i<r; i++){
		array[r][c]+=array[i][c];
	}
	//cout<<array[r][0]<<endl;
	
	for(int i=0; i<r+1; i++){
		for(int j=0; j<c+1; j++){
			cout<<array[i][j];
			if(j==c)cout<<endl;
			else cout<<" ";			
		}

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


Measured memory_bytes: 3116
#include<iostream>
using namespace std;
#include<vector>
#include<set>
#define int long long int
int32_t main()
{
     int n;
     cin>>n;
     //int answer=0;
     set<int> s;
     for(int i=1;i*i<=n;i++)
     {
		 if(n%i==0)
		 {
              int f1=i;
              int f2=n/i;
              int factor=f2-1;
              if(factor!=0&&n/factor==n%factor)
              {
				  s.insert(factor);
			  }
              factor=f1-1;
              if(factor!=0&&n/factor==n%factor)
              {
				  s.insert(factor);
			  }
		 }
	 }
	 int sum=0;
	 for(int x:s)
	    sum+=x;
	 cout<<sum<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

#define INF 100000

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<bool>>a(H, vector<bool>(W,0));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            char c;
            cin >> c;
            if (c == '#')a[i][j] = 1;
        }
    }

    set<int>line, row;
    //横に観て無視する列を決める
    for (int i = 0; i < H; i++) {
        bool bel_flag = true;
        for (int j = 0; j < W; j++) {
            if (a[i][j] ==1) {
                bel_flag = false;
                break;
            }
        }
        if (bel_flag)line.insert(i);
    }

    //縦に観て無視する行を決める
    for (int i = 0; i < W; i++) {
        bool bel_flag = true;
        for (int j = 0; j < H; j++) {
            if (a[j][i] == 1) {
                bel_flag = false;
                break;
            }
        }
        if (bel_flag)row.insert(i);
    }

    //答え出力
    for (int i = 0; i < H; i++) {
        if (line.find(i) != line.end())continue;
        for (int j = 0; j < W; j++) {
            if (row.find(j) != row.end())continue;
            cout << ((a[i][j]) ? "#" : ".");
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/08/20 03:55:25
// -----------------------------------

#include <bits/stdc++.h>
#include <atcoder/fenwicktree.hpp>

using namespace std;
using ll = long long;

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

  int n,q; cin>>n>>q;
  atcoder::fenwick_tree<long long> bit(n);
  for (int i = 0; i < n; i++) {
    int a; cin>>a;
    bit.add(i, a);
  }
  while (q--) {
    int t; cin>>t;
    if (t == 0) {
      int p,x; cin>>p>>x;
      bit.add(p, x);
    } else {
      int l,r; cin>>l>>r;
      cout << bit.sum(l, r) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 8244
N, x = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
for i in range(1, len(a)):
    # 2組の合計がxよりも大きいなら
    if a[i-1] + a[i] > x:
        # 右側の数が0より大きいなら食べる
        if a[i] > 0:
            # 右側の箱の飴をすべて食べてもx以上ならすべて食べる
            if (a[i-1] + a[i] - x) > a[i]:
                ans += a[i]
                a[i] = 0
            # 右側の箱の飴を食べるだけでx以下になるならその分だけ食べる
            else:
                ans += (a[i-1] + a[i] - x)
                a[i] = a[i] - (a[i-1] + a[i] - x)

        # 右の箱を食べただけでx以下にならない時は左側の箱の飴も食べる
        if a[i-1] + a[i] > x:
            # 左側の箱の飴をすべて食べる
            if (a[i-1] + a[i] - x) > a[i-1]:
                ans += a[i-1]
                a[i-1] = 0
            # 左側の箱の飴をx以下になるだけ食べる
            else:
                ans += (a[i-1] + a[i] - x)
                a[i-1] = a[i-1] - (a[i-1] + a[i] - x)

print(ans)


Measured memory_bytes: 14592
#include <bits/stdc++.h>
using namespace std;
 int main(){
 int a,b,c;
 cin>>a>>b>>c;

 if(a > b) swap(a, b);
 if(b > c) swap(b, c);
 if(a > b) swap(a, b);

 cout<<a<<" "<<b<<" "<<c<<endl;
 return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <cmath>
#include <limits.h>
using namespace std;

int N;
int F[110][12];
int P[110][12];

int change(int n){
	int b = 0;
	int base = 1;
	while(n>0){
		b += (n%2)*base;
		n = n/2;
		base *= 10;
	}
	return b;
}

int main(){
	//string t = to_string(change(512)); 
	//cout << t[2] << endl;
	while(cin >> N && N > 0){
		for(int i=0;i<N;i++){
			for(int j=0;j<10;j++){
				cin >> F[i][j];
			}
		}
		for(int i=0;i<N;i++){
			for(int j=0;j<11;j++){
				cin >> P[i][j];
			}
		}
		long long  ans = LONG_MIN;
		for(int i=1;i<1024;i++){
			long long  ansnow = 0;
			string s = to_string(change(i));
			while(s.size()<10){
				s = '0' + s;
			}
			int open[12] = {0};
			for(int j=0;j<10;j++){
				char sj = s[j];
				int n = atoi(&sj);
				if(n==1) open[j] = 1;
				else open[j] = 0;
			}
			for(int j=0;j<N;j++){
				int count = 0;
				for(int k=0;k<10;k++){//店iと被る数
					if(open[k] == 1 && F[j][k] == 1) count++;
				}
				ansnow += P[j][count];
			}
			if(ansnow>ans) ans = ansnow;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
typedef long long ll;

map<char,queue<char>> mp;

void step(char c){
  if(mp[c].empty()){
    char ans = c + 'A'-'a';
    cout << ans << endl;
    return;
  }
  char next = mp[c].front();
  mp[c].pop();
  step(next);
  return;
}

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  for(char p : a) mp['a'].push(p);
  for(char p : b) mp['b'].push(p);
  for(char p : c) mp['c'].push(p);
  step('a');
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#define all(c) c.begin(),c.end()
#define INF 100000000
using namespace std;
typedef pair<int,int> P;
int n;
vector<int> dp;
vector<int> v;
vector<bool> no;
vector<bool> check;
int ans;
bool sh(int pos){
	if(check[pos]||no[pos]==false){
		return false;
	}
	if(pos>=n-1||v[pos]==0||no[pos]==true)
		return true;
	check[pos]=true;
	return no[pos]=sh(pos+v[pos]);
}



void ret(int pos,int cnt){
	if(pos>=n-1){
		ans=min(cnt,ans);
		return;
	}
	if(dp[pos]!=-1){
		if(cnt>=dp[pos])
			return;
		dp[pos]=cnt;
	}else
		dp[pos]=cnt;
	
	if(v[pos]!=0){
		ret(pos+v[pos],cnt);
		return;
	}
	for(int i=1;i<=6;i++){
		if(pos+i<=n-1&&no[pos+i])
		ret(pos+i,cnt+1);
	}
}
int dfs(){
	queue<P> que;
	que.push(P(0,0));
	int ans=INF;
	vector<int> d(n,INF);
	while(!que.empty()){
		P pos=que.front();
		que.pop();
		//cout<<pos.first<<endl;
		if(d[pos.first]<=pos.second){
			continue;
		}
		if(pos.first>=n-1){
			if(ans==INF){
				ans=pos.second;
			}else{
				if(ans>=pos.second)
					ans=pos.second;
				else
					break;
			}
		}
		d[pos.first]=pos.second;
		if(v[pos.first]!=0){
			que.push(P(v[pos.first]+pos.first,pos.second));
			continue;
		}
		for(int i=1;i<=6;i++){
			if(i+pos.first<=n-1&&no[i+pos.first]){
				que.push(P(pos.first+i,pos.second+1));
			}
		}
	}
	return ans;
}
int main(){
	cin>>n;
	no.resize(n);
	check.resize(n);
	v.resize(n);
	dp.resize(n);
	fill(all(no),true);
	
	fill(all(dp),-1);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	fill(all(check),false);
	for(int i=1;i<n-1;i++){
		if(no[i]){
			fill(all(check),false);
			no[i]=sh(i);
		}
	}
	//ret(0,0);
	
	cout<<dfs()<<endl;
	return 0;
}

Measured memory_bytes: 2228
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include <map>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()
int main() {
	int n;
	cin >> n;
	map<string, bool> mp;
	int ans = 0;
	rep(i, n) {
		string s;
		cin >> s;
		if (mp.find(s) == mp.end()) {
			mp[s] = true;
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 18628
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	long long Q,H,S,D;
	scanf("%lld %lld %lld %lld", &Q, &H, &S, &D);
	long long N;
	scanf("%lld", &N);

	long long min = 8*Q;
	long long min2;
	bool isD = false;
	if(min>4*H) min = 4*H;
	if(min>2*S) min = 2*S;
	min2 = min;
	if(min>D){
		isD = true;
		min = D;
	}
	long long ans;
	if(isD){
		ans = (N/2)*D + (N%2)*min2/2;
	}else{
		ans = N*min/2;
	}

	printf("%lld\n", ans);

	return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  ll n, k; std::cin >> n >> k;
  n = n % k;
  chmin(n, abs(n-k));
  std::cout << n << "\n";
}


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

 
// Driver code to test above functions
int32_t main()
{
 
    long long n, ans = 0;
    cin >> n;
    map<long long, int> mp;
    for(int i=1;i<=n;i++)
    {
        long long x;
        cin >> x;
 
        ans += mp[i-x];
        mp[i+x]++;
    }
 
    cout << ans;
 
    return 0;
 
} 


Measured memory_bytes: 26300
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef long long llong;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  llong n,k,to;
  to=0;
  cin>>n>>k;
  vector<int> h(n);
  for(llong i=0;i<n;i++){
    cin>>h.at(i);
  }
  sort(h.begin(),h.end());
  for(llong i=0;i<n-k;i++){
    to+=h.at(i);
  }
  cout<<to<<endl;
  return 0;
}


Measured memory_bytes: 1024