akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("-O3")
/*
				C++
				encoding: UTF-8
				Last Modified: 24/Aug/20 10:28:18 AM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

#define int int64_t

template < typename T > void print (const T& t) {
	cout << t << '\n';
}

template < typename T, typename U, typename... ARGS >
void print (const T& t, const U& u, const ARGS&... args) {
	cout << t << " ";
	print (u, args...);
}

const int N = 1e3 + 5;
char arr[N][N];
int ans[N][N];
int n, m;
int x, y;
int g, h;

bool check (int a, int b) {
	return a >= 0 and a < n and b >= 0 and b < m;
}

signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	cin >> n >> m;
	cin >> x >> y;
	x--;
	y--;
	cin >> g >> h;
	g--;
	h--;

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> arr[i][j];
			ans[i][j] = 1e9;
		}
	}

	priority_queue< pair< int, pair< int, int > >, vector< pair< int, pair< int, int > > >, greater<> > q;
	q.push ({0, {x, y}});
	ans[x][y] = 0;

	while (!q.empty ()) {
		auto [dis, p] = q.top ();
		q.pop ();

		int a = p.first, b = p.second;

		if (check (a - 1, b) and arr[a - 1][b] == '.' and ans[a - 1][b] > dis) {
			q.push ({dis, {a - 1, b}});
			ans[a - 1][b] = dis;
		}
		if (check (a + 1, b) and arr[a + 1][b] == '.' and ans[a + 1][b] > dis) {
			q.push ({dis, {a + 1, b}});
			ans[a + 1][b] = dis;
		}
		if (check (a, b - 1) and arr[a][b - 1] == '.' and ans[a][b - 1] > dis) {
			q.push ({dis, {a, b - 1}});
			ans[a][b - 1] = dis;
		}
		if (check (a, b + 1) and arr[a][b + 1] == '.' and ans[a][b + 1] > dis) {
			q.push ({dis, {a, b + 1}});
			ans[a][b + 1] = dis;
		}


		for (int i = -2; i <= 2; ++i) {
			for (int j = -2; j <= 2; ++j) {
				if ((i == 0 and j == 0) or (abs (i) == 1 and abs (j) == 0) or (abs (i) == 0 and abs (j) == 1))
					continue;
				int c = a + i, d = b + j;
				if (check (c, d) and arr[c][d] == '.' and ans[c][d] > dis + 1) {
					q.push ({dis + 1, {c, d}});
					ans[c][d] = dis + 1;
				}
			}
		}
	}
	if (ans[g][h] == 1e9) ans[g][h] = -1;
	print (ans[g][h]);

	return 0;
}

Measured memory_bytes: 12660
main = do
    s <- getLine
    p <- getLine
    let b = canCreate (s ++ s) p
    putStrLn b

canCreate :: String -> String -> String
canCreate [] _ = "No"
canCreate str@(s:ss) p
    | s == head p = case (equalString str p) of
                        True -> "Yes"
                        False -> canCreate ss p
    | otherwise = canCreate ss p

equalString :: String -> String -> Bool
equalString s p = take (length p) s == p

Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

signed main() {
	IOS;
	int a=0;
	vector<int> K(9);
	rep(i,9){
		int k;
		cin>>k;
		K[i]=k;
	}
	
	
	int N; cin>>N;
	rep(i,N){
		int b; cin>>b;
		rep(j,9){
			if(b==K[j]){
				K[j]=0;
			}
		}
	}
	rep(i,3){
		if(K[i]==0 && K[i+3]==0 && K[i+6]==0) a=1;
	}
	for(int i=0;i<9;i+=3) {
		if(K[i]==0 && K[i+1]==0 && K[i+2]==0) a=1;
	}	
	if(K[0]==0 && K[4]==0 && K[8]==0) a=1;
	if(K[2]==0 && K[4]==0 && K[6]==0) a=1;
	if(a==1){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	
}


Measured memory_bytes: 256
n , a = map(int, input().split())
num = 5000*n
ans = [0, n, 0]

def find(num):
    for _ in range(n+1):
        if num < a:
            ans[0] += 1
            ans[1] -= 1
            num += 5000
        elif num > a:
            ans[1] -= 1
            ans[2] += 1
            num -= 4000
        elif num == a:
            return ' '.join(map(str, ans))
    return '-1 -1 -1'

print(find(num))

Measured memory_bytes: 3064
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

void outPut_YN(bool isYes) {
	if(isYes)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

const long long MOD = 1000000007;

long long fact(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum *= i;

	return sum;
}

long long fact_mod(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum = (sum * i) % MOD;

	return sum;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}

long long pow_mod(int a, int b) {
	long long ans = 1;
	for (int i = 0; i < b; i++)
		ans = (ans * a) % MOD;

	return ans;
}

long long powll(long long a, long long  b) {
	long long ans = 1;
	for (long long i = 0; i < b; i++)
		ans = ans * a;

	return ans;
}

long long modinv(long long a) {

	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;

	return u;
}

long long _gcd(long long a, long long b)
{
	if (a < b)
		swap(a, b);

	if (a % b == 0)
		return b;
	else
		return _gcd(b, a % b);
}

int main()
{
	long long h, a, sum = 0;

	cin >> h >> a;

	cout << (long long)ceil(h / (double)a) << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Long> cur = new ArrayList<>();
        for (long i = 1; i <= 9; i++) {
            cur.add(i);
        }
        while (true) {
            if (cur.size() >= n) {
                System.out.println(cur.get(n - 1));
                return;
            }
            n -= cur.size();
            ArrayList<Long> next = new ArrayList<>();
            for (long x : cur) {
                if (x % 10 != 0) {
                    next.add(x * 10 + x % 10 - 1);
                }
                next.add(x * 10 + x % 10);
                if (x % 10 != 9) {
                    next.add(x * 10 + x % 10 + 1);
                }
            }
            cur = next;
        }
    }
}


Measured memory_bytes: 30036
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

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

	ll N, M; scanf("%lld %lld", &N, &M);
	ll left = -1;
	set<int> s;
	vector<vector<int>> g(N);
	ll last = 0;
	for (int i = 0; i < M; i++) {
		ll c, d; scanf("%lld %lld", &c, &d);
		c--; d--;
		g[c].push_back(d);
	}
	ll res = 0;
	for (int i = 0; i < N; i++) {
		if (g[i].size() > 0) {
			if (left == -1) left = i;
			for (auto e : g[i]) s.insert(e);
		}
		if (s.find(i) != s.end()) {
			s.erase(s.find(i));
			if (s.size() == 0) {
				res += i - last + (i - left) * 2;
				last = i;
				left = -1;
				//cout << res << endl;
			}
		}
	}
	//cout << last << " " << res << endl;
	res += N + 1 - last;
	cout << res << endl;
	return 0;

}



Measured memory_bytes: 3324
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
int main(){
  string s,s2,s3,t;
  cin>>s>>t;
  if(s.size()<t.size()){
    cout<<"UNRESTORABLE"<<endl;
    return 0;
  }
  bool flag=true;
  vector<string> v;
  for(ll i=0;i<=s.size()-t.size();i++){
    string tmp=s.substr(i,t.size());
    flag=true;
    rep(j,t.size()){
      if(!(tmp[j]==t[j] || tmp[j]=='?')) flag=false;
    }
    
    if(flag){
      s2=s;
      s3=s2.replace(i,t.size(),t);
      replace(ALL(s3),'?','a');
      v.push_back(s3);
    }
  }
  if(v.size()>0){
    sort(ALL(v));
 	cout<<v[0]<<endl;
  }else{
    cout<<"UNRESTORABLE"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int v[100001];
int main() {
    int n;
    scanf("%d",&n);
    int ans=0;
    int A=0,B=0,K=0;

    for(int i=1;i<=n;i++) {
        string s;
        cin>>s;
        for(int i=0;i<s.size()-1;i++) {
            if(s[i]=='A' && s[i+1]=='B') ans++;
        }
        if(s[0]=='B' && s[s.size()-1]=='A') K++;
        else if(s[0]=='B') B++;
        else if(s[s.size()-1]=='A') A++;
    }

    if(K>1) {
        ans += (K-1);
        if(A || B) {A++; B++;}
    }
    if(K==1) {
        if(A) A--,ans++;
        if(B) B--,ans++;
    }

    ans += min(A,B);
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    ll n; cin >> n;
    ll s = (ll)sqrtl(n);
    ll ans = 0;
    for(ll m=0; m<s; m++){
        if(n % (m+1) == 0){
            if(n / (m+1) - 1 > m+1) ans += n / (m+1) - 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
# import numpy as np
from fractions import gcd

sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7


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


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


def lcm(x, y): return (x * y) // gcd(x, y)

from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
# import numpy as np
from fractions import gcd

sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7


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


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


def lcm(x, y): return (x * y) // gcd(x, y)


N, M = inp_list()
A = inp_list()
A.sort(reverse=True)
total = sum(A)

if A[M - 1] * 4 * M < total:
    print('No')
else:
    print('Yes')



Measured memory_bytes: 5704
// D - Dice in Line
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
double in(){double x;cin>>x;return x;}
int N,K;
vector<int> S(1);//累積和

int main(){
	cin>>N>>K;
	rp(i,0,N) S.push_back(S[i] + in()+1);
	int ans = 0;
	rp(i,0,N-K+1) ans = max(ans, S[i+K]-S[i]);
	printf("%.12f\n",ans/2.0);
}

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

int main()
{
   int a,b,c,d;
  
   cin>>a>>b>>c>>d;
  
  int turn =0;
  
  while(a>0&&c>0)
  {
      if(turn%2==0)
      {
         c-=b;
         if(c<=0)
           cout<<"Yes"<<endl;
      }
      
      if(turn%2==1)
      {
          a-=d;
          if(a<=0)
            cout<<"No"<<endl;
      }
 
     turn++;
    
  }


   return 0;


}


Measured memory_bytes: 3612
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstdlib>
#define rp(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)

typedef long long ll;

using namespace std;

int main(){
    string s;
    ll ans=0;
    cin>>s;
    for(ll i=0; i < (1 << (s.size()-1));i++){
        string tmp;
        tmp=tmp+s[0];
        for(ll j=1;j<s.size();j++){
            if(  (i >> (j-1) & 1 )== 0) tmp = tmp + s[j];
            if(  (i >> (j-1) & 1) == 1) {
                ans += (ll)atoll(tmp.c_str());
                tmp="";
                tmp = tmp+s[j];
            }
        }
        ans+=(ll)atoll(tmp.c_str());
    }
    cout<<ans<<endl;
    return 0;
}


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    ll n, m, ans = 0LL;
    cin >> n >> m;
    if(n > m) swap(n, m);

    if(n == 1){
        if(m == 1) ans = 1LL;
        else if(m == 2) ans = 0LL;
        else ans = m-2LL;
    }else if(n == 2){
        ans = 0LL;
    }else{
        ans = (n-2) * (m-2);
    }

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


Measured memory_bytes: 256
// 2020-08-02 21:17:37
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  auto ok = [&](ll x) {
    ll cnt = 0;
    rep(i, n) {
      if(x < a[i]) {
        cnt += a[i] / x;
        if(a[i] % x == 0) cnt--;
      }
    }
    return cnt <= k;
  };
  ll l = 0, r = 1e9+5;
  while(l + 1 < r) {
    ll x = (l + r) / 2;
    if(ok(x)) r = x;
    else l = x;
  }
  cout << r << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 4680
#include <bits/stdc++.h>
using namespace std;
#define int unsigned long long
#define mod 1000000007
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int no_of_input;
  int input;
  vector<int> vect1;
  cin >> no_of_input;
  for(int i=0;i<no_of_input;i++){
    cin >> input;
    vect1.push_back(input);
  }
  int ans = 0;
  int id = 1;
  for(int i=0;i<60;i++){
    int cnt1 = 0,cnt2 = 0;
    for(int j=0;j<vect1.size();j++){
      if(vect1[j]%2==1){
        cnt1++;
      }
      else{
        cnt2++;
      }
      vect1[j] /= 2;
    }
    int temp = (cnt1*cnt2)%mod*((id)%mod);
    temp %= mod;
    ans += temp;
    ans %= mod;
    id *= 2;
  }
  cout << ans;

}


Measured memory_bytes: 6384
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    int n;
    scanf("%d", &n);
    char s[n+1], t[n+1];
    scanf("%s%s", s, t);

    for ( int i=0; i<n; i++ )
        printf("%c%c", s[i], t[i]);
    printf("\n");

    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
def main():
    a,b,k = map(int, input().split())

    i = a
    while True:
        if i > b:
            return
        if i-a + 1 > k:
            i = max(i, b-k+1)
            break
        print(i)
        i += 1
    while True:
        if i > b:
            break
        print(i)
        i += 1

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<template<class...> class ContT, class ValueT, size_t Dim>
struct vec_type
{
    using type = ContT<typename vec_type<ContT, ValueT, Dim-1>::type>;
};

template<template<class...> class ContT, class ValueT>
struct vec_type<ContT, ValueT, 0>
{
    using type = ValueT;
};

template<class ValueT, size_t Dim = 1>
using vec_t = typename vec_type<std::vector, ValueT, Dim>::type;


template<class ValueT, size_t Dim, class = typename std::enable_if<Dim == 0>::type>
auto make_vec(ValueT value = ValueT()) -> ValueT
{
    return value;
}

template<class ValueT, size_t Dim, class... Rest>
auto make_vec(size_t size0, Rest... rest)
{
    auto vec = make_vec<ValueT, Dim-1>(rest...);
    return std::vector(size0, vec);
}

int diffabs(int l, int r)
{
    if (l < r) return r-l;
    else return l-r;    
}


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

int f(vi p, int X)
{
    for (int d = 0; d < 100; ++d)
    {
        if (p[X-d] == 0)
            return X-d;
        if (p[X+d] == 0)
            return X+d;
    }
}

int main()
{
    int X, N;
    cin >> X >> N;
    vi p(102, 0);
    for (int i = 0; i < N; i++)
    {
        int pi;
        cin >> pi;
        ++p[pi];
    }
    
    int ans = f(p, X);
    cout << ans << endl;
}


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

class Program {
    static void Main (string[] args) {
        int n  = int.Parse(Console.ReadLine ());
        string[] p = Console.ReadLine ().Split(' ');
        int[] pn = new int[n];
        int[] pn_sort = new int[n];
        int cnt = 0;

        for(int i=0;i<n;i++){
            pn[i] = int.Parse(p[i]);
            pn_sort[i] = int.Parse(p[i]);
        }

        Array.Sort(pn_sort);

        for(int i=0;i<n;i++){
            if(pn[i] != pn_sort[i]) cnt++;
        }

        if(cnt == 2 || cnt == 0){
            Console.WriteLine("YES");
        }else{
            Console.WriteLine("NO");
        }

    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n,k;
    cin >> n >> k;
    ll a[n];
    for(ll i = 0;i < n;i++){
        cin >> a[i];
    }
    for(ll i = 1;i < n;i++){
        a[i] += a[i-1];
    }
    a[0] = (a[0]-1)%k;
    if(a[0] < 0){
        a[0] += k;
    }
    for(ll i = 1;i < n;i++){
        a[i] = (a[i]-i-1)%k;
        if(a[i] < 0){
            a[i] += k;
        }
    }
    ll ans = 0;
    map<ll,ll> freq;
    freq[a[0]] = 1;
    for(ll i = 1;i < min(n,k);i++){
        if(freq.find(a[i]) != freq.end()){
            freq[a[i]]++;
        }
        else{
            freq[a[i]] = 1;
        }
        ans += (freq[a[i]]-1);
    }
    for(ll i = min(n,k);i <= n-1;i++){
        freq[a[i-k]]--;
        if(freq[a[i-k]] == 0){
            freq.erase(a[i-k]);
        }
        if(freq.find(a[i]) != freq.end()){
            freq[a[i]]++;
        }
        else{
            freq[a[i]] = 1;
        }
        ans += (freq[a[i]]-1);
    }
    for(ll i = 0;i < min(n,k-1);i++){
        if(a[i] == 0){
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> a(h,(vector<char>(w)));
    rep(i,h){
        rep(j,w) cin >> a[i][j];
    }
    vector<bool> flag_h(h);
    vector<bool> flag_w(w);
    rep(i,h){
        rep(j,w){
            if(a[i][j] == '#') flag_h[i] = true;
        }
    }
    rep(j,w){
        rep(i,h){
            if(a[i][j] == '#') flag_w[j] = true;
        }
    }
    rep(i,h){
        rep(j,w){
            if(flag_h[i] && flag_w[j]) cout << a[i][j];
        }
        if(flag_h[i]) cout << endl;
    }
    return 0;
}

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

#ifdef LOCAL
	#define de(x) cout<<#x<<"="<<x<<endl
	#define rff freopen("input.txt","r",stdin)
	#include "Debug.h"
#else
	#define de(x)
	#define rff
#endif

#define itr(x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define PQ priority_queue
#define pii pair<int,int>
#define vi vector <int>
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=1e5+3;

int n,a[MAXN],b[MAXN];
deque <int> q,q2;
vi v;
ll ans;

void make1(){
	ll t=0;
	q.pb(a[0]);
	int l=1,r=n-1;
	while (l<=r){
		if (l<=r) q.pb(a[r--]);
		if (l<=r) q.pf(a[r--]);
		if (l<=r) q.pb(a[l++]);
		if (l<=r) q.pf(a[l++]);
	}
	int x=0;
	while (q.size()){
		b[x++]=q.front();
		q.pop_front();
	}
	rep(i,n-1){
		t+=abs(b[i]-b[i+1]);
	}
	ans=max(ans,t);
}

void make2(){
	ll t=0;
	q.pb(a[n-1]);
	int l=0,r=n-2;
	while (l<=r){
		if (l<=r) q.pb(a[l++]);
		if (l<=r) q.pf(a[l++]);
		if (l<=r) q.pb(a[r--]);
		if (l<=r) q.pf(a[r--]);
	}
	int x=0;
	while (q.size()){
		b[x++]=q.front();
		q.pop_front();
	}
	rep(i,n-1){
		t+=abs(b[i]-b[i+1]);
	}
	ans=max(ans,t);
}

int main(){
	cin>>n;
	rep(i,n){
		cin>>a[i];
	}
	sort(a,a+n);
	make1();
	make2();
	cout<<ans;
	re 0;
}

Measured memory_bytes: 1408
n, w = map(int, input().split())
dp = [0]*(w+1)

for i in range(n):
  weight, value = map(int, input().split())
  for j in range(w, -1, -1):
    if j == 0 or dp[j] != 0:
      if j+weight <= w:
        dp[j+weight] = max([dp[j+weight], dp[j]+value])

print(max(dp))


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

int n, a[1000000];

int main(){
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a+1, a+n+1);
    cout << a[n] << " ";
    int _min = 1e9, c;
    for (int i = 1; i < n; i++){
        if (abs(a[n]-2*a[i]) < _min){
            _min = abs(a[n]-2*a[i]);
            c = a[i];
        }
    }
    cout << c;
}

Measured memory_bytes: 640
use std::io::Read;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();

    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut vec = Vec::new();

    loop {
        match iter.next() {
            None => { break; }
            Some(some) => {
                let val: usize = some.parse().unwrap();
                vec.push(val);
            }
        }
    }

    let mut prev = 0;
    let mut count = 0;
    for v in vec {
        if prev <= v {
            count += 1;
            prev = v;
        } else {}
    }

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


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main() {
    int a,b;
    for(;;)
    {
        cin>>a>>b;
        if(a==0&&b==0)
            break;
        if(a<b) cout<<a<<" "<<b<<"\n";
        else cout<<b<<" "<<a<<"\n";
    }
}


Measured memory_bytes: 3068
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;


public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
	// TODO Auto-generated method stub
		int[]	params = null;
		String	out    = "";

		while ((params = parseParams()) != null) {
			if (params.length != 2) {
				continue;
			}

			HashMap<Integer, Boolean>	result = new HashMap<Integer, Boolean>();
			while (params[0] != 0 && params[1] != 0) {
				for (int key:params) {
					Boolean	val = true;

					switch (key) {
					case 1:
					case 2:
						val = (result.containsKey(key)) ? !result.get(key) : true;
						break;
					default:
						val = (result.containsKey(key)) ? !result.get(key) : false;
						break;
					}

					result.put(key, val);
				}
				params = parseParams();
			}

			out += result.containsValue(false) ? "NG\n" : "OK\n";
		}

		System.out.print(out);
	}

	private static  int[] parseParams() {
		int[]		params = null;
		String[]	split  = null;
		String		strIn  = null;
 
		if ((strIn = parseStdin()) != null) {
			split  = strIn.split(" ");
			params = new int[split.length];
			for (int n = 0; n < split.length; n++) {
				params[n] = Integer.parseInt(split[n]);
			}
		}
		 
		return params;
	}
 
	private static String parseStdin() {
		String	strNum = null;
 
		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					strNum = line;
				}
			}
		}
		catch (IOException e) {}
 
		return strNum;
	}
}

Measured memory_bytes: 22440
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

template< typename T >
T mod_pow(T x, T n, const T &p) {
    T ret = 1;
    while(n > 0) {
        if(n & 1) (ret *= x) %= p;
        (x *= x) %= p;
        n >>= 1;
    }
    return ret;
}

int main(void) {
    int N, P;
    string S;
    cin >> N >> P >> S;
    
    int64_t ans = 0;
    if(10 % P == 0) {
        for(int i=0; i<N; i++) {
            if((S[i]-'0') % P == 0) {
                ans += i+1;
            }
        }
    } else {
        reverse(S.begin(), S.end());
        vector<int64_t> v(P);
        int t = 0;
        for(int i=0; i<N; i++) {
            t += (S[i]-'0') * mod_pow(10, i, P);
            t %= P;
            v[t]++;
        }
        for(auto e: v) {
            ans += e * (e-1) / 2;
        }
        ans += v[0];
    }

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


Measured memory_bytes: 640
#include <iostream>

int main(){
  long A, B, C, K;
  std::cin >> A >> B >> C >> K;
  
  if (K <= A) std::cout << K;
  else if (K <= A + B) std::cout << A;
  else std::cout << A - (K - A - B);
  
  return 0;
}

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

int main() {
	int n, j;
	vector<int> p(100);
	vector<string> s(100);
	vector<int> b(100, 0);

	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> s[i] >> p[i];
	
	for (int k = 0; k < n; k++) {
		j = 0;
		for (int i = 0; i < n; i++) {
			if (b[j] == 1)
				j = i;
			if (b[i] == 0) {
				if (s[j] > s[i]) {
					j = i;
				}
				else if (s[j] == s[i] && p[j] < p[i]) {
					j = i;
				}
			}
		}
		cout << j+1 << endl;
		b[j] = 1;
	}

	return 0;
}

Measured memory_bytes: 256
using System;
namespace C
{
    class Cmondai
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            String s = Console.ReadLine();
            int dst;
            int tdst = 0;
            for(int j=0;j<n;j++){
                if(s[j]=='.'){
                    tdst ++;
                }
            }
            dst = tdst;
            for(int i=0;i<n;i++){
                if(s[i]=='.'){
                    tdst --;
                }
                else{
                    tdst ++;
                }
                if(tdst<dst){
                    dst = tdst;
                }
            }
            Console.WriteLine(dst.ToString());
        }
    }
}

Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}


ll a[225816];
P b[225816];

int main(void){
	int n,i,k;
	ll ans=0ll;
	cin >> n >> k;
	for(i=1; i<=n; ++i){
		cin >> a[i];
	}
	for(i=0; i<n; ++i){
		a[i+1] += a[i];
	}
	for(i=0; i<=n; ++i){
		a[i] -= i;
		a[i] %= k;
		b[i] = P(a[i],i);
 	}
	sort(b,b+n+1);
	for(i=0; i<=n; ++i){
		ans += (ll)(lower_bound(b,b+n+1,P(a[i],i+k))-lower_bound(b,b+n+1,P(a[i],i+1)));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5376
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

MAX = 105000
primes = list()
for i in range(MAX):
    primes.append(True)
primes[0] = False
primes[1] = False

for i in range(2, MAX):
    j = i + i
    while j < MAX:
        primes[j] = False
        j = j + i

primeList = []
for i in range(len(primes)):
    if primes[i]:
        primeList.append(i)

while True:
    n = int(input())
    if n == 0:
        break
    ans = 0
    for i in range(n):
        ans += primeList[i]
    print(ans)


Measured memory_bytes: 6704
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim (lld)1e9+7
#define MAX2 (int)2e5+9
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const lld mod=lim;

lld power(lld x, lld y, lld p)  
{   lld res = 1;     x = x % p; if (x == 0) return 0;  
  
    while (y > 0)  
    { if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;   }  
    return res;  } 


int extend_gcd(int a, int b, int& x, int& y) {
    if (b == 0) { x = 1;y = 0;return a;}
    int x1, y1;
    int d = extend_gcd(b, a % b, x1, y1);
    x = y1; y = x1 - y1 * (a / b);return d;	}

int rowNum[]={-1,0,0,1};
int colNum[]={0,-1,1,0};

int main()
{
	fastio
	char c;
	cin>>c;

	if(c<97)
		cout<<'A'<<endl;

	else
		cout<<'a'<<endl;
}

Measured memory_bytes: 3608
# include <bits/stdc++.h>
using namespace std;
# define MOD 1000000007
typedef long long ll;
class box{
public:
    int w, s, v;
};
bool compare(box a, box b){
    return a.s + a.w < b.s + b.w;
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int n;
	cin>>n;
	box boxes[n];
	int MAXS = 0;
	for(int i=0;i<n;i++){
	    cin>>boxes[i].w>>boxes[i].s>>boxes[i].v;
	    MAXS = max(MAXS, boxes[i].w + boxes[i].s);
	}
	sort(boxes, boxes + n, compare);
// 	for(int i=0;i<n;i++){
// 	    cout<<boxes[i].w<<" "<<boxes[i].s<<" "<<boxes[i].v<<"\n";
// 	}
	ll dp[n+1][MAXS+1];
	for(int i=0;i<=n;i++){
	    for(int w=0;w<=MAXS;w++){
	        if(i == 0 or w == 0){
	            dp[i][w] = 0;
	        }
	        else if(w >= boxes[i-1].w and w<=boxes[i-1].w+boxes[i-1].s){
	            dp[i][w] = max(dp[i-1][w], dp[i-1][w-boxes[i-1].w] + boxes[i-1].v);
	        }else dp[i][w] = dp[i-1][w];
	    }
	}
	ll ans = 0;
	for(int w=0;w<=MAXS;w++){
	    ans = max(ans, dp[n][w]);
	}
	cout<<ans;
	return 0;
}

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

int main(){

    int tomadas_atuais,tomadas_vazias,cont=0;

    scanf("%d %d",&tomadas_atuais,&tomadas_vazias);
        if(tomadas_vazias==1){
            printf("0\n");
            return 0;
        }
            for(int i=1;i<21;i++){
              if((tomadas_atuais*i)-(i-1)>=tomadas_vazias){
                printf("%d\n",i);
                break;
              }
            }

    return 0;
}


Measured memory_bytes: 128
n=gets.to_i
a=gets.split.map(&:to_i)
b=gets.split.map(&:to_i).inject(:+)
c=gets.split.map(&:to_i)
(n-1).times do |i|
  if a[i]+1==a[i+1]
    b+=c[a[i]-1]
  end
end
p b

Measured memory_bytes: 1788
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
const int MaxN = 3000;

int ans[MaxN * MaxN + 5],x[MaxN * MaxN + 5],y[MaxN* MaxN + 5];

int main()
{
	int h,w,d,q,biu,l,r;
	while(~scanf("%d %d %d",&h,&w,&d))
	{
		for(int i = 1;i <= h;i++)
		{
			for(int j = 1;j <= w;j++)
			{
				scanf("%d",&biu);
				y[biu] = i;
				x[biu] = j;
			}
		}
		memset(ans,0,sizeof(ans));
		for(int i = 1;i <= h*w;i++)
		{
			biu = i+d;
			if(biu > h*w) break;
			ans[biu] += abs(x[i]-x[biu])+abs(y[i]-y[biu]);
			ans[biu] += ans[i];
		}
		scanf("%d",&q);
		for(int i = 1;i <= q;i++)
		{
			scanf("%d %d",&l,&r);
			printf("%d\n",ans[r]-ans[l]);
		}
	}
	return 0;
}

Measured memory_bytes: 39296
import math
n = int(input())
s = int(input())

if n == s:
    print(n+1)
    exit(0)
elif n < s:
    print(-1)
    exit(0)

def f(b,n):
    if n < b:
        return n
    else:
        return f(b,n//b) + n%b

for k in range(2,math.floor(math.sqrt(n))+2):
    if f(k,n) == s:
        print(k)
        exit(0)

P = [1,n-s]
for k in range(2,math.floor(math.sqrt(n-s))+1):
    if (n-s) % k == 0:
        P.append(k)
        P.append((n-s)//k)

P = sorted([p+1 for p in P])
for b in P:
    if f(b,n) == s:
        print(b)
        exit(0)
print(-1)

Measured memory_bytes: 43376
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int ans=1;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      ans=0;
      break;
    }
  }
  cout << (ans?"Yes":"No") << endl;
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(void)
{
	int i,j;
	int N, M;

	int a[50], b[50];
	int c[50], d[50];

	int dis, point;


	scanf("%d %d", &N, &M);

	for (i = 0; i < N; i++) {
		scanf("%d %d", &a[i], &b[i]);
	}
	for (i = 0; i < M; i++) {
		scanf("%d %d", &c[i], &d[i]);
	}

	for (i = 0; i < N; i++) {
		dis = abs(a[i] - c[0]) + abs(b[i] - d[0]);
		point = 0;
		for (j = 1; j < M; j++) {
			if (abs(a[i] - c[j]) + abs(b[i] - d[j]) < dis) {
				dis = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				point = j;
			}
		}
		printf("%d\n", point + 1);
	}

	return 0;
}


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

typedef long long int ll;
typedef long long unsigned int ull;
typedef long double ld;
typedef vector<int> vr;
typedef pair<int, int> pr;
#define pb push_back
#define ff first
#define ss second
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(2);


int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    string ans = "";
    while(n--){

        ans += 'a' + (char)(n % 26);
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=1e9+7;

bool Compare(int a, int b)
{
   return a < b;
}
priority_queue<int, vector<int>, function<bool(int, int)>> pq(Compare);

vi pr;
void seive(){
	int p[100005]={0};
	f(i,2,100005){
		if(p[i]==0){
			pr.pb(i);
			for(int j=i*2;j<100005;j+=i) p[j]=1;
		}
	}
}

// https://codeforces.com/blog/entry/79048



void solve(){
	int n; cin>>n;
	int a[n]; f(i,0,n) cin>>a[i];
	int r=0;
	f(i,1,n) if(a[i]<a[i-1]){
		r+=a[i-1]-a[i];
		a[i]=a[i-1];
	}
	cout<<r;
}


int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  int t=1; //cin>>t;
  while(t--) solve();
  return 0;
}
// check for overflows dummy !!!

Measured memory_bytes: 5216
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
//#define for(i,a,b) for(int i=(int)a;i<=(int)b;i++
using namespace std;
void solve()
{
	string s,r;
	
	cin>>s>>r;
	bool ok=true;
	for(int i=0;i<r.length()-1;i++)
	{
		if(s[i]!=r[i])
		{
			ok=false;
			break;
		}
	}
	if(ok)
	cout<<"Yes\n";
	else
	cout<<"No\n";
}
int main()
{
	//int t;cin>>t;
	//while(t--)
	solve();
}


Measured memory_bytes: 3624
using System;using System.Linq;using static System.Console;class P{static void Main(){var s=ReadLine();var n=int.Parse(ReadLine());for(string q=ReadLine();q!=null;q=ReadLine()){var r=q.Split();int a=int.Parse(r[1]),b=int.Parse(r[2]);if(q[2]=='i')WriteLine(s.Substring(a,-~b-a));if(q[2]=='v')s=s.Substring(0,a)+string.Join("",s.Substring(a,-~b-a).Reverse())+s.Substring(-~b);if(q[2]=='p'){s=s.Remove(a,-~b-a);s=s.Insert(a,r[3]);}}}}


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

int main() {
  int b,f,r,v;
  int n;
  cin >> n;
  
  vector<vector<vector<int> > > data(4, vector<vector<int> >(3, vector<int>(10,0)));
  
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    data.at(b-1).at(f-1).at(r-1) += v;
  }
    
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      
      for (int k = 0; k < 10; k++) {
        cout << ' ' << data.at(i).at(j).at(k);
        if (k == 9){
          cout << endl;
        }
      }
      
      if (j == 2 && i != 3) {
        cout << "####################" << endl;
      }
    }
  }
}


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

int d=1000000007;

long long pow_int(int a,int b,int c){//a^c mod b
  long long buf;
  if(c==1) return a;
  else{
    buf=pow_int(a,b,c/2)%b;
    buf=(buf*buf)%b;
  }
  if(c%2) buf=(buf*a)%b;
  return buf;
}
long long InvMod(int a,int b){//aのmod bでの逆元(a^b-2)
  return pow_int(a,b,b-2);
}


long long cul(int m,int j){//mCj
  if(j<0||m<j) return 0;
  if(j>m/2) j=m-j;
  long long r=1;
  for(int i=0;i<j;i++){
    r=(r*(m-i))%d;
    r=(r*InvMod(j-i,d))%d;
  }
  return r;
}

int main(){
  int i,n,k;
  long long ans;
  cin>>n>>k;
  n=n-k;
  for(i=0;i<k;i++){
    ans=0;
    if(n<i){
      for(i=i;i<k;i++) cout<<0<<endl;
      break;
    }
    ans=cul(n+1,i+1)*cul(k-1,i);
    cout<<ans%d<<endl;
  }
  return 0;
}

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

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

const int MAX = 5100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
  ll X, Y;
  cin >> X >> Y;
  if((X+Y) %3 != 0){
    cout << 0 << endl;
  } else {
    ll i = (2*Y - X)/3;
    ll j =(2*X - Y)/3;
    //cout << i << " " << j << endl;
    // 前処理
    COMinit();
    ll ans = COM(i+j, i);
    cout << ans << endl;
  }
}


Measured memory_bytes: 119808
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main(void)
{
  int a,b;

  cin >> a >> b;

  int ans = a + b;
  if(ans < a - b) ans = a - b;
  if(ans < a * b) ans = a * b;

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


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	resolve(os.Stdin)
}

func resolve(r io.Reader) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	a, b := scanInt(sc), scanInt(sc)
	n := (b + a - 3) / (a - 1)
	fmt.Println(n)
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


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

int main() {
  int H , W;
  cin >> H >> W;
  string s;
  
  s = "#";
  
  string str;
  for (int i= 0;i < W + 1;i++) {
    cout << s;
  }
  
  cout << s << endl;
  
  for (int i = 0;i < H;i++) {
    string A;
    cin >> A;
    cout << s << A << s << endl;
  }
  
  
  
  for (int i = 0;i < W +2;i++) {
    cout << s;
  }
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/15  Problem: 058_arc_b / Link: https://arc058.contest.atcoder.jp/tasks/arc058_b?lang=en ----- */
/* ------問題------

縦 H マス、横 W マスのマス目があります。 いろはちゃんは、今一番左上のマス目にいます。 そして、右か下に1マス移動することを繰り返し、一番右下のマス目へと移動します。 ただし、下から A 個以内、かつ左から B 個以内のマス目へは移動することは出来ません。
移動する方法は何通りあるか求めてください。
なお、答えは非常に大きくなることがあるので、答えは 109+7 で割ったあまりを出力してください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */


LL F[200005], R[200005];
long long  powmod(long long  x, long long  n, long long  MOD) {
	long long  res = 1;
	while (n > 0) {
		if (n & 1) {
			res = (res*x) % MOD;
		}
		x = (x*x) % MOD;
		n >>= 1;
	}
	return res;
}
void make() {
	F[0] = 1;
	for (int i = 1; i<200005; i++) F[i] = F[i - 1] * i%MOD;
	for (int i = 0; i<200005; i++) R[i] = powmod(F[i], MOD - 2, MOD);
}

LL nCr(int a, int b) {
	return F[a] * R[b] % MOD*R[a - b] % MOD;
}

LL H, W, A, B;
LL ans = 0LL;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	cin >> H >> W >> A >> B;
	make();
	FOR(h, 0, H - A) {
		ans += (nCr(B - 1 + h, B - 1) * nCr(W - 1 - B + H - 1 - h, W - 1 - B)) % MOD;
		ans %= MOD;
	}


	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3456
#include <stdio.h>

int n;
int A[2001];

int solve(int i,int m);

int main()
{
	int q,m,i;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	{
		scanf("%d",&A[i]);
	}
	scanf("%d",&q);
	for(i=0;i<q;i++)
	{
		scanf("%d",&m);
		if(solve(0,m))
		{
			printf("yes\n");
		}
		
		else printf("no\n");
	}
	return 0;
}

int solve(int i,int m)
{	
	if(m==0)
	{
		return 1;
	}
	
	if(i>=n)
	{
		return 0;
	}
	
	int res = solve(i+1,m) || solve(i+1,m-A[i]);
	
	return res;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f first
#define s second
#define pb push_back
#define mod 1000000007
ll dp[1<<22];
ll co(ll n)
{
  ll g=n;
  ll c=0;
  while(g>0)
  {
    c+=(g%2);
    g/=2;
  }
  return c;
}
void solve()
{
    ll n;
    cin>>n;
    ll g=1ll<<n;
    ll a[30][30];
    for(int x=0;x<n;x++)
    for(int y=0;y<n;y++)
      cin>>a[x][y];
    dp[0]=1;
      for(ll y=0;y<n;y++)
      {  for(ll x=0;x<g;x++)
         {  ll d=co(x);
          if(y+1==d)
          for(ll z=0;z<n;z++)
          {
             if(a[y][z]==1 && x&(1ll<<z))
             {
                  dp[x]+=dp[x^(1ll<<z)];
                  dp[x]%=mod;
             }
          }
      }
    }
  cout<<dp[g-1]<<"\n";
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll i=1;
  //cin>>i;
  ll k=0;
  while(k<i)
  {
       solve();
       ++k;
  }   
}
    

Measured memory_bytes: 18688
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 8000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};

typedef long long ll;

using namespace std;

int ans[111111],ans2;
int n,m;
string s;
signed main(){    
    
    cin>>s;
    int co=0,co2=0;
    rep(i,s.size()-1){
        if(s[i]=='R'){
            if(i%2==0)co++;
            else co2++;
        }
        if(s[i]=='R' && s[i+1]=='L'){
            if(i%2!=0){
                ans[i]+=co2;
                ans[i+1]+=co;
            }
            else{
                ans[i]+=co;
                ans[i+1]+=co2;
            }
            
            co=0;co2=0;
        }
    }
    co=0,co2=0;
    for(int i=s.size()-1;i>=1;i--){
        if(s[i]=='L'){
            if(i%2==0)co++;
            else co2++;
        }
        if(s[i-1]=='R' && s[i]=='L'){
            if(i%2!=0){
                ans[i]+=co2;
                ans[i-1]+=co;
            }
            else{
                ans[i]+=co;
                ans[i-1]+=co2;
            }
            co=0;co2=0;
        }
    }
    rep(i,s.size())cout<<ans[i]<<" ";
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int h,w;
    cin>>h>>w;
    string s[h],t[w];
    for(int i=0;i<h;i++){
        string ss;
        cin>>ss;
        s[i]=ss;
    }
    for(int i=0;i<w;i++){
        string ss;
        cin>>ss;
        t[i]=ss;
    }
    for(int i=0;i<h-w+1;i++){
        for(int j=0;j<h-w+1;j++){
            bool ok=true;
            for(int ii=0;ii<w;ii++){
                for(int jj=0;jj<w;jj++){
                    if(s[i+ii][j+jj]!=t[ii][jj])ok=false;
                }
            }
            if(ok){cout<<"Yes"<<endl;return 0;}
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int div(int n){
    int cnt = 0;
    rep(i, n){
        if(n%(i+1)==0) cnt++;
    }
    return cnt;
}

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    rep(i, n){
        if(i%2==0) {
            if(div(i+1)==8){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256