akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18
#define MAX_NUM 13000

int A[80][80], B[80][80];
bool dp[80][80][MAX_NUM];

int main() {
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++) cin >> A[i][j];
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++) cin >> B[i][j];

    dp[0][0][abs(A[0][0] - B[0][0])] = true;
    for (int i = 1; i < H; i++) {
        int k = abs(A[i][0] - B[i][0]);
        for (int x = 0; x < MAX_NUM - k; x++)
            dp[i][0][x] = dp[i - 1][0][abs(x - k)] | dp[i - 1][0][x + k];
    }
    for (int j = 1; j < W; j++) {
        int k = abs(A[0][j] - B[0][j]);
        for (int x = 0; x < MAX_NUM - k; x++)
            dp[0][j][x] = dp[0][j - 1][abs(x - k)] | dp[0][j - 1][x + k];
    }
    for (int i = 1; i < H; i++) {
        for (int j = 1; j < W; j++) {
            int k = abs(A[i][j] - B[i][j]);
            for (int x = 0; x < MAX_NUM - k; x++) {
                dp[i][j][x] |= dp[i - 1][j][abs(x - k)] | dp[i - 1][j][x + k];
                dp[i][j][x] |= dp[i][j - 1][abs(x - k)] | dp[i][j - 1][x + k];
            }
        }
    }
    for (int x = 0; x < MAX_NUM; x++)
        if (dp[H - 1][W - 1][x]) {
            cout << x << endl;
            return 0;
        }
    return 0;
}

Measured memory_bytes: 81536
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

a, b, c, k = nm()
ans = min(a, k) - max(k - a- b, 0)
print(ans)


Measured memory_bytes: 9060
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 998244353
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, string> PS;

template <class T>
struct BIT {
  vector<T> x;
  BIT(int n) : x(n, 0) {
    // initialize
  }

  T sum(int i, int j) {
    if (i == 0) {
      T S = 0;
      for (j; j >= 0; j = (j & (j + 1)) - 1)
        S += x[j];
      return S;
    } else
      return sum(0, j) - sum(0, i - 1);
  }
  void add(int k, T a) {

    for (; k < x.size(); k |= k + 1)
      x[k] += a;
  }
};

int main() {
  ll n;
  cin >> n;
  vector<ll> v;
  REP(i, n) {
    ll h;
    cin >> h;
    v.pb(h);
  }
  vector<ll> s = v;

  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());

  ll ok = 0, ng = s.size();

  while (ng - ok > 1) {
    ll m = s[(ok + ng) / 2];
    vector<ll> imos;
    for (auto &a : v) {
      if (a < m) {
        imos.pb(-1);
      } else {
        imos.pb(1);
      }
    }

    REP(i, imos.size() - 1) {
      imos[i + 1] += imos[i];
    }
    BIT<ll> b(2 * n + 1);

    ll cnt = 0;
    REP(i, n) {
      cnt += (i - b.sum(0, imos[i] + n)) + (imos[i] < 0);
      //自分より小さい中央値のものを足す
      b.add(imos[i] + n, 1);
    }
    if (cnt <= (n + (n * (n - 1)) / 2) / 2) {
      //cout << cnt << " " << m << endl;
      ok = (ok + ng) / 2;
    } else {
      //cout << cnt << " " << m << endl;
      ng = (ok + ng) / 2;
    }
  }
  cout << s[ok] << endl;
}

Measured memory_bytes: 5240
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    #endif 
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) {
        // cout << "Case #" << tt - t << ": "; 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}
vector<string> s;
int get (int mask) {
    auto s_copy = s;
    int n = s_copy.size();
    int m = s_copy[0].size();
    for (int bit = 0; bit < n; ++bit) {
        if ((1 << bit) & mask) {
            for (int col = 0; col < m; ++col)
                s_copy[bit][col] = 'r';
        }
    }
    for (int bit = n; bit < n + m; ++bit) {
        if ((1 << bit) & mask) {
            for (int row = 0; row < n; ++row) 
                s_copy[row][bit - n] = 'r';
        }
    }
    int ans = 0;
    for (auto &i: s_copy)
        for (auto j : i)
            if (j == '#')
                ++ans;
    return ans;
}
void solve() {  
    int n, m, k;
    cin >> n >> m >> k;
    s.resize(n);
    rep(i, 0, n)
        cin >> s[i];
    int ans = 0;
    for (int mask = 0; mask < (1 << (n + m)); ++mask) {
        if (get(mask) == k) {
            ++ans;
        }
    }
    cout << ans;
}          

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

#pragma region mod
const int p = 1e9 + 7; //10^9 + 7
struct mint
{
    ll x;
    mint(ll x = 0) : x(x % p) {}
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= p)
            x -= p;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += p - a.x) >= p)
            x -= p;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= p;
        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
    {
        mint r = 1;
        mint a = *this;
        while (true)
        {
            if (t & 1)
            {
                r *= a;
            }
            t >>= 1;
            if (t == 0)
                break;
            a *= a;
        }

        return r;
    }

    mint inv() const
    {
        return pow(p - 2);
    }

    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
};

struct comb
{
    vector<mint> fact, invs;
    comb(int n) : fact(n + 1), invs(n + 1)
    {
        assert(n < p);

        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;

        invs[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            invs[i - 1] = invs[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * invs[n - k] * invs[k];
    }
};
#pragma endregion

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    mint ans = mint(2).pow(n) - 1;
    if (a > b)
    {
        swap(a, b);
    }

    vector<mint> fact(b + 1);
    fact[0] = 1;
    rep(i, b)
    {
        fact[i + 1] = fact[i] * (i + 1);
    }

    mint fall = 1;
    rep(i, a)
    {
        fall *= (n - i);
    }

    mint nca = fall * fact[a].inv();
    for (int i = a; i < b; ++i)
    {
        fall *= (n - i);
    }

    mint ncb = fall * fact[b].inv();

    ans -= nca;
    ans -= ncb;

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

Measured memory_bytes: 1792
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 505
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int p[maxn*maxn],d[maxn][maxn],ans,n,v[maxn][maxn];
const int kx[4]={0,0,1,-1};
const int ky[4]={1,-1,0,0};
queue <int> qx,qy;

inline void bfs()
{
	while(!qx.empty())
	{
		int x=qx.front(),y=qy.front(); qx.pop(); qy.pop();
		for(int i=0;i<=3;i++)
		{
			int tx=x+kx[i],ty=y+ky[i];
			if(tx<=n&&tx>=1&&ty<=n&&ty>=1)
			if(d[tx][ty]>d[x][y]+(v[x][y]==0))
			{
				d[tx][ty]=d[x][y]+(v[x][y]==0);
				qx.push(tx); qy.push(ty);
			}
		}
	}
}

int main()
{
	n=read(); rep(i,1,n*n) p[i]=read();
	rep(i,1,n) rep(j,1,n) d[i][j]=min(min(i-1,n-i),min(j-1,n-j));
	rep(i,1,n*n)
	{
		int x=(p[i]-1)/n+1,y=p[i]%n; if(y==0) y=n;
		ans+=d[x][y]; qx.push(x); qy.push(y); v[x][y]=1; bfs();
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6508
v[5];a[]={0,10,50,100,500,v};c,b;main(z){for(;c>4?++b?b>4?c=0,b=-1:~printf(z>0?"%d %d\n":"",a[b],z=v[b]+*v%a[b+1]/a[b]):puts(""):~scanf("%d",v+c)?*v-=v[c]*a[c],++c:0;);}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  cin >> N >> S;
  vector<int> s(N);
  for(int i = 0; i < N; i++){
    if(S[i] == 'R') s[i] = 0;
    else s[i] = 1;
  }
  int RED_COUNT = count(s.begin(), s.end(), 0);
  int WHITE_COUNT = count(s.begin(), s.end(), 1);
  int tmp_count = 0;
  if(RED_COUNT > WHITE_COUNT){
    for(int i = 0; i < RED_COUNT; i++) if(s[i] == 1) tmp_count++;
  }else for(int i = N-1; i > N - WHITE_COUNT-1; i--) if(s[i] == 0) tmp_count++;
  cout << tmp_count << endl;
}

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

  int i,j,n,tmp,min,cnt = 0;

  int arr[100];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++)scanf("%d",&arr[i]);

  for(i = 0 ; i < n ; i ++){

    min = i;

    for(j = i ; j < n ; j++)if(arr[min] > arr[j])min = j;//最小値の添字を検索

    if(i != min){
      tmp = arr[min];
      arr[min] = arr[i];
      arr[i] = tmp;
      cnt++;
    }
  }

  for(i = 0 ; i < n-1 ; i++)printf("%d ",arr[i]);

  printf("%d\n",arr[i]);
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define pll pair<ll,ll>
#define pii pair<int,int>
#define F first
#define S second
const int maxn = 2e5 + 5;
const double eps = 1e-9;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    vector<pair<string,int>>v;
    v.pb({"a",1});
    int n;
    cin >> n;
    for (int i = 2 ; i <= n ; i++) {
        vector<pair<string,int>>nxt;
        for (auto j:v) {
            for (auto k = 0 ; k <= j.S ; k++) {
                nxt.pb({j.F+(char)('a'+k),(k==j.S?j.S+1:j.S)});
            }
        }
        swap(nxt,v);
    }
    sort(v.begin(),v.end());
    for (auto i:v) {
        cout << i.F << '\n';
    }
}


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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;


void solve(int testCase){

    ll ans = 0;
    scanf("%d" , &n);

    for(int i = 1 ; i <= n ; i ++){
            if(i%3 == 0 || i%5 == 0) continue;
            ans += 1ll * i;
    }

    printf("%lld\n" , ans);


}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 3768
#include <iostream>
#include <algorithm>

using namespace std;
typedef unsigned long long ull;

ull PickLargestMinimumPiece(const ull _total_size, const ull _piece1_s, const ull _piece1_l, const ull _piece3_s, const ull _piece3_l){
	ull tmp = min(_piece1_s, _piece3_s);
	
	ull piece2 = _total_size - _piece1_s - _piece3_l;
	tmp = max(tmp, min(_piece1_s, piece2));

	piece2 = _total_size - _piece1_l - _piece3_s;
	tmp = max(tmp, min(_piece3_s, piece2));

	piece2 = _total_size - _piece1_l - _piece3_l;
	tmp = max(tmp, piece2);

	return tmp;
}

void CalcPiece1(int *_i2, ull *_piece1_s, ull *_piece1_l, const int _i1, const int _N, const ull _one_third_size, const int *_A){
	for (; *_i2 < _i1 + _N - 2;){
		*_piece1_s = *_piece1_l;
		*_piece1_l += _A[*_i2%_N];
		(*_i2)++;
		if (*_piece1_l > _one_third_size) break;
	}
}

void CalcPiece3(int *_i3, ull *_piece3_s, ull *_piece3_l, const int _i1, const int _N, const ull _one_third_size, const int *_A){
	for (; *_i3 < _i1 + _N - 1;){
		*_piece3_l = *_piece3_s;
		*_piece3_s -= _A[*_i3%_N];
		(*_i3)++;
		if (*_piece3_s <= _one_third_size) break;
	}
}

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

	int N;
	cin >> N;

	int *A = new int[N];
	ull total_size = 0;
	int i1_ini = 0;
	int A_max = 0;
	for(int i=0; i<N; i++){
		cin >> A[i];
		total_size += A[i];
		if (A[i] > A_max){
			A_max = A[i];
			i1_ini = i;
		}
	}
	ull one_third_size = total_size / 3;
	ull answer = 0;
	if (A_max > one_third_size){
		ull half_size = (total_size - A_max) / 2;
		ull tmp = 0;
		ull piece2 = 0;
		for (int i3 = i1_ini + 1; i3 < i1_ini + N - 1; i3++){
			piece2 = tmp;
			tmp += A[i3%N];
			if (tmp > half_size) break;
		}
		ull piece3 = total_size - A_max - tmp;
		answer = max(piece2, piece3);
		cout << answer << endl;
		delete[] A;
		return 0;
	}

	int i2 = i1_ini;
	ull piece1_s = 0;
	ull piece1_l = 0;
	CalcPiece1(&i2, &piece1_s, &piece1_l, i1_ini, N, one_third_size, A);
	const int i1_fin = i2;

	int i3 = i2;
	ull piece3_s = total_size - piece1_l;
	ull piece3_l = 0;
	CalcPiece3(&i3, &piece3_s, &piece3_l, i1_ini, N, one_third_size, A);

	answer = PickLargestMinimumPiece(total_size, piece1_s, piece1_l, piece3_s, piece3_l);

	for (int i1 = i1_ini + 1; i1 < i1_fin; i1++){
		int A_tmp = A[(i1 - 1) % N];
		piece1_l -= A_tmp;
		if (piece1_l > one_third_size) piece1_s -= A_tmp;
		else CalcPiece1(&i2, &piece1_s, &piece1_l, i1, N, one_third_size, A);

		piece3_s += A_tmp;
		if (piece3_s <= one_third_size) piece3_l += A_tmp;
		else CalcPiece3(&i3, &piece3_s, &piece3_l, i1, N, one_third_size, A);

		answer = max(answer, PickLargestMinimumPiece(total_size, piece1_s, piece1_l, piece3_s, piece3_l));
	}

	cout << answer << endl;

	delete[] A;

	return 0;
}

Measured memory_bytes: 1536
#!/usr/bin/env python3
print([0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input())])

Measured memory_bytes: 2940
// C: Base -2
"use strict";

const DEBUG_MODE = false;
const rawInput = DEBUG_MODE
  ? "0"
  : require("fs")
      .readFileSync("/dev/stdin", "utf8")
      .trim();

const process = inputRaw => {
  let input = parseInt(inputRaw);
  let result = "";

  while (input !== 0) {
    let remainder = input % -2;
    input = ~~(input / -2);

    if (remainder < 0) {
      remainder *= -1;
      input += 1;
    }

    result = Number(remainder).toString() + result;
  }

  console.log(result ? result : "0");
};

process(rawInput);


Measured memory_bytes: 11724
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
ll n, b, c;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    ll h=1000000000;
    ll s=(n+h-1)/h;
    ll amari=n%h;
    if(amari==0){
        amari=h;
    }
    int ans = 0;
    cout << 0 <<" "<<0<<" ";
    cout << h <<" "<<1<<" ";
    cout <<h-amari <<" "<<s<<"\n";
}



Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as U

main :: IO ()
main = do
  k <- readLn
  print $ solve k

solve :: Int -> Int
solve k = seq U.! (k - 1)
  where
    seq = U.fromList [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

Measured memory_bytes: 508
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;
    ll ans=0,id;
    int N,M;
    ll A,B,C,W;
    int a[100];
    bool f=false;
    ll sum=0;
    string S;

int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N)cin>>a[i];
    sort(a,a+N);

    cout<<a[N-1]-a[0];


    //cout<<ans;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int A, B;
    int a, b;

    cin >> A >> B;

    a = A%3;
    b = B%3;

    if(a==0 || b==0 || a+b ==3){
        cout << "Possible";
    }else{
        cout << "Impossible";
    }
}



Measured memory_bytes: 384
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))
def plis(a): return " ".join(list(map(str, a)))

N = input()
if(N[0] == N[2]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class ANovember30 {
public:
	void solve(std::istream& in, std::ostream& out) {
        int m1, m2, d1, d2;
        in >> m1 >> d1 >> m2 >> d2;
        if(m1 != m2 && d1 > d2) out << 1 << endl;
        else out << 0 << endl;
	}
};


int main() {
	ANovember30 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = [INT() for _ in range(N)]

ans = 0
loc = 1

for i in range(N):
	loc = a[loc - 1]
	ans += 1
	if loc == 2:
		print(ans)
		break

else:
	print(-1)


Measured memory_bytes: 9360
import sys
A,B = map(int,input().split())
sys.setrecursionlimit(2000)
def search(x):
    p = (x*0.08)//1
    q = (x*0.10)//1
    if p==A and q==B:
        print(x)
        exit()
    elif p > A and q > B:
        print(-1)
    else:
        search(x+1)
search(1)

Measured memory_bytes: 3828
//main関数

#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,count=1;
    string s;
	cin>>n>>s;
    for(int i=0;i<n-1;i++){
        if(s.at(i)!=s.at(i+1)){
            count++;
        }
    }
    cout<<count;
}

Measured memory_bytes: 512
import sys
import re
import math
import collections
import decimal
import bisect
import itertools

import copy

# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    s = list(input())

    w_cnt = 0
    ans = 0
    for i in range(len(s)):
        if s[i] == "W":
            ans += i - w_cnt
            w_cnt += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8020
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

#define MOD 1000000007

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

   bool ok[100010] = {};
   ll wa[100010] = {};
   rep(i, m){
       ll p;
       string s;
       cin >> p >> s;
       if(!ok[p]){
           if(s == "AC")ok[p]=true;
           else wa[p]++;
       }
   }

   ll ans = 0;
   ll wns = 0;
   rep(i, n+1)if(ok[i])ans++, wns+=wa[i];
   cout << ans << " " << wns << endl;
}
   

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


int32_t main(){
    int n; cin>>n; vector <int> a(n),pref(n); for(int i=0 ; i<n ; i++) cin>>a[i];
    pref[0] = a[0];
    for(int i=1 ; i<n ; i++) pref[i] = (pref[i-1]+a[i])%mod;
    
    int ans =0;
    for(int i=0 ; i<n-1 ; i++){
       ans = (ans + ((a[i]%mod)* ((pref[n-1]-pref[i]+mod)%mod))%mod)%mod; 
    }
      cout<<ans;
}

Measured memory_bytes: 6392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll bd[3001][3001], n, a;

int main() {
	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> a;
		bd[i][i] = a;
	}
	for (int i=1; i<=n-1; i++) {
		for (int j=0; j+i<n; j++) {
			bd[j][j+i] = max(bd[j][j]-bd[j+1][j+i], bd[j+i][j+i]-bd[j][j+i-1]);		
		}	
	}
	cout << bd[0][n-1] << "\n";
}

Measured memory_bytes: 70016
#include<cstdio>
#include<algorithm>
int main() {
	int n, a[100], i;
	scanf("%d", &n);
	for (i = 0; i < n; i++)scanf("%d", &a[i]);
	std::sort(a, a + n);
	int d = 0;
	for (i = 0; i < n; i++) {
		if (i % 2 == 0)d += a[n-i-1];
		else d -= a[n-i-1];
	}
	printf("%d", d);
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int L[n * 2];
    for(int i = 0; i < n * 2; i++){
        cin >> L[i];
    }
    sort(L, L + n * 2);
    int cnt = 0;
    for(int i = 0; i < n * 2; i += 2){
        cnt += L[i];
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
ans=[]
while_count=0
while True:
    n=input()
    if int(n[0])==0:
        break
    count=0
    for i in range(len(n)):
        count+=int(n[i])
    ans.append(count)
    n=[]
    while_count+=1

for i in range(while_count):
    print(ans[i])


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

using namespace std;

typedef long long LL;

#define MAX_N 100005
#define MOD 1000000007

int N;
LL T[MAX_N], A[MAX_N];

void input()
{
  cin >> N;
  for (size_t i = 0; i < N; i++) {
    scanf("%lld", &T[i]);
  }
  for (size_t i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
}

int check()
{
  LL height = 0;
  LL pos = 0;
  for (size_t i = 0; i < N; i++) {
    if(height < T[i]){
      height = T[i];
      pos = i;
    }
  }
  LL height2 = 0, pos2 = 0;
  for (int i = N-1; 0 <= i; i--) {
    if(height2 < A[i]){
      height2 = A[i];
      pos2 = i;
    }
  }
  if(pos <= pos2 && T[pos] == A[pos2]){
    return pos;
  }
  else{
    return -1;
  }
}

int main()
{
  input();

  int heightPos = check();
  if(heightPos == -1){
    cout << 0 << endl;
    return 0;
  }
  else{
    LL ans = 1;
    LL height = 0;
    for (int pos = 0; pos < heightPos; pos++) {
      if(height == T[pos]){
        ans *= height;
        ans %= MOD;
      }
      else{
        height = T[pos];
      }
    }

    LL height2 = 0;
    for (int pos = N-1; heightPos < pos; pos--) {
      if(height2 == A[pos]){
        ans *= height2;
        ans %= MOD;
      }
      else{
        height2 = A[pos];
      }
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 1792
// AOJ 0272: The Lonely Girl's Lie
// 2017.10.14 bal4u@uu
// 2018.1.2

#include <stdio.h>
#include <string.h>

int n;
int a[40003], b[40003];
int f[100002];

//#define getchar_unlocked()  getchar()
int in()
{
	int n, c;

	c = getchar_unlocked();
	n = 0;
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

void getdata(int *a)
{
	int i, j, k, max;
	int *aa;

	memset(f, 0, sizeof(f));
	max = 0, k = n;
	while (k--) {
		i = in(), f[i]++; if (i > max) max = i;
	} 
	for (k = n, aa = a, i = max; k; i--) if (f[i]) {
		j = f[i], k -= j; while (j--) *aa++ = i;
	}
}

int main()
{
	int i, k, ans;

	while (n = in()) {
		getdata(a);
		getdata(b);

		ans = n;
		i = 0;
		for (k = 0; k < n; k += 2) {
			if (a[k] > b[i++]) { ans = k + 1; break; }
		}
		if (ans == n) puts("NA");
		else printf("%d\n", ans);
	}
	return 0;
}



Measured memory_bytes: 2468
#include <iostream>
#include <memory.h>
static const int MAXN = 200000 + 10;
int cnt[MAXN];
int cover[MAXN];
int a[MAXN];

int main() {
//    freopen("test.txt", "r", stdin);
    memset(cnt, 0, sizeof(cnt));
    memset(cover, 0, sizeof(cover));
    int n, m;
    scanf("%d%d", &n, &m);
    int ret = n;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        int tmp = a[i] - cnt[a[i]];
        if (tmp < 1) tmp = 1;
        cover[tmp]++;
        if (cover[tmp] == 1) ret--;
        cnt[a[i]]++;
    }
    int index, val;
    for (int i = 0; i < m; i++) {
        scanf("%d%d", &index, &val);
        if (a[index] == val) {
            printf("%d\n", ret);
            continue;
        }
        int num = cnt[a[index]];
        int tmp = a[index] - num + 1;
        if (tmp < 1) tmp = 1;
        cover[tmp]--;
        if (cover[tmp] == 0) ret++;
        cnt[a[index]]--;
        tmp = val - cnt[val];
        if (tmp < 1) tmp = 1;
        cover[tmp]++;
        if (cover[tmp] == 1) ret--;
        cnt[val]++;
        printf("%d\n", ret);
        a[index] = val;
    }

    return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 int n,k;
 cin>>n>>k;
 vector<int> h(n);
 for(int i=0;i<n;i++) cin>>h[i];
 vector<int> dp(n);
 dp[n-1]=0;
 for(int i=n-2;i>=0;i--){
  dp[i]=1e9;
  for(int j=i+1;j<=i+k&&j<n;j++){
   dp[i]=min(dp[i],dp[j]+abs(h[j]-h[i]));
  }
 }
 cout<<dp[0]<<endl;
 return 0;
}

Measured memory_bytes: 1024
n, d = gets.split(' ').map(&:to_i)

ary = []
n.times do
    ary << gets.split(' ').map(&:to_i)
end

count = 0
(n-1).times do |i|
    (n-1-i).times do |k|
        sum = 0
        d.times do |j|
            sum += (ary[i][j] - ary[i+k+1][j])**2
        end
        count += 1 if Math.sqrt(sum) == Math.sqrt(sum).to_i
    end
end

print count

Measured memory_bytes: 1788
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<cstdio>
using namespace std;

map<int,int>mp[5];
int D[40][40],cost[5][40],ans=pow(10,9);

void func(set<int> S,int i,int sum){
    for(auto s:S){
        set<int> V=S;
        int x=sum;
        x+=cost[i][s];

        if(i==2){
            ans=min(ans,x);
            continue;
        }
        V.erase(s);
        func(V,i+1,x);
    }
}

int main(){
    int N,C;cin>>N>>C;
    set<int> Set;
    for(int i=1;i<=C;i++){
        Set.insert(i);
        for(int j=1;j<=C;j++)
            cin>>D[i][j];
    }
    
    int c;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            cin>>c;
            mp[(i+j)%3][c]++;
        }
    }

    for(int i=0;i<3;i++){
        for(int c=1;c<=C;c++){
            cost[i][c]=0;
            for(auto itr=mp[i].begin();itr!=mp[i].end();itr++)
                cost[i][c]+=itr->second*D[itr->first][c];
        }
    }

    func(Set,0,0);
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 256
"""http://mayokoex.hatenablog.com/entry/2015/06/11/124120を参照しました"""
"""三分探索、賢い"""
import sys
MI = 1e-6
def calc(x,y,b):
    res = 90000
    for bx,by,l in b:
        d = l**2-(x-bx)**2-(y-by)**2
        if d < res:
            res = d
    return res

def search_y(x,b):
    p = [-100,-33,33,100]
    for t in range(100):
        if abs(p[0]-p[3]) < MI:
            return (calc(x,p[0],b)+calc(x,p[3],b))/2
        l = calc(x,p[1],b)
        r = calc(x,p[2],b)
        if l < r:
            p[0] = p[1]
        else:
            p[3] = p[2]
        p[1] = (2*p[0]+p[3])/3
        p[2] = (p[0]+2*p[3])/3
    return (calc(x,p[0],b)+calc(x,p[3],b))/2

def search(b):
    p = [-100,-33,33,100]
    for t in range(100):
        if abs(p[0]-p[3]) < MI:
            return (search_y(p[0],b)+search_y(p[3],b))/2
        l = search_y(p[1],b)
        r = search_y(p[2],b)
        if l < r:
            p[0] = p[1]
        else:
            p[3] = p[2]
        p[1] = (2*p[0]+p[3])/3
        p[2] = (p[0]+2*p[3])/3
    return (search_y(p[0],b)+search_y(p[3],b))/2

def solve(n):
    b = [[int(x) for x in sys.stdin.readline().split()] for i in range(n)]
    ans = 0
    print(search(b)**0.5)

while 1:
    n = int(sys.stdin.readline())
    if n == 0:
        break
    solve(n)



Measured memory_bytes: 5824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int MOD = 1000000007;

//↓combination(ll a, ll b) でaCr計算。
//------------------------------------------------------------------------------------------
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}
ll kj(ll x){
    ll s = 1;
    for(ll i = 1; i <= x; i++){
        s = s * i % MOD;
    }
    return s;
}
ll combination(ll a, ll b){
    if(a == 0 && b == 0) return 1;
    if(a < b || a < 0) return 0;
    return (kj(a) * mpow(kj(b), MOD-2) % MOD) * mpow(kj(a-b), MOD-2) % MOD;
}
//---------------------------------------------------------------------------------------------
//↑combination(ll a, ll b) でaCr計算。

int main(){
    int K;
    cin >> K;
    ll sum=0;
    for(int i=1; i <= K; i++){
        for(int j=1; j <= K; j++){
            for(int k=1; k <= K; k++){
            sum += gcd(gcd(i,j),k);
            }
        }
    }
    cout << sum;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int n, s[1000009], q, t[50009], c = 0;

int main(){
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	cin >> q;
	for(int i=0;i<q;i++){
		cin >> t[i];
	}

	for(int i=0;i<q;i++){
		int key = t[i];
		s[n] = key;
		int j = 0;
		while(s[j] != key){
			j++;
		}
		if(j != n) c++;
	}
	cout << c << endl;
}

Measured memory_bytes: 1752
def main():
    H, W, A, B = list(map(int, input().split(' ')))
    for _ in range(B):
        print('1' * A + '0' * (W - A))
    for _ in range(H - B):
        print('0' * A + '1' * (W - A))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3956
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    readLine()!!.split(' ')
            .mapIndexed { index, s ->
                index + 1 to s.toInt()
            }
            .sortedBy { it.second }
            .map { it.first }
            .joinToString(" ")
            .let { println(it) }

}


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

using namespace std;

int n;
string s[111];

int solve(int& idx){
  int ret;
  if(isdigit(s[idx].back())) {
    ret = s[idx].back()-'0', idx++;
  } else {
    ret = (s[idx].back() == '*');
    int base = idx; idx++;
    while(idx < n && s[base].size()+1 == s[idx].size()) {
      if(s[base].back() == '+') ret += solve(idx);
      else if(s[base].back() == '*') ret *= solve(idx);
    }
  }
  return ret;
}

int main()
{
  while(cin >> n, n) {
    for(int i = 0; i < n; i++) cin >> s[i];
    int idx = 0;
    cout << solve(idx) << endl;
  }
  return 0;
}

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

int main(int argc, char** argv)
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if(a == b) puts(a == c? "No": "Yes");
	else if(a == c) puts(a == b? "No": "Yes");
	else if(b == c) puts(b == a? "No": "Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,cnt = 1;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin >> a >> b;
	ll c = __gcd(a,b);
	for(ll i = 2;i <= c / i; ++i){
		if(c % i == 0){
			cnt ++;
			while(c % i == 0) c /= i;
		}
	}
	if(c > 1) cnt++;
	cout << cnt ;
	return 0;
}

Measured memory_bytes: 256
//Radhe Radhe
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//using namespace boost::multiprecision;
//#include<boost/math/common_factor.hpp>
#include <ext/numeric>
using namespace __gnu_cxx;
using namespace std;
#define int long long
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define array(a,n) int a[n]; for(int i=0;i<n;i++) cin>>a[i];
#define loop(i,a,b,x) for(int i=a;i<b;i+=x)
const int MOD = 1000000007;

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) {
        int n;
        cin >> n;
        int  a[n];
        int pref[n + 1];
        pref[0] = 0;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            pref[i + 1] = pref[i] + a[i];
        }

        int dp[n][n];
        memset(dp, 0x3f, sizeof(dp));
        for (int i = 0; i < n; i++) {
            dp[i][i] = 0;
        }

        for (int l = 2; l <= n; l++) {
            for (int i = 0; i < n - l + 1; i++) {
                int j = i + l - 1;
                for (int k = i; k < j; k++) {
                    dp[i][j] = min(dp[i][j], (dp[i][k] + dp[k + 1][j]) + (pref[k + 1] - pref[i] + pref[j + 1] - pref[k + 1]));
                }
            }
        }

        cout << dp[0][n - 1] << endl;
    }
    return 0;

}



Measured memory_bytes: 1536
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)



  int moves(int a, int b)
  {
    return abs(1-a) + abs(1-b);
  }

int32_t main()
{
       

  

    
     int n;
     cin >> n;


     int ans = 100000000000000;



     for(int i = 1; i <= n/i;i++)
     {
      if(n%i == 0)
      {
        ans = min ({ans,moves(i,n/i),moves(n/i,i)});
      }
     }

     cout << ans;

   return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean isKuku = false;
		for(int i = 1; i < 10; i++){
			for(int k = 1; k < 10; k++){
				if(n == i * k){
					isKuku = true;
				}
			}
		}
		System.out.println(isKuku ? "Yes" : "No");
	}
}


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

int main(){
    string C="CODEFESTIVAL2016";
    string S;
    cin>>S;
    int ans=0;
    for(int i=0;i<16;i++){
        if(C[i]!=S[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pow_mod(ll fi,ll se,ll mod){
  if(se==0){
    return 1;
  }
  if(se%2){
    return pow_mod(fi,se-1,mod)*fi%mod;
  }
  ll t=pow_mod(fi,se/2,mod);
  return t*t%mod;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

vector<pair<int,int>> Dir={{-1,0},{1,0},{0,1},{0,-1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/



int main(){
  ll h,w;
  cin>>h>>w;
  vector<string>s(h);
  //vector<vector<vector<ll>>> cnt(h,vector<vector<ll>>(w,vector<ll>(4)));
  vector<vector<ll>> cnt(h,vector<ll>(w,1));
  rep(i,h){
    
      cin>>s[i];
    
  }
  
  ll tmp=0;
  rep(i,h){
    tmp=0;
    rep(j,w){
      if(s[i][j]=='#'){
        tmp=j+1;
        continue;
      }
      cnt[i][j]+=j-tmp;
      //cout<<cnt[i][j][0]<<endl;
    }
  }
  rep(i,h){
    tmp=w-1;
    for(ll j=w-1;j>=0;j--){
      if(s[i][j]=='#'){
        tmp=j-1;
        continue;
      }
      cnt[i][j]+=tmp-j;
      //cout<<cnt[i][j][1]<<endl;
      
    }
  }
  rep(j,w){
    tmp=0;
    rep(i,h){
      if(s[i][j]=='#'){
        tmp=i+1;
        continue;
      }
      cnt[i][j]+=i-tmp;
    }
  }
  rep(j,w){
    tmp=h-1;
    for(int i=h-1;i>=0;i--){
      if(s[i][j]=='#'){
        tmp=i-1;
        continue;
      }
      cnt[i][j]+=tmp-i;
    }
  }
  ll ans=0;
  rep(i,h){
    rep(j,w){
       
      //rep(k,4)if(s[i][j]=='.'){tmp+=cnt[i][j][k];}
      
      ans=max(ans,cnt[i][j]);
    }
  }
  op(ans);
  return 0;
}


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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int ans = 0;
  vector<int> cosin(5);
  for(int i = 0; i < 5; i++){
    cin >> cosin[i];
    if(cosin[i] % 10 != 0){
      string s = to_string(cosin[i]);
      int x = s[s.size()-1] - '0';
      ans += cosin[i] + (10 - x);
    } else{
      ans += cosin[i];
    }
  }
  int min = 10;
  for(int i = 0; i < 5; i++){
    if(cosin[i] % 10 != 0){
      string s = to_string(cosin[i]);
      int x = s[s.size()-1] - '0';
      if(x < min){
        min = x;
      }
    }
  }
  cout << ans - (10 - min) <<endl;
}


Measured memory_bytes: 3676
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}




int main(){

    ll n;
    cin>>n;

    vector<pair<ll,ll>> so;
    ll nn = n;
   for(ll s=2;s<=sqrt(n);s++){
       if(nn%s==0){
           ll sum = 0;
           while(nn%s==0){
               nn/=s;
               sum++;
           }
           so.push_back({s,sum});
         //  cout<<s<<" "<<sum<<endl;
       }
   }
   if(nn!=1){
       so.push_back({nn,1});
   }

   ll ans = 0;
   rep(i,so.size()){
       int k=1;
       ll s2=so[i].second;
       while(s2>=k){
           ans++;
           s2-=k;
           k++;
       }
   }
    cout<<ans<<endl;












return 0;
}


Measured memory_bytes: 3724
#include<stdio.h>
int main(){
	int a,b,flag=0;
	char s[11];
	scanf("%d%d",&a,&b);
	scanf("%s",s);
	if(s[a]!='-'){
		printf("No\n");
		return 0;
	}
	for(int i=0;i<=a+b;i++){
		if(i!=a && (s[i]<'0' || s[i]>'9')){
			flag=1;
			break;
		}
	}
	printf("%s\n",flag?"No":"Yes");
	return 0;
}

Measured memory_bytes: 128
N,K = map(int,(input().split()))
A=[i for i in range(N+1)]
rui=[0]
for i in range(1,N+1):
  rui.append(i+rui[i-1])

ans=0
max_comb=0
min_comb=0
for i in range(K,N+2):
  try:
    max_comb=rui[-1]-rui[-1-i]
  except:
    max_comb=rui[-1]
  min_comb=rui[i-1]
  ans+=max_comb-min_comb+1
  ans %= (10**9+7)
print(ans)

Measured memory_bytes: 27176
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
z = [int(i) for i in input().split()]
f = 1
for i in range(1,5):
  if all(i in j for j in (x,y,z)): f = 0
if f: print("YES")
else: print("NO")

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cstring>
#include<cmath>
#include <numeric>
#include<queue>
#include<climits>
#include<cstdio>
#include<map>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
//#define INF ((LLONG_MAX) / (2))
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;
#define INF 1e9+7
#define N_MAX 1001




int main(){

    ll n,a,b;
    cin >> n >> a >> b;
    vector<ll> h(n);
    REP(i,n){
        cin >> h[i];
    }
    ll diff = a-b;
    ll lb = 0,ub = 1000000000;
    ll mid;

    while(ub - lb > 1){

        mid = (lb + ub)/2;
        ll cnt = 0;
        for(int i = 0;i < n;i++){

            if(h[i] > b * mid){
                cnt += (h[i]-b*mid-1)/diff + 1;
            }
        }

        if(cnt > mid){
            /*mid回以上かかる*/
            lb = mid;
        }else{
            /*mid回以内で終わる*/
            ub = mid;
        }
    }
    cout << ub << endl;



    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
  int x, y;
  scanf("%d %d", &x,&y);

  printf("%d\n",gcd(x,y));
  return 0;
}


int gcd(int x, int y){
  int d;
  while(1)
    {
      d = x % y;
      if (d == 0)
        break;
      x = y;
      y = d;
    }
  return y;
}

Measured memory_bytes: 592
import java.io.*;
import java.util.*;

public class Main{
    
    public static void main(String[] arg){
        Scanner scan =new Scanner(System.in);
        int a=scan.nextInt();
        int b=scan.nextInt();

        if(a>=13){
            System.out.println(b);
        }
        else if(a >=6 && a<=12) {
            System.out.println(b/2);
        }
        else System.out.println(0);

    }
}

Measured memory_bytes: 21716
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    if n < 105:
        print(0)
        exit()
    i = 105
    ans = 0
    while i <= n:
        if i % 2 == 0:
            i += 1
            continue
        cnt = 0
        a = 1
        while a * a <= i:
            if i % a == 0:
                if i // a == a:
                    cnt += 1
                else:
                    cnt += 2
            a += 1
        #print(i,cnt)
        if cnt == 8:
            ans += 1
        i += 1
    print(ans)
if __name__ == '__main__':
  main()


Measured memory_bytes: 5144
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <functional>
#include <map>
#include <math.h>
#include <list>

using namespace std;
#define ll long long int


int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	vector<int> a;
	int sum = 0;
	int n, m;
	int in;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> in;
		a.push_back(in);
		sum += in;
	}
		sort(a.begin(), a.end(), greater<int>());

		if (a[m - 1] * 4 * m >= sum) cout << "Yes" << endl;
		else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3636