akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 0x3f3f3f
#define PB push_back
#define F first
#define S second
#define FOR(i,k) for(int i=0; i<k; i++)
#define RFOR(i,k) for(int i=k; i>=0; i--)
#define ALL(x) x.begin(), x.end()
#define INS(x) inserter(x, x.begin())
#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
#define DEBUGV(x) cout<<#x<<": "; for(auto &d:x) cout<<d<<" "; cout<<endl
#define DEBUGM(x) for(auto &p:x) cout<<p.F<<":"<<p.S<<" "; cout<<endl;
#define OUT(x) cout<<(x)<<endl

using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VPII;
typedef vector<VI> VVI;
typedef map<char,int> MC;
typedef map<int,int> MI;
typedef map<string,int> MS;

template<typename T, typename U> void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> void amax(T &x, U y) { if(x < y) x = y; }
VPII neighbors = {{0,1}, {1,0}, {0,-1}, {-1,0}};
PII operator+(PII &l, PII &r) { return {l.F+r.F, l.S+r.S}; }
bool IsValid(PII p, int Y, int X) { 
  return p.F >=0 && p.F < Y && p.S >=0 && p.S < X; }
bool IsPrime(int n) {
  if (n <= 1)  return false;
  if (n <= 3)  return true;
  if (n%2 == 0 || n%3 == 0) return false;
  for (int i=5; i*i<=n; i=i+6)
    if (n%i == 0 || n%(i+2) == 0)
      return false;
  return true;
}

int main() {
  int n;
  cin>>n;
  VI v;
  FOR(i,n) {
    int x;
    cin>>x;
    v.PB(x);
  }

  VI v2 = v;
  sort(ALL(v2));
  int m1 = v2[v.size()/2-1];
  int m2 = v2[v.size()/2];
  for(int d : v) {
    if(d<=m1)
      OUT(m2);
    else
      OUT(m1);
  }
}

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

int main() {
   int N, M;
   cin >> N >> M;
  vector<vector<int>> data(M, vector<int>(2));;
  vector<int> dip(51);
   for(int i = 0; i < M; i++){
     cin >> data.at(i).at(0);
     cin >> data.at(i).at(1);
   }
  for(int i = 0; i < M; i++){
    for(int k = 1; k < N+1; k++){
    if(data.at(i).at(0) == k){
      dip.at(k)++;
    }
    if(data.at(i).at(1) == k){
      dip.at(k)++;
    }
  }
  }
  for(int i = 1; i < N+1; i++){
    cout << dip.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
#define data_type long long
#define endl "\n"
set<list<char> > mp;
void sum(list<char> s,int i,int counter)
{
    if(i==s.size())
        return;
    mp.insert(s);
    sum(s,i+1,counter);
    auto it=s.begin();
    advance(it,i-1);
    if(*it!='+')
        {
            it++;
            s.insert(it,'+');
            sum(s,i+1,counter+1);
        }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string str;
    cin>>str;
    if(str.size()==1)
      return cout<<str<<endl,0;
    list<char> ss(str.begin(),str.end());
    sum(ss,1,0);
    long long sum=0;
    for(auto i:mp)
        {
            str.clear();
            for(auto j:i)
                str+=j;
            stringstream ss(str);
            string wo;
            while(getline(ss, wo, '+'))
                {
                    long long d=stoll(wo);
                    sum+=d;
               }
        }

    cout<<sum<<endl;

    return 0;
}



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

using namespace std;
using ll = long long;

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

  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];

  auto isok = [&](int m) -> bool {
    int sum = 0;
    for (auto aa : a)
      sum += (aa - 1) / m;
    return sum <= k;
  };

  int l = 0;
  int r = 1e9;
  while (r - l > 1) {
    int m = l + (r - l) / 2;
    if (isok(m)) {
      r = m;
    } else {
      l = m;
    }
  }
  cout << r << endl;

  return 0;
}


Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100005;
int n,m,v,p,a[N];
bool check(int mid){
	ll sum=1ll*m*(v-p);
	int nowv=a[mid]+m;
	for(int i=1;i<=n-p+1;++i){
		if(i!=mid){
			if(a[i]<=nowv){
				sum-=min(nowv-a[i],m);
			}
			else{
				return 0;
			}
		}
	}
	return sum<=0;
}
int main(){
	scanf("%d%d%d%d",&n,&m,&v,&p);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	int l=1,r=n,ans=n+1;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid))ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%d\n",n-ans+1);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


int main() {
    int n, a, b;
    string str, c, rst, str2;
    cin >> str;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> c >> a >> b;
        if (c == "print"){
            for (int j = a; j <= b; j++){
                cout << str[j];
            }
        }
        if (c == "replace"){
            cin >> rst;
            for (int k = a; k <= b; k++){
                str[k] = rst[k - a];
            }
        }
        if  (c == "reverse"){
            str2 = str;
            for (int l = b; l >= a; l--){
                str[a - (l - b)] = str2[l];
            }
        }
    if (c == "print"){
        cout << endl;
    }
    }
}


Measured memory_bytes: 3228
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let x: i32 = sc.cin();
    put!(if x >= 30 { "Yes" } else { "No" });
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


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

using ll = long long;
constexpr ll inf = 2e9;

using weight = int;

struct edge {
    int to;
    weight cap;
    int rev;
};

using edges = std::vector<edge>;
using graph = std::vector<edges>;

void add_edge(graph& g, int from, int to, weight cap) {
    g[from].push_back(edge{to, cap, static_cast<int>(g[to].size())});
    g[to].push_back(edge{from, 0, static_cast<int>(g[from].size()-1)});
}

void bfs(graph& g, std::vector<int>& level, int s) {
    for(int i = 0; i < (int)level.size(); ++i) {
        level[i] = -1;
    }
    level[s] = 0;
    std::queue<int> que;
    que.push(s);
    while(!que.empty()) {
        int v = que.front(); que.pop();
        for(int i = 0; i < (int)g[v].size(); ++i) {
            edge& e = g[v][i];
            if(e.cap > 0 && level[e.to] < 0) {
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

weight dfs(graph& g, std::vector<int>& level, std::vector<int>& iter, int v, int t, weight f) {
    if(v == t) {
        return f;
    }
    for(int& i = iter[v]; i < (int)g[v].size(); ++i) {
        edge& e = g[v][i];
        if(e.cap > 0 && level[v] < level[e.to]) {
            weight d = dfs(g, level, iter, e.to, t, std::min(f, e.cap));
            if(d > 0) {
                e.cap -= d;
                g[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

weight max_flow(graph& g, int s, int t) {
    weight flow = 0;
    std::vector<int> level(g.size(), -1);
    std::vector<int> iter(g.size(), 0);
    weight INF = 1e9;
    while(true) {
        bfs(g, level, s);
        if(level[t] < 0) {
            return flow;
        }
        for(int i = 0; i < (int)iter.size(); ++i) {
            iter[i] = 0;
        }
        weight f;
        while((f = dfs(g, level, iter, s, t, INF)) > 0) {
            flow += f;
        }
    }
}

int main() {
    int n; cin >> n;
    map<int, int> m;
    for(int i = 0; i < n; ++i) {
        int a; cin >> a;
        m[a] += 1;
    }
    int ans = 0;
    for(ll x = (1LL << 31); x >= 1; x >>= 1) {
        for(auto& p : m) {
            if(m.count(x - p.first) == 0) continue;
            int r = 0;
            if(p.first * 2 == x) {
                r = p.second / 2;
            } else {
                r = min(p.second, m[x - p.first]);
            }
            ans += r;
            p.second -= r;
            m[x - p.first] -= r;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

const int mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) {
			x -= mod;
		}
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) {
			x -= mod;
		}
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

int main() {
    ll h, w, a, b;
    cin >> h >> w >> a >> b;
    vector<mint> nck1(h-a), nck2(h-a);

    nck1[0] = 1;
    for(int i = 1; i < h - a; i++){
        nck1[i] = nck1[i - 1];
        nck1[i] *= (b - 1 + i);
        nck1[i] /= i;
    }

    nck2[h-a-1] = 1;
    for(int i = w-b+a-1; i >= w-b; i--){
        nck2[h-a-1] *= i;
    }
    for(int i = 1; i <= a; i++){
        nck2[h-a-1] /= i;
    }
    for(int i = 1; i < h - a; i++){
        nck2[h-a-1-i] = nck2[h-a-i];
        nck2[h-a-1-i] *= w-b+a-1+i;
        nck2[h-a-1-i] /= a+i;
    }

    ll ans = 0;
    rep(i, h-a){
        ll sum = nck1[i].x * nck2[i].x;
        sum %= mod;
        ans += sum;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1664
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  string s;
  cin >> s;
  for(int i=1;i<3;i++){
    if(s[i-1]!=s[i]){
      cout <<"Yes\n";
      return 0;
    }
  }
  cout <<"No\n";
}


Measured memory_bytes: 256
#pragma GCC optimze("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll inf=1e18, N=50005;
vector<ll> adj[N];
inline ll mult(ll x,ll y){x%=hell;y%=hell;return (1LL*x*y)%hell;}
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll powMod(ll base,ll expo){
	if(base==0)return 0;
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base); 
		expo>>=1;
	}
	return ans;
}
void solve(){
	ll n, a[3];
	cin>>n;
	ll dp[3][n+2];
	rep(i,0,n+2)rep(j,0,3)dp[j][i]=0;
	rep(j,0,3)dp[j][0]=0;
	rep(i,1,n+1){
		rep(j,0,3)cin>>a[j];
		rep(j,0,3){
			rep(k,0,3){
				if(j==k)continue;
				dp[j][i]=max(dp[j][i],dp[k][i-1]+a[j]);
			}
		}
	}
	cout<<max(dp[0][n],max(dp[1][n],dp[2][n]));
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


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

#define pb push_back
#define mid ((l+r) >> 1)
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int N = 200007;

vector<ii> interv[N];

ll seg[4 * N];
ll lazy[4 * N];

const ll infll = 0x3f3f3f3f3f3f3f3fll;

void prop(int p, int l, int r) {
	if(lazy[p]) {
		seg[p] += lazy[p];


		if(l != r) {
			lazy[2 * p] += lazy[p];
			lazy[2 * p + 1] += lazy[p];
		}
	}
	lazy[p] = 0;
}

void update(int p, int l, int r, int a, int b, ll x) {
	prop(p, l, r);
	if(r < a or l > b) return;
	if(l >= a and r <= b) {
		lazy[p] += x;
		prop(p, l, r);
	} else {
		update(2 * p, l, mid, a, b, x);
		update(2 * p + 1, mid+1, r, a, b, x);
		seg[p] = max(seg[2 * p], seg[2 * p + 1]);
	}
}

ll query(int p, int l, int r, int a, int b) {
	prop(p, l, r);
	if(r < a or l > b) return -infll;
	if(l >= a and r <= b) {
		return seg[p];
	}

	return max(query(2 * p, l, mid, a, b), query(2 * p + 1, mid+1, r, a, b));
}

ll f[N];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n, m; cin >> n >> m;

	for(int i = 0; i < m; ++i) {
		int l, r, w; cin >> l >> r >> w;

		l--, r--;
		interv[l].eb(r, w);
	}


	for(int i = n-1; i >= 0; --i) {
		update(1, 0, n-1, i, i, f[i+1]);

		for(ii aux : interv[i]) {
			int r, w;
			tie(r, w) = aux;

			update(1, 0, n-1, i, r, w);
		}

		f[i] = max(0ll, query(1, 0, n-1, i, n-1));
	}

	cout << f[0] << '\n';
}

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

using namespace std;

typedef long long ll;

int main(){
	ll n,m;
	cin >> n >> m;
	ll sum[n];ll a;
	map<ll, ll> r;r[0]=1;
	for(ll i = 0; i < n; i++){
		cin >> a;
		if(i)sum[i]=(sum[i-1]+a)%m;
		else sum[0]=a;
		auto itr = r.find(sum[i]%m);
		if(itr == r.end())r[sum[i]%m]=1;
		else r[sum[i]%m]++;
	}
	ll ans = 0;
	for(auto itr = r.begin(); itr != r.end(); itr++){
		ll num=itr->second;
		ans+=num*(num-1)/2;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <string.h>
  
#define MAX 2000
  
int main(){
  int n, i, j, a[20], dp[MAX+1], in;
  
  memset(dp,0,sizeof(dp));
  
  scanf("%d" ,&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d" ,a + i);
  }
  
  dp[0] = 1;
  for(i = 0 ; i < n ; i++){
    for(j = MAX ; j >= 0 ; j--){
      if(dp[j] && j + a[i] <= MAX){
        dp[j + a[i]] = 1;
      }
    }
  }
    
  scanf("%d" ,&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d" ,&in);
    if(dp[in]){
      puts("yes");
    }else{
      puts("no");
    }
  }
  
  return 0;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define rap(i,n) for(int i=1;i<=n;++i)
using namespace std;
signed main(){
	int n,k,q,a[1000000],b[1000000];
  cin>>n>>k>>q;
  rap(i,q){
    cin>>a[i];
  }
  rap(i,n){
	b[i] = k -q;
  }
  rap(i,q){
	b[a[i]]++;
    }
  rap(i,n){
    if(b[i]<=0){
	cout<<"No\n";
    }else{
      cout<<"Yes\n";
    }
  }
  return(0);
}

Measured memory_bytes: 6784
# -*- coding: utf-8 -*-
"""
B - Template Matching
https://atcoder.jp/contests/abc054/tasks/abc054_b

"""
import sys


def solve(N, M, A, B):
    for y in range(0, N-M+1):
        for x in range(0, N-M+1):
            for m in range(M):
                t = A[y+m][x:x+M]
                if t != B[m]:
                    break
            else:
                return 'Yes'
    return 'No'


def main(args):
    N, M = map(int, input().split())
    A = [input() for _ in range(N)]
    B = [input() for _ in range(M)]
    ans = solve(N, M, A, B)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define F first
#define S second
#define MP make_pair
#define PB push_back
typedef long long ll;
const ll oo = 1e13;
const ll N = 1e5;
int main() {_
int n,m,cost,time,mn=oo,ans=oo;cin >> n >> m;
for(int i=0;i<n;i++){
    cin >> cost >> time ;
    if(time <= m)
            ans=min(cost,ans);
}
if(ans<1001)
    cout << ans << endl ;
else cout << "TLE" << endl ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n];
    
    for(int i=0; i<n; i++)
        cin>>arr[i];
    
    int ans = 1, val = arr[0];
    
    for(int i=1; i<n; i++)
    {
        if(arr[i] >= val)
            ans++, val = max(val, arr[i]);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,sum=0;
    cin>>n;
    int w[n];
    for(int i=0;i<n;i++)
    {
        cin>>w[i];
        sum+=w[i];
    }
    int mini=sum;
    int pre=0;
    for(int i=0;i<n;i++)
    {
        pre+=w[i];
        mini=min(mini,abs(pre-(sum-pre)));
    }
    cout<<mini<<"\n";
}

Measured memory_bytes: 3580
#include<iostream>
#include<sstream>
#include<vector>
#include<stack>
#include <iomanip>

using namespace std;
inline double toInt(string s) {double v; istringstream sin(s);sin>>v;return v;}

int main()
{
  string str;
  for(;getline(cin,str);)
    {
      istringstream ss(str);
      stack<double,vector<double> > st;
      string tmp;
      for(;ss>>tmp;)
        {
          if(tmp=="+")
            {
              double a=st.top();st.pop();
              double b=st.top();st.pop();
              st.push(b+a);
            }
          else if(tmp=="-")
            {
              double a=st.top();st.pop();
              double b=st.top();st.pop();
              st.push(b-a);
            }
          else if(tmp=="*")
            {
              double a=st.top();st.pop();
              double b=st.top();st.pop();
              st.push(b*a);
            }
          else if(tmp=="/")
            {
              double a=st.top();st.pop();
              double b=st.top();st.pop();
              st.push(b/a);
            }
          else
            {
              st.push(toInt(tmp));
              //              cout<<"tmp"<<st.top()<<endl;
            }
        }
      cout<< fixed << setprecision(6) <<st.top()<<endl;

    }
}

Measured memory_bytes: 1320
#include <vector>
#include <iostream>

using namespace std;
typedef long long int ll;
class stone
{
public:
    int w,v;
    stone(ll wt=0,ll val=0)
    {
        this->w = wt;
        this->v = val;
    }
};

void disp(vector<vector<ll>>& m)
{
    for (int i=0;i<m.size();++i)
    {
        for (int j=0;j<m[0].size();++j)
        {
            cout<<m[i][j]<<" ";
        }
        cout<<endl;
    }
}
ll knap(vector<stone>& inv,ll B)
{
    ll n = inv.size();
    vector<vector<ll>> dp(n+1);
    for (ll i=0;i<=n;++i) dp[i].resize(B+1);

    for (ll item=0;item<n;++item)
    {
        ll i = item+1;
        for (ll cap=1;cap<=B;++cap)
        {
            ll dont = dp[i-1][cap];
            ll take = 0;
            if (cap>=inv[item].w) take = dp[i-1][cap-inv[item].w] + inv[item].v;

            dp[i][cap] = max(take,dont);
        }
    }

    //disp(dp);
    return dp[n][B];
}

int main()
{
    ll n,B;
    cin>>n>>B;

    vector<stone> inv(n);

    for (ll i=0;i<n;++i)
    {
        ll w,v;
        cin>>w>>v;
        stone* st = new stone(w,v);
        inv[i] = *st;
    }

    cout<<knap(inv,B)<<endl;

    return 0;

}


Measured memory_bytes: 79488
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
#define ll               long long
int main(){
  ll a,b,c,f;cin>>a>>b>>c;
  f=a+b+c;
  f-=min({a,b,c})+max({a,b,c});
  cout<<f*min({a,b,c})/2;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

vs f(string s){
	int n=s.size();
	vs a;
	string t;
	for(int i=0;i<n;i++){
		if(s[i]=='\"'){
			a.push_back(t);
			t="";
		}
		else t+=s[i];
	}
	a.push_back(t);
	return a;
}

string s,t;

int main(){
	while(1){
		cin>>s>>t;
		if(s==".") break;
		if(s==t){
			cout<<"IDENTICAL"<<endl;
			continue;
		}
		vs a=f(s),b=f(t);
		if(a.size()==b.size()){
			int t=0;
			for(int i=0;i<a.size();i++){
				if(a[i]!=b[i]){
					if(i%2==1) t++;
					else t=inf;
				}
			}
			if(t==1) cout<<"CLOSE"<<endl;
			else cout<<"DIFFERENT"<<endl;
		}
		else cout<<"DIFFERENT"<<endl;
	}
}


Measured memory_bytes: 3032
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace kp
{
    public class Program
    {
        //static long[,] cmb;
        static int MAX_INT = 1000000007;
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            //int[] input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
            long A = long.Parse(Console.ReadLine());
            long B = long.Parse(Console.ReadLine());
            long C = long.Parse(Console.ReadLine());
            long D = long.Parse(Console.ReadLine());
            long E = long.Parse(Console.ReadLine());
            
            // A~Eの一番小さい数字を探す
            long min = A;
            if (min > B) min = B;
            if (min > C) min = C;
            if (min > D) min = D;
            if (min > E) min = E;

            if (N % min == 0)
                Console.WriteLine((5 + (N/min-1)) + "");
            else
                Console.WriteLine((5 + N/min) + "");


                
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e17;
const ll M = 50;  // 桁数の最大値

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

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    vl dp0(M+1, -1);  // dp0[i+1] : 先頭i桁がkと一致しているときのfの最大値
    vl dp1(M+1, -1);  // dp1[i+1] : 先頭i桁の時点でkより小さいことが確定しているときのfの最大値
    dp0[0] = 0;
    rep(d, M) {
        
        ll mask = 1ull<<(M - 1 - d);  // 先頭からd桁目(dは0-index)のビット

        ll cnt = 0;  // aのmaskビット目が1のものの個数
        rep(i, n) {
            if(a[i] & mask) {
                cnt++;
            }
        }

        // Xのd桁目を0,1にしたときのコスト
        ll cost0 = mask*cnt;
        ll cost1 = mask*(n - cnt);

        // dp1[d] -> dp1[d+1]
        if(dp1[d] != -1) {
            chmax(dp1[d+1], dp1[d] + max(cost0, cost1));
        }

        // dp0[d] -> dp1[d+1]
        if(dp0[d] != -1) {
            if(k & mask) {  // kのmaskビット目が1であることが必要で
                chmax(dp1[d+1], dp0[d] + cost0);  // Xのd桁目は0にする
            }
        }

        // dp0[d] -> dp0[d+1]
        if(dp0[d] != -1) {
            if(k & mask) {  // kのmaskビット目が1のとき
                chmax(dp0[d+1], dp0[d] + cost1);  // Xのd桁目は1にそろえる
            }
            else {  // kのmaskビット目が0のとき
                chmax(dp0[d+1], dp0[d] + cost0);  // Xのd桁目は0にそろえる
            }
        }
        
    }
    
    out(max(dp0[M], dp1[M]));
    re0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
using namespace std;
int main(){
    char S[3];
    for(int i=0;i<3;i++){
        cin >> S[i];
    }
    int count = 0;
    int max = 0;
    for(int i=0;i<3;i++){
        if(S[i]=='R'){
            count++;
        }else {
            count = 0;
        }
    if(max<count) max = count;

    }
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 3744
#include <stdio.h>

int bubble_sort(int n, int *a)
{
	int i, f, x;
int ans = 0;
	do {
		f = 0;
		for (i = n-1; i > 0; i--) {
			if (a[i] < a[i-1]) {
				x = a[i], a[i] = a[i-1], a[i-1] = x;
ans++;
				f = 1;
			}
		}
	} while (f);
return ans;
}
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}
int a[102];
int main()
{
	int N, i, k;
	N = in();
	for (i = 0; i < N; i++) a[i] = in();
	k = bubble_sort(N, a);
	printf("%d", a[0]);
	for (i = 1; i < N; i++) printf(" %d", a[i]);
	putchar('\n');
	printf("%d\n", k);
	return 0;
}




Measured memory_bytes: 2064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define int long long
using namespace std;
signed main() {
	string s; cin >> s;
	int ans1 = 0, ans2 = 0;
	for (int i = 0; i < s.size(); i++) 
		if (s[i] - '0' != i % 2)ans1++;
	for (int i = 0; i < s.size(); i++)
		if (s[i] - '0' != (i+1) % 2)ans2++;
	cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 512
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("NO"),0;
#define mod 1000000007
#define N 500055
//#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,r,c,tot,cnt,z[N],a1,a2,b1,b2;
pa q[N];
int check(int x,int y){
	if (y==0) return x;
	if (x==r) return y+r;
	if (y==c) return r+c+r-x;
	if (x==0) return r+r+c+c-y;
	return -1;
}
signed main(){
	r=read();c=read();n=read();
	tot=0;
	F(i,1,n){
		a1=read();a2=read();b1=read();b2=read();
		if (check(a1,a2)!=-1&&check(b1,b2)!=-1){
			a1=check(a1,a2);b1=check(b1,b2);
			if (a1>b1) swap(a1,b1);
			q[++tot]=mp(a1,i);q[++tot]=mp(b1,-i);
		}
	}
	sort(q+1,q+tot+1);
	F(i,1,tot){
		if (q[i].se>0){
			z[++cnt]=q[i].se;
		}
		else{
			if (q[i].se!=-z[cnt]) ret;
			cnt--;
		}
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 3840
#include<iostream>
using namespace std;
#include<string>
#include<stdio.h>

typedef struct box { int val; box *prev, *next; } box_t;
box_t* init()
{
    box_t* head = new box_t;
    head->val = -1;
    head->next = NULL;
    head->prev = NULL;
    return head;
}
box_t* make_tail(box_t* head)
{
    box_t* tail = new box_t;
    tail->val = -1;
    head->next = tail;
    tail->next = NULL;
    tail->prev = head;
    return tail;
}
// f_insert, f_delete_key, f_delete, b_delete, f_show.
box_t* f_insert(box_t* head, int data)
{
    box_t* box = new box_t;
    box->val = data;
    box->next = head->next;
    box->prev = head;
    head->next->prev = box;
    head->next = box;
    return box;
}
int f_delete_key(box_t* head, box_t* tail, int key)
{
    box_t* box = head->next;
    while(box != tail){
        if(box->val == key){
            box->next->prev = box->prev;
            box->prev->next = box->next;
            delete box;
            return 1; }
        box = box->next; };
    return -1;
}
int f_delete(box_t* head)
{
    if(!(head->next->next)) return -1;
    box_t* box = head->next;
    head->next = box->next;
    box->next->prev = head;
    delete box;
    return 1;
}
int b_delete(box_t* tail)
{
    if(!(tail->prev->prev)) return -1;
    box_t* box = tail->prev;
    tail->prev = box->prev;
    box->prev->next = tail;
    delete box;
    return 1;
}
void f_show(box_t* head, box_t* tail)
{
    box_t* box = head->next;
    while(box != tail){
        printf("%d", box->val);
        box = box->next;
        if(box != tail) printf(" "); };
    printf("\n");
    return;
}
int main()
{
    int i, n;
    cin >> n;
    string cmd; int key;
    box_t* head = init();
    box_t* tail = make_tail(head);
    for(i = 0; i < n; i++){
        cin >> cmd;
        if(cmd[0] == 'i'){ scanf("%d", &key); f_insert(head, key); }
        else if(cmd[6] == 'F'){ f_delete(head); }else if(cmd[6] == 'L'){ b_delete(tail); }
        else{ scanf("%d", &key); f_delete_key(head, tail, key); }
    }
    f_show(head, tail);
    return 0;
}

Measured memory_bytes: 32500
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

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

  int i=0;
  while(i<s.size()){
    cout<<s[i];
    i+=w;
  }
  cout<<endl;

  return 0;
}

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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;


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

    cout << s[0] << s.size() - 2 << s.back();


}

Measured memory_bytes: 256
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new File("c:\\0526-input.txt"));

		while (scan.hasNext()) {
			String a = scan.next();
			String b = scan.next();
			System.out.println(run(a, b));
		}
		scan.close();
		System.exit(0);
	}

	private static int run(String a, String b) {
		return Math.max(len(a, b), len(b, a));
	}

	private static int len(String a, String b) {
		int max = 0;

		for (int i = 0; i <= a.length(); i++) {
			int c = 0;
			for (int j = i, k = 0; j < a.length() && k < b.length(); j++, k++)
				if (a.charAt(j) == b.charAt(k))
					c++;
				else {
					if (c > max)
						max = c;
					c = 0;
				}
			if (c > max)
				max = c;
		}
		return max;
	}
}

Measured memory_bytes: 28812
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int count = 0;
  
  for (int i = 0; i < K; i++) {
    if (A >= B) {
      B *= 2;
      count++;
    }
  }
  
  for (int i = 0; i < K - count; i++) {
    if (B >= C) {
      C *= 2;
    }
  }
  if (A < B && B < C) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(){
	int n,a,b;
	long long ans;
	cin>>n>>a>>b;
	if(a>b)
		ans=0;
	else if(n==1){
		if(a==b)
		  ans=1;
		else 
			ans=0;
	}
	else
		ans=(long long)(n-2)*(b-a)+1;

	cout<<ans;
	return 0;
}

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

using namespace std;

void divisibility(int arr[], int n)
{

  unordered_set<int> set;
  int max_ele = INT_MIN;
  for (int i = 0; i < n; i++) {
    set.insert(arr[i]);

    max_ele = max(max_ele, arr[i]);
  }

  unordered_set<int> res;
  for (int i = 0; i < n; i++) {

    if (arr[i] != 0) {

      for (int j = arr[i] * 2; j <= max_ele; j += arr[i]) {

        if (set.find(j) != set.end())
          res.insert(j);
      }
    }
  }


  unordered_map<int, int> map;
  for (int i = 0; i < n; i++)
    map[arr[i]]++;

  unordered_map<int, int>::iterator it;
  vector<int> ans;
  for (it = map.begin(); it != map.end(); it++) {

    if (it->second >= 2) {
      if (res.find(it->first) == res.end()) {

        int val = it->second;
        while (val--)
          ans.push_back(it->first);
      }
    }

    if (res.find(it->first) != res.end()) {
      int val = it->second;

      while (val--)
        ans.push_back(it->first);
    }
  }

  int count = 0;
  for (auto x : ans)
    count++;
  cout << n - count << endl;
}

int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  int n;
  cin >> n;
  int a[n];

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

  divisibility(a, n);

  return 0;
}


Measured memory_bytes: 30564
#include <bits/stdc++.h>
using namespace std;
int main() {
long long counter=0;
long long n;
cin>>n;
long long a;
cin>>a;
long long odd=0;
long long asd=0;
for(long long i=0;i<n;i++){
cin>>counter;
if(counter%2==0){
asd++;}
else{
odd++;}}
if(odd==0){
if(a==0){
counter=pow(2,n);
cout<<counter<<endl;}
else{
cout<<0<<endl;}}
else{counter=pow(2,n-1);
cout<<counter<<endl;}}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
using namespace std;
using ll = long long;
int main() {
  ll n;
  cin >> n;
  vector<ll> A(n, 0);
  map<ll,ll> C;
  ll sum = 0;
  for(ll i=0; i<n; i++) {
    cin >> A[i];
    sum += A[i];
    C[A[i]]++;
  }
  ll q;
  cin >> q;
  for(ll i=0; i<q; i++) {
    ll b,c;
    cin >> b >> c;
    if(C.count(b)==1) {
      ll amt = C[b];
      sum += amt*(c-b);
      C[c] += amt;
      C.erase(b);
    }
    cout << sum << endl;
  }
}


Measured memory_bytes: 7936
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

LL get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		LL s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	LL s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 1e+5+5;

int n;
map<LL,int>id;
int k;
int cnt[N];
int tk[N];

int main(){
	n=get();
	bool pd=0;
	fo(i,1,n){
		LL x=get(),y=1,px=1;
		fo(j,2,2154)
		if (x%j==0){
			int c=0;
			while(x%j==0)x/=j,c++;
			c=c%3;
			if (c){
				fo(t,1,c)px=px*j;
				fo(t,1,3-c)y=y*j;
			}
		}
		if (x==1&&y==1)pd=1;
		else{
			LL v=sqrt(x);
			if (v*v<x)v++;
			if (v*v==x)x=x*px,y=y*v;
			else{y=y*x*x;x=x*px;}
			if (!id[x])id[x]=++k;
			cnt[id[x]]++;
			if (id[y]){
				tk[id[x]]=id[y];
				tk[id[y]]=id[x];
			}
		}
	}
	int ans=0;
	fo(i,1,k)
	if (!tk[i]||tk[i]<i)ans+=max(cnt[i],cnt[tk[i]]);
	if (pd)ans++;
	printf("%d\n",ans);
	return 0;
}

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

// // two stack implementation
// int main(){
//     string s;
//     cin >> s;
//     int q;
//     cin >> q;
//     string t;
//     rep(qi, q) {
//         int ty;
//         cin >> ty;
//         if(ty == 1) {
//             swap(s, t);
//         } else {
//             int f; char c;
//             cin >> f >> c;
//             if (f == 1) {
//                 t += c;
//             } else {
//                 s += c;
//             }
//         }
//     }
//     reverse(t.begin(), t.end());
//     t += s;
//     cout << t << endl;
//     return 0;
// }

int main() {
    string s;
    cin >> s;
    deque<char> q;
    for (char c : s) q.push_back(c);
    bool flip = false;
    int Q;
    cin >> Q;
    rep(qi, Q) {
        int query_type;
        cin >> query_type;
        if (query_type == 1){
            flip = !flip;
        } else {
            int f; char c;
            cin >> f >> c;
            if (flip) f = 3 - f;
            if (f == 1) {
                q.push_front(c);
            } else {
                q.push_back(c);
            }
        }
    }
    if (flip) reverse(q.begin(), q.end());
    string ans;
    for (char c : q) ans += c;
    cout << ans << endl;
}

Measured memory_bytes: 1412
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    H,W=map(int,input().split())
    A=[[] for _ in range(H+2)]
    A[0]=A[H+1]=['#']*(W+2)
    black=[]
    for i in range(1,H+1):
        row=list(input())
        A[i]=['#']+row+['#']
        for j,cell in enumerate(row):
            if cell=='#':
                black.append([i,j+1])
    nextcells=[]
    nextcells.extend(black)
    c=-1
    dx=[0,1,0,-1]
    dy=[1,0,-1,0]
    while nextcells:
        c+=1
        cells=[]
        cells.extend(nextcells)
        nextcells=[]
        for cell in cells:
            for k in range(4):
                if A[cell[0]+dy[k]][cell[1]+dx[k]]=='.':
                    nextcells.append([cell[0]+dy[k],cell[1]+dx[k]])
                    A[cell[0]+dy[k]][cell[1]+dx[k]]='#'
    print(c)
        

if __name__ == '__main__':
    main()


Measured memory_bytes: 185768
import sys
n, m = map(int, input().split())
a = []
for i in range(n):
  a.append(list(input()))
b = []
for i in range(m):
  b.append(list(input()))
for i in range(n - m + 1):
  for j in range(n - m + 1):
    if [c[j:j+m] for c in a[i:i+m]] == b:
      print('Yes')
      sys.exit()
print('No')


Measured memory_bytes: 3064
import java.util.*;

 
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    
    Queue<Long> q = new ArrayDeque<>();
    
    for(long i=1;i<10;i++){
      q.add(i);
    }
    long tmp;
    long x=1;
    
    while(k-- >0){
      x = q.poll();
      tmp = x % 10;
      if(tmp != 0)
        q.add(10*x + tmp -1);
      q.add(10*x+tmp);
      if(tmp != 9)
        q.add(10*x + tmp +1);
    }
    System.out.println(x);
    
  }
}

Measured memory_bytes: 30036
#include<iostream>
#include<cstdio>
#include<cmath>
#define ll long long
using namespace std;
ll s,x11,x22,x33,y11,y22,y33;
int main(){
	scanf("%lld",&s);
	ll t=sqrt(s);
	if(t*t<s)t++;
	ll a=(t*t-s)%t;
	ll b=(t*t-s)/t;
	x11=0;y22=0;
	x33=t;
	y33=t-b;
	y11=y33-1;
	x22=x33-a;
	printf("%lld %lld %lld %lld %lld %lld",x11,y11,x22,y22,x33,y33);
	return 0;
}

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

int main(){
  long long int n,k;
  cin >> n >> k;
  vector<long long int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  for(int i=0;i<n-k;i++){
    if(a.at(i+k)>a.at(i)){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 4788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


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

  ll y = 100;
  ll ans = 0;
  while (y < x) {
    y = y * 1.01;
    ++ans;
  }
  
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3664
# https://tjkendev.github.io/procon-library/python/max_flow/dinic.html
from collections import deque
class Dinic:
	def __init__(self, n):
		self.n = n
		self.g = [[] for i in range(n)]

	def add_edge(self, fr, to, cap):
		forward = [to, cap, None]
		forward[2] = backward = [fr, 0, forward]
		self.g[fr].append(forward)
		self.g[to].append(backward)

	def add_bidirectional_edge(self, v1, v2, cap1, cap2):
		edge1 = [v2, cap1, None]
		edge1[2] = edge2 = [v1, cap2, edge1]
		self.g[v1].append(edge1)
		self.g[v2].append(edge2)

	def bfs(self, s, t):
		self.level = level = [None]*self.n
		deq = deque([s])
		level[s] = 0
		g = self.g
		while deq:
			v = deq.popleft()
			lv = level[v] + 1
			for w, cap, _ in g[v]:
				if cap and level[w] is None:
					level[w] = lv
					deq.append(w)
		return level[t] is not None

	def dfs(self, v, t, f):
		if v == t:
			return f
		level = self.level
		for e in self.it[v]:
			w, cap, rev = e
			if cap and level[v] < level[w]:
				d = self.dfs(w, t, min(f, cap))
				if d:
					e[1] -= d
					rev[1] += d
					return d
		return 0

	def flow(self, s, t):
		flow = 0
		INF = 10**30
		g = self.g
		while self.bfs(s, t):
			*self.it, = map(iter, self.g)
			f = INF
			while f:
				f = self.dfs(s, t, INF)
				flow += f
		return flow

H, W = map(int, input().split())
a = [input() for _ in range(H)]
d = Dinic(H+W+2)
for i in range(H):
	for j in range(W):
		if a[i][j] == "S":
			d.add_edge(H+W, i, 10**5)
			d.add_edge(H+W, H+j, 10**5)
		elif a[i][j] == "T":
			d.add_edge(i, H+W+1, 10**5)
			d.add_edge(H+j, H+W+1, 10**5)
		elif a[i][j] == "o":
			d.add_edge(i, H+j, 1)
			d.add_edge(H+j, i, 1)
ans = d.flow(H+W, H+W+1)
if ans > 10000:
	print(-1)
else:
	print(ans)

Measured memory_bytes: 47964