akhauriyash/Code-Regression huggingface dataset:
import math
N = int(input())
def func(a,b):
    return max(len(str(a)),len(str(b)))
ans = len(str(N))
for i in range(2,math.floor(pow(N,1/2)) + 1):
    if N % i == 0:
        div1 = i
        div2 = N // i
        if func(div1,div2) < ans:
            ans = func(div1,div2)
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>

using namespace std;

typedef long long int ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
/* -- template -- */
const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long 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;
    }
    // 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;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

mint cnt[100001];

int main() {
    ll N, K; cin >> N >> K;
    for(ll i = K;i >= 1;--i) {
        mint p = K / i;
        cnt[i] = p.pow(N);
        for(ll j = 2 * i; j <= K;j += i) {
            cnt[i] = cnt[i] - cnt[j];
        }
    }
    mint ans = 0;
    rep(i, K){
        ans += (mint(i) + 1) * cnt[i + 1];
    }
    cout << ans << endl;
}


Measured memory_bytes: 4412
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello
{
    public static void Main()
    {
        //AB上にある本の冊数、および所要時間を保持する
        var HWK = Console.ReadLine().Split().Select(e => int.Parse(e)).ToArray();
        var aCnt = HWK[0];
        var bCnt = HWK[1];
        var k = HWK[2];
        var aArray = Console.ReadLine().Split().Select(e => long.Parse(e)).ToArray();
        var bArray = Console.ReadLine().Split().Select(e => long.Parse(e)).ToArray();
        //AB上の本にかかる所要時間を累積和で保存しておく
        var sumA = new long[aCnt + 1];
        var sumB = new long[bCnt + 1];
        //0冊読んだ場合からN冊読んだ場合までの累積和配列を作成
        for (var i = 1; i <= aCnt; i++)
        {
            sumA[i] = sumA[i - 1] + aArray[i - 1];
        }
        for (var i = 1; i <= bCnt; i++)
        {
            sumB[i] = sumB[i - 1] + bArray[i - 1];
        }
        var ans = 0;
        var j = bCnt;
        for (var i = 0; i <= aCnt; i++)
        {
            if (sumA[i] > k) continue;
            while (sumB[j] > k - sumA[i])
            {
                j--;
            }
            ans = Math.Max(ans, i + j);
        }
        //for (var i = aCnt; i >= 0; i--)
        //{
        //    if (k < sumA[i]) continue;
        //    if (m == sumB.Length) continue;
        //    while (sumB[m] <= k - sumA[i])
        //    {
        //        m++;
        //        if (m == sumB.Length) break;
        //    }
        //    ans = Math.Max(ans, i + m - 1);
        //}
        Console.WriteLine(ans);
    }
}



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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int h,w,d,q,a[303][303];
vi r[100005];
pii v[100005];
void solve(){
    cin>>h>>w>>d;
    rep(i,1,h+1){
        rep(j,1,w+1){
            cin>>a[i][j];
            v[a[i][j]]={i,j};
        }
    }
    int s=h*w/d;
    rep(i,1,d+1){
        r[i].resize(s+1);
        int cur=i,cnt=1;
        while(cur+d<=h*w){
            int x1=v[cur].x,y1=v[cur].y;
            int x2=v[cur+d].x,y2=v[cur+d].y;
            r[i][cnt]=r[i][cnt-1]+abs(x1-x2)+abs(y1-y2);
            cnt++;
            cur+=d;
        }
    }
    cin>>q;
    while(q--){
        int L,R;
        cin>>L>>R;
        int H=L%d;
        if(!H) H+=d;
        cout<<r[H][(R-H)/d]-r[H][(L-H)/d]<<endl;
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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


int main() {
    int N;
    cin >> N;

    string temp; getline(cin, temp);

    for (int n = 0; n != N; ++n) {
        int bases[3] = {0};
        string event;
        int runs = 0, outs = 0;
        
        while (cin >> event) {
            if (event == "HIT") {
                if (bases[2] == 1) {
                    runs++;
                    bases[2] == 0;
                }
                if (bases[1] == 1) {
                    bases[1] = 0;
                    bases[2] = 1;
                }
                if (bases[0] == 1) {
                    bases[0] = 0;
                    bases[1] = 1;
                }
                bases[0] = 1;
            }
            if (event == "HOMERUN") {
                for (int i = 0; i != 3; ++i) {
                    if (bases[i] == 1) {
                        runs++;
                        bases[i] = 0;
                    }
                }
                runs++;
            }
            if (event == "OUT") {
                outs++;
                if (outs == 3) {
                    break;
                }
            }
        }
        cout << runs << endl;
    }
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;
li m;
li parent[100100];
vector<li> edges[100100];
vector<li> inv_edges[100100];

li degree[100100];

vector<li> order;

int main() {
    cin >> n >> m;
    rin{
        parent[i] = -1;
    }
    rep(i, n + m - 1) {
        li a, b;
        cin >> a >> b;
        a--;
        b--;
        edges[a].pb(b);
        inv_edges[b].pb(a);
        degree[b]++;
    }
    queue<li> q;
    rin{
        if (degree[i] == 0) {
            q.push(i);
            parent[i] = -1;
        }
    }
    order.reserve(n);
    while (!q.empty()) {
        li now = q.front();
        order.pb(now);
        q.pop();
        for (auto && next : edges[now]) {
            degree[next]--;
            if (degree[next] == 0) {
                q.push(next);
                parent[next] = now;
            }
        }
    }
    rin{
        cout << parent[i] + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 14080
n, q = gets.strip.split.map(&:to_i)
s = gets.strip
qs = q.times.map { gets.strip.split.map(&:to_i) }

counts = [0]
current = 0

(1..(n - 1)).each do |i|
  if s[i - 1] == 'A' && s[i] == 'C'
    current += 1
  end

  counts << current
end

qs.each do |l, r|
  puts(counts[r - 1] - counts[l - 1])
end


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

int main()
{
    double a, b, x;
    cin >> a >> b >> x;
    double s = x / a;
    double rad;
    if(s >= a * b / 2) {
        double h = (a * b - s) * 2 / a;
        rad = atan2(h, a);
    }
    else {
        double w = s * 2 / b;
        rad = atan2(b, w);
    }
    double PI = acos(-1);
    double deg = rad /(2 * PI) * 360;
    cout << setprecision(15) << deg << endl;
    return 0;
}


Measured memory_bytes: 4124
use std;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn d_chat_in_a_circle() {
    let n = read::<i64>();
    let mut a = read_vec::<i64>();
    a.sort();
    let ans: i64 = (1..n).map(|k| a[((n - k / 2) as usize) - 1]).sum();

    println!("{}", ans);
}

fn main() {
    d_chat_in_a_circle();
}


Measured memory_bytes: 6592
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<cstdlib>
#include<vector>
#include<set>
#include<deque>
#include<queue>
#include<math.h>
#include<chrono>
#include<list>
#include<random>
#include<bitset>
#include<assert.h>
#include<ctime>
#include<cstdio>
#include <unordered_map>

using namespace std;

#define fast_input() {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); }
//#define ll long long
using ll = long long;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/*
MIKUNO - 15/02/1999
*/
const int N = 1e5 + 5;
//	priority_queue <ll, vector<ll>, greater<ll> > q;
int n, m, k, cnt, rs, q;

int main()
{
	fast_input();
	int n, k;
	cin >> n;
	cin >> k;
	vector<int>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<int>dp(n, 1e9);
	dp[0] = 0;

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n,d,a;cin>>n>>d;
    vector<vector<int>>v(n);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<d;j++)
        {
            cin>>a;
            v[i].push_back(a);
        }
    }
    int ans=0;
    float sum=0;
    for(int k=0;k<n;k++)
    for(int i=k+1;i<n;i++)
    {
        sum=0;
        for(int j=0;j<d;j++)
        {
                sum+=pow(v[i][j]-v[k][j],2);
        }
        sum=sqrt(sum);
        if(sum==floor(sum))ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include<iostream>
#include <numeric>
// #include<string>
#include<vector>
#include <algorithm>
#include <cmath>
// #include <functional>

using namespace std;

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

    cout << c << " " << a << " " << b;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>

#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORN(i, a, b) for (int i = a; i <= b; i++)
#define P(s) cout << s << endl
#define PC(condition, _true, _false) if (condition) _true; else _false;
#define toInt(_char) _char - '0'

using namespace std;
//
// Created by karayuu on 2019-3-28.
//

int main() {
    int r = 0, c = 0;
    cin >> r >> c;

    int t[101][101];
    FOR(i, 0, r) {
        FOR(j, 0, c) {
            cin >> t[i][j];
        }
    }

    int sa[101];
    FOR(i, 0, r) {
        int sum = 0;
        FOR(j, 0, c) {
            sum += t[i][j];
        }
        sa[i] = sum;
    }

    int sb[101];
    FOR(i, 0, c) {
        int sum = 0;
        FOR(j, 0, r) {
            sum += t[j][i];
        }
        sb[i] = sum;
    }

    FOR(i, 0, r) {
        FOR(j, 0, c) {
            if (j != 0) {
                cout << " ";
            }
            cout << t[i][j];
        }
        cout << " ";
        cout << sa[i] << endl;
    }
    int s = 0;
    FOR(i, 0, c) {
        if (i != 0) {
            cout << " ";
        }
        cout << sb[i];
        s += sb[i];
    }
    cout << " ";
    cout << s;
    cout << endl;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
int main()
{

map<long long int,long long int>m;
vector<long long int>v;
long long int a,b,c,d,r=0,i,j=0,k,l;
cin>>a;
for(i=1;i<=a;i++)
{
 cin>>b;
        m[b]++;
        if(m[b]==1)v.push_back(b);
}
    sort(v.begin(),v.end());
    //cout<<v.size()<<endl;
for(i=v.size()-1;i>=0;i--)
{

  if(m[v[i]]>=2)
  {
   r++;
  if(r==1)k=v[i];
            if(r==1&&m[v[i]]>=4)
            {
            j=1;c=v[i];
        }
  if(r==2)l=v[i];m[v[i]]=0;
  }
}
  if(j==1)
   {
   cout<<c*c<<endl;
   }
    else
    {
    if(r>1)cout<<l*k<<endl;
else cout<<"0\n";}
}

Measured memory_bytes: 7284
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

int h,w;
typedef pair<int, int> P;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};

bool check(int i, int j) {
    if (i < 0 || i >= h || j < 0 || j >= w) return false;
    else return true;
}

int main(int argc, char const *argv[]) {
    cin >> h >> w;
    vector<vector<char>> c(h, vector<char>(w));
    queue<P> q;
    REP(i,h) {
        REP(j,w) {
            cin >> c[i][j];
            if (c[i][j] == '#') q.push({i, j});
        }
    }
    vector<vector<int>> x(h, vector<int>(w));
    while (!q.empty()) {
        P p = q.front(); q.pop();
        for (int i = 0; i < 4; ++i) {
            int Y = p.first+dy[i];
            int X = p.second+dx[i];
            if (check(Y, X)) {
                if (c[Y][X] == '#') continue;
                q.push({Y,X});
                c[Y][X] = '#';
                x[Y][X] = x[p.first][p.second]+1;
            }
        }
    }
    int ans = 0;
    REP(i,h) {
        REP(j,w) {
            ans = max(ans, x[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13456
import sys
from math import sqrt

input = sys.stdin.readline


def I():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    _ = I()
    a_list = MI()

    min = inf
    for a in a_list:
        c = 0
        while a % 2 == 0 and c < min:
            c += 1
            a /= 2

        if min > c:
            min = c

    print(min)
    pass


if __name__ == "__main__":
    main()


Measured memory_bytes: 38512
import math

N = int(input())
for h in range(math.ceil(N/4),3500+1):
    buff = 4/N-1/h
    if buff==0:
        continue
    for n in range(math.ceil(1/buff),3500+1):
        #print(h,n)
        if 4*h*n-N*h-n*N!=0:
            if (N*h*n)%(4*h*n-N*h-n*N) ==0:
                print(h,n,int(N*h*n/(4*h*n-N*h-n*N)))
                exit()
print("not found")

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

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

using ll = long long;
constexpr ll INF = 10000000000;

using namespace std;

//fixed << setprecision(10)

/////////////////////////////////////////////////////////////////////////////////////////////////////////

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

	int x = b - a;
	if (x % 2 == 0)cout << "Alice" << "\n";
	else cout << "Borys" << endl;
	
}

Measured memory_bytes: 256
N,M = map(int,input().split())
A = []
MOD = 1000000007
for _ in range(M):
  a = int(input())
  A.append(a)
DP = [1]*(N+1)
for i in A:
  DP[i] = 0
for i in range(2,N+1):
  DP[i] = (DP[i-1]+DP[i-2])%MOD*DP[i]
print(DP[-1])

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint
{
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        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;
    }

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

// 2のN乗を求める関数
mint f(int n)
{
    if (n == 0)
    {
        return 1;
    }

    mint x = f(n / 2);
    x *= x;
    if (n % 2 == 1)
    {
        x *= 2;
    }
    return x;
}

mint choose(int n, int a)
{
    mint x = 1, y = 1;
    for (size_t i = 0; i < a; i++)
    {
        x *= n - i;
        y *= i + 1;
    }
    return x / y;
}

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

    mint ans = f(n);
    ans -= 1;
    ans -= choose(n, a);
    ans -= choose(n, b);

    cout << ans.x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(ll, N, M);
  print(max(N - 2, N % 2) * max(M - 2, M % 2));
}


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

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RREP(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define ALL(r) (r).begin(), (r).end()

int64_t f(int64_t n) {
    return (n % 2 == 0) ? n / 2 : 3 * n + 1;
}

void Main() {
    int32_t n, m, x, a;
    cin >> n >> m >> x;
    vector<int32_t> b(n+1, 0);
    rep(i, m) {
        cin >> a;
        b[a] = 1;
    }
    REP(i, x, n) {
        b[i+1] += b[i];
    }
    RREP(i, x, 1) {
        b[i-1] += b[i];
    }
    cout << min(b[0], b[n]) << endl;
}

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


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
int x, y, a, b, c;
ll p[N], q[N], r[N];
ll sump[N], sumq[N], sumr[N];
int main()
{
	scanf("%d%d%d%d%d", &x, &y, &a, &b, &c);
	for (int i = 1; i <= a; i++) scanf("%lld", &p[i]);
	for (int i = 1; i <= b; i++) scanf("%lld", &q[i]);
	for (int i = 1; i <= c; i++) scanf("%lld", &r[i]);
	sort(p + 1, p + a + 1);
	sort(q + 1, q + b + 1);
	sort(r + 1, r + c + 1);
	for (int i = a; i >= 1; i--) sump[i] = sump[i + 1] + p[i];
	for (int i = b; i >= 1; i--) sumq[i] = sumq[i + 1] + q[i];
	for (int i = c; i >= 1; i--) sumr[i] = sumr[i + 1] + r[i];
	ll ma = 0, pos_p = a - x + 1, pos_q = b - y + 1;
	ma = sump[pos_p] + sumq[pos_q];
	int pos_r = c;
	while (pos_r > 0)
	{
		if ((pos_p <= a && p[pos_p] < r[pos_r]) && (pos_q <= b && q[pos_q] < r[pos_r]))
		{
			if (r[pos_r] - p[pos_p] > r[pos_r] - q[pos_q])
			{
				ma += r[pos_r] - p[pos_p];
				pos_p++;
				pos_r--;
			}
			else
			{
				ma += r[pos_r] - q[pos_q];
				pos_q++;
				pos_r--;
			}
		}
		else if (pos_p <= a && p[pos_p] < r[pos_r])
		{
			ma += r[pos_r] - p[pos_p];
			pos_p++;
			pos_r--;
		}
		else if (pos_q <= b && q[pos_q] < r[pos_r])
		{
			ma += r[pos_r] - q[pos_q];
			pos_q++;
			pos_r--;
		}
		else break;
	}
	cout << ma << endl;
}

Measured memory_bytes: 4992
N = int(input())
*A, = map(int, input().split())
ok = 1
for i in range(N-2, -1, -1):
    if A[i] > A[i+1]:
        if A[i] == A[i+1]+1:
            A[i] -= 1
        else:
            ok = 0
print("Yes" if ok else "No")

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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define all(c) begin(c),end(c)

template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


auto solve() {
    int N, W;
    cin >> N >> W;
    vi w(N), v(N);
    REP(i, N) cin >> w[i] >> v[i];

    vector<vll> dp(N + 1, vll(W + 1, 0));

    REP(i, N) {
        REP(j, W+1) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);

            int weight = j + w[i];
            if (weight <= W) {
                dp[i + 1][weight] = max(dp[i + 1][weight], dp[i][j] + v[i]);
            }
        }
    }

    return *max_element(all(dp[N]));
}


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

    cout << solve() << endl;
//    solve();

    return 0;
}


Measured memory_bytes: 80256
N=int(input())
work=[0]*N
for i in range(N):
  work[i]=list(map(int,input().split()))
work=sorted(work,key=lambda x: x[1])
time=0
for i in work:
  time+=i[0]
  if time>i[1]:
    print('No')
    exit()
print('Yes')

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

int main() {
  int n;
  cin >> n;
  
  vector<int> v(n);
  for(int i=0; i<n; i++) cin >> v[i];
  
  int ans = 0;
  for(int i=0; i<n; i++) {
    while(v[i]%2==0) {
      v[i] /= 2;
      ans++;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
struct edge
{
  ll to;
  ll cost;
  edge() {}
  edge(ll to, ll cost) : to(to), cost(cost){};
};
int main()
{

ll n;
cin >> n;
vector<vector<edge>> g(n);
rep(i, n-1)
{
  ll a, b;
  cin >> a >> b ;
  g[a - 1].emplace_back(b - 1, i);
  g[b - 1].emplace_back(a - 1, i); //無向辺
}
ll m ;
cin >> m ;
vector<ll> v;
rep(i,m){
  ll a, b;
  cin >> a >> b;
  a--;b--;
  vector<pair<ll,ll>> par(n);
  vector<bool> see(n);
  queue<ll> q;
  par[a]={-1,-1};
  see[a]=1;
  q.push(a);
  while(!q.empty()){
    auto p=q.front();
    if(p==b){
      ll vv=0;
      while(par[p].first!=-1){
        vv+=(1LL<<par[p].second);
        p=par[p].first;
      }
      v.push_back(vv);
      break;
    }
    see[p]=1;
    q.pop();
    for(auto r:g[p]){
      if(see[r.to]!=0)continue;
      par[r.to]={p,r.cost};
      q.push(r.to);
    }
  }
}
rep(i,1LL<<m){
  ll k=__builtin_popcountll(i);
  ll a=0;
  rep(j,m){
    if(i>>j & 1LL){
      a|=v[j];
    }
  }
  if(k%2)ans-=1LL<<(n-1-__builtin_popcountll(a));
  else ans+=1LL<<(n-1-__builtin_popcountll(a));
}
cout << ans << endl;
return 0;
}

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

int main(){
  int n;cin>>n;
  int k;cin>>k;
  bool flag=0;

  while(n>0){

   n-=k; 
  if(n<=0){
  if(n==0)flag=0;
  else flag=1;
}
}
if(flag==0)cout<<0;
else cout<<1;

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
#define v(T) vector<T>
#define vv(T) vector<v(T)>
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
template<class T>bool chmax(T &a, const T &b){
    if (a < b) {a = b; return true;}
    return false;
}
template<class T>bool chmin(T &a, const T &b){
    if (a > b) {a = b; return true;}
    return false;
}

typedef pair<ll, ll> LP;
struct L{
    ll x;
    ll h;
    L(ll x, ll h): x(x), h(h){};
    bool operator<(const L &a){
        return x < a.x;
    }
    // bool operator>=(const L &a){
    //     return x >= a.x;
    // }
};
const ll inf = 1e18;
int main()
{
    int n;
    ll d, a;
    cin >> n >> d >> a;
    vll s(n+1, 0);
    v(L) p;
    rep(i, n){
        int x, h;
        cin >> x >> h;
        p.emplace_back(x, h);
    }    
    sort(all(p));
    ll ans = 0;
    rep(i, n){
        p[i].h -= s[i];
        if (p[i].h > 0){
            auto pos = lower_bound(all(p), L(p[i].x+2*d+1, inf));
            int r = distance(p.begin(), pos);
            r = min(r, n);
            ll num = (p[i].h+a-1)/a;
            s[i] += a*num;
            s[r] -= a*num;
            ans += num;
        }
        s[i+1] += s[i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 8960
#include<stdio.h>
#include<algorithm>
using namespace std;
int d[600001];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		int p;scanf("%d",&p);
		d[p]=1;
	}
	int last=0;
	for(int i=0;i<=600000;i++){
		if(d[i])last=i;
		d[i]=last;
	}
	for(int i=0;i<b;i++){
		int c;
		scanf("%d",&c);
		int ret=0;
		for(int j=c-1;j<=600000;j+=c)ret=max(ret,d[j]-j+c-1);
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 3372
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main()
        {
            var line = Console.ReadLine();
            int n = int.Parse(line.Split()[0]);
            int a = int.Parse(line.Split()[1]);
            int b = int.Parse(line.Split()[2]);
            int ans = 0;
            for(int i = 1; i <= n; i++)
            {
                int digit = 0;
                int ni = i;
                while (ni > 0)
                {
                    digit += ni % 10;
                    ni /= 10;
                }
                if (a <= digit && digit <= b) ans+=i;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    int n,k,q;
    cin>>n>>k>>q;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=2e9;
    for(int i=0;i<n;i++){
        vector<int> vv;
        int mn=a[i];
        for(int j=0;j<n;j++){
            vector<int> v;
            while(j<n&&mn<=a[j]){
                v.push_back(a[j]);
                j++;
            }
            if(v.size()>=k){
                sort(v.begin(),v.end());
                for(int l=0;l<(int)v.size()+1-k;l++){
                    vv.push_back(v[l]);
                }
            }
        }
        if(vv.size()>=q){
            sort(vv.begin(),vv.end());
            ans=min(ans,vv[q-1]-mn);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>

int main(void){
    int n,k;
    scanf("%d %d",&n,&k);
    int w[n];
    for(int i=0;i<n;i++){
        scanf("%d",&w[i]);
    }
    
    int P=0;
    int sum=0;
    int count=0;
        for(int j=0;j<n;j++){
        sum=sum+w[j];
    }
    P=sum/k;
    int lift=0;
    int l=0;
    while(1){
    	for(l=0;l<n;l++){
    		
    		lift+=w[l];
    		if(P<lift){
    			lift=0;
    			l--;
    			count++;
    			if(count>=k){
    				count=0;
    				P++;
    				l++;
    				break;
				}
			}
		}
		if(l==n) break;
	}
  printf("%d\n",P);


    return 0;
}



Measured memory_bytes: 2168
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

const double PI = 3.1415926535897932384626433832795;

int main() {
  char x, y;
  cin >> x >> y;
  string ans;
  if(x < y) {
    ans = "<";
  }
  else if(x > y) {
    ans = ">";
  }
  else {
    ans = "=";
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

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

    int ma = f/(a*100);
    int mb = f/(b*100);


    double ans = 0;
    int mizu = 0;
    int sato = 0;
    for(int i=0; i<=ma; i++){
        for(int j=0; j<=mb; j++){
            if((i*a+j*b)*100>f) continue;

            for(int k=0; f>=((i*a+j*b)*100+k*c); k++){
                for(int l=0; f>=(((i*a+j*b)*100+k*c+l*d)); l++){
                    if(((i*a+j*b)*e) >= (k*c+l*d)){
                        #if 1
                        int tmp = (k*c + l*d);
                        if(100*(i*a+j*b)+tmp==0){
                            continue;
                        }
                        double tmp2 = (double)(tmp*100)/(double)(100*(i*a+j*b)+tmp);
                        if(tmp2>=ans){
                            ans =  tmp2; 
                            mizu = 100*(i*a+j*b)+tmp;
                            sato = tmp;
                        }
                        #endif
                    }
                }
            }
        }
    }

    cout << mizu << " " << sato << endl; 
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
			
		}
	public static void Ans() {

			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];

			//答えの出力
			var ans = N == 0 ? 1 : 0;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


Measured memory_bytes: 27940
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;



/*
Union Find Tree with size information
*/
class UnionFind
{
private:
  vector<ll> parent;
  vector<ll> size;

public:
  UnionFind(ll n);
  ll find(ll x);
  ll get_size(ll x);
  void unite(ll x, ll y);
};

UnionFind::UnionFind(ll n){
  parent = vector<ll>(n);
  for (ll i=0;i<n;i++){ parent[i]=i; }
  size = vector<ll>(n, 1);
}

// Find root node of x
ll UnionFind::find(ll x){
  if (parent[x]==x) return x;
  return parent[x] = find(parent[x]);
}


// Get size of tree including x
ll UnionFind::get_size(ll x){
  return size[find(x)];
}

// Unite trees which includes x and y
void UnionFind::unite(ll x, ll y){
  ll rx = find(x);
  ll ry = find(y);
  if (rx==ry) return;
  if (size[rx] < size[ry]) swap(rx, ry);
  size[rx] += size[ry];
  parent[ry] = rx;
  return;
}


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

  ll N, K, L;
  cin >> N >> K >> L;

  UnionFind road_uf(N);
  REP(i,K){
    ll p, q;
    cin >> p >> q;
    road_uf.unite(p-1, q-1);
  }

  UnionFind train_uf(N);
  REP(i,L){
    ll r, s;
    cin >> r >> s;
    train_uf.unite(r-1, s-1);
  }

  vector<P> root_pair(N);
  map<P,ll> count;
  REP(i,N){
    root_pair[i] = P(road_uf.find(i), train_uf.find(i));
    count[root_pair[i]] ++;
  }

  REP(i,N){
    if (i<N-1){
      cout << count[root_pair[i]] << " ";
    } else {
      cout << count[root_pair[i]] << "\n";
    }
  }

  return 0;
}


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

int main(){
  string S;
  cin >> S;
  int N = S.size();
  
  int64_t ans = 0;
  
  for (int tmp = 0; tmp < (1 << N-1); tmp++) {
    bitset<10> s(tmp);
    int a = 0;
    for (int i = 0; i < N-1; i++){
      if(s.test(i)){
        string sum = S.substr(a, i + 1 - a);
        ans += stoll(sum);
        a = i + 1;
      }
    }
    string sum = S.substr(a);
    ans += stoll(sum);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#define ll long long
using namespace std;
int main() {
    ll h, n;
    cin >> h >> n;
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        h -= a;
    }
    if (h <= 0) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
#define FOR(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	char c;
	for(;scanf("%c",&c)!=EOF;){
		printf("%c",('a'<=c&&c<='z')?c^32:c);
	}
	return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
    int A, B;
    cin >> A >> B;
    int ans = -1;
    for (int i = 1; i < 2000; i++) {
        int e = floor(i * 0.08);
        int t = floor(i * 0.10);
        if (e == A && t == B) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative

selectionSort (x:[]) = (0, [x])
selectionSort (x:xs) =
    let
        (s, selected) = select x xs
        (c, sorted)   = selectionSort selected
        c'            = if x /= s then c+1 else c
    in
        (c', s:sorted)

select :: Int -> [Int] -> (Int, [Int])
select n nums =
    let
        m = minimum nums
    in
        if m < n
           then (m, swap n m nums)
           else (n, nums)
    where
        swap :: Int -> Int -> [Int] -> [Int]
        swap _ _ []   = []
        swap n m (x:xs)
          | m == x    = n:xs
          | otherwise = x:(swap n m xs)

main :: IO ()
main = do
    getLine
    nums <- map read . words <$> getLine :: IO [Int]
    let (count, sorted) = selectionSort nums
    putStrLn $ unwords (show <$> sorted)
    print count



Measured memory_bytes: 4144
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<complex>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef pair<int,int> pa;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int n,cnt[666],a[666],b[666];
char s[55];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	if (n<26){
		FOR(i,1,n) putchar(s[i]),++cnt[s[i]];
		FOR(i,'a','z')
			if (!cnt[i]){putchar(i);return 0;}
	}
	FOR(i,1,n) a[i]=b[i]=s[i]-'a'+1;
	if (!next_permutation(a+1,a+n+1)) return puts("-1"),0;
	FOR(i,1,n){
		putchar(a[i]+'a'-1);
		if (a[i]!=b[i]) break;
	}
	return 0;
}


Measured memory_bytes: 256
#python3
around = [(-1, -1), (-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1)]

def main():
    h, w = map(int, input().split())
    a = [input() for _ in range(h)]
    field = [list(a[i]) for i in range(h)]

    for si in range(h):
        for sj in range(w):
            if field[si][sj] == '#':
                continue 
            cnt = 0
            for di, dj in around:
                i = si + di
                j = sj + dj  

                if (i < 0) | (i >= h) | (j < 0) | (j >= w) :
                    continue
                if field[i][j] == '.':
                    continue
                if field[i][j] == '#':
                    cnt += 1
            
            field[si][sj] = str(cnt)

    for i in field:
        print(''.join(i))  
     
main()



Measured memory_bytes: 3188
s=str(input())
n=len(s)
ans=0
for i in range(int((n-1)/2)):
  if s[i]!=s[n-1-i]:
    ans+=1
    #print("3",i)
nn=int((n-1)/2)
if nn//2==0:
  nna=int(nn/2)
else:
  nna=int((nn-1)/2)
for i in range(nna):
  if s[i]!=s[nn-1-i]:
    ans+=1
    #print("1",i)
nnn=int((n+3)/2)
nnnn=n-nnn+1
if nnnn//2==0:
  nnb=int(nnnn/2)
else:
  nnb=int((nnnn-1)/2)
for i in range(nnnn):
  if s[nnn-1+i]!=s[n-1-i]:
    ans+=1
    #print(nnn-1-i,n-1-i)
if ans==0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,t) for(int i = (s); i < (t); i++)

int N, K;

int main()
{
    scanf("%d %d", &N, &K);
    printf("%d\n", (N%K==0)?0:1);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sf(xx) scanf("%lld",&xx)
#define fast()              ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define input()             freopen("G:/daily practise/in0.txt","r",stdin)
#define output()            freopen("G:/daily practise/out0.txt","w",stdout)
#define maxn 1000001
#define ll long long
int main() {
	fast();
	ll x,n,sum=0;
	cin>>n;
	vector<ll> v;
	for (int i = 0; i < n; ++i)
	{
		cin>>x;
		v.push_back(x);
		sum^=x;
	}
	cout<<(sum^v[0]);
	for (int i = 1; i < n; ++i)
	{
		cout<<" "<<(sum^v[i]);
	}
	cout<<endl;
}

Measured memory_bytes: 5256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  rep(i, N) cin >> L[i];
  sort(L.begin(), L.end());
  ll ans = 0;
  rep(i, N) {
    rep(j, i) {
      int k = (L.begin()+j) - lower_bound(L.begin(), L.begin()+j, L[i]-L[j]+1);
      // cout << L[i] << L[j] << k << endl;
      ans += k;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

int main(int argc, char const *argv[])
{

    int d, n;
    cin >> d >> n;
    if (n == 100)
    {
        n = 101;
    }
    cout << (int)pow(100, d) * n << endl;
    return 0;
}


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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] strs = br.readLine().split(" ");
    int age = Integer.parseInt(strs[0]);
    int money = Integer.parseInt(strs[1]);
    if (age < 13) {
      if (age < 6) {
        System.out.println(0);
      } else {
        System.out.println(money / 2);
      }
    } else {
      System.out.println(money);
    }
  }
}

Measured memory_bytes: 21076
import sys
from functools import lru_cache

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def score(x, counter, N):
    ans = 0
    for i in range(40):
        if x & (1 << i):
            ans += (N - counter[i]) * (1 << i)
        else:
            ans += counter[i] * (1 << i)
    return ans


def main():
    N, K, *A = map(int, read().split())

    counter = [0] * 40
    for a in A:
        for i in range(40):
            if a & (1 << i):
                counter[i] += 1

    B = [0] * 40
    for i in range(39):
        if counter[i] < N - counter[i]:
            B[i + 1] = B[i] + (1 << i)
        else:
            B[i + 1] = B[i]

    C = [0] * 40
    for i in range(39, 0, -1):
        if K & (1 << i):
            C[i - 1] = C[i] + (1 << i)
        else:
            C[i - 1] = C[i]

    ans = score(K, counter, N)

    for i in range(40):
        if K & (1 << i):
            x = B[i] + C[i]
            res = score(x, counter, N)
            if ans < res:
                ans = res

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 20772
def main():
    h, w = map(int, input().split())
    a = [list(map(lambda aa: aa % 2 == 0, map(int, input().split())))
         for _ in range(h)]

    right = [0] * h
    moves = []
    # move left to right
    for i, row in enumerate(a):
        isCarrying = False
        for j in range(w-1):
            if isCarrying ^ row[j]:
                isCarrying = False
            else:
                isCarrying = True
                moves.append((i+1, j+1, i+1, j+2))
            right[i] = isCarrying ^ row[w-1]
    # move up to down
    isCarrying = False
    for i in range(h-1):
        if isCarrying ^ right[i]:
            isCarrying = False
        else:
            isCarrying = True
            moves.append((i+1, w, i+2, w))

    print(len(moves))
    for m in moves:
        print(*m)


main()


Measured memory_bytes: 26652
def main():
    n, m = [int(e) for e in input().split()]
    A = [int(e) for e in input().split()]
    BC = [[int(e) for e in input().split()] for i in range(m)]

    A.sort()
    BC.sort(key=lambda x: x[1], reverse=True)

    bci = 0
    for i in range(n):
        c = BC[bci][1]
        if A[i] < c:
            A[i] = c
        else:
            break

        BC[bci][0] -= 1
        if BC[bci][0] == 0:
            bci += 1

        if bci == m:
            break

    print(sum(A))

if __name__ == "__main__":
    main()


Measured memory_bytes: 81772
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

template <typename T>
std::vector<int> sort_indexes(const std::vector<T> &v) {
	std::vector<int> idx(v.size());
	std::iota(idx.begin(), idx.end(), 0);
	std::sort(idx.begin(), idx.end(), [&v](int i1, int i2) {return v[i1] < v[i2];});
	return idx;
}


int main() {
	int d;
	std::cin >> d;
	int N=26;
	std::vector<lnt> c(N);
	std::vector<std::vector<lnt> > v(d,std::vector<lnt>(N));
	rep(i,N) std::cin >> c[i];
	rep(i,d) {
		rep(j,N) {
			std::cin >> v[i][j];
		}
	}
	std::vector<int> last(N,-1);
	rep(i,d) {
		std::vector<int> idx(N);
		std::iota(idx.begin(), idx.end(), 0);
		double X=1; double Y=5;
		auto f = [&](int ix) -> double {
			return c[ix]*(i-last[ix]+X)+v[i][ix]/Y;
		};
		std::sort(idx.begin(), idx.end(), [&](int i1, int i2) {return f(i1) > f(i2) ;});
		last[idx[0]]=i;
		print(idx[0]+1);
	}
	/*
	lnt sum=0;
	std::vector<int> last(N,-1);
	rep(i,d) {
		int t;
		std::cin >> t;
		t--;
		sum+=v[i][t];
		last[t]=i;
		rep(j,N) sum-=(i-last[j])*c[j];
		print(sum);
	}
	*/
}


Measured memory_bytes: 3752