akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<functional>


using namespace std;

class Main{
public:
  void input();
  void run();

private:
  int N;
  int K;
};


void Main::input(){
  cin >> N >> K;
  return;
}


void Main::run(){
  cout << N-K+1 << endl;
  return;
}






int main(){
  Main m;
  m.input();
  m.run();
  return 0;
}



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

ll modPow(ll a, ll n) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  ll t = modPow(a, n / 2);
  return (t * t) % MOD;
}

int main(){
  ll N;
  string S;
  cin >> N >> S;
  vector<vector<ll>> dp(N,vector<ll>(N+1,0));
  rep(i,N){
    rep(j,N+1){
      if(i==0){
        if(j==0||j==1){
          dp.at(i).at(j)=j+1;
        }
      }else{
        if(j==0){
          dp.at(i).at(j)=dp.at(i-1).at(j)+dp.at(i-1).at(j+1);
        }else{
          if(j==N){
            dp.at(i).at(j)=2*dp.at(i-1).at(j-1);
          }else{
            dp.at(i).at(j)=2*dp.at(i-1).at(j-1)+dp.at(i-1).at(j+1);
          }
        }
      }
      dp.at(i).at(j)%=MOD;
    }
  }
  dp.at(N-1).at((ll)S.size())*=modPow(500000004,(ll)S.size());
  dp.at(N-1).at((ll)S.size())%=MOD;
  cout << dp.at(N-1).at((ll)S.size()) << endl;
        
}

Measured memory_bytes: 198804
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <string.h>
#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define LL long long
#define eps 1e-6
using namespace std;

ll length[100];
ll sum0[100];
ll sum = 0;
ll f(ll n,ll x0){
    if(n == 1){
        if(x0 == 1){
            return 0;
        }else if(x0 == 2){
            return 1;
        }else if(x0 == 3){
            return 2;
        }else if(x0 == 4){
            return 3;
        }else if(x0 == 5){
            return 3;
        }
    }
    if(x0 == 1){
        return 0;
    }else if(x0 == length[n]){
        return sum0[n];
    }if(x0 == ((length[n]+1)>>1)){
        return sum0[n-1]+1;
    }else if(x0 < ((length[n]+1)>>1)){
        return f(n-1,x0-1);
    }else{
        return f(n-1,(x0-length[n-1]-2))+sum0[n-1]+1;
    }
}


int main() {
    length[0] = 1;
    sum0[0] = 1;
    for(ll i = 1; i <= 50; i ++){
        length[i] = (length[i-1] *2 ) + 3;
        sum0[i] = sum0[i-1]*2+1;
    }
    //pld(sum0[50]); pn
    ll n,x;
    sld(n) sld(x);
    pld(f(n,x)); pn
    return 0;
}
//10 11 12 14 15


Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()]

# dp[i] = iマス目にたどり着くまでの最小コスト
dp = [float('inf')] * n
# 最初のマスまでのコストは0
dp[0] = 0
# 2マス目への行き方は「最初のマスから1つ進む」の1通り
dp[1] = abs(h[1] - h[0])
# 3マス目以降は「1つ前のマスから1つ進む」と「2つ前のマスから2つ進む」の2通り
for i in range(2,n):
    # 1つ前から移動したときの最小コスト
    step1 = dp[i-1] + abs(h[i] - h[i-1])
    # 2つ前から移動したときの最小コスト
    step2 = dp[i-2] + abs(h[i] - h[i-2])
    dp[i] = min(step1, step2)
print(dp[n-1])

Measured memory_bytes: 13708
class Dice:
  __table =[[0,1,2,3,4,5],[0,2,4,1,3,5],[0,4,3,2,1,5],[0,3,1,4,2,5],
            [1,5,2,3,0,4],[1,2,0,5,3,4],[1,0,3,2,5,4],[1,3,5,0,2,4],
            [2,5,4,1,0,3],[2,4,0,5,1,3],[2,0,1,4,5,3],[2,1,5,0,4,3],
            [3,5,1,4,0,2],[3,1,0,5,4,2],[3,0,4,1,5,2],[3,4,5,0,1,2],
            [4,2,5,0,3,1],[4,5,3,2,0,1],[4,3,0,5,2,1],[4,0,2,3,5,1],
            [5,1,3,2,4,0],[5,3,4,1,2,0],[5,4,2,3,1,0],[5,2,1,4,3,0]]
  __another = []
  def __init__(self,dice):
    self.dice = dice
    for t in self.__table:
      a = []
      for v in t:
        a.append(dice[v])      
      self.__another.append(a)
      
  def output(self):
    print(self.dice[0])
    
  def right_dise(self,a,b):
    for t in self.__another:
      if t[0] == a and t[1] == b:
        return t[2]

  def comparison(self,dice):
    result = 0
    for table_temp in self.__another:
      table_temp = ''.join(map(str,table_temp))
      dice = ''.join(map(str,dice))
      if table_temp == dice:
        print('Yes')
        result = 1
        break
    if result == 0:
      print('No')
        
  def move(self,str):
    if str == 'N':
      temp = self.dice[0]
      self.dice[0] = self.dice[1]
      self.dice[1] = self.dice[5]
      self.dice[5] = self.dice[4]
      self.dice[4] = temp
    elif str == 'S':
      temp = self.dice[0]
      self.dice[0] = self.dice[4]
      self.dice[4] = self.dice[5]
      self.dice[5] = self.dice[1]
      self.dice[1] = temp
    elif str == 'E':
      temp = self.dice[0]
      self.dice[0] = self.dice[3]
      self.dice[3] = self.dice[5]
      self.dice[5] = self.dice[2]
      self.dice[2] = temp
    elif str == 'W':
      temp = self.dice[0]
      self.dice[0] = self.dice[2]
      self.dice[2] = self.dice[5]
      self.dice[5] = self.dice[3]
      self.dice[3] = temp      
  
      
di1 = list(map(int,input().split()))
di2 = list(map(int,input().split()))
di = Dice(di1)

di.comparison(di2)


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

int main()
{
  const int MAX_N = 100000;
  const int MAX_DEPTH = 20;

  vector<vector<double> > dp(MAX_N, vector<double>(MAX_DEPTH, 0.0));
  dp[0][1] = 1.0;
  for (int i = 1; i < MAX_N; ++i) {
    dp[i][1] += dp[i-1][0];
    for (int j = 2; j < MAX_DEPTH; ++j) {
      double p = 1.0 / (1 << (j-1));
      dp[i][j] += p * dp[i-1][j-1];
      dp[i][0] += (1.0 - p) * dp[i-1][j-1];
    }
  }

  for (int i = 1; i < MAX_N; ++i) {
    for (int j = MAX_DEPTH-1; j > 1; --j)
      dp[i][j-1] += dp[i][j];
    dp[i][1] += dp[i-1][1];
  }

  int n;
  while (~scanf("%d", &n)) {
    if (n == 0)
      break;
    printf("%.8f\n", dp[n-1][1]);
  }
  return 0;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

signed main(){
    ll H, W;
    cin >> H >> W;
    if(H == 1 || W == 1){
        PRINT("1");
        return 0;
    }
    PRINT(((H + 1) / 2) * ((W + 1) / 2) + (H / 2) * (W / 2));
    return 0;   
}

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

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int N;

int f[11];

// 6 8 4 2 7 5 3 1
// (5~1) ... (7!)
// 6 (7~1) ... (6!)
// 6 8 

// 1 3 2
// (0) ... (2!) 0
// 1 (2~1) 1!
// 1 3 2

int calc(vector<int> a) {
    int ret = 0;
    rep(i, N) {
        int cnt = 0;
        rep(j, i) if (a[i] > a[j]) cnt++;
        int tmp = (a[i] - 1 - cnt) * f[(N - (i+1))];
        //cout << tmp << endl;
        ret += tmp;
    }

    return ret;
}

signed main()
{
    f[0] = 1;
    rep1(i, 10) f[i] = i * f[i-1];

    cin >> N;

    vector<int> P(N), Q(N);

    rep(i, N) cin >> P[i];
    rep(i, N) cin >> Q[i];

    // cout << "calc(P) = " << calc(P) << endl;
    // cout << "calc(Q) = " << calc(Q) << endl;

    int ans = calc(P) - calc(Q);
    if (ans < 0) ans = -ans;

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


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

  for(int i=0;i<N;i++){
    cin >> S.at(i);
  }

  sort(S.begin(),S.end());
  S.erase(unique(S.begin(),S.end()),S.end());
  cout << S.size() << endl;

}

Measured memory_bytes: 9596
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S1, S2;
    cin >> S1 >> S2;
    if(S1[0] == S2[2] && S1[1] == S2[1] && S1[2] == S2[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    //cout << S1;

    return 0;
}


Measured memory_bytes: 256
def kaibun(s):
    for i in range(round((len(s) / 2))):
        if s[i] == s[len(s) - i - 1]:
            continue
        else:
            return False
    return True


s = str(input())
n = len(s)
if kaibun(s):
    if kaibun(s[0:round((n - 1) / 2)]):
        if kaibun(s[round((n + 3) / 2) - 1:]):
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();
			
			if(op.equals("+")){
				System.out.println(a + b);
			}
			else if(op.equals("-")){
				System.out.println(a - b);
			}
			else if(op.equals("*")){
				System.out.println(a * b);
			}
			else if(op.equals("/")){
				System.out.println(a / b);
			}
			else if(op.equals("?")){
				break;
			}
		}
	}
}

Measured memory_bytes: 26208
#include<iostream>

using namespace std;

int main(){
    static bool not_prim[1000000];
    static int num_prim[1000000];
    for(int i=2;i<1000000;i++)
    {
        if(!not_prim[i])
        {
            for(int j=2;j*i<1000000;j++)
            {
                not_prim[i*j]=true;
            }
        }
        num_prim[i]=num_prim[i-1]+!not_prim[i];
    }
    int n;
    while(cin >> n){
    cout<<num_prim[n]<<endl;
    }
    return 0;
}

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

class Program
{
    bool[] visit;
    bool[] color; // [0] -> false
    List<List<Tuple<int, long>>> g = new List<List<Tuple<int, long>>>();
    void Run()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        visit = new bool[n];
        color = new bool[n];
        for (int i = 0; i < n; i++) g.Add(new List<Tuple<int, long>>());
        for (int i = 0; i < n - 1; i++)
        {
            int u = sc.NextInt() - 1;
            int v = sc.NextInt() - 1;
            long w = sc.NextLong();
            g[u].Add(Tuple.Create(v, w));
            g[v].Add(Tuple.Create(u, w));
        }

        Dfs(0, 0, false);


        for (int i = 0; i < n; i++)
        {
            Console.WriteLine(color[i] ? "0" : "1");
        }
    }

    void Dfs(int node, long dist, bool c)
    {
        if (visit[node]) return;
        visit[node] = true;
        color[node] = c;
        foreach (var next in g[node])
        {
            long d = dist + next.Item2;
            Dfs(next.Item1, d, next.Item2 % 2 == 0 ? c : !c);
        }
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


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

int main(){
    string s;
    cin >> s;
    string x = "";
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '0'){
            x += '0';
        }else if(s[i] == '1'){
            x += '1';
        }else if (s[i] == 'B'){
            if(x.size() == 0){
            continue;
        }
            x.erase(x.size()-1);
        }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

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

  vector<int> L(K);
  int ind = 0;
  rep(i, K) {
    while (S[ind] == 'x')
      ind++;
    L[i] = ind;
    ind += C + 1;
  }

  vector<int> R(K);
  ind = N - 1;
  repr(i, K - 1, 0) {
    while (S[ind] == 'x')
      ind--;
    R[i] = ind;
    ind -= C + 1;
  }

  rep(i, K) {
    if (L[i] == R[i])
      cout << (L[i] + 1) << endl;
  }
}

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

#define len(x)  (int((x).size()))
#define append push_back
#define pp make_pair
#define ff(a, b)    for (int a = 0; a < int(b); ++a)
#define kk(n)    ff(k, n)
#define xx(n)    ff(x, n)
#define yy(n)    ff(y, n)
#define ii(n)    ff(i, n)
#define fff(a, b, c) for (int a = int(b); a < int(c); ++a)
#define kkk(a, b) fff(k, a, b)
#define xxx(a, b) fff(x, a, b)
#define yyy(a, b) fff(y, a, b)
#define iii(a, b) fff(i, a, b)
#define bb begin()
#define ee end()
#define uu first
#define vv second
#define all(x)  (x).bb, (x).ee
#define ite(v)   decltype((v).bb)
#define fe(i, v) for(ite(v) i = (v).bb; i != (v).ee; ++i)
#define err(...)    { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#define zz(array, byte)   memset(array, byte, sizeof(array));

using LL = long long;
using DD = long double;
using pii = pair<int, int>;



const LL  INFLL  = 0x7f7f7f7f7f7f7f7fLL;
const int INFint = 0x7f7f7f7f;  //Works with memset(..).
 
     




int main() {
    ios_base::sync_with_stdio(false);     cin.tie(NULL);
    //cout << '\n';
    cout.precision(16);
    
    string s;
    cin >> s;
    int ps = 0;
    ii (len(s))
        if (s[i] == 'p')
            ++ps;

    cout << (len(s) / 2 - ps) << '\n';

    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int Func(int a) {
	if (a == 1)
		return 300000;
	if (a == 2)
		return 200000;
	if (a == 3)
		return 100000;
	else
		return 0;
}

int main(void) {
	int ans = 0, i, a, b;
	cin >> a >> b;
	ans += Func(a);
	ans += Func(b);
	if (a == 1 && b == 1)
		ans += 400000;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
      (cons (subseq str 0 pos)
            (split x (subseq str (+ pos size))))
      (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(princ (if (oddp (* (read) (read))) "Odd" "Even"))


Measured memory_bytes: 18488
#coding: utf-8

inputs = map(int, raw_input().split())
n = inputs[0]
k = inputs[1]
d = map(int, raw_input().split())
p = []

p.append(n//10000)
p.append(n//1000 - p[0]*10)
p.append(n//100 - p[0]*100 - p[1]*10)
p.append(n//10 - p[0]*1000 - p[1]*100 - p[2]*10)
p.append(n%10)

topindex = 0

for i in range(5):
    if p[i] != 0:
        topindex = i
        break

    
while True:
    dex = 0
    for i in range(topindex,5):
        if p[i] in d:
            dex = 1
    if dex == 1:
        n += 1
        p = []
        p.append(n//10000)
        p.append(n//1000 - p[0]*10)
        p.append(n//100 - p[0]*100 - p[1]*10)
        p.append(n//10 - p[0]*1000 - p[1]*100 - p[2]*10)
        p.append(n%10)

        topindex = 0

        for i in range(5):
            if p[i] != 0:
                topindex = i
                break
    else:
        break

print(n)

Measured memory_bytes: 2696
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cins(string, 2, n);
    Cout(n[0] < n[1] ? "<" : n[0] > n[1] ? ">" : "=");
}

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

int main() {
	int N,M;
	cin >> N >> M;
	int ans=1;
	if(M==1){
		for(int i=0; i<N; i++){
			ans*=2;
			ans%=1000000;
		}
	}else if(M==2){
		
	int up[N+1],middle[N+1],down[N+1],upsum[N+1],downsum[N+1];
	up[0]=1; middle[0]=1; down[0]=1; upsum[0]=1; downsum[0]=1;
	up[1]=3; middle[1]=3; down[1]=4; upsum[1]=4; downsum[1]=5;
	
	for(int i=2; i<=N; i++){
		down[i]=(up[i-1]+middle[i-1]+down[i-1]+upsum[i-2]+1)%1000000;
		middle[i]=(up[i-1]+middle[i-1]+down[i-1])%1000000;
		up[i]=(up[i-1]+middle[i-1]+down[i-1]+downsum[i-2])%1000000;
		
		upsum[i]=(upsum[i-1]+up[i])%1000000;
		downsum[i]=(downsum[i-1]+down[i])%1000000;
	}
		
		ans=down[N];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <limits>
#include <queue>
#include <iomanip>
#include <deque>
#include <stack>
#include <cstdio>
#include <cmath>
#include <complex.h>
#include <cstdio>
#include <random>
#include <chrono>
#include <numeric>
#include <cassert>
#include <iso646.h>
#include <exception>
#include <stdexcept>

using namespace std;

typedef long long i64;

struct Vertex
{
    i64 x, y;
};

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

    int N, K;
    cin >> N >> K;

    Vertex vertices[50];
    for (int i = 0; i < N; i++)
        cin >> vertices[i].x >> vertices[i].y;

    sort(vertices, vertices + N, [](auto& lhs, auto& rhs) { return make_pair(lhs.x, lhs.y) < make_pair(rhs.x, rhs.y); });

    i64 min_area = numeric_limits<i64>::max();
    for (int i = 0; i < N; i++)
    {
        for (int j = i; j < N; j++)
        {
            const int m = j - i + 1;
            Vertex middle_vertices[50];
            for (int k = i; k <= j; k++)
                middle_vertices[k - i] = vertices[k];

            sort(middle_vertices, middle_vertices + m, [](auto& lhs, auto& rhs) { return make_pair(lhs.y, lhs.x) < make_pair(rhs.y, rhs.x); });

            for (int i1 = 0; i1 < m; i1++)
            {
                for (int j1 = i1; j1 < m; j1++)
                {
                    i64 y0 = middle_vertices[i1].y;
                    i64 y1 = middle_vertices[j1].y;

                    const int verts_in_rect = j1 - i1 + 1;
                    bool good_range = vertices[i].y >= y0 && vertices[i].y <= y1;
                    good_range |= vertices[j].y >= y0 && vertices[j].y <= y1;

                    if (good_range && verts_in_rect >= K)
                    {
                        i64 x0 = vertices[i].x;
                        i64 x1 = vertices[j].x;

                        i64 dx = x1 - x0;
                        i64 dy = y1 - y0;

                        i64 rect_area = dx * dy;

                        min_area = min(min_area, rect_area);
                    }
                }
            }
        }
    }

    cout << min_area;
}

Measured memory_bytes: 256
#include <iostream>

#define MAXN 51

using namespace std;

int N, A, x[MAXN];
long long int dp[MAXN][MAXN*50][MAXN];

long long int f(int i, int s, int n) {
    if(dp[i][s][n] != -1) return dp[i][s][n];
    if(i == N) {
        if(s == A*n and n != 0)
            return dp[i][s][n] = 1;
        else
            return dp[i][s][n] = 0;
    }
    return dp[i][s][n] = f(i+1,s+x[i],n+1) + f(i+1,s,n);
}

int main() {
    cin >> N >> A;
    for(int i = 0; i < N; i++)
        cin >> x[i];
    for(int i = 0; i < MAXN; i++)
        for(int j = 0; j < MAXN*50; j++)
            for(int k = 0; k < MAXN; k++)
                dp[i][j][k] = -1LL;
    f(0,0,0);
    cout << dp[0][0][0] << endl;
    return 0;
}


Measured memory_bytes: 52096
#include<stdio.h>
using namespace std;
const int sss=1<<21;
int n;
int a[1000][1000];
int d[1000],p[10000],color[1000];
int prim(){
	int u,minv;
	for(int i=0;i<n;i++){
		d[i]=sss;
		p[i]=-1;
	}
	d[0]=0;
	while(1){
		minv=sss;
		u=-1;
		for(int i=0;i<n;i++){
			if(minv>d[i]&&color[i]!=1){
				u=i;
				minv=d[i];
			}
		}
		if(u==-1) break;
		color[u]=1;
		for(int v=0;v<n;v++){
			if(color[v]!=1&&a[u][v]!=sss){
				if(d[v]>a[u][v]){
					d[v]=a[u][v];
					p[v]=u;
				}
			}
		}
	}
	int sum=0;
	for(int i=0;i<n;i++){
		if(p[i]!=-1) {
			sum+=a[p[i]][i];
		}
	}
	return sum;
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			int e;scanf("%d",&e);
			a[i][j]=e==-1?sss:e;
		}
	}
	printf("%d\n",prim());
	return 0;
} 


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

int main() {
  int l, r, diff;
  cin >> l >> r;
  diff = r - l;
  l = l % 2019;
  r = l + diff;
  if (r >= 2019 || l == 0) {
    cout << 0 << endl;
  } else {
    int ans = 2019;
    for (int i = l; i < r; ++i) {
      for (int j = i + 1; j <= r; ++j)
	    ans = min(ans, i * j % 2019);
    }
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;
using ll = long long;

int x, y, z, k;
vector<ll> a, b, c;


//合計がn以上のものだけでk個以上作れるか？
bool chack(ll n)
{

    int cnt = 0;
    for(int I = 0; I < x; I++){
        for(int J = 0; J < y; J++){
            ll sum = a[I] + b[J];

            cnt += lower_bound(c.begin(), c.end(), n - sum) - c.begin();
        }
    }

    return (cnt >= k);

}





int main()
{
    cin >> x >> y >> z >> k;
    a.resize(x);
    b.resize(y);
    c.resize(z);
    for(int i = 0; i < x; i++){cin >> a[i];a[i] *= -1;}
    for(int i = 0; i < y; i++){cin >> b[i];b[i] *= -1;}
    for(int i = 0; i < z; i++){cin >> c[i];c[i] *= -1;}

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll left = -910000000000;
    ll right = 0;


    while(right - left > 1)
    {
        ll mid = (left + right) / 2;
        (chack(mid) ? right : left) = mid;
    }

    vector<ll> ans;

    for(int i = 0; i < x; i++){
        for(int j = 0; j < y; j++){
            for(int t = 0; t < z; t++){
                if(a[i] + b[j] + c[t] >= right || ans.size() >= 1000000)break;
                ans.push_back(a[i] + b[j] + c[t]);
            }
        }
    }

    sort(ans.begin(), ans.end());

    for(int i = 0; i < k; i++)cout << -ans[i] << endl;


}

Measured memory_bytes: 10096
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  bool map[100] = {};

  int tmp = a;
  while (true)
  {
    if (tmp % b == c)
    {
      cout << "YES" << endl;
      return 0;
    }
    if (map[tmp % b])
    {
      break;
    }
    map[tmp % b] = true;
    tmp += a;
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
int h[101010];

int main(){
    cin >> n;
    REP(i, n){
        cin >> h[i];
    }
    int ans = 0, num = 0;
    for(int i = n - 2;i >= 0;i--){
        if(h[i] >= h[i + 1])num++;
        else {
            ans = max(ans, num);
            num = 0;
        }
    }
    ans = max(ans, num);
    cout << ans << endl;
}

Measured memory_bytes: 640
N, K = map(int, input().split())

sum_tab = [0]
sum_tmp = 0
for i in range(N + 1):
    sum_tmp += i
    sum_tab.append(sum_tmp)

MY_DIV = 1000000007
    
ans = 0
for i in range(K, N + 2):
    # sum_min = sum_tab[i] - sum_tab[0]
    # sum_max = sum_tab[-1] - sum_tab[-1 - i]
    # print("#", i, (sum_min, sum_max))
    # ans_tmp = sum_max - sum_min + 1
    ans_tmp = ((N - i + 1) * i + 1) % MY_DIV
    #
    ans = (ans + ans_tmp) % MY_DIV

print(ans)

Measured memory_bytes: 19372
N = int(input())
a = list(map(int, input().split()))
aN = 0
al = [0] * (N + 1)
ans = []
for i in reversed(range(1, N + 1)):
    total = 0
    for j in range(2 * i, N + 1, i):
        total += al[j]
    if total % 2 != a[i - 1]:
        al[i] = 1
        ans.append(i)
ans.reverse()
print(len(ans))
for i in ans:
    print(i, end=' ')

Measured memory_bytes: 12116
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    while(cin >> n >> k, n | k)
    {
        vector<int> A(n);
        for(int i = 0; i < n; i++) cin >> A[i];
        vector<int> sum(n + 1, 0);
        for(int i = 1; i <= n; i++) sum[i] = sum[i - 1] + A[i - 1];
        int ans = -1;
        for(int i = 1; i <= n - k; i++)
        {
            ans = max(ans, sum[i + k] - sum[i]);
        }
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define debug(x) cout << #x << " = " << x << endl
#define print(x) cout << x << endl;
const ll MOD = 1000000007;

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

    set<int> sunuke;

    rep(i, K)
    {
        int d;
        cin >> d;
        rep(i, d)
        {
            int temp;
            cin >> temp;
            sunuke.insert(temp);
        }
    }

    cout << N - sunuke.size() << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, K;
    cin >> n >> K;
    vector<vector<vector<ll>>> dp(64, vector<vector<ll>>(n, vector<ll>(n)));
    vector<vector<vector<ll>>> f(2, vector<vector<ll>>(n, vector<ll>(n)));
    int pre = 0, cur = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> dp[0][i][j];
            if (K & 1) {
                f[0][i][j] = dp[0][i][j];
            }
        }
    }
    if ((K & 1LL) == 0) {
        for (int i = 0; i < n; i++) {
            f[0][i][i] = 1;
        }
    }
    for (int i = 1; i < 62; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                for (int l = 0; l < n; l++) {
                    dp[i][j][k] += dp[i - 1][j][l] * dp[i - 1][l][k] % MOD;
                    dp[i][j][k] %= MOD;
                }
                if ((K >> i) & 1LL) {
                    for (int l = 0; l < n; l++) {
                        f[cur][l][k] += f[pre][l][j] * dp[i][j][k] % MOD;
                        f[cur][l][k] %= MOD;
                    }
                }
            }
        }
        if ((K >> i) & 1) {
            swap(pre, cur);
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    f[cur][j][k] = 0;
                }
            }
        }
    }
    ll res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            res += f[pre][i][j];
            res %= MOD;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 1664
n = gets.to_i
ans = n.times.map{gets.chomp}

ac = 0
wa = 0
tle = 0
re = 0


ans.each do |r|
  if r == "AC"
    ac += 1
  elsif r == "WA"
    wa += 1
  elsif r == "TLE"
    tle += 1
  else
    re += 1
  end
end

puts "AC x #{ac}\nWA x #{wa}\nTLE x #{tle}\nRE x #{re}"

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  sort(H.begin(), H.end());
  int res = 1 << 30;
  for (int i = 0; i + K - 1 < N; i++) {
    res = min(res, H[i + K - 1] - H[i]);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 640
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> ns(255);
    for(int i = 0; i < n; i++){
        string s; cin >> s;
        ns[s[0]]++;
    }
    string s = "MARCH";
    ll ans = 0;
    for(int i = 0; i < 5; i++){
        for(int j = i + 1; j < 5; j++){
            for(int k = j + 1; k < 5; k++){
                ans += (ll)ns[s[i]] * ns[s[j]] * ns[s[k]];
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
def givel(): 
    n=int(input()) 
    l=[int(i) for i in input().split()] 
    curr = 0 
    i = 0 
    while i<len(l): 
        temp = i+1 
        ans = 0 
        while temp<len(l) and l[temp]<=l[temp-1]: 
            temp+=1 
            ans+=1 
        i=temp 
        curr = max(curr,ans) 
    return curr
print(givel())

Measured memory_bytes: 63984
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
bool isPrime[100010];
void set_prime() {
	for (int i = 1; i <= 100000; i++) {
		isPrime[i] = true;
	}
	isPrime[0] = false; isPrime[1] = false;
	for (int i = 2; i * i <= 100000; i++) {
		int j = 2;
		while (i * j <= 100000) {
			isPrime[i * j] = false;
			j++;
		}
	}
}
int l[100000], r[100000];
int main()
{
	int Q;
	scanf("%d", &Q);
	for (int i = 0; i < Q; i++) {
		scanf("%d%d", &l[i], &r[i]);
	}
	set_prime();
	int s[100010] = { 0 };
	s[0] = 0;
	for (int i = 1; i <= 100000; i++) {
		s[i] = s[i - 1];
		if (isPrime[i] && isPrime[(i + 1) / 2]) {
			s[i]++;
		}
	}
	for (int i = 0; i < Q; i++) {
		printf("%d\n", s[r[i]] - s[l[i] - 1]);
	}
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);

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

            // 解析
            List<int> lstOut = new List<int>();
            for (int i = 1; i <= iN ; i += 2)
            {
                int iCnt = 0;
                for (int j = 1; j <= i ; j++)
                {
                    if (i % j == 0) { iCnt += 1; }
                }
                lstOut.Add(iCnt);
            }
            int iOut = lstOut.Count(x=> x == 8);

            // 出力
            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: 13396
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int N, P[4], T[4];
//---------------------------------------------------------------------------------------------------
int ans = inf;
int cnt[4];
void dfs(int cu) {
	if (cu == 4) {
		int prize = 0;
		rep(i, 0, 4) prize += P[i] * cnt[i];
		int cha = 0;
		rep(i, 0, 4) cha += T[i] * cnt[i];

		if (N <= cha) chmin(ans, prize);

		return;
	}

	rep(i, 0, N + 1) {
		cnt[cu] = i;
		dfs(cu + 1);
	}
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, 4) cin >> P[i];
	rep(i, 0, 4) cin >> T[i];

	dfs(0);
	cout << ans << endl;
}





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

int main() {
  string S;
  cin >> S;
  if(S.at(0)=='7' | S.at(1)=='7' | S.at(2)=='7') cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
 
void Matrix(void);

int m[100][100]={0};
int p[100];
int length;
 
void Matrix(void){
    int x;
    int y;
    int i;
    int j;
    int k;
    int n = length;


 
  for(i=1;i<=n;i++){
    m[i][i]=0;
    }
     
   for(k=2;k<=n;k++){
    for(i=1;i<=n-k+1;i++){
      x = i + k-1;
      
 m[i][x]=2147483647; 


      for(j=i;j<=x-1;j++){
    y=m[i][j]+m[j+1][x]+p[i-1]*p[j]*p[x];
    if(m[i][x]>y) m[i][x]=y;
       }
      }
         
         
    }
     
}
 
int main(void){
  int a;
  int i;
    scanf("%d",&length);
     
    for(i=1 ; i <= length ; i++){
        scanf("%d %d", &a,&p[i]);
        if(i==1){
            p[0]=a;
        }
         
    }
         
    Matrix();
     
    printf("%d\n",m[1][length]);
     
     
    return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

ll histogram(vi h, int N) {
	stack<pair<int, int>> st;
	ll res = 0;
	REP(i,N) {
		if (st.empty()) {
			st.push(make_pair(h[i], i));
		} else {
			if (st.top().first < h[i]) {
				st.push(make_pair(h[i], i));
			} else if (st.top().first > h[i]) {
				int last_idx;
				while (!st.empty()) {
					if (st.top().first >= h[i]) {
						auto _top = st.top(); st.pop();
						res = max(res, (ll)_top.first * (i - _top.second));
						last_idx = _top.second;
					} else break;
				}
				st.push(make_pair(h[i], last_idx));
			}
		}
	}
	return res;
}

void Main() {
	int H, W; cin >> H >> W;
	vvi c(H, vi(W));
	REP(i,H) REP(j,W) {
		cin >> c[i][j];
	}
	vvi h(H, vi(W + 1));
	REP(i,H) REP(j,W + 1) {
		if (j == W) {
			h[i][j] = 0;
			continue;
		}
		if (c[i][j] == 1) {
			h[i][j] = 0;
			continue;
		}
		if (i == 0) {
			h[i][j] = 1;
			continue;
		}
		h[i][j] = h[i - 1][j] + 1;
	}
	long long res = 0;
	REP(i,H) {
		res = max(res, histogram(h[i], W + 1));
	}
	cout << res << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



Measured memory_bytes: 18268
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n=s.size();
  vector<long long> A(n+1,0),B(n+1,0),C(n+1,0),D(n+1,0);
  D[0]=1;
  for(int i=0;i<n;i++){
    A[i+1]=A[i];
    C[i+1]=C[i];
    B[i+1]=B[i];
    D[i+1]=D[i];
    if(s[i]=='A')
      A[i+1]=(A[i+1]+D[i])%(1000000007);
    else if(s[i]=='B')
      B[i+1]=(B[i+1]+A[i])%(1000000007);
    else if(s[i]=='C')
      C[i+1]=(C[i+1]+B[i])%(1000000007);
    else{
      A[i+1]=(long long)(A[i+1]*3+D[i])%(1000000007);
      B[i+1]=(long long)(B[i+1]*3+A[i])%(1000000007);
      C[i+1]=(long long)(C[i+1]*3+B[i])%(1000000007);
      D[i+1]=(long long)(D[i+1]*3)%(1000000007);
    }
  }
  cout << C[n] << endl;
 // for(int i=0;i<n+1;i++)
   // cout << D[i] <<' ' << A[i] << ' ' << B[i] << ' ' << C[i] << endl;
}

Measured memory_bytes: 3584
function main()
	a = parse.(split(readline()))
	x = parse.(split(readline()))
	y = parse.(split(readline()))
	max = -100
	min = 100
	for i in 1:a[1]
		if max <= x[i]
			max = x[i]
		end
	end
	for i in 1:a[2]
		if min >= y[i]
			min = y[i]
		end
	end
	if a[3] >= a[4] || max >= min || max >= a[4] || min <= a[3]
		print("War")
	else
		print("No War")
	end
end


main()


Measured memory_bytes: 180752
N,P=map(int,input().split())
A=list(map(int,input().split()))
odd=0
for i in range(N):
  if A[i]%2==1: odd+=1
if odd==0:
  if P==1: print(0)
  else: print(2**N)
else:
  print(2**(N-1))

Measured memory_bytes: 3060
package main

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

func main() {
	log.SetFlags(log.Lshortfile)
	n := nextInt()
	k := -1
	for m := 1; m < n*2; m++ {
		if m*(m+1)/2 == n && m*(m+1)%2 == 0 {
			k = m + 1
			break
		}
	}
	if k == -1 {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
	log.Println(k)
	z := make([][]int, k)
	cnt := 1
	for i := 0; i < k; i++ {
		for j := i + 1; j < k; j++ {
			z[i] = append(z[i], cnt)
			z[j] = append(z[j], cnt)
			cnt++
		}
	}
	fmt.Println(len(z))
	for i := 0; i < k; i++ {
		fmt.Printf("%d", len(z[i]))
		for j := 0; j < len(z[i]); j++ {
			fmt.Printf(" %d", z[i][j])
		}
		fmt.Println()
	}
}
func Max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func Min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func Sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func Abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int h, w, d; cin >> h >> w >> d;
    vector<pair<int, int>> v(h*w + 1);
    repeat (i, h) {
        repeat (j, w) {
            int t; cin >> t;
            pair<int, int> p {i, j};
            v[t] = p;
        }
    }
    
    auto getdis = [](const vector<pair<int, int>> &v, int a, int b) -> int {
        pair<int, int> src = v[a];
        pair<int, int> dst = v[b];
        return abs(src.fst - dst.fst) + abs(src.snd - dst.snd);
    };
    
    vector<vector<int>> s(d);
    s[0].emplace_back(0);
    
    repeat_from_to (i, 1, h*w) {
        int x = i % d;
        int y = i / d;
        int t;
        //dump(x); dump(y); el;
        if (y == 0) {
            t = 0;
        }
        else {
            t = s[x][y-1] + getdis(v, i, i-d);
        }
        s[x].emplace_back(t);
    }
    
    //repeat(i, d) {dump(i); vdump(s[i]); el;}
    
    int q; cin >> q;
    rep (q) {
        int lo, hi; cin >> lo >> hi;
        int x = lo % d;
        cout << s[x][hi/d] - s[x][lo/d] << endl;
    }
}


Measured memory_bytes: 6016