akhauriyash/Code-Regression huggingface dataset:
#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>;

int main() {
    int n;
    cin >> n;
    deque<int> deque1;
    deque<int> deque2;
    rep(i,n) {
        int x;
        cin >> x;
        if ((i+1)%2 == 1) deque1.push_back(x);
        else deque2.push_back(x);
    }
    if (n % 2 == 1) {
        while (deque1.size() > 0) {
            cout << deque1.back() << " ";
            deque1.pop_back();
        }
        while (deque2.size() > 0) {
            cout << deque2.front();
            if (deque2.size() != 1) cout << " ";
            deque2.pop_front();
        }
    }
    else {
        while(deque2.size() > 0) {
            cout << deque2.back() << " ";
            deque2.pop_back();
        }
        while(deque1.size() > 0) {
            cout << deque1.front();
            if (deque1.size() != 1) cout << " ";
            deque1.pop_front();
        }
    }
    cout << endl;
}

Measured memory_bytes: 2944
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using uint = uint32_t;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

struct fun {
	ll a, b;
	ll operator() (ll x){
		return a * x + b;
	}
};
bool cmp(fun a, fun b, fun c) {
	ll x1 = -(a.b - b.b) * (a.a - c.a);
	ll x2 = -(a.b - c.b) * (a.a - b.a);
	return x1 >= x2;
}

signed main() {
	EmiliaMyWife

	int n;
	ll c;
	cin >> n >> c;
	vector<ll> dp(n);
	vector<ll> arr(n);
	for(int i = 0; i < n; i++)
		cin >> arr[i];
	deque<fun> line;
	line.push_back({-2 * arr[0], arr[0] * arr[0]});
	for(int i = 1; i < n; i++) {
		while(line.size() > 1 && line[0](arr[i]) >= line[1](arr[i]))
			line.pop_front();
		dp[i] = line.front()(arr[i]) + c + arr[i] * arr[i];
		fun w = {-2 * arr[i], arr[i] * arr[i] + dp[i]};
		while(line.size() > 1 && cmp(line[line.size() - 2], line.back(), w))
			line.pop_back();
		line.push_back(w);
	}
	cout << dp.back() << '\n';

	return 0;
}


Measured memory_bytes: 8328
#include<iostream>
using namespace std;
int main() {
    int a,b,s;
    cin>>a>>b;
    if(a>=b){
        s=a;
        for(int i=0;i<s;i++)
            cout<<b;
    } else{
        for(int i=0;i<b;i++)
            cout<<a;

    }

}

Measured memory_bytes: 256
def gcd(x,y):
    if x < y:
        (x,y) = (y,x)
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

n,k = map(int, input().split())
list_a = list(map(int, input().split()))
g = list_a[0]
for i in range(1,n):
    g = gcd(g,list_a[i])
if k > max(list_a):
    print("IMPOSSIBLE")
else:
    if k % g == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


Measured memory_bytes: 14100
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    vector<int> l(n+1,-1),r(n+1,-1),u(n+1,-1),v(n+1,-1);
    for(auto& x:a)
    cin>>x;
    for(auto& x:b)
    cin>>x;
    int res=0;
    vector<int> h(n+1,0);
    for(auto x=1,a1=0,b1=0;x<=n;x++)
    {
        while(a1<n and a[a1]<x)
        ++a1;
        if(a1<n and a[a1]==x)
        {
            int j=a1;
            while(j<n and a[j]==x)
            ++j;
            tie(l[x],r[x])={a1,j};
            a1=j;
        }
        while(b1<n and b[b1]<x)
        ++b1;
        if(b1<n and b[b1]==x)
        {
            int j=b1;
            while(j<n and b[j]==x)
            ++j;
            tie(u[x],v[x])={b1,j};
            b1=j;
        }
        if(~l[x] and ~u[x])
        {
            ++res;
            if(r[x]-l[x]+v[x]-u[x]>n)
            {
                cout<<"No\n";
                return 0;
            }
            if(u[x]<=l[x])
            {
                if(v[x]<=l[x])
                {
                    ++h[0];
                    --h[l[x]-v[x]+1];
                    ++h[r[x]-u[x]];
                    --h[n];
                }
                else
                {
                    ++h[r[x]-u[x]];
                    --h[l[x]+n-v[x]+1];
                }
            }
            else
            {
                ++h[max(0,r[x]-u[x])];
                --h[l[x]+n-v[x]+1];
            }
        }
    }
    for(auto i=0;i<n;i++)
    {
        if(h[i]==res)
        {
            cout<<"Yes\n";
            rotate(b.begin(),b.begin()+n-i,b.end());
            for(auto xx:b)
            cout<<xx<<" ";
            cout<<endl;
            return 0;
        }
        h[i+1]+=h[i];
    }
    return 0;
}


Measured memory_bytes: 8788
import heapq

N,M,S,T = map(int,input().split())
S,T = S-1,T-1
src = [tuple(map(int,input().split())) for i in range(M)]

es = [[] for i in range(N)]
for u,v,a,b in src:
    u,v = u-1,v-1
    es[u].append((v,a,b))
    es[v].append((u,a,b))

INF = float('inf')
cy = [INF] * N
cy[S] = 0
hq = [(0,S)]
heapq.heapify(hq)
while hq:
    cost,v = heapq.heappop(hq)
    for to,a,b in es[v]:
        if cost + a >= cy[to]: continue
        cy[to] = cost + a
        heapq.heappush(hq, (cy[to],to))

cs = [INF] * N
cs[T] = 0
hq = [(0,T)]
heapq.heapify(hq)
while hq:
    cost,v = heapq.heappop(hq)
    for to,a,b in es[v]:
        if cost + b >= cs[to]: continue
        cs[to] = cost + b
        heapq.heappush(hq, (cs[to],to))

ans = [INF]
for i in reversed(range(N)):
    tmp = cs[i] + cy[i]
    ans.append(min(ans[-1],tmp))

for a in reversed(ans[1:]):
    print(10**15 - a)

Measured memory_bytes: 73848
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int a, b;
	cin >> a >> b;
	cout << (b - a) * (b - a + 1) / 2 - b << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;

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

        int N = sc.nextInt();
        int[] s = new int[N];
        int ans = 0;
        ArrayList<Integer> list = new ArrayList<Integer>();

        for(int i=0; i<N; i++){
            s[i] = sc.nextInt();
            list.add(s[i]);
            ans += s[i];
        }

        Collections.sort(list);
        
        if(ans%10!=0){
            System.out.println(ans);
        }
        else{
            for(int i=0; i<N; i++){
                if(list.get(i)%10!=0){
                    ans -= list.get(i);
                }
                if(ans%10!=0){
                    System.out.println(ans);
                    break;
                }
                if(i==N-1){
                    System.out.println(0);
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 21972
#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>;
const ll MOD = 1e9 + 7;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> dp(N + 1, -1);
    vector<ll> a(M);
    for (int i = 0; i < M; i++)
    {
        cin >> a[i];
        dp[a[i]] = 0;
    }

    dp[0] = 1;
    

    for (int i = 1; i <= N; i++)
    {
        if (dp[i] == 0)
        {
            continue;
        }
        if (i == 1)
        {
            dp[i] = dp[i - 1];
            continue;
        }
        
        dp[i] = dp[i - 1] + dp[i - 2];
        dp[i] %= MOD;
    }
    
    cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[100010];
    for (int i=0; i<n; i++) {
        cin >> a[i];
        a[i]--;
    }
    int ans=0;
    for (int i=0; i<n; i++) {
        if (a[i] > i && a[a[i]] == i) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  bool flag = false;
  int n;
  for ( int i = 1; i <= 100001; i++ ) {
    if ( N == i*(i+1)/2 ) {
      flag = true;
      n = i;
      break;
    }
  }

  if ( !flag ) {
    cout << "No" << endl;
    return 0;
  }

  vector<int> ans[n+1];  
  int p = 1;
  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n-i; j++ ) {
      ans[i].emplace_back(p++);      
    }
    int m = ans[i].size();    
    for ( int j = m-1; j >= m-(n-i); j-- ) {
      ans[i+((m-1)-j)+1].emplace_back(ans[i][j]);      
    }
  }

  cout << "Yes" << endl;
  cout << n+1 << endl;
  for ( int i = 0; i < n+1; i++ ) {
    cout << n << " ";
    for ( int j = 0; j < ans[i].size(); j++ ) {
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3200
N, K = map(int, input().split())
a = []
for _ in range(N):
    a.append(int(input())-K)
    
su = 0
v = [(0, 0)]
for i in range(N):
    su += a[i]
    v.append((su, i+1))
v = sorted(v)

data = [0]*(N+2)

def sumation(i):
    s = 0
    while i > 0:
        s += data[i]
        i -= i & -i
    return s
    
def add(i, x):
    while i <= N+1:
        data[i] += x
        i += i & -i
ans = 0
for e, i in v:
    ans += sumation(i+1)
    add(i+1, 1)
    
print(ans)

Measured memory_bytes: 41676
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <iomanip>

using namespace std;

int main(){
	int n;
	cin >> n;
	int cnt = 0;
	for(int i = 1; i < n; i++){
		for(int j = 1; j < n; j++){
			if(i*j < n){
				cnt++;
			}
			else{
				break;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

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

int GetRandom(int min,int max){
	return min + (int)(rand()*(max-min+1.0)/(1.0+RAND_MAX));
}

int main(){
    // 入力
    int D;
    cin >> D;   // D = 365
    ll c[26];
    for(int i=0;i<26;i++)
        cin >> c[i];
    ll s[D][26];
    for(int i=0;i<D;i++)
        for(int j=0;j<26;j++)
            cin >> s[i][j];
    // 初期解t[D]
    int t[D];
    /*
    for(int i=0;i<D;i++)
        cin >> t[i];
    */
    for(int i=0;i<D;i++){
        //t[i] = GetRandom(1,26);   // 1<=, <=26
        t[i] = i%26 + 1;
    }
    // クエリ
    int M;
    // cin >> M;
    M = 100000;
    int d[M], q[M];
    /*
    for(int i=0;i<M;i++)
        cin >> d[i] >> q[i];
    */
    for(int i=0;i<M;i++){
        d[i] = GetRandom(1,D);   // 1<=, <=365
        q[i] = GetRandom(1,26);   // 1<=, <=26 
    }

    // 処理部
    ll v_best = 0;
    for(int query=0;query<M;query++){
        int last[26] = {}, q_;
        // コンテスト種別の変更
        q_ = t[d[query]-1];
        t[d[query]-1] = q[query];
        // D日分
        ll v = 0;
        for(int i=1;i<=D;i++){
            // 満足度の増加分
            v += s[i-1][t[i-1]-1];
            last[t[i-1]-1] = i;
            // 満足度の低下分（コンテスト26種分）
            for(int j=0;j<26;j++)
                v -= c[j]*(i - last[j]);
        }
        // cout << v << endl;
        if(v < v_best){
            t[d[query]-1] = q_;
        }
    }

    // 答え出力
    for(int i=0;i<D;i++)
        cout << t[i] << endl;

}

Measured memory_bytes: 4508
n = int(input())
A = list(map(int, input().split()))
from itertools import accumulate
B = [0]+A
B = list(accumulate(B))

d = {}
ans = 0
for i in range(n+1):
  if B[i] not in d:
    d[B[i]] = 1
  else:
    ans += d[B[i]]
    d[B[i]] += 1
    
print(ans)

Measured memory_bytes: 41364
#include <stdio.h>
#define NUMBER 10000
int main(void){
  int  i,num;
  int a[NUMBER];
  scanf("%d",&num);

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

  long min,max,sum;
  min=max=sum=a[0];
  for(i=1;i<num;i++){
      if(a[i]>max){
      max=a[i];}
      if(a[i]<min){
      min=a[i];}
      sum+=a[i];
  }
  printf("%ld %ld %ld\n",min,max,sum);
  return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    int a[n][m];
    int b[m];

    for (int row=0; row!=n; ++row){
        for (int col=0; col!=m; ++col){
            cin >> a[row][col];
        }
    }

    for (int row=0; row!=m; ++row){
        cin >> b[row];
    }

    for (int row=0; row!=n; ++row){
        int val=0;
        for (int col=0; col!=m; ++col){
            val += a[row][col] * b[col];
        }
        cout << val << endl;
    }
    return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

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

const int mod = 1000000007;

struct mint {
    ll x;
    mint(ll x=0):x(x%mod){}

    mint& operator+=(const mint a) {
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator-=(const mint a) {
        if((x -= mod-a.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator*=(const mint a) {
        x = (x * a.x) % mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
};

mint dp[100005][13];

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

  string s;
  cin >> s;

  dp[0][0] = 1;
  rep(i, s.length()) {
    char c = s[i];
    if (c == '?') {
      rep(k, 10) {
        rep(j, 13) {
          dp[i+1][(10*j+k) % 13] += dp[i][j];
        }
      }
    } else {
      int k = c - '0';
      rep(j, 13) {
        dp[i+1][(10*j+k) % 13] += dp[i][j];
      }
    }
  }

  cout << dp[s.length()][5].x << endl;
}


Measured memory_bytes: 10752
#include <iostream>
#include <vector>

using namespace std;

template <typename Adj, typename Visit>
int dfs(int p, Visit& visit, const Adj& adj) {
  if (visit[p])
    return 0;

  visit[p] = true;
  auto result = 1;
  for (const auto& np: adj[p]) {
    if (not visit[np])
      result += dfs(np, visit, adj);
  }

  return result;
}

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

  int n, m;
  cin >> n >> m;

  vector<vector<int>> adj(n + 1);

  while (m--) {
    int a, b;
    cin >> a >> b;
    adj[a].emplace_back(b);
    adj[b].emplace_back(a);
  }

  vector<bool> visit(n + 1);
  auto result = 0;
  for (auto i = 1; i <= n; i++) {
    if (not visit[i]) {
      result = max(result, dfs(i, visit, adj));
    }
  }

  cout << result << '\n';

  return 0;
}


Measured memory_bytes: 23176
# vim: set fileencoding=utf-8:
import collections


def main():
    # すべての数に対して、すべての数との差を計算する(10^5)か？TLEだ
    # 最大にするには、配列の中央の差が最大となるようにジグザグにしてけばいい
    N = input()
    A = sorted([input() for _ in xrange(N)])

    a = uzuamuki_sort(A, start="max", lr="right")
    b = uzuamuki_sort(A, start="max", lr="left")
    c = uzuamuki_sort(A, start="min", lr="right")
    d = uzuamuki_sort(A, start="min", lr="left")
    anss = [cal_ans(ele, N) for ele in [a, b, c, d]]
    print(max(anss))


def cal_ans(arr, N):
    ans = 0
    for i in xrange(N - 1):
        ans += abs(arr[i] - arr[i + 1])

    return ans


def uzuamuki_sort(A, start, lr):
    deq = collections.deque(A)
    uzu = collections.deque()

    def max_lr():
        uzu.appendleft(deq.popleft())
        uzu.append(deq.popleft())

    def max_rl():
        uzu.append(deq.popleft())
        uzu.appendleft(deq.popleft())

    def min_lr():
        uzu.appendleft(deq.pop())
        uzu.append(deq.pop())

    def min_rl():
        uzu.append(deq.pop())
        uzu.appendleft(deq.pop())

    if start == "max":
        uzu.append(deq.popleft())
        if lr == "right":
            while True:
                try:
                    min_rl()
                    max_rl()
                except IndexError:
                    break
        elif lr == "left":
            while True:
                try:
                    min_lr()
                    max_lr()
                except IndexError:
                    break

    elif start == "min":
        uzu.append(deq.pop())
        if lr == "right":
            while True:
                try:
                    max_rl()
                    min_rl()
                except IndexError:
                    break
        elif lr == "left":
            while True:
                try:
                    max_lr()
                    min_lr()
                except IndexError:
                    break

    return list(uzu)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10012
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int h, w, h1, w1, k;
  cin >> h >> w >> h1 >> w1 >> k;
  cout << ((h1*60)+w1) - ((h*60)+w) - k << endl;
  return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

template <typename T>
using V = std::vector<T>;
template <typename T>
vector<T> make_vec(size_t n, T a) {
  return vector<T>(n, a);
}
template <typename... Ts>
auto make_vec(size_t n, Ts... ts) {
  return vector<decltype(make_vec(ts...))>(n, make_vec(ts...));
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << '[';
  for (auto &&e : v) os << e << ' ';
  return os << ']';
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &v) {
  os << '[';
  for (auto &&e : v) os << e << ' ';
  return os << ']';
}

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

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

  string s, t;
  cin >> s >> t;

  V<V<int>> dic(26);
  REP(i, s.size()) {
    int c = s[i] - 'a';
    dic[c].push_back(i);
  }

  i64 ans = [&]() -> i64 {
    i64 iter = 0;
    i64 j = 0;
    REP(i, t.size()) {
      int tc = t[i] - 'a';
      const V<int> &d = dic[tc];
      if (d.empty()) return -1;
      while (true) {
        auto it = lower_bound(d.begin(), d.end(), j);
        if (it == d.end()) {
          assert(j > 0);
          ++iter;
          j = 0;
          continue;
        } else {
          j = *it + 1;
          break;
        }
      }
    }
    return iter * s.size() + j;
  }();
  cout << ans << endl;
}


Measured memory_bytes: 4132
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
ll tag[800050],t[800050];
int n,m;
struct re{
	int l,r,v;
}a[200050];
void pushdown(int l,int r,int id){
	if (l==r||!tag[id])return;
	t[id<<1]+=tag[id];t[id<<1|1]+=tag[id];tag[id<<1]+=tag[id];tag[id<<1|1]+=tag[id];
	tag[id]=0;
}
void modify(int l,int r,int id,int ql,int qr,ll v){
	if (ql<=l&&r<=qr){t[id]+=v;tag[id]+=v;return;}
	int mid=(l+r)>>1;
	pushdown(l,r,id);
	if (ql<=mid)modify(l,mid,id<<1,ql,qr,v);
	if (qr>mid)modify(mid+1,r,id<<1|1,ql,qr,v);
	t[id]=max(t[id<<1],t[id<<1|1]);
}
ll query(int l,int r,int id,int x){
	if (r==x)return t[id];
	int mid=(l+r)>>1;
	if (mid<x)return max(t[id<<1],query(mid+1,r,id<<1|1,x));
	else return query(l,mid,id<<1,x);
}
bool cmp(re a,re b){return a.r<b.r;}
int main(){
	scanf("%d%d",&n,&m);n++;
	for (int i=1;i<=m;i++)scanf("%d%d%d",&a[i].l,&a[i].r,&a[i].v),a[i].l++,a[i].r++;
	sort(a+1,a+m+1,cmp);
	int pos=1;
	for (int i=2;i<=n;i++){
		modify(1,n,1,i,i,query(1,n,1,i));
		while (a[pos].r==i)modify(1,n,1,a[pos].l,a[pos].r,a[pos].v),pos++;
	}
	printf("%lld",t[1]);
}

Measured memory_bytes: 14464
#include<iostream>
#include<vector>
#include<string>

const int MOD = 1000000007;

int main(){
    int n, m;
    std::cin >> n >> m;
    std::vector<bool> notUsed(n + 1, false);
    for(int i = 0; i < m; i++){
        int a;
        std::cin >> a;
        notUsed[a] = true;
    }

    std::vector<int> dp(n + 1, 0);
    dp[0] = 1;
    for(int i = 0; i < n; i++){
        // 現在i段目にいる
        if(i + 1 <= n && !notUsed[i + 1]){
            dp[i + 1] += dp[i];
            dp[i + 1] %= MOD;
        }
        if(i + 2 <= n && !notUsed[i + 2]){
            dp[i + 2] += dp[i];
            dp[i + 2] %= MOD;
        }
    }

    std::cout << dp[n] % MOD << std::endl;
    return 0;
}


Measured memory_bytes: 640
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

// Entry for Queue
type Entry struct {
	prev  *Entry
	value int
}

// Queue is
type Queue struct {
	head *Entry
	tail *Entry
}

func (q *Queue) enqueue(x int) {
	entry := Entry{
		prev:  q.head,
		value: x,
	}
	if q.head == nil {
		q.tail = &entry
	} else {
		q.head.prev = &entry
	}
	q.head = &entry
}

func (q Queue) front() (bool, int) {
	if q.tail == nil {
		return false, -1
	}
	return true, q.tail.value
}

func (q *Queue) dequeue() int {
	if q.tail == nil {
		return -1
	}
	deletedEntry := *q.tail
	if q.head == q.tail {
		q.head = nil
		q.tail = nil
	} else {
		q.tail = q.tail.prev
	}
	return deletedEntry.value
}

func main() {
	scanner.Split(bufio.ScanWords)

	nQueues := nextInt()
	queues := make([]Queue, nQueues)
	for i := 0; i < nQueues; i++ {
		queues[i].head = nil
		queues[i].tail = nil
	}

	nQueries := nextInt()
	for i := 0; i < nQueries; i++ {
		queryType := nextInt()
		iQueue := nextInt()
		if queryType == 0 {
			queues[iQueue].enqueue(nextInt())
		} else if queryType == 1 {
			ok, tailValue := queues[iQueue].front()
			// fmt.Println(ok, tailValue, queues)
			if ok {
				fmt.Println(tailValue)
			}
		} else if queryType == 2 {
			queues[iQueue].dequeue()
		}
	}
}



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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, y;
  cin >> n >> y;
  for(int i=0; i<=n; i++){
    for(int j=0; j<=n; j++){
      if(10000 * i + 5000 * j > y || i + j > n) break;
      if(10000 * i + 5000 * j + (n - i - j) * 1000 == y){
        cout << i << " " << j << " " << (n - i - j) << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}


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

int main(){
    int n,m,c;
    cin>>n>>m>>c;
    vector<int> b(m);
    for(int i=0;i<m;i++) cin>>b[i];
    vector<vector<int>> a(n,vector<int>(m));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++) cin>>a[i][j];
    }   
    int res=0; 
    for(int i=0;i<n;i++){
        int sum=c;
        for(int j=0;j<m;j++){
            sum+=a[i][j]*b[j];
        }
        if(sum>0) res++;
    }
    cout<<res<<endl;
    return 0;
}

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

int main()
{
  int N;scanf("%d",&N);
  pair<string,int> op[N],np[N];
  for(int P,i=0;i<N;i++)
  {
    string S;cin>>S>>P;
    op[i].first=S,op[i].second=100-P;
    np[i].first=S,np[i].second=100-P;
  }
  sort(np,np+N);
  for(int i=0;i<N;i++)
  {
    for(int j=0;j<N;j++)
    {
      if(op[j].first==np[i].first&&op[j].second==np[i].second)printf("%d\n",j+1);
    }
  }
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
template<typename T> T changeMax(T& a, T b){if(a < b)a = b;return 0;}

int main()
{
    int n, m, AC_cnt = 0, WA_cnt = 0;
    cin >> n >> m;
    vector<int> v(m);
    vector<string> k(m);
    rep(i, m){
        cin >> v[i] >> k[i];
    }
    vector<bool> AC(n, false);
    vector<int> h(n);
    rep(i, m){
        if(AC[v[i]-1] == false){
            if(k[i] == "AC"){
                AC[v[i]-1] = true;
                AC_cnt++;
            }
            else{
                WA_cnt++;
                h[v[i]-1]++;
            }
        }
    }
    for(int i = 0; i < n; i++){
        if(AC[i] == false){
            WA_cnt -= h[i];
        }
    }
    cout << AC_cnt << " " << WA_cnt << endl;
    system("pause");
}

Measured memory_bytes: 6776
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    int N;
    string S;
    cin >> N >> S;
    for(int i=0;i<S.size();i++){
        char c = S[i];
        for(int j=0;j<N;j++){
            if(c=='Z') c = 'A';
            else c++;
        }
        cout << c << (i!=S.size()-1? "":"\n");
    }    
}

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


using namespace std;

int main()  {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    long long min_val = 999999999999;
    int val = 0;

    for(int i = 0; i <= 100000; i++) {
        val = (A*max(0, X-i)) + (B*max(0, Y-i)) + (i*2*C);
        if(min_val > val) min_val = val;
    }

    cout << min_val << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 1010;
const int MAXM = 110;
const int MAXK = 510;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int res = 0;
    FOR(i,0,SZ(s)-1) {
        int cnt = 0;
        FOR(j,i,SZ(s)-1)
            if (s[j] == 'A' || s[j] == 'T' || s[j] == 'G' || s[j] == 'C') cnt++;
            else break;
        res = max(res, cnt);
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	vector<int> h(1000000);
	vector<int> cost(100000);
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}
	cost[0] = 0;
	for (int i = 1; i < N; i++) {
		if (i == 1) {
			cost[i] = abs(h[i] - h[i - 1]);
		}
		else {
			cost[i] = min(cost[i-1]+abs(h[i] - h[i - 1]), cost[i-2]+abs(h[i] - h[i - 2]));
		}
	}
	cout << cost[N - 1] << endl;
}

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

int main() {
	// your code goes here
	int n,k;
	cin >> n >> k;
	int a[n];
	for(int i=0;i<n;i++)
	    cin >> a[i];
	sort(a,a+n);
	int sum=0;
	for(int i=0;i<k;i++)
	    sum+=a[i];
	cout << sum;
	return 0;
}


Measured memory_bytes: 3624
import java.util.*;

public class Main{
    Scanner in = new Scanner(System.in);

    void solve(){
        int n = Integer.parseInt(in.nextLine());
        ArrayList<String> list = new ArrayList<>();
        for(int i = 0; i < n; i++){
            list.add(in.nextLine());
        }
        list.stream().map(s -> s.replaceAll("Hoshino", "Hoshina")).forEach(System.out::println);
    }
    
    public static void main(String[] args){
        new Main().solve();    
    }
}

Measured memory_bytes: 31916
N = int(input())
if N==1:
    print("a")
    exit()
def dfs(s,cnt):
    if len(s)==N:
        return s
    for i in range(cnt+1):
        if i==cnt:
            cnt+=1
        if dfs(s+chr(ord("a")+i),cnt)!=None:
            ans.append(dfs(s+chr(ord("a")+i),cnt))
ans=[]
dfs("a",1)
ans = sorted(ans)
print(*ans)

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

int main(){
  int L;
  cin >> L;
  ld tmp = (ld)L / 3;
  ld ans = tmp * tmp * ((ld)L - tmp - tmp);
  cout << setprecision(8) << ans << endl;
}

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

public class Main {

	List<Integer>[] tree;
	int[] w;
	int INF = Integer.MAX_VALUE / 3;
	int[][] dp;

	int MAX = 6000;
	int[] buf = new int[MAX + 1];
	int[] buf2 = new int[MAX + 1];

	void dfs(int u) {
		for (int v : tree[u]) {
			dfs(v);
		}

		for (int col = 0; col < 2; col++) {
			Arrays.fill(buf, INF);
			buf[0] = 0;
			for (int v : tree[u]) {
				int val1 = dp[v][col];
				int val2 = dp[v][col ^ 1];
				Arrays.fill(buf2, INF);

				for (int i = 0; i <= MAX; i++) {
					// pairs (w[v], val2), (val1, w[v])
					if (i >= w[v]) {
						buf2[i] = Math.min(buf[i - w[v]] + val2, buf2[i]);
					}
					if (i >= val1) {
						buf2[i] = Math.min(buf[i - val1] + w[v], buf2[i]);
					}
				}
				System.arraycopy(buf2, 0, buf, 0, buf.length);
			}

			int min = INF;
			for (int i = 0; i <= w[u]; i++) {
				min = Math.min(min, buf[i]);
			}
			dp[u][col] = min;
		}
	}

	void solve() {
		int n = in.nextInt();
		tree = new List[n];
		for (int i = 0; i < n; i++) {
			tree[i] = new ArrayList<>();
		}
		for (int i = 1; i < n; i++) {
			tree[in.nextInt() - 1].add(i);
		}
		w = new int[n];
		for (int i = 0; i < n; i++) {
			w[i] = in.nextInt();
		}
		dp = new int[n][2];
		for (int[] i : dp) {
			Arrays.fill(i, INF);
		}
		dfs(0);
		if (dp[0][0] < INF || dp[0][1] < INF) {
			out.println("POSSIBLE");
		} else {
			out.println("IMPOSSIBLE");
		}
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

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

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

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

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

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


Measured memory_bytes: 27360
#include<bits/stdc++.h>
#define maxn 200000+5
#define inf 0x3f3f3f3f
using namespace std;

string a[maxn];
string s;
map<string,int> st;

int main(){
	int n;
	cin>>n;
	int maxx = -inf;
	for(int i=0;i<n;i++){
		cin>>a[i];
		st[a[i]]++;
		maxx = max(st[a[i]],maxx);
	}
	int len = st.size();
	for(auto i=st.begin();i!=st.end();i++){
		//cout<<i->first<<" "<<i->second<<endl;
		if(i->second == maxx){
			cout<<i->first<<endl;
		}
	}
	return 0;
} 

Measured memory_bytes: 26752
from collections import defaultdict
n, k = map(int, input().split())
a = list(map(int, input().split()))
dic = defaultdict(int)
for i in range(n):
    dic[a[i]] += 1

s = sorted(dic.values())
if len(dic) <= k:
    print(0)
else:
    num = 0
    for i in range(len(dic) - k):
        num += s[i]
    print(num)

Measured memory_bytes: 32572
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#endif

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


MY_NAMESPACE(sandbox)
ll gcd(ll a, ll b)
{
	if (a < b)
		swap(a, b);
	if (a % b == 0)
		return b;
	return gcd(b, a % b);
}

ll modpow(ll base, ll exponent, ll mod)
{
	ll retval = 1;
	while (exponent > 0)
	{
		if (exponent % 2)
			retval = (retval * base) % mod;
		exponent /= 2;
		base = (base * base) % mod;
	}
	return retval;
}

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

	ll modval = 1000000007;

	int n;
	cin >> n;
	map<pll, int> cnt;
	for (int i = 0; i < n; i++)
	{
		ll a, b;
		cin >> a >> b;
		if (a != 0 && b != 0)
		{
			if (a < 0)
			{
				a *= -1;
				b *= -1;
			}
			ll g = gcd(abs(a), abs(b));
			cnt[{a / g, b / g}]++;
		}
		else if (a == 0 && b == 0)
			cnt[{0, 0}]++;
		else if (a == 0)
			cnt[{0, 1}]++;
		else  // b == 0
			cnt[{1, 0}]++;
	}

	ll num00 = 1;
	if (cnt[{0, 0}] == 0)
		num00 = 0;
	else
		num00 = cnt[{0, 0}];
	cnt.erase(make_pair(0,0));

	ll num = 1;
	while (!cnt.empty())
	{
		auto this_item = *cnt.begin();
		cnt.erase(cnt.begin());
		pll this_pair = this_item.first;
		pll anti_pair = { this_pair.second, -this_pair.first };
		if (anti_pair.first < 0)
			anti_pair = { -this_pair.second, this_pair.first };
		else if (anti_pair.first == 0)
			anti_pair = { 0, 1 };
		if (cnt.find(anti_pair) == cnt.end())
			cnt[anti_pair] = 0;
		auto anti_item = cnt.find(anti_pair);

		num = num * (modpow(2, this_item.second, modval) - 1 + modpow(2, anti_item->second, modval) - 1 + 1) % modval;
		cnt.erase(anti_item);
	}
	ll retval = (num + modval - 1) % modval;
	cout << (retval + num00) % modval << "\n";
		
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>
#define llint long long

using namespace std;

llint n;
string s; 
unordered_map<string, llint> mp;

int main(void)
{
	cin >> n;
	cin >> s;
	string t = s.substr(n/2);
	reverse(t.begin(), t.end());
	
	int N = 1<<n;
	for(int i = 0; i < N; i++){
		string r, b;
		for(int j = 0; j < n; j++){
			if(i & (1<<j)) r += t[j];
			else b += t[j];
		}
		r += "#" + b;
		mp[r]++;
	}
	
	llint ans = 0;
	for(int i = 0; i < N; i++){
		string r, b;
		for(int j = 0; j < n; j++){
			if(i & (1<<j)) r += s[j];
			else b += s[j];
		}
		r += "#" + b;
		ans += mp[r];
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 74228
//品質管理

#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>

using namespace std;
#define LL long long

int C, N, p[1003][1003], ans = 0, mir;

int main() {
	cin >> C >> N;
	mir = 0;
	for (int i = 0; i < N; i++) {
		string tmp; cin >> tmp;
		for (int j = 0; j < N; j++) p[i][j] = tmp[j]-'0';
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i < N / 2)//縦
				if (p[i][j] == p[N - 1 - i][j])mir++;
			if (j < N / 2)//横
				if (p[i][j] == p[i][N - 1 - j])mir++;;
		}
	}
	if (mir == N * N)ans++;
	for (int i = 1; i < C; i++) {
		int D;
		cin >> D;
		for (int j = 0; j < D; j++) {
			int _i, _j;
			cin >> _i >> _j; _i--; _j--;
			bool t = (p[_i][_j] == p[N - 1 - _i][_j]),
				y = (p[_i][_j] == p[_i][N - 1 - _j]);
			mir += (t ? -1 : 1) + (y ? -1 : 1);
			p[_i][_j] = p[_i][_j] ? 0 : 1;
		}
		if (mir == N * N)ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 7104
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 (b<a) {a=b; return 1;} return 0;}

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    rep(i, m) cin >> a[i] >> b[i];
    vector<P> p(m);
    rep(i, m) p[i] = P(--b[i], --a[i]);
    sort(p.begin(), p.end());
    int ans = 0;
    int now = 0;
    rep(i, m) {
        int begin = p[i].second;
        int end = p[i].first;
        if (begin >= now) {
            ans++;
            now = end;
        }
    }
    cout << ans << endl;
}


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

string s[200000];
int main() {
	
	//B
	int n;
	int a[100];
	cin >> n;
	int i;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2 == 0) {
			if (a[i] % 3 == 0) {

			}
			else if (a[i] % 5 == 0) {

			}
			else {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
	return 0;

	//C
	/*int i, n;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s, s + n);
	//cout<< endl << "sort" << endl;
	//for (i = 0; i < n; i++) {
	//	cout << s[i] << endl;
	//}
	//cout << "sort" << endl << endl;
	string t;
	t = s[0];
	int counter = 1, maxc = 0;
	for (i = 1; i < n; i++) {
		if (s[i] == t) {
			counter++;
		}
		else {
			t = s[i];
			if (counter > maxc)maxc = counter;
			counter = 1;
		}

	}
	if (counter > maxc)maxc = counter;

	t = s[0]; counter = 1;
	for (i = 1; i < n; i++) {
		if (s[i] == t) {
			counter++;
		}
		else {
			t = s[i];
			if (counter  == maxc)cout << s[i-1] << endl;
			counter = 1;
		}

	}
	if (counter == maxc) {
		cout << s[n - 1] << endl;
	}
	return 0;*/

	//D
	/*int n,k;
	cin >> n >> k;
	int i;
	long long int a[200000];
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}*/
	//E
	/*string s;
	cin >> s;
	int i, j;
	int flag = 0;
	long long int sum = 0;
	for (i = s.size() - 1; i >= 0; i--) {
		j = s[i] - '0' + flag;
		if (j == 10) {
			j = 0;
			flag = 1;
		}
		else {
			flag = 0;
		}
		if (j <= 5) {
			sum = sum + j;
		}
		else {
			sum = sum + 10 - j;
			flag = 1;
		}
	}
	cout << sum + flag << endl;
	return 0;*/


}

Measured memory_bytes: 9832
#include <stdio.h>



int main(void)
  
{

  char S[10];
  int i=0,count=0,max=0;
  
   
  scanf("%s", S);
  
 for(i=0;i<10;i++)
 {
   if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T')
   count++;
   
   else
   {
   if(count > max)
   max = count;
   count = 0;
   }
     
 }
    
  if(count > max)
   max = count;
  
    printf("%d", max);
  
 
  	return 0;
  
}

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

int main(){
  int n;
  cin >> n;
  if (n >= 65 && 90 >= n) cout << 1 << endl;
  else if (n >= 97 && 122 >= n) cout << 2 << endl;
  else {cout << 0 << endl;}
}


Measured memory_bytes: 3116
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝




*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n>>m;
    l(i,0,m)
    {
        cin>>a;
        d=d+a;
    }
    if(d>=n)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    using Tile = array<int, 4>;
    auto normalize = [&](Tile &a) {
        Tile b = a;
        for (int i = 1; i < 4; i++) {
            Tile c;
            for (int j = 0; j < 4; j++) c[j] = b[(i+j)%4];
            if (c < a) a = c;
        }
    };
    auto type = [&](Tile &a) {
        if (a[0] == a[2] && a[1] == a[3]) {
            if (a[0] == a[1]) return 4;
            else return 2;
        }
        return 1;
    };
    vector<Tile> v(n);
    map<Tile, long long> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 4; j++) cin >> v[i][j];
        normalize(v[i]); m[v[i]]++;
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        m[v[i]]--;
        for (int j = i+1; j < n; j++) {
            m[v[j]]--;
            for (int r = 0; r < 4; r++) {
                vector<Tile> w;
                long long curr = 1;
                for (int c = 0; c < 4; c++) {
                    Tile a = {v[i][(c+1)%4], v[i][c], v[j][(r-c+5)%4], v[j][(r-c+4)%4]};
                    normalize(a); w.emplace_back(a);
                    curr *= m[a] * type(a);
                    m[a]--;
                    if (curr == 0) break;
                }
                for (auto &x: w) m[x]++;
                ans += curr;
            }
            m[v[j]]++;
        }
        m[v[i]]++;
    }
    cout << ans / 3 << "\n";
    return 0;
}

Measured memory_bytes: 20224
def f(n, x):
    if n == 0:
        return 1
    len_ = 2**(n+1) - 3
    num = 2**(n) - 1
    if x == 1:
        return 0
    elif x <= len_ + 1:
        return f(n-1, x-1)
    elif x == len_ + 2:
        return num + 1
    elif x <= (len_ + 1) * 2:
        return num + 1 + f(n-1, x-len_-2)
    else:
        return num * 2 + 1

n, x = map(int, input().split())

print(f(n,x))


Measured memory_bytes: 3060
#ifdef __APPLE__
    # include <iostream>
    # include <cmath>
    # include <algorithm>
    # include <stdio.h>
    # include <cstdint>
    # include <cstring>
    # include <string>
    # include <cstdlib>
    # include <vector>
    # include <bitset>
    # include <map>
    # include <queue>
    # include <ctime>
    # include <stack>
    # include <set>
    # include <list>
    # include <random>
    # include <deque>
    # include <functional>
    # include <iomanip>
    # include <sstream>
    # include <fstream>
    # include <complex>
    # include <numeric>
    # include <immintrin.h>
    # include <cassert>
    # include <array>
    # include <tuple>
    # include <unordered_map>
    # include <unordered_set>
    # include <thread>
#else
    # include <bits/stdc++.h>
#endif

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back
#define fir first
#define sec second

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;

const int max_n = -1, inf = 1000111222;

int main() {
//    freopen("barik.in", "r", stdin);
//    freopen("barik.out", "w", stdout);

    int n;
    map<string,int> cnt;
    cin>>n;
    for (int i=0;i<n;i++){
        string s;
        cin>>s;
        cnt[s]++;
    }
    cout<<"AC x "<<cnt["AC"]<<"\n";
    cout<<"WA x "<<cnt["WA"]<<"\n";
    cout<<"TLE x "<<cnt["TLE"]<<"\n";
    cout<<"RE x "<<cnt["RE"]<<"\n";
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string pos[100010] = {};
    ll lv = 0, rv = N-1;
    cout << 0 << endl;
    cin >> pos[0];
    if(pos[0] == "Vacant") return 0;
    cout << N-1 << endl;
    cin >> pos[N-1];
    if(pos[N-1] == "Vacant") return 0;
    while(rv - lv > 1){
        ll mid = (lv + rv) / 2;
        cout << mid << endl;
        cin >> pos[mid];
        if(pos[mid] == "Vacant") return 0;
        if(pos[mid] == pos[lv]){
            if((mid - lv - 1) % 2 == 0){
                rv = mid;
            }else{
                lv = mid;
            }
        }else{
            if((mid - lv - 1) % 2 == 0){
                lv = mid;
            }else{
                rv = mid;
            }
        }
    }

}


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

#define PI acos(-1)
#define hell 1000000007
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define mset(a,n) memset(a,n,sizeof a)
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define renn(i,a,b,p) for(__typeof((a) i=(a);i>=(b);i-=p)
#define ADD(a,b,c) ((a)%c+(b)%c)%c
#define SUB(a,b,c) ((a)%c-(b)%c+c)%c
#define MUL(a,b,c) (((a)%c)*((b)%c))%c
#define lbd lower_bound
#define ubd upper_bound
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
#define endl "\n"
#define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define line cout<<endl
#define bug(n) {outl(n);return;}
#define N 200005
ll n,a[N],x,y;
set<ll> s;
map<ll,ll> f;
void solve(){
    cin>>n;
    rep(i,1,n+1)cin>>a[i],s.insert(a[i]),f[a[i]]++;
    auto it=s.end();it--;
    x=*it;
    it--;
    if(sz(s)!=1)y=*it;
    else{
        rep(i,1,n+1)outl(x);
        return;
    }
    rep(i,1,n+1){
        if(a[i]==x){
            if(f[x]>1)outl(x);
            else outl(y);
        }else outl(x);
    }
}
void prep(){
    
}
int main(){
    io;
    ll t=1;
    // cin>>t;
    prep();
    fix(12);
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 16128