akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<int,int> pii;
#define endl '\n'
#define F first
#define S second
const int MAX_N=3e3+3;

char s[MAX_N], t[MAX_N];
int n, m;
int dp[MAX_N][MAX_N];
pii track[MAX_N][MAX_N];
char ans[MAX_N];

int main()
{
	scanf("%s",s+1);
	scanf("%s",t+1);
	n=strlen(s+1);
	m=strlen(t+1);
	for(int i=1;s[i];i++) for(int j=1;t[j];j++)
	{
		dp[i][j]=max({dp[i-1][j],dp[i][j-1],dp[i-1][j-1]+(s[i]==t[j])});
		if(dp[i][j]==dp[i-1][j]) track[i][j]={i-1,j};
		else if(dp[i][j]==dp[i][j-1]) track[i][j]={i,j-1};
		else track[i][j]={i-1,j-1};
	}
	for(int i=n,j=m,len=dp[i][j],nxt;len!=0;)
	{
		nxt=dp[track[i][j].F][track[i][j].S];
		if(nxt!=len) ans[nxt]=s[i];
		tie(i,j)=track[i][j];
		len=nxt;
	}
	printf("%s\n",ans);
	return 0;
}



Measured memory_bytes: 105856
-- fairness.hs --- Fairness

-- author: Seong Yong-ju <sei40kr@gmail.com>

solve :: Integer -> Integer -> Integer -> Integer -> Maybe Integer
solve a b _ k =
  if abs ans <= ((10 :: Integer) ^ (18 :: Integer))
    then Just ans
    else Nothing
  where
    ans =
      (a - b) *
      (if odd k
         then -1
         else 1)

main :: IO ()
main = do
  [a, b, c, k] <- map (read :: String -> Integer) . words <$> getLine
  putStrLn $ maybe "Unfair" show $ solve a b c k


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;

int main() {
  string s;
  cin >> s;
  
  s.at(5) = ' ';
  s.at(13) = ' ';
  
  cout << s << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repe(i,n) for(int i = 0; i <= (int)(n); i++)
typedef vector<int> VI; typedef vector<VI> VVI;
typedef vector<string> VS; typedef vector<VS> VVS;
typedef pair<int, int> PII;
typedef long long LL;


int main(){
  LL sum = 0;
  VI num(1000000, 0);
  int i = 0;
  string s;
  cin >> s;

  while (i != (s.size())) {
    int a = 0, b = 0, j = 0;

    if (s[i] == '<')  { 
      while (s[i] == '<') { a++; i++; }
      for (j = (i-a); j <= i; j++) num[j] += j - (i-a);
    } else  { 
      while (s[i] == '>') { b++; i++; } 
      for (j = i; j >= (i-b); j--) {
        num[j] = (i - j);
      }
      j++;
      if (j != 0 && num[j] <= num[j-1]) num[j] = (num[j-1] + 1);
    }
  }

  //cout << num[0];
  //rep(i, s.size()) {
  //  cout << " " << s[i] << " " << num[i+1];
  //}
  //cout << endl;

  rep(i,s.size()+1) {
    sum += num[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 4740
#include<bits/stdc++.h>
using namespace std;
#define int  unsigned long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int x,maxi=0,y=0;

signed main(){
  int N,K;
  cin >> N >> K;
  int A[2000+10];
  rep(i,N){
    cin >> A[i];
  }
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(A[i] > A[j]) y++;
    }
  }
  int h;
  if(K%2==0) h=0;
  else h=1;

  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      if(A[i] > A[j]){
        /*int number = A[i];
        A[i] = A[j];
        A[j] = number;*/
        x++;
      }
    }
  }
  //cout << x << endl;
  if(h==0) cout << (x*K%1000000007+((K/2)*y)%1000000007*(K-1)%1000000007)%1000000007 << endl;
  else cout << (x*K%1000000007+(((K-1)/2)*y)%1000000007*K%1000000007)%1000000007 << endl;
  //cout << (((x*((1+K))%1000000007)*K)%1000000007)/2 << endl;
  //cout << x*(1+K)*K/2%1000000007<< endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;

ll n, m, l=1, g, a[100005];

int main() {
	ll i;
	cin >> n >> m;
	for(i=0; i<n; i++) {
		scanf("%lld", &a[i]);
		a[i] /= 2;
		l = l / __gcd(l, a[i]) * a[i];
	}
	for(i=0; i<n; i++) {
		if(l / a[i] % 2 == 0) {puts("0"); return 0;}
	}
	cout << (m / l + 1) / 2;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>

using namespace std;
 
int main(void){
	
	int N,M,count=0,check;
	
	cin>>N>>M;
	
	int L[M],R[M];
	//int L2[M],R2[M];
	
	for(int i=0;i<M;i++){
		cin>>L[i]>>R[i];
	}
	
	sort(L,L+M);
	sort(R,R+M);
	
	int a=R[0]-L[M-1];
	
	if(a<0)
		cout<<0;
	else if(a>=0)
		cout<<a+1;
	
	/**for(int i=0;i<N;i++){
		check=0;
		for(int j=0;j<M;j++){
			if(i>=L[j]-1 && i<=R[j]-1){
				check++;
			}
		}
		if(check==M){
			count++;
		}
	}**/
	
	return 0;
}

Measured memory_bytes: 1024
{-# LANGUAGE OverloadedStrings #-}

import           Data.Bool
import           Data.Maybe
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = solve <$> getParams >>= B.putStrLn

getParams :: IO [Int]
getParams = readInts <$> B.getLine

readInts :: B.ByteString -> [Int]
readInts = map readInt . B.words

readInt :: B.ByteString -> Int
readInt = fst . fromJust . B.readInt

solve :: [Int] -> B.ByteString
solve = bool "bust" "win" . (<= 21) . sum


Measured memory_bytes: 380
def solve(N, A, B):
    if A % 2 == B % 2:
        return (B - A) // 2
    return min(A-1, N-B) + 1 + (B - A -1)//2

if __name__ == "__main__":
    n, a, b = map(int, input().split())
    print(solve(n, a, b))


Measured memory_bytes: 2940
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

uint64_t diff_abs(uint64_t x, uint64_t y)
{
  return x >= y ? x - y : y - x;
}

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

  vector<uint64_t> h(N);
  N_TIMES(n, N) { cin >> h[n]; }

  vector<uint64_t> dp(N, 1e+12);
  dp[0] = 0;

  N_TIMES(n, N - 1) {
    for (uint64_t k = 1; k <= K; ++k) {
      if (n + k < N) {
        dp[n + k] = min(dp[n + k], dp[n] + diff_abs(h[n], h[n + k]));
      }
    }
  }

  cout << dp[N - 1] << endl;

  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int n=s.length();
    string s1="es";
    string s2="s";
    if(s[n-1]=='s')
    {
        s=s+"es";
    }
    else
    {
        s=s+"s";
    }
    cout<<s<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n; cin >> n;
	string s; cin >> s;
	ll r=0, g=0, b=0;
	rep(i,n){
		if(s[i]=='R') r++;
		else if(s[i]=='G') g++;
		else b++;
	}
	ll ans = r*g*b;
	rep(i,n-2){
		REP(j,i+1,n-1){
			if(2*j-i >= n) break;
			if(s[i]!=s[j] && s[j]!=s[2*j-i] && s[i]!=s[2*j-i]) ans--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int p[1010];
    for(int i = 0; i < n; i++) cin >> p[i];
    sort(p, p+n);
    int ans = 0;
    for(int i = 0; i < k; i++) ans += p[i];
    cout << ans << endl;
      
}


Measured memory_bytes: 3648
// ABC049_A
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    char ch;
    cin >> ch;
    
    // calculation
    if (ch == 'a' || ch == 'e' ||ch == 'i' ||ch == 'o' ||ch == 'u'){
        cout << "vowel" << "\n";
    } else {
        cout << "consonant" << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define MAX 200000
using namespace std;
vector<int> v[MAX+1];
bool visited[MAX+1];
int dfs(int x)
{
	visited[x] = true;
	int res = 1;
	for(int y:v[x])
	{
		if(visited[y])
			continue;
		res += dfs(y);
	}
	return res;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	while(m--)
	{
		int x,y;
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	int ans = 1;
	for(int i=1;i<=n;++i)
	{
		if(visited[i])
			continue;
		ans = max(ans,dfs(i));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 24160
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

using namespace std;


int main(){
   ll n,a,b,c,d,e;
   cin>>n>>a>>b>>c>>d>>e;
   ll x=min({a,b,c,d,e});

   cout<<ll(ceil(double(n)/x)+4);

return 0;
}



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

using ll = long long;
using ld  = long double;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
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 << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
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] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //




// --------- library end - //


int main(){

  ll X = il();
  if (X >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;



}

Measured memory_bytes: 3676
package main

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

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

type vert struct {
	a int
	b int
}

func main() {
	sc.Split(bufio.ScanWords)
	
	 n,m := scanInt(),scanInt()
	 g := make([][]int,n)
	 
	 for i := 0; i < m; i++ {
		 u,v := scanInt()-1,scanInt()-1
		 g[u] = append(g[u], v)
	 }

	 s,t := scanInt()-1,scanInt()-1

	 g3 := make([][]int, n)
	 for i := 0; i < n; i++ {
		 g3[i] = []int{-1,-1,-1}
	 }

	 g3[s][0] = 0

	 q := make([]vert, 0)
	 q = append(q, vert{s,0})

	 for len(q) > 0 {
		 a,b := q[0].a, q[0].b
		 for _, e := range g[a] {
			 if g3[e][(b+1)%3] != -1 {
				continue
			 }

			g3[e][(b+1)%3] = g3[a][b]+1
			q = append(q, vert{e,(b+1)%3})
		 }

		 q = q[1:]
	 }

	 if g3[t][0] == -1 {
		 fmt.Println(-1)
	 } else {
		 fmt.Println(g3[t][0]/3)
	 }

}


Measured memory_bytes: 20736
#include <iostream>

int main()
{
  for ( ; ; ) {
    int h, w ;
    std::cin >> h >> w ;

    if ( h == 0 && w == 0 )
      return 0 ;
    
    for ( int i = 0 ; i < h ; ++i ) {
      for ( int j = 0 ; j < w ; ++j ) {
        if ( ( i + j ) % 2 )
          std::cout << "." ;
        else
          std::cout << "#" ;
      }
      std::cout << std::endl ;
    }
    std::cout << std::endl ;
  }
  return 0 ;
}

Measured memory_bytes: 2988
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define fi first
#define se second
#define eb emplace_back
#define ef emplace_front
#define pof pop_front()
#define pob pop_back()
#define Rep(i,n) for(li i=0,nn=(li)(n);i!=nn;++i)
#define Rep1(i,n) for(li i=1,nn=(li)(n)+1;i!=nn;++i)
#define Size(v) (li)(v.size())
#define SortA(v) sort(v.begin(),v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii);}
#define Input2(a,b) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii)>>(b).at(ii);}
#define mp make_pair
using li = int64_t;
using intl = int64_t;
using vi = vec<li>;
using vb = vec<bool>;
using vvi = vec<vi>;
using qi = deque<li>;
using pi = pair<li,li>;
using vpi = vec<pi>;
using si = set<li>;
using vsi = vec<si>;
using mii = map<li,li>;
using vmii = vec<mii>;
vec<li> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<li> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr li INF = 9223372036854775807;

void Yes(li b){
  if(b)cout<<"Yes";
  else cout<<"No";
}
void yes(li b){
  if(b)cout<<"yes";
  else cout<<"no";
}

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

  int N,K;

  cin >>N>>K;

  vi A(N);
  Input(A);

  for(int i=K;i<N;++i){
  	Yes(A[i]>A[i-K]);
  	cout <<'\n';
  }
}

Measured memory_bytes: 4772
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iterator>
#include <cstdlib>
#include <algorithm>
using namespace std;

typedef vector<int> vint;

vint input(int sz){
	string s;
	getline(cin, s);
	stringstream ss1(s), ss2;
	istream_iterator<int> b(ss1), e;
	vint v(b, e);
	if(cin.eof() || v.size() != sz){ throw ""; }
	for(int i = 0; i < sz; ++i){
		if(i){ ss2 << ' '; }
		ss2 << v[i];
	}
	string t = ss2.str();
	if(s != t){ throw 0; }
	return v;
}

int main(){
	for(int i = 0; i < 7; ++i){
		vint v = input(2);
		cout << v[0] - v[1] << '\n';
	}

	cin.peek();
	if(!cin.eof()){
		exit(EXIT_FAILURE);
	}
}

Measured memory_bytes: 1248
s = gets.chomp.split("").sort
t = gets.chomp.split("").sort.reverse
slen = s.length
tlen = t.length
ss = ""
tt = ""
slen.times do |i|
  ss = ss + s[i]
end
tlen.times do |i|
  tt = tt + t[i]
end
if ss < tt
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 14256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()

def max_rect_in_hist(Hist):
    Hist.append(0)
    ans=0
    Q=[(-1,0)]
    for i,h in enumerate(Hist):
        while(Q[-1][1]>h):
            i0,h0=Q.pop()
            ans=max(ans,h0*(i-Q[-1][0]-1))
        if(Q[-1][1]<=h):
            Q.append((i,h))
    return ans

def resolve():
    h,w=map(int,input().split())
    C=[list(map(lambda x:1-int(x),input().split())) for _ in range(h)]
    from itertools import product
    for i,j in product(range(h-1),range(w)):
        if(C[i+1][j]): C[i+1][j]+=C[i][j]
    print(max(max_rect_in_hist(c) for c in C))
resolve()


Measured memory_bytes: 51996
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>
#include <numeric>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);j++)
#define frk(n) for(k=0;k<(n);k++)
#define frl(n) for(l=0;l<(n);l++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vvvd vector<vector<vector<double>>>


//#define int long long

using namespace std;


const int MAX = 510000;

ll mod_inverse(int a,int M){
	int x=M-2;
	ll temp=a;
	ll ret=1;
	//a^(MOD-1)==1(mod MOD)を利用
	//a^-1==a^(MOD-2) (mod MOD)を繰り返し二乗法で求める

	while(x!=0){
		if(x%2==1){
			ret=(ret*temp)%M;
		}
		temp=(temp*temp)%M;
		x=x/2;
	}
	return ret;
}

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

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

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

signed compare_int(const void *a, const void *b)
{
	int *A = (int *)a;
	int *B = (int *)b;
	if (*A < *B) return 1;
	if (*A > *B) return -1;
	return 0;
}


int gcd(int a,int b){
	while(1==1){
		if(a==0||b==0){
			return a+b;
		}else if(a>b){
			a %= b;
		}else{
			b %= a;
		}
	}
}

signed main(void)
{
	//変数の宣言
	int n,m,q;
	int h,w;
	static int a[100010];
	static int s[100010];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int temp3=0;
	vector<int> vec;
	vector<int> vtemp;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	static char stemp[100010];
	vvi graph;
	
	//データの読み込み


	scanf("%s",&stemp);
	//scanf_s("%s",&stemp,200);


	//scanf("%s",&s);
	//scanf_s("%s",&s,200010);


	/*for(i=0;i<n;i++){
		//scanf("%d",&a[i]);
		scanf_s("%d",&a[i]);
	}

	for(i=0;i<q;i++){
		//scanf("%d",&s[i]);
		scanf_s("%d",&s[i]);
	}*/



	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

//	clock_t start=clock();
//	COMinit();
	
	if(stemp[0]=='7'||stemp[1]=='7'||stemp[2]=='7'){
		printf("Yes");
	}else{
		printf("No");
	}

//	clock_t end=clock();

	//	printf("計算部分終了\n");

	//出力
	
	//printf("%d",(d[i-1][j-1]+1)/2);

//	printf("time=%lf",(double)(end-start)/CLOCKS_PER_SEC);
	//	printf("結果の出力終了\n");

	return 0;
}



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

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

int main() {
  int s;
  cin >> s;
  vector<ll> sv(1000005);
  unordered_set<ll> us;
  sv[1] = s;
  us.emplace(s);
  ll ans = 0;
  for (ll i = 2; i <= 1000000; ++i) {
    if (sv[i - 1] % 2 == 0) {
      sv[i] = sv[i - 1] / 2;
      if (us.find(sv[i]) == us.end()) {
        us.emplace(sv[i]);
      } else {
        ans = i;
        break;
      }
    } else {
      sv[i] = 3 * sv[i - 1] + 1;
      if (us.find(sv[i]) == us.end()) {
        us.emplace(sv[i]);
      } else {
        ans = i;
        break;
      }
    }
  }

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


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> test(n);
    rep(i,n) cin >> test[i];
    for(int i=k; i<n; i++){
        if(test[i]>test[i-k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

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

int n,h;
int a,b;
bool c[500*500*500];
string z;

int main(){
  for(;;){
    cin >> n >> h;
    if(!n && !h)break;

    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	for(int k=0;k<n;k++)c[i*n*n+j*n+k] = true;

    int cnt = 0;
    for(int i=0;i<h;i++){
      cin >> z >> a >> b;
      a--;
      b--;
      if(z == "xy")
	for(int j=0;j<n;j++){
	  if(c[a*n*n+b*n+j]){
	    cnt++;
	    c[a*n*n+b*n+j] = false;
	  }
	}
      else if(z=="yz")
	for(int j=0;j<n;j++){
	  if(c[j*n*n+a*n+b]){
	    cnt++;
	    c[j*n*n+a*n+b] = false;
	  }
	}
      else 
	for(int j=0;j<n;j++){
	  if(c[a*n*n+j*n+b]){
	    cnt++;
	    c[a*n*n+j*n+b]= false;
	  }
	}
    }

    cout << n*n*n-cnt << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Main {
    int H, W, N;
    int sr, sc;
    string S, T;
    void input() {
        cin >> H >> W >> N;
        cin >> sr >> sc >> S >> T;
        --sr;
        --sc;
    }
    void output() {
        string d = "LURDLU";
        int dr[] = {0, -1, 0, 1, 0, -1};
        int dc[] = {-1, 0, 1, 0, -1, 0};
        REP(i, 4) {
            int r = sr, c = sc;
            REP(j, N) {
                if (S[j] == d[i]) {
                    r += dr[i];
                    c += dc[i];
                    if (r < 0 || r >= H || c < 0 || c >= W) {
                        cout << "NO" << endl;
                        return;
                    }
                }
                if (T[j] == d[i + 2]) {
                    r += dr[i + 2];
                    c += dc[i + 2];
                    r = max(0, r);
                    r = min(H - 1, r);
                    c = max(0, c);
                    c = min(W - 1, c);
                }
            }
        }
        cout << "YES" << endl;
    }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


Measured memory_bytes: 3976
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  long H,W;
  cin>>H>>W; 
  if(H==1||W==1){
    cout<<1<<endl;
  }
  else{
  if(H%2==1&&W%2==1){
    cout<<H*W/2+1<<endl;
  }
  else{
    cout<<H*W/2<<endl;
  }
  }
}




Measured memory_bytes: 256
# -- coding: utf-8 --
def find_word():
    word = input()
    alpha = [chr(i) for i in range(97, 97+26)]
    alpha_set = set(alpha)
    word_set = set(list(word))
    if alpha_set - word_set:
        for w in alpha:
            if not w in word:
                return (word + w)
    else:
        for i, w in enumerate(word[::-1]):
            new_word = word[:(-1 * (i + 1))]
            for j in range(1, 27):
                if 97 <= ord(w) + j <= 122 and not chr(ord(w) + j) in new_word:
                    return (new_word + chr(ord(w) + j))
    return -1

if __name__ == '__main__':
    print(find_word())

Measured memory_bytes: 3064
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ret = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if 500*a+100*b+50*c == X:
        ret += 1
print(ret)

Measured memory_bytes: 3060
n = int(input())
a = sorted([int(i) for i in input().split()])
a_i = (a[-1]+1)//2
ans = 0
for i in range(n):
    while abs(a_i - a[i]) < abs(a_i - ans):
        ans = a[i]
print(a[-1]," ",ans)

    


Measured memory_bytes: 14052
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;

int main(){
    double a,b;
    int C;
    cin>>a>>b>>C;
    double S,L,h;
    S=a*b*sin(C*2*M_PI/360)/2;
    L=a+b+sqrt(a*a+b*b-2*a*b*cos(C*2*M_PI/360));
    h=2*S/a;
    printf("%.5f\n%.5f\n%.5f\n",S,L,h);
    return 0;
}


Measured memory_bytes: 3656
using System;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int[] a = sc.IntArray();

        int zero = 0;
        int one = 0;
        int two = 0;

        foreach (int i in a)
        {
            if (i % 2 == 1)
            {
                zero++;
            }
            else if (i % 4 == 2)
            {
                one++;
            }
            else
            {
                two++;
            }
        }

        // tztz

        if (two + 1 == zero && one == 0)
        {
            Console.WriteLine("Yes");
            return;
        }

        if (two >= zero)
        {
            Console.WriteLine("Yes");
            return;
        }

        Console.WriteLine("No");
    }

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

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 20448
#include<bits/stdc++.h>
#define LL long long
#define mm(a,b) memset(a,b,sizeof(a))
using namespace std;
const LL mod=1e9+7;
LL dp[55];
char s[2][55];
int main(){
//	freopen("input.txt","r",stdin);
	int n;
	scanf("%d",&n);
	for(int i=0;i<=1;i++) scanf("%s",s[i]);
	for(int j=0;j<n;j++){
		if(s[0][j]==s[1][j]){
			if(j==0) dp[j]=3;
			else{
				if(s[0][j-1]==s[1][j-1]) dp[j]=(dp[j-1]*2)%mod;
				else dp[j]=dp[j-1];
			}
		}
		else{
			if(j==0) dp[j+1]=6,j++;
			else{
				if(s[0][j-1]==s[1][j-1]) dp[j+1]=(dp[j-1]*2)%mod;
				else dp[j+1]=(dp[j-1]*3)%mod;
				j++;
			}
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

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

T1,T2 = LI()
A1,A2 = LI()
B1,B2 = LI()

if A1 > B1 and A2 > B2:
    print(0)
    exit()
if A1 < B1 and A2 < B2:
    print(0)
    exit()

if A1 > B1:
    t = (A1-B1)*T1 / (B2-A2)
    delta = (A1-B1)*T1+(A2-B2)*T2
    if t == T2:
        print('infinity')
        exit()
    elif t > T2:
        print(0)
        exit()
    else:
        if delta > 0:
            print(math.floor((T2-t)*(B2-A2)/delta) + 1)
            exit()
        else:
            x = (A1-B1)*T1 / (-delta)
            if int(x) == x:
                print(2*int(x))
            else:
                print(2*math.floor(x)+1)

else:
    t = (B1-A1)*T1 / (A2-B2)
    delta = (B1-A1)*T1+(B2-A2)*T2
    if t == T2:
        print('infinity')
        exit()
    elif t > T2:
        print(0)
        exit()
    else:
        if delta > 0:
            print(math.floor((T2-t)*(A2-B2)/delta) + 1)
            exit()
        else:
            x = (B1-A1)*T1 / (-delta)
            if int(x) == x:
                print(2*int(x))
            else:
                print(2*math.floor(x)+1)

Measured memory_bytes: 38420
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define int long long
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
    const int MAX =200005;
const int MOD =1e9+7;
using mint = modint998244353;
//using mint = modint;
using S=int;
using F=int;
S op(S a,S b){
  return max(a,b);
}
S e(){
  return 0;
}
S mapping(F  f,S x){
  return f*x;
}
F composition(F f,F g){
  return f*g;
}
F id(){
  return 1;
}
signed main(){
int n,k;
cin>>n>>k;
int a;
segtree<int,op,e> seg(300005);
for(int i=0;i<n;i++){
  cin>>a;
  int t=seg.prod(max(0ll,a-k),min(300005ll,a+k+1));
  seg.set(a,t+1);
}
cout<<seg.all_prod()<<endl;
}


Measured memory_bytes: 13852
table = 6.times.map {|i| [i * 10, (i + 1) * 10 - 1]} + [[60, 120]]

until (n = $<.gets.to_i).zero?
  count = Array.new(7, 0)
  n.times.map {$<.gets.to_i}.each do |age|
    idx = table.index {|a, b| age.between?(a, b)}
    count[idx] += 1
  end
  puts count
end


Measured memory_bytes: 14796
package main

import "fmt"

/*
1.A,B,C,Xを決める
2.A,B,Cの組み合わせを全通り考えて、その合計をXと比較する
*/

func main() {
	var A, B, C, X int

	//入力を受け付け
	fmt.Scan(&A)
	fmt.Scan(&B)
	fmt.Scan(&C)
	fmt.Scan(&X)

	//組み合わせの数
	conb := 0

	for i := 0; i <= A; i++ {
		for j := 0; j <= B; j++ {
			for l := 0; l <= C; l++ {
				sum := (500 * i) + (100 * j) + (50 * l)

				if sum == X {
					conb++
				}
			}
		}

	}

	fmt.Println(conb)
}


Measured memory_bytes: 1768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;


ll n,k,K;
int tile[2001][2001]={};
int ans=0;

void func(ll x,ll y){
  ll nx,ny;
  nx=(x+k-1)%K;ny=(y+k-1)%K;
  tile[x][y]+=1;
  if(x>nx && y>ny){
    tile[0][0]+=1;
  }
  if(x>nx){
    tile[0][y]+=1;
    tile[0][ny+1]-=1;
  }
  if(y>ny){
    tile[x][0]+=1;
    tile[nx+1][0]-=1;
  }
  tile[nx+1][y]-=1;
  tile[x][ny+1]-=1;
  tile[nx+1][ny+1]+=1;
}
int main(){
  cin>>n>>k;
  K=2*k;
  for(int i=0;i<n;i++){
    ll x,y,xn,yn;
    char c;
    cin>>x>>y>>c;
    if(c=='W')x+=k;
    x=(x+1)%K;y=(y+1)%K;
    xn=(x+k)%K;yn=(y+k)%K;
    func(x,y);
    func(xn,yn);
  }
  for(int i=0;i<K;i++){
    for(int j=1;j<K;j++){
      tile[i][j]+=tile[i][j-1];
    }
  }
  for(int j=0;j<K;j++){
    for(int i=1;i<K;i++){
      tile[i][j]+=tile[i-1][j];
    }
  }
  for(int i=0;i<K;i++){
    for(int j=0;j<K;j++){
      ans=max(ans,tile[i][j]);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
long long dp[51][51][2501];
int main(){
    long long n,a;
    cin >> n >> a;
    long long x[n];
    long long b=0;
    for(long long i=0;i<n;i++){
        cin >> x[i];
        b=max(b,x[i]);
    }
    dp[0][0][0]=1;
    long long ans=0;
    for(long long i=1;i<=n;i++){
        for(long long j=0;j<=n;j++){
            for(long long k=0;k<=n*b;k++){
                if(k<x[i-1]) dp[i][j][k]=dp[i-1][j][k];
                if(k>=x[i-1]&&j>=1) dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i-1]];
            }
        }
    }
    for(long long i=1;i<=n;i++){
        ans+=dp[n][i][i*a];
    }
    cout << ans << endl;
}

Measured memory_bytes: 50048
N=int(input())
a=[]
a=input().split(" ")
A=int(a[0])
B=int(a[1])
Y=input()
X=[]
X=Y.split(" ") #数値YをリストXに格納
Z=[int(i) for i in X] #リストXの要素を"文字"から"数値"に変換
Z.sort()#並び替え
p=[i for i in Z if i<=A]
q=[i for i in Z if A<i<=B]
r=[i for i in Z if B<i]
P=len(p)
Q=len(q)
R=len(r)
print(min(P,Q,R))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define N 110
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define READ(f) freopen (f, "r", stdin)
#define WRITE(f) freopen (f, "w", stdout)
#define pp pop_back
#define mapiter map<int, int>::iterator
#define pii pair<int, int>
#define forn(i, n) for(ll i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, n) for(int i = n - 1; i >= 0; --i)
#define forr1(i, n)	for(int i = n; i >= 1; --i)
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define elif else if
#define lld long double
#define r0 return 0
#define EPS 1e-7
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
const int inf = 1e9 + 1;
const ll modw = 1e9 + 7;
 
const ll mods[2] = {1000000009ll, 1000000007ll};
const ll p[2] = {31, 53};
 
using namespace std;
using namespace __gnu_pbds;

int main()
{
	barnarnar
	ll x, k, d;
	cin >> x >> k >> d;
	ll ans1 = x % d, ans2 = (-x) % d;
	if(ans1 < 0)	ans1 += d;
	if(ans2 < 0)	ans2 += d;
	ll need1 = (abs(ans1 - x) / d), need2 = (abs(ans2 - x) / d);
	//cout << ans1 << ' ' << need1 << ' ' << ans2 << ' ' << need2 << endl;
	if(k >= max(need1, need2))
	{
		if(ans1 == 0)
		{
			if(need1 % 2 == k % 2)	cout << 0;
			else	cout << d;
			r0;
		}
		if(k % 2 == need1 % 2)	cout << abs(ans1);
		else	cout << abs(ans2);
	}
	else
	{
		if(x < 0)	cout << abs(x + k * d);
		else	cout << abs(x - k * d);
	}
}	
// # pog-unlimitation

/*
Merami isn't so great?
Are you kidding me?
When was the last time you saw a player with such aim ability and movement with a tablet?
Merami puts the game in another level, and we will be blessed if we ever see a player with his skill and passion for the game again.
Whitecat breaks records.
Vaxei breaks records.
Merami breaks the rules.
You can keep your statistics.
I prefer the magic.
*/

Measured memory_bytes: 3656
n = int(input())
ls = []
for i in range(n):
    a = int(input())
    p = []
    for _ in range(a):
        x,y = map(int,input().split())
        p.append([x-1,y])
    ls.append(p)
ans = 0

for i in range(2**n):
    flag = 0
    for j in range(n):
        if (i>>j) & 1:
            for k in ls[j]:
                if (i >> k[0]) & 1!= k[1]:
                    flag = 1
                    break
    if flag == 0:
        ans = max(ans,bin(i)[2:].count('1'))
print(ans)


Measured memory_bytes: 3064
def A083356(n):
    t = 0
    for r in range(1, int(n**0.5)+1):
        t += r*(r+int(n/r))*(int(n/r)+1-r)//2
    return t

def A000330(n):
    return n * (n + 1) * (2 * n +1) // 6

def A143127(n):
    return 2 * A083356(n) - A000330(int(n**0.5))

n = int(input())
print(A143127(n))


Measured memory_bytes: 9420
#include <stdio.h>
#define MAX 36

typedef struct{
  char type;
  int number;
}Card;

int main()
{
  int n;
  scanf("%d", &n);

  int i, j, key_num, k;
  char c, key_type;
  Card card_b[n], card_s[n];
  for(i=0;i<n;i++)
    {
      scanf(" %c%d", &c, &k);
      card_b[i].type = card_s[i].type = c;
      card_b[i].number = card_s[i].number = k;
    }

  //Bubble Sort Algo
  for(i=0; i<=n-1; i++)
    {
      for(j=n-1; j>=i+1; j--)
	{
	  if(card_b[j].number < card_b[j-1].number)
	    {
	      key_num = card_b[j].number;
	      key_type = card_b[j].type;
	      card_b[j].number = card_b[j-1].number;
	      card_b[j].type = card_b[j-1].type;
	      card_b[j-1].number = key_num;
	      card_b[j-1].type = key_type;
            }
        }
    }

  for(i=0;i<n-1;i++)
    {
      printf("%c%d ", card_b[i].type, card_b[i].number);
    }
  printf("%c%d\n", card_b[n-1].type, card_b[n-1].number);
  printf("Stable\n");
    

  int minj;
  //Selection Sort Algo
  for(i=0; i<=n-2; i++)
    {
      minj = i;
      for(j=i; j<=n-1; j++)
	{
	  if(card_s[j].number < card_s[minj].number)
	    {
	      minj = j;
            }
        }

      if(minj != i)
	{
	  key_num = card_s[i].number;
	  key_type = card_s[i].type;
	  card_s[i].number = card_s[minj].number;
	  card_s[i].type = card_s[minj].type;
	  card_s[minj].number = key_num;
	  card_s[minj].type = key_type;
        }
    }

  int isStable = 1;
  for(i=0;i<n-1;i++)
    {
      printf("%c%d ", card_s[i].type, card_s[i].number);
      if(card_s[i].type != card_b[i].type && card_s[i].number == card_b[i].number)
	{
	  isStable = 0;
	}
    }
  printf("%c%d\n", card_s[n-1].type, card_s[n-1].number);
  printf(isStable ? "Stable\n" : "Not stable\n");

  return 0;

}



Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int A[1];
int size=1;
int m=2;
#define N 101
#define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)


int main()
{
    fast;
    int a,b;
    char ch;
    cin>>a>>ch>>b;
    if(ch=='+')
        cout<<a+b;
    else
        cout<<a-b;
}


Measured memory_bytes: 3568
#include <iostream>
#include "string.h"
#include "stdio.h"
using namespace std;
int n,m[107][107];
int color[107],d[107],f[107],tt;

void dfs_visit(int u)
{
	int v;
	color[u]=1;
	d[u]=++tt;
	for(v=0;v<n;v++)
	{
		if(m[u][v]==0)continue;
		if(color[v]==0)dfs_visit(v);
	}
	color[u]=2;
	f[u]=++tt;
}

void dfs()
{
	int u;
	for(u=0;u<n;u++)color[u]=0;
	tt=0;
	
	for(u=0;u<n;u++)
		if(color[u]==0)dfs_visit(u);
	for(u=0;u<n;u++)
		printf("%d %d %d\n",u+1,d[u],f[u]);
}
int main(int argc, char *argv[]) {
	int u,k,v,i,j;
	cin>>n;
	memset(m, 0, sizeof(m));
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&u,&k);
		u--;
		for(j=0;j<k;j++)
		{
			scanf("%d",&v);
			v--;
			m[u][v]=1;
		}
	}
	
	dfs();
	
	return 0;
}


Measured memory_bytes: 3268
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define mod 1000000007
#define pb push_back
#define VJ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mp make_pair()
#define vi(x) vector<int>x
#define vl vector<long long int>
#define vc vector<char>
#define max 100001 
using namespace std;
// 
void solve(){
	string num;cin>>num;
	int ans=0;
	for(int i=0;i<num.length();i++){
		ans+=(int)num[i]-48;
	}
	// cout<<ans;
	if(ans%9==0) cout<<"Yes";
	else cout<<"No";
 
}
 
int main(){
	 #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	 #endif
	VJ
	solve();
	return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  int count = 0;
  
  for( ;A <= B; A++) {
    int x, y;
    x = A / 10000;
    y = A % 10;
    if( x != y ) {
      continue;
    }
    
    int z, a, b, c;
    z = A % 10000;
    a = z / 1000;
    b = A / 10;
    c = b % 10;
    if( a != c) {
      continue;
    }
    
    else
      count++;
  }
  
  cout << count << endl;
    
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int a,b;
    cin >> a >> b ;
    if ( a < b ) {
        cout <<"a < b"<<endl;
    } else if ( a > b ){
        cout <<"a > b"<<endl;
    } else if ( a == b ) {
        cout <<"a == b"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3080
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int v [] = new int[n];
        int c [] = new int[n];
        Arrays.setAll(v, i -> stdIn.nextInt());
        Arrays.setAll(c, i -> stdIn.nextInt()); 
        int ans = 0;
        for(int i = 0; i < n; i++){
            if(v[i] - c[i] > 0) ans += v[i] - c[i];
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 26964
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

const int MOD = 1000000000 + 7;
const int MAXN = 200000 + 1000;
const int MAXM = 4000 + 100;
const int ZERO = MAXM / 2;

int fpow(int x, int p)
{
	int ret = 1;
	for(; p; p >>= 1, x = (long long)x * x % MOD)
		if(p & 1)
			ret = (long long)ret * x % MOD;
	return ret;
}

int get_inv(int x)
{
	return fpow(x, MOD - 2);
}

int fac[2 * MAXM], inv[2 * MAXM];
int get_c(int n, int m)
{
	return (long long)fac[n] * inv[m] % MOD * inv[n - m] % MOD;
}

void init()
{
	fac[0] = 1;
	for(int i = 1; i < 2 * MAXM; i++)
		fac[i] = (long long)fac[i - 1] * i % MOD;
	for(int i = 0; i < 2 * MAXM; i++)
		inv[i] = get_inv(fac[i]);
}

int n, m;
int a[MAXN], b[MAXN];
int f[MAXM][MAXM];

int& dp(int x, int y)
{
	return f[x + ZERO][y + ZERO];
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	init();

	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i] >> b[i];
	for(int i = 1; i <= n; i++)
		m = max(m, a[i]), m = max(m, b[i]);
	for(int i = 1; i <= n; i++)
		dp(-a[i], -b[i]) += 1;
	for(int i = -m; i <= m; i++)
		for(int j = -m; j <= m; j++)
			dp(i, j) = ((long long)dp(i, j) + dp(i, j - 1) + dp(i - 1, j)) % MOD;
	int ans = 0;
	for(int i = 1; i <= n; i++)
		ans = (ans + dp(a[i], b[i])) % MOD;
	// cerr << ans << endl;
	for(int i = 1; i <= n; i++)
		ans = (ans - get_c(2 * a[i] + 2 * b[i], 2 * a[i]) + MOD) % MOD;
	// cerr << ans << endl;
	ans = (long long)ans * get_inv(2) % MOD;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 66688
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;

const int MAXN = 262150;
const ll INF = 100000000ll;

ll DP[MAXN][55], n, in[20][2];
bool vis[MAXN][55];

ll dp(int st, int val, int index) {
	if (st == ((1 << n) - 1)) return 0;
	if (vis[st][val]) return DP[st][val];

	vis[st][val] = true;
	DP[st][val] = INF;

	vector<pii> G;
	int tmp = 0;

	for (int i = n-1; i >= 0; --i) {
		if (st & (1 << i)) tmp ^= 1;
		else G.push_back(make_pair(i, tmp));
	}

	reverse(G.begin(), G.end());

	int len = G.size(), id;
	for (int i = 0; i < len; ++i) {
		tmp = (i + G[i].second) & 1;
		id = G[i].first;
		if (in[id][tmp] >= in[val][index]) {
			DP[st][val] = min(dp(st + (1 << id), id, tmp) + i, DP[st][val]);
		}
	}
	return DP[st][val];
}

int main(){
	ios::sync_with_stdio(0),cin.tie(0);
	while (cin >> n) {
		for (int i = 0; i < 2; ++i) {
			for (int j = 0; j < n; ++j) {
				cin >> in[j][i];
			}
		}

		in[n][0] = in[n][1] = 0;
		memset(vis, 0, sizeof(vis));

		if (dp(0, n, 0) >= INF) cout << "-1\n";
		else cout << dp(0, n, 0) << '\n';

	}
	return 0;
}


Measured memory_bytes: 127104
#include <stdio.h>
#include <string.h>

int main(void)
{
    char S[4];
    char S_NUM[7][4]  = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    int i;
    
    
    scanf("%s", S);
    
    
    for(i=0; i<7; i++)
    {
        if(!strcmp(S_NUM[i], S))
            break;
    }
    
    printf("%d\n", 7-i);
    
    
    //system("pause");
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H , N ;
  cin >> H >> N ;
  
  vector<int> damage(N);
 
   for (int i = 0; i < N; i++) {
    cin >> damage.at(i);
  }
 
  int sum = 0;
 
  for (int i = 0; i < N; i++) {
 
    sum += damage.at(i);
  }
  
    if(sum - H >= 0) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 640
// Grading.c
// あなたの課題は、あるクラスの数学の成績を付けるプログラムを作成することです。
// プログラムは複数の学生のテストの点数を読み込みます。
// テストの点数は、中間試験の点数 m、期末試験の点数 f、再試験の点数 r で構成されています。
// 中間試験と期末試験は 50 点満点（m, f ≤ 50）、再試験は 100 点満点 （r ≤ 100）です。
// 試験を受けていない場合は点数を -1 とします。
// 以下の手順で成績が付けられます：
//
// ・中間試験、期末試験のいずれかを欠席した場合成績は F。
// ・中間試験と期末試験の合計点数が 80 以上ならば成績は A 。
// ・中間試験と期末試験の合計点数が 65 以上 80 未満ならば成績は B。
// ・中間試験と期末試験の合計点数が 50 以上 65 未満ならば成績は C。
// ・中間試験と期末試験の合計点数が 30 以上 50 未満ならば成績は D。 
//   ただし、再試験の点数が 50 以上ならば成績は C。
// ・中間試験と期末試験の合計点数が 30 未満ならば成績は F。
// 【入力】
// 複数のデータセットが入力として与えられます。各データセットでは、
// 空白で区切られた m、f、r が 1 行に与えられます。
// m、f、r がすべて -1 のとき入力の終わりとします。
// データセットの数（生徒の数）は 50 を超えません。
// 【出力】
// 各データセットについて、成績（A、B、C、D、または F）を１行に出力して下さい。
// 【例】
// 入力：
// 40 42 -1
// 20 30 -1
// 0 2 -1
// -1 -1 -1
// 出力：
// A
// C
// F
#include<stdio.h>

int main( void) {
  int m, f, r;
  int sum;
  char grade;

  while( 1) {
    scanf( "%d %d %d", &m, &f, &r);

    if ( m == -1 && f == -1 && r == -1) break;

    sum = m + f;

    if ( m == -1 || f == -1) grade = 'F';
    else if ( sum >= 80) grade = 'A';
    else if ( 65 <= sum && sum < 80) grade = 'B';
    else if ( 50 <= sum && sum < 65) grade = 'C';
    else if ( ( 30 <= sum && sum < 50) && r >= 50) grade = 'C';
    else if ( ( 30 <= sum && sum < 50) && r < 50) grade = 'D';
    else if ( sum < 30) grade = 'F';

    printf( "%c\n", grade);
  }

  return 0;
}



Measured memory_bytes: 2144