akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PL;
typedef pair<int,int> P;
const ll INF = 1e20;
const ll MOD = 1e9 + 7;

int MAXN = 405;
vector<ll> a(MAXN);
vector<vector<ll>> dp(MAXN,vector<ll>(MAXN,-1));

ll dfs(int l,int r) {
    if (dp[l][r] != -1) return dp[l][r];
    if (r - l == 1) {
        return dp[l][r] = 0;    
    }
    ll ans = INF;
    for (int i = l + 1; i < r ; i ++ ) {
        ans = min(ans,dfs(l,i) + dfs(i,r));
    }
    if (l == 0) ans += a[r - 1];
    else ans += a[r - 1] - a[l - 1];
    return dp[l][r] = ans;
}

int main() {
    int n; cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,n - 1) a[i + 1] += a[i];
    cout << dfs(0,n) << endl;
}

Measured memory_bytes: 1664
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n; cin>>n;
    vector<int> cnt(3,0);
    rep(i,n){
        int a,c=0; cin>>a;
        while(a%2==0){
            a/=2; c++;
        }
        cnt[min(c,2)]++;
    }
    int k=n-cnt[1];
    if(cnt[1]){
        cout<<((k+1)/2<=cnt[2] ? "Yes" : "No")<<endl;
    }
    else{
        cout<<(k/2<=cnt[2] ? "Yes" : "No")<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  i64 a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;

  pair<double,pair<int,int>> ans = {0,{0,0}};
  for(int A = 0; A <= f; A += a){
    for(int B = 0; A + B <= f ; B += b){
      int w = A + B;
      for(int C = 0;A * 100 + B * 100 + C <= f;C += c){
        for(int D = 0;A* 100 + B * 100 + C + D <= f;D += d){
          int s = C + D;
          if(s > w * e) break;
          ans = max(ans , {1.0 * s / (1.0 * s + w * 100) , {s + w * 100,s}});
        }
      }
    }
  }

  cout << ans.second.first << ' ' << ans.second.second << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){

    ll K, A, B;
    cin >> K >> A >> B;

    if(B - A <= 2){
        cout << K + 1 << endl;
    }
    else{
        if(K < A - 1){
            cout << K + 1 << endl;
        }
        else{
            K -= A - 1;
            if(K % 2 == 0) cout <<  K / 2 * (B - A) + A << endl;
            else cout << K / 2 * (B - A) + A + 1 << endl;
        }
    }
}



Measured memory_bytes: 384
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

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

    int backet[110] = {0};
    backet[a]++;
    backet[b]++;
    backet[c]++;
    int ans = 0;
    for(int i = 0; i < 110; i++){
        if(backet[i] > 0){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
n = N % 10
if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
  print('hon')
elif n == 0 or n == 1 or n== 6 or n == 8:
  print('pon')
else:
  print('bon')

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll ar[500009],br[500009],fr[500009];
string s1,s2;
map<string,int>mp;
int main()
{
    ll i,j,k,e,r,n,s,d,f,g,h,u,ck=0,ck1=0,t;
    cin >> n;
    for(i=1;i<=n;i++)
    {
        cin >> ar[i];
        stringstream ss;
        ss << ar[i];
        ss >> s2;
        mp[s2]=i;
    }
    sort(ar+1,ar+1+n);
    for(i=1;i<=n;i++)
    {
        stringstream ss1;
        ss1 << ar[i];
        ss1 >> s1;
        cout << mp[s1] << " ";
    }
    cout << endl;
}



Measured memory_bytes: 15872
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair 
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define rrep(i,a,b) for(int i = a; i >=b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
#define all(x) (x).begin(),(x).end()
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using ii = pair<int, int>;
using pli = pair<ll, int>;
using vi = vector<int>;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using pil = pair<int,ll>;
using vvi = vector<vi>;
using vpi = vector<ii>;

const int N = 100100;
ll mod=1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    map<string,int> cnt;
    rep(i,0,n-1){
        string s;
        cin>>s;
        cnt[s]++;
    }
    cout<<"AC x "<<cnt["AC"]<<nl;
    cout<<"WA x "<<cnt["WA"]<<nl;
    cout<<"TLE x "<<cnt["TLE"]<<nl;
    cout<<"RE x "<<cnt["RE"]<<nl;
    return 0;
}


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

int main() {
  int i = 1,n,x;
  cin >> n;
  while (i <= n) {
    x = i;
    if (x % 3 == 0) {
      cout << " " << i;
    } else {
      while (x) {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
        x /= 10;
      }
    }
    i++;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3080
#include <stdio.h>
#include <ctype.h>

int main(){
    char ch;
    while(1){
        scanf("%c", &ch);
        if(ch=='\n'){
            printf("\n");
            break;
        }else if(islower(ch)){
            printf("%c", toupper(ch));
        }else if(isupper(ch)){
            printf("%c", tolower(ch));
        }else{
            printf("%c", ch);
        }
    }

    return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define endl "\n"
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define ll long long
#define llu unsigned long long
#define MAX(a, b)  (((a) > (b)) ? (a) : (b))
#define MIN(a, b)  (((a) < (b)) ? (a) : (b))
#define ABS(X) ((X)< 0 ? -(X): (X))
#define LCM(X, Y)  ( ( (X) / (GCD( (X)  , (Y) ))) * (Y) )
#define MEM( A,  B) memset((A), (B), sizeof(A))
#define MEM_VEC(V, FILL ) fill( V.begin(), V.end(), FILL)
#define FOR_EACH(IT, V) for (auto IT = V.begin(); IT != V.end(); IT++)
#define DEBUG_ARRAY_PRINT(A,I) cout<<"at pos "<< I <<"  value is: "<< A[I]
#define TURBO ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0)
const double EPS =1e-9 ;
const double PI = 3.1415926535897932384626433832795 ;
using namespace std ;
inline ll GCD(ll A, ll B){
      if ( B == 0 ) return A;
      return GCD( (B) ,  (A % B) );
}
inline ll POW(ll BASE, ll EXP) {
   ll RES = 1;
   for(ll I= 0; I < EXP; I++) RES *= BASE ;
   return RES;
}

inline ll BIGMOD  ( ll a, ll p, ll m ) {
   ll res = 1 % m;
   ll x = a % m;
   while ( p > 0 ) {
       if ( (p & 1) > 0 ) res = ( res * x ) % m;
       x = ( x * x ) % m; p >>= 1;
   }
   return res;
}
inline void FILE_HANDLE( ){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

}

int main()
{
            TURBO;
            string str ;
            cin >> str ;int cnt = 0 ;
            int maximum = 0 ;
            for(int i = 0 ; i < str.size() ; i++)
            {
                  if(str[i] == 'R')
                  {
                        while(str[i] == 'R')
                        {
                              cnt++ ;
                              i++;
                        }
                  }
                  if(cnt > maximum)
                  {
                        maximum = cnt ;
                        cnt = 0 ;
                  }
            }
            cout << maximum << endl ;
}



Measured memory_bytes: 3604
import numpy as np
n,m = map(int,input().split())
xyz = [list(map(int,input().split())) for i in range(n)]
xyz = np.array(xyz)
a = [[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]
a = np.array(a)
ans = 0
temp = []
for i in a:
    temp = []
    b = i * xyz
    for j in b:
        temp.append(sum(j))
    temp.sort(reverse=1)
    ans = max(ans,sum(temp[:m]))
print(ans)

Measured memory_bytes: 12508
#include <iostream>
#include <vector>
#include <random>
#include <deque>
#include <tuple>

using namespace std;
using lint = long long;

lint MOD[3] = {1000000007, 1000000009, 998244353};
mt19937 mt((int)time(nullptr));
int R[10000];

lint myhash(vector<vector<int>>& graph, int v, int d, int i) {
    lint ret = 8951 * (graph[v].size() + 1);
    for (int sv : graph[v]) {
        ret *= (myhash(graph, sv, d + 1, i) + R[d]) % MOD[i];
        ret %= MOD[i];
    }
    return ret;
}

bool solve() {
    int H[2], W[2];
    vector<string> S[2];

    for (int i = 0; i < 2; ++i) {
        cin >> H[i] >> W[i];
        if (i == 0 && H[i] == 0) return false;

        S[i].resize(H[i] + 2);

        for (int x = 0; x < H[i] + 2; ++x) {
            if (x == 0 || x == H[i] + 1) {
                S[i][x] = string(W[i] + 2, '.');
            } else {
                cin >> S[i][x];
                S[i][x] = '.' + S[i][x] + '.';
            }
        }
    }

    vector<vector<int>> graph[2];

    for (int i = 0; i < 2; ++i) {
        vector<vector<int>> id(H[i] + 2, vector<int>(W[i] + 2, -1));
        int curid = 0;

        deque<pair<pair<int, int>, pair<int, int>>> que;
        que.emplace_front(make_pair(0, 0), make_pair(-1, -1));

        while (!que.empty()) {
            pair<int, int> p, sp;
            tie(p, sp) = que.front();
            que.pop_front();

            int x, y, sx, sy;
            tie(x, y) = p;
            tie(sx, sy) = sp;

            if (id[x][y] >= 0) continue;

            if (sx < 0 || S[i][sx][sy] != S[i][x][y]) {
                id[x][y] = curid++;
                graph[i].push_back(vector<int>());
                if (id[x][y] > 0) graph[i][id[sx][sy]].push_back(id[x][y]);
            } else {
                id[x][y] = id[sx][sy];
            }

            for (int dx = -1; dx <= 1; ++dx) {
                for (int dy = -1; dy <= 1; ++dy) {
                    if ((dx == 0 && dy == 0) ||
                        (S[i][x][y] == '.' && abs(dx) + abs(dy) == 2)) continue;

                    int nx = x + dx, ny = y + dy;
                    if (nx < 0 || H[i] + 2 <= nx || ny < 0 || W[i] + 2 <= ny ||
                        id[nx][ny] >= 0) continue;

                    if (S[i][nx][ny] == S[i][x][y]) {
                        que.emplace_front(make_pair(nx, ny), make_pair(x, y));
                    } else {
                        que.emplace_back(make_pair(nx, ny), make_pair(x, y));
                    }
                }
            }
        }
    }

    for (int j = 0; j < 3; ++j) {
        lint val[2];
        for (int i = 0; i < 2; ++i) {
            val[i] = myhash(graph[i], 0, 0, j);
        }
        if (val[0] != val[1]) {
            cout << "no" << endl;
            return true;
        }
    }

    cout << "yes" << endl;
    return true;
}

int main() {
    for (int i = 0; i < 10000; ++i) R[i] = mt();
    while (solve()) {}
    return 0;
}



Measured memory_bytes: 3412
// In The Name Of Allah

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

#define int long long

const int inf = 1e18;
const int maxx = 1e5 + 19;

int n;
pair<int, int> a[maxx];
int b[maxx], ans = 0;

int32_t main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second; 
        ans -= a[i].second;
        b[i] = a[i].first + a[i].second;
    }
    sort(b, b + n);
    for (int i = n - 1; i >= 0; i -= 2)
        ans += b[i];
    cout << ans;
    return 0;
}


Measured memory_bytes: 2560
import heapq
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p=sorted(p, reverse=True)[:x]
q=sorted(q, reverse=True)[:y]
r.sort(reverse=True)
s = p+q
res = sum(s)
heapq.heapify(s)
for val in r:
    suffix = heapq.heappop(s)
    if suffix < val:
        heapq.heappush(s, val)
        res += val-suffix
    else:
        break
print(res)




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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  sort(v.begin(), v.end());
  int ans = 0;
  rep(i, k) ans += v[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;


int main() {
    int n;
    cin >> n;
    
    vector<long long> sum(5, 0);
    for (int i = 0; i < n; ++i)
    {
        string tmp;
        cin >> tmp;
        
        if (tmp[0] == 'M')
        {
            sum[0]++;
        }
        if (tmp[0] == 'A')
        {
            sum[1]++;
        }
        if (tmp[0] == 'R')
        {
            sum[2]++;
        }
        if (tmp[0] == 'C')
        {
            sum[3]++;
        }
        if (tmp[0] == 'H')
        {
            sum[4]++;
        }
    }
    
    long long ret = 0;
    
    for (int i = 0; i < 3; ++i)
    {
        for (int j = i + 1; j < 4; ++j)
        {
            for (int k = j + 1; k < 5; ++k)
            {
                ret += (long long)((long long)sum[i] * (long long)sum[j] * (long long)sum[k]);
            }
        }
    }
    
    cout << ret << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;
int main()
{
    int n;
    cin>>n;
    vector<int>a(n),b(n),c(n);
    rep(i,n){
        cin>>a[i];
        a[i]--;
    }
    rep(i,n)cin>>b[i];
    rep(i,n-1)cin>>c[i];
    int util=0;
    int bef=-1;
    rep(i,n){
        if(bef==a[i]-1&&bef>=0){
            util+=c[a[i]-1];
        }
        util+=b[a[i]];
        bef=a[i];
    }
    cout<<util<<endl;
}


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

int main()
{
 	int A;
  	int B;
  	int C;
  	cin >> A;
  	cin >> B;
  	cin >> C;
  	if(A == B)
      cout << C;
  	else if(B == C)
      cout << A;
  	else
      cout << B;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define REP(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;

int main(){
    std::ios_base::sync_with_stdio(false);

    int n; cin>>n;
    bool f[100][5][2];
    ll p[100][11];

    REP(i,n) REP(j,5) REP(k,2){bool ff; cin>>ff; f[i][j][k]=ff;}
    REP(i,n) REP(j,11){ll pp; cin>>pp; p[i][j]=pp;}

    ll ans=-INF;
    for(int bit=1; bit<(2<<9); ++bit){

      std::bitset<16> x(bit);


      int open[100]; REP(i,n) open[i]=0;
      REP(y,10) if(bit & (1<<y)) {


        REP(i,n) if(f[i][y%5][y%2]) open[i]++;
        // cout << y << endl;
      }
      ll cnt=0LL;




      REP(i,n) cnt+=p[i][open[i]];

      ans=max(ans, cnt);
    }

    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>

int main()
{
    long N;
    std::cin >> N;
    double ex=std::sqrt(N);
    long temp=ex;
    long FAB=100000000;
    for(long i=ex; i>0; i--){
        long wari=N/i;
        if(wari*i==N){
            long temp2=std::max(wari,i);
            long FABtemp=std::to_string(temp2).length();
            if(FAB>FABtemp){
                FAB=FABtemp;
            }
        }
    }
    std::cout << FAB << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
int MOD=1000000007;
int main(){
    int N,bo=1,ans=0; cin >> N;
    int a[N+10];
    for(int i=1; i<=N; i++)
    cin >> a[i];
    for(int i=0; i<N; i++){
        if(bo==2){
            cout << ans << endl;
            return 0;
        }
        bo=a[bo];
        ans++;
    }
    cout << -1 << endl;
}



Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e18
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  int N;
  string s;
  cin >> N >> s;
  ll r = 0, g = 0, b = 0;
  REP(i,N){
    if(s[i]=='R')
      r++;
    else if(s[i]=='B')
      b++;
    else
      g++;
  }
  ll sum = r * g * b;
  ll cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N;j++){
      int k = 2 * j - i;
      if(k>=N)
        continue;
      if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k])
        cnt++;
    }
  }
  cout << sum - cnt << endl;

  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MOD=1e9+7;

int ad(int x,int y){
	return (x+y)%MOD;
}
int mi(int x,int y){
	return ((x-y)+MOD)%MOD;
}

int main(){
	int N;
	cin>>N;
	//ACGTが0123で、下3文字。
	int dp[101][4][4][4];
	
	rep(i,4)rep(j,4)rep(k,4)dp[3][i][j][k]=1;
	dp[3][0][2][1]=0;
	dp[3][2][0][1]=0;
	dp[3][0][1][2]=0;
	
	bool last4[4][4][4][4];
	rep(l,4)rep(i,4)rep(j,4)rep(k,4){
		bool ok=true;
		if(i==0&&j==2&&k==1)ok=false;
		if(i==2&&j==0&&k==1)ok=false;
		if(i==0&&j==1&&k==2)ok=false;
		if(l==0&&i==2&&k==1)ok=false;
		if(l==0&&j==2&&k==1)ok=false;		
		last4[l][i][j][k]=ok;
	}
	
	for(int x=4;x<=N;x++){
		rep(i,4)rep(j,4)rep(k,4){
			int ct=0;
			rep(l,4)if(last4[l][i][j][k])ct=ad(ct,dp[x-1][l][i][j]);
			dp[x][i][j][k]=ct;
        }
	}
	int ans=0;
	rep(i,4)rep(j,4)rep(k,4)ans=ad(ans,dp[N][i][j][k]);
	cout<<ans;
}

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

typedef long long ll;
typedef long double ld;

#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ld a, b;

    cin >> a >> b;

    cout << ceil((a + b) / 2) << endl;

    return 0;
}

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

using namespace std;

typedef unsigned long long int lli;

const int MOD = 1000000007;

int main() 
{
    int n;
    scanf("%d", &n);
    
    lli p = 1;
    
    for(int i = 1; i <= n; i++)
        p = ((p % MOD) * (i % MOD)) % MOD;
        
    printf("%llu\n", p%MOD);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int h1, m1, h2, m2; cin >> h1 >> m1 >> h2 >> m2;
    int k; cin >> k;
    int t1 = h1*60+m1;
    int t2 = h2*60+m2;
    if (t2 >= t1) {
        cout << t2 - t1 - k << endl;
    } else {
        cout << 60*24 - t1 + t2 - k << endl;
    }
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned  long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
    ll n,c=0,sum=0;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
      cin>>a[i];
    }
    sort(a,a+n,greater<ll>());
    c=1;
    sum=a[0];
    ll kahatak=(n-1)/2;
    ll nn=n-1;
    for(int i=1;i<n;i++)
    {
      if(nn-c>=2)
      {
        sum+=(2*a[i]);
        c+=2;
      }
      else if(nn-c==1)
      {
        sum+=a[i];
        c++;
      }
      if(c==n)
      {
        break;
      }
        /*kahatak--;
        if(kahatak<=0)
        {
          break;
        }*/
       
    }
    /*if(n&1)
    {
      sum+=a[2*kahatak+1];
    }*/
    cout<<sum<<endl;
    //cout<<a[0]*(n-1)<<endl;
    //cout<<c<<endl;
}
return 0;
}

Measured memory_bytes: 5208
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdlib.h>
#define ll long long
#define MOD_P 1000000007
using namespace std;

int main()
{
	int H,W,h,w;

	cin >> H >> W >> h >> w;
	
	printf("%d", (H - h) * (W - w));
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;
int main()
{
	int a,b,h,m;
	double PI=3.14159265358979323846;
	cin>>a>>b>>h>>m;
	m+=h*60;
	double hh=2*PI/720*m;
	double mm=2*PI/60*m;
	while (hh>2*PI) hh-=2*PI;
	while (mm>2*PI) mm-=2*PI;
	double del=hh-mm;
	double ans=sqrt(a*a+b*b-2*a*b*cos(del));
	cout<<setiosflags(ios::fixed)<<setprecision(15)<<ans;
}

Measured memory_bytes: 4256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll maxSubArraySum(int a[], int size)
{
         ll max_so_far = 0, max_ending_here = 0;
   for (int i = 0; i < size; i++)
   {
       max_ending_here = max_ending_here + a[i];
       if (max_ending_here < 0)
           max_ending_here = 0;

       /* Do not compare for all elements. Compare only
          when  max_ending_here > 0 */
       else if (max_so_far < max_ending_here)
           max_so_far = max_ending_here;
   }
                return max_so_far;
}
ll fast_power(ll a,ll b,ll p)
{
	if(b==0)
	{
		return (1%p);
	}
	ll t=fast_power(a,b/2,p);
	ll ans=(t*t)%p;
	if(b%2)
	{
		ans=(ans*(a%p))%p;
	}
	return ans;
}
int main()
{
	ll h;
	cin>>h;
	//cout<<log2(h)
	ll x=(int)log2(h);
	cout<<2*(fast_power(2,x,1000000000000000)-1)+1<<endl;
	
}



Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 2e5 + 7;
const int Inf = 1e9 + 7;
typedef long long ll;
typedef pair <int, int> pr;
map <int, int> mp;
set <int> sst;
vector <int> vect;
priority_queue <pr> qua;
int n;
int a[maxn];
int c[maxn], d[maxn];
 
int main() {
	cin >> n;
	ll sum = 0;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] -= i;
	}
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; i++) sum += abs(a[i] - a[(n + 1) / 2]);
	cout << sum << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	register int f=1,k=0;register char c=getchar();
	while (c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();
	while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();
	return k*f;
}
const int maxn=2e5+100;
int a[maxn];
int main()
{
	int n=read();
	for (register int i=1;i<=n;i++)a[i]=read();
	ll ans=0;bool flag=1;
	if (a[1])flag=0;
	for (register int i=2;i<=n;i++)
	if (a[i]>a[i-1]+1)flag=0;
	if (!flag)return puts("-1"),0;
	for (register int i=n;i>1;i--)
	{
		if (a[i]==a[i-1]+1)++ans;
		else ans+=a[i];
	}
	printf("%lld\n",ans);
//	for (register int i=1;i<=n;i++)cout <<a[i]<<" ";puts("");
//	for (register int i=1;i<=n;i++)cout << a[i]-i<<" ";puts("");
//	for (register int i=1;i<=n;i++)cout << i%10 <<" ";
	/*
	for (register int i=1;i<=n;i++)
	store[i].pos=i,a[i]=store[i].val=read(),
	a[i]==a[i-1]+1?(f[i]=f[i-1]+1):(f[i]=1),f[i]>mx&&(mx=f[i],p=i,value=a[i]);
	for (register int i=p-mx+1;i<=p;i++)vis[i]=1;
	sort(store+1,store+1+n,cmp);
	for (register int i=1;i<p-mx+1;i++)
	if (a[i]>value[i])
	printf("%d\n",pre+rear);*/
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

bool prime(int n){
    int i;
    for(i=2;i<n;i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}

int main(){
    int c,i,n;
    cin >> n;
    c = 0;
    for(i=6;i<=55555;i+=5){
        if(prime(i)==true && c<n){
            cout << i << " " ;
            c++;
        }
        if(c==n){
            break;
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.text.*;
import java.math.*;
import static java.lang.Integer.*;
import static java.lang.Double.*;
import java.lang.Math.*;

public class Main {

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

	public void run() throws Exception {
		FastIO file = new FastIO();
		long[] a = new long[5];
		long n = file.nextLong();
		for (int i = 0; i < 5; i++) {
			a[i] = file.nextLong();
		}
		long v = Arrays.stream(a).min().getAsLong();
		long t = (n + v - 1) / v;
		System.out.println(t + 4);
	}

	public static class FastIO {
		BufferedReader br;
		StringTokenizer st;

		public FastIO() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	public static long pow(long n, long p, long mod) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n % mod;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2, mod);
			return (temp * temp) % mod;
		} else {
			long temp = pow(n, p / 2, mod);
			temp = (temp * temp) % mod;
			return (temp * n) % mod;

		}
	}

	public static long pow(long n, long p) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2);
			return (temp * temp);
		} else {
			long temp = pow(n, p / 2);
			temp = (temp * temp);
			return (temp * n);

		}
	}

	public static long gcd(long x, long y) {
		if (x == 0)
			return y;
		else
			return gcd(y % x, x);
	}

	public static boolean isPrime(int n) {
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;

		if (n % 2 == 0 || n % 3 == 0)
			return false;

		for (int i = 5; i * i <= n; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;

		return true;
	}
}


Measured memory_bytes: 26452
#include <cstdio>
#include <vector>
#include <algorithm>
#include <climits>
#include <string>

using namespace std;

int n;
vector<pair<string, int> > S, T;

int partition(int p, int r)
{
    int x=S[r].second;
    int i=p-1;
    for(int j=p; j<r; j++){
        if(S[j].second<=x){
            i++;
            swap(S[i], S[j]);
        }
    }
    swap(S[i+1], S[r]);
    return i+1;
}

void quickSort(int p, int r)
{
    if(p<r){
        int q=partition(p, r);
        quickSort(p, q-1);
        quickSort(q+1, r);
    }
}


int merge(int left, int mid, int right)
{
    int n1=mid-left, n2=right-mid;
    vector<pair<string, int> > L(n1+1), R(n2+1);
    for(int i=0; i<n1; i++){
        L[i]=T[left+i];
    }
    L[n1]=make_pair("", INT_MAX);
    for(int i=0; i<n2; i++){
        R[i]=T[mid+i];
    }
    R[n2]=make_pair("", INT_MAX);
 
    int cnt=0;
    for(int i=0, j=0, k=left; k<right; k++){
        if(L[i].second<=R[j].second){
            T[k]=L[i];
            i++;
        } else{
            T[k]=R[j];
            j++;
        }
        cnt++;
    }
    return cnt;
}
 
int mergeSort(int left, int right)
{
    if(left+1<right){
        int mid=(left+right)/2;
        int c1=mergeSort(left, mid);
        int c2=mergeSort(mid, right);
        return merge(left, mid, right)+c1+c2;
    }
    return 0;
}

int main()
{
    scanf("%d", &n);
    S=vector<pair<string, int> >(n);
    for(auto &it : S){
        char buf[8]; int d;
        scanf("%s %d", buf, &d);
        it=make_pair(buf, d);
    }
    copy(S.begin(), S.end(), back_inserter(T));
    mergeSort(0, n);
    quickSort(0, n-1);
    if(S==T){
        printf("Stable\n");
    } else{
        printf("Not stable\n");
    }
    for(auto &it : S){
        printf("%s %d\n", it.first.c_str(), it.second);
    }
    return 0;
}

Measured memory_bytes: 11752
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> namespace mp = boost::multiprecision; //mp::cpp_intで宣言
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////


ll a[51];
ll pa[51];

ll ans=0;
void po(ll k,ll pos){
    if(k==0){
        if(pos==1)ans++;
        return;
    }
    if(pos<=1)return;
    if(pos<=1+a[k-1]){
        po(k-1,pos-1);
    }else if(pos==2+a[k-1]){
        ans++;
        ans+=pa[k-1];
    }else{
        if(pos==a[k])pos--;
        ans+=1+pa[k-1];
        po(k-1,pos-2-a[k-1]);
    }
    
}


int main(){
    ll n,x;cin>>n>>x;
    
    a[0]=1;
    rep(i,1,50){
        a[i]=2*a[i-1]+3;
    }
    pa[0]=1;
    rep(i,1,50){
        pa[i]=2*pa[i-1]+1;
    }
    po(n,x);
    cout<<ans<<endl;


    return 0;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n;
    ll ans = 0;
    cin >> n;
    FOR(i, 1, n)
    {
        if(i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }
    cout << ans;
    return 0;
}


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

int main(){
  int n,d;
  cin >> n >> d;
  d *=2;
  d += 1;
  if(n%d==0){
    cout << n/d << endl;
  } else {
    cout << n/d+1 << endl;
  }
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(){
  int n,m,y,a,b,cnt=0;
  scanf("%d%d",&n,&y);
  for(a=y/10000>n?n:y/10000;a>=0;a--){
    m=y;
    m-=a*10000;
    for(b=m/5000>n-a?n-a:m/5000;b>=0;b--){
      if((m-b*5000)/1000==n-a-b){
          printf("%d %d %d",a,b,n-a-b);
          return 0;
      }
    }
  }
  printf("-1 -1 -1");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;

int main(){

    int i, n, k, answer;

    scanf("%d%d", &n, &k);
    answer = k;

    for(i = 1; i < n; i++) answer *= k - 1;

    printf("%d\n", answer);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
#include <complex>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
    long a,b,c,d;
    string s;
    cin  >> a >>b >>c >>d;




    // cout << max(0, (min(b,d) - max(a,c))   );
    long m = (min(b,d) - max(a,c));
    m = max((long)0,m);
    cout << m ;
    
    return 0;
}






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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	int n;
	cin>>n;
	vector<int> a(n+1);
	for(int i=0;i<n+1;i++)cin>>a[i];
	ll ans = 0;
	for(int i=0;i<n;i++){
		int b;
		cin>>b;
		int can = min(b,a[i]);
		b-=can;
		a[i]-=can;
		ans+=can;
		can = min(b,a[i+1]);
		ans+=can;
		a[i+1]-=can;
	}
	cout << ans << endl;
}

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

using namespace std;
using ll = long long;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<ll> a(n), v(n, 0);
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  ll tmp = sum / 2;

  for (int i = 0; i < n - 1; i += 2) {
    tmp -= a[i];
  }
  v[n - 1] = tmp * 2;
  for (int i = n - 2; i >= 0; i--) {
    v[i] = (a[i] - v[i + 1] / 2) * 2;
  }
  for (ll i : v)
    cout << i << endl;

  return 0;
}


Measured memory_bytes: 2944
#include <stdio.h>
#include <string.h>
#define MAX 2000000
#define INFTY (1<<30)
int H , A[MAX+1];


void maxHeapify(int i)
{
	int tmp;
	int l , r , largest;
	l = 2*i;
	r = 2*i+1;
	
	if( l <= H && A[l] > A[i]) largest = l;
	else largest = i;
	if(r <= H && A[r] > A[largest] ) largest = r;
	
	if(largest != i)
	{
		tmp = A[i];
		A[i] = A[largest];
		A[largest] = tmp;
		maxHeapify(largest);
	}
}

int extract()
{
	int maxv;
	if( H < 1 ) return -INFTY;
	maxv = A[1];
	A[1] = A[H--];
	maxHeapify(1);
	return maxv;
}

void increaseKey(int i , int key)
{
	int tmp;
	if(key < A[i]) return;
	A[i] = key;
	while(i > 1 && A[i/2] < A[i])
	{
		tmp = A[i];
		A[i] = A[i/2];
		A[i/2] = tmp;
		i = i / 2;
	}
}

void insert(int key)
{
	H++;
	A[H] = -INFTY;
	increaseKey(H,key);
}
int main(void)
{
	int key;
	char com[10];
	
	while(1)
	{
		scanf("%s",com);
		if(com[0] == 'e' && com[1] == 'n') break;
		if( com[0] == 'i')
		{
			scanf("%d",&key);
			insert(key);
		}
		else{
			printf("%d\n",extract());
		}
	}
	return 0;
}


Measured memory_bytes: 5644
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int sum=0;
    if(a>b)
    {
        sum+=a;
        a--;
    }
    else
    {
        sum+=b;
        b--;
    }
    if(a>b)
    {
        sum+=a;
        a--;
    }
    else
    {
        sum+=b;
        b--;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int I=X;I<Y;I++)
#define REP(I,X,Y) for(int I=Y-1;I>=X;I--)
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  int V,E,r=0,s,t,d;
  cin >> V >> E;
  vector<tuple<int,int,int>> edges;
  ll dmin[V];
  FOR(i,0,V)dmin[i] = LINF;
  dmin[r] = 0;
  FOR(i,0,E){
    cin >> s >> t >> d;
    edges.push_back(make_tuple(s-1,t-1,-d));
  }
  FOR(i,0,V-1){
    FOR(j,0,E){
      int s=get<0>(edges[j]),t=get<1>(edges[j]),d=get<2>(edges[j]);
      if(dmin[s] != LINF)dmin[t] = min(dmin[t],dmin[s]+d);
    }
  }
  ll ans = -dmin[V-1];
  FOR(i,0,V-1){
    FOR(j,0,E){
      int s=get<0>(edges[j]),t=get<1>(edges[j]),d=get<2>(edges[j]);
      if(dmin[s] != LINF)dmin[t] = min(dmin[t],dmin[s]+d);
    }
  }
  if(ans < -dmin[V-1])puts("inf");
  else cout << -dmin[V-1] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,a[200000];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n,greater<>());
    int ans=0;
    for(int i=1;i<n;i++)
        ans+=a[i/2];
    cout<<ans<<endl;
}


Measured memory_bytes: 5164
#include <cstdio>
#include <stack>
#include <algorithm>
using namespace std;
int w;
int b[1407][1407], pre[1407][1407];
int solve(int height[]) {
	int ret = 0;
	stack<pair<int, int> > s;
	for (int i = 1; i <= w + 1; i++) {
		if (s.empty()) s.push(make_pair(height[i], i));
		else {
			if (s.top().first < height[i]) s.push(make_pair(height[i], i));
			else if (s.top().first > height[i]) {
				int pos = i;
				while (!s.empty() && s.top().first >= height[i]) {
					pair<int, int> cur = s.top();
					int area = cur.first * (i - cur.second);
					s.pop();
					ret = max(ret, area);
					pos = cur.second;
				}
				s.push(make_pair(height[i], pos));
			}
		}
	}
	return ret;
}
int main() {
    int h, ans = 0;
    scanf("%d%d", &h, &w);
    for (int i = 1; i <= h; i++) {
    	for (int j = 1; j <= w; j++) {
    		scanf("%d", &b[i][j]);
		}
	}
	for (int i = 1; i <= h; i++) {
    	for (int j = 1; j <= w; j++) {
    		if (b[i][j] == 1) pre[i][j] = 0;
			else pre[i][j] = pre[i - 1][j] + 1;
		}
	}
	for (int i = 1; i <= h; i++) {
		ans = max(ans, solve(pre[i]));
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 18104
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, t;
    cin >> n >> t;
    vector<int> a(n), b(n);
    rep (i, n) cin >> a[i];
    int amax = a.back();
    reprev(i, n) {
        chmax(amax, a[i]);
        b[i] = amax - a[i];
    }
    sort(all(b), greater<int>());
    int ans = 1;
    while (ans < n && b[ans] == b[ans - 1]) ans++;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a; cin >> a;
    a = a % 1000;
    if(a) a = 1000 - a;
    cout << a << endl;
}

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

using namespace std;

const int MAX_N = 100000;

int n, x, a[MAX_N + 1];
long long ans = 0;

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

    cin >> n >> x;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    for (int i = 1; i < n; i++) {
        ans += max(0, min(a[i + 1], (a[i] + a[i + 1]) - x));
        a[i + 1] -= max(0, min(a[i + 1], (a[i] + a[i + 1]) - x));

        ans += max(0, min(a[i], (a[i] + a[i + 1]) - x));
        a[i] -= max(0, min(a[i], (a[i] + a[i + 1]) - x));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
n, k = map(int, input().split())
a = list(map(int, input().split()))
"""
point = 1
points = []

for i in range(n):
    point *= a[i]
    if i >= k - 1:
        points.append(point)
        if i >= k:
            if points[-1] > points[-2]:
                print("Yes")
            else:
                print("No")
        point //= a[i - k + 1]
"""
for i in range(n):
    if i >= k:
        if a[i] > a[i - k]:
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 94296
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define mmm 1000000007
#define pb push_back
									//nestedcode
ll dp[100005];

 int main(){
	ios::sync_with_stdio(false);
  	cin.tie(0); cout.tie(0);
  	ll n,m,i,j,a,b,c,ans;
  	cin>>n>>m;
  	for(i=1;i<=pow(2,12)+3;i++){
  	    dp[i] = INT_MAX;
  	}
  	for(j=0;j<m;j++){
  		cin>>a>>b;
  		ans = 0;
  		for(i=0;i<b;i++){
  			cin>>c;
  			c--;
  			ans+=pow(2,c);
		  }
		  for(i=0;i<=pow(2,12)+3;i++){
		    dp[i|ans] = min(dp[i]+a,dp[i|ans]);
		  }
		  
	  }
	  
	  if(dp[(ll)pow(2,n)-1] == INT_MAX){
	  	cout<<-1;
	  }else{
	  	cout<<dp[(ll)pow(2,n) - 1];
	  }
}

Measured memory_bytes: 512
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

N = int(input())
Ps = list(map(int,input().split(" ")))
MOD = 10 ** 9 + 7
g = 1
for p in Ps:
    g = lcm(g,p)
ans = 0

print(sum([g // p for p in Ps]) % (10 ** 9 + 7))



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

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  int diff = b - a;

  for (int i = 0; i <= diff; i++) {
    int num = a + i;
    int ones_place = num % 10;
    int tens_place = num / 10 % 10;
    int thousands_place = num / 1000 % 10;
    int ten_thousands_place = num / 10000 % 10;
    if (ones_place == ten_thousands_place && tens_place == thousands_place)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

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

//Cards
public class Main{

	static int[] bipartiteMatching(boolean[][] graph) {
		int n = graph.length;
		if(n==0)return new int[0];
		int m = graph[0].length;
		int[] match = new int[m];
		Arrays.fill(match, -1);
		int res = 0;
		for (int i = 0; i < n; i++) {
			boolean[] visited = new boolean[m];
			if (go(i,graph,visited,match)) res++;
		}
		return match;
	}
	static boolean go(int v,boolean[][] graph,boolean[] visited,int[] match) {
		int m = graph[0].length;
		for (int i = 0; i < m; i++)  if (!visited[i] && graph[v][i] && match[i] == -1) {
			visited[i] = true;
			match[i] = v;
			return true;
		}
		for (int i = 0; i < m; i++) if (!visited[i] && graph[v][i]) {
			visited[i] = true;
			if (go(match[i],graph,visited,match)) {
				match[i] = v;
				return true;
			}
		}
		return false;
	}
	
	public static long gcd(long a, long b){
		if(a < b){
			long tmp = a;
			a = b;
			b = tmp;
		}
		while(b!=0){
			long r = a%b;
			a = b;
			b = r;
		}
		return a;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if((n|m)==0)break;
			int[] blue = new int[n];
			int[] red = new int[m];
			for(int i=0;i<n;i++)blue[i]=sc.nextInt();
			for(int j=0;j<m;j++)red[j]=sc.nextInt();
			boolean[][] match = new boolean[n][m];
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					match[i][j] = gcd(blue[i], red[j]) >= 2;
				}
			}
			int[] r = bipartiteMatching(match);
			int s = 0;
			for(int i:r)s+=i==-1?0:1;
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 14000
#include <iostream>
#define ll long long

using namespace std;

int main()
{
    int X;
    cin >> X;

    bool answer = false;
    if (X-3 == 0) answer = true;
    if (X-5 == 0) answer = true;
    if (X-7 == 0) answer = true;

    cout << (answer ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256