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

using namespace std;

int data[11][500];

void make(int sum, int checked, int rev){
  data[rev][sum]++;
  for(int i = 0; i < 10; i++){
    if(!(checked & (1<<i))){
      make(sum+(rev+1)*i,checked+(1<<i),rev+1);
    }
  }
}
int main(){

  make(0,0,0);
  fill(data[0],data[0]+500,0);
  int n,s;
  while(cin >> n >> s){
    if(s >= 500 || n > 10) cout << "0" << endl;
    else cout << data[n][s] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in range(n):
    if a[i] == 0:
        cnt -= 1000000000000
        break
    elif a[i] < 0:
        cnt += 1
a = [abs(a[i]) for i in range(n)]
if cnt < 0 or cnt % 2 == 0:
    print(sum(a))
else:
    print(sum(a) - 2*min(a))

Measured memory_bytes: 14332
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  string S;
  cin >> S;
  int answer = 0;
  int size = S.size();
  for(int i = 0; i < size - 1; i++){
    if(S.at(size - 1 - i) != S.at(size - 2 - i)){
      answer++;
    }
  }
  
  cout << answer << endl;    
  
}

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


#define	ll_int long long int


typedef struct{
	ll_int x;
	ll_int y;
}DATA_T;


DATA_T *WORK;


void Merge_sort(DATA_T *box, int l, int r, int kind)
{
	int mid;
	ll_int num1, num2;
	int i, j, k;


	if(r <= l)
		return;

	mid = (l + r) / 2;


	Merge_sort(box, l, mid, kind);

	Merge_sort(box, mid + 1, r, kind);


	for(i = l; i <= mid; i++)
		WORK[i] = box[i];

	for(i = mid + 1, j = r; i <= r; i++, j--)
		WORK[i] = box[j];


	j = l;
	k = r;
	for(i = l; i <= r; i++){
		if(kind){
			num1 = WORK[j].y;
			num2 = WORK[k].y;
		}else{
			num1 = WORK[j].x;
			num2 = WORK[k].x;
		}

		if(num1 <= num2 && j <= mid)
			box[i] = WORK[j++];
		else
			box[i] = WORK[k--];
	}
}


void Print_box(DATA_T *box, int n)
{
	int i;

	for(i = 0; i < n; i++)
		printf("%lld %lld\n", box[i].x, box[i].y);
}


int main()
{
	int n;
	DATA_T *c_box;	//Coordinate
	int i;

	scanf("%d", &n);

	c_box = (DATA_T *)malloc(sizeof(DATA_T) * n);
	WORK = (DATA_T *)malloc(sizeof(DATA_T) * n);

	for(i = 0; i < n; i++)
		scanf("%lld %lld", &c_box[i].x, &c_box[i].y);

	Merge_sort(c_box, 0, n - 1, 1);
	Merge_sort(c_box, 0, n - 1, 0);

	Print_box(c_box, n);

	return 0;
}


Measured memory_bytes: 4984
L , R = map(int,input().split())
if R - L >= 2019 or L == 0:
    print("0")
    exit()
min = 2020

for i in range(L , R):
    for j in range(i + 1 , R + 1):
        tmp_min = ( i * j) % 2019
        if tmp_min < min:
            min = tmp_min
print(min)

Measured memory_bytes: 3060
h,w = map(int,input().split())
s = [input() for _ in range(h)]
ans = 'Yes'
for i in range(h):
    for j in range(w):
        f = False
        if s[i][j]=='#':
            if i>0 and s[i-1][j]=='#': f=True
            if i<h-1 and s[i+1][j]=='#': f=True
            if j>0 and s[i][j-1]=='#': f=True
            if j<w-1 and s[i][j+1]=='#': f=True
            if not f:
                ans = 'No'
print(ans)

Measured memory_bytes: 39152
N = int(input())  # 1 <= N <= 4000
S = input()  # [RGB]{N}
L = {
    'R': tuple(i for i, v in enumerate(S) if v == 'R'),
    'G': tuple(i for i, v in enumerate(S) if v == 'G'),
    'B': tuple(i for i, v in enumerate(S) if v == 'B')
}
R_length = len(L['R'])
G_length = len(L['G'])
B_length = len(L['B'])

ans = R_length * G_length * B_length
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if k >= N:
            break
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            ans -= 1
print(ans)





Measured memory_bytes: 9096
#include <iostream>
using namespace std;
static const int MAX =100;
static const int INFTY =(1<<21);
static const int WHITE =0;
static const int GRAY =1;
static const int BLACK =2;

int n, M[MAX][MAX];

int prim(){
  int u,minv;
  int d[MAX],p[MAX],color[MAX];

  for(int i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }
  d[0]=0;

  while(1){
    minv=INFTY;
    u=-1;
    for(int i=0;i<n;i++){
      if(minv>d[i] && color[i] !=BLACK){
        u=i;
        minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(int v=0;v<n;v++){
      if(color[v] != BLACK && M[u][v]!=INFTY){
        if(d[v]>M[u][v]){
          d[v]=M[u][v];
          p[v]=u;
          color[v]=GRAY;
        }
      }
    }
  }
  int sum=0;
  for(int i=0;i<n;i++){
    if(p[i]!=-1)sum+=M[i][p[i]];
  }
  return sum;
}

int main(){
  cin >> n;

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
    int e; cin >> e;
    M[i][j]= (e==-1)? INFTY:e;
    }
  }

  cout << prim() << endl;
}


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

int main(){
  int N, M;
  cin >> N >> M ;
  // odd + odd
  int ans = 0;
  if(N>0){
	  ans += N*(N-1)/2;
  }
  if(M>0){
    ans += M*(M-1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    vi a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    // aとcをソート
    sort(all(a));
    sort(all(c));

    // bを基準に真に小さいaの個数と真に大きいcの個数をカウント
    ll ans = 0;
    rep(i, n){
        // biより真に小さいaの個数をカウント
        auto it_a = lower_bound(all(a), b[i]);
        ll acnt = it_a-a.begin();
        // biより真に大きいcの個数をカウント
        auto it_c = upper_bound(all(c), b[i]);
        ll ccnt = n-(it_c-c.begin());
        ans += acnt*ccnt;
    }
    cout << ans << endl;
}

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

// マクロ
// forループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x)begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
// 出力
#define PRINT(x) cout<<(x)<<endl
#define PRINTA(x,n) REP(i,n)PRINT(x[i])
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
// 略記
#define PB push_back
#define MP make_pair

const int MAX_SQRT_N = 1000100;

ll prime[MAX_SQRT_N];
bool is_prime[MAX_SQRT_N];

ll sieve(ll n) {
    ll p = 0;
    FOR(i, 0, n) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    FOR(i, 2, n) {
        if (is_prime[i]) {
            prime[p++] = i;
            for (int j = 2 * i; j <= n; j += i) is_prime[j] = false;
        }
    }
    return p;
}

bool judge_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main() {
    ll N; cin >> N;
    REP(i, MAX_SQRT_N) prime[i] = 0;
    sieve(MAX_SQRT_N);
    ll ans = 0;
    REP(i, MAX_SQRT_N) {
        ll p = prime[i];
        if (prime[i] == 0) break;
        while (N % p == 0) {
            N /= p;
            p *= prime[i];
            ans++;
        }
        while (N % prime[i] == 0) {
            N /= prime[i];
        }
    }
    if (judge_prime(N)) ans++;
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 12356
#include <iostream>
#include <vector>
#include <math.h>
#include <iomanip>
#include <map>
 
using namespace std;
typedef vector<vector<int>> matrix;
typedef vector<int> vec;
 
matrix matprod( matrix &A, matrix &B, int mod = 1);
matrix matpow( matrix src, int p, int M );
int solve();
 
int main(void) {
 
	//FILE *fpin = freopen("data.txt","r",stdin);
 
	while(solve()){}
 
	return 0;
}
 
void printmat( matrix &m ) {
	for( int i = 0; i < m.size(); i++ ) {
		for( int j = 0; j < m[i].size(); j++ ) {
			cout << m[i][j] << " ";
		}
		cout << endl;
	}
}
matrix matprod( matrix &A, matrix &B, int mod ) {
 
	matrix ret( B.size(), vec( A[0].size(), 0 ) );
	for( int i = 0; i < ret.size(); i++ ) {
		for( int j = 0; j < ret[i].size(); j++ ) {
			//ret???(i,j)??????
			for( int k = 0; k < A[i].size(); k++ ) {
				ret[i][j] += A[i][k]*B[k][j];
				ret[i][j] %= mod;
			}
		}
	}
 
	return ret;
 
}
matrix matpow( matrix src, int p, int M) {
 
	//???????´????
	if( p == 0 ) {
		matrix ret(src);
		for( int i = 0; i < ret.size(); i++ ) {
			for( int j = 0; j < ret[i].size(); j++ ) {
				if( i == j ) {
					ret[i][j] = 1;
				} else {
					ret[i][j] = 0;
				}
			}
		}
		return ret;
	}
	if( p == 1 ) { return src; }
 
	if( p & 1 ) {
 
		matrix n;
		matrix m(matpow(src,(p-1)/2,M));
 
		n = matprod(m,m,M);
		return matprod(src,n,M);
 
	} else {
 
		matrix m(matpow(src,p/2,M));
		return matprod(m,m,M);
 
	}
 
}
 
int solve() {
 
	int N,M,A,B,C,T;
 
 
	cin >> N >> M >> A >> B >> C >> T;
 
 
	if( N == 0 ){ return 0; }
 
	matrix mat( N, vec(N, 0) );
	matrix ans( N, vec(N, 0) );
	matrix mat2(N, vec(N, 0) );
 
	vector<int> S(N,0);
 
	int t[3] = { A, B, C };
 
	for( int i = 0; i < N; i++ )
		{ cin >> S[i]; }
 
	for( int i = 0; i < N; i++ ) {
		for( int k = -1; k < 2; k++ ) {
			if( i + k < 0 || i + k >= N ) { continue; }
			mat[i][i+k] = t[k+1];
		}
	}
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < N; j++ ) {
			mat2[i][j] = S[(i+j)%N];
		}
	}
 
	mat = matpow( mat, T, M );
	ans = matprod( mat, mat2, M );
 
	for( int i = 0; i < N; i++ ) {
		if( i > 0 ) { cout << " "; }
		cout << ans[i][0];
	}
 
	cout << endl;
 
 
 
	return 1;
 
}

Measured memory_bytes: 3356
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;

int bs_cnt_less(vl& A, const ll X, bool equal) {
    if (equal) return upper_bound(A.begin(), A.end(), X) - A.begin();
    else return lower_bound(A.begin(), A.end(), X) - A.begin();
}

int bs_cnt_greater(vl& A, const ll X, bool equal) {
    if (equal) return A.end() - lower_bound(A.begin(), A.end(), X);
    else return A.end() - upper_bound(A.begin(), A.end(), X);    
}

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


  ll N,M; cin>>N>>M;
  vl A(N); REP(i,N) cin>>A[i];

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

  ll l = 2;       // AMIN*2
  ll r = 1e5*2+1; // AMAX*2+1

  while(l < r-1) { // [l,r)
    ll m = (l+r)/2; // 1 回の(両手)握手で幸福度の増分を m にできるか
    
    ll num = 0; // 幸福度の増分を m 以上にできる通り数
    REP(i,N) { // 左手を i とつなぐ
      // 右手を m-A[i] 以上でつなげる通り数を加える
      num += bs_cnt_greater(A, m-A[i], true);
    }

    if (num>=M) {
      l = m;
    } else {
      r = m;
    }
  }

  vl sum(N+1,0); // sum[i] : [0,i) での A[i] の累積和
  REP(i,N) sum[i+1] = sum[i] + A[i];

  ll ans = 0, num = 0;
  REP(i,N) { // 左手を i とつなぐ
    //int lle = bs_cnt_less(A, l-A[i], true);
    // 右手を l-A[i] より大にできる通り数
    int lgt = bs_cnt_greater(A, l-A[i], false);
    //assert(l+1 == r);
    //assert(lle + lgt == N);
    int lle = N - lgt;

    num += lgt;
    ans += A[i]*lgt + (sum[N] - sum[lle]);
  }
  if (num<M) { // 握手回数が余っていたら
    // l で M 回以上の握手ができることは調べてあるので
    ans += l*(M-num);
  }
 
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int n;

        Scanner scan = new Scanner(System.in);

        n = scan.nextInt();

        long sum = 0;
        for(int i = 1; i <= n; i++) {
            if(i % 15 != 0 && i % 3 != 0 && i % 5 != 0) {
                sum += i;
            }
        }

        System.out.println(sum);
    }
}

Measured memory_bytes: 27188
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <stdlib.h>
#include <time.h>
#include <map>
#include <limits.h>
#include <queue>
using namespace std;
long long n, ans= LONG_LONG_MAX;
int main() {
	cin >> n;
	for(long long x= 1; x * x <= n; x++)
		if(n % x == 0) ans= min(ans, x + n / x - 2);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

int main() {
  int N, M;
  cin >> N >> M;
  vector<ll> height(N);
  vector<vector<int>> path(N);

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

  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    path[a - 1].push_back(b - 1);
    path[b - 1].push_back(a - 1);
  }

  int res = 0;

  for (int i = 0; i < N; i++) {
    int pathCount = path[i].size();
    if (pathCount == 0) {
      res++;
      continue;
    }

    bool heighest = true;
    for (int j = 0; j < pathCount; j++) {
      if (height[path[i][j]] >= height[i]) {
        heighest = false;
        break;
      }
    }
    if (heighest) {
      res++;
    }
  }

  cout << res << endl;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)


using namespace std;

bool to[NUM];
bool ot[NUM];
vector<vector<lli>> v;
vector<vector<lli>> rev;

void bfs(lli now){
	if(to[now])return;
	to[now]=true;
	for(lli e:v[now]){
		bfs(e);
	}
}

void bfs2(lli now){
	if(ot[now])return;
	ot[now]=true;
	for(lli e:rev[now]){
		bfs2(e);
	}
}
int main(){

	v.resize(NUM);
	rev.resize(NUM);
	REP(i,0,NUM){
		to[i]=false;
		ot[i]=false;
	}
	vector<tuple<lli,lli,lli>> cost;
	lli n,m,p;
	lli distance[NUM];
	REP(i,0,NUM)distance[i]=INF;
	distance[0] = 0;
	cin>>n>>m>>p;

	REP(i,0,m){
		lli a,b,c;
		cin>>a>>b>>c;
		a--,b--;
		v[a].push_back(b);
		rev[b].push_back(a);
		cost.emplace_back(a,b,p-c);
	}

	bfs(0);
	bfs2(n-1);

	bool isEnter=true;
	lli cnt = 0;
	while(isEnter){
		if(cnt > n){
			cout<<-1<<endl;
			return 0;
		}
		isEnter=false;
		REP(i,0,m){
			lli a,b,c;
			tie(a,b,c) = cost[i];
			if((to[a]&&ot[a])== false)continue;
			if(DEBUG)cout<<"a="<<a<<" b="<<b<<" c="<<c<<endl;
			if(distance[b] > distance[a] + c){
				distance[b] = distance[a] + c;
				isEnter=true;
			}
		}
		cnt++;
	}
	lli ans = -distance[n-1];
	cout<<max(0LL,ans)<<endl;

	return 0;

}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1, 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    REP(i, N) cin >> w[i] >> v[i];

    ll mxv = accumulate(ALL(v), 0);
    vector<vector<ll>> dp(N + 1, vector<ll>(mxv + 1, INF64));
    dp[0][0] = 0;
    REP(i, N) {
        REP(j, mxv + 1) {
            chmin(dp[i + 1][j], dp[i][j]);
            if (j - v[i] < 0)
                continue;
            chmin(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
        }
    }
    ll ans;
    REP(i, mxv + 1) {
        if (dp[N][i] <= W)
            ans = i;
    }
    print(ans);

    return 0;
}

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

int main(){
    int n, k;
    int i=0;
    cin >> n >> k;
    if (n <= k){
        cout << 1;
    }else{
        do{
            n = n / k;
            i++;
        }while (k <= n);
        cout << i + 1;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6,mod=1e9+7;

int big(int b,int p,int m=mod)
{
  int ret=1;
  while(p)
  {
    if(p&1)ret=(1LL*ret*b)%m;
    b=(1LL*b*b)%m;p/=2;
  }
  return ret;
}

vector<int>fac[N+2];int vis[N+2];
void seive()
{
  for(int i=2;i<=N;i++)
  {
    if(vis[i])continue;
    for(int j=i;j<=N;j+=i)
    {
      vis[j]=1;fac[j].push_back(i);
    }
  }
}
int mx[N+2],aa[N+2];
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  seive();

  int n;cin>>n;
  for(int i=1;i<=n;i++)
  {
    int z;cin>>z;int xx=z;aa[i]=z;
    for(auto x:fac[z])
    {
      int cnt=0;
      while(xx%x==0)xx/=x,cnt++;
      mx[x]=max(mx[x],cnt);
    }
  }
  long lcm=1;
  for(int i=1;i<=N;i++)
    lcm=(lcm*big(i,mx[i]))%mod;
  long ans=0;
  for(int i=1;i<=n;i++)
    ans=(ans+lcm*big(aa[i],mod-2))%mod;
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 65408
import java.util.*;
import java.io.*;

public class Main{

     public static void main(String []args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int max=0;
        int temp=0;
        String s = scanner.next();
        
        
        for(int i=0;i<s.length();i++)
        {
            if(s.charAt(i)=='I')
            temp++;
            else
            temp--;
            
            max = Math.max(temp,max);
            
            
        }
        
        System.out.println(max);
        
     }
}

Measured memory_bytes: 35604
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;
 
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1)
 
const double EPS = 1e-10;
 
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int n,k; cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    repr(i,k,n){
        if(a[i] > a[i-k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

}


Measured memory_bytes: 4840
use std::io::*;
const MOD: u64 = 1_000_000_007;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let s: Vec<char> = itr.next().unwrap().chars().collect();
    let n = s.len();

    let mut dp = vec![vec![0; 2]; n + 1];
    dp[0][0] = 1;
    for i in 0..n {
        if s[i] == '0' {
            dp[i + 1][0] += dp[i][0];
            dp[i + 1][1] += dp[i][1] * 3;
        } else {
            dp[i + 1][1] += dp[i][1] * 3;
            dp[i + 1][1] += dp[i][0];
            dp[i + 1][0] += dp[i][0] * 2;
        }
        dp[i + 1][0] %= MOD;
        dp[i + 1][1] %= MOD;
    }
    println!("{}", (dp[n][0] + dp[n][1]) % MOD);
}


Measured memory_bytes: 10492
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int
#define pp pair<pii,pii>
const int hell =1000000007;



int power(int a,int b)
{
  if(b==0)return 1;
  if(b==1)return a;
  int t=power(a,b/2);
  t%=hell;
  t*=t;
  t%=hell;
  if(b%2)return (t*a)%hell;
  else
     return t;
}
int p[100000]={0};
bool b[100000]={false};

void pri()
{
  

  rep(i,2,100000)
  for(int j=i+i;j<100000;j+=i)b[j]=true;

    rep(i,2,100000)if(b[i]==false)p[i]=1;
}



int solve( ){

int n;
  cin>>n;
int mx=0;
int ans=0;
rep(i,0,n)
{
	int a;
	cin>>a;
	if(a>=mx)ans++;
	mx=max(mx,a);
}

cout<<ans;

return 0;
}



signed main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin.exceptions(cin.failbit);
 
 // pri();
  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;
    int k=1;
   while(t--)
     {
       //cout<<"case #"<<k<<":"<<" ";k++;
      solve();
     }

         time_req = clock() - time_req;
   //cout << "Processor time taken is "
     // << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

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


int main(){
	
	int m[300];
	m['I']=1;
	m['V']=5;
	m['X']=10;
	m['L']=50;
	m['C']=100;
	m['D']=500;
	m['M']=1000;
	string s;
	while(cin>>s){
		s+='#';
	int sum = 0;
		reps(i,1,s.size()){
			if(s[i]!='#' && m[s[i]]>m[s[i-1]]){
				sum -= m[s[i-1]];
			}else{
				sum += m[s[i-1]];
			}
		}
		printf("%d\n",sum);
	}
}

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

int main(){
	int N,K;
	cin >> N >> K;
	vector<int> a(N);
	for(int i=0;i<N;i++)cin>>a[i];

	vector<bool> dp(K+1,false); // dp[i] := はじめ石がi個の時、先攻の人が勝てるかどうか

	for(int i=0;i<=K;i++){ // iが小さい方から決まっていく
		for(int j=0;j<N;j++){
			if(i-a[j] >= 0)if(dp[i-a[j]] == false){ //あるiのとき、石をa[j]個取って相手が勝てない状態にできるなら勝てる
				dp[i] = true;
			}
		}
	}
	if(dp[K]){
		cout << "First" << endl;
	}else{
		cout << "Second" << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define LL long long
using namespace std;
int n,tot;
const int N=1005;
LL a[N][N],zhi[N<<1],vis[10010];
LL GCD(LL a,LL b){return b?GCD(b,a%b):a;}
LL LCM(LL a,LL b){if(!a||!b)return a+b;else return a/GCD(a,b)*b;}
void YYCH()
{
	vis[1]=1;
	for(int i=2;i<=10000;++i)
	{
		if(!vis[i])zhi[++tot]=i;
		for(int j=1;j<=tot&&i*zhi[j]<=10000;++j)
		{
			vis[i*zhi[j]]=1;
			if(!(i%zhi[j]))break;
		}
	}
}
int main()
{
	cin>>n;if(n==2)return printf("4 7\n23 10\n")==233;
	YYCH();
    for(int i=1;i<=n;++i)
    	for(int j=((i+1)&1)+1;j<=n;j+=2)
    		a[i][j]=zhi[(i+j)/2]*zhi[n+(i-j)/2+(n+1)/2];
    for(int i=1;i<=n;++i)
    	for(int j=(i&1)+1;j<=n;j+=2)
			a[i][j]=LCM(LCM(a[i-1][j],a[i][j-1]),LCM(a[i+1][j],a[i][j+1]))+1;
    for(int i=1;i<=n;++i,puts(""))
    	for(int j=1;j<=n;++j)printf("%lld ",a[i][j]);
    return 0;
}

Measured memory_bytes: 7168
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>

using namespace std;
int c[4][4];

int main(){
   for(int i=1;i<4;i++){
      for(int j=1;j<4;j++){
         cin>>c[i][j];
      }
   }
   for(int a1=0;a1<c[1][1]+1;a1++){
      if(c[2][1]+c[1][2]-c[1][1]==c[2][2] && c[2][1]+c[1][3]-c[1][1]==c[2][3] && c[3][1]+c[1][2]-c[1][1]==c[3][2] && c[3][1]+c[1][3]-c[1][1]==c[3][3]){
         cout<<"Yes"<<endl;
         return 0;
      }
   }
   cout<<"No"<<endl;

   
   
}

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

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

  vector<int> nums;

  int now = 1;
  int cnt=0;
  for(int i = 0; i < n; i++)
  {
      if(s[i]-'0'==now){
          cnt++;
      }
      else {
          nums.push_back(cnt);
          now=1-now;
          cnt=1;
      }
  }
  nums.push_back(cnt);
  if(nums.size()%2==0) nums.push_back(0);

  int tmp=0;
  int ans = 0;
  for(int i = 0; i < (int)nums.size(); i+=2)
  {
      int end = min(i+2*k+1,(int)nums.size());
      for(int j = i; j < end; j++)
      {
          tmp+=nums[j];
      }
      ans=max(ans,tmp);
      tmp=0;
  } 

  cout << ans << endl;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     // return p.first>q.first;//descending by first
//     // return p.first<q.first;//ascending by first
//     // return p.second>q.second;//descending by second
//     return p.second<q.second;//ascending by second
// }

bool cmp(int p,int q) {
    return p>q;//descending
    // return p<q;//ascending
}


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {
    int n;
    string s;
    cin>>n>>s;

    int cnt=0;
    f1(i,n-2) {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') {
            ++cnt;
        }
    }
    cout<<cnt<<endl;


    // ()?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define INF 1e9
typedef long long llong;
using namespace std;
 
int main(){
	int n;
	cin>>n;
	
	vector<int> a(n);
	int cnt=0;
	bool jud=false;
	bool jud0=false;
	REP(i,n){
		scanf("%d",&a[i]);
		if(a[i]<0){
			++cnt;
			continue;
		}
		if(a[i]==0) jud0=true;
	}
	if(cnt%2==0) jud=true;
	
	llong sum=0;
	if(jud||jud0){
		REP(i,n){
			if(a[i]<0) a[i]*=-1;
			sum+=a[i];
		}
		cout<<sum<<endl;
		return 0;
	}else{
		int tmp=INF;
		REP(i,n){
			if(a[i]<0) a[i]*=-1;
			tmp=min(tmp,a[i]);
			sum+=a[i];
		}
		cout<<sum-2*tmp<<endl;
		return 0;
	}
}

Measured memory_bytes: 640
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n;
    cin >> n;
    
    vector<int> v(n);
    for (auto &x : v) cin >> x;
    sort(ALL(v));
    
    int maxV = 0;
    for (int i = 0; i < n-1; ++i) {
        if (min(v[i], v[n-1] - v[i]) > min(maxV, v[n-1] - maxV)) maxV = v[i];
    }
    
    cout << v[n-1] << " " << maxV << "\n";
    
    return 0;
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }

int main()
{
	int n, a;
	int64_t b = 0, c = 0;
	vector<bool> flag(pow(10, 9), false);

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		if (!flag[a - 1])
			flag[a - 1] = true;
		else
		{
			if (c < a)
			{
				b = c;
				c = a;
				flag[a - 1] = false;
			}
			else if (b < a)
				b = a;
		}
	}
	cout << b * c << endl;
}


Measured memory_bytes: 125016
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

int main()
{
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    cout
        << (char)(s1[0] - 32)
        << (char)(s2[0] - 32)
        << (char)(s3[0] - 32)
        << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
char p[1002][1002], cop[1002][1002];
long long  a, b, c, d, ma, i, j;
int  main() {
	cin >> a >> b >> c >> d;
	cout << max(max(a * d, a * c), max(b * c, b * d)) << endl;
	return 0;
}

Measured memory_bytes: 3544
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

const MODULO: usize = 1_000_000_007;

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let l: usize = scan(tokens);
    let r: usize = scan(tokens);
    println!("{}", f(l, r, 1, 1, 1, 1, 0));
}

fn f(l: usize, r: usize, bb: usize, bu: usize, ub: usize, uu: usize, res: usize) -> usize {
    if r == 0 {
        return res;
    }
    f(
        l >> 1,
        r >> 1,
        if l & 1 == 0 {
            if r & 1 == 0 {
                bb
            } else {
                (bu + bb + ub) % MODULO
            }
        } else {
            if r & 1 == 0 {
                0
            } else {
                bb
            }
        },
        if l & 1 == 0 {
            (bu + bu + uu) % MODULO
        } else {
            bu
        },
        if r & 1 == 0 {
            ub
        } else {
            (uu + ub + ub) % MODULO
        },
        (uu + uu + uu) % MODULO,
        if l == 0 {
            if r == 1 {
                (res + ub) % MODULO
            } else {
                (res + uu) % MODULO
            }
        } else if l == 1 {
            if r == 1 {
                (res + bb) % MODULO
            } else {
                (res + bu) % MODULO
            }
        } else {
            res
        },
    )
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll h,w,n;cin>>h>>w>>n;
    if(h>w)swap(h,w);
    cout<<(n-1)/w+1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;

ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}

int main(){
    string s, t;
    cin >> s >> t;
    int N = t.size();
    string x = "";
    while(x.size() < N) x += s;
    int M = x.size();
    x = t+x+x;
    int A[x.size()];
    A[0] = x.size();
    int i = 1;
    int j = 0;
    while(i < x.size()){
        while(i+j < x.size() && x[j] == x[i+j]) j++;
        A[i] = j;
        if(j == 0){i++; continue;}
        int k = 1;
        while(i+k < x.size() && k+A[k] < j){A[i+k] = A[k]; k++;}
        i += k, j -= k;
    }
    bool able[M];
    fill_n(able, M, false);
    rep(i, M) if(A[N+i]>=N) able[i] = true;
    int g = gcd(N, M);
    int res[g];
    fill_n(res, g, 0);
    rep(i, g){
        int pos = i, times = 0, cnt = 0;
        while(true){
            if(pos == i) times++;
            if(times == 3) break;
            if(able[pos]){
                cnt++;
                if(cnt == 2*M/g){cout << -1 << endl; exit(0);};
            }
            else{
                res[i] = max(res[i], cnt);
                cnt = 0;
            }
            pos = (pos+N)%M;
        }
    }
    int ans = 0;
    rep(i, g) ans = max(ans, res[i]);
    cout << ans << endl;
}

Measured memory_bytes: 14732
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>

#define PI 3.1415926535897932384626433832795
#define pii pair <int, int>
#define pb push_back
#define ll long long
#define ss second
#define ff first
#define N 100010

using namespace std;

int a;
string s;

int main()
{
	cin >> s;
	
	for(int i = 0; i < s.length(); i++)
		if(s[i] == 'o') a++;
	
	cout << 700 + a*100;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var n = long.Parse(ReadLine().Replace("/",""));
            WriteLine(n > 20190430 ? "TBD" : "Heisei");
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    string S;
    cin >> S;
    bool f=true;
    for(int i=0;i<S.length();i++){
        if(i%2==0 && S[i]=='L'){
            f = false;
        }
        if(i%2==1 && S[i]=='R'){
            f = false;
        }
    }
    if(f){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;

int main() {
  int n;
    cin >> n;
    int sum = 0;
    int tmp = n;
    
    while(n > 0) {
      sum += n % 10;
      n /= 10;
    }

    if(tmp % sum == 0) cout << "Yes" << endl;
    else cout << "No" <<endl;
    
}
  









  


Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll a,b,c;
int main()
{
    scanf("%lld%lld%lld",&a,&b,&c);
    ll now=min(a,c),ans=0;
    a-=now;c-=now;ans+=now;
    now=min(b,c);
    b-=now;c-=now;ans+=2*now;
    if(c>0) ans++; else ans+=b;
    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << ' '; clog << LF;}

struct Rect { int height, left; Rect(int h=0, int l=0): height(h), left(l) {} };
int H, W;
int mat[1500][1500];
int dp[1500][1500];

int slv(const int *bar)
{
  stack<Rect> s;
  s.emplace(-1, -1);

  int largest = 0;
  for(int i = 0; i <= W; ++i) {
    const int h = bar[i];

    if(s.top().height < h) {
      s.emplace(h, i);
    }
    else if (s.top().height > h) {
      Rect r;
      while(s.top().height >= h) {
        r = s.top(); s.pop();
        chmax(largest, (i - r.left) * r.height);
      }
      s.emplace(h, r.left);
    }
  }

  return largest;
}

signed main()
{
  cin >> H >> W;
  for (int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      cin >> mat[i][j];
      mat[i][j] = 1 - mat[i][j];
    }
  }

  int ans = 0;
  for (int i = H-1; i >= 0; --i) {
    for (int j = 0; j < W; ++j) {
      if (mat[i][j]) mat[i][j] += mat[i+1][j];
    }
    chmax(ans, slv(mat[i]));
  }

  cout << ans << endl;

  return 0;
}





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



int main()
{
	int n, ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
	return 0;
}



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

const double pi=acos(-1);
typedef long long ll;
const int maxn=1e4+10;
int  f[300050],vis[200050];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s,t,u;
    cin >> s;
    int len=s.length();
    while(len--)
        cout << "x";
    
    return 0;
}


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

#define rep(i,n)  for(int i = 0; i < (n); i++)
using vi = vector<int>;
using ll = long long;
const int inf = 1<<30;

int main(){
  int e;
  while(cin >> e, e){
    int m = inf;
    rep(z,101) rep(y,1001){
      int x = e - z*z*z - y*y;
      if(0 <= x){
	m = min(m, x+y+z);
      }
    }
    cout << m << endl;
  }
}



Measured memory_bytes: 2984
#include<bits/stdc++.h>
using namespace std;
int main() {
  using LL = long long;
  int N;
  cin >> N;
  vector<LL> S(N);
  for(auto& s: S) cin >> s;
  LL res = 0;
  for(auto d=1; d<N; ++d) {
    unordered_set<int> used;
    LL sum = 0;
    for(auto i=0; i<N; i+=d) {
      auto j = N-1 - i;
      used.emplace(i);
      if(used.count(j)) break;
      if(j < d) break;
      sum += S[i] + S[j];
      res = max(res, sum);
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  vector<string> s(N);
  for (int i = 0; i < N; ++i)
    cin >> s[i];

  map<char, int> m;

  for (int i = 0; i < s[0].size(); ++i) {
    if (m.find(s[0][i]) == m.end())
      m[s[0][i]] = 0;
    ++m[s[0][i]];
  }

  for (int i = 1; i < N; ++i) {
    map<char, int> tmp;
    for (int j = 0; j < s[i].size(); ++j) {
      if (tmp.find(s[i][j]) == tmp.end())
        tmp[s[i][j]] = 0;
      ++tmp[s[i][j]];
    }
    for (map<char, int>::iterator j = m.begin(); j != m.end(); ++j) {
      if (tmp.find(j->first) == tmp.end())
        m[j->first] = 0;
      else
        m[j->first] = min(j->second, tmp[j->first]);
    }
  }

  string ret = "";
  for (map<char, int>::iterator i = m.begin(); i != m.end(); ++i) {
    if (i->second == 0)
      continue;
    for (int j = 0; j < i->second; ++j)
      ret += i->first;
  }

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

  cout << ret << endl;

  return 0;
}

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

using namespace std;

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

    char a;
    cin>>a;

    cout<<(isupper(a)? "A": "a")<<"\n";


    return 0;
}


Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
import math

a, b, x = list(map(int, input().split()))


l = 0
r = math.pi/2
v = 0
while abs(v-x) > 0.0000001:
    mid = (r+l)/2
    if b*math.tan(math.pi/2 - mid) < a:
        v = b * b*math.tan(math.pi/2 - mid)/2*a
    else:
        v = (b*a - a*a/(math.tan(math.pi/2 - mid))/2)*a

    if x < v:
        l = mid
    else:
        r = mid

    #print(v,mid*180/math.pi)
print(mid*180/math.pi)


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

typedef struct shutugen{
	char words[33];
	int kaisu;
}shutugen;

int main(void){
	int i,j,k,topkaisu,endflag=0;
	char words[10001];
	shutugen tango[10000];
	
	for(i=0;i < 10000;i++){
		tango[i].words[0] = '\0';
		tango[i].kaisu = 0;
	}
	
	scanf("%[^\n]",words);
	getchar();
	
	i=0,j=0,k=0;
	for(i=0;words[i] != '\0';i++){
		if(isalpha(words[i])){
			tango[j].words[k]=words[i];
			k++;
		}else if(words[i] = ' '){
			// printf("%s\n",tango[j].words);
			k = 0;
			j++;
		}
	}
	// printf("%s\n",tango[j].words);
	
	//最も出現頻度が高い単語を探す
	topkaisu = 0;
	for(i=0;strcmp(tango[i].words,"") != 0;i++){
		for(j=i+1;strcmp(tango[j].words,"") != 0;j++){
			if(strcmp(tango[i].words,tango[j].words) == 0){
				tango[i].kaisu+=1;
				if(topkaisu < tango[i].kaisu) topkaisu = tango[i].kaisu;
			}
		}
	}
	//表示
	for(i=0;tango[i].words[0] != '\0';i++){
		if(topkaisu == tango[i].kaisu){
			printf("%s",tango[i].words);
			break;
		}
	}
	
	printf(" ");
	// 文字数が多い単語を探す
	for(i=32;i > 0;i--){
		for(j=0;tango[j].words[0] != '\0';j++){
			if(isalpha(tango[j].words[i])){
				printf("%s\n",tango[j].words);
				endflag = 1;
				break;
			}
		}
		if(endflag == 1) break;
	}
	
	return 0;
}

Measured memory_bytes: 968
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        String[] s = new String[h];
        for(int i = 0; i < h; i++){
            s[i] = sc.next();
        }
        
        int[] sx = new int[h*w];
        int count;
        int index;
        for(int y = 0; y < h; y++){
            count = 1;
            for(int x = 0; x < w; x++){
                index = w*y +x;
                if(s[y].charAt(x) == '.'){
                    sx[index] = count;
                    count++;
                }else{
                    count = 1;
                }
            }
        }
        for(int y = 0; y < h; y++){
            for(int x = w-1; x >=0; x--){
                index = w*y +x;
                if(sx[index] != 0){
                    for(int i = 1; i < sx[index]; i++){
                        sx[index -i] = sx[index];
                    }
                    x -= sx[index];
                }
            }
        }
        
        int[] sy = new int[h*w];
        for(int x = 0; x < w; x++){
            count = 1;
            for(int y = 0; y < h; y++){
                index = w*y +x;
                if(sx[index] != 0){
                    sy[index] = count;
                    count++;
                }else{
                    count = 1;
                }
            }
        }
        for(int x = 0; x < w; x++){
            for(int y = h-1; y >= 0; y--){
                index = w*y +x;
                if(sy[index] != 0){
                    for(int i = 1; i < sy[index]; i++){
                        sy[index -w*i] = sy[index];
                    }
                    y -= sy[index];
                }
            }
        }
        
        int max = 0;
        int light;
        for(int i = 0; i < h*w; i++){
            light = sx[i] + sy[i];
            if(light > max){
                max = light;
            }
        }
        
        System.out.println(max -1);
    }
}

Measured memory_bytes: 78276
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a == b + c){
			System.out.println("Yes");
        }else if(b == a + c){
			System.out.println("Yes");
   		}else if(c == a + b){
			System.out.println("Yes");
        }else{
			System.out.println("No");
    }
	}

}


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

int main() {
  int a, b, c, k; cin >> a >> b >> c >> k;
  string ans = "No";
  while (k > 0) {
    if (a >= b) b*=2;
    else break;
    k--;
  }
  while (k > 0) {
    if (b >= c) c*=2;
    else break;
    k--;
  }
  if (a < b && b < c) ans = "Yes";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
typedef long long LL;
const int mo = 1e9+7;
const int MAXN = 401;
const int MAXA = 401;
int F[MAXN][MAXN];
int Pow[MAXA][MAXN], Sum[MAXN][MAXA];
void init()
{
	int i, j;
	for(i=1; i<MAXA; ++i)
	{
		Pow[i][0] = 1;
		for(j=1; j<MAXN; ++j)
			Pow[i][j] = LL(Pow[i][j-1]) * i % mo;
	}
	for(i=0; i<MAXN; ++i)
		for(j=1; j<MAXA; ++j)
			Sum[i][j] = (Sum[i][j-1] + Pow[j][i]) % mo;
}
int main()
{
	init();
	int N, C, i, j, k, A[MAXN], B[MAXN];
	scanf("%d%d", &N, &C);
	for(i=1; i<=N; ++i)
		scanf("%d", A+i);
	for(i=1; i<=N; ++i)
		scanf("%d", B+i);
	F[0][0] = 1;
	for(i=1; i<=N; ++i)
		for(j=0; j<=C; ++j)
			for(k=j; k<=C; ++k)
				F[i][k] = (F[i][k] + F[i-1][k-j]*LL(Sum[j][B[i]]-Sum[j][A[i]-1])) % mo;
	printf("%d\n", (F[N][C]+mo)%mo);
}


Measured memory_bytes: 2048