akhauriyash/Code-Regression huggingface dataset:
/*
    Author - Param Kothari
    Ah shit, here we go again
*/
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair 
 
typedef long long ll;
typedef long double ld;

const ll MOD = 1000000007;

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

ll ncr(ll n, ll k){
    if(k > n - k){
        k = n - k;
    }
    ll res = 1, num = 1, den = 1;
    for(int i = 0; i < k; i++){
        num = (num * (n - i)) % MOD;
        den = (den * (i + 1)) % MOD;
    }
    res = num * modp(den, MOD - 2, MOD);
    return res % MOD;
}

void solve(){
    ll n = 0, a = 0, b = 0;
    cin >> n >> a >> b;
    ll res = modp(2, n, MOD);
    res = (res % MOD) - 1;
    ll diff1 = ncr(n, a);
    ll diff2 = ncr(n, b);    
    //cout << res << " " << diff1 << " " << diff2 << "\n";
    cout << (res - diff1 - diff2 + MOD + MOD) % MOD << "\n";
    return;
}
 
int main(){
    IOS;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
s = input().rstrip()
ans = 1
i = 0
left = 0
right = 1
while i < n:
    if k > 0:
        pos = s.find('01', i)
        if pos == -1:
            i = n
            right = n - 1
        else:
            pos = s.find('10', pos + 1)
            if pos == -1:
                i = n
                right = n - 1
            else:
                right = pos
                i = pos + 1
        k = k - 1
        ans = max(ans, right - left + 1)
    else:
        pos = s.find('01', left)
        left = pos + 1
        k = k + 1

print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl '\n'
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<" "
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define inf 100000000000000000
#define sp << " " <<
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);

ll arr[22][22],n;
unordered_map <ll,ll> dp;

ll feel(ll curr)
{
    if(dp.count(curr))
        return dp[curr];
    if(curr+1==(ll)pow(2,n))
        return 1;
    ll temp=0;
    fr(i,0,n)
    {
        if(!(curr&(1<<i)) && arr[__builtin_popcount(curr)][i])
        {
            temp+=feel(curr|(1<<i));
            temp%=md;
        }
    }
    dp[curr]=temp;
    return temp;
}

int main()
{
    fast;
    cin >> n;
    fr(i,0,n)fr(j,0,n)cin >> arr[i][j];
    cout << feel(0);
}

Measured memory_bytes: 82512
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int A = Integer.parseInt(sc.get());
		int V = Integer.parseInt(sc.get());
		int B = Integer.parseInt(sc.get());
		int W = Integer.parseInt(sc.get());
		int T = Integer.parseInt(sc.get());
		int length = Math.abs(A - B);
		if (V == W) {
			System.out.println("NO");
			return;
		}
		var time = -Math.floorDiv(-length, (V - W));
		System.out.println(time > 0 && T >= time ? "YES" : "NO");
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 32832
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>

#define ll long long
#define pll pair<ll, ll>

#define reps(i, f, n) for (int i = (f); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

const int INF = 1111111111;
const double EPS = 1e-9;

using namespace std;

void init()
{
}

void solve()
{
	const int ALPH = 26;

	ll n;
	cin >> n;

	int keta = 0;
	ll ketaMul = 1;

	while (true)
	{
		if (ketaMul > n)
		{
			break;
		}

		n -= ketaMul;

		keta++;
		ketaMul *= ALPH;
	}

	string ans = "";

	rep(i, keta)
	{
		ll mod = n % ALPH;
		n /= ALPH;

		string s = string(1, 'a' + mod);
		ans = s + ans;
	}

	cout << ans << endl;
}

int main()
{
	init();
	solve();
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int H,W,h,w;
  cin>>H>>W>>h>>w;
  int a[H][W];
  memset(a,0,sizeof(a));

  int x=1000000000/(w*h);
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      a[i][j]=x;

  for(int i=h-1;i<H;i+=h){
    for(int j=w-1;j<W;j+=w){
      a[i][j]=-(x*(h*w-1)+1);
    }
  }
  
  bool flg=1;
  int b[H+1][W+1];
  memset(b,0,sizeof(b));
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      b[i+1][j+1]=b[i+1][j]+a[i][j];
  for(int i=0;i<H;i++)
    for(int j=0;j<=W;j++)
      b[i+1][j]+=b[i][j];
  
  for(int i=0;i<=H-h;i++){
    for(int j=0;j<=W-w;j++){
      int tmp=b[i+h][j+w]-b[i][j+w]-b[i+h][j]+b[i][j];
      flg&=tmp<0;
    }
  }

  int cnt=0;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      cnt+=a[i][j];

  if(!flg||cnt<=0){
    cout<<"No"<<endl;
    return 0;
  } 

  cout<<"Yes"<<endl;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(j) cout<<" ";
      cout<<a[i][j];
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int a;
  cin >> a;
  
  if ((a/1000==a/100%10 && a/1000==a/10%10)||(a%10==a/100%10 && a%10==a/10%10))
  {cout<<"Yes"<<endl;}
 
 else {cout<<"No"<<endl;}
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int n;
long long m,a,r,c,h;
vector<long long> D(5);
string s;
int P[10] = {0,0,0,0,0,0,1,1,1,2};
int Q[10] = {1,1,1,2,2,3,2,2,3,3};
int R[10] = {2,3,4,3,4,4,3,4,4,4};

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
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;
}

void solve() {
    for (int i = 0; i < n; ++i) {
        cin >> s;
        if (s[0] == 'M') m++;
        if (s[0] == 'A') a++;
        if (s[0] == 'R') r++;
        if (s[0] == 'C') c++;
        if (s[0] == 'H') h++;
    }
    D[0] = m, D[1] = a, D[2] = r, D[3] = c, D[4] = h;
    long long ans = 0;
    for (int i = 0; i < 10; ++i) {
        ans += (D[P[i]] * D[Q[i]] * D[R[i]]);
    }
    cout << ans << endl;
    return;
}

int main() {
    cin >> n;
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
const int lim =  1e6;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    vector<vector<int>> fac(lim + 1);
    vector <bool> p(lim + 1, 1);
    vector <int> sth(lim + 1, 0);
    for(int i = 2; i <= lim; i++){
        fac[i].pb(i);
        if(p[i]) for(int j = 2*i; j <= lim; j += i){
            p[j] = 0;
            fac[j].pb(i);
        }
    }
    int n; cin >> n;
    vector <int> v(n);
    for(int &x: v) cin >> x;
    for(int x: v){
        //cout << fac[x].size() << "\n";
        for(int y: fac[x]){
            sth[y]++;
            //cout << y << "\n";
        }
    }
    int g = v[0];
    for(int i = 1; i < v.size(); i++) g = __gcd(g, v[i]);
    bool bl = 1;
    for(int i = 2; i <= lim; i++) if(sth[i] > 1) bl = 0;
    //cout << sth[5] << '\n';
    if(bl) cout << "pairwise coprime\n";
    else if(g == 1) cout << "setwise coprime\n";
    else cout << "not coprime\n";
}


Measured memory_bytes: 72884
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        char[][] a = new char[h][w];
        for (int i = 0; i < h; i++) {
            a[i] = sc.next().toCharArray();
        }
        sc.close();

        // 主処理
        List<Integer> skipIndexListX = new ArrayList<>();
        List<Integer> skipIndexListY = new ArrayList<>();

        for (int i = 0; i < h; i++) {
            boolean isSkipLine = true;
            for (int j = 0; j < w; j++) {
                if (a[i][j] == '#') {
                    isSkipLine = false;
                    break;
                }
            }
            if (isSkipLine) {
                skipIndexListY.add(i);
            }
        }

        for (int i = 0; i < w; i++) {
            boolean isSkipLine = true;
            for (int j = 0; j < h; j++) {
                if (a[j][i] == '#') {
                    isSkipLine = false;
                    break;
                }
            }
            if (isSkipLine) {
                skipIndexListX.add(i);
            }
        }

        List<String> lineList = new ArrayList<>();
        for (int i = 0; i < h; i++) {
            if (!skipIndexListY.contains(i)) {
                String line = "";
                for (int j = 0; j < w; j++) {
                    if (!skipIndexListX.contains(j)) {
                        line += a[i][j];
                    }
                }
                if (0 < line.length()) {
                    lineList.add(line);
                }
            }
        }

        String result = String.join("\n", lineList);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 27268
#include<bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopb(i,a,b) for(int i=a;i>=b;i--)
#define loopm(i,a,b,step) for(int i=a;i<b;i+=step)
#define loopbm(i,a,b,step) for(int i=a;i>=b;i-=step)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define INF 1000000007
#define MOD 1000000007
#define BINF 1000000000000000001
#define int long long int
#define double long double

using namespace std;

#undef int
int main()
{
#define int long long int
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x,y;
    cin>>x>>y;
    if(x==y)
     cout<<-1;
    else
    {
        if(x==1)
         cout<<y+1;
        else
        {
            if(x<y)
             cout<<x;
            else
            {
                if(x%y==0)
                 cout<<-1;
                else
                 cout<<x;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;

Int GCD(Int a, Int b){
if(b==0) return a;
if(a < b) return GCD(b, a);
unsigned r;
while ((r=a%b)) {
a = b;
b = r;
}
return b;
}

int main() {
    int N,M,C;
    cin >> N >> M >> C;
    vi B = vi(M);
    vvi A = vvi(N,vi(M,0));

    rep(i,M){
        cin >> B[i];
    }
    rep(i,N){
        rep(j,M){
            cin >> A[i][j];
        }
    }

    int ans = 0;
    rep(i,N){
        int tmp =0;
        rep(j,M){
            tmp+=A[i][j]*B[j];
        }
        if(tmp+C>0){
            ans++;
        }
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
BFSでなるべく広くとればいい？
.....
.#.#.
.....
.#.#.
.....

00000
01122
00000
03344
00000

00000
11122
00000
33344
00000

00000
11122
11122
33344
33344

11122
11122
11122
33344
33344

.#..#
.#.#.
###..
.#.#.
.....

01112
03344
56777
08899
00000

11112
33344
56777
88899
00000

11112
33344
56777
88899
88899
なんかいけそう

*/
int main(){
  ll H,W,K; cin>>H>>W>>K;
  vector<vector<char>> Z(H+10, vector<char>(W+10,'x'));
  vector<vector<ll>> A(H+10, vector<ll>(W+10,0));
  for(ll y=1; y<=H; y++) for(ll x=1; x<=W; x++) cin>>Z[y][x];
  //→
  ll high=0;
  for(ll y=1; y<=H; y++){
    ll k=0;
    for(ll x=1; x<=W; x++){
      if(Z[y][x]=='.') A[y][x]=k;
      else if(Z[y][x]=='#'){
        high++;
        k=high;
        A[y][x]=k;
      }
    }
  }
  //←
  for(ll y=H; y; y--) for(ll x=W; x; x--) if(A[y][x]==0) A[y][x]=A[y][x+1];
  //↓  
  for(ll x=1; x<=W; x++) for(ll y=1; y<=H; y++) if(A[y][x]==0) A[y][x]=A[y-1][x];
  //↑
  for(ll x=W; x; x--) for(ll y=H; y; y--) if(A[y][x]==0) A[y][x]=A[y+1][x];  
  for(ll y=1; y<=H; y++){
    for(ll x=1; x<=W; x++){
      cout<<A[y][x];
      if(x<W) cout<<" ";
    }
    cout<<endl;
  }
}

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

using namespace std;

#define int long long
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint int t;cin>>t;while(t--)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>

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

    if((a==b&&a!=c)||(b==c&&b!=a)||(a==c&&a!=b)){
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define MAX 1000000
using namespace std;

int N;


int main()
{
    int N;
    int X[MAX];
    int sumX = 0;
    int minX = 100;
    int maxX = 1;

    cin >> N;
    for(int i = 0; i < N; i++){
      cin >> X[i];
      sumX += X[i];

      if(X[i] < minX){
        minX = X[i];
      }else if(X[i] > maxX){
        maxX = X[i];
      }
    }

    int ave = sumX / N;

    int minsum = 100000000;
    int minpos = -1;
    for(int x = minX; x <= maxX; x++){
      int sum = 0;
      for(int i = 0; i < N; i++){
        sum += (x - X[i]) * (x - X[i]);
      }
      if(sum < minsum){
        minsum = sum;
        minpos = x;
      }
    }

    cout << minsum << endl;
}


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

int main() {
	cin.tie(nullptr); ios::sync_with_stdio(false);
	int64_t H, W;
	cin >> H >> W;
	int64_t ans = INT64_MAX;
	auto diff = [](initializer_list<int64_t> l){
		return max(l) - min(l);
	};
	auto calc = [&]() {
		for(int i = 0; i < H; ++i) {
			if(W % 2 != 0 && (H - i) % 2 != 0) {
				ans = min(ans, diff({i * W, (H - i) / 2 * W, (H - i) / 2 * W + W}));
				ans = min(ans, diff({i * W, W / 2 * (H - i), (W / 2 + 1) * (H - i)}));
			} else ans = min(ans, diff({i * W, W * (H - i) / 2}));
		}
	};
	calc();
	swap(W, H);
	calc();
	cout << ans << endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
P, C = [list(map(int, input().split())) for _ in range(2)]
c = [1] * N
m = [[0] * (N+1) for i in range(N)]
for i in range(N):
    m[i][1] = (C[P[i]-1])
ans = max(C)
for i in range(N):
    j = i
    while P[j]-1 != i:
        j = P[j]-1
        c[i] += 1
        m[i][c[i]] = m[i][c[i]-1] + C[P[j]-1]
    if m[i][c[i]] > 0:
        ans = max(ans, m[i][c[i]] * (K//c[i]-1) + max(m[i] + [m[i][c[i]] + m[i][j+1] for j in range(K%c[i])]))
    else:
        ans = max(ans, max(m[i][1:min(c[i],K)+1]))
print(ans)


Measured memory_bytes: 282212
#define _USE_MATH_DEFINES
#include<iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main()
{
	int n;
	char *ch;
	cin >> n;
	ch = new char[n];

	for (int i = 0; i < n; i++){
		cin >> ch[i];
	}
	
	string str = "";
	int countr = 0;
	int countl = 0;
	int addl = 0;
	int addr = 0;
	for (int i = 0; i < n; i++){
		
		if (ch[i] == '('){
			countl++;
		}
		else if (ch[i] == ')'){
			countr++;
		}
		addl = min(addl, countl - countr);
	}


	addl = -addl;
	addr = countl - (n - countl) + addl;

	for (int i = 0; i < addl; i++){
		str = str + '(';
	}

	for (int i = 0; i < n; i++){
		str = str + ch[i];
	}

	for (int i = 0; i < addr; i++){
		str = str + ')';
	}

	cout << str;

	return 0;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v),v.end()));
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, W;
	cin >> n >> W;
	vi v(n), w(n);
	ll sumw = 0;
	REP(i, n) {
		cin >> v[i] >> w[i];
		sumw += w[i];
	}
	vvi dp(n + 1, vi(W+1, -INF));
	REP(i,W+1)dp[0][i] = 0;
	REP(i, n) {
		REP(j, W+1) {
			if (j < w[i])dp[i + 1][j] = dp[i][j];
			else dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
		}
	}

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

Measured memory_bytes: 6736
S = str(input())
T = str(input())
ans = 'No'
s = [S[i] for i in range(len(S))]
for i in range(len(S)):
    s.append(S[i])
for i in range(len(S)):
    fr = 0
    for j in range(len(S)):
        if s[i + j] != T[j]:
            fr += 1
            break
    if fr == 0:
        ans = 'Yes'
print(ans)

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

int main(){
    string S;
    cin >> S;
    long K;
    cin >> K;
    int l = S.length();
    int first = 0;
    char ch = S[0];
    int count = 1;
    int  sum = 0;
    int f_count = 0;
    for(int i = 1; i < l ; i++){
        if (ch == S[i]){
            count++;
            if (count == 2){
                first = i-1;
            }
            // cout << ch << " " << i << count << endl;
        }
        else{
            ch = S[i];
            sum += count / 2;
            if (first == 0) f_count = count;
            count = 1;
            first = 0;
        }
    }
    // cout << "sum" << sum  << " " << count << endl;
    sum += count / 2;
    int sum2 = 0;
    if (S[l-1] == S[0] && count % 2 == 1 && f_count % 2 == 1){
        sum2 = 1;
    }
    if (l == count) cout << (l * K) / 2 << endl;
    else cout << sum * K + sum2 * (K-1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll x = max(a*c, a*d);
    ll y = max(b*c, b*d);
    cout << max(x, y) << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> score(n, k - q);

    int temp;
    rep(i, q) {
        cin >> temp;
        score[temp - 1]++;
    }

    rep(i, n) {
        if(score[i] > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
ab=[]
for _ in range(N):
    ab.append(tuple(map(int, input().split())))

num=[0]*(10**5+1)
for el in ab:
    num[el[0]]+=el[1]
#print(num)
count=0
for i in range(10**5+1):
    count+=num[i]
    if count>=K:
        print(i)
        break


Measured memory_bytes: 61016
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };
// struct edge{ll to; ll cost;};



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }

// ll gcd(ll m, ll n){
//   if(m<n) swap(m,n);
//   if(n==0) return m;
//   return gcd(n, m%n);
// }

// ll get_pow(ll x, ll y){
//   ll ret=0;
//   ll temp = y;
//   while(true){
//     if(x<=temp) break;
//     ret++;
//     temp *= 2;
//   }
//   return ret;
// }






int main() {
  cout<<fixed<<setprecision(10);


  ll N,M;cin>>N>>M;
  vstring A(N);rep(i,N)cin>>A[i];
  vstring B(M);rep(i,M)cin>>B[i];

  bool match;
  bool ans = false;

  rep(i,N-M+1){
    rep(j,N-M+1){
      match = true;
      // cout<<"Start"<<endl;
      rep(k,M){
        match = match && (A[i+k].substr(j,M) == B[k]);
        // cout << A[i+k].substr(j,M) << endl;
      }
      ans = ans || match;
      // cout << endl;

    }
  }

  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  // cout << ans << endl;
}

















//


Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int num = sc.nextInt();
        ArrayList<BigDecimal> list = new ArrayList<BigDecimal>();

        for(int i=0; i<num; i++){
            list.add(sc.nextBigDecimal());
        }

        BigDecimal sumnum = new BigDecimal(0);

        for (BigDecimal e : list) {
            sumnum = sumnum.add(e);
        }

        Optional<BigDecimal> maxnum = list.stream().max(Comparator.naturalOrder());
        Optional<BigDecimal> minnum = list.stream().min(Comparator.naturalOrder());

        minnum.ifPresent(n -> System.out.print(n + " "));
        maxnum.ifPresent(n -> System.out.print(n + " "));
        System.out.println(sumnum);
    }
}



Measured memory_bytes: 69644
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;


int main() {
	int A;
	int B;

	cin >> A >> B;
	cout << max(0, A - 2 * B);

	system("PAUSE");
}


Measured memory_bytes: 504
#include <iostream>

int main(){
    long long n;
    std::cin >> n;
    auto f = [&](long long a){
        int res = 0;
        while(a){
            res += a % 10;
            a /= 10;
        }
        return res;
    };
    int ans = f(n);
    long long k = 1;
    while(n >= 10){
        n /= 10;
        k *= 10;
    }
    ans = std::max(ans, f(n * k - 1));
    std::cout << ans << std::endl;
}

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

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,k = readInts()
S = input()
a = 0
for i in range(1,len(S)):
    if S[i] != S[i-1]:
        a += 1
print(n - 1 - max(a - 2 * k, 0))


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

using namespace std;

const int mod = 1e9 + 7, m = 1e5;
int f[m + 2], frq[m + 1] = {};

int modularPow(int a, int p) {
    if (!p)
        return 1;
    if (p & 1)
        return (1ll * a * modularPow((1ll * a * a) % mod, p / 2)) % mod;
    return modularPow((1ll * a * a) % mod, p / 2);
}

int modF(int a, int b) { return (1ll * a * modularPow(b, mod - 2)) % mod; }

int choose(int n, int k) { return modF(f[n], (1ll * f[n - k] * f[k]) % mod); }

int sub(int a, int b) {
    a -= b;
    if (a < 0)
        a += mod;
    return a;
}

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

    f[0] = 1;
    for (int i = 1; i <= m + 1; i++)
        f[i] = (1ll * i * f[i - 1]) % mod;

    int n, ind1, ind2;
    cin >> n;
    int arr[n + 1];

    for (int i = 0; i <= n; i++) {
        cin >> arr[i];
        frq[arr[i]]++;

        if (frq[arr[i]] == 2) {
            for (int j = 0; j < i; j++)
                if (arr[j] == arr[i]) {
                    ind1 = j + 1;
                    break;
                }
            ind2 = i + 1;
        }
    }

    for (int i = 1; i <= n + 1; i++) {
        int all = choose(n + 1, i);

        if (i - 1 <= (n + 1 - ind2) + (ind1 - 1))
            all = sub(all, choose((n + 1 - ind2) + (ind1 - 1), i - 1));

        cout << all << "\n";
    }

    return 0;
}

Measured memory_bytes: 2432
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>

#define rep(i,n) for(int i=1; i<n+1;i++)
typedef long long ll;

using namespace std;

int maze[2002][2002];
int vscore[2002][2002];
int hscore[2002][2002];

int h,w;
int counter;
const int INF = 100000000;
string s;

int main(){
cin >> h >> w;

for (int i = 0;i<2002;i++){
  maze[0][i] = 1;
  maze[i][0] = 1;
  maze[h+1][i] = 1;
  maze[i][w+1] = 1;
}

rep(i,h){
  cin >> s;
  rep(j,w){
    if (s[j-1] == '#'){
      maze[i][j] = 1;
    }
  }
}

int l,r;
bool flag = false;
rep(i,h){
  rep(r,w+1){
    if(flag && maze[i][r] == 0){
      counter++;
    }
    else if(flag && maze[i][r] == 1){
      for (int p = l; p < r; p++) vscore[i][p] = counter;
      counter = 0;
      flag = false;
    }
    else if(maze[i][r] == 0){
      l = r;
      flag = true;
      counter++;
    }
  }
}

rep(i,w){
  rep(r,h+1){
    if(flag && maze[r][i] == 0){
      counter++;
    }
    else if(flag && maze[r][i] == 1){
      for (int p = l; p < r; p++) hscore[p][i] = counter;
      counter = 0;
      flag = false;
    }
    else if(maze[r][i] == 0){
      l = r;
      flag = true;
      counter++;
    }
  }
}


int ans = 0;

rep(i,h)rep(j,w) ans = max(ans,hscore[i][j]+vscore[i][j]);

cout << ans-1 << endl;



return 0;
}

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

int D;
ll G;
int p[20], c[20];

int ans = 1.0e9;

void rec(int sum, int cnt, int i, vector<bool> D_bool) {
    if (i == D) {
        if (sum >= G) {
            ans = min(ans, cnt);
        }
        else {
            int j = D-1;
            for (int k = D-1; k >= 0; k--) {
                if (!D_bool[k]) {
                    j = k;
                    break;
                }
            }
            
            for (int l = 0; l < p[j] - 1 && sum < G; l++) {
                sum += 100*(j+1);
                cnt++;
            }
            if (sum >= G) {
                ans = min(ans, cnt);
            }
        }
    }
    else {
        D_bool[i] = false;
        rec(sum, cnt, i+1, D_bool);

        D_bool[i] = true;
        for (int j = 0; j < p[i]; j++) {
            sum += 100*(i+1);
            cnt++;
        }
        sum += c[i];
        rec(sum, cnt, i+1, D_bool);
    }

}

int main() {
    cin >> D >> G;
    for (int i = 0; i < D; i++) cin >> p[i] >> c[i];

    vector<bool> vec_bool;
    for (int i = 0; i < D; i++) vec_bool.push_back(false);
    rec(0, 0, 0, vec_bool);

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
using namespace std;

int main() {
    int x[5] = { 0 };
    cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];
    for (int i = 0; i < 5; i++) {
        if (x[i] == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(ll i=0;i<N;++i)
const ll INF = 1LL<<60;

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    ll N,M; cin >> N >> M;
    string S,T; cin >> S >> T;

    ll lcm = N * M / (euclidean_gcd(N,M));

    map<ll,char> mp;

    if(S.size() < T.size()) swap(S,T);
    bool ok = true;
    rep(i,S.size()){
        ll index = (lcm/(S.size()))*i;
        mp[index] = S[i];
    }
    rep(i,T.size()){
        ll index = (lcm/(T.size()))*i;
        if(mp[index]){
            if(mp[index] != T[i]) ok = false;
        }
    }

    if(ok) cout << lcm << endl;
    else cout << "-1" << endl;
}

Measured memory_bytes: 10880
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int a[] = new int[N];
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}
		int max = 0;
		for (int i = 0; i < N; i++) {
			if (a[i] != 0) {
				max += a[i] - 1;
			}
		}
		System.out.println(max);
	}
}


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

int main() {
    int a, b, ans;
    cin >> a >> b;
    if (a>=13) {
        ans = b;
    } else if (a<6) {
        ans = 0;
    } else {
        ans = b/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,k,a[200100],b[200100],le,ri,ok;
void move(){
	for(int i=1;i<=n;i++) b[i]=0;
	for(int i=1;i<=n;i++){
		le=max(i-a[i],1);
		ri=min(i+a[i],n);
		b[le]++;b[ri+1]--;
	}
	ok=1;
	for(int i=1;i<=n;i++){
		a[i]=a[i-1]+b[i];
		if(a[i]!=n) ok=0;
	}
}
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=k;i++){
		move();
		if(ok) break;
	}
	for(int i=1;i<=n;i++) cout<<a[i]<<' ';
	cout<<endl;
	return 0;
}


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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

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

const int mod = 998244353;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }  

int main(){

    int w, h, x, y;
    cin >> w >> h >> x >> y;    
    ld p = 1ll * w*h;
    cout << fixed << setprecision(10);
    cout << ld(p/2) << " ";

    if(2*x == w && 2*y == h)
        cout << 1;
    else
        cout << 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  char Atcoder[100], s[100], Contest[100], a[4];
  
  scanf("%s %s %s", Atcoder, s , Contest);
  
  a[0] = Atcoder[0];
  a[1] = s[0];
  a[2] = Contest[0];
  a[3] = 0;
  
  printf("%s\n", a);
  
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n, k;
    cin >> n >> k;
    ll a[n];
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }
    ll d[n];
    rep(i, n) { d[i] = -1; }

    ll next = 0;
    ll distance = 0;
    while (true) {
        // cout << next << endl;
        if (k == 0) {
            cout << next + 1 << endl;
            return 0;
        }
        if (d[next] != -1) {
            ll loop_size = distance - d[next];
            // cout << "loop_size" << loop_size << endl;
            k--;
            k %= loop_size;
            rep(i, n) { d[i] = -1; }
        } else {
            d[next] = distance;
            k--;
        }
        distance++;
        next = a[next];
    }
    return 0;
}



Measured memory_bytes: 6780
#include <iostream>
#include <algorithm>
#include <math.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
    string s; cin>>s;
    int n=s.size(),ans=0;

    rep(i,n){
        if(i%2==0){
            if(s[i]=='p') ans--;
        }else{
            if(s[i]=='g') ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int b[4010][4010];
int w[4010][4010];
int accB[4010][4010];
int accW[4010][4010];

ll get(int acc[4010][4010], int x1, int y1, int x2, int y2) {
  return acc[x2][y2] - acc[x1][y2] - acc[x2][y1] + acc[x1][y1];
}

int main2() {
  CLR(b, 0);
  CLR(w, 0);
  CLR(accB, 0);
  CLR(accW, 0);
  int N = nextInt();
  int K = nextInt();
  REP(i, N) {
    int x = nextInt() % (2*K);
    int y = nextInt() % (2*K);
    char c; scanf(" %c", &c);
    if (c == 'B') {
      b[x][y]++;
      b[x+2*K][y+2*K]++;
      b[x+2*K][y]++;
      b[x][y+2*K]++;
      
    } else {
      w[x][y]++;
      w[x+2*K][y+2*K]++;
      w[x][y+2*K]++;
      w[x+2*K][y]++;
    }
  }
  // REP(i, 4*K) pv(b[i], b[i] + 4*K);
  // cout << "." << endl;
  // REP(i, 4*K) pv(w[i], w[i] + 4*K);
  // cout << "///" << endl;

  REP(r, 4*K) REP(c, 4*K) accB[r+1][c+1] = accB[r+1][c] + accB[r][c+1] - accB[r][c] + b[r][c];
  REP(r, 4*K) REP(c, 4*K) accW[r+1][c+1] = accW[r+1][c] + accW[r][c+1] - accW[r][c] + w[r][c];

  // REP(i, 4*K+1) pv(accB[i], accB[i] + 4*K+1);
  // cout << "." << endl;
  // REP(i, 4*K+1) pv(accW[i], accW[i] + 4*K+1);
  // cout << "///" << endl;


  ll ans = 0;
  REP(dx, K) {
    REP(dy, K) {
      {
        ll here = 0;
        here += get(accB, dx, dy, dx + K, dy + K);
        here += get(accB, dx+K, dy+K, dx + 2*K, dy + 2*K);
        here += get(accW, dx+K, dy, dx + 2*K, dy + K);
        here += get(accW, dx, dy+K, dx + K, dy + 2*K);
        // cout << dx << " " << dy << " " << here << endl;
        chmax(ans, here);
        chmax(ans, N - here);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 251520
import numpy as np

n = int(input())

U = np.arange(1, n ** 0.5 + 1, dtype = np.int64) # +1を忘れない！

div = U[n % U == 0]
ans = min((n / div) + div) - 2

print(int(ans))

"""old


from itertools import combinations
import numpy as np

n = int(input())

a = 2
cnt = 0
ans = []


def walk_counter(ll, n):
    left = np.prod(ll)
    right = n // left
    return left + right - 2


tmp_n = n

while tmp_n >= a:
    while tmp_n % a == 0:
        tmp_n = tmp_n // a
        # cnt += 1
        ans.append(a)
    # if cnt > 0:
    #     ans.append([a, cnt])
    #     cnt = 0
    a = a + 1

if tmp_n == a:
    ans.append(a)

fin = 0

for i in range(len(ans)):
    for v in combinations(ans, i):
        tmp = walk_counter(v, n)
        if i == 0:
            fin = tmp
        elif fin > tmp:
            fin = tmp

# 組み合わせでなく、√nまでの試し割法のほうが早い

print(fin)
"""


Measured memory_bytes: 28984
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <sstream>
#include <complex>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using iii = pair<int, ii>;
using viii = vector<iii>;

using ll = long long int;
using vc = vector<char>;
using vb = vector<bool>;
using ib = pair<int, bool>;
using vib = vector<ib>;

#define MOD 1000 * 1000 * 1000 + 7
#define INF 1000 * 1000 * 1000

bool resuelveCaso() {
	int n;
	cin >> n;
	if (!cin) return false;
	int m;
	cin >> m;

	cout << m * n - m - n  + 1<< '\n';

	return true;
}

int main() {
	while (resuelveCaso()) {}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <cstring>

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

int n,x,t,a;

int main() {
    cin >> n >> x >> t;
    a = n/x;
    if (n%x) a++;
    cout << a*t << endl;
}


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


int main(){
    ll h,n;cin>>h>>n;
    ll dp[20010];
    rep(i,0,20010)dp[i]=9999999999;
    dp[0]=0;
    ll MAXA=-1;
    rep(i,0,n){
        ll a,b;cin>>a>>b;
        rep(j,0,20010){
            ll nj=min(j+a,20010LL);
            dp[nj]=min(dp[nj],dp[j]+b);
        }
        MAXA=max(MAXA,a);
    }
    ll ans=9999999999;
    rep(i,h,h+MAXA)ans=min(ans,dp[i]);
    cout<<ans<<endl;
}







Measured memory_bytes: 384
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => {
        #[cfg(debug_assertions)]
        eprintln!(">>> {} = {:?}", stringify!($x), $x)
    };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! flush {
    () => {
        std::io::stdout().flush().unwrap();
    };
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let a: i64 = sc.cin();
    let b: i64 = sc.cin();
    let c: i64 = sc.cin();
    let d: i64 = sc.cin();
    put!(max!(a * c, a * d, b * c, b * d));
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


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

// Shortening code
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

// Macros
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = a; i >= b; i--)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // Your code
    int n;
    cin >> n;
    vector<vi> A(n);
    REP(i, 0, n - 1)
    {
        int a;
        cin >> a;
        A[a - 1].push_back(i);
    }
    REP(i, 0, n){
        cout << A[i].size() << endl;
    }
    return 0;
}

Measured memory_bytes: 14132
#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
typedef vector<int> vint;
typedef pair<int,int> PII;
int read(){
	char c=getchar();int d=0,f=1;
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f=-1;
	for(;c>='0'&&c<='9';d=d*10+c-48,c=getchar());
	return d*f;
}
const int N=200010;
const int mod=998244353;
int H,W,a,b,r[1001][1001],ri[1001],rri[1001];
bool cmp(int a,int b){return ri[a]<ri[b];}
int main(){
	cin>>H>>W>>a>>b;
	//w h a b
	if(a*2>W||b*2>H){
		cout<<-1<<endl;
		return 0;
	}
	PII mk;bool fg=0;
	ref(i,0,H)ref(j,0,W)if(i*a+(H-i)*(W-a)==j*b+(W-j)*(H-b)){
		fg=1;
		mk=mp(i,j);
	}
	if(!fg)cout<<-1<<endl;else{
		ref(i,1,mk.fi){ri[i]=a;ref(j,1,a)r[i][j]=1;}
		ref(i,mk.fi+1,H){ri[i]=W-a;ref(j,1,W-a)r[i][j]=1;}
		ref(i,1,W){
			int tot=0;
			ref(j,1,H)tot+=r[j][i];
			int st=0;
			if(i<=mk.se)st=b;else st=H-b;
			if(tot>st){
				int nn=0;
				ref(j,1,H)if(r[j][i])rri[++nn]=j;
				sort(rri+1,rri+nn+1,cmp);
				ref(j,1,tot-st){
					ri[rri[j]]++;
					swap(r[rri[j]][i],r[rri[j]][ri[rri[j]]]);
				}
			}
		}
		ref(i,1,H){ref(j,1,W)printf("%d",r[i][j]);putchar('\n');}
	}
}

Measured memory_bytes: 5120
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();

        int cnt = 0;
        for (int i = 0; i <= n - 3; ++i) {
            if (s.charAt(i) == 'A' && s.charAt(i+1) == 'B' && s.charAt(i+2) == 'C') ++cnt;
        }

        System.out.println(cnt);
    }
}

Measured memory_bytes: 22868
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N;
  cin >> N;
  vector<int> x(N), y(N);
  rep(i,N) cin >> x[i] >> y[i];
  double dis = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i+1; j < N; ++j) {
      dis += sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
    }
  }
  int way = 1;
  rep(i,N) way *= i+1;
  // cout << way << endl;
  double ans = dis * 2 / N;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 3228
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int a=0,b=0,a1=0,b1=0;
	for(int i=0;i<4;i++)
	{
		cin>>a;
		a1+=a;
	}
	for(int i=0;i<4;i++)
	{
		cin>>b;
		b1+=b;
	}
	cout<<max(a1,b1)<<endl;
	return 0;
}


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

#define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl "\n"
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;
bool isprime(ll n){for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
ll factorial(ll n){return (n==1 || n==0) ? 1:n*factorial(n-1);}
ll power(ll x,ll y){ll res=1;x=x%mod;while(y>0){if(y&1)res=((res%mod)*(x%mod))%mod;y=y>>1;x=((x%mod)*(x%mod))%mod;}return res;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res=((res%mod)*((n-i)%mod))%mod;res=((res%mod)*(power(i+1,mod-2))%mod)%mod;}return res;}
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
ll max(ll a,ll b){ll sol=a>b?a:b;return sol;}
ll min(ll a,ll b){ll sol=a<b?a:b;return sol;}
////////////////////////////////////////////////////
int main()
{
   bolt;
   string s;
   cin>>s;
   string r=s;
   ll ans=0;
   reverse(r.begin(),r.end());
   for (ll i=0;i<=ceil(1.0*s.size()/2)-1;i++)
   {
      if (s[i]!=r[i])
         ans++;
   }
   cout<<ans;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;

#define rep(i,m,n) for(ll i=m;i<n;i++)

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

 ll n,k;
  cin >> n >> k;
  
  ll m=(n-1)*(n-2)/2;
  if(k>m) {
    cout << -1 << endl;
    return 0;
  }
  
  vector<pll> p;
  rep(i,2,n+1) p.push_back(make_pair(1,i));
  
  ll index=2;
  while(m>k){
   
   rep(i,index+1,n+1){
    p.push_back(make_pair(index,i));
     m--;
     if(m==k) break;
   }
    index++;
  }
 cout << p.size() << endl;
  rep(i,0,p.size()) cout << p[i].first << " " << p[i].second << endl;
}

  

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;
    int tap = 1, ans = 0;
    while (tap < b) {
        tap--;
        tap += a;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256