akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    int A, B;
    cin >> A >> B;

    cout << (A + B) % 24 << endl;

    return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;
int A,B,C,D,E,F;
int X[10001],Y[10001];
int main() {
	cin>>A>>B>>C>>D>>E>>F;

	int S,T;
	S=A;
	T=E;
	if(S>B)S=B;
	if(S>C)S=C;
	if(S>D)S=D;
	if(T>F)T=F;
	int R=A+B+C+D+E+F;
	cout<<R-S-T<<endl;
	return 0;
}

Measured memory_bytes: 3040
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    ll X, Y;
    cin >> X >> Y;
    ll sum = 0;
    for(ll num = X; num <= Y; num *= 2){
        sum++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
res = [[False for _ in range(m)] for _ in range(n)]

for i in range(n):
    o = list(map(int, input().split()))
    for j, x in enumerate(o):
        if j != 0:
            res[i][x - 1] = True

res = list(zip(*res))

ans = sum(1 for x in res if all(x))

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#define lli long long

lli dfs(lli n, lli num,lli a,lli b,lli c) {
	lli ans = 0;
	if (n < num) {
		return 0;
	}
	if (a > 0 && b > 0 && c > 0) ans++;
	
	ans+=dfs(n, num*10+3,a+1,b,c)+dfs(n, num * 10 + 5,a,b+1,c) + dfs(n, num * 10 + 7,a,b,c+1);
	return ans;
}


int main() {
	lli n;
	std::cin >> n;
	lli num = 0, a = 0, b = 0, c = 0;
	std::cout << dfs(n, num,a,b,c); 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
int main()
{
       ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
       map<string,int>a;
       int n;
       cin >> n;
       for (int i=0; i<n; i++)
       {
             string s;
             cin >> s;
             a[s]++;
       }
       cout <<"AC" << " x " <<a["AC"] << endl;
       cout << "WA x "<<a["WA"] << endl;
       cout << "TLE  x "<<a["TLE"] << endl;
       cout << "RE  x "<<a["RE"] << endl;
	return 0;
}





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

int main() {
    int n, k, x, y, ans = 0;
    cin >> n >> k >> x >> y;
    if(n <= k) ans = n * x;
    else ans = k * x + (n - k) * y;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<db , db>
#define pll pair<ll , ll>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define mod1 998244353 
#define inf 1000000000000000007
#define eps 0.000001
#define stp fixed<<setprecision(20)
#define endl '\n'

const ll N=200005;
ll a[N],b[N],val[N];
vll fact[N];

void sieve()
{
    for(ll i=1;i<N;i++)
    {
        fact[i].pb(i);
        for(ll j=2*i;j<N;j+=i)
            fact[j].pb(i);
    }
}

int main()
{
    fastio;
    #ifdef APNA_IO
        start_routine();
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);    
    #endif

    sieve();
    
    ll n;cin>>n;
    for(ll i=1;i<=n;i++)
        cin>>a[i];

    for(ll i=n;i>0;i--)
    {
        b[i]=(a[i]-val[i])%2;
        b[i]=(b[i]+2)%2;

        for(auto j:fact[i])
            val[j]=(val[j]+b[i]);
    }

    ll ans=0;
    for(ll i=1;i<=n;i++)
        if(b[i]) ans++;
    cout<<ans<<endl;
    for(ll i=1;i<=n;i++)
        if(b[i]) cout<<i<<" ";

    #ifdef APNA_IO
        end_routine();
    #endif
}


Measured memory_bytes: 38656
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int x;
  cin>>x;

  cout<<(x/500)*1000+(x%500)/5*5<<newl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100000];
int dp[100000];

void solve(){
     int t,k; 
     memset(dp, 0, sizeof dp);
   cin>>t>>k;
   for(int i=0;i<t;++i){
       cin>>a[i];
   }
   //dp[0]=a[0];
      for(int i=1;i<t;++i){
          dp[i]=1000000000;
          for(int j=i-1;j>=0 && (i-j)<=k; j--){
              dp[i]=min(dp[i], abs(a[i]-a[j]) + dp[j]);
          }
      }

  cout<<dp[t-1]<<endl;
   
}
int main() {
  
   // while(t--){
    solve();
//   }
    return 0;
}


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

int main(){
  int N, M, count=0;
  cin >> N >> M;
  vector<int> H(N);
  vector<int> good(N,1);
  for(int i=0; i<N; i++)
    cin >> H.at(i);
    
  for(int i=0;i<M;i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if(good.at(a)==0 && good.at(b)==0)
      continue;
    else if(H.at(a) > H.at(b))
      good.at(b) = 0;
    else if(H.at(a) < H.at(b))
      good.at(a) = 0;
    else{
      good.at(a) = 0;
      good.at(b) = 0;
    }
  }
  
  for(int i=0; i<N; i++){
    if(good.at(i)==1)
      count++;
  }
  
  cout << count << endl;
  
  return 0;
}

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

int n,k,t=1,cnt=0,mid,r;
int a[200005],now[200005],visited[200005]; 

inline int get_mod(int aa,int bb)
{
	if (aa%bb==0)  return bb;
	else return aa%bb;
}

signed main()
{
	cin>>n>>k;
	for (int i=1;i<=n;i++)  cin>>a[i];
	
	for (int i=1;i<=n*n;i++)
	{
		now[++cnt]=t;
		
		if (visited[t]==0)  visited[t]=cnt;
		else
		{
			mid=visited[t];
			r=cnt;
			break;
		}
		t=a[t];
	}
	r--;
	k++;
	
	if (k<=mid)  cout<<now[k]<<endl;
	else
	{
		k=k-mid;
		k=get_mod(k,r-mid+1);
		k=k+mid;
		
		cout<<now[k]<<endl;
	}
	return 0;
}

Measured memory_bytes: 8240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

ll dx[4]{-2, 0, 2, 0};
ll dy[4]{0, -2, 0, 2};

ll f[100][100];
ll d[100][100];

int main(int argc, char **argv)
{
	ll H, W;
	while (cin >> W >> H)
	{
		if (H == 0 && W == 0) break;
		memset(f, 0, sizeof f);

		H = H*2 - 1;
		W = W*2 - 1;
	
		for (ll h = 0; h < H; ++h)
		{
			for (ll w = 0; w < W; ++w)
			{
				if ((h % 2 == 0) && (w & 1))
				{
					cin >> f[h][w];
				}
				else if ((h & 1) && (w % 2 == 0))
				{
					cin >> f[h][w];
				}
				else
					f[h][w] = 8;

				d[h][w] = -1;
			}
		}

		// for (ll h = 0; h < H; ++h)
		// {
		// 	for (ll w = 0; w < W; ++w)
		// 	{
		// 		std::cout << f[h][w]<< " ";
		// 	}
		// 	std::cout << std::endl;
		// }

		queue<pair<ll, ll>> que;
		que.push(pair<ll, ll>(0, 0));
		d[0][0] = 1;

		while (!que.empty())
		{
			auto now = que.front(); que.pop();
			ll h = now.first;
			ll w = now.second;

			for (ll i = 0; i < 4; ++i)
			{
				ll nh = h + dy[i];
				ll nw = w + dx[i];
				ll mh = h + dy[i]/2;
				ll mw = w + dx[i]/2;

				if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
				if (mh < 0 || mh >= H || mw < 0 || mw >= W) continue;
				if (d[nh][nw] != -1) continue;
				if (f[mh][mw] == 1) continue;

				d[nh][nw] = d[h][w] + 1;
				que.push(pair<ll, ll>(nh, nw));
			}
		}

		std::cout << (d[H-1][W-1] == -1 ? 0 : d[H-1][W-1]) << std::endl;
	}
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const int INF = 1e9;
const double pi=acos(-1);


int main(){
  int n,p;
  string s;
  cin >> n >> p >> s;

  ll ans=0;
  if(p==2 || p==5){
    rep(i,n){
      if((s[n-1-i]-'0')%p==0)ans+=n-i;
    }
  }
  else{
    ll ten=1;
    vector<ll>sum(p,0);
    ll now=0;
    sum[0]++;
    rep(i,n){
      now=(now+(s[n-1-i]-'0')*ten)%p;
      sum[now]++;
      ten=(ten*10)%p;
    }
    rep(i,p){
      ans+=sum[i]*(sum[i]-1)/2;
    }
  }   
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

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

    int tmp = (a == b) ? c : (a == c) ? b : a;
    cout << tmp << endl;



    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if((a+b)>=(a-b) && (a+b)>=(a*b)) printf("%d\n",(a+b));
    else if((a-b)>=(a+b) && (a-b)>=(a*b)) printf("%d\n",(a-b));
    else if((a*b)>=(a+b) && (a*b)>=(a-b)) printf("%d\n",(a*b));
    return 0;

}

Measured memory_bytes: 1716
K = int(input())

def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)

def gcd3(a,b,c):
  return gcd(a, gcd(b,c))

ans = 0

for x in range(1,K+1):
  for y in range(1,K+1):
    for z in range(1,K+1):
      ans += gcd3(x,y,z)

print(ans)


Measured memory_bytes: 81340
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <map>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

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

int main(){
	int N;
	cin >> N;
	if (1 == N){
		cout << "Hello World" << endl;
	}
	else{
		int A, B;
		cin >> A >> B;
		cout << A + B << endl;
	}

    return 0;
}

Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    MOD = 2**61-1
    SI = lambda : sys.stdin.readline().rstrip()

    s = SI()
    t = SI()
    lens = len(s)
    lent = len(t)

    def cx(x):
        return ord(x) - ord('a') + 1

    hsh = 0
    for x in t:
        hsh = (hsh * 26 + cx(x)) % MOD

    n = (lens + lent) * 2
    dp = [0] * n

    h = 0
    ans = 0
    for i in range(n):
        if i >= lent:
            h -= cx(s[(i - lent)%lens]) * pow(26,lent-1,MOD)
        h = (h * 26 + cx(s[i % lens])) % MOD
        if h == hsh:
            if i < lent:
                dp[i] = 1
            else:
                dp[i] = dp[i-lent] + 1
            ans = max(ans,dp[i])

    if n - ans * lent < lent * 2 - 1:
        print(-1)
    else:
        print(ans)

if __name__ == '__main__':
    main()

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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for(int i = 0; i < N; i++) cin >> L[i];
  int ans = 1;
  int D = 0;
  while(ans < N + 1) {
    D += L[ans - 1];
    if(D <= X) ans++;
    else break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
using namespace std;

int dp[100001];
int main() {
    int n,q; cin >> n >> q;
    string s; cin >> s;
    for(int i = 1; i<n; i++){
        if(s[i]=='C' && s[i-1]=='A') dp[i]++;
        dp[i] += dp[i-1];
    }
    for(int i= 0; i<q; i++){
        int l,r; cin >> l >> r;
        cout << dp[r-1] - dp[l-1] << endl;
    }
}

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

int main() {
  long n,ans1,ans2=999999999999999;
  cin >> n;
  vector<long> a(n);
  for(long i=0;i<n;i++) cin >> a[i];
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  ans1=a[0];
  for(long i=1;i<n;i++) if(min(ans1-ans2,ans2)<min(ans1-a[i],a[i])) ans2=a[i];
  cout << ans1 << " " << ans2 << endl;
}

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

using namespace std;

int main() {
    int n;
    string x;
    cin >> n >> x;

    vector<int> f(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        int c = 0;
        for (int j = 1; j <= i; j <<= 1) {
            if ((i & j) > 0) {
                c++;
            }
        }
        f[i] = f[i % c] + 1;
    }

    int p = 0;
    for (int i = 0; i < n; i++) {
        if (x[i] == '1') {
            p++;
        }
    }

    vector<int> res(n);
    if (p == 0) {
        for (int i = 0; i < n; i++) {
            res[i] = 1;
        }
    } else if (p == 1) {
        int q = 0;
        for (int i = 0, j = 1; i < n; i++, j <<= 1, j %= (p + 1)) {
            if (x[n - i - 1] == '1') {
                q = (q + j) % (p + 1);
            }
        }

        for (int i = 0, j = 1; i < n; i++, j <<= 1, j %= (p + 1)) {
            if (x[n - i - 1] == '0') {
                res[n - i - 1] = f[(q + j) % (p + 1)] + 1;
            } else {
                res[n - i - 1] = 0;
            }
        }
    } else {
        int q = 0, r = 0;
        for (int i = 0, j = 1, k = 1; i < n; i++, j <<= 1, j %= (p + 1), k <<= 1, k %= (p - 1)) {
            if (x[n - i - 1] == '1') {
                q = (q + j) % (p + 1);
                r = (r + k) % (p - 1);
            }
        }

        for (int i = 0, j = 1, k = 1; i < n; i++, j <<= 1, j %= (p + 1), k <<= 1, k %= (p - 1)) {
            if (x[n - i - 1] == '0') {
                res[n - i - 1] = f[(q + j) % (p + 1)] + 1;
            } else {
                res[n - i - 1] = f[(r - k + p - 1) % (p - 1)] + 1;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        cout << res[i] << endl;
    }
}


Measured memory_bytes: 5172
#include<bits/stdc++.h>
using namespace std;
int main(){
  unsigned long long N;cin>>N;
  vector<unsigned long long>prime_times(N+1,1);
  for(int i=2;i<=N;i++){
    int k=i,d=2;
    while(k!=1){
      while(k%d==0){
        k/=d;
        prime_times[d]=(prime_times[d]+1)%1000000007;
      }
      d++;
    }
  }
  unsigned long long ans=1;
  for(int i=2;i<=N;i++){
    ans=(ans*prime_times[i])%1000000007;
    //cout<<i<<" "<<prime_times[i]<<endl;
  }
  cout<<ans%1000000007;
}
/*


*/

Measured memory_bytes: 256
n = int(input())
i,j=1,1
count=0

x = i*j
cc = n-x

while cc>=1:

	cnt=0
	while 1:
		p = i*j
		c = n - p
		if c>=1:
			#print(i,":",j,":",c)
			j=j+1
			cnt+=1
		else:
			j=i
			break

	count=count+((cnt*2)-1)

	i=i+1
	j=j+1

	x = i*j
	cc = n-x


print(count)

Measured memory_bytes: 9124
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let x = read::<i64>();
  let a = read::<i64>();
  let b = read::<i64>();

  println!(
    "{}",
    if (x - a).abs() < (x - b).abs() {
      "A"
    } else {
      "B"
    }
  );
}



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

using namespace std;

using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;



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

	char prev = ' ';

	for (char c : s) {
		if (prev == 'A' && c == 'C') {
			cout << "Yes" << endl;
			return 0;
		}
		prev = c;
	}
	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int t[500010];
ll l[500010],r[500010],sum[500010],nisum[500010],w[500010],ls[500010];
int n;
struct que
{
	ll cop[500010],tim[500010];
	int head,tail;
	void clear()
	{
		for (int i=0;i<=head;i++) cop[i]=tim[i]=0;
		head=0;tail=0;
	}
	void push(int t,long long x)
	{
		while ((head>1)&&((cop[head]-cop[head-1])*(t-tim[head-1])-(x-cop[head-1])*(tim[head]-tim[head-1])<=0)) head--;
		cop[++head]=x;tim[head]=t;tail++;
	}
	long long top(int t)
	{
		if (head<tail) tail=head;
		while ((tail>1)&&(cop[tail]-t*tim[tail]<cop[tail-1]-t*tim[tail-1])) tail--;
		return cop[tail]-t*tim[tail];
	}
}que;
struct que2
{
	ll cop[500010],tim[500010];
	int head,tail;
	void clear()
	{
		for (int i=0;i<=head;i++) cop[i]=tim[i]=0;
		head=0;tail=1;
	}
	void push(int t,long long x)
	{
		while ((head>1)&&((cop[head]-cop[head-1])*(t-tim[head-1])-(x-cop[head-1])*(tim[head]-tim[head-1])<=0)) head--;
		cop[++head]=x;tim[head]=t;
	}
	long long top(int t)
	{
		while ((head>tail)&&(cop[tail]-t*tim[tail]<cop[tail+1]-t*tim[tail+1])) tail++;
		//cout<<tim[tail]<<endl;
		return cop[tail]-t*tim[tail];
	}
}que2;
void work(int pl,int pr)
{
	if (pl==pr)
	{
		w[pl]=max(w[pl],l[pl-1]+r[pl+1]+1-t[pl]);
		return;
	}
	int mid=(pl+pr)>>1;
	work(pl,mid);work(mid+1,pr);
	que2.clear();
	for (int i=pl-1;i<=mid;i++) que2.push(i,l[i]+sum[i]+(ll)i*(i-1)/2);
	ll x=-4e18;
	for (int i=pr;i>mid;i--)
	{
		x=max(x,que2.top(i)+(ll)i*(i+1)/2-sum[i]+r[i+1]);
		w[i]=max(w[i],x);
	}
	que2.clear();
	for (int i=pr+1;i>mid;i--) que2.push(n-i+1,r[i]+nisum[i]+(ll)(n-i+1)*(n-i+1-1)/2);
	x=-4e18;
	for (int i=pl;i<=mid;i++)
	{
		x=max(x,que2.top(n-i+1)+(ll)(n-i+1)*(n-i+1+1)/2-nisum[i]+l[i-1]);
		w[i]=max(w[i],x);
	}
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {scanf("%d",&t[i]);sum[i]=sum[i-1]+t[i];}
	for (int i=n;i>=1;i--) nisum[i]=nisum[i+1]+t[i];
	que.clear();que.push(0,0);
	for (int i=1;i<=n;i++)
	{
		l[i]=max(l[i-1],que.top(i)+(ll)i*(i+1)/2-sum[i]);
		que.push(i,l[i]+sum[i]+(ll)i*(i-1)/2);
	}
	que.clear();que.push(0,0);
	for (int i=n;i>=1;i--)
	{
		r[i]=max(r[i+1],que.top(n-i+1)+(ll)(n-i+1)*(n-i+1+1)/2-nisum[i]);
		que.push(n-i+1,r[i]+nisum[i]+(ll)(n-i+1)*(n-i+1-1)/2);
	}
	//l[i]为前i个的dp值,r[i]为i~n的dp值 
	memset(w,214,sizeof(w));//w[i]表示强制i这个题目一定要做的最大cost 
	work(1,n);
	int q;scanf("%d",&q);
	while (q--)
	{
		int p;ll x;scanf("%d%lld",&p,&x);
		printf("%lld\n",max(l[p-1]+r[p+1],w[p]+t[p]-x));
	}
}

Measured memory_bytes: 33280
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    ll ans = 0;
    vector<int> S;
    vector<P> Area;
    char ch;

    for(int i = 0; cin >> ch; i++){
        if(ch == '\\') S.push_back(i);
        else if(ch == '_') continue;
        else {
            if(S.size() == 0) continue;
            int tmp = S.back();
            S.pop_back();
            int tmp_area = i - tmp;
            ans += tmp_area;

            while(Area.size() > 0 && Area.back().first > tmp){
                tmp_area += Area.back().second;
                Area.pop_back();
            }
            Area.push_back(P(tmp, tmp_area));
        }
    }

    cout << ans << endl;
    cout << Area.size();
    rep(i, Area.size()){
        cout << ' ' << Area[i].second;
    }
    cout << endl;
}


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


int main() {
	int matrix[3][3];
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			cin >> matrix[i][j];
		}
	}
	vector<int> b(3);
	b.at(0) = matrix[0][0];
	b.at(1) = matrix[0][1];
	b.at(2) = matrix[0][2];

	bool ans = true;

	for(int i=0; i<3; i++){
		if(matrix[1][i]-b.at(i) != matrix[1][(i+1)%3]-b.at((i+1)%3)) ans = false;
		if(matrix[2][i]-b.at(i) != matrix[2][(i+1)%3]-b.at((i+1)%3)) ans = false;
	}

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


Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>
using namespace std;


int main(){
    
    stack<int> S;
    string s;
    while(cin>>s){
        int a,b;
        if(s[0]=='+'){
            a=S.top();S.pop();
            b=S.top();S.pop();
            S.push(a+b);
        }else if(s[0]=='*'){
            a=S.top();S.pop();
            b=S.top();S.pop();
            S.push(a*b);
        }else if(s[0]=='-'){
            a=S.top();S.pop();
            b=S.top();S.pop();
            S.push(b-a);
        }else{
            S.push(atoi(s.c_str()));
        }
        
        
    }
    cout<<S.top()<<endl;

    return 0;
}



Measured memory_bytes: 3244
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class SegmentTree:
    def __init__(self, array, operator, identity_element):
        _len = len(array)
        self.__op = operator
        self.__size = 1 << (_len - 1).bit_length()
        self.__tree = [identity_element] * self.__size + \
            array + [identity_element] * (self.__size - _len)
        self.__ie = identity_element

        for i in range(self.__size - 1, 0, -1):
            self.__tree[i] = operator(
                self.__tree[i * 2], self.__tree[i * 2 + 1])

    def update(self, i, v):
        i += self.__size
        self.__tree[i] = v
        while i:
            i //= 2
            self.__tree[i] = self.__op(
                self.__tree[i * 2], self.__tree[i * 2 + 1])

    def query(self, l, r):
        """[l, r)
        """
        l += self.__size
        r += self.__size
        ret = self.__ie
        while l < r:
            if l & 1:
                ret = self.__op(ret, self.__tree[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.__op(ret, self.__tree[r])
            l //= 2
            r //= 2
        return ret


def slv(N, P):

    lst = SegmentTree([0] * (N+1), max, 0)
    rst = SegmentTree([N+1] * (N+1), min, N+1)
    pi = [(p, i+1) for i, p in enumerate(P)]
    pi.sort(reverse=True)

    lst.update(pi[0][1], pi[0][1])
    rst.update(pi[0][1], pi[0][1])
    ans = 0
    for p, i in pi[1:]:
        l = lst.query(0, i+1)
        ll = lst.query(0, l)
        r = rst.query(i, N+1)
        rr = rst.query(r+1, N+1)

        lst.update(i, i)
        rst.update(i, i)
        c = 0
        c += max(0, (l - ll)) * (r-i)
        c += max(0, (rr - r)) * (i-l)
        ans += c*p
    return ans

def main():
    N = read_int()
    P = read_int_n()
    print(slv(N, P))



if __name__ == '__main__':
    main()


Measured memory_bytes: 123608
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
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;

bool a[10][4];
int n;
int v[8];
int node;
int hoge;

vector<bool> solve(string s) {
//  cout << s << endl;
  if (s[0] != '(') {
    vector<bool> res(4);
    REP(i,4)
      if (a[s[0]-'1'][i]) {
        res[i] = 1;
      }
    return res;
  }
  int aa = 0;
  REP(i, s.size()) {
    if (s[i] == '(') aa++;
    else if (s[i] == ')') aa--;
    if (aa == 1 && s[i] == ' ') {
      vector<bool> L = solve(s.substr(1,i-1));
      vector<bool> R = solve(s.substr(i+1,s.size()-i-2));
      vector<bool> res(4);
      if (v[hoge] == 0) {
        REP(i,4) if (L[i]&&R[i]) res[i] = 1;
      } else if (v[hoge] == 1) {
        REP(i,4) if (L[i]||R[i]) res[i] = 1;
      } else {
        REP(i,4) if (L[i]&&!R[i] || !L[i]&&R[i]) res[i] = 1;
      }
      hoge++;
      // cout << "L ";
      // FOR(it, L)
      //   cout <<*it << " ";
      // cout << endl;
      // cout << "R ";
      // FOR(it, R)
      //   cout <<*it << " ";
      // cout << endl;
      // FOR(it, res)
      //   cout <<*it << " ";
      // cout << endl;
      return res;
    }
  }
}

int res;
void solve1(string s, int nest) {
  if (nest == node) {
    hoge = 0;
    vector<bool> vv = solve(s);
    // cout << "node = ";
    // REP(i, node) {
    //   cout << v[i] << " ";
    // }
    // cout <<"OK" << endl;
    
    if (count(ALL(vv), 1) == 4)
      res++;
    return;
  }
  REP(i,3) {
    v[nest] = i;
    solve1(s,nest+1);
  }
}



int main() {
  string s;
  while(getline(cin,s)) {
    if (s=="END") break;
    cin >> n;
    REP(i,n) {
      REP(j,4)
        cin >> a[i][j];
    }
    cin.ignore();
    node = count(ALL(s), '(');
    res = 0;
    solve1(s, 0);
    cout << res << endl;
  }
}

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

const int N=1e6+100,mod=998244353;
int n,m,fac[N],inv[N],ans;
int qpow(int x,int y) {
	int ret=1;
	while(y) {
		if(y&1) ret=1ll*ret*x%mod;
		x=1ll*x*x%mod, y>>=1;
	}
	return ret;
}
int C(int x,int y) {
	return 1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main() {
	scanf("%d%d",&n,&m);
	if(n<m) swap(n,m);
	fac[0]=1;
	for(int i=1;i<=n<<1;++i)
		fac[i]=1ll*fac[i-1]*i%mod;
	inv[n*2]=qpow(fac[n*2],mod-2);
	for(int i=n*2-1;~i;--i)
		inv[i]=1ll*inv[i+1]*(i+1)%mod;
	for(int i=1;i<=m;++i)
		ans=(ans+1ll*C(2*i,i)*C(n+m-2*i,n-i)%mod)%mod;
	//cout<<ans<<endl;
	printf("%lld",(1ll*ans*(mod+1)/2%mod*qpow(C(n+m,n),mod-2)%mod+n)%mod);
	return 0;
}

Measured memory_bytes: 8064
#include <iostream>

using namespace std;

void selectionSort(int *Array, int N)
{
  int mini = 0;
  int counter = 0;
  for(int i = 0; i < N; i++ ){
    mini = i;
    for(int j = i; j < N; j++){
      if( Array[j] < Array[mini]){
        mini = j;
        
      }
    }
    if ( i != mini ){
      swap(Array[i], Array[mini]);
      counter++;
    }
    
  }

  for(int i = 0; i < N; i++){
    if ( i == N -1 ) cout << Array[i] << endl;
    else cout << Array[i] << " ";
  }

  cout << counter << endl;
  return;
}


int main(int argc, char const *argv[])
{
  int n, array[101];
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> array[i];
  }
  
  selectionSort(array, n);
  return 0;
}



Measured memory_bytes: 3124
#include <iostream>

using namespace std;

int q1, b, c1, c2, q2;
long lev;


bool C(long x){	
	lev = (b-c1*x)/c2;//ツ閉津環鶏ツ禿キツ。
	if(b-c1*x<0)return false;
	if(q2<x)    return false;
	if(lev<0)   return false;
	return x+lev>=q1;
}


void solve(){
	long l=0, u=10000000;


	for(int i=0; i<100; i++){
		long m=(l+u)/2;
		C(m)?l=m
			:u=m;
	}
	if(u-1+lev>=q1&&u-1>0){
		if(lev<0)lev=0;
		cout<<u-1<<' '<<lev<<"\n";
	}else
		cout<<"NA\n";
 }  
  
int main(){ 	
	while(cin>>q1){
		if(!q1)break;
		cin>>b>>c1>>c2>>q2;
		solve();
	}
    return 0;  
}  

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

int main(void){
  int a, b;
  cin >> a >> b;
  if(1 <= a && a<= 9){
    if(1 <= b && b <=9){
      cout << a * b;
    } else {
      cout << -1;
    }
  } else {
    cout << -1;
  }

  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <stdio.h>

using namespace std;
 
int main(){

  	char str1[200], str2[100], str3[200];

 	scanf("%s %s", str1, str2);
  
  	strcpy(str3, str1);
  	strcat(str1, str3);
  
	if(strstr(str1,str2)==NULL)
      cout << "No" << endl;
  	else
      cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    int n = S.size() + 1;
    vector<ll> a(n);
    rep(i, n - 1)
    {
        if (S[i] == '<') {
            a[i + 1] = a[i] + 1;
        }
    }
    for (int i = n - 2; i >= 0; --i) {
        if (S[i] == '>') {
            if (a[i + 1] >= a[i]) {
                a[i] = a[i + 1] + 1;
            }
        }
    }
    cout << accumulate(a.begin(), a.end(), 0ll) << endl;
    return 0;
}

Measured memory_bytes: 4764
package main
import . "fmt"
func main() {
  var n,k,s int
  Scan(&n)
  Scan(&k)
  s = 1
  for i:=0;i<n;i++ {
    s = s + min(s,k)
  }
  Println(s)
}
func min(x int,y int) int {
  if x < y {
    return x
  } else {
    return y
  }
}

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

int main() {
  string S; cin >> S;
  reverse(S.begin(), S.end());
  vector<string> v = { "maerd", "remaerd", "esare", "resare" };
  for (int i = 0; i < S.size(); i++) {
    bool can = false;
    for (int j = 0; j < 4; j++) {
      string T = v.at(j);
      if (S.substr(i, T.size()) == T) {
        can = true;
        i += T.size() - 1;
      }
    }
    if (!can) { cout << "NO" << endl; return 0; }
  }
  cout << "YES" << endl;
}

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

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    vector<int> dp(n, INT_MAX);
    dp[0] = 0;

    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j <= i + k; j++)
        {
            if (j < n)       
                dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
            else
                break;
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <queue>
#include <math.h>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#include <list>
#include <ctype.h>
#include <cassert>
#include <stack>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <functional>
#include <ctime>
#include <limits>
#include <tuple>
#include <complex>
#include <numeric>

using namespace std;

#define snd second
#define fst first
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define left _left
#define right _right

const ld pi = acos(-1.0l);

template<typename T>
T abs(T x) {
    return x > 0 ? x : -x;
}

template<typename T>
T sqr(T x) {
    return x * x;
}

template<typename T>
bool chmin(T &x, T y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}

template<typename T>
bool chmax(T &x, T y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}

template<typename U, typename V>
ostream &operator<<(ostream &s, const pair<U, V> &x) {
    s << "(" << x.fst << ", " << x.snd << ")";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const vector<U> &x) {
    s << "[";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "]";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const set<U> &x) {
    s << "{";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "}";
    return s;
}

template<int sz>
ostream operator<<(ostream &s, const bitset<sz> &x) {
    for (int i = 0; i < sz; i++) {
        s << x[i];
    }
    return s;
}


//-----------------------------------------------------------------------------


int main() {
    srand(time(NULL));

    retry:
#ifdef LOCAL
    // gen();

    freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#else
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
#endif

    int n;
    scanf("%d", &n);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    set<int> s;
    s.insert(-1);
    s.insert(n);

    vector<pair<int,int>> b;
    for (int i = 0; i < n; i++) {
        b.pb(mp(a[i], i));
    }

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

    ll ans = 0;
    for (auto p : b) {
        auto it = s.lower_bound(p.snd);
        auto it2 = it;
        it2--;

        ll x = (*it - p.snd) * 1LL * (p.snd - *it2);
        ans += x * p.fst;
        s.insert(p.snd);
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 12016
// ABC_154_D

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

#define forn(i, n) for(int i = 0; i < (int)n; ++i)

int sum(int n) {
	int sum = n * (n+1) / 2;

	return sum;
}

int main()
{	
	int n, k;
	cin >> n >> k;

	vector<int> v(n);
	forn(i, n) cin >> v[i];

	vector<double> expv(n, 0);
	forn(i, n) {
		double tmp = 0;
		tmp= (double)sum(v[i]) / (double)v[i];
		expv[i] = tmp;
	}

	// sum
	vector<double> sum(n+1, 0);
	forn(i, n) sum[i+1] = sum[i] + expv[i];

	double max = 0;
	for(int j = 0; j <= n-k; ++j) {
		double tmp = sum[j+k] - sum[j];

		//cout << tmp << "\n";

		if(max < tmp) max = tmp;
	}

	cout << fixed << setprecision(15);
	cout << max << "\n";
}

Measured memory_bytes: 4096
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n, m; int mx = -1;
int a[110]; int ans[200];
bool dp[110][10010];
int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];
    cin >> m;
    for (int k = 0; k < m; k++) {
        cin >> ans[k];
        mx = max(mx, ans[k]);
    }
    
        memset(dp, 0, sizeof(dp));
        dp[0][0] = true;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j <= mx; ++j) {
                dp[i + 1][j] |= dp[i][j];
                if (j >= a[i]) dp[i + 1][j] |= dp[i][j - a[i]];
            }
        }
    for (int l = 0; l < m; l++) {
        if (dp[n][ans[l]]) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}


Measured memory_bytes: 4176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (n); i++)
#define rrep(i, s, n) for (int i = (s); i > (n); i--)
#define all(v) v.begin(), v.end()
#define co(s) cout << (s) << endl
#define ll long long

void solve(){
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,0,n){cin>>a[i];}

  int ans = 0;
  rep(i,0,n){
    int mini = i;
    rep(j,i,n){
      if(a[j]<a[mini]) mini = j;
    }
    swap(a[i],a[mini]);
    if(i!=mini) ans++;
  }

  rep(i,0,n){
    cout<<a[i];
    if(i!=n-1)
    {
        cout<<" ";
    }
  }
  cout<<endl;
  co(ans);
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
  return 0;
}


  // int ans = 0;
  // rep(i,0,n){
  //   rrep(j,n-1,i){
  //     if(a[j-1]>a[j]){
  //       swap(a[j-1],a[j]);
  //       ans++;
  //     }
  //   }


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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int a,b;

main() {
    cin >> a >> b;
    if (a>b) a--;
    ct(a)
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef set <int> si;
typedef set <int> :: iterator sitr;
typedef set <ll> :: iterator sltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef mset <int> :: iterator msitr;
typedef mset <ll> :: iterator msltr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newline '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template
int h,w;
char grid[200][200];
bool invr[200],invc[200];
int main(){
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);

     cin>>h>>w;
     for(int i=1;i<=h;i++){
         for(int j=1;j<=w;j++){
             cin>>grid[i][j];
         }
     }

     for(int i=1;i<=h;i++){
         for(int j=1;j<=w;j++){
             if(grid[i][j]=='#'){
                invr[i]=true;
                invc[j]=true;
             }
         }
     }

     for(int i=1;i<=h;i++){
        bool have = false;
        for(int j=1;j<=w;j++){
            if(invr[i]&&invc[j]){cout<<grid[i][j];have=true;}
            else continue;
        }
        if(have)cout<<newline;
     }
}


Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint n;
    cin >> n;
    lint lucas[87];
    REP(i, n+1){
        if(i == 0){
            lucas[i] = 2;
        }
        else if(i == 1){
            lucas[i] = 1;
        }
        else {
            lucas[i] = lucas[i-1] + lucas[i-2];
        }
    }
    cout << lucas[n] << endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  bool ok = true;
  rep(i,s.size()) {
    if ((i % 2 == 0 && s.at(i) == 'L') ||  (i % 2 != 0 && s.at(i) == 'R')) {
      ok = false;
    }
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3608
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> 
// using namespace __gnu_pbds;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MaX 300005
using namespace std;

 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
   	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
// typedef tree<int, null_type, less<int>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//     new_data_set; 
bool isprime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}



int main()
{
	fast();
	string s,t;
	ll i,ans=0;
	cin>>s>>t;
	for(i=0;i<s.length();i++)
	{
		if(s[i]!=t[i])
			ans++;
	}
	cout<<ans;
}




/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡖⠁⠀⠀⠀⠀⠀⠀⠈⢲⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣼⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣧⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣸⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣇⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣿⣿⡇⠀⢀⣀⣤⣤⣤⣤⣀⡀⠀⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣔⢿⡿⠟⠛⠛⠻⢿⡿⣢⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⣿⣷⣤⣀⡀⢀⣀⣤⣾⣿⣿⣿⣷⣶⣤⡀⠀⠀⠀⠀
⠀⠀⢠⣾⣿⡿⠿⠿⠿⣿⣿⣿⣿⡿⠏⠻⢿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣷⡀⠀⠀
⠀⢠⡿⠋⠁⠀⠀⢸⣿⡇⠉⠻⣿⠇⠀⠀⠸⣿⡿⠋⢰⣿⡇⠀⠀⠈⠙⢿⡄⠀
⠀⡿⠁⠀⠀⠀⠀⠘⣿⣷⡀⠀⠰⣿⣶⣶⣿⡎⠀⢀⣾⣿⠇⠀⠀⠀⠀⠈⢿⠀
⠀⡇⠀⠀⠀⠀⠀⠀⠹⣿⣷⣄⠀⣿⣿⣿⣿⠀⣠⣾⣿⠏⠀⠀⠀⠀⠀⠀⢸⠀
⠀⠁⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⢇⣿⣿⣿⣿⡸⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠈⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠐⢤⣀⣀⢀⣀⣠⣴⣿⣿⠿⠋⠙⠿⣿⣿⣦⣄⣀⠀⠀⣀⡠⠂⠀⠀⠀
⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠉⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠋⠁⠀⠀⠀⠀⠀
*/

Measured memory_bytes: 3792
#include <stdio.h>

#define N 8
int main(void){
    long int n,q, dig;
    int num[]={0,1,2,3,5,7,8,9};
     
    while (scanf("%d", &n), n!=0){
        dig = 0;        
        q=0;
        while (n){
            q += n%N;
            q *= 10;
            n /= N;
            dig++;
        }
        q /= 10;
        if (dig){
            while (dig--){
                printf("%d", num[q%10]);
                q /= 10;
            }
        } else printf("0");
        printf("\n");
    }
     
    return 0;
}

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


int main(){
  int64_t N,M,ans=0,t=0;
  cin >> N >> M;
  vector<int64_t> x(N),y(N),z(N),P(N);
  for(int64_t i=0;i<N;i++){
    cin >> x.at(i) >> y.at(i) >> z.at(i);
  }
  for(int64_t i=0;i<N;i++){
    P.at(i)=x.at(i)+y.at(i)+z.at(i);
  }
  sort(P.begin(),P.end());
  t=0;
  for(int64_t i=N-1;i>=N-M;i--){
    t+=P.at(i);
  }
  ans=max(t,ans);
  for(int64_t i=0;i<N;i++){
    P.at(i)=-x.at(i)+y.at(i)+z.at(i);
  }
  sort(P.begin(),P.end());
  t=0;
  for(int64_t i=N-1;i>=N-M;i--){
    t+=P.at(i);
  }
  ans=max(t,ans);
  for(int64_t i=0;i<N;i++){
    P.at(i)=x.at(i)-y.at(i)+z.at(i);
  }
  sort(P.begin(),P.end());
  t=0;
  for(int64_t i=N-1;i>=N-M;i--){
    t+=P.at(i);
  }
  ans=max(t,ans);
  for(int64_t i=0;i<N;i++){
    P.at(i)=x.at(i)+y.at(i)-z.at(i);
  }
  sort(P.begin(),P.end());
  t=0;
  for(int64_t i=N-1;i>=N-M;i--){
    t+=P.at(i);
  }
  ans=max(t,ans);
  for(int64_t i=0;i<N;i++){
    P.at(i)=-x.at(i)-y.at(i)+z.at(i);
  }
  sort(P.begin(),P.end());
  t=0;
  for(int64_t i=N-1;i>=N-M;i--){
    t+=P.at(i);
  }
  ans=max(t,ans);
  for(int64_t i=0;i<N;i++){
    P.at(i)=-x.at(i)+y.at(i)-z.at(i);
  }
  sort(P.begin(),P.end());
  t=0;
  for(int64_t i=N-1;i>=N-M;i--){
    t+=P.at(i);
  }
  ans=max(t,ans);
  for(int64_t i=0;i<N;i++){
    P.at(i)=x.at(i)-y.at(i)-z.at(i);
  }
  sort(P.begin(),P.end());
  t=0;
  for(int64_t i=N-1;i>=N-M;i--){
    t+=P.at(i);
  }
  ans=max(t,ans);
  for(int64_t i=0;i<N;i++){
    P.at(i)=-x.at(i)-y.at(i)-z.at(i);
  }
  sort(P.begin(),P.end());
  t=0;
  for(int64_t i=N-1;i>=N-M;i--){
    t+=P.at(i);
  }
  ans=max(t,ans);
  cout << ans << endl;
}


Measured memory_bytes: 256