akhauriyash/Code-Regression huggingface dataset:
def resolve():
    '''
    code here
    '''
    N = int(input())
    S = input()

    W_list = [0 for _ in range(N)]
    E_list = [0 for _ in range(N)]
    
    for i, s in enumerate(S):
        if i == 0:
            if s == 'W':
                W_list[i] = 1
        else:
            W_list[i] = W_list[i-1]
            if s == 'W':
                W_list[i] += 1

        
    for i, s in enumerate(S[::-1]):
        if i == 0:
            if s == 'E':
                E_list[i] = 1
        else:
            E_list[i] = E_list[i-1]
            if s == 'E':
                E_list[i] += 1
    
    E_list = E_list[::-1]

    sum_list = []
    for i in range(N):
        sum_list.append(E_list[i] + W_list[i])

    res = min(sum_list) -1
    print(res)


if __name__ == "__main__":
    resolve()


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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    ll a, b, c; cin >> a >> b >> c;
    ll k; cin >> k;
    if (abs(a - b) > pow(10, 18)) { 
        cout << "Unfair" << endl;
        return 0;
    }
    if (k % 2 == 0) cout << a - b << endl;
    else cout << b - a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define ss second
#define ff first
#define pii pair<int,int> 
#define mp make_pair()
#define ll long long
int main(){
	io
 	int n;
  	cin>>n;
  	vector<ll int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  ll int x=0;
  for(int i=0;i<n;i++){
  	if(i%2) x-=a[i];
    else x+=a[i];
  }
  vector<ll int> ans(n);
  ans[0]=x;
  for(int i=1;i<n;i++){
  	ans[i]=2*a[i-1]-ans[i-1];
  }
  for(int i=0;i<n;i++) cout<<ans[i]<<" ";
  	
}

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

using namespace std;

const int N = 1e5 + 10;

int dp[N];
int nums[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> nums[i];
	dp[1] = 0;
	dp[2] = abs(nums[1] - nums[2]);
	for(int i = 3; i <= n; i++) {
		dp[i] = 1e9 + 10;
		for(int j = i-1; j >= max(1, i - k); j--)
			dp[i] = min(dp[i], dp[j] + abs(nums[i] - nums[j]));
	}
	cout << dp[n] << "\n";
	return 0;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
P = [0 for _ in range(N+1)]
S = [0 for _ in range(N+1)]

for _ in range(M):
    p, s = input().split()
    p = int(p)
    if s == 'WA' and S[p] == 0:
        P[p] += 1
    elif s == 'AC' and S[p] == 0:
        S[p] = 1

for i in range(N+1):
    if S[i] == 0 and P[i] > 0:
      P[i] = 0
        
print(sum(S), sum(P))


Measured memory_bytes: 4756
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
/*bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}*/

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

const ll mod = 1e9 + 7;
const ll IMF = 1LL<<29;
const double PI = 3.14159265358979323846;


// ***************************CODE**********************//



int main(){


        
        int x,y,z,k;
        cin >> x >> y >> z >> k;

        vector<ll> a(x) , b(y) , c(z);
        rep(i,x) cin >> a[i];
        rep(i,y) cin >> b[i];
        rep(i,z) cin >> c[i];


        vector<ll> ab;
        for(int i = 0; i < x; i++){
                for(int j = 0; j < y; j++){
                        ab.push_back(a[i] + b[j]);
                }
        }

        sort(all(ab));
        reverse(all(ab));

        vector<ll> abc;
        
        for(int i = 0; i < min(k, (int)ab.size()); i++){
                for(int j = 0; j < z; j++){
                        abc.push_back(ab[i]+c[j]);
                }
        }

        sort(all(abc));
        reverse(all(abc));
        

        for(int i = 0; i < k; i++){
                cout << abc[i] << endl;
        }
        return 0;

}


Measured memory_bytes: 43368
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

template<class T> inline bool chmin(T& a, T b){ if(a>b){a=b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b){ if(a<b){a=b; return 1;} return 0;}

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__


void solve(void){
  
  ll K, N;
  cin >> K >> N;
  
  vector<ll> A(N), D(N);
  
  ll sum=0;
  
  REP(i,N){
    cin >> A[i];
    if(i>0){
      D[i-1]=A[i]-A[i-1];
      sum += D[i-1];
    }
  }
  D[N-1]=K-A[N-1]+A[0];
  sum += D[N-1];
  
  sort(ALL(D),greater<ll>());
  
  sum -= D[0];
  
  cout << sum << endl;
  
  return;
   
}

#define TESTCASES 1

int main(int argc, const char * argv[]) {


    cin.tie(0);
    ios::sync_with_stdio(false);

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}


Measured memory_bytes: 3456
using System;

class AtCoder
{
    static int Solve(string s)
    {
        int aIndex = -1;
        int zIndex = -1;
        int i = 0;

        foreach (char c in s)
        {
            if (c == 'A' && aIndex == -1)
            {
                aIndex = i;
            }
            else if (c == 'Z')
            {
                zIndex = i;
            }
            ++i;
        }
        
        return (zIndex - aIndex) + 1;
    }

    static void Main()
    {
        string s = Console.ReadLine();
        int answer = Solve(s);
        Console.WriteLine(answer);
    }
}

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

int main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	
	char c[30]={0};int i=0;
	while(cin>>c[i++]);
	for(int j=0;j<i-1;j++){
		cout<<c[i-2-j];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3040
import java.util.*; 
 
class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int r=sc.nextInt();
        int d=sc.nextInt();
		int x=sc.nextInt();
  		
		for(int c=0;c<10;c++){
          x=x*r-d;
          System.out.println(x);
    	}
 
    	
    }
}


Measured memory_bytes: 23636
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
typedef long long ll;

const int N   = 200;
const ll inf =(1LL<<58);

ll land[N][N];
ll sea[N][N];

void wf(int n,ll mat[N][N]){
  rep(k,n)rep(i,n)rep(j,n)mat[i][j]=min(mat[i][j],mat[i][k]+mat[k][j]);
}


ll dp[1000][N];
ll solve(int n,vector<int> &in,int s){
  wf(n,land);
  wf(n,sea);
  rep(i,in.size())rep(j,n)dp[i][j]=inf;
//   rep(i,n){
//     rep(j,n){
//       dp[0][j]=min(dp[0][j],land[s][i]+sea[i][j]+land[j][in[0]]);
//       cout << dp[0][j] << endl;
//     }
//   }

  dp[0][s]=0;

  REP(i,1,in.size()){
    rep(j,n){
      rep(k,n){
	dp[i][k]=min(dp[i][k],
		     dp[i-1][j]+land[in[i-1]][j]+sea[j][k]+land[k][in[i]]);
      }
      dp[i][j]=min(dp[i][j],dp[i-1][j]+land[in[i-1]][in[i]]);
    }
  }

  ll ret = inf;
  rep(i,n)ret=min(ret,dp[in.size()-1][i]);
  return ret;
}

main(){
  int n,m;
  while(cin>>n>>m && n){
    rep(i,n){
      rep(j,n)sea[i][j]=land[i][j]=inf;
      sea[i][i]=0;land[i][i]=0;
    }
    rep(i,m){
      int f,t;ll c;char tmp;
      cin>>f>>t>>c>>tmp;
      f--;t--;
      if (tmp == 'L')land[f][t]=land[t][f]=min(land[t][f],c);
      if (tmp == 'S')sea[f][t] =sea[t][f] =min( sea[t][f],c);
    }


    int q;
    cin>>q;
    vector<int> in(q);
    rep(i,q)cin>>in[i],in[i]--;
    cout << solve(n,in,in[0]) << endl;
  }
  return false;
}

Measured memory_bytes: 3100
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def root(x):
        if par[x] == x:
            return x
        par[x] = root(par[x])
        return par[x]
    def unite(x,y):
        x = root(x)
        y = root(y)
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1
    n,m = LI()
    par = [i for i in range(n)]
    rank = [0]*n
    for i in range(m):
        x,y,z = LI()
        x -= 1
        y -= 1
        if root(x) != root(y):
            unite(x,y)
    s = set([root(i) for i in range(n)])
    print(len(s))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 82592
n, m = map(int,input().split())
ans = ['*'] * n
flag = False
for _ in range(m):
    s, c = map(int,input().split())
    if s > n:
        flag = True
        continue
    if s == 1 and c == 0:
        if n > 1:
            flag = True
    if ans[int(s)-1] == '*':
        ans[int(s)-1] = str(c)
    elif ans[int(s)-1] != str(c):
        flag = True
if flag:
    print(-1)
    exit()

for i in range(n):
    if ans[i] == '*':
        if i == 0:
            if n == 1:
                ans[i] = '0'
            else:
                ans[i] = '1'
        else:
            ans[i] = '0'

ans = ''.join(ans)
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200) cout << s << endl;
    else cout << "red" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e7+7;
const int maxm = 5e3+7;
const ll mod = 1e9 + 7;
#define afdafafafdafaf y1;
int ar[1000000], n, m;
int main()
{
    scanf("%d", &n);
    if(n & 1){
        printf("%d\n", n / 2);
    }
    else{
        printf("%d\n", n / 2 - 1);
    }
    return 0;
}


Measured memory_bytes: 256
//abc119_c.cpp
//Sun Mar 10 15:21:00 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;
int l[8];
int n,A,B,C;

int dfs(int x, int a, int b, int c){
	if (x == n){
		if (min({a,b,c})>0){
			return abs(a-A)+abs(b-B)+abs(c-C)-30;
		}else {
			return 100000000;
		}
	}
	int ret0 = dfs(x+1,a,b,c);
	int ret1 = dfs(x+1,a+l[x],b,c)+10;
	int ret2 = dfs(x+1,a,b+l[x],c)+10;
	int ret3 = dfs(x+1,a,b,c+l[x])+10;
	return min({ret0,ret1,ret2,ret3});
}


int main(){
	cin >> n >> A >> B >> C;

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

	int ans = dfs(0,0,0,0);
	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

using namespace std;

typedef long long ll;

int t;

ll a, b, c, d;

map <ll, ll> mp;

void f (ll n)
{
    if(mp.find(n) != mp.end())
        return;
    f(n / 2);
    if((n + 1) / 2 < n)
        f((n + 1) / 2);
    f(n / 3);
    if((n + 2) / 3 < n)
        f((n + 2) / 3);
    f(n / 5);
    if((n + 4) / 5 < n)
        f((n + 4) / 5);
    ll ans = LLONG_MAX;
    if(LLONG_MAX / d >= n)
        ans = n * d;
    ans = min(ans, mp[n / 2] + a + abs(n - n / 2 * 2) * d);
    ans = min(ans, mp[(n + 1) / 2] + a + abs(n - (n + 1) / 2 * 2) * d);
    ans = min(ans, mp[n / 3] + b + abs(n - n / 3 * 3) * d);
    ans = min(ans, mp[(n + 2) / 3] + b + abs(n - (n + 2) / 3 * 3) * d);
    ans = min(ans, mp[n / 5] + c + abs(n - n / 5 * 5) * d);
    ans = min(ans, mp[(n + 4) / 5] + c + abs(n - (n + 4) / 5 * 5) * d);
    mp[n] = ans;
}

ll n;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> t;
    while(t--)
    {
        cin >> n >> a >> b >> c >> d;
        mp.clear();
        mp[0] = 0;
        f(n);
        cout << mp[n] << "\n";
    }
    return 0;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int calc(double rate, int notax){
    double temp = notax;
    double tax = 1.0 + (rate/100);
    int ret = (int) temp*tax - notax;
    return (int) ret;
}

int main(void){
    int A, B; cin >> A >> B;
    int ans = -1;
    rep(i, 10000){
        if(calc(8.0, i) == A && calc(10.0, i) == B) {ans = i; break;}
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  vector<int> a,b;
  for(int i = 0; i < n; ++i){
    int x,y; cin >> x >> y;
    a.push_back(x+y);
    b.push_back(x+(1000000000-y));
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  cout << max(a.back() - a.front(), b.back() - b.front()) << endl;
  return 0;
}


Measured memory_bytes: 5076
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;
	template<class T>using pair = std::pair<T, T>;

	struct max_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	constexpr max_t max;
	constexpr min_t min;

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
	
	template<class T>constexpr T pow(T val, std::uint64_t p)
	{
		auto ret = T(1);
		auto s = 1ULL;
		for (auto i = 0; i < 63; ++i, s <<= 1)
		{
			if (p & s)
			{
				ret *= val;
			}
			val *= val;
		}
		return ret;
	}
	template<class Range>void sort(Range& rng)
	{
		std::sort(std::begin(rng), std::end(rng));
	}
	template<class Range, class Pred>void sort(Range& rng, Pred pred)
	{
		std::sort(std::begin(rng), std::end(rng), pred);
	}
}

void Main()
{
	std::size_t H, W;
	std::cin >> H >> W;
	int cx, cy, dx, dy;
	std::cin >> cx >> cy >> dx >> dy;
	--cx; --cy;
	--dx; --dy;
	boost::multi_array<bool, 2> field(boost::extents[H][W]);
	for (auto i : boost::irange(H))
	{
		for (auto j : boost::irange(W))
		{
			char c;
			std::cin >> c;
			field[i][j] = c == '.';
		}
	}
	boost::multi_array<std::optional<int>, 2> dp(boost::extents[H][W]);
	std::deque<std::tuple<int, int, int>> queue;
	queue.emplace_back(cx, cy, 0);
	while (queue.size())
	{
		auto [x, y, s] = queue.front();
		queue.pop_front();
		if (dp[x][y])
		{
			continue;
		}
		dp[x][y] = s;
		if (0 <= x - 1 && field[x - 1][y])
		{
			queue.emplace_front(x - 1, y, s);
		}
		if (0 <= y - 1 && field[x][y - 1])
		{
			queue.emplace_front(x, y - 1, s);
		}
		if (x + 1 < H && field[x + 1][y])
		{
			queue.emplace_front(x + 1, y, s);
		}
		if (y + 1 < W && field[x][y + 1])
		{
			queue.emplace_front(x, y + 1, s);
		}
		for (auto i : boost::irange(-2, 3))
		{
			for (auto j : boost::irange(-2, 3))
			{
				if (i == 0 && j == 0)
				{
					continue;
				}
				auto a = x + i;
				auto b = y + j;
				if (0 <= a && a < H && 0 <= b && b < W && field[a][b])
				{
					queue.emplace_back(a, b, s + 1);
				}
			}
		}
	}
	std::cout << dp[dx][dy].value_or(-1) << std::endl;
}

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

Measured memory_bytes: 13768
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    string N;
    cin >> N;
    int L = (int)N.size();
    reverse(N.begin(), N.end());

    vector<vector<int>> minPaper(L + 1, vector<int>(2, 1e9));
    minPaper[0][0] = 0;

    for(int i = 0; i < L; i++){
        char c = N[i];
        int temp = c - '0';
        if(temp == 0){
            int temp1 = minPaper[i][0] + temp;
            int temp2 = minPaper[i][1] + temp;
            minPaper[i + 1][0] = min(temp1, temp2);
            int temp4 = minPaper[i][1] + (10 - temp) - 1;
            minPaper[i + 1][1] = temp4;
        }
        else if(temp == 9){
            int temp1 = minPaper[i][0] + temp;
            minPaper[i + 1][0] = temp1;
            int temp3 = minPaper[i][0] + (10 - temp) + 1;
            int temp4 = minPaper[i][1] + (10 - temp) - 1;
            minPaper[i + 1][1] = min(temp3, temp4);
        }
        else{
            int temp1 = minPaper[i][0] + temp;
            int temp2 = minPaper[i][1] + temp;
            minPaper[i + 1][0] = min(temp1, temp2);

            int temp3 = minPaper[i][0] + (10 - temp) + 1;
            int temp4 = minPaper[i][1] + (10 - temp) - 1;
            minPaper[i + 1][1] = min(temp3, temp4);
        }
    }

    cout << min(minPaper[L][0], minPaper[L][1]) << endl;

    return 0;
}

Measured memory_bytes: 55940
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
int main()
{
    int a[3];
    scanf("%d %d %d",&a[0],&a[1],&a[2]);
    sort(a,a+3);
    int aa = (a[0]+a[1])/10;
    int aa1 = (a[0]+a[1])%10;
    printf("%d%d\n",aa+a[2],aa1);
    return 0;
}


Measured memory_bytes: 256
#ifndef BZ
#ifndef __clang__
#pragma GCC optimize "-O3"
#endif
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

const ll MOD = 1e9 + 7;

ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}

const int MAXN = 200020;
const int LOG = 20;

int n;
vector<int> eds[MAXN];
int up[MAXN][LOG];
int tin[MAXN];
int tout[MAXN];
int tm1;

bool is_p(int a, int b) {
	return tin[a] <= tin[b] && tin[b] < tout[a];
}

int lca(int a, int b) {
	if (is_p(a, b))
		return a;
	if (is_p(b, a))
		return b;
	for (int i = LOG - 1; i >= 0; --i) {
		if (!is_p(up[a][i], b))
			a = up[a][i];
	}
	return up[a][0];
}

vector<int> gr[MAXN];

void dfs1(int v, int h) {
	gr[h].push_back(v);
	tin[v] = tm1++;
	for (int u: eds[v])
		dfs1(u, h + 1);
	tout[v] = tm1;
}

void add(ll &a, ll b) {
	a = (a + b) % MOD;
}

void pop(vector<array<ll, 4>> &vv) {
	array<ll, 4> &x = vv.back();
	array<ll, 4> &y = vv[vv.size() - 2];
	array<ll, 4> z = {y[0], 0, 0, 0};
	add(z[3], (y[3] * (x[1] + x[2] + x[3]) + y[1] * x[1]) % MOD);
	add(z[2], y[2] * (x[2] + x[3]));
	add(z[1], y[1] * (x[2] + x[3]) + y[2] * x[1]);
	y = z;
	vv.pop_back();
}

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	++n;
	for (int i = 1; i < n; ++i) {
		int p;
		cin >> p;
		eds[p].push_back(i);
		up[i][0] = p;
	}
	for (int i = 1; i < LOG; ++i)
		for (int j = 0; j < n; ++j)
			up[j][i] = up[up[j][i - 1]][i - 1];
	dfs1(0, 0);
	ll ans = pw(2, n - 1);
	for (int h = 1; h < MAXN; ++h) {
		if (gr[h].empty())
			break;
		vector<array<ll, 4>> vv;
		vv.push_back({0, 0, 1, 0});
		for (int x: gr[h]) {
			int y = lca(x, vv.back()[0]);
			while (vv.size() >= 2 && !is_p(vv[vv.size() - 2][0], x))
				pop(vv);
			if (vv.size() >= 2) {
				if (vv[vv.size() - 2][0] == y)
					pop(vv);
				else {
					vv.back()[0] = y;
					add(vv.back()[2], vv.back()[3]);
					vv.back()[3] = 0;
				}
			}
			vv.push_back({x, 1, 1, 0});
		}
		while (vv.size() > 1)
			pop(vv);
		add(ans, pw(2, n - gr[h].size()) * vv[0][1]);
	}
	cout << ans << "\n";
	return 0;
}




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

int main() {
	int n,a[210],cnt=0;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int j=0;j<1000000010;j++){
		for(int i=0;i<n;i++){
			if(a[i]%2==0){
				a[i]/=2;
			}else{
				cout << cnt << endl;
				return 0;
			}
		}
		cnt++;
	}
	return 0;
}


Measured memory_bytes: 256
/*Raihan Kabir
  University of Chittagong
  Bangladesh
  */
#include<iostream>
#include<vector>
#include<set>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<array>
using namespace std;
typedef long long ll;
#define endl '\n'
int main(){
    long long n,m;
    cin>>n>>m;
    int a[m];
    long long sum=0;
    for(int i=0;i<m; i++){
        cin>>a[i];
        sum+=a[i];
    }
    if(n>=sum)cout<<n-sum;
    else cout<<-1;
    return 0;
}


Measured memory_bytes: 3620
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    int n, m, l, r,maxl=-1,minr=100000;
    cin >> n >> m;
    vector<int>key(n, m);
    rep(i, m) {
        cin >> l >> r;
        maxl = max(maxl, l);
        minr = min(minr,r);
    }
    if (minr >= maxl)cout << minr - maxl + 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

string s[3];
int cnt[3];

int main() {
  cin >> s[0] >> s[1] >> s[2];
  int cur = 0;
  while (cnt[cur] < s[cur].size()) {
    int next = s[cur][cnt[cur]] - 'a';
    ++cnt[cur];
    cur = next;
  }
  char ans = 'A' + cur;
  cout << ans;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
const int N = 1e6 + 10;
int flag[N], prim[N], a[N], vist[N];
int cnt;
void get_prim()
{
	//int tot = 0;
	for(int i = 2; i <= 1e6; i++)
	{
		if(!flag[i])	prim[++cnt] = i;
		//if(!flag[i] && i <= 1000)	tot++;
		for(int j = 1; j <= cnt; j++)
		{
			if(prim[j] * i > 1e6)	break;
			flag[prim[j] * i] = 1;
			if(i % prim[j] == 0)	break;
		}
	}
	//printf("%d\n",tot);
	//printf("<%d>",cnt);
}
int main()
{
	get_prim();
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)	scanf("%d", &a[i]);
	/*sort(a + 1, a + n + 1);
	m = unique(a + 1, a + n + 1) - a - 1;
	if(n > cnt)
	{
		printf("not coprime\n");
		return 0;
	}*/
	for(int i = 1;i <= n; i++)
	{
		for(int j = 1; j <= cnt; j++)
		{
			if(a[i] == 1 || prim[j] > 1000 )	break;
			if(a[i] % prim[j] == 0)	vist[j] ++; 
			while(a[i] % prim[j] == 0)	a[i] /= prim[j];
		}
		if(a[i] != 1)
		{
			int x = lower_bound(prim + 1, prim + cnt + 1, a[i]) - prim;
			vist[x]++;
		}
	}
	for(int i = 1; i <= cnt; i++)
		if(vist[i] == n)
		{
			printf("not coprime\n");
			return 0;
		}
	for(int i = 1; i <= cnt; i++)
		if(vist[i] > 1)
		{
			printf("setwise coprime\n");
			return 0;
		}
	printf("pairwise coprime\n");
	return 0;
 } 

Measured memory_bytes: 11944
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s=="SUN") cout<<"7\n";
  if(s=="MON") cout<<"6\n";
  if(s=="TUE") cout<<"5\n";
  if(s=="WED") cout<<"4\n";
  if(s=="THU") cout<<"3\n";
  if(s=="FRI") cout<<"2\n";
  if(s=="SAT") cout<<"1\n";
  return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N,M,X;
	cin>>N>>M>>X;
	vi A(N+1, false);
	while(M--){
		int a; cin>>a;
		A[a] = true;
	}

	int l = 0, r = 0;
	rp(i,1,N){
		if(i<=X){
			if(A[i]) l++;
		}
		else{
			if(A[i]) r++;
		}
	}
	ote(min(l,r));
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *
 
S = input()
Q = INT()
q = deque(S)
flg = 1
for _ in range(Q):
	Que = input().split()
	if Que[0] == "1":
		flg *= -1
	else:
		_, F, C = Que
		if any(int(F)*flg == x for x in [2, -1]):
			q.append(C)
		else:
			q.appendleft(C)


ans = "".join(q)
if flg == -1:
	ans = ans[::-1]
print(ans)

Measured memory_bytes: 95192
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

abc = readints()
k = int(input())
x = sorted(abc)
xx = x[2]
for _ in range(k):
    xx *= 2
print(x[0]+x[1]+xx)


Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
int main(){
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  if(r <= x && r <= y && x + r <= W && y + r <= H) puts("Yes");
  else puts("No");
    
    return 0;
    
}


Measured memory_bytes: 3072
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;


signed main() {
	string r[4] = { "dream", "dreamer", "erase", "eraser" };
	string s, t = "";
	cin >> s;
	bool f = true;
	int i = s.size() - 1;
	while (i >= 0) {
		string t1 = s.substr(i - 4, 5);
		// cout << t1 << endl;
		if (t1 == r[0] || t1 == r[2]) {
			i -= 5;
			continue;
		}
		string t2 = s.substr(i - 5, 6);
		// cout << t2 << endl;
		if (t2 == r[3]) {
			i -= 6;
			continue;
		}
		string t3 = s.substr(i - 6, 7);
		if (t3 == r[1]) {
			i -= 7;
			continue;
		}
		f = false;
		break;
	}
	cout << (f ? "YES" : "NO") << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
template<class S,class T> bool chmax(S& x,T y){
	if(x<y){x=y;return 1;}
	return 0;
}
template<class S,class T> bool chmin(S& x,T y){
	if(x>y){x=y;return 1;}
	return 0;
}
const int MAX_N=610,MAX_S=181000;
int N,K,A,B,a[MAX_N];
short inf=1000;
short dp0[MAX_N+1][MAX_S+1],a0[MAX_N+1][MAX_S+1];
short dp1[MAX_N+1][MAX_S+1],a1[MAX_N+1][MAX_S+1];
int l[MAX_S+1],r[MAX_S+1];
bool can[MAX_S+1];
bool sel[MAX_N];
int main(){
	cin>>N>>K>>A>>B;
	rep(i,N) cin>>a[i];
	int S=accumulate(a,a+N,0);
	for(int j=K;j<=N;j++) rep(s,S+1) dp0[j][s]=dp1[j][s]=inf;
	dp0[K][accumulate(a,a+K,0)]=0;
	for(int j=K;j<=N;j++){
		rep(s,S+1){
			if(dp1[j][s]==inf) continue;
			if(chmin(dp1[j+1][s],dp1[j][s])) a1[j+1][s]=-1;
			int l=dp1[j][s],r=K;
			if(j>K) chmin(r,dp1[j-1][s]);
			for(int i=l;i<r;i++) if(chmin(dp0[j][s-a[i]],i+1)) a0[j][s-a[i]]=i;
		}
		rep(s,S+1){
			if(dp0[j][s]==inf) continue;
			if(chmin(dp0[j+1][s],dp0[j][s])) a0[j+1][s]=-1;
			if(chmin(dp1[j+1][s+a[j]],dp0[j][s])) a1[j+1][s+a[j]]=-2;
		}
	}
	rep(s,S+1) can[s]=(dp0[N][s]!=inf);
	rep(i,MAX_S+1){
		l[i]=1e9;
		if(can[i]) l[i]=0;
		if(i>0) chmin(l[i],l[i-1]+1);
	}
	rep(i,MAX_S+1){
		r[MAX_S-i]=1e9;
		if(can[MAX_S-i]) r[MAX_S-i]=0;
		if(i>0) chmin(r[MAX_S-i],r[MAX_S-i+1]+1);
	}
	int ans=-1,x;
	for(int i=A;i<=B;i++){
		if(chmax(ans,min(l[i],r[i]))) x=i;
	}
	cout<<x<<endl;
	int s=x-ans;
	if(s<0||!can[s]) s=x+ans;
//	assert(can[s]);
	rep(i,K) sel[i]=1;
	int t=0,j=N;
	while(!(t==0&&j==K&&s==accumulate(a,a+K,0))){
//		printf("t,j,s=%d,%d,%d\n",t,j,s);
		if(t==0){
			short x=a0[j][s];
			if(x==-1) j--;
			else{
//				assert(x>=0);
				s+=a[x];
				t=1;
				sel[x]=0;
			}
		}else{
			short x=a1[j][s];
			if(x==-1) j--;
			else{
//				assert(x==-2);
				j--;
				s-=a[j];
				t=0;
				sel[j]=1;
			}
		}
	}
	rep(i,N) if(sel[i]) cout<<i+1<<" ";
	puts("");
}

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

int main()
{
  string s;
  cin>>s;
  long long int x;
  long long int a;
  a=0;
  for(int i=0;i<s.length();i++){
      x=s[i]-'0';
      a=a+x;
  }
  if(a%9==0){
      cout<<"Yes"<<endl;
  }
  else{
      cout<<"No"<<endl;
  }
   return 0;
}

Measured memory_bytes: 3752
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdlib>
#include <iostream>

using namespace std;

#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int H, W;
vector<string> S;

bool pal[110][110];
int cnt[110][110];

int fact[] = { 1, 1, 2, 6, 24 };

int uf[303030];

int root(int p)
{
	return uf[p] < 0 ? p : (uf[p] = root(uf[p]));
}
bool join(int p, int q)
{
	p = root(p);
	q = root(q);
	if (p == q) return false;
	uf[p] += uf[q];
	uf[q] = p;
	return true;
}

int pohe(vector<char> ch)
{
	int ret = 24;
	for (int i = 0; i < ch.size(); ++i) {
		int app = 0;
		for (int j = 0; j < ch.size(); ++j) {
			if (ch[i] == ch[j]) {
				++app;
				if (i < j) goto nxt;
			}
		}
		ret /= fact[app];
	nxt:
		continue;
	}
	return ret;
}

int main()
{
	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; ++i) {
		char in[220];
		scanf("%s", in);
		S.push_back(string(in));
	}
	i64 mult = 1;
	if (S.size() % 2 == 1) {
		string tg = S[S.size() / 2];
		string tg2 = tg;
		reverse(tg2.begin(), tg2.end());
		if (tg != tg2) mult *= 2;
		S.erase(S.begin() + (S.size() / 2));
	}
	if (S.size() == 0) {
		printf("%lld\n", mult);
		return 0;
	}
	H = S.size();
	if (S[0].size() % 2 == 1) {
		string tg;
		for (int i = 0; i < H; ++i) {
			tg.push_back(S[i][S[0].size() / 2]);
			S[i].erase(S[i].begin() + (S[0].size() / 2));
		}
		string tg2 = tg;
		reverse(tg2.begin(), tg2.end());
		if (tg != tg2) mult *= 2;
	}
	if (S[0].size() == 0) {
		printf("%lld\n", mult);
		return 0;
	}
	H = S.size();
	W = S[0].size();
	i64 ret = 1;
	for (int i = 0; i < H / 2; ++i) {
		for (int j = 0; j < W / 2; ++j) {
			vector<char> ch;
			ch.push_back(S[i][j]);
			ch.push_back(S[H - 1 - i][j]);
			ch.push_back(S[i][W - 1 - j]);
			ch.push_back(S[H - 1 - i][W - 1 - j]);

			int waf = pohe(ch);
			if (waf == 24) {
				pal[i][j] = true;
				cnt[i][j] = 12;
			} else {
				pal[i][j] = false;
				cnt[i][j] = waf;
			}
		}
	}
	for (int i = 0; i < 5000; ++i) uf[i] = -1;
	int rem = 0;
	for (int i = 0; i < H / 2; ++i) {
		for (int j = 0; j < W / 2; ++j) {
			if (pal[i][j]) {
				if (join(i, j + H / 2)) ++rem;
			}
			ret = ret * cnt[i][j] % MOD;
		}
	}
	while (rem--) ret = ret * 2 % MOD;
	ret = ret * mult % MOD;
	printf("%lld\n", ret);

	return 0;
}


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

void onepri(int x)	//?????????'???'?????¨???????????¢??°
{
	for(int i = 0; i < x; i++)
		cout << '#';
	cout << endl;
}

int main(){
	int H,W;

	while(1){
		cin >> H >> W;
		if(H == 0 && W == 0)break;
		
		onepri(W);

		for(int i = 0; i < H-2; i++){
			for(int j = 0; j < W; j++){
				if(j == 0 || j == W-1)cout << '#';
				else cout << '.';
			}
			cout << endl;
		}
		if(H != 1)onepri(W);

		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#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 treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if (k < u->key)u = u->left;
    else u = u->right;
  }
  return u;
}

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 == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);

}
void preorder(Node u){
  if (u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  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");
    }
  }
  return 0;
}



Measured memory_bytes: 20452
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<pair<int,int>>v[20];
int boom[20];
int main()
{
    int n;cin>>n;
    int a,b;
    for(int i=1;i<=n;i++)
    {
        int m;cin>>m;
        for(int j=0;j<m;j++)
        {
            cin>>a>>b;
            v[i].push_back({a,b});
        }
    }
    int ans=0;
    for(int i=1;i<1<<n;i++)
    {
        int t=i;
        int temp=1;
        int ok=1;
        memset(boom,-1,sizeof(boom));
        while(t)
        {
            if(t&1)
            {
                if(boom[temp]==0) ok=0;
                else boom[temp]=1;
                for(pair<int,int>a:v[temp])
                {
                    if(boom[a.first]!=-1&&boom[a.first]!=a.second)
                        ok=0;
                    else
                        boom[a.first]=a.second;
                }
            }
            else
            {
                if(boom[temp]==1) ok=0;
                else boom[temp]=0;
            }
            temp++;
            t/=2;
        }
        for(int j=temp;j<=n;j++)
        {
            if(boom[j]==1) ok=0;
        }
        t=i;
        //cout<<ok<<endl;
        if(ok)
        {
            int sum=0;
            for(;t;t/=2) if(t&1) sum++;
            ans=max(ans,sum);
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

void solve()
{
        int n; cin >> n;
        vector<int> a(n);
        forn(i, n) cin >> a[i];
        int res = 0, cnt = 0;
        for(int i = 1; i < n; ++i)
        {
                if (a[i] <= a[i - 1])
                {
                        cnt++;
                }
                else cnt = 0;
                res = max(res, cnt);
        }
        cout << res << endl;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}


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

int main()
{
    string s;
    cin >> s;
    vector<int> v(4);
    rep(i, 4)v[i] = s[i] - '0';
    rep(i, 8) {
        int res = v.front();
        rep(j, 3) {
            res += v[j + 1] * ((i >> j) & 1 ? 1 : -1);
        }
        if (res == 7) {
            rep(j, 3) {
                cout << v[j] << ((i >> j) & 1 ? "+" : "-");
            }
            cout << v.back() << "=7" << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int maax(int a,int b){
  if(a>b)return a;
  return b;
}
int main(){
  int t;
  cin>>t;
  int a[t],b[t],c[t];
  for(int i=0;i<t;i++){
    cin>>a[i]>>b[i]>>c[i];
  }
  
  for(int i=1;i<t;i++){
    a[i]+=maax(b[i-1],c[i-1]);
    b[i]+=maax(c[i-1],a[i-1]);
    c[i]+=maax(a[i-1],b[i-1]);
    
  }
  cout<<maax(maax(a[t-1],b[t-1]),c[t-1]);
}

Measured memory_bytes: 1408
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
    int N, M;
    cin >> N >> M;
    vector<P> v;
    for(int i = 0; i < N; i++){
        long long int A;
        cin >> A;
        v.push_back(P(A, 1));
    }
    for(int i = 0; i < M; i++){
        long long int B, C;
        cin >> B >> C;
        v.push_back(P(C, B));
    }
    sort(v.begin(), v.end());
    long long int ans = 0, cnt = 0;
    for(int i = v.size() - 1; i >= 0; i--){
        if(cnt + v[i].second >= N){
            ans += v[i].first * (N - cnt);
            break;
        }
        ans += v[i].first * v[i].second;
        cnt += v[i].second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6536
#include <stdio.h>
#include <stdbool.h>

bool Pythagoras_checker(int side[3])
{
    int temp;
    
    for (int i = 0; i < 2; i++) {   //sort
        for (int j = 2; j > i; j--) {
            if (side[i] > side[j]) {
                temp = side[j];
                side[j] = side[i];
                side[i] = temp;
            }
        }
    }
    
    if (side[0] * side[0] + side[1] * side[1] == side[2] * side[2]) {
        return true;
    } else {
        return false;
    }
}

int main(void)
{
    int a;
    int side[3];

    scanf("%d", &a);
    
    for (int i = 0; i < a; i++) {
        for (int j = 0; j < 3; j++) {
            scanf("%d", &side[j]);
        }
        
        if (Pythagoras_checker(side) == true) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }

    return 0;
}

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

#define int ll
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'
#define hyphen() cerr << "--\n"

#define fst first
#define pb push_back

const int MOD = (int)1e9 + 7;

signed main() {
    int N;

    cin >> N;

    FORE(A, 1, 3500) {
        FORE(B, 1, 3500) {
            int n = N * A * B;
            int d = 4 * A * B - A * N - B * N;

            if (d > 0 && n % d == 0 && n < 3500 * d) {
                int ans = n / d;
                cout << A << " " << B << " " << ans << endl;
                return 0;
            }
        }
    }

}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

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



Measured memory_bytes: 5152
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 998244353;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

int main(){
    ll n,x,m;
    cin >> n >> x >> m;
    vector<ll> md(100001,-1);
    vector<ll> ln;
    ll st_id, end_id, cnt;

    for(ll i = x; ; i = i*i % m){
        ln.push_back(i);
        if(md[i] == -1){
            md[i] = 1;
        } else {
            for(ll j = 0; j < ln.size(); j++){
                if(ln[j] == i){
                    st_id = j;
                    break;
                }
            }
            cnt = ln.size() - st_id - 1;
            break;
        }
    }
    ll before_sum[st_id+1];
    before_sum[0] = 0;
    for(int i = 1; i <= st_id; i++){
        before_sum[i] = before_sum[i-1] + ln[i-1];
    }
    ll loop_sum[cnt+1];
    loop_sum[0] = 0;
    for(int i = 1; i <= cnt; i++){
        loop_sum[i] = loop_sum[i-1] + ln[st_id+i-1];
    }

    ll ans;
    if(n <= st_id){
        ans = before_sum[n];
    } else {
        n -= st_id;
        ans = before_sum[st_id];
        if(n >= cnt) ans += loop_sum[cnt]*(n/cnt);
        ans += loop_sum[(n%cnt)];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4700
import math

A, B = map(lambda x: int(x), input().split(" "))

# a = A / 0.08
# a = a // 10
# a *= 10
#
# result = -1
# for i in range(10):
#     temp = a + i
#     if math.floor(temp*0.08) == A and math.floor(temp*0.1) == B:
#         result = int(temp)
#         break


result = -1
for i in range(1, 1263):
    if math.floor(i*0.08) == A and math.floor(i*0.1) == B:
        result = int(i)
        break

print(result)


Measured memory_bytes: 2940