akhauriyash/Code-Regression huggingface dataset:
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.weight = [0] * (n+1)

    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.root(self.par[x])
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    def union(self, x, y, w):
        rx = self.root(x)
        ry = self.root(y)
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1


    def same(self, x, y):
        return self.root(x) == self.root(y)

    def diff(self, x, y):
        return self.weight[x] - self.weight[y]

N,M = map(int,input().split())
wuf = WeightedUnionFind(N)
for i in range(M):
    l,r,d = map(int,input().split())
    l -= 1
    r -= 1
    if (wuf.same(l,r)):
        diff = wuf.diff(l,r)
        if (diff != d):
            print("No")
            quit()
    else:
        wuf.union(l,r,d)
print("Yes")


Measured memory_bytes: 10308
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			while (true) {
				String s = reader.readLine();
				String[] a = s.split(" ");
				
				int H = Integer.parseInt(a[0]);
				int W = Integer.parseInt(a[1]);
				
				if (H == 0 && W == 0) {
					break;
				}
				
				for (int i = 0; i < H; i++) {
					for (int j = 0; j < W; j++) {
						if ((i + j) % 2 == 0) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
					System.out.println();
				}
				System.out.println();
			}
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

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

int main() {

    int n, m, a, b;
    scanf("%d %d", &n, &m);

    int arr[n];

    for (int i = 0; i < n; i++) {
        arr[i] = 0;
    }

    for (int i = 0; i < m; i++) {
        scanf("%d %d", &a, &b);
        arr[a-1] += 1;
        arr[b-1] += 1;
    }
    
    for (int i = 0; i < n; i++) {
        printf("%d\n",arr[i]);
    }



    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <bitset>

using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	// Absolute
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	// GCD: a > b
	ul gcd(ul a,ul b) { return (!b) ? a : gcd(b,a%b); }
}

int main(int argc,char *argv[])
{
	ll array[9]={};
	for(int i = 0;i < 9;++i) std::cin >> array[i];
	
	ll n;
	std::cin >> n;

	for(int i = 0;i < n;++i)
	{
		ll b;
		std::cin >> b;
		for(int i = 0;i < 9;++i)
			if(array[i] == b) { array[i] = -1; break; }
	}
	
	// 縦横
	for(int i = 0;i < 3;++i)
	{
		ll v=0,h=0;
		for(int j = 0;j < 3;++j)
		{
			if(array[i*3+j] == -1) ++v;
			if(array[j*3+i] == -1) ++h;
		}
		if(v==3 || h==3){ std::cout << "Yes" << std::endl; return 0; }
	}
	// 斜め
	if(array[0] == array[4] && array[8] == -1) { std::cout << "Yes" << std::endl; return 0; }
	if(array[2] == array[4] && array[6] == -1) { std::cout << "Yes" << std::endl; return 0; }

	std::cout << "No" << std::endl;

	return 0;
}

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

int main()
{
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  
  if(k <= a)
    cout << k << endl;
  else if(k <= a + b)
    cout << a << endl;
  else
    cout << a - (k - a - b) << endl;
  
  return 0;
}

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

int main() {
    int n,m;
    cin >> n >> m;
    int maxID = n;
    int minID = 1;
    for(int i = 0;i < m; i++){
        int l,r;
        cin >> l >> r;
        maxID = min(maxID,r);
        minID = max(minID,l);
    }
    cout << max(maxID - minID + 1 , 0) << endl;
}

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  ll K;
  cin>>K;
  ll a(0);
  for(int i(0);i<=K+100;i++){
    a = (a*10+7)%K;
    if(a == 0){
      cout << i+1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}



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

int main() {
	int a, b,ans;
	char op;
	cin >> a >> op >> b;

	if (op == '+')
	{
		ans = a + b;
	}
	else if (op == '-')
	{
		ans = a - b;
	}

	cout << ans << endl;
}

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

bool check(long p, vector<long> w, long k) {
	long sum = 0;
	int cnt = 0;
	for (int i = 0; i < w.size();) {
		if (sum + w[i] > p) {
			sum = 0;
			cnt++;
			if (cnt >= k) return false;
		}
		else {
			sum += w[i];
			i++;
		}
	}
	return cnt < k;
}

int binary_serch(vector<long> v, long l, long r, long k) {
	int mid;
	while (l <= r) {
		mid = l;
		if (check(mid, v, k)) return l;
		else l++;
	}
	return 0;
}

int main() {
	long n, k; cin >> n >> k;
	vector<long> w(n), p(k, 0);
	for (int i = 0;i < n;i++) cin >> w[i];
	long M = accumulate(w.begin(), w.end(), 0);
	long ans = binary_serch(w, M / k, M, k);
	cout << ans << endl;
};


Measured memory_bytes: 6048
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<Long, Long> Pair;
void solve() {
  string a, b;
  cin >> a >> b;
  int ans = 0;
  fore(i, 0, SZ(a)) if (a[i] != b[i]) ans++;
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int t = 1;
  //cin >> t;
  while (t--) solve();

  return 0;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
using namespace std;
const int INF=LLONG_MAX-1e10;
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
const int mo_num=1e9+7;
int n,m,t,a[maxn],b[maxn],ans;

main()
{
    IOS
    int A,B,N;
    cin>>A>>B>>N;
    out(floor((double)(A*min(B-1,N))/(double)B))
    return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define mp make_pair
const int mx=1e5+5;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	/*freopen(".in", "r", stdin);
	freopen(".out", "w", stdout); 
    */	
	long long h;cin >> h;
	long long last=1,ans=0;
	while(h/2){
		ans+=last;
		last=last*2;
		h=h/2;
	}	
	cout << ans+last << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <bitset>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <cctype>
#include <fstream>

#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000			 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979
#define MAXI 7500000

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int  ,long long int> P;

//int dy[5] = { 0,0,1,-1,0 };
//int dx[5] = { 1,-1,0,0,0 };

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

long long int power(long long int m,long long int k){
	long long int tmp = 0;

	if(k==0){
		return 1;
	}
	if (k % 2 == 0)
	{
		return ((power(m, k / 2) % MOD)*(power(m,k/2)%MOD))%MOD;
	}
	else
	{
		return ((m%MOD)*(power(m, k - 1) % MOD))%MOD;
	}
}

int main(void)
{
	long long int m, n;

	cin >> m >> n;

	cout << power(m, n) << endl;
}



Measured memory_bytes: 3092
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf 9e18
#define minf -9e18
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

ll zeroes(ll n)
{
	ll ans = 0;

	ll val = 5;

	while(true)
	{
		ans += n/val;
		if(val > (ceil((double)n/(double)5))) break;
		else val *= 5;
	}

	return ans;
}



int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
    ll n;
    cin>>n;

    ll ans = 0;

    if(n%2==0)
    {
    	ans = zeroes(n/2);
    }

    cout<<ans;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

void trace(int a[], int n) {
    for (int i = 0; i < n; ++i) {
        if (i > 0) printf(" ");
        printf("%d", a[i]);
    }
    printf("\n");
}

void insertionSort(int a[], int n) {
    for (int i = 1; i < n; ++i) {
        int v = a[i];
        int j = i - 1;
        while (j >= 0 && v < a[j]) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        trace(a, n);
    }
}

int main() {
    int n;
    int a[100];
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
    trace(a, n);
    insertionSort(a, n);
    return 0;
}

Measured memory_bytes: 1032
#include <stdio.h>
#include<stdlib.h>
#define ll long long

int main(void){
  ll n,m;
  scanf("%lld %lld",&n,&m);
  ll array[n];
  for(ll i=0;i<n;++i) array[i] = 0;
  
  for(ll i=0;i<m;++i){
    ll a,b;
    scanf("%lld %lld",&a,&b);
    --a;
    --b;
    array[a]++;
    array[b]++;
  }
  for(ll i=0;i<n;++i){
    printf("%lld\n",array[i]);
  }

  return 0;
}

Measured memory_bytes: 1712
n=gets.to_i
a=$<.read.split.map{|e|e.split ""}
b=a.transpose.map{|i|i.count ?#}
p (g=n.times.map{|i|a[i].count(?.)+(b[i]==0?1:0)}.min)==n+1?-1:g+n-b.count(n)

Measured memory_bytes: 17020
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        int num = 0;
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String nl = in.nextLine();
      	String[] strs = in.nextLine().split(" ");
        in.close();
      	int[] lst = Stream.of(strs)
      			.mapToInt(Integer::parseInt)
      			.sorted()
      			.toArray();
      	for (int i = 0; i < n*2; i++) {
      		if (i % 2 == 0) {
      			num += lst[i];
      		}
      	}
        System.out.println(num);
    }
}

Measured memory_bytes: 27348
import math
A,B,H,M = [int(hoge) for hoge in input().split()]
Hkaku = H/12 + M/720
Mkaku = M/60
kaku = 360*abs(Hkaku-Mkaku)
kaku = min(kaku,360-kaku)
if kaku == 180:
    print(A+B);exit()
C = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(kaku)))
print(C)


Measured memory_bytes: 62384
//Author - Sumit

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

#define ll long long
#define int ll
#define ps push
#define pb push_back
#define INF 10000000000LL
#define MOD 1000000007
#define mp make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repd(i,a,b) for (int i = a; i >= b; i--)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pair<int,int>>
#define itr :: iterator it
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug(x) cout << x << "\n";
#define debug2(x,y) cout << x << " " << y << "\n";
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;



void solve(){
    int a,b;
    cin>>a>>b;
    debug(max(0LL,(a-2*b)));    
}

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

    
    int t=1;
   // cin>>t;
    WL(t){
        solve();
    } 
} 

Measured memory_bytes: 256
def kakezan_list():
    kake_list = list()
    for i in range(1, 10):
        for j in range(1, 10):
            kake_list.append(i*j)
    return kake_list

n = int(input())
#print(kakezan_list())

if n in kakezan_list():
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<stdio.h>

int main(void){
   int H,N;
   scanf("%d %d",&H,&N);
   int a[N];
   for(int i=0;i<N;i++){
      scanf("%d",&a[i]);
      H -=a[i];
   }
   if(H<=0){
      printf("Yes");
   }else{
      printf("No");
   }
   return 0;
}


Measured memory_bytes: 2116
#include <iostream>
#include <vector>
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
using namespace std;

const ll INF = 1LL<<60;
int main(){
  ll V, E;
  cin >> V >> E;
  vector<vector<ll>> dp(V, vector<ll>(V, INF));
  rep(i, E){
    ll s, t, d;
    cin >> s >> t >> d;
    dp[s][t] = d;
  }
  rep(i, V) dp[i][i] = 0;
  rep(k, V)rep(i, V)rep(j, V){
    if (dp[i][k] == INF || dp[k][j] == INF) continue;
    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
  }
  
  bool neg = false;
  rep(i, V) if (dp[i][i] < 0) neg = true;
  if(neg) cout << "NEGATIVE CYCLE" << endl;
  else{
    rep(i, V){
      rep(j, V){
        if (dp[i][j] == INF) cout << "INF";
        else                 cout << dp[i][j];
        if (j == V-1) cout << endl;
        else          cout << ' ';
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 3240
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
       Scanner sc = new Scanner(System.in);
        
        long n = sc.nextLong();
        long a = 0;

        long max = -1000000;
        long min = 1000000;
        long sum = a;
    	
            //ystem.out.println(n);
            
        for(int i = 0;i < n;i++){

            a =sc.nextLong();

            if(max < a){
                max = a;
            }
            if(min> a){
                min = a;
            }
            sum = sum + a;
        }
        System.out.println(min + " " + max + " " +sum);
    }
}




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

#[allow(dead_code)]
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")
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    let n = s.len();
    let mid = (n + 1) / 2 - 1;
    let c = s[mid];
    let mut ans = (n + 1) / 2;
    let mut offset = 0;
    if s.len() % 2 == 1 { offset = 1; }
    for i in 0..n {
        if mid < i + offset || n <= mid + i + 1 { break; }
        if s[mid - i - offset] != c || s[mid + i + 1] != c { break; }
        ans += 1;
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
gets
a = gets.strip.split(" ").map(&:to_i)

if a.size == 1
  puts a.first
else
  all = a.first
  1.upto(a.size - 1) do |i|
    all = all.gcd(a[i])
  end

  l = Array.new(a.size)
  r = Array.new(a.size)

  l[0] = a.first
  1.upto(a.size - 1) do |i|
    l[i] = a[i].gcd(l[i - 1])
  end

  r[a.size - 1] = a.last
  (a.size - 2).downto(0) do |i|
    r[i] = a[i].gcd(r[i + 1])
  end

  ans = 0
  0.upto(a.size - 1) do |i|
    x = i > 0 ? l[i - 1] : nil
    y = i < a.size ? r[i + 1] : nil

    ans = 
      if x && y
        [ans, x.gcd(y)].max
      else
        [ans, (x || y)].max
      end
  end

  puts [ans, all].max
end


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

using namespace std;

int dp[5003][5003];
int n;
string s;

const int mod = 1e9 + 7;

int bPow(int n, int k) {
	if (k == 1) {
		return n;
	}
	if (k == 0) {
		return 1;
	}
	int cur = bPow(n, k / 2);
	if (k % 2 == 1) {
		return ( ( 1ll * cur * cur ) % mod * n ) % mod;
	}
	else {
		return (1ll * cur * cur) % mod;
	}
}

signed main() {
	cin >> n >> s;
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			if (j == 0) {
				dp[i][j] = (1ll * dp[i-1][j] + 1ll * dp[i-1][j+1]) % mod;
				continue;
			}
			dp[i][j] = (1ll * dp[i-1][j+1] + 1ll * 2 * dp[i-1][j-1]) % mod;
			//cout << dp[i][j] << " " << i << " " << j << endl;  
		}
	}
	cout << 1ll * dp[n][s.length()] * bPow(bPow(2, s.length()), mod-2) % mod;
}

Measured memory_bytes: 97920
#include<bits/stdc++.h>
#define inf 2000000000
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
#define rng_23 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef set<int> si;
typedef multiset<int> msi;
typedef map<int,int> mii;
int main()
{
    int i,j,k;
    int n;
    cin>>n;
    vii edge;
    vector<vi> vec;
    for(i=1,j=n-(n&1);i<j;i++,j--){
        vi temp;
        temp.pb(i);
        temp.pb(j);
        vec.pb(temp);
    }
    if(n&1)
        vec.pb(vi(1,n));
    for(i=0;i<(int)vec.size()-1;i++){
        for(j=i+1;j<(int)vec.size();j++){
            for(auto vi: vec[i]){
                for(auto vj: vec[j])
                    edge.pb({vi,vj});

            }
        }
    }
    cout<<edge.size()<<endl;
    for(auto e: edge)
        cout<<e.fi<<" "<<e.se<<endl;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <random>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

vector<string> f(int d, char c) {
	if (d == 0) {
		return vector<string>(1, "");
	}
	auto p = f(d - 1, c);
	if (c != '0' && d > 1) {
		auto q = f(d - 1, c - 1);
		for (auto& elm : q)p.push_back(elm);
	}
	if (c != '9' && d > 1) {
		auto q = f(d - 1, c + 1);
		for (auto& elm : q)p.push_back(elm);
	}
	for (auto& elm : p) {
		elm.push_back(c);
	}
	return p;
}


vector<LL>ans;
int main() {
	for (int d = 1; d <= 10; ++d) {
		for (char c = '0'; c <= '9'; ++c) {
			auto res = f(d, c);
			for (auto s : res) {
				//reverse(s.begin(), s.end());
				std::istringstream iss(s);
				LL sei;
				iss >> sei;
				ans.push_back(sei);
			}
		}
	}
	sort(ans.begin(), ans.end());
	ans.erase(unique(ans.begin(), ans.end()), ans.end());
	int K;
	cin >> K;
	cout << ans[K] << endl;
	return 0;
}

Measured memory_bytes: 3852
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;

	if (a > b){
		cout << "a > b" << endl;
	}
	else if (a < b){
		cout << "a < b" << endl;
	}
	else {
		cout << "a == b" << endl;
	}



	return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    ll t, ans = 1, gcd;
    rep(i, n) {
        cin >> t;
        gcd = __gcd(t, ans);
        ans = (t / gcd) * ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
 * atcoder/abc089/b.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }

void solve() {
  int x;cin >> x;
  int n = x+100000;
  vector<bool> P(n, true);
  loop(i,2,n) {
    if (P[i]) {
      for (int j=i+i; j<n; j += i) {
        P[j] = false;
      }
    }
  }
  
  loop(i,x,n) {
    if (P[i]) {
      cout << i << endl;
      return;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 3636
n = int(input())
A = 0
B = 0
AB = 0
ans = 0
for i in range(n):
    s = input()
    for i in range(len(s)-1):
        if s[i:i+2] == "AB":
            ans += 1
    if s[0] == "B" and s[-1] == "A":
        AB += 1
    elif s[0] == "B":
        B += 1
    elif s[-1] == "A":
        A += 1
if AB > 0:
    if A + B > 0:
        ans += AB + min(A,B)
    elif A + B == 0:
        ans += AB - 1
else:
    ans += min(A,B)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
  int N;
  cin>>N;
  vector<int> A(N+1);
  rep(i,N) cin>>A[i];
  A[N]=0;
  int c=1,ans=0;
  rep(i,N){
    if(A[i]!=A[i+1]){
      ans+=c/2;
      c=1;
    }
    else c++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
/* Hardwork allways pays off */
//You never know how close to the solution you are ,so keep practicing
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define mod 1000000007
#define REP(i,n) for(ll i=1;i<=n;i++)
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(), (x).end()
void make_unique(vector<ll> vec)
{
sort(all(vec));
vec.resize(unique(all(vec)) - vec.begin());
}

int main() 
 {   ios;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    //  cin>>t; 
    while(t--)
      {ll l,k,p,a,b,c,n,m,i,j,flag=0,count=0,move=0;
       cin>>n;
       ll A[n],B[n];
       for(i=0;i<n;i++)
       {
         cin>>A[i]>>B[i];
       }
       for(i=0;i<n-2;i++)
       {
         if(A[i]==B[i])
          {
            if(A[i+1]==B[i+1])
             {if(A[i+2]==B[i+2])
               {
                 {flag=1;break;}
               }
             }
          }
       }
       
      if(flag==1)
       cout<<"Yes"<<endl;
      else
       cout<<"No"<<endl;

        
      }
	return 0;
}


Measured memory_bytes: 3656
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

void yes() { cout << "Possible" << endl; }
void no() { cout << "Impossible" << endl; }
void yesOrNo(bool flg) {
  if (flg)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
}

void solve(ll A, ll B) {
  bool result = A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0;
  yesOrNo(result);
}

int main() {
  ll A;
  scanf("%lld", &A);
  ll B;
  scanf("%lld", &B);
  solve(A, B);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int INF=1e18;
int V,E;
int d[110][110];

void warshall_floyd(){
    REP(k,V) REP(i,V) REP(j,V){
        if(d[i][k]==INF or d[k][j]==INF) continue;
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }
}

signed main()
{
    cin>>V>>E;
    REP(i,V) REP(j,V) if(i!=j) d[i][j]=INF;
    REP(i,E){
        int a,b,c; cin>>a>>b>>c;
        d[a][b]=c;
    }

    warshall_floyd();

    REP(i,V){
        if(d[i][i]<0){
            cout<<"NEGATIVE CYCLE"<<endl;
            return 0;
        }
    }

    REP(i,V){
        REP(j,V){
            if(j) cout<<' ';
            if(d[i][j]==INF) cout<<"INF";
            else cout<<d[i][j];
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3196
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        sc.close();

        int sec;
        if (a <= c && c <= b && d <= b) {
            sec = d - c;
        } else if (a <= c && c <= b && d >= b) {
            sec = b - c;
        } else if (a >= c && a <= d && d <= b) {
            sec = d - a;
        } else if (a >= c && a <= d && d > b) {
            sec = b - a;
        } else {
            sec = 0;
        }
        System.out.println(sec);
    }
}


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

using namespace std;

int main (void) {
    int N, K;
    string S;
    cin >> N >> K >> S;

    vector<int> nums;   /* 1-0-1-...-0-1 の個数の配列 */
    int         now = 1;
    int         cnt = 0;
    for ( int i = 0; i < N; i++ ) {
        if ( S.at(i) == now + '0' )
            cnt++;
        else {
            nums.push_back(cnt);
            cnt = 1;
            now = 1 - now;
        }
    }
    if ( cnt != 0 )
        nums.push_back(cnt);

    /* 1-0-1-...-0 だったら最後にダミーの0を置く */
    if ( nums.size() % 2 == 0 )
        nums.push_back(0);

    int ans = 0;
    int sum = 0;
    int left = 0, right = 0;

    for ( int i = 0; i < (int)nums.size(); i+= 2 ) {
        int nleft = i;
        int nright = min(i + 2 * K + 1, (int)nums.size());

        while ( nleft > left ) {
            sum -= nums.at(left);
            left++;
        }

        while ( nright > right ) {
            sum += nums.at(right);
            right++;
        }

        ans = max(ans, sum);
    }

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


Measured memory_bytes: 4008
p=input().rstrip().split(' ')
N=int(p[0])
L=int(p[1])
l=[]
q=[]
w=[]
S=[]
D=[]
x=0;
for i in range(1,N+1):
    l.append(i)
    q.append(L+i-1)
    x=x+(L+i-1)
for i in range(0,len(q)):
    T=0;
    for j in range(0,len(q)):
        if i!=j:
            T+=q[j]
    S.append(abs(T-x))
    D.append(T)
C=min(S)
print(D[S.index(C)])


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;int main(){int n,k[10],b;char z;while(true){cin>>n;if(n==0)break;for(int i=0;i<n;i++)k[i]=0;b=0;for(int i=0;i<100;i++){cin>>z;if(z=='M')k[i%n]++;if(z=='S'){b+=k[i%n]+1;k[i%n]=0;}if(z=='L'){k[i%n]+=b+1;b=0;}}sort(k,k+n);for(int i=0;i<n;i++)cout<<k[i]<<" ";cout<<b<<endl;}return 0;}

Measured memory_bytes: 1184
// Problem : C - Scc Puzzle
// Contest : AtCoder - AtCoder Beginner Contest 055
// URL : https://atcoder.jp/contests/abc055/tasks/arc069_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

double pi=acos(-1.0);
const int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int c,s;cin>>s>>c;
int ans=min2(c/2,s);
s-=ans;
c-=ans*2;
ans=(ans+c/4);
cout<<ans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    // 下一桁が最も小さいものをチョイス
    ll N = 5;
    vector<ll> x(N), y(N);
    vector<int> indices(N);
    rep(i, N){cin >> x.at(i);}
    rep(i, N){y.at(i) = (x.at(i) % 10 == 0) ? 10 : (x.at(i) % 10);}
    iota(indices.begin(), indices.end(), 0);
    sort(indices.begin(), indices.end(), [&y](ll i1, ll i2) {
        return y[i1] < y[i2]; // これは昇順
    });
    // for (auto a: indices){cout << a << endl;}
    ll ans = 0;
    rep(i, N){
        if (i == indices.at(0)){
            ans += x.at(i);
        } else {
            ans += (ll) ceil((double) x.at(i) / 10) * 10;
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

int main(){
	int S; 
	int h,m,s;

	cin >> S;

	h = S/3600;
	m = S%3600;
	s = m%60;
	m = m/60;

	cout << h << ":" << m << ":" << s << endl;

	return 0;
}

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

int main() {
  int n,ans,count=0;
  cin>>n;
  long long a[n];
  for(int i=0;i<n;i++){
    long long k;
    cin>>k;
    a[i]=k;
  }
  sort(a,a+n);
  for(int i=a[1];i>0;i--){
    if(a[1]%i==0||a[0]%i==0){
      for(int j=0;j<n;j++){
        if(a[j]%i==0)count++;
      }
    }
    if(count>n-2){
      ans=i;
      break;
    }
    else count=0;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
if __name__ == "__main__":
    input_str = input()
    ans = []
    for s in input_str:
        if s == "0":
            ans.append("0")
        elif s == "1":
            ans.append("1")
        else:
            if len(ans) == 0:
                continue
            else:
                ans.pop()

    print("".join(ans))


Measured memory_bytes: 2940
n=gets.to_i
ans=n>2 ? 2 : 1
2.step{|k|
  ksq=k*k
  if ksq>=n-1
    ans+=1 if ksq<=n
    break
  end
  q,r=n.divmod(k)
  ans+=1 if r==1
  q,r=q.divmod(k) while r==0
  ans+=1 if r==1
}
puts ans

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

int N, Q;
string s;
vector<char> t, d;

bool isOK_l(int v) {
  if(v == -1) return true;
  rep(i, 0, Q) {
    if(t[i] != s[v]) continue;
    if(d[i] == 'R') v++;
    else v--;
    if(v == -1) return true;
    if(v == N) return false;
  }
  return false;
}

int bs_l() {
  int ng = N;
  int ok = -1;
  while(abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if(isOK_l(mid)) ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isOK_r(int v) {
  if(v == N) return true;
  rep(i, 0, Q) {
    if(t[i] != s[v]) continue;
    if(d[i] == 'R') v++;
    else v--;
    if(v == N) return true;
    if(v == -1) return false;
  }
  return false;
}

int bs_r() {
  int ng = -1;
  int ok = N;
  while(abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if(isOK_r(mid)) ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin >> N >> Q >> s;
  t.resize(Q);
  d.resize(Q);
  rep(i, 0, Q) cin >> t[i] >> d[i];
  cout << bs_r() - bs_l() - 1 << endl;
  return 0;
}


Measured memory_bytes: 900
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n;
  scanf("%d", &n);
  vi a(n);
  vi b(3, 0);
  rep (i, n) {
    scanf("%d", &a[i]);
    int c = a[i];
    int j = 0;
    for ( ; j < 3; ++j, c /= 2) {
      if (c % 2 == 1 || j == 2) {
        b[j] += 1;
        break;
      }
    }
  }

  bool ans = true;
  int before = 2;
  rep (i, n) {
    if (before == 2) {
      if (b[0] > 0) {
        b[0] -= 1;
        before = 0;
        continue;
      } else if (b[1] > 0) {
        b[1] -= 1;
        before = 1;
        continue;
      } else {
        b[2] -= 1;
        before = 2;
        continue;
      }
    }
    if (before == 1) {
      if (b[1] > 0) {
        b[1] -= 1;
        before = 1;
        continue;
      } else {
        b[2] -= 1;
        before = 2;
        continue;
      }
    }
    if (before == 0) {
      if (b[2] > 0) {
        b[2] -= 1;
        before = 2;
        continue;
      }
    }
    ans = false;
    break;
  }

  if (ans) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int n = b - a;
		int tHeight = 0;
		
		for(int i = 1; i <= n; i++) {
			tHeight += i;
		}
		
		int sHeight = tHeight - b;
		
		System.out.println(sHeight);
	}
}

Measured memory_bytes: 23124
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    h, w = map(int, readline().split())
    grid = []
    hd = 0
    for row in range(h):
        s = input()
        if all([char == "." for char in s]):
            hd += 1
        else:
            grid.append(s)

    rem = []
    for col in range(w):
        for row in range(h - hd):
            if grid[row][col] == "#":
                break
        else:
            rem.append(col)

    for row in range(h-hd):
        disp = ""
        for col in range(w):
            if col in rem:
                continue
            disp += grid[row][col]
        print(disp)


if __name__ == '__main__':
    main()


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

long long x[N], v[N];
long long f[N], g[N];

void solve() {
  int n;
  long long c;
  scanf("%d%lld", &n, &c);
  for (int i = 0; i < n; ++i) {
    scanf("%lld%lld", x+i, v+i);
    f[i] = v[i]-x[i];
    g[i] = i;
    if (i) {
      f[i] = f[i]+f[i-1]+x[i-1];
      if (f[g[i-1]] > f[i]) g[i] = g[i-1];
    }
  }
  long long ans = 0;
  ans = max(ans, f[g[n-1]]);
  long long cum = 0;
  for (int i = n-1; i > 0; --i) {
    ans = max(ans, v[i]+cum-2*(c-x[i])+f[g[i-1]]);
    cum += v[i];
  }
  ans = max(ans, cum-2*(c-x[0]));
  reverse(x, x+n);
  reverse(v, v+n);
  for (int i = 0; i < n; ++i) {
    x[i] = c-x[i];
    f[i] = v[i]-x[i];
    g[i] = i;
    if (i) {
      f[i] = f[i]+f[i-1]+x[i-1];
      if (f[g[i-1]] > f[i]) g[i] = g[i-1];
    }
  }
  ans = max(ans, f[g[n-1]]);
  cum = 0;
  for (int i = n-1; i > 0; --i) {
    ans = max(ans, v[i]+cum-2*(c-x[i])+f[g[i-1]]);
    cum += v[i];
  }
  ans = max(ans, cum-2*(c-x[0]));
  
  printf("%lld", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 6920
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;





signed main() {
    ll n;
    cin >> n;
    
    vll a(n);
    
    deque <ll> dq;
    
    rep(i, n) {
        cin >> a[i];
        
        if (i % 2 == 0) {
            dq.push_back(a[i]);
        } else {
            dq.push_front(a[i]);
        }
        
    }
    
    if (n % 2 == 1) Rev(dq);
    
    for (auto i: dq) {
        cout << i << " ";
    }
    
    
    
    
    
}

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

int main(){
  int t; cin >> t;
  while(t--){
    int n; cin >> n;
    int umax=0,dmax=0;
    vector<int> b(n);
    for(int i=0;i<n;++i) cin >> b[i];
    for(int i=0;i<n-1;++i){
      if(b[i]<b[i+1]) umax=max(umax,b[i+1]-b[i]);
      else dmax=max(dmax,b[i]-b[i+1]);
    }
    cout << umax << " " << dmax << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3112
import Control.Applicative

main = do
    n <- read <$> getLine
    putStrLn $
        concat $ zipWith (++) (repeat " ") (show <$> filterCheckNumber n)

filterCheckNumber :: Int -> [Int]
filterCheckNumber n = [ x | x <- [1..n], (x `mod` 3 == 0) || includeThree x ]

includeThree :: Int -> Bool
includeThree x
    | x == 0          = False
    | x `mod` 10 == 3 = True
    | otherwise       = includeThree $ x `div` 10


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i <= (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    ll a, b, c, cnt = 0;
    cin >> a >> b >> c;
    repi(i, b, a)
    {
        if (c % i == 0)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3104