akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  int c[h][w];
  for (int i = 0; i < h; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < w; j++) {
      if (s[j] == '.') {
        c[i][j] = 0;
      } else {
        c[i][j] = 1;
      }
    }
  }

  int ans = 0;
  // 選び方全探索 (2^6)^2通り
  for (int i = 0; i < (1 << h); i++) {
    for (int j = 0; j < (1 << w); j++) {
      // 選んだところは省いて数える
      int cnt = 0;
      for (int ii = 0; ii < h; ii++) {
        if (i & (1 << ii)) continue;
        for (int jj = 0; jj < w; jj++) {
          if (j & (1 << jj)) continue;
          cnt += c[ii][jj];
        }
      }
      if (cnt == k) ans++;
    }
  }

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


Measured memory_bytes: 3632
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/
#include <assert.h> /*確認*/
#include <ctype.h>  /*文字操作*/
#include <stdbool.h>/*bool型の利用*/

#define rep(i, n) for(int  i = 0; i < (n); i++)
#define max(a,b) ((a>b)?a:b)
#define ABS(a) (((a)>(0))?a:-(a))

//date 03/07
//abc158

int main(void)
{
  int A;
  int B;
  int i;
  double taxA=0;
  double taxB=0;
  int flag = 0;
  scanf("%d %d", &A, &B);
  for ( i = 0; i < 2000; i++) {
    taxA=(double)i * 0.08;
    taxB=(double)i * 0.1;
    if ((int)taxA == A && (int)taxB == B) {
      flag= 1;
      break;
    }
  }

  if (flag == 1) {
    printf("%d\n", i);
  }else printf("-1\n" );
  return 0;
}


Measured memory_bytes: 128
S = input()
N = len(S)
kai = []
kai2 = []
kai3 = []
rev = []
rev2 = []
rev3 = []

for i in range(N):
  kai.append(S[i])

for i in range(0, int((N - 1) / 2)):
  kai2.append(S[i])

for i in range(int((N + 3) / 2) - 1, N):
  kai3.append(S[i])

kai.reverse()
kai2.reverse()
kai3.reverse()

for i in range(N):
  rev.append(S[i])

for i in range(0, int((N - 1) / 2)):
  rev2.append(S[i])

for i in range(int((N + 3) / 2) - 1, N):
  rev3.append(S[i])

if kai == rev:
  if kai2 == rev2:
    if kai3 == rev3:
      print('Yes')
    else:
      print('No')
  else:
    print('No')
else:
  print('No')


Measured memory_bytes: 3064
def PrimeDecomp(N,ConcFlag):
    if ConcFlag:
        if N<=1:
            return [1],1
        else:
            I = 2
            PrimeDec = []
            DivCount = 1
            while I*I<=N:
                Cnt = 0
                while N%I==0:
                    N //= I
                    PrimeDec.append(I)
                DivCount *= (Cnt+1)
                I += 1
            if N>=2:
                PrimeDec.append(N)
                DivCount *= 2
            return PrimeDec,DivCount        
    else:
        if N<=1:
            return [1],[1],1
        else:
            I = 2
            PrimeDec = []
            PrimeCnt = []
            DivCount = 1
            while I*I<=N:
                Cnt = 0
                while N%I==0:
                    N //= I
                    Cnt += 1
                if Cnt>=1:
                    PrimeDec.append(I)
                    PrimeCnt.append(Cnt)
                    DivCount *= (Cnt+1)
                I += 1
            if N>=2:
                PrimeDec.append(N)
                PrimeCnt.append(1)
                DivCount *= 2
            return PrimeDec,PrimeCnt,DivCount

def DivisorFactorial(N,FactDec,FactCnt,MemoFlag,Mod,ModFlag):
    if MemoFlag:
        if N<=1:
            FDivCnt = 1
            return FactDec,FactCnt,FDivCnt
        else:
            PrimeDec,PrimeCnt,_ = PrimeDecomp(N,False)
            for TP in range(0,len(PrimeDec)):
                if PrimeDec[TP] in set(FactDec):
                    FactCnt[FactDec.index(PrimeDec[TP])] += PrimeCnt[TP]
                else:
                    FactDec.append(PrimeDec[TP])
                    FactCnt.append(PrimeCnt[TP])
            FDivCnt = 1
            for TF in FactCnt:
                FDivCnt = [FDivCnt*(TF+1),(FDivCnt*(TF+1))%Mod][ModFlag]
            return FactDec,FactCnt,FDivCnt
    else:
        if N<=1:
            FDivCnt = 1
            return FactDec,FactCnt,FDivCnt
        else:
            for TN in range(2,N+1): 
                PrimeDec,PrimeCnt,_ = PrimeDecomp(TN,False)
                for TP in range(0,len(PrimeDec)):
                    if PrimeDec[TP] in set(FactDec):
                        FactCnt[FactDec.index(PrimeDec[TP])] += PrimeCnt[TP]
                    else:
                        FactDec.append(PrimeDec[TP])
                        FactCnt.append(PrimeCnt[TP])
            FDivCnt = 1
            for TF in FactCnt:
                FDivCnt = [FDivCnt*(TF+1),(FDivCnt*(TF+1))%Mod][ModFlag]
            return FactDec,FactCnt,FDivCnt
FactDec,FactCnt,FDivCnt = DivisorFactorial(int(input()),[],[],False,10**9+7,True)
print(FDivCnt)

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

using namespace std;

int ans(int n, int d)
{
     return (n + 2*d) / ( 2*d +1 );
}

int main(void)
{
  int n,d;
  
  cin >> n >> d;
  
  cout << ans(n,d) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int A,B,Q;cin >> A >> B >> Q;
    vector<ll> s(A+2),t(B+2),x(Q+2);
    s[0]=-1e18;t[0]=-1e18;
    s[A+1]=1e18;t[B+1]=1e18;

    FOR(i,1,A+1)cin >> s[i];
    FOR(i,1,B+1)cin >> t[i];
    rep(i,Q)cin >> x[i];

    vector<ll> res;
    rep(i,Q){
        auto itr_ns = upper_bound(All(s),x[i]);
        auto itr_nt = upper_bound(All(t),x[i]);
        ll a=*itr_ns,b=*(--itr_ns),c=*itr_nt,d=*(--itr_nt);
        ll tmp=1e18;
        tmp=min(tmp,abs(x[i]-a)+abs(a-c));
        tmp=min(tmp,abs(x[i]-a)+abs(a-d));
        tmp=min(tmp,abs(x[i]-b)+abs(b-c));
        tmp=min(tmp,abs(x[i]-b)+abs(b-d));
        tmp=min(tmp,abs(x[i]-c)+abs(c-a));
        tmp=min(tmp,abs(x[i]-c)+abs(c-b));
        tmp=min(tmp,abs(x[i]-d)+abs(d-a));
        tmp=min(tmp,abs(x[i]-d)+abs(d-b));
        res.push_back(tmp);
    }

    rep(i,Q)cout << res[i] << endl;

    return 0;
}

Measured memory_bytes: 4596
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
using namespace std;
//#define int long

signed main() 
{
	int A, B;
	cin >> A >> B;
	if (A + B == 3)cout << "3";
	else if (A + B == 4)cout << "2";
	else cout << "1";
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    for (ll a : A) {
        if (a == 0) {
            cout << 0 << '\n';
            return;
        }
    }
    ll now = 1;
    ll tar = 1e18;
    rep(i, N) {
        ll a = A[i];
        if (tar/now >= a) {
            now *= a;
        }else {
            cout << -1 << '\n';
            return;
        }
    }
    cout << now << '\n';
}

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


Measured memory_bytes: 3984
from itertools import permutations

N, M = map(int, input().split())
adj = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
for _ in range(M):
    a, b = map(int, input().split())
    adj[a][b] = 1
    adj[b][a] = 1

ans = 0
for seq in permutations(range(1, N + 1)):
    if seq[0] != 1:
        continue
    new = 1
    for i in range(1, N):
        if adj[seq[i - 1]][seq[i]] == 0:
            new = 0
    ans += new
print(ans)


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

int main(){
	long long N,co=0,k=0;
  cin >> N;
  
 
  
  vector <long long> L(N);
  
  
  rep(i,N)
    cin >> L.at(i);
  
  sort(L.begin(),L.end());
  
rep(i,N-2){
  for(int j=i+1;j<N-1;j++){
    k=j+1;
    while(k!=N && L.at(k)<L.at(i)+L.at(j)){
   		k++;
  }
    co=co+k-j-1;
}
}  
  cout << co << endl;
 
}



Measured memory_bytes: 256
N = int(input())
x, y, h = [], [], []
x2, y2, h2 = [], [], []
for i in range(N):
    xi, yi, hi = map(int, input().split())
    if hi != 0:
        x.append(xi)
        y.append(yi)
        h.append(hi)


def fn(H, X, Y, Cx, Cy):
    return H + abs(Cx - X) + abs(Cy - Y)

if len(h) == 1:
    print(x[0], y[0], h[0])
    exit()

for Cx in range(101):
    for Cy in range(101):
        H = fn(h[0], x[0], y[0], Cx, Cy)
        flag = True
        for i in range(1, len(h)):
            if H != fn(h[i], x[i], y[i], Cx, Cy):
                flag = False
                break
        if flag:
            print(Cx, Cy, H)
            exit()




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

int main() {
  ll n;
  cin>>n;
  vector<ll> a(n+1),b(n);
  rep(i,n+1){
    cin>>a[i];
  }
  ll ans=0;
  rep(i,n){
    ll b;
    cin>>b;
    if(a[i]>0){
      ans+=min(a[i],b);
      a[i]-=b;
      if(a[i]<0){
      ans+=min(a[i+1],abs(a[i]));
      a[i+1]+=a[i];
    }
    }else{
      ans+=min(a[i+1],b);
      a[i+1]-=b;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
 
const ll MOD=1e9+7;
const ll INF=1e18;
 
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};


int main(){
    char a[210],b[210];
    while(1){
        cin >> a;
        if(a[0] == '.')break;
        cin >> b;
        int dif = 0,ai = 0,bi = 0;
        for(;ai < strlen(a) || bi < strlen(b);ai++,bi++){
            if(a[ai] == '"' && b[bi] == '"'){
                for(int i = 1;ai + i < strlen(a);i++){
                    if(a[ai+i] == '"' && b[bi+i] == '"'){
                        ai += i; bi += i;
                        break;
                    }else if(a[ai+i] != b[bi+i]){
                        dif++;
                        if(dif >= 2) break;
                        int add = 0;
                        for(add = 0;a[ai+i+add] != '"';add++) ;
                        ai = ai + i + add;
                        for(add = 0;b[bi+i+add] != '"';add++) ;
                        bi = bi + i + add;
                        break;
                    }
                }
                if(dif >= 2)break;
            }else if(a[ai] != b[bi]){
                dif = 3;
                break;
            }
        }
        if(ai == strlen(a) && bi == strlen(b) && dif == 0){
            cout << "IDENTICAL" << endl;
        }else if(dif == 1){
            cout << "CLOSE" << endl;
        }else{
            cout << "DIFFERENT" << endl;
        }
    }
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
//ITNOA
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <fstream>
#include <cstring>
#include <cstdlib>
#include <iomanip>

using namespace std;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;


#define rep(i, s, e) for(int i = s; i < e; i ++)
#define int long long
#define X first
#define Y second

typedef long long ll;
typedef long double ld;

const int maxN = 300 + 5;
const int mod = 1000*1000*1000 + 7;
const int base = 701;
const int SQ = 500;
const int maxL = 20;

int a[maxN][maxN];
int n,m; 

bool de[maxN];

bool is_del() {
	for(int i = 0; i < m; i ++)
		if(de[i] == false)
			return false;
	return true;
}

int cnt[maxN];
bool is_ok(int t) {
	memset(cnt,0,sizeof cnt);
	for(int i = 0; i < n; i ++) 
		for(int j = 0; j < m; j ++) 
			if(de[a[i][j]] == false) {
				cnt[a[i][j]] ++;
				break;	
			}

	for(int i = 0; i < m; i ++)
		if(cnt[i] > t)
			return false;
	return true;
}

bool check(int t) {
	memset(de,0,sizeof de);
	
	while(!is_del() && !is_ok(t)) {
		for(int i = 0; i < m; i ++)
			if(cnt[i] > t) 
				de[i] = true;
	}

	if(is_del())
		return false;
    return true;	
}


int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m;
	for(int i = 0; i < n; i ++) 
		for(int j = 0; j < m; j ++) {
			cin >> a[i][j]; a[i][j] --;
		}

	int lo = 0, hi = n;
	while(hi - lo > 1) {
		int mid = (hi+lo) >> 1;
		if(check(mid))
			hi = mid;
		else 
			lo = mid;
	}
	cout << hi << endl;
	return 0;
}


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


int main(){
    ll n,all; cin >> n; all=0;
    vector<ll> a(n+10);
        vector<ll> b(n+10);

    for(ll i=1;i<=n+1;i++) cin >>a.at(i);
    for(ll i=1;i<=n;i++) cin >> b.at(i);
    for(int i=1;i<=n;i++){
    if(a.at(i)<=b.at(i)){
        if(a.at(i)+a.at(i+1)>b.at(i)) {
            all+=b.at(i);
        a.at(i+1)=(a.at(i)+a.at(i+1)-b.at(i));
        a.at(i)=0;
        }
        else {
        all+=a.at(i+1)+a.at(i);
        a.at(i)=0;
        a.at(i+1)=0;
        }

        
    }
    
    else{
        all+=b.at(i);
        a.at(i)-=b.at(i);
    }
    //cout << a.at(i)<<all << endl;
    
    }
    cout << all << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <math.h>
#include <queue>
#include <list>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <ctime>
#include <iomanip>
#include <fstream>
using namespace std;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define IN(x,c) (find(c.begin(),c.end(),x) != (c).end())
#define REP(i,n) for (int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define INIT(a,v) memset(a,v,sizeof(a))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
template<class A, class B> A cvt(B x) { stringstream ss; ss<<x; A y; ss>>y; return y; }

#define SPC << " " <<
#define DEBUG(x) cerr << #x << " = "; cerr << x << endl;
#define DEBUG_ITER(x) cerr << #x << " = "; for (auto _ : x) cerr << _ << ' '; cerr << endl;

typedef pair<int,int> PII;
typedef long long int64;
typedef vector<int> VI;

int f[100000];

int main() {
	FOR (x,1,100) FOR (y,1,100) FOR (z,1,100) {
		int n=x*x+y*y+z*z+x*y+y*z+z*x;
		f[n]++;
	}
	int n;
	cin >> n;
	FOR (i,1,n) cout << f[i] << "\n";
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  int answer = 700;
  if (S[0] == 'o') answer += 100;
  if (S[1] == 'o') answer += 100;
  if (S[2] == 'o') answer += 100;
  cout << answer << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	l := make([]int, n)

	run := 0
	runmax := 0
	l[0] = nextInt()
	for i := 1; i < n; i++ {
		l[i] = nextInt()
		if l[i-1] >= l[i] {
			run++
			runmax = max(runmax, run)
		} else {
			run = 0
		}
	}

	fmt.Println(runmax)

}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 4396
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
n = int(input())
arr = factorization(n)
#print(arr)
if(n==1):
    print(0)
    exit()
ans = 0
for i in arr:
    for j in range(1,1000):
        if(i[1]+1<=j*(j+1)//2):
            ans += j-1
            break

print(ans)


Measured memory_bytes: 63460
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<queue>

using namespace std;

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

int board[4010][4010];

int main() {
  while (true) {
    int w, h, n;
    cin >> w >> h;
    if (w == 0 && h == 0) break;
    cin >> n;
    vector<pair<pair<int, int>, pair<int, int> > > v;
    vector<int> x, y;
    x.push_back(0);
    x.push_back(w);
    y.push_back(0);
    y.push_back(h);
    rep (i, n) {
      int x1, y1, x2, y2;
      cin >> x1 >> y1 >> x2 >> y2;
      v.push_back(make_pair(make_pair(x1, y1), make_pair(x2, y2)));
      x.push_back(x1 - 1);
      x.push_back(x1);
      x.push_back(x2 - 1);
      x.push_back(x2);
      y.push_back(y1 - 1);
      y.push_back(y1);
      y.push_back(y2 - 1);
      y.push_back(y2);
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    x.erase(unique(x.begin(), x.end()), x.end());
    y.erase(unique(y.begin(), y.end()), y.end());
    memset(board, 0, sizeof(board));
    int w0 = lower_bound(x.begin(), x.end(), 0) - x.begin();
    int ww = lower_bound(x.begin(), x.end(), w) - x.begin();
    int h0 = lower_bound(y.begin(), y.end(), 0) - y.begin();
    int hh = lower_bound(y.begin(), y.end(), h) - y.begin();
    rep (i, n) {
      int x1 = lower_bound(x.begin(), x.end(), v[i].first.first) - x.begin();
      int y1 = lower_bound(y.begin(), y.end(), v[i].first.second) - y.begin();
      int x2 = lower_bound(x.begin(), x.end(), v[i].second.first) - x.begin();
      int y2 = lower_bound(y.begin(), y.end(), v[i].second.second) - y.begin();
      board[y1][x1]++;
      board[y2][x1]--;
      board[y1][x2]--;
      board[y2][x2]++;
    }
    rep (i, y.size()) rep (j, x.size()) {
      board[i + 1][j] += board[i][j];
    }
    rep (i, y.size()) rep (j, x.size()) {
      board[i][j + 1] += board[i][j];
    }
    int res = 0;
    int dx[] = {1, -1, 0, 0};
    int dy[] = {0, 0, 1, -1};
    for (int i = h0; i < hh; ++i) for (int j = w0; j < ww; ++j) {
	if (board[i][j] == 0) {
	  res++;
	  queue<pair<int, int> > que;
	  que.push(make_pair(i, j));
	  while (!que.empty()) {
	    pair<int, int> now = que.front();
	    que.pop();
	    if (now.first < h0 || hh <= now.first) continue;
	    if (now.second < w0 || ww <= now.second) continue;
	    if (board[now.first][now.second] != 0) continue;
	    board[now.first][now.second] = 9;
	    rep (k, 4) {
	      que.push(make_pair(now.first + dy[k], now.second + dx[k]));
	    }
	  }
	}
      }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 64092
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	final int MAX_N = 1000002;
	int[] dp1 = new int[MAX_N], dp2 = new int[MAX_N];

	void run(){
		Scanner in = new Scanner(System.in);
		Arrays.fill(dp1, Integer.MAX_VALUE);
		Arrays.fill(dp2, Integer.MAX_VALUE);
		dp1[0] = dp2[0] = 0;
		for(int i=0; i<MAX_N; i++){
			for(int j=1, sum=1; i + sum < MAX_N; j++, sum += j*(j+1)/2){
				dp1[i+sum] = Math.min(dp1[i+sum], dp1[i]+1);
				if((sum&1)>0){
					dp2[i+sum] = Math.min(dp2[i+sum], dp2[i]+1);
				}
			}
		}
		for(int n = in.nextInt(); n > 0; n = in.nextInt()){
			System.out.println(dp1[n] + " " + dp2[n]);
		}
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 34496
# C - Prison

n, m = map(int, input().split())

ansl = 1
ansr = n

for i in range(m):
    l, r = map(int, input().split())
    if l>ansl:
        ansl = l
    if r<ansr:
        ansr = r

print(max(ansr-ansl+1,0))


Measured memory_bytes: 3060
// ALDS1_7_A.cpp
// Tree - Rooted Tree

#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
using namespace std;

struct Node
{
	int id;
	int parent = -1;
	int depth = 0;
	string type = "internal node";
	vector<int> children = {};
};

int main()
{
	int n;
	cin >> n;
	vector<Node> nodes(n);
	for (int i = 0; i < n; i++) {
		int id;
		int child_num;
		cin >> id >> child_num;
		nodes[id].id = id;
		if (!child_num) nodes[id].type = "leaf";
		while (child_num--) {
			int tmp;
			cin >> tmp;
			nodes[id].children.push_back(tmp);
			nodes[tmp].parent = id;
		}
	}

	for (int i = 0; i < n; i++) {
		int depth = 0;
		int j = i;
		while (nodes[j].parent != -1) {
			j = nodes[j].parent;
			depth++;
		}
		nodes[i].depth = depth;
		if (!depth)
			nodes[i].type = "root";
		printf("node %d: parent = %d, depth = %d, ",
			nodes[i].id, nodes[i].parent, nodes[i].depth);

		cout << nodes[i].type << ", [";
		for (int k = 0; k < nodes[i].children.size(); k++) {
			if (k > 0) printf(", ");
			printf("%d", nodes[i].children[k]);
		}
		printf("]\n");
	}

	return 0;
}

Measured memory_bytes: 12644
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

ll a[505][505];
ll c[505][505];

void solve()
{
    int n,m,Q;
    scanf("%d%d%d", &n, &m, &Q);
    int i,j;
    for(i=0; i<m; i++) {
        int l,r;
        scanf("%d%d", &l, &r); l--; r--;
        a[l][r]++;
    }
    for (i = 0; i < n; i++) {
        for(j = 0; j< n; j++) {
            c[i+1][j+1] = c[i][j+1]+c[i+1][j]-c[i][j]+a[i][j];
        }
    }

    for (i = 0; i < Q; i++) {
        int p,q;
        scanf("%d%d", &p, &q); p--;
        printf("%lld\n", c[q][q]- c[p][q] - c[q][p] +c[p][p]);
    }

    return;
}


int main(int argc, char* argv[])
{
#if 1
	solve();
#else
	int T; scanf("%d", &T);
	while (T--) {
		solve();
	}
#endif
	return 0;
}


Measured memory_bytes: 4736
n=int(input())
a=list(map(int,input().split()))
def ma():
  fg=[1,-1]
  ret = [0]*2
  tot = [0]*2
  il = range(n)
  jl = range(2)
  for i in il:
    for j in jl:
      tot[j]+=a[i]
      if tot[j]*fg[j]<=0:
        ret[j] += abs(fg[j] - tot[j])
        tot[j] += fg[j] - tot[j]
      fg[j]*=-1
  return min(ret)
print(ma())

Measured memory_bytes: 14332
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

vector<ll> layer;
vector<ll> patty;

ll solve(ll n, ll x)
{
	if(!x) return 0;
	if(x == layer[n]) return patty[n];
	if(x == layer[n] + 1) return patty[n] + 1;
	if(x > layer[n] + 1) return patty[n] + 1 + solve(n, x - layer[n] - 1);
	if(x < layer[n]) return solve(n - 1, x - 1);
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, x; cin >> n >> x;
	layer.resize(n + 1);
	patty.resize(n + 1);
	layer[0] = patty[0] = 1;
	for(int i = 1; i <= n; i++) layer[i] = 2 * layer[i - 1] + 3;
	for(int i = 1; i <= n; i++) patty[i] = 2 * patty[i - 1] + 1;
	cout << solve(n, x);

	return 0;
}

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

long long gcm(long long n, long long m){
    if(n>m) return gcm(m,n);
    long long a = m%n;
    if(a == 0){
        return n;
    }else{
        return gcm(a,n);
    }
}

int main()
{
    long long n,m;
    cin >> n >> m;
    string s,t;
    cin >> s >> t;
    long long l = n/gcm(n,m) * m;
    map<long long, char> ma;
    for(int i=0; i<n; i++){
        ma[1+i*l/n] = s[i];
    }
    for(int i=0; i<m; i++){
        if(ma.count(1+i*l/m) == 1 && ma[1+i*l/m] != t[i]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 6144
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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
















int main(){
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split();
            int iN = int.Parse(sS[0]);
            int iM = int.Parse(sS[1]);
            long iK = long.Parse(sS[2]);
            List<long> lstA = new List<long>() { 0 };
            List<long> lstB = new List<long>() { 0 };
            sS = System.Console.ReadLine().Trim().Split();
            for (int i = 0; i < sS.Length; i++) { lstA.Add(lstA[i] + long.Parse(sS[i])); }  // Aの読んだ冊数に対する時間
            sS = System.Console.ReadLine().Trim().Split();
            for (int i = 0; i < sS.Length; i++) { lstB.Add(lstB[i] + long.Parse(sS[i])); }  // Bの読んだ冊数に対する時間

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iBr = iM;
            int iOut = 0;
            for (int i = 0; i < lstA.Count; i++)                                            // Aを0冊からN冊読む
            {
                long iZ = iK - lstA[i];                                                     // Aを読んだ残り(だんだん少なくなる)
                if (iZ < 0) { break; }                                                      // Aを読んだ残りがない場合は終了
                for (int j = iBr; j >= 0; j--)                                              // BをM冊から見てく
                {
                    if (lstB[j] <= iZ) { iOut = Math.Max(iOut, (i + j)); iBr = j; break; }  // Aを読んだ残り時間で読めたBの冊数→ABの読んだ冊数
                }
            }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 74176
#include<iostream>
#include<cstdio>
using namespace std;
int h,w,k,fnt[301][301],lst[301][301],leng[301],tsf,catergory;
char s[301][301];
int p[301][301];
int main()
{
  cin>>h>>w>>k;
  for (int i=1;i<=h;++i)
    for (int j=1;j<=w;++j)
      cin>>s[i][j];
  for (int i=1;i<=h;++i)
    {
      for (int j=1;j<=w;++j)
	if (s[i][j]=='#')
	  {
	    ++leng[i];
	    fnt[i][leng[i]]=lst[i][leng[i]-1]+1;
	    lst[i][leng[i]]=j;
	  }
      if (lst[i][leng[i]]!=w)
	  lst[i][leng[i]]=w;
    }
  for (int i=1;i<=h;++i)
    {
      if (leng[i])
	{
	  tsf=i;
	  for (int j=1;j<=leng[i];++j)
	    {
	      ++catergory;
	      for (int t=fnt[i][j];t<=lst[i][j];++t)
	        p[i][t]=catergory;
	    }
	}
      else
	{
	  for (int j=1;j<=w;++j)
	    p[i][j]=p[tsf][j];
	}
    }
  for (int i=h;i>=1;--i)
  	if (leng[i])
	  	tsf=i;
  for (int i=1;i<=h;++i)
  	if (p[i][1]==0)
	  {
	  	for (int j=1;j<=w;++j)
	       p[i][j]=p[tsf][j];
	   } 
  for (int i=1;i<=h;++i)
    {
      for (int j=1;j<=w;++j)
	cout<<p[i][j]<<' ';
      cout<<endl;
    }
  return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  set<int> S;
  int N;cin>>N;
  int buf;
  for(int i=0; i<N; i++){
    cin>>buf;
    S.insert(buf);
  }
  cout<<(S.size()==N? "YES\n": "NO\n");  
}

Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int hh = sc.nextInt();
        int ww = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
        System.out.println((hh - h) * (ww - w));
    }

}


Measured memory_bytes: 25044
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
const int mod = 1000000007;

struct mint{
  ll x;
  mint(ll x = 0):x((x % mod + mod) % mod){};
  mint pow(ll y) const {
    mint res(1);
    mint a(x);
    while(y>0){
      if(y&1) res *= a;
      a *= a;
      y >>= 1;
    }
    return res;
  }
  mint inv() const{ return pow(mod-2); }
  mint& operator+= (const mint a) noexcept {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-= (const mint a) noexcept {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*= (const mint a) noexcept {
    (x *= a.x) %= mod;
    return *this;
  }
  mint& operator/= (const mint a) noexcept {
    return (*this) *= a.inv();
  }
  mint operator+ (const mint a) const noexcept {
    mint res(*this);
    return res += a;
  }
  mint operator- (const mint a) const noexcept {
    mint res(*this);
    return res -= a;
  }
  mint operator* (const mint a) const noexcept {
    mint res(*this);
    return res *= a;
  }
  mint operator/ (const mint a) const noexcept{
    mint res(*this);
    return res /= a;
  }
};

ostream& operator<<(ostream& stream, const mint& n){
  stream << n.x;
  return stream;
};

struct comb{
  vector<mint> fact, ifact;
  comb(int n): fact(n+1), ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k) const noexcept{
    if(k < 0 || n < k) return 0;
    return fact[n] * ifact[k] * ifact[n-k];
  }
};

mint dp[105][10];

int main(void){
  int h, w, k;
  cin >> h >> w >> k;
  dp[0][0] = 1;

  REP(i, h){
    REP(j, w){
      REP(k, 1<<(w-1)){
        bool ok = true;
        REP(l, w-2){
          if((k & (1<<l)) && (k & (1<<(l+1)))) ok = false;
        }
        if(!ok) continue;
        if(k & (1<<j)){ //j本目からj+1本目の橋がある
          dp[i+1][j+1] += dp[i][j];
        }else if(j > 0 && (k & (1<<(j-1)))){ //j本目からj-1本目に橋がある
          dp[i+1][j-1] += dp[i][j];
        }else{ //橋がない場合
          dp[i+1][j] += dp[i][j];
        }
      }
    }
  }
  cout << dp[h][k-1] << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {


    public static void main(String[] args) {
        int r =0;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashSet hs = new HashSet<>();
        for(int i=0;i<n;i++){
            hs.add(sc.next());
        }
        System.out.println(hs.size());
    }
}

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


int main(){
    int N, Q;
    while(cin >> N >> Q, N+Q){
        vector<pair<int, int>> year;
        map<int, string> era;
        while(N--){
            string s;
            int b, y;
            cin >> s >> b >> y;
            year.emplace_back(y-b, 1);
            year.emplace_back(y, 0);
            era[y] = s;
        }
        sort(begin(year), end(year));
        while(Q--){
            int y;
            cin >> y;
            auto p = lower_bound(begin(year), end(year), make_pair(y, -1));
            if(p == end(year) or p->second == 1) cout << "Unknown" << endl;
            else cout << era[p->first] << ' ' << y-(p-1)->first << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3276
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;

int main(){
    char c;
    cin>>c;
    cout<<(c>='A'&&c<='Z'?'A':'a')<<endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1<<28;

int main(){

    ll N; cin >> N;
    ll p_x = 0;
    ll p_y = 0;
    ll pt = 0;
    for(ll i = 0; i < N; i++){
        ll t, x, y; cin >> t >> x >> y;
        ll dis = abs(p_x - x) + abs(p_y - y);
        ll l_dis = abs(t - pt);
        if(p_x == x && p_y == y){
            cout << "No" << endl;
            return 0;              
        }
        if(!(dis <= l_dis)){
            cout << "No" << endl;
            return 0;            
        }
        if((l_dis - dis) % 2 == 1){
            cout << "No" << endl;
            return 0;               
        }
        p_x = x;
        p_y = y;
        pt = t;

    }
    cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    ll a[n+2];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    a[0] =a[n+1] = 0;
    ll sum = 0;
    for(int i=1;i<=n+1;i++)
    {
        sum += abs( a[i] - a[i-1 ] );
    }
    for(int i=1;i<=n;i++)
    {
        cout<< sum + abs( a[i+1 ] -a[i-1] ) - abs( a[i] - a[i-1 ] ) - abs( a[i+1] - a[i]) <<endl;
    }
}

Measured memory_bytes: 4340
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][2];
		
		for(int i = 0; i <= 1 ; i++) {
			for(int j = 0; j < n ; j++) {
				a[j][i] = sc.nextInt();
			}
		}
		int ans = 0;
		
		for(int i = 0; i < n ;i++) {
			int sum = 0;
			int x = 0;
			int y = 0;
			for(int j = 0; j <= n ; j++) {
				sum += a[x][y];
				
				if(x != i || y == 1) {
					x = x + 1 ;
				}
				else {
					y = 1;
				}
				
			}
			ans = Math.max(ans, sum);

		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 21716
// clang-format off
	#include <bits/stdc++.h>
	using namespace std; using ll = long long; using uint = unsigned int;
	#define SFINAE(x, ...)	template <class, class = void> struct x : false_type {}; template <class T> struct x<T, void_t<__VA_ARGS__>> : true_type {};
	SFINAE(DefaultIO, decltype(cout << declval<T &>()))
	SFINAE(IsTuple, typename tuple_size<T>::type)
	SFINAE(Iterable, decltype(begin(declval<T>())))
	template <class T> constexpr char Space(const T &) { return (Iterable<T>::value or IsTuple<T>::value) ? '\n' : ' '; }
	template <auto &os> struct Writer {
		template <class T> void Impl(T const &t) const {
			if constexpr (DefaultIO<T>::value) os << t;
			else if constexpr (Iterable<T>::value) { int i = 0; for (auto &&x : t) ((i++) ? (os << Space(x), Impl(x)) : Impl(x)); }
			else if constexpr (IsTuple<T>::value) apply([this](auto const &... args) { int i = 0; (((i++) ? (os << ' ', Impl(args)) : Impl(args)), ...);}, t);
			else static_assert(IsTuple<T>::value, "No matching type for print");
		}
		template <class F, class... Ts> auto &operator()(F const &f, Ts const &... ts) const { return Impl(f), ((os << ' ', Impl(ts)), ...), os << '\n', *this; }
	};
	template <auto &is> struct Reader {
		template <class T> auto& operator()(T &t) const {
			if constexpr (DefaultIO<T>::value) is >> t;
			else if constexpr (Iterable<T>::value) for (auto &x : t) (*this)(x);
			else if constexpr (IsTuple<T>::value) apply([this](auto &... args) { ((*this)(args), ...); }, t);
			else static_assert(IsTuple<T>::value, "No matching type for read");
			return *this;
		}
	};
	#ifdef NARUT_LOCAL
	#define Debug(...) cerr << "\033[0;31m", Writer<cerr>{}(__VA_ARGS__), cerr << "\033[0m\n"
	#else
	#define Debug(...) 0
	#endif
	[[maybe_unused]] constexpr Reader<cin> Cin; [[maybe_unused]] constexpr Writer<cout> Cout;
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)
// clang-format on





auto Main() {
	array<int,5> x;
	Cin(x);
	cout << find(begin(x), end(x), 0) - x.begin()+1;
	
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	assert(freopen("io/test.in", "r", stdin));
	cin.exceptions(cin.badbit | cin.failbit);
	cerr << fixed << setprecision(10);
#endif

	Main();
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<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; }
const long double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int M1 = 0, M2 = 0;
 
	int N;
	cin >> N;
	int A[N+1]{};
	rep(i,N+1){
		if(i == 0) A[0] = 0;
		else{
			int W = __builtin_popcount(i);
			A[i] = A[i%W] + 1;
		}
	}
	string S;
	cin >> S;
	int num1 = 1, num2 = 1;
	int QW1[N+1], QW2[N+1];
	int popc = 0;
	rep(i,N){
		if(S[i] == '1') popc++;
	}
	if(popc == 0){
		rep(i,N){
			cout << 1 << endl;
		}
		return 0;
	}
	else if(popc == 1){
		if(S[N-1] == '0'){
			rep(i,N-1){
				if(S[i] == '1'){
					cout << 0 << endl;
				}
				else{
					cout << 1 << endl;
				}
			}
			cout << 2 << endl;
		}
		else{
			rep(i,N-1){
				cout << 2 << endl;
			}
			cout << 0 << endl;
		}
		return 0;
	}
	int popc1 = popc+1;
	int popc2 = popc-1;
	num1 %= popc, num2 %= popc;
	rep(i,N){
		QW1[N-1-i] = num1;
		QW2[N-1-i] = num2;
		if(S[N-1-i] == '1'){
			M1 += num1;
			M2 += num2;
		}
		num1 *= 2, num2 *= 2;
		num1 %= popc1;
		num2 %= popc2;
	}
	rep(i,N){
		if(S[i] =='0') cout << A[(M1+QW1[i]) % popc1] + 1 << endl;
		else cout << A[(M2-QW2[i]+popc2) % popc2] + 1 << endl;
	}
}

Measured memory_bytes: 8408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
bool C[1500][1500];
ll dpt[1500][1500];

int main() {
    init();
    ll H, W, ans = 0;
    cin >> H >> W;
    rep(i, H) rep(j, W) cin >> C[i][j];

    rep(i, W) if (!C[0][i]) dpt[0][i] = 1;
    repe(i, 1, H) rep(j, W) if (!C[i][j]) dpt[i][j] = dpt[i - 1][j] + 1;

    stack<ll> st;
    vl left(W + 1);
    
    rep(i,H){
        rep(j,W + 1){
            while(!st.empty() and dpt[i][st.top()]>=dpt[i][j]){
                chmax(ans, (j - left[st.top()]) * dpt[i][st.top()]);
                st.pop();
            }
            left[j] = st.empty() ? 0 : (st.top() + 1);
            st.emplace(j);
        }
        st.pop();
    }

    cout << ans << endl;
}


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

int main(){
	int a = 1000;
	int e = 0;
	int k;
	rep(i, 6){
		int d;
		cin >> d;
		if(i == 5){
			k = d;
			break;
		}
		a = min(a, d);
		e = max(e, d);
	}

	if(e-a <= k) cout << "Yay!" << endl;
	else cout << ":(" << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
d, x = map(int, input().split())
li = list()
for i in range(n):
    li.append(int(input()))
ans = 0

for i in range(1, d+1):
    if(i == 1):
        ans = ans + n
    else:
        for j in range(n):
            if li[j] == 1:
                ans = ans + 1
            else:
                if i >= (li[j] + 1) and i % (li[j]) == 1:
                    ans = ans + 1

print(ans + x)


Measured memory_bytes: 3064
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Ciniii(N,K,Q);
    vector<int> a(Q),acc(N,0);
    rep(i,Q){ 
        cin >> a[i]; 
        a[i]--;
        acc[a[i]]++;
    }

    // Q-acc[i]だけ減点されている
    rep(i,N){
        if(K<=Q-acc[i]){
            cout << "No" << nn;
        }else{
            cout << "Yes" << nn;
        }
    }
    return 0;
}

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

#define debug(x) cerr << #x << ": " << x << "\n"
#define all(a) a.begin() ,a.end()
#define rall(a) a.rbegin() ,a.rend()
#define _sort(a) sort(a.begin() ,a.end())

using namespace std;

using ll = long long;
using vi = vector<int>;
using vii = vector<int ,int>;

int main(){
    ios::sync_with_stdio(false) ,cin.tie(0);
    int n ,m , count  = 0;
    double sum = 0;
     cin >> n >> m;
    vector<double>a(n);
    for(auto &x:a)cin >> x , sum += x;
    double M = sum * 1 / (4*m);
    
    for(int i = 0 ; i < n ; i++){
        if(a[i] >=  M){
            count++;
        }
    }
    cout << (count >= m ? "Yes" : "No");
    return 0;
}
/*
*   created: 
*/

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define M 1000000
#define L 14

char H[M][L]; /* Hash Table */
long long getKey(char str[]);
int find(char str[]);
int insert(char str[]);

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[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;
}

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

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

/* convert a string into an integer value */
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 find(char str[]){
	long long i, key, num;
	
  	key = getKey(str);
  	
  	for ( i = 0; ; i++){
    num = (h1(key) + i * h2(key)) % M;
    if( strlen(H[num]) == 0 ) return 0;
    else if ( strcmp(H[num],str) == 0 ) return 1;
  }
  return 0;
}

int insert(char str[]){
	  long long i,key, h;
  key = getKey(str);
  for( i = 0; ; i++ ){
    h = (h1(key) + i*h2(key)) % M;
    if( strcmp(H[h], str) == 0 ) return 1;
    else if ( strlen(H[h]) == 0 ){
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;

}



Measured memory_bytes: 15408
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>

using namespace std;

int a[15];

bool solve(int n, int A, int B) {
	if (n == 10) return true;
	if (A < a[n] && solve(n+1, a[n], B)) return true;
	if (B < a[n] && solve(n+1, A, a[n])) return true;
	return false; 
}

int main() {
	int N;
	scanf("%d", &N);
	while (N--) {
		int i;
		for (i = 0; i < 10; i++) {
			scanf("%d", &a[i]);
		}
		if (solve(0, -1, -1)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1200