akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a) for(ll i=ll(a-1);i>=0;--i)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll MOD3 = 1e6;
const ll EPS = 1e-10;
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<long double,long double> point;
typedef complex<long double> Point;
const ll MAX = 1e9;
constexpr ll nx[4] = {-1,0,1,0};
constexpr ll ny[4] = {0,1,0,-1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    bool f = 0;
    if ((a <= 0 && 0 <= b) || (c <= 0 && 0 <= d)) f = 1;
    if (f) PRINT(max({a*c,a*d,b*c,b*d,0ll}));
    else PRINT(max({a*c,a*d,b*c,b*d}));
}


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

#define MEM(a, b) memset(a, b, sizeof a);
#define REP(i, k) for(int i = (0); i < (k); i++ )
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)

#define ALL(cont) cont.begin(), cont.end()
#define RALL(cont) cont.begin(), cont.end()
#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define INF (int)INT_MAX
#define EPS (int)1e-9
#define PI acos(-1)
#define MOD 1000000007

#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long L;
typedef unsigned long UL;
typedef long long LL;
typedef unsigned long long ULL;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

bool available_digits[11];
int dp1[200000];
vector<int> dp2[200000];
int f(int x, vector<int> &v) {
    if (x == 0) return 0;
    else if (x < 0) return -INF;
    else if (dp1[x] != -1) {
        v = dp2[x];
        return dp1[x];
    }
    else {
        int costs[20] = {/*0*/ -1, 2, 5, 5, 4, 5, 6, 3, 7, 6};

        int maxi = -1;
        FOR(i, 1, 9) {
            if (!available_digits[i]) continue;
            debug(x, i);
            vector<int> k;
            int d = f(x - costs[i], k);
            k.pb(i);
            if (maxi <= d + 1) {
                maxi = d + 1;
                v = k;
            }
        }
        dp1[x] = maxi;
        dp2[x] = v;
        debug(x, maxi, v);
        return maxi;
    }
}

void solve(__attribute__((unused)) int tc = 0) {
    int n, m, x;
    cin >> n >> m;
    MEM(available_digits, 0);
    MEM(dp1, -1);

    REP(_, m) { cin >> x; available_digits[x] = true; }
    vector<int> ans;
    f(n, ans);
    sort(ALL(ans));
    reverse(ALL(ans));
    FOREACH(it, ans) cout << *it;
    cout << endl;
    return;
}

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

    /*int TC;
      cin >> TC;
      REP(tc, TC) {
      solve(tc);
      }*/
    solve();
#ifdef TIME
    cout << "Execution time(second) : " << int(clock() * 1000.0 / CLOCKS_PER_SEC) << " ms" << endl;
#endif
}


Measured memory_bytes: 116608
def C():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    A_B = []
    for i in range(N):
        A_B.append(A[i] - B[i])

    A_B.sort()
    tmp = 0
    cnt = 0
    for i in range(N):
        if A_B[i] >= 0:
            break
        else:
            tmp += abs(A_B[i])
            cnt += 1

    A_B = A_B[::-1]

    for i in range(N):
        if tmp <= 0:
            break
        tmp -= A_B[i]
        cnt += 1

    if tmp > 0:
        cnt = -1
    print(cnt)
C()

Measured memory_bytes: 18524
/*input
5
4
2
*/
/*

  ####   #    #    ##    #####    ####           #    #
 #       #    #   #  #   #    #  #    #          #    #
  ####   ######  #    #  #    #  #    #          #    #
      #  #    #  ######  #    #  #    #          # ## #
 #    #  #    #  #    #  #    #  #    #          ##  ##
  ####   #    #  #    #  #####    ####  #######  #    #

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
using namespace std;
#define N  1000005
inline void solve()
{
	lld n,h,w;
	cin >> n >> h >> w;
	lld ans=0;
	rep(i,1,n+1)
	{
		rep(j,1,n+1)
		{
			if((i+h-1 <= n) && (j+w-1)<=n)
			{
				ans++;
			}
		}
	}
	cout << ans << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

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

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

    int A = 0;
    int B = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == 'A') A++;
        else B++;
    }

    if (A == 0 || B == 0) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
    }
}

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

int main(){
    double x1,y1,x2,y2;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    double r=pow(pow(x1-x2,2)+pow(y1-y2,2),0.5);
    printf("%lf\n",r);
}


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

int main() {
  string S;
  cin >>S;
  bool bg = true;
  for(int i=1;i<4;i++){
    if(S.at(i) == S.at(i-1)){
      bg= false;
      break;
    }
      
  }
  if(bg == true)
    cout << "Good" << endl;
  else
    cout << "Bad" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll N,ans=0;
  cin>>N;
  vector<string> vec(N);
  vector<char> v(10);
  unordered_map<char,ll> map;
  for(ll i=0;i<N;i++){cin>>vec.at(i);}
  for(ll i=0;i<N;i++){
    string str=vec.at(i);
    for(ll j=0;j<10;j++){v.at(j)=str.at(j);}
    sort(v.begin(),v.end());
    vec.at(i)=v.at(0);
    for(ll j=1;j<10;j++){vec.at(i)+=v.at(j);}
  }
  sort(vec.begin(),vec.end());
  for(ll i=0;i<N-1;i++){
    ll k=0;
    while(i+k+1<=N-1){
      if(vec.at(i+k+1)==vec.at(i+k)){k++;}
      else{break;}
    }
    ans+=k*(k+1)/2;
    i+=k;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 7296
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  set<int> se;
  rep(i,n)
  {
    int num;cin>>num;
    if(se.count(num))se.erase(num);
    else se.insert(num);
    
  }
  cout<<se.size()<<endl;
  return 0;

}


Measured memory_bytes: 4992
/* it was worth becoming a chemist */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long unll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const ll INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const db EPS = (db) 1e-9;
const db pi = acos(-1.0);
const int MAXN = 1e5 + 5;

string s;
ll res;


int main() {
  
    cin >> s;
    ll cts = 0, ctt = 0;
    res = sz(s);
    for (int i = 0; i < sz(s); i++) {
   		if (s[i] == 'S') {
   			if (ctt > 0) {
   				res -= (min(ctt, cts) * 2);
   				cts -= min(ctt, cts);
   				ctt = 0;
   			}
   			cts++;
   		}
   		else {
			if (cts > 0) {
				ctt++;
				if (cts == ctt) {
					res -= (ctt + cts);
					cts = 0;
					ctt = 0;
				}
			}
		}
   	}
   	if (cts > 0 && ctt > 0) {
		res -= (min(cts, ctt) * 2);   		
   	}
	cout << max(res, (ll)0);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll int
#define ld long double
#define fs first
#define sc second
#define task "tet"
using namespace std;
const ll N = 2e5 + 9;
const ll inf = 1e9 + 7;
typedef pair<ll,ll> LL;

ll a,b;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>a>>b;
    cout<<a*b;
}


Measured memory_bytes: 3656
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Integer min;
        Integer max = -2000000000;

        List<Integer> IntList = new ArrayList<Integer>();
        Scanner sc;
        sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0;i<n;i++) {
            IntList.add(Integer.parseInt(sc.next()));
        }

        min = IntList.get(0);
        for (int in = 1;in<IntList.size();in++) {
            max = Math.max(max,IntList.get(in) - min);
            min = Math.min(min,IntList.get(in));
        }

        System.out.println(max);

    }
}


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

int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> S(M, 0);
  vector<int> P(M);
  for (int i = 0; i < M; i++)
  {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++)
    {
      int s;
      cin >> s;
      s--;
      S.at(i) |= (1 << s);
    }
  }
  for (int i = 0; i < M; i++)
  {
    int p;
    cin >> p;
    P.at(i) = p;
  }

  int cnt = 0;
  // O((2^N)M)のアルゴリズム
  for (int i = 0; i < (1 << N); i++)
  {
    bool flag = true;
    for (int j = 0; j < M; j++)
    {
      if (__builtin_popcount(S.at(j) & i) % 2 != P.at(j))
      {
        flag = false;
        break;
      }
    }
    if (flag)
    {
      cnt++;
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N, W;
    cin >> N >> W;

    int value[110], weight[110];
    for (int i = 0; i < N; i++)
    {
        cin >> value[i] >> weight[i];
    }

    int dp[110][10010];
    for (int w = 0; w <= W; w++) dp[0][w] = 0;

    for (int i = 0; i < N; i++)
    {
        for (int w = 0; w <= W; w++)
        {
            if(w >= weight[i]) dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w]);
            else dp[i+1][w] = dp[i][w];
        }
    }

    cout << dp[N][W] << endl;
}


Measured memory_bytes: 7076
#include<stdio.h>

int main(){
  int n,a;
  scanf("%d%d",&n,&a);
  int i,ma,mi;
  ma=a;
  mi=a;
  for(i=1;i<n;i++){
    scanf("%d",&a);
    if(ma<a)ma=a;
    if(a<mi)mi=a;
  }
  printf("%d\n",ma-mi);
  return 0;
}


Measured memory_bytes: 128
/*#include <iostream>
using namespace std;

int main(){
	double a[8];
	while(cin >>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>a[5]>>a[6]>>a[7]){
		if((a[3]-a[1])*(a[7]-a[5])==-1*(a[2]-a[0])*(a[6]-a[4]))cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}*/
#include <iostream>
#include <math.h>
using namespace std;
int main(){
    double xa,ya,xb,yb,xc,yc,xd,yd;
    int a;
    while(cin>>xa>>ya>>xb>>yb>>xc>>yc>>xd>>yd){
        if(xa==xb){
            if(yc==yd) a=1;
            else a=2;
        }else if(xc==xd){
            if(ya==yb) a=1;
            else a=2;
        }else{
            double l=(yb-ya)/(xb-xa);
            double m=(yd-yc)/(xd-xc);
            if(fabs(l*m+1)<0.000001) a=1;
            else a=2;
        }
        switch(a){
        case 1:
            cout<<"YES"<<endl;
            break;
        case 2:
            cout<<"NO"<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3180
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  vector<int> a(n);
  int s = 0;
  rep(i, n) {
    cin>>a[i];
    s += a[i];
  }
  dump(a);
  dump(s);

  auto isright = [&](int k) {
    vi b(a);
    rep(i,n)b[i]+=k;
    int cnt=0;
    rep(i,n){
      cnt += ceil(b[i]-(n-1), n+1);
    }
    dump(k, cnt);
    if (k>=cnt) return true;
    else return false;
  };

  rep(i, max(s-2500, 0LL), s+2){
    if (isright(i)) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

using namespace std;

int n,m;
int ans;

int main()
{
    scanf("%d%d",&n,&m);
    if(abs(m + n) % 2)
        printf("IMPOSSIBLE\n");
    else
        printf("%d\n",abs(m + n) / 2);
    return 0;
}


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

int main() {
	int A, B, C;
	scanf("%d%d%d", &A, &B, &C);
	if (A+B+C == 17) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

#include <math.h>
#include <stdlib.h>


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

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
  int X, Y;
  cin >> X >> Y;

  cout << X + Y/2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <queue>

using namespace std;
const int N_MAX = 100;
const int INF = 1000000;
int H, W;
char maze[N_MAX+10][N_MAX+10] = {};
int d[N_MAX+10][N_MAX+10] = {};
int sx, sy;
int gx, gy;

typedef pair<int, int> P;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int bfs() {
  int i, j;
  queue<P> to_search;
  for (i = 0; i < H+2; i++) {
    for (j = 0; j < W+2; j++) {
      d[i][j] = INF;
    }
  }
  to_search.push(P(sx, sy));
  d[sx][sy] = 0;
  while (to_search.size() > 0) {
    P now = to_search.front();
    to_search.pop();
    if (now.first == gx && now.second == gy) {
      break;
    }
    for (i = 0; i < 4; i++) {
      int x = now.first + dx[i];
      int y = now.second + dy[i];
      if (d[x][y] == INF && maze[x][y] != '#') {
	to_search.push(P(x,y));
	d[x][y] = d[now.first][now.second] + 1;
      }
    }
  }
  return d[gx][gy];
}
     
int main() {
  int i, j;
  sx = 1;
  sy = 1;
  queue<int*> to_search;
  scanf("%d %d", &H, &W);
  gx = H;
  gy = W;
  for (i = 1; i < H+1; i++) {
    scanf("%s", maze[i]);
  }
  for (j = 0; j < W; j++) {
    maze[0][j] = '#';
    maze[H+1][j] = '#';
  }
  for (i = 0; i < H+2; i++) {
    string a = string(maze[i]);
    a = "#" + a;
    a = a + "#";
    for (j = 0; j < W+2; j++) {
      maze[i][j] = a.c_str()[j];
    }
  }
  /*for (i = 0; i < H+2; i++) {
    for (j = 0; j < W+2; j++) {
      if (maze[i][j] == 'S') {
	sx = i;
	sy = j;
      } else if (maze[i][j] == 'G') {
	gx = i;
	gy = j;
      }
      printf("%c", maze[i][j]);
    }
    printf("\n");
    }*/
  int count = 0;
  for (i = 1; i < H+1; i++) {
    for (j = 1; j < W+1; j++) {
      if (maze[i][j] == '.') {
	count += 1;
      }
    }
  }
  int ans = bfs();
  /*for (i = 0; i < H+2; i++) {
    for (j = 0; j < W+2; j++) {
      if (d[i][j] == INF) {
	printf("×");
      } else {
	printf("%d", d[i][j]);
      }
    }
    printf("\n");
    } */
  if (d[gx][gy] == INF) {
    printf("-1");
  } else {
    printf("%d", count-ans-1);
  }
  return 0;
}
  


Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void GetCubed(int num){
      int n = (int)Math.pow(num, 3);
      System.out.println(n);
    }

    public static void main(String[] args) throws IOException{
      BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
      String s = r.readLine();
      int num = Integer.parseInt(s);
      GetCubed(num);
    }
}

Measured memory_bytes: 24100
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

vector<ll> ans;

void countAns(const string& s, int c) {
  int lft = 0;
  int rgt = 0;
  while(rgt < s.size()) {
    if(s[rgt] == c) {
      rgt++;
      continue;
    }
    int l = rgt - lft;
    ans[rgt-1] += l - l / 2;
    ans[rgt] += l / 2;
    lft = rgt;
    while(lft < s.size()) {
      if(s[lft] != c) {
        lft++;
      }
      else {
        break;
      }
    }
    rgt = lft;
  }
}

signed main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = s.size();
  ans.resize(s.size());
  countAns(s, 'R');
  reverse(all(s));
  reverse(all(ans));
  countAns(s, 'L');
  REP(i, n) {
    cout << ans[n-1-i] << " ";
  }
  cout << endl;
  return 0; 
}


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

int main(){
	int solved = 0;
	int ans = 0;
	int input;
	int m, n;

	cin >> m >> n;

	for(int i=0; i < m; i++){
		solved = 0;
		for(int j=0; j < n; j++){
			cin >> input;
			if(input) solved++;
		}
		ans = max(solved, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

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

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N, K; cin >> N >> K;
  string S; cin >> S;

  vector<int> que;
  int n_zero = 0, n_one = 0;
  if (S[0] != '1') que.push_back(0);
  rep(i, N){
    if (S[i] == '0'){
      if (n_one != 0) que.push_back(n_one);
      n_zero++;
      n_one = 0;
    }
    else{
      if (n_zero != 0) que.push_back(n_zero);
      n_one++;
      n_zero = 0;
    }
    if (i == N - 1){
      if (S[i] == '0') que.push_back(n_zero);
      else que.push_back(n_one);
    }
  }
  vector<int> s((int)que.size() + 1, 0);
  rep(i, (int)que.size()) s[i + 1] = s[i] + que[i];
  int ans = 0;
  for (int left = 0; left < s.size(); left += 2){
    int right = left + K * 2 + 1;
    if (right >= s.size()) right = (int)s.size() - 1;
    ans = max(ans, s[right] - s[left]);
  }
  cout << ans << endl;
  /*
  rep(i, (int)que.size()) cout << que[i] << " ";
  cout << endl;
  rep(i, (int)s.size()) cout << s[i] << " ";
  cout << endl;*/

}


Measured memory_bytes: 1272
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n>> m;
  vector<int> v(m);
  rep(i, m) cin >> v[i];
  ll sum = 0;
  rep(i, m) sum+=v[i];
  ll res = n - sum;
  if(res >= 0) cout << res << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 3684
#include <iostream>
#include <sstream>
#include <stdio.h>
//#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;

int main(void)
{
	lli N, P; cin >> N >> P;
	lli odd = 0;
	rep(i, 0, N) {
		int tmp; cin >> tmp;
		odd += (tmp % 2);
	}
	lli C_even = pow(2, N - odd);

	lli ans = 0, tmp = 0;
	for (lli r = P; r <= odd; r += 2) {
		if (r == 0)tmp = 1;
		else if (r == 1)tmp = odd;
		else tmp = ((lli)odd - r + 1) * ((lli)odd - r + 2) * tmp / r / (r - 1);
		ans += tmp;
	}
	ans *= C_even;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
using ll=long long;
ll bs[21];
ll as[21];

int main(){ _;
  int n,m;
  ll c;
  cin>>n>>m>>c;
  REP(i,m) cin>>bs[i];
  int result = 0;
  REP(z,n){
    ll sm=c;
    REP(i,m){
      cin>>as[i];
      sm+=as[i]*bs[i];
    }
    if (sm>0LL)result++;
  }
  cout<<result<<endl;
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	string s, t;
	cin >> s;
	cin >> t;

	int ans = 0;
	REP(i,3){
		if(s[i] == t[i]) ans++;
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define ll long long int
#define ld long double
#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)

using namespace __gnu_pbds;
using namespace std;

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

//template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

#ifdef LOCAL
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif


std::mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int ri(int a, int b) {
    return uniform_int_distribution<int>(a, b)(rng);
}

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

const ll INF = (ll)(8e18);
const ll MOD = (ll)(1e9 + 7);
const ll HMOD = (ll)4222234727;
const ll Hashprime = (ll)31;

const int maxn = 100100;

int32_t main(){
    IOS;
    #ifndef ONLINE_JUDGE
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    int t = 1; // cin >> t;
    while(t--){
      string s; cin >> s;
      if(s.back() == 's') s += "es";
      else s += "s";
      cout << s << '\n';
    }
    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}
//g++ -DLOCAL -std=c++17 -Wshadow -Wall -o "c" "comp.cpp" -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define sc(a) scanf("%d",&a)
#define scl(a) scanf("%lld",&a)
#define ll long long
#define pb push_back
#define mkp make_pair
#define inf 1e9
#define rn 100007
#define ppi pair<int,int>
#define mod 1000000007

ll n,k,dp[100007][103];
struct stt
{
    ll w,v;
};
stt ara[100007];
bool cmp(stt a,stt b)
{
    return b.v*a.w<a.v*b.w;
}
ll fun(ll wt,ll i)
{
    if(wt>=k||i>=n)
        return 0;
    if(dp[wt][i]!=-1)
        return dp[wt][i];
    ll mx=-1;
    if(wt+ara[i].w<=k)
        mx=max(fun(wt+ara[i].w,i+1)+ara[i].v,fun(wt,i+1));
    else
        mx=fun(wt,i+1);

    return dp[wt][i]=mx;
}
int main()
{
    cin>>n>>k;
    memset(dp,-1,sizeof dp);
    for(ll i=0; i<n; i++)
        cin>>ara[i].w>>ara[i].v;
    sort(ara,ara+n,cmp);
    cout<<fun(0,0)<<endl;

}


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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 200010, M = 1010;

int n;
int a[N];

int main()
{
	scanf("%d", &n);
	
	int t = 1;
	for (int i = 0; i < n; i ++ )
	{
		scanf("%d", &a[i]);
		if (a[i] == t) t ++ ;
	}
	t -- ;

	if (t == 0) puts("-1");
	else printf("%d\n", n - t);
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>

class Dice{
    private:
        int t, b, n, e, s, w;
    public:
        void roll(char d);
        void showEast(){printf("%d\n", e);}
        int getT(){return t;}
        int getB(){return b;}
        int getN(){return n;}
        int getS(){return s;}
        int getE(){return e;}
        int getW(){return w;}
        Dice(int t, int s, int e, int w, int n, int b) : t(t), s(s), e(e), w(w), n(n), b(b) {}
        Dice(Dice &a) : t(a.t), s(a.s), e(a.e), w(a.w), n(a.n), b(a.b) {}
};

void Dice::roll(char d){
    int tmp = 0;
    if (d == 'S') {
        tmp = s;
        s = t;
        t = n;
        n = b;
        b = tmp;
    }else if (d == 'E') {
        tmp = e;
        e = t;
        t = w;
        w = b;
        b = tmp;
    }else if (d == 'N') {
        tmp = n;
        n = t;
        t = s;
        s = b;
        b = tmp;
    }else if (d == 'W'){
        tmp = w;
        w = t;
        t = e;
        e = b;
        b = tmp;
    }else if (d == 'C'){    // Clockwise
        tmp = n;
        n = w;
        w = s;
        s = e;
        e = tmp;
    }else if(d == 'U'){     // Unti-Clockwise
        tmp = s;
        s = w;
        w = n;
        n = e;
        e = tmp;
    }
}

int main(){
    int a, b, c, d, e, f, q, t, s;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
    Dice dice(a, b, c, d, e, f);
    scanf("%d", &q);
    for(int i = 0; i < q; i++){
        scanf("%d %d", &t, &s);
        if(t == dice.getB()){
            dice.roll('S');
            dice.roll('S');
        }else if(t == dice.getE()){
            dice.roll('W');
        }else if(t == dice.getW()){
            dice.roll('E');
        }else if(t == dice.getN()){
            dice.roll('S');
        }else if(t == dice.getS()){
            dice.roll('N');
        }
        while(s != dice.getS()){
            dice.roll('C');
        }
        dice.showEast();
    }
    return 0;
}


Measured memory_bytes: 2712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    // 予選通過者の数pass, 海外学生の数fnum，海外学生の予選通過ラインfpts
    ll n, a, b;
    cin >> n >> a >> b;
    ll pass = 0, fnum = 0;
    string s;
    cin >> s;
    rep(i, 0, n){
        auto cur = s[i];
        if(cur == 'a'){
            if(pass < a + b){
                cout << "Yes" << endl;
                pass++;
            }else{
                cout << "No" << endl;
            }
        }
        if(cur == 'b'){
            if(pass < a + b && fnum < b){
                cout << "Yes" << endl;
                fnum++;
                pass++;
            } else {
                cout << "No" << endl;
            }
        }
        if(cur == 'c') {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
 
   
int main(){
    int a,b,c;
    cin >> a >> b >>c ;
    set<int> d;
    d.insert(a);
    d.insert(b);
    d.insert(c);
    cout << d.size() << endl;
    }

Measured memory_bytes: 3628
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string S;

    cin >> S;

    if (S[0] == S[1] && S[1] == S[2])
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include<iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	string str;cin >> str;
	
	ll n = str.size()-1;
	
	ll ans = 0;
	
	REP(i,(1<<n))
	{
		ll tmp = 0;
		REP(j,str.size())
		{
			tmp *= 10;
			tmp += str[j] - '0';
			if(i & (1<<j))
			{
				ans += tmp;
				tmp = 0;
			}
		}
		ans += tmp;
	//	cout << ans << endl;
	}
	
	cout << ans << endl;
	
	return 0;
}

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

const int mx = 100005,inf = 1e18;
int dp[mx][3];

struct node{
    int a;
    int b;
    int c;
};

main()
{
    int n;
    cin>>n;
    vector<node> v(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>v[i].a>>v[i].b>>v[i].c;
    }
    for(int i=1;i<=n;i++)
    {
        dp[i][0] = max(dp[i-1][1],dp[i-1][2])+v[i].a;
        dp[i][1] = max(dp[i-1][0],dp[i-1][2])+v[i].b;
        dp[i][2] = max(dp[i-1][0],dp[i-1][1])+v[i].c;
    }
    int ans = max(dp[n][0],max(dp[n][1],dp[n][2]));
    cout<<ans;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define p_b push_back
#define MOD 1000000007

vector<ll> v[300005] ;
ll marked[300005];
ll dist[300005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ;
    ll n,m;
    cin >> n >> m ;
    while(m--)
    {

        ll a,b;
        cin >> a >> b ;
        v[a].p_b(n+b);
        v[a+n].p_b(b+n+n);
        v[a+n+n].p_b(b);

    }
    ll x,y;
    cin >> x >> y;

    // do the bfs

    queue <ll> q;
    q.push(x);
    marked[x] = 1;
    ll counter = 0;
    while(!q.empty())
    {
        ll temp = q.front();
        q.pop();
        counter = dist[temp] + 1;
        //cout << counter << endl;
        //cout << temp << endl;


        for(auto idx:v[temp] )
        {

            if(marked[idx])
            {

                continue;
            }
            else
            {
                if(idx == y)
                {

                    cout << counter/3 << endl;
                    return 0;


                }

                marked[idx] = 1;
                dist[idx] = counter;
                q.push(idx);

            }
        }

    }


    cout << -1 << endl;




    return 0;
}


Measured memory_bytes: 21376
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define pb push_back
#define ALL(v) v.begin(),v.end()
const long long INF = 1LL << 60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
using P = pair<int, int>;
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; }
using Graph = vector<vector<int>>;
int main()
{
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N);
    rep(i, N){
        cin >> C[i];
        rep(j, M){
            int a;
            cin >> a;
            A[i].pb(a);
        }
    }
    ll inf = 1e18;
    ll ans =inf;
    for(ll cond = 1 ; cond < 1<<(N+1) ; ++cond){
        vector<int> B(M, 0);
        ll cost = 0;
        rep(i, N)
        {
            if(!(cond &(1<<i))) continue;
            rep(j, M) B[j] += A[i][j];
            cost += C[i];
        }
        bool ok = true;
        rep(i, M){
            if(B[i] < X) ok = false;
        }
        if(ok){
            chmin(ans, cost);
        }
    }
    if(ans != inf) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3596
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

X, A = map(int, raw_input().split())
if X < A:
    print 0
else:
    print 10

Measured memory_bytes: 2808
def solve():
    n,k = map(int,input().split())
    d = set(map(int,input().split()))
    for i in range(n,100000):
        s = map(int,str(i))
        flag = True
        for j in s:
            if j in d:
                flag = False
        if flag:
            print(i)
            return

if __name__ == "__main__":
    solve()

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

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> ns(n);
	for(int i=0;i<n;i++){
		cin >> ns[i];
	}
	int v;
	priority_queue<int> q;
	for(int i=0;i<n;i++){
		cin >> v;
		q.push(ns[i]-v);
	}
	int ans = 0;
	while(!q.empty()){
		v=q.top();
		q.pop();
		if(v<=0) break;
		ans+=v;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())

ans = float("inf")
for i in range(1, H):
    h = H - i
    s1 = [i * W, h // 2 * W, (h - h // 2) * W]
    if 0 not in s1: ans = min(ans, max(s1)-min(s1))
    s2 = [i * W, W // 2 * h, (W - W // 2) * h]
    if 0 not in s2: ans = min(ans, max(s2) - min(s2))

for i in range(1, W):
    w = W - i
    s1 = [i * H, w // 2 * H, (w - w // 2) * H]
    if 0 not in s1: ans = min(ans, max(s1)-min(s1))
    s2 = [i * H, H // 2 * w, (H - H // 2) * w]
    if 0 not in s2: ans = min(ans, max(s2) - min(s2))

print(ans)


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

using namespace std;

int main(void){
    int n;
    cin >> n;
    int cost = 0;
    int arr[n] = {0};
    for (int i=0;i<n;i++){
        cin >> arr[i];
    }

    vector <int> dp(n, INT_MAX);
    dp[0] = 0;
    for(int i=1;i<n;i++){
        if (i-2 >= 0){
            dp[i] = min((dp[i-1]+abs(arr[i] - arr[i-1])), (dp[i-2]+abs(arr[i] - arr[i-2])));
        }else{
            dp[i] = min((dp[i-1]+abs(arr[i] - arr[i-1])), dp[i]);
        }
    }
    cout << dp[n-1] << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <iterator>
#include <iostream>
#include <set>
#include <cassert>
#include <algorithm>
#include <vector>
using namespace std;

vector<int> flowers;
int mizuya(int r, int m)
{
    if (r == m)
    {
        return flowers[r];
    }

    int min, minIdx;
    min = 1000;
    for (int i = r; i <= m; i++)
    {
        if (min > flowers[i])
        {
            min = flowers[i];
            minIdx = i;
        }
    }
    for (int i = r; i <= m; i++)
    {
        flowers[i] -= min;
    }
    if (minIdx == r)
    {return min + mizuya(minIdx + 1, m);
    }
    else if (minIdx == m)
    {return min + mizuya(r, minIdx - 1);
    }
    else
    {
        return min + mizuya(r, minIdx - 1) + mizuya(minIdx + 1, m);
    }
}
int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int hi;
        cin >> hi;
        flowers.push_back(hi);
    }
    cout << mizuya(0, N - 1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
    ll N, T, t[200000], X = 0;
    cin >> N >> T >> t[0];
    for (int i = 1; i < N; i++) {
        cin >> t[i];
        if (t[i] - t[i-1] < T) X += t[i] - t[i-1];
        else X += T;
    }
    X += T;
    cout << X << endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mod=1e9+7;
ll N,K;
vector<ll> v;
ll memo[109][100009];
bool vis[109][100009];
ll sol(int pos,int p){
  if(p<0)return 0;
  if(p==0)return 1;
  if(pos==N)return 0;
  ll t=0;
  if(vis[pos][p])return memo[pos][p];
  vis[pos][p]=1;
  //t+=sol(pos+1,p);
  for(int i=0;i<=v[pos];i++){
    t+=sol(pos+1,p-i);
  }
  return memo[pos][p]=(sol(pos+1,p)+sol(pos,p-1)-sol(pos+1,p-1)+mod)%mod;
}
signed main(){
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
		cin>>N>>K;
		for(ll i=0;i<N;i++){
      ll a;
      cin>>a;
      v.push_back(a);
		}
		for(int i=0;i<=K;i++)memo[N][i]=1;
		for(int i=N-1;i>=0;i--){
      for(int j=0;j<=K;j++){
        ll f=0;
        if(j-v[i]>0)f=memo[i+1][j-v[i]-1];
        memo[i][j]=memo[i+1][j]-f;
        if(j>0)memo[i][j]+=memo[i][j-1];
        memo[i][j]%=mod;
      }
		}
		cout<<(memo[0][K]-(K>0?memo[0][K-1]:0)+mod)%mod;
    return 0;
}

Measured memory_bytes: 80128
C = [list(map(int, input().split())) for _ in range(3)]

l1 = C[0]
l2 = C[1]
if not(l2[0] - l1[0] == l2[1] - l1[1] == l2[2] - l1[2]):
	print("No")
	exit()

l1 = C[0]
l2 = C[2]
if not(l2[0] - l1[0] == l2[1] - l1[1] == l2[2] - l1[2]):
	print("No")
	exit()

print("Yes")


Measured memory_bytes: 3064
#70b
A,B,C,D = map(int, input().split())

if A<=C<=B:
    if A<=D<=B:
        print(D-C)
    else:
        print(B-C)
elif C<=A<=D:
    if C<=B<=D:
        print(B-A)
    else:
        print(D-A)
else:
    print(0)

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;
type I = usize;
const MOD: usize = 1e9 as usize + 7;

fn main() {
    input!{
      n: usize,
      ss: chars,
    }
    let mut chr = vec![0; 27];
    for i in 0..n {
        let s = ss[i] as usize - 'a' as usize;
        chr[s] += 1;
    }

    let mut ans = 1;
    for i in 0..chr.len() {
        if chr[i] > 0 {
            ans *= (chr[i]+1);
            ans %= MOD;
        }
    }
    println!("{}", ans-1);
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
#define MAX 2000000
#define L 14

char data[MAX][L];
int getChar(char ch){
  if(ch=='A') return 1;
  else if(ch=='C') return 2;
  else if(ch=='G') return 3;
  else if(ch=='T') return 4;
  else return 0;
}

long long getKey(char str[]){
  long long sum=0,p=1,i;
  for (i=0;i<strlen(str);i++){
    sum+=p*(getChar(str[i]));
    p*=5;
  }
  return sum;
}

int h1(int key){return key%MAX; }
int h2(int key){return 1+(key%(MAX-1)); }

int find(char str[]){
    long long x,i,t;
    x=getKey(str);
    for(i=0;;i++){
        t=(h1(x)+i*h2(x))%MAX;
        if(strcmp(data[t],str)==0)return 1;
        else if(strlen(data[t])==0)return 0;
    }
  return 0;
}

int insert(char str[]){
    long long x,i,t;
    x=getKey(str);
    for(i=0;;i++){
        t=(h1(x)+i*h2(x))%MAX;
        if(strcmp(data[t],str)==0)return 1;
        else if(strlen(data[t])==0){
            strcpy(data[t],str);
            return 0;
        }
    }
  return 0;
}

int main(){
    int i,n,h;
    char str[L],com[9];
    for(i=0;i<MAX;i++) data[i][0]='\0';
    scanf("%d",&n);
    for(i=0;i<n;i++){
    scanf("%s %s",com,str);
    if(com[0]=='i' ){
      insert(str);
    }else{
        if (find(str)){
            printf("yes\n");
        }else {
            printf("no\n");
        }
    }
  }
    return 0;
}


Measured memory_bytes: 29132
#include <stdio.h>
int main(){
	long long n;
	for(;~scanf("%lld",&n)&&n;){
		long long r=0;
		int i=2;
		for(;;i++){
			long long x=n-(long long)i*(i-1)/2;
			if(x<i)break;
			if(x%i==0)r++;
		}
		printf("%lld\n",r);
	}
	return 0;
}

Measured memory_bytes: 1008