akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoderABC115
{
    class Program
    {
        public static long[] powarray = new long[1000];
        public static long Pow(long a, long b)
        {
            return
                (powarray[b] != 0)? powarray[b] :
                (b == 0)? powarray[b] = 1 :
                powarray[b] = a * Pow(a, b - 1);
        }
        public static long Eat(long num, int burgerLevel)
        {
            if (burgerLevel == 0) return 1;
            if (num == 1) return 0;
            num--;

            long eatNum = 0;
            if (num <= (Pow(2, burgerLevel + 1) - 3)) return eatNum + Eat(num, burgerLevel - 1);
            eatNum += Pow(2, burgerLevel) - 1;
            num -= Pow(2, burgerLevel + 1) - 3;

            if (num == 1) return eatNum + 1;
            num--;
            eatNum++;

            if (num <= (Pow(2, burgerLevel + 1) - 3)) return eatNum + Eat(num, burgerLevel - 1);
            eatNum += Pow(2, burgerLevel) - 1;
            num -= Pow(2, burgerLevel + 1) - 3;

            num--;
            return eatNum;
        }
        public static void Main(string[] args)
        {
            for (int i = 0; i < 1000; i++) powarray[i] = 0;
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            long X = long.Parse(s[1]);
            Console.WriteLine(Eat(X, N));
        }
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
int main()
{
	int h,r;
	scanf("%d%d",&h,&r);
	if(h>-r){
		printf("1\n");
	}else if(h==-r){
		printf("0\n");
	}else{
		printf("-1\n");
	}
	return 0;
}

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


int main(void){
  int n,i,d,l,lmax,llmax=0;
  string s;
  
  cin >> n >> s;
  
  for (d=1;d<n;d++){
    l=lmax=0;
    for (i=0;i<n-d;i++){
      if (s[i]==s[i+d]) l++;
      else l=0;
      lmax=max(lmax,l);
    }
    llmax=max(llmax,min(d,lmax));
  }
  
  cout << llmax << endl;
  
  return 0;
}

Measured memory_bytes: 256
def main():
    width, height, point_num = map(int, input().split())
    points = [tuple(map(int, input().split())) for _ in range(point_num)]
    white_range = [[0, 0], [width, height]]
    for point in points:
        if point[2] == 1:
            white_range[0][0] = max(point[0], white_range[0][0])
        elif point[2] == 2:
            white_range[1][0] = min(point[0], white_range[1][0])
        elif point[2] == 3:
            white_range[0][1] = max(point[1], white_range[0][1])
        else:
            white_range[1][1] = min(point[1], white_range[1][1])
    if white_range[1][0] < white_range[0][0] or white_range[1][0] < white_range[0][0]:
        print(0)
    else:
        print((white_range[1][0] - white_range[0][0]) * (white_range[1][1] - white_range[0][1]))


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pl=pair<ll,ll>;
using vi=vector<int>;
using vl=vector<ll>;
using vvi=vector<vi>;
using vvl=vector<vl>;
using vs=vector<string>;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

bool inRange(int H, int W, int h, int w) {
    return h < 0 || w < 0 || H <= h || W <= w; 
}

void solve() {
    int H, W, sh, sw, gh, gw;
    cin >> H >> W >> sh >> sw >> gh >> gw;
    sh--;sw--;gh--;gw--;
    vs S(H);
    rep(i, H) {
        cin >> S[i];
    }
    int delta[] = {1,0,-1,0,1};
    deque<pair<int, int>> deq;
    deq.push_front(mp(sh,sw));
    vvi move(H, vi(W, 1e9));
    move[sh][sw] = 0;
    while(!deq.empty()) {
        auto v = deq.front();
        deq.pop_front();
        int ch = v.fi;
        int cw = v.sc;
        rep(i, 4){
            int nh = ch + delta[i];
            int nw = cw + delta[i+1];
            if(inRange(H,W,nh,nw) || S[nh][nw]=='#') continue;
            if(move[nh][nw] > move[ch][cw]) {
                move[nh][nw] = move[ch][cw];
                deq.push_front({ nh, nw });
            }
        }
        for(int i=-2;i<=2;i++) {
            for(int j=-2;j<=2;j++) {
                int nh = ch + i;
                int nw = cw + j;
                if(inRange(H,W,nh,nw) || S[nh][nw]=='#') continue;
                if(move[nh][nw] > move[ch][cw]+1) {
                    move[nh][nw] = move[ch][cw]+1;
                    deq.push_back({ nh, nw });
                }
            }
        }
    }
    print(move[gh][gw]==1e9?-1:move[gh][gw]);
}   

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


Measured memory_bytes: 8764
/*
 * @Filename: 
 * @Author: shifaqiang
 * @Email: 14061115@buaa.edu.cn
 * @Github: https://github.com/luoboganer
 * @Date: 2020-07-12 00:38:24
 * @LastEditors: shifaqiang
 * @LastEditTime: 2020-07-12 22:09:55
 * @Software: Visual Studio Code
 * @Description: 
 */

#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
    int n;
    cin >> n;
    vector<vector<int>> points(n, vector<int>(3, 0));
    for (auto i = 0; i < n; i++)
    {
        cin >> points[i][0] >> points[i][1] >> points[i][2];
    }
    int a = points[0][0], b = points[0][1], c = points[0][2];
    for (auto i = 1; i < n; i++)
    {
        int next_a = max(b, c) + points[i][0];
        int next_b = max(a, c) + points[i][1];
        int next_c = max(a, b) + points[i][2];
        a = next_a, b = next_b, c = next_c;
    }
    int ret = max(max(a, b), c);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 8800
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define inf 1<<30
#define il inline 
#define in1(a) read(a)
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)
il void readl(ll &x){
    x=0;ll f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
il void read(int &x){
    x=0;int f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
using namespace std;
/*===================Header Template=====================*/
int k;
int main(){
	int ans=0;
	read(k);
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			if(i%2==0&&j%2) ans++;
		}
	}
	printf("%d",ans);
	return 0;
}

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

int main() {
  int q,w,e,r; cin >>q>>w>>e>>r;
  cout << min(q,w) + min(e,r);
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n, m;
  cin >> n >> m;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;

  vector<ll> sum(n + 1);
  rep(i, n) {
    sum[i + 1] = sum[i] + a[i];
  }

  map<int, ll> count;
  rep(i, n + 1) {
    ++count[sum[i] % m];
  }

  for (auto it = count.begin(); it != count.end(); ++it) {
    ans += (it->second) * (it->second - 1) / 2;
  }
  cout << ans << endl;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int main() {
	std::string s, t;
	std::cin >> s >> t;
	int a = ri(), b = ri();
	std::string u;
	std::cin >> u;
	if (u == s) a --;
	else b--;
	printf("%d %d\n", a, b);
  	return 0;
}


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

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

	int a[n+3],b[n+3];
	int nax[n+3] = {0};
	int tax = 0;
	for(int i=0;i<n;++i){
		cin>>a[i];
	}

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

	for(int i=0;i<n;++i){
		for(int j=0;j<=i;++j){
			nax[i] += a[j];
		}
		for(int k=n-1;k>=i;--k){
			nax[i] += b[k];
		}
	}
	
	for(int i=0;i<n;++i){
		tax = max(tax,nax[i]);
	}
	cout<<tax<<endl;
}

Measured memory_bytes: 256
/*in the name of Allah the most beneficent the most merciful.*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
//#define mod2 20071027
//#define MOD 998244353
#define base 139
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case #%lld: ", ++c)
#define out(x) cout << #x << " -> " << x << endl;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FILE   freopen("input.txt", "r", stdin);  freopen("out.txt", "w", stdout);
using namespace std;
const int B = 16, N = 100010, M = 5000010;
ll n;
int solve()
{
    in1(n);
    if(n>=30) printf("Yes\n");
    else printf("No\n");    
    return 0;
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    return solve();
}
/*

*/

Measured memory_bytes: 3760
a,b,c,d=input().split()
a=int(a)
b=int(b)
c=int(c)
d=int(d)
list1=[]
list1.append(a*c)
list1.append(a*d)
list1.append(b*c)
list1.append(b*d)
list1.sort()
print(list1[3])

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int r,g,b,n;cin >> r >> g >> b >> n;
	ll ans=0;
	rep(i,n/r+1){
		rep(j,n/g+1){
			if(i*r+j*g>n) break;
			if((n-i*r-j*g)%b==0) ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
data = [list(map(int,input().split())) for _ in range(n)]
data.sort(key=lambda x:x[2],reverse=True)
for cx in range(101):
    for cy in range(101):
        hq = data[0][2] + abs(data[0][0]-cx) + abs(data[0][1]-cy)
        t = True
        for i in range(1,n):
            if data[i][2] != max(0, hq-abs(data[i][0]-cx)-abs(data[i][1]-cy)):
                t = False
                break
        if t:
            print(cx,cy,hq)
            exit()

Measured memory_bytes: 41200
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	cout << (c - a) * 60 + d - b - e;
	return 0;
}

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

int main()
{   
	string s,t,u;
	cin>>s>>t;

	int a,b;
	cin>>a>>b;

	cin>>u;

	if(s==u)
		a--;
	else
		b--;

	cout<<a<<" "<<b;

return 0;
}

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

int main () {
    int n, l;
    cin >> n >> l;
    vector<string> S(n);
    
    for (int i = 0; i < n; i++) {
        cin >> S[i];
    }

    sort(S.begin(), S.end());
    
    for (int i = 0; i < n; i++) {
        cout << S[i];
    }
    cout << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include<vector>
#include<string>
#include<cstring>
#include<deque>
#include<queue>
#include<list>
#include<algorithm>
using namespace std;
int main()
{
    int n,k;
   cin>>n>>k;
cout<<(n%k!=0)<<endl;

}

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

int count_divisor(int N){
  int ret = 0;
  for(int i = 1; i <= N; ++i){
    if(!(N%i)) ++ret;
  }
  return ret;
}

int main(){
  int N;
  cin >> N;
  int ans = 0;
  for(int i = 1; i <= N; i += 2){
    if(count_divisor(i) == 8) ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int n;
  int s[100];
  int i;
  int max = 0;
  int min = 0;
  int sum = 0;
  int avg;

  
  while(1){
    scanf("%d",&n);
    if(n == 0)
      break;
    
    for(i = 0;i < n;i++){
      scanf("%d",&s[i]);
      if(i != 0 && s[i] > s[max])
	max = i;
      if(i != 0 && s[i] < s[min])
	min = i;
    }

    for(i = 0;i < n;i++)
      sum += s[i];
    
    sum = sum - s[max] - s[min];
    
    avg = sum / (n-2);

    printf("%d\n",avg);
    
    max = 0;
    min = 0;
    sum = 0;
  }

  return 0;
}
  

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

vector<int> T = {2, 5, 5, 4, 5, 6, 3, 7, 6};

int f(int x){
    return T[x-1];
}

string solve(string a, string b){
    
    if(a.size() > b.size()) return a;
    if(b.size() > a.size()) return b;
    return max(a, b);
}

int main(){
    int N, M; cin >> N >> M;
    vector<int> A(M);
    for(int &a:A)
        cin >> a;

    vector<string> dp(N+1);

    for(int i=1; i<=N; i++){
        
        for(int j=0; j<M; j++){
            if(i-f(A[j])==0 || ((i-f(A[j])>0) && dp[i-f(A[j])]!="")){
                string S = dp[i-f(A[j])];
                S += '0' + A[j];
                dp[i] = solve(dp[i], S);
            }
        }
    }
    
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 41472
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	b := 0
	c := 0
	for i := 0; i < n; i++ {
		if b <= a[i] {
			b = a[i]
			c++
		}
	}
	_, _ = fmt.Fprintf(writer, "%d", c)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <math.h>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
using namespace std;

const int MOD = 1000000007;

int main(){
    ll N;
    cin >> N;
    vector <pair<int, int> > v(N);

    REP(i,N)
    {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(),v.end());

    if(N==1)
    {
        cout << 1 << endl;
        return 0;
    }

    int cnt = 0;
    int cur = 0;
    for(int i = 0; i < N-1; ++i)
    {
        //1個
        if(v[i].first + v[i].second <= v[i+1].first - v[i+1].second)
        {
            ++cnt;
            if(i == N-2)++cnt;
            continue;
        }
        else
        {
            if(i == N-2)++cnt;
            //v[i]のほうが短いか
            if(v[i].first + v[i].second <= v[i+1].first + v[i+1].second)
            {
                v[i+1].first = v[i].first;
                v[i+1].second = v[i].second;
            }
        }
    }


    cout << cnt << endl;

    return 0;    
}


Measured memory_bytes: 1024
// Bismillahirrahmanirrahim
// by Batrrr Tolkynbayev
#include <bits/stdc++.h>
// skripi krasava
#define respa return 0
#define all(x) x.begin(), x.end()
#define sz size
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 2e5 + 17, M = N << 2, mod = 1e9 + 7; 

int tt = 1, n, a[N];

void solve () {
	cin >> n;	
	for (int i = 1; i <= n << 1; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + n + n + 1);
	int res = 0;
	for (int i = 2; i <= n << 1; i += 2) {
		res += min(a[i], a[i - 1]);
	}
	cout << res;
}

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// cin >> tt;
	while (tt--) solve();
	respa;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(){
  int imos[1002][1002];
  for(int i = 0;i < 1002;i++){
    for(int j = 0;j < 1002;j++){
      imos[i][j]=0;
    }
  }
  int N,x1,y1,x2,y2,ans=0,q;
  cin >> N;
  for(int i = 0;i < N;i++){
    cin >> x1 >> y1 >> x2 >> y2;
    for(int j = x1;j < x2;j++)imos[j][y1]++;
    for(int j = x1;j < x2;j++)imos[j][y2]--;
  }
  for(int i = 0;i < 1001;i++){
    q = 0;
    for(int j = 0;j < 1001;j++){
      q+=imos[i][j];
      ans=max(ans,q);
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 7028
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long d = sc.nextLong();
    long result = 0;
    for (long i = 0; i < n; i++) {
      long x = sc.nextLong();
      long y = sc.nextLong();
      if (Math.sqrt(x * x + y * y) <= d) {
        result++;
      }
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 49264
#!/usr/bin/env python3
import sys
import math
MOD = 1000000007  # type: int
from collections import Counter
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

def solve(N: int):
    soinsuu = prime_decomposition(math.factorial(N))
    counter = Counter(soinsuu)
    answer =1
    for value in counter.values():
        answer = answer*(value+1)
    print(answer%MOD)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

/* 幅優先探索。dequeをキューとして使う。ABC007/c とほぼ同じ。スタート地点が複数あるので、最初の時点でキューに複数のタプルが挿入される。*/
int main(void){
    int H,W;
    cin >> H >> W;
    char board[H][W];
    deque<tuple<int, int, int>> will_search;
    int dot_count = 0;
    rep(i,H){
        rep(j,W){
            cin >> board[i][j];
            if(board[i][j] == '#')will_search.emplace_back(make_tuple(i,j,0));
        }
    }
    const int DIRECTION_NUM = 4;
    const int dx[DIRECTION_NUM] = {1, -1, 0, 0};
    const int dy[DIRECTION_NUM] = {0, 0, 1, -1};
    int ans = 0;
    while(!will_search.empty()){
        tuple<int, int, int> current_location = will_search.front();
        will_search.pop_front();
        rep(i,DIRECTION_NUM){
            int next_y = get<0>(current_location) + dy[i];
            int next_x = get<1>(current_location) + dx[i];
            int step = get<2>(current_location) + 1;
            if(next_x >= 0 && next_x < W && next_y >= 0 && next_y < H){
                if(board[next_y][next_x] == '.'){
                    will_search.emplace_back(make_tuple(next_y, next_x, step));
                    board[next_y][next_x] = '#';
                    ans = step;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13328
N = int(input())
a = list(int(i) for i in input().split())
b = list(int(i) for i in input().split())

ans = 0
for n in range(N+1):
    ap = a[:n]
    bp = b[n-1:]
    apsum = sum(ap)
    bpsum = sum(bp)
    s = apsum +bpsum
    if s > ans:
        ans = s
print(ans)

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL)
    {
      y=x;
      if(z->key<x->key)
	{
	  x=x->left;
	}
      else
	{
	  x=x->right;
	}
    }
  z->parent=y;
  if(y==NIL)
    {
      root=z;
    }
  else if(z->key<y->key)
    {
      y->left=z;
    }
  else
    {
      y->right=z;
    }
}





void inorder(Node u){
  if(u->left!=NIL)
    {
      inorder(u->left);
    }
  printf(" %d",u->key);
  if(u->right!=NIL)
    {
      inorder(u->right);
    }
}
void preorder(Node u){
  printf(" %d",u->key);
   if(u->left!=NIL)
    {
      preorder(u->left);
    }
  if(u->right!=NIL)
    {
     preorder(u->right);
    }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> t(n), v(n);
    for(int i=0;i<n;i++) cin >> t[i];
    for(int i=0;i<n;i++) cin >> v[i];

    vector<int> vv(200*100+5, 999999);
    vector<int> vvv(200*100+5, 999999);
    //vector<int> ans(200*100+5);

    int sum = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<=t[i];j++){
            vv[sum+j] = min(vv[sum+j], v[i]);
        }
        for(int j=0;j<t[i];j++){
            vvv[sum+j] = v[i];
        }
        sum += t[i];
    }


    vv[0] = 0;
    vv[sum] = 0;
    for(int i=0;i<=sum;i++){
        for(int j=1;j<sum;j++){
            if(abs(vv[j]-vv[j-1]) <= 1 && abs(vv[j]-vv[j+1]) <= 1) continue;
            vv[j] = min({vv[j], vv[j-1]+1, vv[j+1]+1});
        }
    }

    for(int i=0;i<=sum;i++){
        //cout << i << ":" << vv[i] << endl;
    }

    double ans = 0;

    for(int i=0;i<sum;i++){
        double l = vv[i];
        double r = vv[i+1];
        if(vv[i] == vv[i+1]){
            if(vv[i] == vvv[i]){
                ans += l*1.0;
            }else{
                ans += l*1.0 + 1.0*0.5*0.5;
            }
        }else{
            ans += (l+r)*1.0*0.5;
        }
        //cout << ans << endl;
    }

    printf("%lf\n", ans);

    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = long.Parse(Console.ReadLine());
            var sum = 0L;
            for (var i = 1; i <= n; i++)
            {
                if (i % 3 != 0 && i % 5 != 0)
                {
                    sum += i;
                }
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 27372
package main

import (
	"fmt"
)

func main() {
	var n, x, l, ad int
	an := 1
	fmt.Scanln(&n, &x)
	for i := 0; i < n; i++ {
		fmt.Scan(&l)
		ad += l
		if ad <= x {
			an += 1
		}
	}
	fmt.Println(an)

}

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

#define min(X, Y) ((X) < (Y) ? (X) : (Y))

int cmp(const void *x, const void *y);

long long a[2 * 100005];

int main()
{
	long long n;
	long long s = 0;
	long long t = 0;
	long long c = 0;

	scanf("%lld", &n);
	for (long long i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);

		a[i] -= i;
	}

	qsort(a + 1, n, sizeof(long long), cmp);
	
	for (long long i = 1; i <= n; i++) {
		s += llabs(a[i] - a[n / 2]);
		t += llabs(a[i] - a[n / 2 + 1]);
		c += llabs(a[i] - a[n / 2 - 1]);
	}

	printf("%lld\n", min(s, t));

	return 0;
}

int cmp(const void *x, const void *y)
{
	if (*(long long *)x > *(long long *)y) {
		return 1;
	} else if (*(long long *)x == *(long long *)y) {
		return 0;
	} else {
		return -1;
	}
}


Measured memory_bytes: 3324
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 A, B;
  std::cin >> A >> B;
  std::cout << (A * B % 2 == 1 ? "Yes" : "No") << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int a,b,c,x,ans=0;
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(500*i+100*j+50*k==x) ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int flag=0;
    int l = s.length();
    for(int i=0,j=l-1; i<l/2; i++,j--)
    {
        if(s[i]!=s[j])
        {
            flag = 1;
            break;
        }
    }
    if(!flag)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

using namespace std;

int main() {
	int n, m; cin >> n >> m;
	int asum = 0;
	while (m--) {
		int a; cin >> a;
		asum += a;
	}
	cout << max(n - asum, -1) << '\n';
	return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n,h,h_;
    int cnt = 0;
    int maxcnt = 0;
    cin >> n;
    cin >> h;
    int i=1;
    while(i<n){
        cin >> h_;
        while(h>=h_ && i<n){
            cnt++;
            h=h_;
            cin >> h_;
            i++;
        }
        maxcnt = max(maxcnt,cnt);
        cnt = 0;
        h=h_;
        i++;
    }
    cout << maxcnt << endl;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    int taka, ao;
    taka = c/b;
    if(c%b!=0) taka++;
    ao = a/d;
    if(a%d!=0) ao++;

    if(taka<=ao) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
 
int main(void){
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    
    long double solubility = (long double)100 * (long double)E / (long double)(100 + E);
    
    vector<int> water;
    for(int i = 0; i <= F; i++){
        for(int j = 0; j <= F; j++){
            int tmp = 100 * A * i + 100 * B * j;
            if(tmp <= F && tmp > 0){
                water.push_back(tmp);
            } 
        }
    }
    
    vector<int> sugar;
    for(int i = 0; i <= F; i++){
        for(int j = 0; j <= F; j++){
            int tmp = C * i + D * j;
            if(tmp <= F) sugar.push_back(tmp);
        }
    }
    
    long double largest = 0;
    int largestWaterIndex = 0;
    int largestSugarIndex = 0;
    for(int i = 0; i < water.size(); i++){
        for(int j = 0; j < sugar.size(); j++){
            long double percentage = (long double)100 * (long double)sugar[j] / (long double)(water[i] + sugar[j]);
            if(solubility >= percentage && sugar[j] + water[i] <= F){
                if(percentage > largest){
                    largest = percentage;
                    largestWaterIndex = i;
                    largestSugarIndex = j;
                }
            }
        }
    }
    
    int ans1 = water[largestWaterIndex] + sugar[largestSugarIndex];
    int ans2 = sugar[largestSugarIndex];
    
    
    cout << ans1 << " " << ans2 << endl;
}


Measured memory_bytes: 1400
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;

    for(int i=0; i<3; i++){
        if(i%3+1!=a && i%3+1!=b){
            cout<<i%3+1<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int N1 = N % 10;
  N = N / 10;
  int N2 = N % 10;
  N = N / 10;
  int N3 = N % 10;
  N = N / 10;
  int N4 = N % 10;	
  
  if((N1 == N2 && N2 == N3) || (N2 == N3 && N3 == N4)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main()
{
	int64_t n;
	cin >> n;
	vector<int64_t> as(n);
	for (auto &a : as)
	{
		cin >> a;
	}

	vector<int64_t> cnt(n, 0);
	set<int64_t> ans;

	for (int64_t i = n; 1 <= i; i--)
	{
		if (as[i - 1] != cnt[i - 1] % 2)
		{
			ans.insert(i);
			for (int64_t j = 1; j * j <= i; j++)
			{
				if (i % j == 0)
				{
					int64_t k = i / j;
					cnt[j - 1]++;
					if (j != k)
					{
						cnt[k - 1]++;
					}
				}
			}
		}
	}

	cout << ans.size() << endl;
	for (auto &a : ans)
	{
		cout << a << ' ';
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 9856
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	int c=(a%m+b%m);	if(c>=m)	c-=m;	return c;}
int sub(int a,int b,int m=mod){	int c=(a%m-b%m);	if(c<0)		c+=m;	return c;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}
//	x<<1 => x*2		x>>1 => x/2;	cout<<flush;
//	cout<<fixed<<setprecision(10)<<ans<<endl;
#define N 10000001
int a[N],ans[N];

void fun()
{
	int i,j;
	for(i=1;i<N;i++)
		a[i]=1;
	for(i=2;i<N;i++)
		for(j=i;j<N;j+=i)
			a[j]++;
	ans[0]=0;
	for(i=1;i<N;i++)
		ans[i]=a[i]*i+ans[i-1];
}

void solve()
{
	fun();
	int i,j,n;
	cin>>n;
	cout<<ans[n]<<endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int t=1;//cin>>t;
	for(int i=1;i<=t;i++){	solve();}
	return 0;
}

Measured memory_bytes: 159896
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<string>
#define ll long long
using namespace std;
const int maxn = 1e5+5;
int vis[maxn],head[maxn],dis1[maxn],dis2[maxn];
struct edge
{
    int u,v,nxt;
}es[maxn*2];
vector<int> E;
int n,s,e,tot,maxd;
void add(int u,int v)
{
    es[++tot].u=u;
    es[tot].v=v;
    es[tot].nxt=head[u];
    head[u] = tot;
}
void bfs(int s,int d[])
{
    memset(vis,0,sizeof(vis));
    queue<int>q;
    q.push(s);
    vis[s] = 1;
    d[s] = 0;
    while(!q.empty())
    {
        int u = q.front();q.pop();
        for(int i=head[u];i!=-1;i=es[i].nxt)
        {
            int v =es[i].v;
            if(vis[v]) continue;
            d[v] = d[u]+1;
            maxd=max(maxd,d[v]);
            q.push(v);
            vis[v] = 1;
        }
    }
}
int main()
{
    ios::sync_with_stdio(0);
    memset(head,-1,sizeof(head));
    cin>>n>>s>>e;
    tot = -1;
    int u,v;
    for(int i=1;i<n;i++)
    {
        cin>>u>>v;
        add(u,v);
        add(v,u);
    }
    bfs(s,dis2);  //Εά
    maxd = 0;
    bfs(e,dis1);  //Χ·
    int ans = 0;
    for(int i=1;i<=n;i++)
    {
        if(dis2[i]<dis1[i])
        {
            ans = max(ans,dis1[i]-1);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4224
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
       long sum = 0;
        int max =Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;

    for(int i = 0; i < n; i++){
        int a = scan.nextInt();
             max = Math.max(max,a);
             min = Math.min(min,a);
             sum += a;
       
           }
System.out.println(min + " " + max + " " + sum);
    }
}


Measured memory_bytes: 41472
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int   //used int to avoid mle
#define ulli unsigned long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define spl set<pll>
#define msl multiset <lli>
#define msp multiset <pll>
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define fbo find_by_order //returns iterator
#define fok order_of_key //return index
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
lli mod=1000000007;
//string s=bitset<32>(n).to_string();
typedef tree<lli,null_type,less<lli>,rb_tree_tag, // change both to lli if set is req insted of multiset
tree_order_statistics_node_update> indexed_set;
int main()
{
     ios::sync_with_stdio(0);
    cin.tie(0);
      lli n;
        cin>>n;
        lli ar[n];
        for(lli i=0;i<n;i++)cin>>ar[i];
        lli ani=INT_MAX;
        for(lli i=1;i<=100;i++){
            lli cs=0;
            for(lli j=0;j<n;j++){
                cs+=(lli)pow(ar[j]-i,2);
            }
            ani=min(ani,cs);


        }
        cout<<ani;



}

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

#define IL inline 
IL int read() {
	char ch = getchar(); int u = 0, f = 1;
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { u = (u << 1) + (u << 3) + ch - 48; ch = getchar(); }
	return u * f; 
}

const int maxn = 5500;
int b[maxn][maxn], ss[maxn];
vector<pair<pair<int,int>, pair<int,int> > >opt;
IL void ok(int a, int b, int c, int d) {
	opt.push_back(make_pair(make_pair(a, b), make_pair(c, d)));
}
int main() {
	int h = read(), w = read();
	for (int i = 1; i <= h; ++i) for (int j = 1; j <= w; ++j) b[i][j] = read() & 1;
	for (int i = 1; i <= h; ++i) {
		int suc = 0; 
		for (int j = 1; j <= w - 1; ++j) {
			suc += b[i][j]; suc %= 2; if (suc) ok(i, j, i, j + 1);
		}
		ss[i] = (suc + b[i][w]) % 2;
	}	
	int s = 0;
	for (int i = 1; i < h; ++i) { (s += ss[i]) %= 2; if (s) ok(i, w, i + 1, w); }
	int ans = 0;
	cout << opt.size() << endl;
	for (int i = 0; i < opt.size(); ++i) {
		cout << opt[i].first.first << " " << opt[i].first.second << " " << opt[i].second.first << " " << opt[i].second.second << endl;
	}
	return 0;
}

Measured memory_bytes: 14960
#include <bits/stdc++.h>
using namespace std;
int ub(vector<int> &l, int lo, int hi, int x) {
	int ans = -1;
	while(lo <= hi) {
		int mi = (lo + hi) / 2;
		if(l[mi] < x) {
			ans = mi;
			lo = mi + 1;
		} else {
			hi = mi - 1;
		}
	}
	return ans;
}
int lb(vector<int> &l, int lo, int hi, int x) {
	int ans = hi + 1;
	while(lo <= hi) {
		int mi = (lo + hi) / 2;
		if(l[mi] > x) {
			ans = mi;
			hi = mi - 1;
		} else {
			lo = mi + 1;
		}
	}
	return ans;
}
int main() {
	int n;
	cin >> n;
	vector<int> l(n);
	for(int i = 0; i < n; i++)
		cin >> l[i];
	sort(l.begin(), l.end());
	long long cnt = 0;
	for(int a = 0; a < n; a++) {
		for(int b = a + 1; b < n; b++) {
			int c1 = ub(l, 0, n - 1, l[a] + l[b]);
			int c2 = lb(l, 0, n - 1, l[b] - l[a]);
			if(c1 != -1 && c2 != n) {
			//	cout << c1 << " " << c2 << " " << a << " " << b << endl;
				cnt += c1 - c2 + 1;
				if(a <= c1 && a >= c2)
				cnt--;
				if(b <= c1 && b >= c2)
				cnt--;
			//	cout << cnt << endl;
			}
		}
	}
	cout << cnt / 3;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
input = sys.stdin.readline
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False


def ans():
    n = onem()

    a = l()

    dp = [[0]*60 for j in range(n+1)]

    co = 0

    for i in range(1,n+1):
        kkk = a[i-1]
        for j in range(60):
            if j != 0:
                kkk = kkk // 2
            if kkk & 1:
                dp[i][j] = dp[i-1][j] + 1
            else:
                dp[i][j] = dp[i-1][j]

    two = [0 for i in range(61)]
    two[0] = 1
    for i in range(1,61):
        two[i] = (two[i-1]*2) % mod
        

    for i in range(1,n):
        for j in range(60):
            if dp[i][j] == dp[i-1][j]:
                ans = two[j]*(dp[-1][j]-dp[i][j])
                ans %= mod
                co += ans
                co %= mod
            else:
                ans = two[j]*(n-(i-1) - (dp[-1][j] - dp[i-1][j]))
                ans %= mod
                co += ans
                co %= mod

    print(co)

if __name__ == '__main__':
    ans()







Measured memory_bytes: 202256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        
        Arrays.sort(a);
        boolean[] boo = new boolean[a[n-1]+1];
        for(int i=0; i<a[n-1]+1; i++) {
            boo[i] = true;
        }
        
        int count = 0;
        for(int i=0; i<n; i++) {
            if(i>0) {
                if(a[i] == a[i-1] && boo[a[i]]) {
                    boo[a[i]] = false;
                    count--;
                    continue;
                }
            }
            if(boo[a[i]] == true) {
                int x = 2;
                while(a[i]*x <= a[n-1]) {
                    boo[a[i]*x] = false;
                    x++;
                }
                count++;
            } 
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 60924
#include <bits/stdc++.h>
using namespace std;
int N;
typedef long long ll;
typedef pair<ll,int> P;
int a[100005];
ll r[100005];
int main() {
    cin >> N;
    for(int i=0;i<N;i++) {
        cin >> a[i];
    }
    sort( a,a+N );
    for(int i=0;i<N;i++){
        r[i+1] = r[i] + a[i];
    }

    int res = 1;
    for(int i=N-1;i>0;i--){
        if( r[i]*2 < a[i] ) break;
        res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 1408
#include <stdint.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

const long long MOD = 998244353;

ll dp[3001][3001];

void solve(long long A, long long B, long long C, long long D) {
  dp[B][A] = 1;
  FOR(x, A + 1, C + 1) {
    dp[B][x] = dp[B][x - 1] * B;
    dp[B][x] %= MOD;
  }
  FOR(y, B + 1, D + 1) {
    dp[y][A] = dp[y - 1][A] * A;
    dp[y][A] %= MOD;
  }
  FOR(y, B + 1, D + 1) {
    FOR(x, A + 1, C + 1) {
      dp[y][x] = dp[y][x - 1] * y + dp[y - 1][x] * x - dp[y - 1][x - 1] * (x - 1) * (y - 1);
      dp[y][x] = (dp[y][x] % MOD + MOD) % MOD;
    }
  }
  cout << dp[D][C] << endl;
}

int main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  long long D;
  scanf("%lld", &D);
  solve(A, B, C, D);
  return 0;
}


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

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

	vector<int> h(N);
	int maxh = 0;
	for(int i=0; i<N; ++i){
		cin >> h[i];
		maxh = max(maxh, h[i]);
	}

	int ans = 0;
	for(int i=maxh; i>0; --i){
		for(int j=0; j<N; ++j){
			if(h[j] == i){
				--h[j];
				int r = j+1;
				while(r < N && h[r] == i){
					--h[r];
					++r;
				};
				++ans;
				j = r;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N, A, B;
    cin >> N >> A >> B;
    ll ans = (N/(A+B))*A;
    N = N%(A+B);
    ans += min(N,A);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define F first
#define S second
#define pi pair <ll, ll>
#define pii pair <pi, pi>
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T = 1;
	//cin >> T;
	while(T--){	
		ll a;
		ld b;
		cin >> a >> b;
		ld c = a * b;
		ll ans = floor(c);
		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
signed main(){
  ll k,n;
  cin >> k >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  for (ll i = 0; i < n; i++) {
    cin>>a[i];
  }
  for (ll i = 0; i < n - 1; i++) {
    b[i] = a[i + 1] - a[i];
  }
  b[n - 1] = k + a[0] - a[n - 1];
  sort(b.rbegin(),b.rend());
  cout << k - b[0] << "\n";
  return 0;
}

Measured memory_bytes: 3328
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long int lli;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<pll> vop;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define REP(i,a,b) for( long long i=a;i<b;i++)
#define REPR(i,a,b) for(long long i=a;i>=b;i--)
#define adb(a) for(auto ii:a) cout << ii << " "; cout << endl
#define adp(a) for(auto ii:a) cout << ii.F << " " << ii.S << endl;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define endl "\n"
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define PI 3.14159265358979323846
const ll MAXN = 100007;
const ll p = 1000000007;
#define N 200003
#define INF INTMAX_MAX

struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1> {}(p.first);
        auto hash2 = hash<T2> {}(p.second);
        return hash1 ^ hash2;
    }
};

struct LessSecond
{
    template<typename T, typename U>
    bool operator()(const std::pair<T, U> &x, const std::pair<T, U> &y) const
    {
        return x.second < y.second;
    }
};


ll power(ll a, ll b, ll m) { ll ans = 1; a = a % m; while (b) { if (b & 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans; }

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

ll modInverse(ll a, ll m) { ll g = __gcd(a, m); return power(a, m - 2, m); }

bool cmp(const pll &a, const pll &b)
{
    if (a.F != b.F) {
        return a.F > b.F;
    }
    else
        return a.S < b.S;
}


// bool check(ll i, ll j)
// {
//     if (i >= 0 && i < n && j >= 0 && j < m && a[i][j] != '#')
//         return true;
//     return false;
// }

int main()
{


    fastIO;
    int test = 1;
    //cin >> test;
    while (test--)
    {
        ll n;
        cin >> n;
        if (n % 2 == 0 || n % 5 == 0) {
            cout << -1 << endl;
            return 0;
        }
        int ans = 1;
        ll t = 7;
        while (1)
        {
            if (t % n == 0)
                break;
            t = ((t * 10) + 7) % n;
            ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3624