akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
fn main(){
    input!{
        n:usize,
        an:[f64;n],
    }
    let mut ans = 0.;
    for a in &an {
        let sub = 1. / a;
        ans += sub;
    }
    let ans = 1. / ans;
    println!("{}",ans);
}


fn is_prime(x:i64) -> bool {
    if x == 2 {return true;}
    if x < 2 || x % 2 == 0 {return false;}
    let mut j = 3;
    while j <= (x as f64).sqrt() as i64 {
        if x % j == 0 {
            return false;
        }
        j += 2;
    }
    true
}


Measured memory_bytes: 4352
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/
 
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;
 
ll inv[MAX_N], fac[MAX_N];
 
template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }
 
typedef pair<int, pair<int, int>> edge;
 
class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1LL); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};

int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}
 
ll UnionFind::size(int x) {
	return -par[find(x)];
}
 
void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);
 	if (x == y) return;
	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);

	par[x] += par[y];
	par[y] = x;
}
 
bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}

signed main() {
	int n, a, b, c, d;
	cin>>n>>a>>b>>c>>d;
	string s; cin >> s;
	if (c < d) {
		bool ok = true;
		FOR (i,b,d-1) {
			if (s[i-1] == '#' && s[i] == '#') ok = false;
		}
		FOR (i,a,c-1) {
			if (s[i-1] == '#' && s[i] == '#') ok = false;
		}
		if (ok) cout << "Yes" << endl;
		else cout << "No" << endl;
	} else {
		bool ok = true;
		FOR (i,b,d-1) {
			if (s[i-1] == '#' && s[i] == '#') ok = false;
		}
		FOR (i,a,c-1) {
			if (s[i-1] == '#' && s[i] == '#') ok = false;
		}
		if (!ok) {cout << "No" << endl; return 0;}
		FOR (i,b-1,d) {
			if (s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') {
				cout << "Yes" << endl;
				return 0;
			}
		}
		if (c >= s.size() || s[c] == '#') {
			cout << "No" << endl;
			return 0;
		} else {
			if (s[c-2] == '.') {
				cout << "Yes" << endl;
			} else {
				cout << "No" << endl;
			}
		}
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    for (int i=0;i<s.length();i++){
    	s[i]+=n;
        if (s[i]>'Z'){
        	s[i]-=26;
        }
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d[51],x;
    long int sum;
    cin>>n;
    for(int i = 0;i<n;i++)
        cin>>d[i];
    //x = n*(n-1)/2;
    sum = 0;
    for(int i = 0;i<n;i++)
    {
        for(int j = i+1;j<n;j++)
        {
            sum += d[i]*d[j];
        }
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

ll GCD(ll a, ll b){
    if(b==0) return a;
    else return GCD(b,a%b);
}

int main(){
    ll a,b,k; cin >> a >> b >> k;
    ll p = GCD(a,b);
    ll cnt = 0;
    for(ll i=p; i>=1; i--){
        if(p % i == 0){
            cnt++;
            if(cnt == k){
                cout << i << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){

    while(1){
        int i,n=0;
        char x[1000];
        
        scanf("%s", &x);
        if(x[0]=='0'){
            break;
        }else{
            for(i=0;i<strlen(x);i++){
                n+=x[i]-'0';
            }
            printf("%d\n",n);
        }
    }
    return 0;
}


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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  string s;
  cin >> s;
  LL YY= (s[0]-'0')*10+(s[1]-'0');
  LL MM= (s[2]-'0')*10+(s[3]-'0');

  if(1<=YY&&YY<=12){
    if(1<=MM&&MM<=12){
      cout << "AMBIGUOUS" << endl;
    }
    else
    {
      cout << "MMYY" << endl;
    }
  }else{
    if(1<=MM&&MM<=12){
      cout << "YYMM" << endl;
    }else{
      cout << "NA" << endl;
    }
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n); i >= 0; i--)
#define revrepr(i, a, b) for (int i = (a); i >= b; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

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

const long long MOD = 1e9+7;

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; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

int main() {
    int n;
    cin >> n;
    rep(i, n) {
        int a;
        cin >> a;
        if (a % 2 == 0 && !(a % 3 == 0 || a % 5 == 0)) {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
}

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

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  int cnt = 1;
  vector<int> A;
  rep(i, 0, 2) A.push_back(0);
  if(S[0] == '0') A.push_back(0);
  rep(i, 1, N) {
    if(S[i] == S[i-1]) {
      cnt++;
    } else {
      A.push_back(cnt);
      cnt = 1;
    }
  }
  if(cnt) A.push_back(cnt);
  rep(i, 0, 2) A.push_back(0);
  vector<int> sum(A.size() + 1);
  for(int i = 0; i < A.size(); i++) sum[i+1] = sum[i] + A[i];
  int mx = 0;
  K = 2 * K + 1;
  if(sum.size() <= K) {
    cout << N << endl;
    return 0;
  }
  rep(i, 0, sum.size() - K - 1) {
    int a = sum[i+K] - sum[i];
    if(i%2) continue;
    mx = max(mx, a);
  }
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 1272
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
ans=[]
if m==1:
    print(0)
    exit()
if n==1:
    print(max(a)-min(a))
    exit()
for i in range(m-1):
    ans.append(abs(a[i+1]-a[i]))
total=0
ans.sort(reverse=True)
if len(ans)<=n:
    print(0)
    exit()
for i in range(n-1):
    total+=ans[i]
print(sum(ans)-total)


Measured memory_bytes: 13968
#include <stdio.h>
#include <stdlib.h>
int c(const void *v1,const void *v2){
    return *(int *)v1-*(int *)v2;
}
int main(void){
    int n,t,o,id,m1,s1,m2,s2,m3,s3,m4,s4,i,line[200000],line1[400000];
    for(;t=0,o=0,scanf("%d",&n),n;){
        for(i=0;i<n;i++){
            scanf("%d %d %d %d %d %d %d %d %d",&id,&m1,&s1,&m2,&s2,&m3,&s3,&m4,&s4);
            line[o++]=id;
            line[o++]=line1[t++]=m1*60+s1+m2*60+s2+m3*60+s3+m4*60+s4;
        }
        qsort(line1,n,4,c);
        for(i=1;i<2*n;i+=2)
            if(line1[0]==line[i]){
                printf("%d\n",line[i-1]);
                break;
            }
        for(i=1;i<2*n;i+=2)
            if(line1[1]==line[i]){
                printf("%d\n",line[i-1]);
                break;
            }
        for(i=1;i<2*n;i+=2)
            if(line1[n-2]==line[i]){
                printf("%d\n",line[i-1]);
                break;
            }
    }
    return 0;
}

Measured memory_bytes: 736
n = input()
s = list(input())
n = int(n)

r = s.count("R")
g = s.count("G")
b = s.count("B")
ans = r*g*b

for i in range(1,n):
    for j in range(min(i+1,n-i)):
        k = j*2 -i
        if j - i == k -j:
            if k <= n and s[i] != s[i+j] and s[i] != s[i-j] and s[i+j] != s[i-j]:
                ans -= 1
print(ans)

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

#define F(i, a, b) for(int i=a; i<b; i++)
#define mem(arr, val) memset(arr, val, sizeof(arr))
#define rev(str) reverse(str.begin(), str.end())
#define UPPER(str) transform(str.begin(), str.end(), str.begin(), ::toupper)
#define LOWER(str) transform(str.begin(), str.end(), str.begin(), ::tolower)

#define MOD 1000000007
#define INF 1000000000000001
#define epsilon 1e-15

typedef long long int ll;
typedef unsigned long long int ull;

class graph{
    int V, E;
    vector<int> *adj;
public:
    graph(int n, int m){
        this->V = n;
        this->E = m;
        adj = new vector<int>[V+1];
    }

    void insert_edge(int u, int v){
        adj[u].push_back(v);
        adj[0].push_back(u);
        adj[0].push_back(v);
    }

    int topological_sort(){
        int indegree[V+1] = {};
        for(int i=0; i<=V; i++){
            for(auto j : adj[i])
                indegree[j]++;
        }

        int d[V+1] = {};

        queue<int> Q;
        Q.push(0);

        while(!Q.empty()){
            int s = Q.front();
            Q.pop();
            indegree[s] = -1;
            for(auto u : adj[s]){
                indegree[u]--;
                d[u] = max(d[u], d[s]+1);
                if(indegree[u]==0)
                    Q.push(u);
            }
        }

        int ans = 0;
        for(int i=0; i<=V; i++)
            ans = max(ans, d[i]);

        return ans-1;
    }


    void clear(){
        delete[] adj;
    }
};

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    int N, M, u, v;
    cin >> N >> M;

    graph G(N, M);

    for(int i=0; i<M; i++){
        cin >> u >> v;
        G.insert_edge(u, v); 
    }

    int ans = G.topological_sort();

    cout << ans << '\n';

    G.clear();

    return 0;
   
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int x; cin >> x;

    cout << ((x < 1200) ? "ABC" : "ARC");

}


Measured memory_bytes: 256
s = input()
answer = []
cursor = 0


for i in range(len(s)):
  if s[i] == "0" or s[i] == "1":
    #print(s[i])
    answer.append(s[i])
    cursor += 1
  elif cursor > 0:
    del answer[-1]
    cursor -= 1
for i in range(cursor):
  print(answer[i], end = "")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        if(r < 1200){
            System.out.println("ABC");
        }else if(r < 2800){
            System.out.println("ARC");
        } else{
            System.out.println("AGC");
        }
    }
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  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;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main()
{
  ll n, m, k;
  cin >> n >> m >> k;
  combination C(m*n);

  mint ans = 0;
  for(int d = 1; d < m; ++d) {
    mint add = d;
    add *= n*n;
    add *= m-d;
    ans += add;
  }
  for(int d = 1; d < n; ++d) {
    mint add = d;
    add *= m*m;
    add *= n-d;
    ans += add;
  }

  ans *= C(n*m-2, k-2);
  cout << ans.x << endl;
}


Measured memory_bytes: 6392
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    N = int(input())
    A_lsit = list(map(int, input().split()))
    A_binstr_lsit = [bin(a)[2:].zfill(30) for a in A_lsit]

    is_odd_list = [
        bool(sum([
                int(A_binstr_lsit[j][i])
                for j in range(N)
            ])%2)
        for i in range(30)
    ]

    #print(A_lsit)
    #print(A_binstr_lsit)
    #print(is_odd_list)

    answer_list = []

    for i in range(N):
        A_bin = A_binstr_lsit[i]
        answer = ""
        for j in range(30):
            if is_odd_list[j]:
                if A_bin[j] == "1":
                    answer += "0"
                else:
                    answer += "1"
            else:
                answer += A_bin[j]
        answer_list.append(str(int(answer, 2)))
    print(" ".join(answer_list))

if __name__ == "__main__":
    main()



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

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        a: [usize; n],
    }

    let mut a = a;
    let mut sum = 0;
    for i in 1..n  {
        if a[i - 1] > a[i] {
            let sub = a[i - 1] - a[i];
            a[i] += sub;
            sum += sub;
        }
    }

    print!("{}", sum);
}

Measured memory_bytes: 3564
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, P = MAP()
A = list(map(int, input()))

if P == 2 or P == 5:
    ans = 0
    for i, a in enumerate(A):
        if a % P == 0:
            ans += i + 1
    print(ans)
    exit()

acc = [0] * N
cur = A[-1] % P
acc[-1] = cur
k = 1
for i in range(N-2, -1, -1):
    cur += pow(10, k, P) * A[i]
    cur %= P
    acc[i] = cur
    k += 1
acc = acc + [0]

C = Counter(acc)
ans = 0
for v in C.values():
    ans += v * (v-1) // 2
print(ans)


Measured memory_bytes: 14392
// Program.cpp

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

typedef long long           ll;
typedef pair<int, int>      pii;
typedef vector<int>         vi;

#define fr(i, n)            for(int i=0; i<(n); ++i)
#define frC(i, n)           for(int i=0; (i<(n)) && (c); ++i)
#define frA(i, a, n)        for(int i=a; i<=(n); ++i)
#define frD(i, a, n)        for(int i=a; i>=(n); --i)
#define fill(a)             memset(a, 0, sizeof(a))
#define revsort(a, b)       sort(a, b, greater<int>())
#define dout                if(DEBUGGING) cout
#define dbg                 if(DEBUGGING) 
#define endl                "\n"

int DEBUGGING    =          0;
const int INF    =          1000000000;
const int MOD    =          1000000007;
const double PI  =          3.1415926535897932;
const double EPS =          1e-7;

void solve(int TEST_CASE){
    int n;
    cin >> n;
    int a[n],b[n],c[n];
    fr(i,n){
    	cin >> a[i] >> b[i] >> c[i];
    }
    int m[n][3];
    m[0][0] = a[0];
    m[0][1] = b[0];
    m[0][2] = c[0];
    for(int i=1;i<n;++i){
    	m[i][0] = a[i] + max(m[i-1][1],m[i-1][2]);
    	m[i][1] = b[i] + max(m[i-1][0],m[i-1][2]);
    	m[i][2] = c[i] + max(m[i-1][1],m[i-1][0]);
    }
    cout << max(m[n-1][0],max(m[n-1][1],m[n-1][2])) << endl;
}

int main(int argc, char* argv[]){
    if(argc==2 && argv[1][1]=='v') DEBUGGING = 1;
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);
    int nTestCases=1;
    //cin >> nTestCases;
    frA(i,1,nTestCases) solve(i);
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  double result = 0.0;
  int ix;
  double dx;
  string u;
  string x;
  for (int i = 0; i < N; i++) {
    cin >> x >> u;
    if (u == "JPY") {
      ix = stoi(x);
      result += ix;
    } else {
      dx = stod(x);
      result += dx * 380000.0;
    }
  }
  
  cout << result << endl;
  
  return 0;
}


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

typedef long long ll;

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    if (abs(A - B) % 2 == 0)
    {
        cout << "Alice" << endl;
    }
    else
    {
        cout << "Borys" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static const long long MOD_NUM = 1000000007LL;

static void B_task();

int main()
{
	B_task();
	fflush(stdout);
	return 0;
}

static void B_task()
{
	int N;
	static char str[10001] = { 0 };

	get1int(N);
	getstring(str);

	int len = strlen(str);
	for (int i = 0; i < len; i++) {
		int ch = str[i] + N;
		if (ch > 'Z') {
			ch -= 26;
		}
		printf("%c", ch);
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
ll n;
ll rui[20];
ll cnt(ll a,ll b,ll d){ // (a,b]
	return b/d-a/d;
}
ll fizzbuzz_len(ll x){
	ll rem = x;
	ll len = 0ll;
	for(int i=0;;i++){
		if(rem>=rui[i]*9ll){
			ll len8 = cnt(rui[i]-1,rui[i+1]-1,15ll);
			ll len4 = cnt(rui[i]-1,rui[i+1]-1,3ll)+cnt(rui[i]-1,rui[i+1]-1,5ll)-len8*2ll;
			ll ret = rui[i]*9-len8-len4;
			ll s = ret*(ll)(i+1)+len4*4+len8*8;
			rem -= rui[i]*9;
			len += s;
		}else{
			ll len8 = cnt(rui[i]-1,x,15ll);
			ll len4 = cnt(rui[i]-1,x,3ll)+cnt(rui[i]-1,x,5ll)-len8*2ll;
			ll ret = (x-rui[i]+1ll)-len8-len4;
			ll s = ret*(ll)(i+1)+len4*4+len8*8;
			len += s;
			break;
		}
	}
	return len;
}
string fizzbuzz(ll x){
	if(x%15==0)return "FizzBuzz";
	if(x%3==0)return "Fizz";
	if(x%5==0)return "Buzz";
	string ret;
	while(x){
		ret+=(x%10)+'0';
		x/=10;
	}
	reverse(all(ret));
	return ret;
}
int main(){
	cin >> n;
	rui[0]=1ll;
	for(int i=1;i<20;i++)rui[i]=rui[i-1]*10ll;
	ll l=0ll,r=100000000000000000ll;
	while(r-l>1ll){
		ll mid = (l+r)/2;
		if(fizzbuzz_len(mid)<n)l=mid;
		else r = mid;
	}
	int idx = n-fizzbuzz_len(l++)-1;
	string ans;
	while((int)ans.size()<idx+20){
		ans += fizzbuzz(l++);
	}
	cout << ans.substr(idx,20) << endl;
	return 0;
}

Measured memory_bytes: 3180
n, m = map(int, input().split())
a = [[c for c in input()] for i in range(n)]
b = [[v for v in input()] for j in range(m)]
exist = False
for y in range(n):
    for x in range(n):
        if y+m-1 >= n or x+m-1 >= n: continue
        match = True
        for by in range(m):
            for bx in range(m):
                if a[y+by][x+bx] != b[by][bx]: match = False
        if match: exist = True
print('Yes' if exist else 'No')

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

using namespace std;

int main(){
  int n; cin >> n;
  string str[2];
  cin >> str[0] >> str[1];
  vector<int> v;
  for(int i=0;i<n;i++){
    if(str[0][i]==str[1][i]){
      //tate
      v.push_back(1);
    }else{
      //yoko
      v.push_back(0);
      i++;
    }
  }
  long long ans;
  if(v[0]==0) ans=6;
  else ans=3;
  for(int i=0;i<v.size()-1;i++){
    if(v[i]==1 && v[i+1]==0){
      ans=(ans*2)%1000000007;
    }else if(v[i]==0 && v[i+1]==0){
      ans=(ans*3)%1000000007;
    }else if(v[i]==1 && v[i+1]==1){
      ans=(ans*2)%1000000007;
    }
  }
  cout << ans << endl;
}

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

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

    int count = 0;

    int i = 0;
    while(i < s.size()){
        if(s[i] == s[i+1]){
            while(i < s.size() and s[i] == s[i+1]){
                i++;
            }
            i++;
            count++;
        }
        else{
            i++;
            count++;
        }
    }

    cout << count-1 << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define mo 100005
int a[mo],dp[mo];
int n,m;
int main()
{
    while(cin>>n>>m)
    {
        for(int i=0;i<m;i++)
        {
            cin>>a[i];
        }
        memset(dp,1,sizeof(dp));
        dp[0]=0;
        for(int i=0;i<m;i++)
        {
            for(int j=a[i];j<=n;j++)
            {
                dp[j]=min(dp[j-a[i]]+1,dp[j]);
            }
        }
        cout<<dp[n]<<endl;
    }


}



Measured memory_bytes: 3476
#include<stdio.h>
#include <malloc.h>
bool sushu(int a)
{

	for(int i=2;i*i<=a;i++)
	
		if((a%i)==0)
	return false;
	
		return true;
 
}

int main()
{
	int N,count=0;
	scanf("%d",&N);
	//int A[10000];
	int *A;
	A=(int*)malloc(sizeof(int)*N);

	for(int i=0;i<N;i++)
	{
		scanf("%d",&A[i]);
		
		if(sushu(A[i]))
			count++;
	}

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

}


Measured memory_bytes: 2680
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i] >>y[i];
typedef long long int ll;
using namespace std;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

int main(){
	int r,d,x; cin >>r>>d>>x;
	int cnt=x;
	for(int i=0;i<10;i++){
		cnt=r*cnt-d;
		cout << cnt << endl;
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#include "string"
#define int long long
#define pi pair <int, int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl '\n'

const int N = 5e5 + 5;
const int M = 1e9 + 7;

int mod( int m ,int mod = M) {
   m %= mod;
   return (m + mod) % mod;
}

int power(int x,int y) {
   int res = 1;
   x = mod(x);
   while (y > 0) {
      if (y & 1)
         res =mod(res * x);
      y = y / 2;
      x = mod(x * x);
   }
   return mod(res);
}

int32_t main() {
	boost;
	int n;
	cin >> n;
	int ans = power(10, n);
	ans = mod(ans - 2 * power(9, n));
	ans = mod(ans + power(8, n));
	cout << ans << endl;	
}

Measured memory_bytes: 3596
from numba import njit
import numpy as np


@njit('i8(i8, i8, i8)', cache=True)
def mod_pow(x, a, MOD):
    ret = 1
    cur = x
    while a:
        if a & 1:
            ret = ret * cur % MOD
        cur = cur * cur % MOD
        a >>= 1
    return ret


@njit('UniTuple(i8[:], 2)(i8, i8)', cache=True)
def prepare(n, MOD):
    factorials = np.ones(n + 1, dtype=np.int64)
    for i in range(2, n + 1):
        factorials[i] = factorials[i - 1] * i % MOD
    finvs = np.ones(n + 1, dtype=np.int64)
    finvs[n] = mod_pow(factorials[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        finvs[i - 1] = finvs[i] * i % MOD
    return factorials, finvs


@njit('i8(i8, i8)', cache=True)
def solve(k, ls):
    MOD = 10 ** 9 + 7
    facts, finvs = prepare(k + ls, MOD)

    ans = 0
    for i in range(k + 1):
        r = k - i
        pat = facts[ls + r - 1] * finvs[ls - 1] % MOD * finvs[r] % MOD
        ans = (ans + pat * mod_pow(25, r, MOD) % MOD * mod_pow(26, i, MOD)) % MOD

    return ans


k = int(input())
s = input()
print(solve(k, len(s)))


Measured memory_bytes: 139816
c = int(input())
s = input().split()
count = 0
for j in range(c):
    for i in range(c-1,j,-1):
        if int(s[i]) < int(s[i-1]):
            s[i],s[i-1] = s[i-1],s[i]
            count += 1
print(" ".join(s))
print(count)

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

void doc(){
    freopen("OB.inp","r", stdin);
    freopen("OB.out","w", stdout);
}

typedef pair<int, int> ii;

void solve(){
    int n;
    cin >> n;
    int a[n + 1], d[(int)1e5], b[n + 1];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        d[a[i]] = i;
        b[i] = a[i];
       // cout << a[i] << " " << i << " " << d[10] << '\n';
    }

    bool KT[n + 1];
    memset(KT, true, sizeof(KT));
    sort(b + 1, b + n + 1);
    int res = 0;
   // cerr << "PK";
    for(int i = 1; i <= n; i++){
        int cnt = 0, sum = 0, m = 1e5, t = i;
        while(KT[t]){
            m = min(m, a[t]);
            sum += a[t];
            cnt++;
            KT[t] = false;
           // cout << t << " ";
            t = d[b[t]];
           // cout << t << "*" << '\n';
        }

        if (cnt >= 2) res += min(sum + m + b[1] * (cnt + 1), sum + m * (cnt - 2));
        // cout << sum << " " << m << " " << cnt << " " <<  sum + m + b[0] * (cnt + 1) << '\n';
    }
    cout << res << '\n';
}

int main(){
//    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
 //   doc();

    solve();
}



Measured memory_bytes: 3180
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD
#define MAX_N 51

using namespace std;

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

int main() {
  ll n;
  string S[MAX_N];
  cin >> n;
  for (ll i = 0; i < n; i++) {
    cin >> S[i];
  }

  ll A[MAX_N][26];
  for (ll i = 0; i < n; i++) {
    fill(A[i], A[i] + 26, 0);
  }

  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < S[i].size(); j++) {
      A[i][S[i][j] - 'a']++;
    }
  }

  ll a[26];
  fill(a, a + 26, INF);
  for (ll i = 0; i < 26; i++) {
    for (ll j = 0; j < n; j++) {
      a[i] = min(a[i], A[j][i]);
    }
  }

  for (ll i = 0; i < 26; i++) {
    for (ll j = 0; j < a[i]; j++) {
      printf("%c", (int)i + 'a');
    }
  }
  printf("\n");
  return 0;
}


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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	if (S[0] == '7' || S[1] == '7' || S[2] == '7') {
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

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

#define LL long long

const int N = 100100;
const long long mod = 1e9 + 7;

using namespace std;

int a,b,c;

int main()
{
    ios_base::sync_with_stdio(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    cin>>a>>b>>c;
    cout<< min( a * b , c );
}


Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
eg = [[] for _ in range(n + 1)]

for _ in range(m):
    a, b = map(int, input().split())
    eg[a].append(b)
    eg[b].append(a)

ans = 0
for i in range(1, n + 1):
    high = True
    for to in eg[i]:
        if h[i - 1] <= h[to - 1]:
            high = False
    if high:
        ans += 1
print(ans)


Measured memory_bytes: 93936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const ll inf = 1e9+7;
const ll N=100001;
ll n,k,ans=0;

int main(){
	cin>>n>>k;
	if(k==0){
		ans=n*n;
		cout<<ans<<endl;
		return 0;
	}
	FOR(i,k+1,n+1){
		ans+=(i-k)*(n/i);
		if(n-(n/i)*i>=k){
			ans+=n-(n/i)*i-k+1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
#include <queue>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<queue<int> > b(n);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n - 1; ++j) {
            int cur;
            cin >> cur;
            --cur;
            b[i].push(cur);
        }
    }
    queue<int> ma;
    int cnt_f = 0;
    int ans = 0;
    for (int i = 0; i < n; ++i)
        ma.push(i);

    do {
        queue<int> f;
        set<int> del;
        while(!ma.empty()) {
            int cur = ma.front();
            ma.pop();
            if (!b[cur].empty() && !b[b[cur].front()].empty() && cur == b[b[cur].front()].front() && del.find(cur) == del.end()) {
                ++cnt_f;
                f.push(cur);
                f.push(b[cur].front());
                del.insert(cur);
                del.insert(b[cur].front());
            }
        }
        for (auto x : del)
            b[x].pop();
        ++ans;
        ma = f;
    } while(!ma.empty() && cnt_f != n * (n - 1) / 2);
    if (cnt_f == n * (n - 1) / 2)
        cout << ans;
    else
        cout << -1;
    cout << '\n';
    return 0;
}


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

int a[5] = {5,7,5,7,7};
signed main() {
	int n;
	while (cin >> n && n) {
	    vector<int> v(n);
	    rep(i, n) {
	        string s; cin >> s;
	        v[i] = s.size();
	    }
	    rep(i, n) {
	        bool ok = true;
	        int idx = 0;
	        int sum = 0;
	        rep(j, 5) {
	            while (i + idx < n && sum < a[j]) {
	                sum += v[i + idx++];
	              }
	            if (sum > a[j]) {
	                ok = false;
	                break;
	            }
	            sum = 0;
	        }
	        if (ok) {
	            cout << i + 1 << endl;
	            break;
	        }
	    }
    }
}

Measured memory_bytes: 3156
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from itertools import product

s = read().rstrip().decode()
ans = int(s[-1]) * (2 ** (len(s) - 1))
for bit in product(['', '+'], repeat=len(s) - 1):
    memo = 0
    for i, (bf, af) in enumerate(zip(s, s[1:])):
        memo += int(bf)
        if bit[i] == '+':
            ans += memo
            memo = 0
        else:
            memo *= 10
    ans += memo
print(ans)


Measured memory_bytes: 3064
import sys
readline = sys.stdin.readline

def check(s, Edge):
    stack = [s]
    col[s] = False
    res = True
    while stack:
        vn = stack.pop()
        for vf in Edge[vn]:
            if vf in used:
                if col[vn] == col[vf]:
                    res = False
            else:
                col[vf] = not col[vn]
                used.add(vf)
                stack.append(vf)
    return res

N, M = map(int, readline().split())

Edge = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, readline().split())
    a -= 1
    b -= 1
    Edge[a].append(b)
    Edge[b].append(a)


bip = 0
nb = 0
po = 0
used = set()
col = [None]*N
for i in range(N):
    if i in used:
        continue
    used.add(i)
    if not Edge[i]:
        po += 1
        continue
    if check(i, Edge):
        bip += 1
    else:
        nb += 1
print(2*bip**2+2*nb*bip+nb**2+N**2-(N-po)**2)

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n),c(n-1);
  for(int i=0;i<n;i++){
    cin >> a[i];
    a[i]--;
  }
  for(int i=0;i<n;i++){
    cin >> b[i];
  }
  for(int i=0;i<n-1;i++){
    cin >> c[i];
  }
  int sum=0;
  for(int i=0;i<n;i++){
    sum+=b[a[i]];
    if(i>0 && a[i]==a[i-1]+1){
      sum+=c[a[i-1]];
    }
  }
  cout << sum << endl;
}
  


Measured memory_bytes: 256
#include  <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int mx[] = {1,1,0,-1,-1,-1,0,1};
int my[] = {0,1,1,1,-0,-1,-1,-1};
int main(){


  char array[110][110];
  bool check[110][110];
  //int i,j,k ;
  int tate,yoko;
  int answer =0;

  cin >> tate >> yoko;
  rep(i,tate)rep(j,yoko)check[i][j]=true;
  rep(i,tate){
    rep(j,yoko){
      cin>> array[i][j];
      //cout<<"i="<<i<<" j="<<j<<endl;	
      if(array[i][j] =='o' || i == 0)
	{
	  check[i][j] = false;
	  int tempx = j+1;
	  int tempx2 = j-1;
	  if(tempx>=0 && tempx <yoko)
	    check[i][tempx] = false;
	  if(tempx2 >=0 && tempx2 < yoko)
	    check[i][tempx2]= false;
	}
      if(array[i][j] == 'x') {
	check[i][j]=false;
	rep(k,8){
	  int tempx = j+mx[k];
	  int tempy = i+my[k];
	  if(tempx>=0 && tempx <yoko && tempy >=0 && tempy < tate ){
	    check[tempy][tempx] =false;
	    //cout<<tempx<<" "<<tempy<<endl;
	 
	  }

	}

      }
      /* rep(i,tate){
	rep(j,yoko)cout<<check[i][j]<<" ";
	cout<<endl;
	}*/

    }
  }
    rep(i,tate)
      {
      rep(j,yoko)
	  {
	    // cout << check[i][j] << " " ;
	    if(check[i][j])
	      answer++;

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

Measured memory_bytes: 1184
#include<stdio.h>
int main(void){
    unsigned long long int A,B,C,D;
    unsigned long long int g,k,j,r,a,b;
    scanf("%lld %lld %lld %lld",&A,&B,&C,&D);
    g=B/C-(A-1)/C;
    if(C>D){
        a=C;
        b=D;
    }else{
        a=D;
        b=C;
    }
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    r=(D*C)/b;
    k=B/D-(A-1)/D;
    j=B/r-(A-1)/r;
    printf("%lld\n",B-A+1-g-k+j);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
    int n, h[20], count = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &h[i]);
    }
    int max = h[0];
    for(int i = 0; i < n; i++) {
        if(max <= h[i]) {
            count++;
            max = h[i];
        }
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
b = list(map(lambda x:x-1, a))
c = list(map(lambda x:x+1, a))
cnt = [0]*(10**5+2)
for i in a+b+c:
    cnt[i+1] += 1
print(max(cnt))

Measured memory_bytes: 20664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=3000+10;
inline ll quick_pow(ll base,ll n,ll mod) {
	ll ans=1;
	while(n) {
		if(n&1)
			ans=ans*base%mod;
		base=base*base%mod;
		n>>=1;
	}
	return ans;
}
ll c[maxn][maxn];
ll g[maxn][maxn];
int main() {
	ll n,mod;
	scanf("%lld%lld",&n,&mod);
	for(int i=1; i<=n; i++) {
		c[i][0]=1;
		c[i][i]=1;
		for(int j=1; j<i; j++)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	}
	for(int i=0; i<=n; i++) {
		g[i][0]=1;
		for(int j=1; j<=i; j++)
			g[i][j]=(g[i-1][j-1]+g[i-1][j]*(j+1)%mod)%mod;
	}
	ll ans=0;
	for(int i=0; i<=n; i++) {
		ll k=c[n][i];
		if(i&1)
			k=(mod-k)%mod;
		ll kind=quick_pow(2,n-i,mod);
		ll x=quick_pow(2,n-i,mod-1);
		x=quick_pow(2,x,mod);
		ll cnt=0,y=1;
		for(int j=0; j<=i; j++) {
			cnt=(cnt+(g[i][j]*y%mod))%mod;
			y=kind*y%mod;
		}
		ans=(ans+(k*cnt%mod*x%mod))%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
    int n = 0;
    int a = 0;

    std::cin >> n;
    std::vector<int> emp(n);

    for (int i = 0; i < n - 1; i++)
    {
        std::cin >> a;
        emp[a - 1] += 1;
    }
    
    for (int i = 0; i < n; i++)
    {
        std::cout << emp[i] << std::endl;
    }

    return 0;
}

Measured memory_bytes: 4068
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define FORN(i, x, y) for (int i = x; i <= y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define scan1(X) scanf("%d", &X)
#define scan2(X, Y) scanf("%d%d", &X, &Y)
#define scan3(X, Y, Z) scanf("%d%d%d", &X, &Y, &Z)
#define scan4(X, Y, Z, W) scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define scanl1(X) scanf("%lld", &X);
#define scanl2(X, Y) scanf("%lld%lld", &X, &Y)
#define scanl3(X, Y, Z) scanf("%lld%lld%lld", &X, &Y, &Z)
#define scanl4(X, Y, Z, W) scanf("%lld%lld%lld%lld", &X, &Y, &Z, &W)
#define print1(X) printf("%d\n", X);
#define print2(X, Y) printf("%d %d\n", X, Y);
#define print3(X, Y, Z) printf("%d %d %d\n", X, Y, Z);
#define print4(X, Y, Z, W) printf("%d %d %d %d\n", X, Y, Z, W);
#define printl1(X) printf("%lld\n", X);
#define printl2(X, Y) printf("%lld %lld\n", X, Y);
#define printl3(X, Y, Z) printf("%lld %lld %lld\n", X, Y, Z);
#define printl4(X, Y, Z, W) printf("%lld %lld %lld %lld\n", X, Y, Z, W);
#define max3(X, Y, Z) max(X, max(Y, Z))
#define max4(X, Y, Z, W) max(max(X, Y), max(Z, W))
#define min3(X, Y, Z) min(X, min(Y, Z))
#define min4(X, Y, Z, W) min(min(X, Y), min(Z, W))
#define popcount(X) __builtin_popcount(X)
#define all(x) x.begin(), x.end()
#define size(X) (int)X.size()
#define mp make_pair
#define pb push_back
#define fr first
#define sc second
#define lc(x) 2 * x
#define rc(x) 2 * x + 1
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pldld;
const long long l_inf = numeric_limits<long long>::max();
const long long l_ninf = numeric_limits<long long>::min();
const int inf = numeric_limits<int>::max();
const int ninf = numeric_limits<int>::min();
const double pi = 1.00 * acos(-1.00);
const double eps = 1e-8;
void cio(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return (a * (b / gcd(a, b))); }
int sq( int x ) {return x * x;}
////////////////////////////////////////////////////////////////////Header
int main () {
    cio();
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    cout<<max4(a*c, a*d, b*c, b*d)<<endl;
}

Measured memory_bytes: 3648