akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

  vector<int> numbers(N);
  for (int i = 0; i < N; i++) cin >> numbers.at(i);

  int chain_count = 0;

  for (int i = 0; i < N; i++) {
    // 同値を skip
    while (i + 1 < N && numbers.at(i) == numbers.at(i + 1)) i++;

    if (i + 1 < N && numbers.at(i) < numbers.at(i + 1)) {
      // 増加している間は同値を skip
      while (i + 1 < N && numbers.at(i) <= numbers.at(i + 1)) i++;

    } else if (i + 1 < N && numbers.at(i) > numbers.at(i + 1)) {
      // 減少している間は同値を skip
      while (i + 1 < N && numbers.at(i) >= numbers.at(i + 1)) i++;
    }

    chain_count++;
  }

  cout << chain_count << endl;
}

Measured memory_bytes: 3736
#include <stdio.h>

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

    int num[n];
    int ans[n];

    for(i=0;i<n;i++)
    {
        scanf("%d",&s);
        num[i]=s;
    }

    for(i=0;i<n;i++)
    {
        ans[num[i]-1]=i+1;
    }

    for(i=0;i<n;i++)
    {
        printf("%d ",ans[i]);
    }

    return 0;

}

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

int min(int a, int b); 
  
// Returns value of Binomial Coefficient C(n, k) 
int nCr(int n, int k) 
{ 
    int C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (int i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (int j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 
  
// A utility function to return  
// minimum of two integers 
int min(int a, int b) 
{ 
    return (a < b) ? a : b; 
} 
  

int main()
{
  int n,m;
  cin>>n>>m;
  
  int x,y;
  x = nCr(n,2);
  y = nCr(m,2);
  
  cout<<x+y;
  
  return 0;
  
}
  
  


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ld = long double;
const ld eps = 1e-9;

int main() {
	long long int ans = 1e18;
	int N; cin >> N;
	vector<long long int>as(N);
	vector<long long int>sums(N + 1);
	for (int i = 0; i < N; ++i) {
		cin >> as[i];
		sums[i + 1] = sums[i] + as[i];
	}
	for (int i = 1; i < N; ++i) {
		ans = min(ans, abs(sums[N] - sums[i]*2));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
import sys
sys.setrecursionlimit(10**9)

H, W = map(int, input().split())
field = [input() for i in range(H)]
route_count_memory = [[-1] * W for i in range(H)]
route_count_memory[0][0] = 1

def get_route_count(i,j):
    result = 0
    if route_count_memory[i][j] != -1:
        return route_count_memory[i][j]
    if 0 <= i-1 < H and field[i-1][j] != '#':
        result += get_route_count(i-1, j)
    if 0 <= j-1 < W and field[i][j-1] != '#':
        result += get_route_count(i, j-1)
    route_count_memory[i][j] = result
    return result

print(get_route_count(H-1, W-1)%(10**9+7))


Measured memory_bytes: 168184
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int m = sc.nextInt();
			int n = sc.nextInt();
			int p;
			int max = 0;
			
			for(int i=0;i<m;i++){
				p = 0;
				for(int j=0;j<n;j++){
					p += sc.nextInt();
				}
				max = Math.max(max, p);
			}
			System.out.println(max);
		}
	}	
}

Measured memory_bytes: 20564
#include <bits/stdc++.h>
#include<string>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;
  
  int count = 0;
  for(int i = A; i <= B; i++){
    std::string C;
    C = std::to_string(i);
    if(C[0] == C[4] && C[1] == C[3] ){
      count ++;
    }
  }
  std::cout << count << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int r;
    cin >> r;
    cout << 3*r*r << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
	string s;
	while(cin>>s&&s!="#"){
		//board:ball=1,null=0
		int board[10][10]; rep(i,10)rep(j,10) board[i][j]=0;
		//getinfo
		int nowY=0,nowX=0,h=1,w=0,tmpw=0;
		for(int i=0;i<(int)s.size();i++){
			if(s[i]=='b'){
				board[nowY][nowX]=1;
				nowX++;
				tmpw++;
			}else if('1'<=s[i]&&s[i]<='9'){
				nowX+=s[i]-'0';
				tmpw+=s[i]-'0';
			}else if(s[i]=='/'){
				nowY++; nowX=0;
				if(!w) w=tmpw;
				h++;
			}
		}
		//rep(i,h)rep(j,w) cout<<board[i][j];
		//swap
		int a,b,c,d; cin>>a>>b>>c>>d;
		a--; b--; c--; d--;
		board[a][b]=0; board[c][d]=1;
		//rep(i,h)rep(j,w) cout<<board[i][j];
		//print
		int cnt=0;
		for(int y=0;y<h;y++){
			for(int x=0;x<w;x++){
				if(board[y][x]){
					if(cnt) cout<<cnt;
					cnt=0;
					cout<<"b";
				}else{
					cnt++;
				}
			}
			if(cnt) cout<<cnt;
			cnt=0;
			if(y!=h-1) cout<<"/";
		}
		cout<<endl;
	}
	return 0;
}



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

typedef struct {
  long long start;
  long long end;
} time;

int compare(const void *a, const void *b)
{
  return ((time*)a)->start - ((time*)b)->start;
}

int main(void)
{
  int n, m;
  time work[100000];
  long long sum = 0;

  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++)
    scanf("%lld %lld", &work[i].start, &work[i].end);

  qsort(work, n, sizeof(time), compare);
  for (int i = 0; i < n; i++) {
    if (work[i].end < m) {
      sum += work[i].start * work[i].end;
      m -= work[i].end;
    } else {
      sum += work[i].start * m;
      break;
    }
  }
  printf("%lld\n", sum);
}
  


Measured memory_bytes: 3324
n=int(input())
sp=[]
for i in range(n):
    a=input().split()
    sp.append([a[0],int(a[1]),i+1])

l=[[] for i in range(n)]
from operator import itemgetter
sp.sort(key=itemgetter(1))
sp.reverse()
sp.sort(key=itemgetter(0))

for i in range(n):
    print(sp[i][2])

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		if ( N == 1) {
			System.out.println("Hello World");
		} else if ( N == 2 ) {
			int A = sc.nextInt();
			int B = sc.nextInt();
			System.out.println( A+B );
		}
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int n,a[101][101],f[101],k,edge,sum;
struct pp{
	int x;
	int y;
	int v;
}b[10001];
int getf(int u){
	if(u==f[u])return u;
	else return f[u]=getf(f[u]); 
}
int merge(int u,int v){
	int t1=getf(u);
	int t2=getf(v);
	if(t1!=t2){
		f[t2]=t1;
	} 
}
bool cmp(pp a,pp b){
	return a.v<b.v;
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)f[i]=i;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			scanf("%d",&a[i][j]);
			if(a[i][j]!=-1){
				b[k].v=a[i][j];
				b[k].x=i;b[k].y=j;
				k++;
			}
		}
	} 
	sort(b,b+k,cmp); 
//	for(int i=0;i<k;i++){
//		printf("%d %d %d\n",b[i].x,b[i].y,b[i].v);
//	}

	for(int i=0;i<k;i++){
		if(edge==n-1)break;
		if(getf(b[i].x)!=getf(b[i].y)){
			merge(b[i].x,b[i].y);
			sum+=b[i].v;edge++;
		}
	}
	printf("%d\n",sum);
	return 0;
} 


Measured memory_bytes: 3300
def slove():
    import sys
    input = sys.stdin.readline
    s = str(input().rstrip('\n'))
    mc = 0
    c = 1
    for i in range(1, len(s)):
        if s[i] == s[i-1]:
            c += 1
        else:
            c = 1
        mc = max(mc, c)
    print("Yes" if mc >= 3 else "No")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
const int INF = 1e9;
const int MXN = 1e5 + 5;
const int MXV = 0;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for (int i = L; i < (int)R; ++i)
#define FORD(i, L, R) for (int i = L; i > (int)R; --i)
#define IOS                                                                    \
    cin.tie(nullptr);                                                          \
    cout.tie(nullptr);                                                         \
    ios_base::sync_with_stdio(false);
int n;
int arr[MXN];
bool dp[MXN][2];

int dfs(int k,int p)
{
    if(dp[k][p]>0){
        return dp[k][p];
    }
    int ans = 0;
    FOR(i, 0, n) if (k - arr[i] >= 0) { ans |= !dfs(k - arr[i], !p); }
    return dp[k][p] = ans;
}

int main()
{
    IOS;
    int k;
    cin >> n >> k;
    FOR(i, 0, n) { cin >> arr[i]; }
    if (dfs(k, 0) == 0)
    {
        cout << "Second\n";
    }
    else
    {
        cout << "First\n";
    }
}


Measured memory_bytes: 8432
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
is_AC = [False]*N
WA_cnt = [0]*N

for _ in range(M):
    p, S = input().split()
    p = int(p)
    
    if S=='AC':
        is_AC[p-1] = True
    else:
        if not is_AC[p-1]:
            WA_cnt[p-1] += 1

AC = is_AC.count(True)
WA = 0

for i in range(N):
    if is_AC[i]:
        WA += WA_cnt[i]

print(AC, WA)

Measured memory_bytes: 42188
#include<bits/stdc++.h>
using namespace std;
int a[200000],b[200000],n;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a+1,a+n+1,greater<int>());
    for(int i=1;i<=n;i++){
        if(a[1]!=b[i]){
            cout<<a[1]<<endl;
        }else cout<<a[2]<<endl;
    }
    return 0;
}

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

int main(){
	int k,s;
	cin >> k >> s;

	int ans = 0;

	for (int x = 0; x <= k; x++ ){
		for (int y = 0; y <= k; y++){
			int z = s - x - y;
			if ( 0 <= z && z <= k ){
				ans = ans + 1;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long ;
ll const inf = 1e18;
int const nax = 3e5 + 10;

struct P {
    long long cost;
    int nod;
    int res;

    P () {}
    P (long long cost, int nod, int res) : cost(cost), nod (nod), res(res) {}

    bool operator < (const P &x) const {
        return cost > x.cost;
    }
};

struct edge {
    int to;
    int cost;
    int times;
};

bool vis1[55];
int n, m, s;
vector<edge> a[55];
long long dist[55];
long long dp[55][2505];


bool vis[55][2505];

int c[55], d[55];

int main ()  {

    scanf("%d %d %d", &n, &m, &s);

    for (int i = 1 ; i <= m;  ++ i) {
        int u, v, a, b;
        scanf("%d %d %d %d", &u, &v, &a, &b);
        ::a[u].push_back({v, a, b});
        ::a[v].push_back({u, a, b});
    }

    for (int i = 1 ; i <= n ; ++ i) {
        scanf("%d %d", c + i, d + i);
    }

    fprintf(stderr, "ANS\n");

    s = min(s, 2500);

    for (int i = 1 ; i <= n ; ++ i) {
        for (int j = 0 ; j <= 2500 ; ++ j) {
            dp[i][j] = inf;
        }
    }

    dp[1][s] = 0;

    priority_queue<P> q;
    q.push({0, 1, s});

    while (!q.empty()) {
        auto x = q.top();
        q.pop();

        if (vis[x.nod][x.res]) continue;
        vis[x.nod][x.res] = true;

        int to = min(x.res + c[x.nod], 2500);

        if (!vis[x.nod][to] && dp[x.nod][to] > dp[x.nod][x.res] + d[x.nod]) {
            dp[x.nod][to] = dp[x.nod][x.res] + d[x.nod];
            q.emplace(dp[x.nod][to], x.nod, to);
        }

        for (auto i : a[x.nod]) {
            if (x.res >= i.cost && dp[x.nod][x.res] + i.times < dp[i.to][x.res - i.cost]) {
                if (!vis[i.to][x.res - i.cost]) {
                    dp[i.to][x.res - i.cost] = dp[x.nod][x.res] + i.times;
                    q.emplace(dp[i.to][x.res - i.cost], i.to, x.res - i.cost);
                }
            }
        }
    }

    for (int i = 2 ; i <= n;  ++ i) {
        long long res = inf;

        for (int j = 0 ; j <= 2500 ; ++ j) {
            res = min(res, dp[i][j]);
        }

        printf("%lld\n", res);
    }


}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 6384
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>

int main()
{
    int x,m,j=0;
    scanf("%d %d",&x,&m);
    while(x)
    {
        x/=m;
        j++;
    }
    printf("%d\n",j);

    return 0;
}


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

int main() {
  
  string s;
  int a, b;
  cin >> s;
  
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == 'A'){
      a = i;
      break;
    }
  }
    
    for(int i = s.size()-1; i > 0; i--){
      if(s.at(i) == 'Z'){
        b = i;
        break;
      }
    }
  
  cout << b-a+1 <<endl;
    

      
  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
string S, T;

void input() {
  cin >> S;
  int x, y, z;
  ;
}
void solve() {
  cout << S[0] << S.size() - 2 << S[S.size() - 1] << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll dp[100001];
    memset(dp,0,sizeof(dp));
    ll n,w;
    cin>>n>>w;
    ll a,b;
    vector<ll> v;
    v.pb(0);
    for(ll i=0;i<n;i++){
        cin>>a>>b;
        ll maki=v.size();
        for(ll j=maki-1;j>=0;j--){
            if(v[j]+a<=w){
                dp[v[j]+a]=max(dp[v[j]+a],dp[v[j]]+b);
                v.pb(v[j]+a);
            }
        }
        sort(be(v));
        era(v);
    }
    ll ans=0;
    for(ll i=0;i<=100000;i++){
        ans=max(ans,dp[i]);
    }
    cout << ans<<endl;
    return 0;

}


Measured memory_bytes: 3188
def dfs(i, d):
    if i == N:
        if any(v == [] and k != 'X' for k, v in d.items()):
            return
        join_mp = (len(d['A']) - 1) * 10 + (len(d['B']) - 1) * 10 + (len(d['C']) - 1) * 10
        sinshoku_mp = abs(A - sum(d['A'])) + abs(B - sum(d['B'])) + abs(C - sum(d['C']))
        mp = join_mp + sinshoku_mp
        cand.append(mp)
        return
    d['A'].append(l[i])
    dfs(i+1, d)
    del d['A'][-1]
    d['B'].append(l[i])
    dfs(i+1, d)
    del d['B'][-1]
    d['C'].append(l[i])
    dfs(i+1, d)
    del d['C'][-1]
    d['X'].append(l[i])
    dfs(i+1, d)
    del d['X'][-1]

if __name__ == '__main__':
    cand = []
    N, A, B, C = map(int, input().split())
    l = []
    for _ in range(N):
        l.append(int(input()))

    a = {'A': [], 'B': [], 'C': [], 'X': []}
    dfs(0, a)
    print(min(cand))

Measured memory_bytes: 5012
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

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

	int cnt = 0;
	for (int v, i = 0; i < N; ++i) {
		cin >> v;
		cnt += v >= K;
	}

	cout << cnt;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define maxs 202020
#define mme(i,j) memset(i,j,sizeof(i))
#define ll long long
using namespace std;
int a[maxs];
const ll mod = 1e9+7;


ll qm(ll a,ll b)
{
    ll res=1,base=a;
    while(b)
    {
        if(b%2) res=(res*base)%mod;
        base = (base*base)%mod;
        b>>=1;
    }
    return res%mod;
}

map<int,int>mp;

int main()
{
    int n;
    //printf("%lld\n",qm(2,50000));
    while(~scanf("%d",&n)){
        bool fl=0;
        mp.clear();
        for(int i=0;i<n;i++){
            scanf("%d",&a[i]);
            mp[ a[i] ]++;
        }
        int pos =1;
       if(n%2){
            pos = 2;
            if(mp[0]!=1){
                fl=1;
            }
       }

       if(!fl){
            for(;pos<n;pos+=2){
                if(mp[pos]!=2)
                {
                    fl=1;
                    break;
                }
            }
       }

       if(fl)
        puts("0");
       else
        printf("%lld\n",qm(2,n/2)%mod);
    }
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define speedup ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
using namespace std;
void solve() {
  int x;
  cin>>x;
  cout<<!x<<endl;
}

int main()
{
    speedup;
    solve();
return 0;
}


Measured memory_bytes: 3576
main=map read.words<$>getLine>>=print.f
 where f x|(length(filter odd x))==2 =g [y+(if(odd y)then 1 else 0)|y<-x] 1
          |(length(filter odd x))==1 =g [y+(if(odd y)then 0 else 1)|y<-x] 1
          |otherwise                 =g x 0
       g x b =b+sum[quot((maximum x)-y)2|y<-x]

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <class T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

ll N, A, B;
vector<int> h;

bool isok(int x) {
    int rem = x;
    for (int i = 0; i < N && rem >= 0; ++i)
        if (h[i] > x * B)
            rem -= (h[i] - x * B + A - 1) / A;
    return rem >= 0;
}

int search() {
    int ok = 1e9, ng = 0;
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        (isok(mid) ? ok : ng) = mid;
    }
    return ok;
}

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

    cin >> N >> A >> B;
    A -= B;
    h.resize(N);

    for (int i = 0; i < N; ++i)
        cin >> h[i];
    sort(h.begin(), h.end());

    cout << search() << endl;
    return 0;
}


Measured memory_bytes: 640
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, X = lr()
L = np.array([0] + lr())
Lcum = L.cumsum()
i = np.searchsorted(Lcum, X, side='right')
print(i)
# 

Measured memory_bytes: 12508
n = int(input())
a = list(map(int, input().split()))

bunshi = 1
for i in a:
    bunshi *= i

bunbo = 0
for i in range(n):
    tmp = 1
    for j, x in enumerate(a):
        if j != i:
            tmp *= x
    bunbo += tmp

print(bunshi/bunbo)

Measured memory_bytes: 3060
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
   fast;
   #ifndef ONLINE_JUDGE
   freopen("goodluckin.txt","r",stdin);
   freopen("goodluckout.txt","w",stdout);
   #endif
   int a,b;
   cin >> a >> b;
   cout << a*b;
}


Measured memory_bytes: 3608
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)
	if (a == b && a != c) || (a == c && a != b) || (a != b && b == c) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int n,a,b,e,c,d,maxn,x[10000];
int main(){
	cin>>n>>a>>b>>e;maxn=e/a;c=e;d=a;
	for(int i=0;i<n;i++){cin>>x[i];}
	sort(x,x+n);
	for(int i=n-1;i>=0;i--){
		d+=b;c+=x[i];maxn=max(maxn,c/d);
	}
	cout<<maxn<<endl;
	return 0;
}

Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int[] a = new int[100];
        int[] b = new int[100];
        String c;
        int w = sc.nextInt();
        int n = sc.nextInt();

        for(int i=0; i<n; i++){
            c = sc.next();
            String[] str = c.split(",");
            a[i] = Integer.parseInt(str[0]) -1;
            b[i] = Integer.parseInt(str[1]) -1;
        }
        int[] num = new int[w];
        for(int i=0; i< w; i++){
            num[i] = i+1;
        }
        
        int tmp;
        
        for(int i=0; i<n; i++){
            
            tmp = num[a[i]];
            num[a[i]] = num[b[i]];
            num[b[i]] = tmp;
        }

        for(int i=0; i<w; i++){
            System.out.println(num[i]);
        }

        sc.close();
    }
}


Measured memory_bytes: 26308
import kotlin.String

fun main(args: Array<String>) {
    val n = readLong()

    if (n % 2 != 0L) {
        println(0)
        return
    }

    var ans = 0L
    var t = 10L
    while (t <= n) {
        ans += n / t
        t *= 5
    }
    println(ans)
}

// read
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 34540
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int N = int.Parse(ReadLine());

            int ans = int.MaxValue;
            for (int A = 1; A < N; A++)
            {
                ans = Min(sumFunc(A) + sumFunc(N - A), ans);
            }
            WriteLine(ans);
        }

        static int sumFunc(int i)
        {
            if (i < 10) return i;
            return sumFunc(i / 10) + i % 10;
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define Endl '\n'
typedef long long int lli;
void solve();
signed main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  solve();
}
void solve(){
  lli x;
  cin>>x;
  lli cur = 100;
  lli day = 0;
  while(cur<x){
    cur = cur + 0.01*cur;
    day++;
  }
  cout<<day<<Endl;
}


Measured memory_bytes: 3616
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int t; cin >> t;
  while (t--) {
    int n, d; cin >> n >> d;
    int ans = 127 * (n - 1);
    REP(_, n - 1) d ^= 127;
    cout << ans + d << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define max_n 1000000

using namespace std;

void solve()
{
	string s;
	cin >> s;
	ll n = 0;
	for (int i = 0; i < s.length(); ++i)
	{
		n += (s[i] - '0');
		n %= 9;
	}
	if (n)cout << "No" << endl;
	else cout << "Yes" << endl;
}

int32_t main()
{
	IOS
	ll T = 1;
	// cin >> T;
	for (ll i = 1; i <= T; ++i)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef vector < vector <int> > matrix;

const int mod = 1e9 + 7;
int n, x;
long long k;

matrix operator * (matrix a, matrix b){
	int n = (int)a.size();
	int m = (int)a[0].size();
	int k = (int)b[0].size();
	matrix res;
	res.resize(n);
	for(int i = 0; i < n; i++) res[i].resize(k);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			for(int ij = 0; ij < k; ij++){
				res[i][ij] = (1LL * res[i][ij] + 1LL * a[i][j] * b[j][ij] % mod) % mod;
			}
		}
	}
	return res;
}
matrix pw(matrix a, long long b){
	if(b == 1) return a;
	matrix res = pw(a, b / 2);
	if(b % 2 == 0) return res * res;
	else return res * res * a;
}

signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> k;
	vector < vector <int> > ret;
	for(int i = 0; i < n; i++){
		vector <int> p;
		p.clear();
		for(int j = 0; j < n; j++){
			cin >> x;
			p.pb(x);
		}
		ret.pb(p);
	}
	ret = pw(ret, k);
	int ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			ans = (ans + ret[i][j]) % mod;
		}
	}
	cout << ans;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <limits>
#include <utility>
#include <bitset>
#include <sstream>

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


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

	// s:初項
	// a_m = a_n

	int ans = 1;
	vector<int> a;
	a.push_back(s);
	int now = s;
	bool detect = false;
	while (!detect) {
		if (now % 2 == 0) now /= 2;
		else now = 3*now+1;
		
		ans += 1;
		
		for (int i = 0; i < a.size(); i++) {
			if (a[i] == now) detect = true;
		}
		a.push_back(now);
		
		
	}
	cout<<ans<<endl;

	return 0;
}

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

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

    int trend = 0;
    int res = 1;
    for (int i = 0; i<N - 1; i++) {
        if(trend == 1 && a[i] > a[i + 1]) {
            trend = 0;
            res++;
        } else if (trend == -1 && a[i] < a[i + 1]) {
            trend = 0;
            res++;           
        } 
        else if(trend == 0 && a[i] < a[i + 1]) trend = 1;
        else if(trend == 0 && a[i] > a[i + 1]) trend = -1;
    }
    cout << res << endl;
    return 0;
}

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

int main() {
  ll n,ans=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    if(i%3!=0&&i%5!=0){
      ans+=i;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
//#define DEBUG
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}

void solve(){
    int n , m;
    cin >> n >> m;
    vi acc(n + 1);
    for(int i = 0 ; i < m ; i++){
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        acc[l]++;
        acc[r+1]--;
    }
    int ans = 0;
    int num_gate = 0;
    for(int i = 0 ; i < n; i++){
        num_gate = num_gate + acc[i];
        if( num_gate == m){
            ans++;
        }
    }
    cout << ans << endl;
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}

//Thanks to CSES problemset
// I am trained with this kind of problem

Measured memory_bytes: 3712
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

int a[114514][3];

int main() {
	int n;
	cin >> n;
	int c[514], s[514], f[514];
	REP(i, n - 1)cin >> c[i] >> s[i] >> f[i];

	REP(i, n - 1) {
		int t = s[i] + c[i];
		FOR(j, i + 1, n - 1) {
			if (t <= s[j]) t = s[j] + c[j];
			else {
				t = ceil((double)t / (double)f[j]) * f[j] + c[j];
			}
		}
		cout << t << endl;
	}
	cout << 0 << endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<pair<int, int> > > vvp;
typedef vector<pair<int, int> > vp;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<vector<ll> > vvl;
typedef vector<ll> vl;
typedef vector<vector<bool> > vvb;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define mod (1e9+7)
#define inf (1e9+7)
#define nil -1
int main() {
	int n, max_;
	cin >> n >> max_;
	vi V(n);
	vi W(n);
	for (int i = 0; i < n; i++)
	{
		cin >> V[i];
		cin >> W[i];
	}
	vvi dp(n+1,vi(max_+1,0));
	for (int i = 1; i <= n; i++)
	{
		for (int r = 0; r <= max_; r++)
		{
			if (r >= W[i-1]) {
				dp[i][r] = max(dp[i-1][r],dp[i-1][r-W[i-1]]+V[i-1]);
			}
			else {
				dp[i][r] =dp[i - 1][r];
			}
		}
	}
	cout<<(dp[n][max_])<<endl;
}


Measured memory_bytes: 6764
a=[]
i=0
while 1:
    l=input().split()

    h=int(l[0])
    w=int(l[1])

    if h==0 and w==0:
        break
    else:
        a.append(h-2)
        a.append(w-2)
        i=i+2

m=0
while m<i:
    w=a[m+1]+2
    print(w*"#")
    while a[m]>0:
        print("#"+a[m+1]*"."+"#")
        a[m]=a[m]-1
    print(w*"#")
    print("")
    m=m+2


Measured memory_bytes: 5624
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define ll long long
#define int ll
using namespace std;

inline int read(){
	int sum=0,f=1;char c=getchar();
	while(c>'9'||c<'0'){if(c=='-') f=-1;c=getchar();}
	while(c<='9'&&c>='0'){sum=sum*10+c-'0';c=getchar();}
	return f*sum;
}

const int N=55;
const int M=N*N*N;
struct edge{int to,next;}e[N];
struct node{int v,w,id;}a[N];
int n,m,D;
int head[N],cnt;
int dp[M];

inline void add(int x,int y){
	e[++cnt]=(edge){head[x],y};head[x]=cnt;
}

inline bool cmp(node a,node b){return a.v*b.w>b.v*a.w;}

inline void dfs(int x){
	a[x].v=1;
	for(int i=head[x];i;i=e[i].to){
		int k=e[i].next;dfs(k);
		a[x].v+=a[k].v;a[x].w+=a[k].w;
	}
}

signed main(){
	n=read();m=read();D=read();
	int X=min(D,n),d=n*n*n;
	a[1].w=read();
	for(int i=2;i<=n;i++){
		a[i].w=read();int x=read();add(x,i);
	}
	for(int i=1;i<=n;i++) a[i].id=i;
	dfs(1);
	memset(dp,0x3f,sizeof(dp));	dp[0]=0;
	for(int i=1;i<=n;i++){
		int x=X;
		for(int j=0;(1<<j)<=x;j++){
			int v=a[i].v*(1<<j),w=a[i].w*(1<<j);
			for(int k=d;k>=v;k--) dp[k]=min(dp[k],dp[k-v]+w);
			x-=(1<<j);
		}
		if(x){
			int v=a[i].v*x,w=a[i].w*x;
			for(int k=d;k>=v;k--) dp[k]=min(dp[k],dp[k-v]+w);
		}
	}
	sort(a+1,a+n+1,cmp);
	while(a[n].id!=1) n--;
	int ans=0;
	for(int i=0;i<=d;i++){
		if(dp[i]>m) continue;
		int v=i,w=dp[i];
		for(int j=1;j<=n;j++){
			int c=min(j==n? 0x3f3f3f3f:D-X,(m-w)/a[j].w);
			v+=c*a[j].v,w+=c*a[j].w;
		}
		ans=max(ans,v);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1664
#d 
n=int(input())
x=input()

def popcount(m):
    return bin(m).count("1")

intx = int( "0b"+x ,0 )
popcount0 = x.count("1")

intx_mod_pp1 = intx %(popcount0+1)
if popcount0!=1:
    intx_mod_pm1 = intx %(popcount0-1)
    
jisho = ["yet"]*n
for i in range(n):
    if x[i]=="1" and popcount0==1:
        print(0)
        continue
    
    pow2ip = pow(2,n-i-1,popcount0+1)
    if popcount0!=1:   pow2im = pow(2,n-i-1,popcount0-1)
    
    intxi=1
    c=0
    while intxi!=0:
        if c==0:
            if x[i]=="0":
                pop = popcount0+1
                intxi = (intx_mod_pp1 + pow2ip%pop )%pop
            else:
                pop = popcount0-1
                intxi = (intx_mod_pm1 - pow2im%pop )%pop        
        else:
            if jisho[intxi]=="yet":
                togo = intxi%popcount(intxi)
                jisho[intxi]= togo
                intxi = togo
            else:
                intxi =jisho[intxi]
        c+=1
    print(c)

Measured memory_bytes: 88200
#include <iostream>
#include<string>
#include<vector>
using namespace std;
int main (){
    int n,k,cnt=0;
    char w;

string data;
cin>>n;
cin>>data;
cin>>k;

w=data[k-1];

for(;n>0;n--){
    if(w==data[cnt]){
        cout<<w<<flush;
    }
    else{
            cout<<"*"<<flush;
        }
        cnt++;

}
return(0);
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

template <class T>
using priority_queue_with_greater = std::priority_queue<T, std::vector<T>, std::greater<T>>;

priority_queue_with_greater<ll> pq;
priority_queue<ll> pq2;

ll vs[300100], A[300100];

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

    int N;
    std::cin >> N;

    for(int i=0;i<3*N;++i){
        std::cin >> A[i];
    }

    {
        ll sum = 0ll;
        for(int i=0;i<N;++i){
            sum += A[i];
            pq.emplace(A[i]);
        }

        for(int i=N;i<=2*N;++i){
            vs[i] = sum;

            sum += A[i];
            pq.emplace(A[i]);
            ll x = pq.top();
            sum -= x;
            pq.pop();
        }
    }

    {
        ll sum = 0ll;
        for(int i=3*N-1;i>=2*N;--i){
            sum += A[i];
            pq2.emplace(A[i]);
        }

        vs[2*N] -= sum;
        for(int i=2*N-1;i>=N;--i){
            sum += A[i];
            pq2.emplace(A[i]);
            ll x = pq2.top();
            sum -= x;
            pq2.pop();

            vs[i] -= sum;
        }
    }

    // for(int i=N;i<=2*N;++i){
    //     std::cout << vs[i] << " \n"[i == 2*N];
    // }
    
    ll res = -1001001001001001001ll;
    for(int i=N;i<=2*N;++i){
        res = max(res, vs[i]);
    }

    std::cout << res << std::endl;
}


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

void Main()
{
  int R;
  cin >> R;
  cout << 2.0 * acos(-1) * R << endl;
}

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


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

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H.at(i);
  vector<int> DP(N, 2e9);
  DP.at(0) = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 1; j <= 2; j++) {
      if (i + j < N) DP.at(i + j) = min(DP.at(i + j), DP.at(i) + abs(H.at(i) - H.at(i + j)));
    }
  }
  cout << DP.at(N - 1) << "\n";
}

Measured memory_bytes: 4040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner src = new Scanner(System.in);
		int n = src.nextInt();

		int a[] = new int[n];

		for (int i = 0; i < n; i++) {
			int m = src.nextInt();
			a[i] = m;
		}
		int time = 0, p = 0;
		for (int i = 0; i < n - 1; i++) {
			if (a[i] >= a[i + 1]) {
				p++;
			}
			if (time <= p) {
				time = p;
			}
			if (a[i] < a[i + 1]) {

				p = 0;
			}
		}
		System.out.println(time);
	}
}


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

#define gc( ) std::getchar( )
#define pc( i ) std::putchar( i )
#define RE cout << "Passing [" << __FUNCTION__ << "] on " << __LINE__ << '\n'
#define DEBUG(...) for( auto &i: __VA_ARGS__ ) cout << i << " "; cout << '\n'
#define space ' '
#define enter '\n'
using std::make_pair;

template < typename T >
inline T read( )
{
 register T x = 0;
 register char ch = gc( );
 register bool f = 0;
 while( !std::isdigit( ch ) )
 {
  f = ( ch == '-' );
  ch = gc( );
 }
 while( std::isdigit( ch ) )
 {
  x = x * 10 + ( ch - '0' );
  ch = gc( );
 }
 return f ? -x : x;
}

template < typename T >
void print( T x )
{
 if( x < 0 )
 {
  x = -x;
  pc( '-' );
 }
 if( x < 10 )
 {
  pc( x + 48 );
  return;
 }
 print < T > ( x / 10 );
 pc( x % 10 + 48 );
 return ;
}

namespace Solution
{
#define IOS std::ios::sync_with_stdio( false ), std::cin.tie( 0 ), std::cout.tie( 0 )
#define Rep( i, j, k ) for( int i = j; i >= k; --i )
#define rdi( ) read < int > ( )
#define rdl( ) read < long long > ( )
#define pti( i ) print < int > ( i ), putchar( space )
#define ptl( i ) print < long long > ( i ), putchar( space )
#define For( i, j, k ) for( int i = j; i <= k; ++i )
 using std::cin;
 using std::cout;
 using std::endl;
 using std::vector;
 using std::map;
 using std::queue;
 using std::deque;
 using std::set;
 using std::pair;
 const int Maxn = 4001, mod = 1e9 + 7;
 long long n, k, ans, dp[ Maxn ];
 vector < int > a;
 long long POW( long long u, long long U )
 {
  long long res = 1;
  while( U )
  {
   if( U & 1 )
    res = res * u % mod;
   u = u * u % mod;
   U >>= 1;
  }
  return res;
 }
 void Fakemain( )
 {
  IOS;
  cin >> n >> k;
  int ___ = sqrt( n );
  For( i, 1, ___ )
   if( !( n % i ) )
   {
    a.push_back( i );
    if( i != n / i )
     a.push_back( n / i );
   }
  std::sort( a.begin( ), a.end( ), std::less < int > ( ) );
  for( int i = 0; i < ( int ) a.size( ); ++i )
  {
   dp[ i ] = POW( k, ( a[ i ] + 1 ) / 2 );
   for( int j = 0; j < i; ++j )
    if( a[ i ] % a[ j ] == 0 )
     dp[ i ] = ( dp[ i ] - dp[ j ] + mod ) % mod;
   if( a[ i ] & 1 )
    ans = ( ans + dp[ i ] * a[ i ] ) % mod;
   else
    ans = ( ans + dp[ i ] * a[ i ] / 2 ) % mod;
  }
  cout << ans;
  return;
 }

} // namespace Solution

int main( int argc, char* argv[] )
{
 Solution::Fakemain( );
 return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

struct SegmentTree {
	std::vector<i64> seg;
	int sz = 1;
	
	SegmentTree(int n) {
		while(sz < n) sz <<= 1;
		seg.assign(sz * 2, 0);
	}
	void set(int k, i64 x) {
		k += sz;
		if(seg[k] >= x) return;
		seg[k] = x;
		
		while(k >>= 1) seg[k] = std::max(seg[2 * k + 0], seg[2 * k + 1]);
	}
	i64 get(int a, int b) {
		i64 L = 0, R = 0;
		for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if(a & 1) L = std::max(L, seg[a++]);
			if(b & 1) R = std::max(seg[--b], R);
		}
		return std::max(L, R);
	}
	i64 operator[](int k) {
		return seg[k + sz];
	}
};

int main() {
	int n; scanf("%d", &n); std::vector<i64> h(n), a(n);
	for(int i = 0; i < n; i++) scanf("%d", &h[i]);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);
	
	SegmentTree dp(n + 1);
	for(int i = 0; i < n; i++) {
		i64 tmp = dp.get(0, h[i]);
		dp.set(h[i], tmp + a[i]);
	}
	printf("%lld\n", dp.get(0, n + 1));
	return 0;
}


Measured memory_bytes: 7424
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import sys


def chk(s):
  for c in s:
    if c not in ['A','T','G','C']:
      return False
  return True

def solve(s):
  ret = ""
  for i in range(len(s)):
    for j in range(i+1,len(s)+1):
      if chk(s[i:j]) and len(ret) < len(s[i:j]):
        ret = s[i:j]
  return ret

S = str(input())
print(len(solve(S)))


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;
//clang++ -std=c++11 -stdlib=libc++ 
int H,W; 
vector<string> maze;
int ans =0;
int L[2001][2001];
int R[2001][2001];
int D[2001][2001];
int U[2001][2001];
void dfs(int h, int r) {
  int cnt = L[h][r]+R[h][r]+U[h][r]+D[h][r]-3;
  ans = max(ans, cnt);
}

int main() {
  cin >>H>>W;
  maze.resize(H);
  rep(i,H) cin>>maze[i];
  rep(i, H) rep(j,W) {
    if(maze[i][j]=='#') L[i][j]=R[i][j]=U[i][j]=D[i][j]=0;
    else {
      if (j==0) L[i][j] = 1;
      else L[i][j]=L[i][j-1]+1;
      if(i==0) U[i][j]=1;
      else U[i][j]=U[i-1][j]+1;
    }
  }
    for(int i=H-1; i>=0; i--) for (int j=W-1; j>=0;j--) {
    if(maze[i][j]=='#') L[i][j]=R[i][j]=U[i][j]=D[i][j]=0;
    else {
       if(j==W-1) R[i][j]=1;
      else R[i][j] = R[i][j+1]+1;
      if(i==H-1) D[i][j]=1;
      else D[i][j]=D[i+1][j]+1;
    }
  }

 
   rep(i, H) rep(j,W) {
    if (maze[i][j] == '.') {
     dfs(i,j);
    }
  }
 cout << ans << endl;
  return 0;
}

Measured memory_bytes: 66944
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vvi g;
vi a,b;
vvi c;

void dfs(int v,int p,int t){
	a[v]=t;
	for(auto u:g[v]) if(u!=p) dfs(u,v,1-t);
}

int main(){
	cin>>n;
	g=vvi(n);
	a=b=vi(n);
	c=vvi(3);
	for(int i=1;i<=n;i++) c[i%3].push_back(i);
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(0,-1,0);
	int t=0;
	for(auto i:a) t+=i;
	if(t<=n/3||n-t<=n/3){
		int I=0;
		set<int> st;
		int tmp=(t<=n/3?1:0);
		for(int i=0;i<n;i++) if(tmp==a[i]){
			b[i]=c[0][I++];
			st.insert(b[i]);
		}
		I=1;
		for(int i=0;i<n;i++) if(!b[i]){
			while(st.find(I)!=st.end()) I++;
			b[i]=I;
			I++;
		}
	}
	else{
		int I=0,J=0;
		set<int> st;
		for(int i=0;i<n;i++){
			if(a[i]&&I<c[1].size()){
				b[i]=c[1][I++];
				st.insert(b[i]);
			}
			if(!a[i]&&J<c[2].size()){
				b[i]=c[2][J++];
				st.insert(b[i]);
			}
		}
		I=1;
		for(int i=0;i<n;i++) if(!b[i]){
			while(st.find(I)!=st.end()) I++;
			b[i]=I;
			I++;
		}
	}
	for(int i=0;i<n;i++) cout<<b[i]<<" \n"[i==n-1];
}

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

int main() {
  int N;
  cin >> N;
  set<int> SE;
  SE.insert(1);
  for (int i = 2; i * i < N; i++) {
    for (int j = i; j <= N; j *= i) {
      SE.insert(j);
    }
  }
  for (int i = N; i >= 1; i--) {
    if (SE.count(i)) return cout << i << "\n", 0;
  }
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool f[15][15];
int main(){
	ll n,m,k[15],s[15][15],p[15];
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>k[i];
		for(int j=0;j<k[i];j++)cin>>s[i][j];
	}
	for(int i=0;i<m;i++)cin>>p[i];
	ll ans=0;

	for(int i=0;i<(1ll<<n);i++){
		ll yojo=0;
		for(int j=0;j<m;j++){
			ll cnt=0;
			for(int l=0;l<k[j];l++){
				ll num=1ll<<(s[j][l]-1);
				if(i&num)cnt++;
			}
			if(cnt%2==p[j])yojo++;
		}
		if(yojo==m)ans++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    map<string, int> mpa, mpb;
    int n, m;
    cin >> n;
    rep(i, n){
        string s;
        cin >> s;
        mpa[s]++;
    }
    cin >> m;
    rep(i, m){
        string t;
        cin >> t;
        mpb[t]++;
    }

    int ans = 0;
    for(auto e:mpa){
        ans = max(e.second - mpb[e.first], ans);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3652
"""
N = int(input())
N,M = map(int,input().split())
N_list = list(map(int,input().split()))
"""

N = int(input())
H = list(map(int,input().split()))

cnt = 0
max_cnt = 0
pre_num = H[0]
for i in range(1,len(H)):
  _ = H[i]
  
  if _ <= pre_num:
    cnt += 1
  else:
    cnt = 0
    
  pre_num = _
  max_cnt = max(max_cnt,cnt)
  
    
print(max_cnt)

Measured memory_bytes: 15020
#include <bits/stdc++.h>
#define ll long long
using namespace std;
long long fpb(long long x, long long y) { 
    return (y == 0) ? x : fpb(y, x % y); 
}
long long kpk(long long x, long long y) { 
    return x * (y / fpb(x, y)); 
}
bool cmp(long long a,long long b)
{
    return a>b;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    vector <char> ans;
    char temp;
    while(n>0){
        n--;
        temp='a'+n%26;
        //cout<<temp<<endl;
        ans.push_back(temp);
        n/=26;
    }
    reverse(ans.begin(),ans.end());
    for(int i=0;i<ans.size();i++){
        cout<<ans[i];
    }
    cout<<endl;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
using itn = int;
template<class T>
using vec = vector<T>;

#define FOR(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define all(x) (x).begin(),(x).end()

int main(){
  vec< vec<int> > c(3,vec<int>(3));
  REP(i,3){
    REP(j,3){
      cin >>c[i][j];
    }
  }

  itn ansj=0;
  FOR(i,-100,101){
    int z=0;
    REP(j,3){
      if(c[j][0]+i == c[j][1]) ++z;
    }
    if(z == 3) ansj = 1;
  }
  if(ansj == 1){
    FOR(i,-100,101){
      int z=0;
      REP(j,3){
        if(c[j][1]+i == c[j][2]) ++z;
      }
      if(z == 3) ansj = 2;
    }
  }

  if(ansj == 2){
    cout <<"Yes" <<endl;
  }else{
    cout <<"No" <<endl;
  }
}


Measured memory_bytes: 256