akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n,i,j,k,l,m;
    cin >> n;
    if(n<=26){
        cout << (char)('a' + n - 1)<<"\n";
    }
    else{
        ll sum = 26;
        ll gun = 26;
        ll cnt = 2;
        while(1){
            gun *= 26;
            if(sum+gun<n){
                sum = sum + gun;
            }
            else{
                break;
            }
            cnt++;
        }
        ll baki = n - sum;
        baki--;
        deque<char> ans;
        ll gun1 = 1;
        //cout << baki << "\n";
        for (i = 1; i <= cnt;i++){
            ll kotobar = baki / gun1;
            kotobar %= 26;
            ans.push_front(kotobar + 'a');
            gun1 *= 26;
            //gun1 *= 26;
        }
        for(auto x:ans)
            cout << x;
        cout << "\n";
    }
    return 0;
}

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

#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define pii pair<int, int>
#define pb push_back
#define vec vector
#define beg begin
#define dbg(x) cerr << #x << " = " << x << endl;

template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}

template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i;
    }
    return str;
}

template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}

template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}

void solve(); signed main() {
#ifdef LOCAL
    freopen("C:\\Users\\artma\\CLionProjects\\problems\\input.txt", "r", stdin);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();
    return 0;
}

const int MOD = 1e9 + 7, MAXN = 1e6 + 10, INF = 1e18 + 10, BASE = 37;

void solve() {
    string s;
    cin >> s;
    vec<string> mask = {"dream", "dreamer", "erase", "eraser"};
    vec<int> dp(sz(s) + 1);
    dp[0] = 1;

    for (int i = 1; i <= sz(s); ++i) {
        for (auto msk : mask) {
            if (sz(msk) <= i) {
                string tmp = s.substr(i - sz(msk), sz(msk));
                if (tmp == msk && dp[i - sz(msk)]) {
                    dp[i] = 1;
                }
            }
        }
    }

    cout << (dp[sz(s)] ? "YES" : "NO") << endl;
}

Measured memory_bytes: 4184
import java.util.Scanner;

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


    public static void main(String[] args) {
        int h = sc.nextInt();
        int w = sc.nextInt();
        int[][] matrix = new int[h + 2][w + 2];
        for (int i = 1; i < h + 1; i++) {
            char[] arr = sc.next().toCharArray();
            for (int j = 1; j < w + 1; j++) {
                int val;
                if (arr[j - 1] == '.') {
                    val = 0;
                } else {
                    val = -1;
                }
                matrix[i][j] = val;
            }
        }
        for (int i = h + 1; i > 0; i--) {
            for (int j = w + 1; j > 0; j--) {
                if (matrix[i][j] == -1) {
                    if (matrix[i][j - 1] >= 0) {
                        matrix[i][j - 1]++;
                    }
                    if (matrix[i][j + 1] >= 0) {
                        matrix[i][j + 1]++;
                    }
                    if (matrix[i - 1][j - 1] >= 0) {
                        matrix[i - 1][j - 1]++;
                    }
                    if (matrix[i - 1][j] >= 0) {
                        matrix[i - 1][j]++;
                    }
                    if (matrix[i - 1][j + 1] >= 0) {
                        matrix[i - 1][j + 1]++;
                    }
                    if (matrix[i + 1][j - 1] >= 0) {
                        matrix[i + 1][j - 1]++;
                    }
                    if (matrix[i + 1][j] >= 0) {
                        matrix[i + 1][j]++;
                    }
                    if (matrix[i + 1][j + 1] >= 0) {
                        matrix[i + 1][j + 1]++;
                    }
                }
            }
        }
        for (int i = 1; i < h + 1; i++) {
            for (int j = 1; j < w + 1; j++) {
                if (matrix[i][j] == -1) {
                    System.out.print('#');
                } else {
                    System.out.print(matrix[i][j]);
                }
            }
            System.out.println();
        }
    }
}


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

vector<int> G[150000];
double sum1[150000];
double sum2[150000];
double dp1[150000];
double dp2[150000];
double M[150000];
double ans[150000];

double dfs1(int v, int p){
	M[v] = G[v].size();
	if(p != -1) M[v]--;
	if(M[v] == 0) return 0;

	for(auto c : G[v]){
		if(c == p) continue;
		sum1[v] += dfs1(c, v) + 1;
	}
	return dp1[v] = sum1[v] / M[v];
}

void dfs2(int v, int p){
	for(auto c : G[v]){
		if(c == p) continue;
		sum2[v] += dp1[c] + 1.0;
	}
	if(p != -1){
		if(G[p].size() != 1){
			sum2[v] += (sum2[p] - (dp1[v] + 1.0)) / (G[p].size() - 1) + 1.0;
		}
		else{
			sum2[v] += 1.0;
		}
	}
	ans[v] = sum2[v] / G[v].size();
	for(auto c : G[v]){
		if(c == p) continue;
		dfs2(c, v);
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N;
	cin >> N;
	for(int i = 0; i < N - 1; i++){
		int a, b;
		cin >> a >> b;
		a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	dfs1(0, -1);
	dfs2(0, -1);
	for(int i = 0; i < N; i++){
		cout << fixed << setprecision(15) << ans[i] << endl;
	}
}


Measured memory_bytes: 21632
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

x, n = map(int, input().split())
p = list(map(int, input().split()))
i = 0
while True:
    if not (x - i) in p:
        print(x - i)
        sys.exit()
    elif not (x + i) in p:
        print(x + i)
        sys.exit()
    i += 1

Measured memory_bytes: 10456
s=input()
t=input()
ans=len(t)
for i in range(len(s)):
  if i+len(t)>len(s):break
  anss=0
  for j in range(len(t)):
    if t[j]!=s[i+j]:anss+=1
  ans=min(ans,anss)
print(ans)

Measured memory_bytes: 67560
#include <bits/stdc++.h>
using namespace std;
#define N 10005
#define M 1000005 
#define ll long long
#define MOD 1000000007
int n,lcm=1,ans,a[N],p[M],vs[M],inv[M],cnt[M],mx[M];
void sieve(int x)
{
	vs[1]=1;
	for(int i=2;i<=x;++i)
	{
		if(!vs[i]) vs[i]=i,p[++p[0]]=i;
		for(int j=1;i*p[j]<=x;++j)
		{
			vs[i*p[j]]=p[j];
			if(!(i%p[j])) break;
		}
	}
}
int main()
{
	scanf("%d",&n);sieve(1e6);
	for(int i=1;i<=1e6;++i)
		inv[i]=i==1?1:1ll*inv[MOD%i]*(MOD-MOD/i)%MOD;
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		for(int j=a[i];j>1;j/=vs[j])
		{
			++cnt[vs[j]];
			if(cnt[vs[j]]>mx[vs[j]])
				lcm=1ll*lcm*vs[j]%MOD,++mx[vs[j]]; 
		}for(int j=a[i];j>1;j/=vs[j]) --cnt[vs[j]];
	}for(int i=1;i<=n;++i) ans=(ans+1ll*lcm*inv[a[i]]%MOD)%MOD;
	printf("%d\n",ans);return 0;
}

Measured memory_bytes: 16384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.DataInputStream;
import java.util.PriorityQueue;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    CAlchemist solver = new CAlchemist();
    solver.solve(1, in, out);
    out.close();
  }

  static class CAlchemist {

    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();
      PriorityQueue<Double> pq = new PriorityQueue<>();
      for (int i = 0; i < n; ++i) {
        pq.add(in.nextDouble());
      }
      for (int i = 1; i < n; ++i) {
        double first = pq.poll();
        double second = pq.poll();
        pq.add((first + second) / 2.0);
      }
      out.println(pq.poll());
    }

  }

  static interface FastInput {

  }

  static class InputReader implements FastInput {

    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer;
    private int bytesRead;

    public InputReader(InputStream is) {
      din = new DataInputStream(is);
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
    }

    public InputReader(String file_name) throws IOException {
      din = new DataInputStream(new FileInputStream(file_name));
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
    }

    public int nextInt() {
      int ret = 0;
      byte c = read();
      while (c <= ' ') {
        c = read();
      }
      boolean neg = (c == '-');
      if (neg) {
        c = read();
      }
      do {
        ret = ret * 10 + c - '0';
      } while ((c = read()) >= '0' && c <= '9');

      if (neg) {
        return -ret;
      }
      return ret;
    }

    public double nextDouble() {
      double ret = 0, div = 1;
      byte c = read();
      while (c <= ' ') {
        c = read();
      }
      boolean neg = (c == '-');
      if (neg) {
        c = read();
      }

      do {
        ret = ret * 10 + c - '0';
      }
      while ((c = read()) >= '0' && c <= '9');

      if (c == '.') {
        while ((c = read()) >= '0' && c <= '9') {
          ret += (c - '0') / (div *= 10);
        }
      }

      if (neg) {
        return -ret;
      }
      return ret;
    }

    private void fillBuffer() {
      try {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
      } catch (IOException e) {
        throw new RuntimeException("trying to read from null input, verify constraints ");
      }
      if (bytesRead == -1) {
        buffer[0] = -1;
      }
    }

    private byte read() {
      if (bufferPointer == bytesRead) {
        fillBuffer();
      }
      return buffer[bufferPointer++];
    }

  }
}



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

ll gcd(ll x, ll y){
	while(1){
		if(x < y) swap(x, y);
		if(!y) break;
		x %= y;
	}
	return x;
}

int main(){
	int n, k, ans = 0; cin >> n >> k;
	int h[n];
	for(int i=0; i<n; i++){
		cin >> h[i];
		if(h[i] >= k) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
 
 
int main(){
    double R; cin >> R;
 
    cout << 2 * R * 3.141592 << endl;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

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

  if(a >= 10 || b >= 10) cout << -1;
  else cout << a*b;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
P = tuple(map(float, input().split()))

dp = np.zeros(N + 1, dtype=float)
dp[0] = 1

for p in P:
    newDP = dp * (1-p)
    newDP[1:] += dp[:-1] * p
    dp = newDP

n = (N + 1) // 2
ans = dp[n:].sum()
print(ans)


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

int main() {
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }
  
  else{
    cout << "consonant" << endl;
  }
}


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

typedef pair<int, int> Point;

int main(void) {
    int H, W;
    int wall = 0;
    char s[50][50];
    int d[50][50];
    int dir_x[4] = {-1, 0, 1, 0};
    int dir_y[4] = {0, -1, 0, 1};

    cin >> H >> W;
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            cin >> s[h][w];
            if (s[h][w] == '#') wall++;
            d[h][w] = 0;
        }
    }

    int width = W - 1;
    int height = H - 1;
    queue<Point> que;
    que.push(make_pair(0, 0));
    d[0][0] = 1;

    while (!que.empty()) {
        Point p = que.front();
        que.pop();

        if (p.first == width && p.second == height) {
            break;
        }

        for (int i = 0; i < 4; i++) {
            int x = p.first + dir_x[i];
            int y = p.second + dir_y[i];

            if (x >= 0 && y >= 0 && x < W && y < H && s[y][x] != '#' && d[y][x] == 0) {
                que.push(make_pair(x, y));
                d[y][x] = d[p.second][p.first] + 1;
            }
        }
    }

    if (d[height][width] == 0) {
        cout << -1 << endl;
    }
    else {
        cout << H * W - wall - d[height][width];
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }




void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
        if (a[i] % 2) {
            cout << 0 << endl;
            return;
        }
    }
    rep(i, n) a[i] /= 2;
    
    int g = a[0];
    rep3(i, 1, n) g = gcd(g, a[i]);
    rep(i, n) a[i] /= g;
    m /= g;
    
    rep(i, n) if (a[i] % 2 == 0) { cout << 0 << endl; return; }
    
    ll l = 1;
    rep(i, n) {
        l = lcm(l, 1LL * a[i]);
        if (l > m) {
            cout << 0 << endl;
            return;
        }
    }
    
    ll cnt = m / l;
    cout << cnt / 2 + (cnt % 2) << endl;
}



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}





Measured memory_bytes: 640
def main():
    n,m=map(int,input().split())
    if n%2==1:
        x=[f"{i+1} {n-i}" for i in range(m)]
        print(" ".join(x))
    else:
        x=[f"{i+1} {n-i}" if i<m/2 else f"{i+1} {n-i-1}" for i in range(m)]
        print(" ".join(x))

if __name__ == "__main__":
    main()

Measured memory_bytes: 17372
// Created by sz
#include <bits/stdc++.h>
using namespace std;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin>>n;
    vector<int> a(n);
    int sum = 0;
    for(int i = 0; i< n;i++){cin>>a[i];sum+= a[i];}
    
    int avg = sum/n;
    int less_avg = avg-1, more_avg = avg + 1;
    
    int sum_avg = 0, sum_le = 0, sum_mo = 0;
    for(int i = 0; i < n; i++){
        sum_avg += (a[i] - avg)*(a[i] - avg);
        sum_le +=(a[i] - less_avg)*(a[i] - less_avg);
        sum_mo +=(a[i] - more_avg)*(a[i] - more_avg);
    }
    cout<<min(min(sum_avg, sum_mo), sum_le)<<endl;
    
    
    
    return 0;
}


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

int main()
{
    int A,B,i; int C[100]; int mysum=0;int mycount=1;
    cin>>A>>B;
    for(i=0;i<A;i++){scanf("%d",&C[i]);}
    for(i=0;i<A;i++)
    {mysum+=C[i];if(mysum>B){break;}
        mycount++;}
    cout<<mycount<<endl;return 0;
}


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

ll solve(int N, int K, vector<int> P, vector<int>C) {
  vector<vector<int> > loops = {};
  vector<ll> sum = {};
  bitset<5000> flag_check;
  ll max_score = LLONG_MIN;

  REP (i, N) {
    if (flag_check[i]) continue;
    int next = P.at(i) - 1;
    ll tmp_sum = 0;
    vector<int> tmp_vec = {};
    while (true) {
      if (flag_check[next]) break;
      flag_check.set(next);
      tmp_vec.push_back(next);
      tmp_sum += C.at(next);
      next = P.at(next) - 1;
    }
    loops.push_back(tmp_vec);
    sum.push_back(tmp_sum);
  }

  REP (i, loops.size()) {
    vector<int> v = loops.at(i);
    int size = v.size();

    // for (auto i : v) {
    //   cout << C.at(i) << ", ";
    // }
    // cout << endl;

    ll max_all = LLONG_MIN;
    ll max_limit = LLONG_MIN;
    REP (j, size) {
      ll tmp_sum = 0;
      int next = v.at(j);
      REP (k, size) {
        tmp_sum += C.at(next);
        if (k < K % size) {
          max_limit = max(max_limit, tmp_sum);
        }
        max_all = max(max_all, tmp_sum);
        next = P.at(next) - 1;
      }
    }
    ll sum_v = sum.at(i);
    // cout << sum_v << ", " << size << endl;
    // cout << "max_all: " << max_all << endl;
    // cout << "max_limit: " << max_limit << endl;
    ll max_v;
    if (sum_v > 0) {
      max_v = max(sum_v * (K / size) + max_limit, sum_v * (K / size - 1) + max_all);
    } else {
      max_v = max(max_limit, max_all);
    }
    // cout << max_v << endl;
    max_score = max(max_score, max_v);
  }

  return max_score;
}

int main() {
  IN(int, N);
  IN(int, K);
  vector<int> P(N);
  vector<int> C(N);
  vector<int> sumv(N);
  long long sum = 0;
  REP(i, N) {
    cin >> P.at(i);
  }
  REP(i, N) {
    cin >> C.at(i);
    sum += C.at(i);
  }

  cout << solve(N, K, P, C) << endl;;

  return 0;
}


Measured memory_bytes: 3752
N, K = map(int, input().split())
tree = [0]*N
for i in range(N):
    tree[i] = int(input())
tree = sorted(tree)
#print(tree)
ans = 10**9
for j in range(N - K+1):
    sa = tree[j + K-1] - tree[j]
    if sa < ans:
        ans = sa
print(ans)


Measured memory_bytes: 8240
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let x: i64 = input();
    let y: i64 = input();
    println!(
        "{}",
        (0..)
            .scan(x, |acc, _| {
                let t = Some(*acc);
                *acc *= 2;
                t
            })
            .take_while(|&i| i <= y)
            .count()
    );
}


Measured memory_bytes: 4352
let pn = 1000000007

let pow x n =
  let rec doit i acc =
    if i = n then acc
    else doit (i + 1) (acc*x)
  in doit 0 1

let str_fold_left f init s =
  let n = String.length s in
  let rec doit i acc =
    if i = n then acc
    else doit (i + 1) (f acc s.[i])
  in doit 0 init

let () =
  let p = read_line () in
  let t = read_line () in
  let n = String.length p in
  let m = String.length t in
  let h = Array.make (n + 1) 0 in
  String.iteri (fun i c -> h.(i+1) <- h.(i)*pn + Char.code c) p;
  let ht = str_fold_left (fun acc c -> acc*pn + Char.code c) 0 t in
  let x = pow pn m in
  let rec doit i =
    if i <= n then begin
      if h.(i) - h.(i-m)*x = ht then Printf.printf "%d\n" (i - m);
      doit (i + 1)
    end in
  doit m

Measured memory_bytes: 2292
def resolve():
    s = int(input())
    ans = [s]
    count = 0
    while True:
        if ans[count]%2 == 0:
            ans.append(ans[count]//2)
        else:
            ans.append(ans[count]*3+1)
        count += 1
        for i in range(count):
            if ans[i] == ans[count]:
                print(count+1)
                exit()
resolve()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;



int main(){
   int a,b,c,d;
   cin >> a >> b >> c >> d;
   int high = max(a,c);
   int low = min(b,d);
   if(high > low){
      cout << "0" << endl;
   }
   else{
      cout << low - high << endl;
   }

}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }


int n, t;
int a[3005];
ll b[3005];
ll dp[3005][3005], dp2[3005][3005];
void solve() {
    cin >> n >> t;

    reps(i, n) cin >> a[i] >> b[i];

    reps(i, n) rep(j, t) {
        if (j < a[i]) maxs(dp[i][j], dp[i - 1][j]);
        else maxs(dp[i][j], dp[i - 1][j - a[i]] + b[i], dp[i - 1][j]);
    }

    repds(i, n) rep(j, t) {
        if (j < a[i]) maxs(dp2[i][j], dp2[i + 1][j]);
        else maxs(dp2[i][j], dp2[i + 1][j - a[i]] + b[i], dp2[i + 1][j]);
    }

    ll ans = 0;
    reps(i, n) rep(j, t) {
        maxs(ans, dp[i - 1][j] + dp2[i + 1][t - 1 - j] + b[i]);
    }

    cout << ans << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 141312
#include <stdio.h>

int main(void){
    // Here your code !
    int a,b;
    
    scanf("%d %d",&a,&b);
    
    if(a == b){
        printf("Draw\n");
    }else if(a == 1){
        printf("Alice\n");
    }else if(b == 1){
        printf("Bob\n");
    }else if(a > b){
        printf("Alice\n");
    }else{
        printf("Bob\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl 	"\n"

typedef vector< ll > 	vi;
typedef vector< vi > 	vvi;
typedef pair< ll,ll > 	ii;

#define pb 		push_back
#define all(c) 		(c).begin(),(c).end()
#define present(c,x) 	((c).find(x) != (c).end())
#define rep(i,n)        for(ll i=0LL; i<(n); i++)

#define MOD 	1000000007
#define INF 	(int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))

//Maths functions
ll Digit(ll N){ll res=0;while(N) res++, N/=10;return res;}
ll Gcd(ll a,ll b){ return b?Gcd(b,a%b):abs(a); }


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

	ll a[4][4];
	rep(i,3){
		rep(j,3)
			cin>>a[i][j];
	}

// rep(i,3){
// 		rep(j,3)
// 		cout<<a[i][j]<<" ";
// 		cout<<endl;
// 	}

	ll b[3][3] ={0};

	ll t;
	cin>>t;
	ll x;
	while(t--){
		cin>>x;
		for(ll j=0; j<3; j++)
		{
			for(ll k=0; k<3; k++)
			{
				if(x == a[j][k])
					b[j][k]=1;
			}
		}
	}

	// rep(i,3){
	// 	rep(j,3)
	// 	cout<<b[i][j]<<" ";
	// 	cout<<endl;
	// }

	//bool flag=false;

		for(ll i=0; i<3; i++)
		{
			if(b[i][0]==b[i][1] && b[i][1]==b[i][2] && b[i][1]==1)
				{  cout<<"Yes";  return 0; }
		}

		for(ll i=0; i<3; i++)
		{
			if(b[0][i]==b[1][i] && b[1][i]==b[2][i] && b[1][i]==1)
				{  cout<<"Yes";  return 0; }
		}
		
		if(b[0][0]==b[1][1] && b[1][1] == b[2][2] && b[1][1]==1)
		{
			cout<<"Yes"; return 0;
		}

		if(b[0][2]==b[1][1] && b[1][1] == b[2][0] && b[1][1]==1)
		{
			cout<<"Yes"; return 0;
		}

		cout<<"No";



	return 0;
}

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

int main(void){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int ans1 = A * B;
  int ans2 = C * D;
  if(ans1 >= ans2)
    cout << ans1 << "\n";
  else
    cout << ans2 << "\n";
  return 0;
}


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

using namespace std;

#define ll long long
#define pb push_back
#define vi vector<int>
#define bn(n) (n).begin(), (n).end()
#define FOR(n) for(int i = 0; i < (int)n; i++)


void solve() {
    string s;
    cin >> s;
    while(s.find('B') != string::npos) {
        if (s.find('B') != 0) {
            s.erase(s.find('B')-1, 2);
        } else {
            s.erase(s.find('B'), 1);
        }
    }
    cout << s << "\n";
}

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

    int t = 1, i = 1;
    //cin >> t;
    while(t--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


Measured memory_bytes: 3588
# coding: utf-8


def main():
    n, k = map(int, input().split())

    div_k = n // k  # 1からnの %k == 0 の個数

    # 1からnの %k == k/2 の個数
    if k % 2 == 0:
        div_k_harf = n // (k // 2) - div_k
    else:
        div_k_harf = 0

    print(div_k ** 3 + div_k_harf ** 3)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define scanArray(a,n) for(int i = 0; i < n; i++){cin >> a[i];}
using namespace std;

int main()
{
    string S;cin>>S;
    int c;
    c = S.size();
    if (S.at(c-1)=='s'){cout<<S<<"es";}
    else {cout<<S<<"s";}
    return 0;
}


Measured memory_bytes: 3628
/*
    author: Salam_35
    Created at :

*/

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

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF    1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() int testsalam;cin >> testsalam;while(testsalam--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
#define endl '\n'
//void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}
string inttostr(ll n){std::stringstream ss;ss << n;string out=ss.str();return out;}
ll stringtoint(string s){istringstream iss (s);ll n;iss >> n;return n;}
typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

int main()
{
   ll a,b;
  cin >> a>> b;
  cout<<a*b<<endl;
}


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

void print_arr(int data[], int n)
{
	cout<<"Printing array: ";
	for(int i=0; i<n; i++)
	{
		cout<<data[i]<<" ";
	}
	cout<<endl;
}
template <typename T>
void print_vec(vector<T> data)
{
	cout<<"Printing vector: ";
	for(int i=0; i<data.size(); i++)
	{
		cout<<data[i]<<" ";
	}
	cout<<endl;
}
int main()
{
	int n;
	cin>>n;
	int data[n][3], dp[n][3];
	for(int i=0; i<n; i++) cin>>data[i][0]>>data[i][1]>>data[i][2];
	rep(i, 0, 3) dp[0][i]=data[0][i];
	rep(i, 1, n)
	{
        dp[i][0] = data[i][0] + max(dp[i-1][1] , dp[i-1][2]);
        dp[i][1] = data[i][1] + max(dp[i-1][0] , dp[i-1][2]);
        dp[i][2] = data[i][2] + max(dp[i-1][1] , dp[i-1][0]);
	}
	//dp[i][0] represents the maximum score if we take a[i](optimize the past). Similarly for dp[i][1] we have to take b[i]
	cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<endl;
} 

Measured memory_bytes: 2560
chomp(my $n = <STDIN>);
my ($a, $b) = split(/\s/, <STDIN>);
my @p = split(/\s/, <STDIN>);

my ($x,$y,$z) = (0,0,0);
for (@p) {
    if ($_ <= $a) { $x++; }
    elsif ($_ <= $b) { $y++; }
    else { $z++; }
}

my @e = sort($x, $y, $z);
print "$e[0]\n";


Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;
#define mp make_pair
#define pb push_back
#define INF 2100000000
struct se1{
	int to,cost;
	se1(int a,int c):to(a),cost(c){}
};
struct se2{
	int to,time;
	se2(int a,int c):to(a),time(c){}
};
int d[105];
int V;
vector<se1>G[105];
vector<se2>GG[105];
void dijkstra1(int s){
	priority_queue<P,vector<P>,greater<P> > pque;
	fill(d,d+(V+1),INF);
	d[s]=0;
	pque.push(mp(0,s));
	while(!pque.empty()){
		P p=pque.top(); pque.pop();
		int v=p.second;
		if(d[v]<p.first) continue;
		for(int i=0;i<G[v].size();i++){
			se1 q=G[v][i];
			if(d[q.to]>d[v]+q.cost){
				d[q.to]=d[v]+q.cost;
				pque.push(mp(d[q.to],q.to));
			}
		}
	}
}
void dijkstra2(int s){
	priority_queue<P,vector<P>,greater<P> > pque;
	fill(d,d+(V+1),INF);
	d[s]=0;
	pque.push(mp(0,s));
	while(!pque.empty()){
		P p=pque.top(); pque.pop();
		int v=p.second;
		if(d[v]<p.first) continue;
		for(int i=0;i<GG[v].size();i++){
			se2 q=GG[v][i];
			if(d[q.to]>d[v]+q.time){
				d[q.to]=d[v]+q.time;
				pque.push(mp(d[q.to],q.to));
			}
		}
	}
}
int n;
int main(){
	while(1){
		for(int i=0;i<105;i++){
			G[i].clear();
			GG[i].clear();
		}
	scanf("%d %d",&n,&V);
	if(!n) break;
	for(int i=0;i<n;i++){
		int ax,ay,bx,by;
		scanf("%d %d %d %d",&ax,&ay,&bx,&by);
		G[ax].pb(se1(ay,bx));
		G[ay].pb(se1(ax,bx));
		GG[ax].pb(se2(ay,by));
		GG[ay].pb(se2(ax,by));
	}
	int Q;
	scanf("%d",&Q);
	for(int i=0;i<Q;i++){
		int rp,er,ep;
		scanf("%d %d %d",&rp,&er,&ep);
		if(ep==0){
			dijkstra1(rp);
			printf("%d\n",d[er]);
		}else{
			dijkstra2(rp);
			printf("%d\n",d[er]);
		}
	}
}
}

Measured memory_bytes: 1156
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  int a, min = 100, max = 1;

  for (size_t i = 0; i < 3; i++) {
    cin >> a;
    if (a < min) {
      min = a;
    }
    if (a > max) {
      max = a;
    }
  }

  cout << max - min << endl;

  return 0;
}


Measured memory_bytes: 256
import math
import numpy as np
N = int(input())
A = np.array(list(input().split()))
B = np.array(list(input().split()))
a = 0
b = 0 
for i in range(N):
    arank = np.where(A[i:].argsort()==0)[0]
    brank = np.where(B[i:].argsort()==0)[0]
    a += arank*math.factorial(N-(i+1))
    b += brank*math.factorial(N-(i+1))
    #print(a,b,arank,brank,A[i:].argsort(),B[i:].argsort())
print(int(abs(a-b)))

Measured memory_bytes: 12488
#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;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans = 0;
  rep(i, n) ans += a[i] - 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define sz(x)             (int)x.size()
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*(b/gcd(a,b)))
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
#define watch(x)         cout << #x << " = " << x << endl
#define trace(x)         cerr << #x << " = " << x << endl
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){
    
	string s; cin>>s;
	int n = len(s);
	int a[n+1] = {0}, b[n+1] = {0};
	for(int i = 1;i<=n;i++){
		if(s[i-1]=='<')	a[i] = a[i-1] + 1;
		//else a[i] = a[i-1];
	}
	for(int i = n-1;i>=0;i--){
		if(s[i]=='>') b[i] = b[i+1] + 1;
		//else b[i] = b[i+1];
	}
	int sum = 0;
	for(int i = 0;i<=n;i++) sum += max(a[i],b[i]);
	cout<<sum;
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 11684
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n,m;
    cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#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 int MOD = 1e9 + 7;

string A;
int N, ans = 0;



int main(void) {


	cin >> A;

	int n = A.length();
	int cnt = 0;
	FOR(i, 0, n) {
		if (A[i] == 'A' || A[i] == 'C' || A[i] == 'G' || A[i] == 'T')cnt++;
		else {
			if (cnt > ans)ans = cnt;
			cnt = 0;
		}
	}
	ans = max(cnt, ans);
	ct(ans);

	return 0;
}

Measured memory_bytes: 256
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons;
const dx = [1,0,-1,0];
const dy = [0,1,0,-1];
void read(T...)(auto ref T args){ 
	auto line = readln().split(); 
	foreach(i,ref arg; args) arg = line[i].to!(typeof(arg));
}
int sum(int n){return n * (n + 1)/ 2;}

void main(){
	int x,y,s;
	while(read(x,y,s),x|y|s){
		int ans ;
		auto taxed= iota(s).map!(i => tax(x,i)).array.assumeSorted;
		foreach(i;1..s){			
			foreach(j;i..s){
				if (taxed[i] + taxed[j] == s ){
					ans = max(ans,tax(y,i) + tax(y,j));break;
				}
			}
		}
		ans.writeln;
	}
}
int tax(int per,int yen) {return yen * (100 +per) / 100;}

Measured memory_bytes: 2852
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include<numeric>
using namespace std;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;


int main(){
    int a,b,c; cin >> a >>b>>c;
    if(a==b && a==c){
        cout << "No" << endl;
    }else if(a==b || a ==c || b ==c){
        cout << "Yes" << endl;
    }else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;

	dunk(max(a - 2 * b, 0));

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// clang-format off
#define FOR(i, n) for (int i=0; i<(int)n; ++i)
#define RFOR(i, n) for (int i=n-1; i>=0; --i)
#define FORR(x,arr) for(auto& x:arr)
#define OUTV(x) FOR(j,x.size()) cerr<<x[j]<<(x.size()-j-1?' ':'\n');
#define OUTM(x) FOR(i,x.size()) {OUTV(x[i])}
#define DEBUG(x) cerr<<"DEBUG: "<<#x<<" = "<<x<<endl;
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
using namespace std;
typedef signed long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
// clang-format on

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  // std::random_device rd;
  //  std::mt19937 ran(rd());

  int n;
  cin >> n;

  vi v(n), c(n);
  FOR(i,n) cin >> v[i];
  FOR(i,n) cin >> c[i];
  

  int ans = 0;
  for(int i = 0; i <= (1 << n); ++i){
    int j = i;
    int X = 0, Y = 0;
    int pos = 0;
    while(j){
      if(j&1){
        X += v[pos];
        Y += c[pos];
      }
      j /= 2;
      pos++;
    }
    ans = max(ans, X-Y);

  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())

B = list(map(int,input().split()))

ans = 0
tmp_b = 0

tmp_b = B[0]
for b in B:
    max_a = min(tmp_b,b)
    ans += max_a 
    tmp_b = b

max_a = B[-1]
ans += max_a

print(ans)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int a, b, x;
  cin >> a >> b >> x;
  if (x >= a && (a + b) >= x) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

typedef long long ll;

const ll N = 110;

ll t;
bool h[N];
ll n, x;


int main() {
	cin >> x >> n;
	for (ll i = 0; i < n; i++) cin >> t, h[t] = true;

	t = 0;
	while (true) {
		if (!h[x - t]) {
			cout << x - t << endl;
			break;
		}
		if (!h[x + t]) {
			cout << x + t << endl;
			break;
		}

		t++;
	}

	return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>

char prime[10001];

void setprime(int max){
    int i,j;

    for(i=4;i <= max;i +=2){
        prime[i] = 1;
    }
    for(i = 3; i*i <= max;i += 2){
        if(prime[i] == 0){
            for(j = i*2;j<=max;j+=i){
                prime[j]=1;
            }
        }
    }
}

int main(void){
    int n,i;
    setprime(10001);
    while(scanf("%d",&n),n){
        for(i=n;i >= 2;i--){
            if(prime[i]+prime[i-2] == 0){
                printf("%d %d\n",i-2,i);
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 608
integer N
integer,allocatable,dimension(:)::x,y
integer p,q
integer ans,preans
read*,N
allocate(x(N),y(N))
do i=1,N
  read*,x(i),y(i)
end do

ans=N
do i=1,N
  do j=1,N
    if(i==j)cycle
    p=x(i)-x(j)
    q=y(i)-y(j)
    preans=N
    do ii=1,N
      do jj=1,N
        if(x(ii)+p==x(jj).and.y(ii)+q==y(jj))preans=preans-1
      end do
    end do
    ans=min(ans,preans)
  end do
end do

print"(i0)",ans

end

Measured memory_bytes: 640
n = int(input())
h = list(map(int, input().split()))
ans = 0
s = 0
c = h[0]
for i in h[1:]:
    if c >= i:
        s += 1
    else:
        ans = max(ans, s)
        s = 0
    c = i
ans = max(ans, s)
print(ans)

Measured memory_bytes: 14252
#include <cstdio>
#include <string>
#include <set>
#include <cstring>

using namespace std;

set<string> st;

void maintain(){
  set<string> tempst = st;

  st.clear();
  auto itr = tempst.begin();
  for(int i=0; i < 5 && itr != tempst.end(); i++){
    st.insert(*itr);
    itr++;
  }

}

int main(){
  char str[5001];
  int k;
  scanf("%s", str);
  scanf("%d", &k);
  // for(int i=0; str[i] != '\0'; i++){
  //   printf("%c", str[i]);
  // }
  // printf("!\n");

  int n = strlen(str);
  

  for(int i=1; i <= 5; i++){
    for(int j=0; str[j] != '\0'; j++){
      if(j + (i - 1) >= n){
        break;
      }
      st.insert(string(str + j, i));
    }
      
    maintain();
  }
  
  int i = 0;
  for(auto itr=st.begin(); itr != st.end(); itr++){
    if(i == k - 1){
      printf("%s\n", itr->c_str());
    }
    i++;
  }

  
  return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

    static int MOD = 1_000_000_007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        long ans = 1L;
        if(Math.abs(n - m) <= 1){
            for(int i = 1; i <= n; i++) ans = ans * i % MOD;
            for(int i = 1; i <= m; i++) ans = ans * i % MOD;
            if(n == m) ans = ans * 2 % MOD;
        }else{
            ans = 0;
        }

        System.out.println(ans);
        sc.close();
    }

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000000ll;
int n;
long long x;
long long rea[10010],dp[10010];
long long ans = INF;
int getnext(int a,int b)
{
	if(a - b >= 1) return a - b;
	else return a - b + n;
}
int main()
{
	cin >> n >> x;
	for(int i = 1; i <= n; i++)
		cin >> rea[i];
	for(int i = 1; i <= n; i++)
		dp[i] = INF;
	for(int i = 0; i < n; i++)
	{
		long long tmp = 0;
		for(int j = 1; j <= n; j++)
			dp[j] = min(dp[j], rea[getnext(j, i)]), tmp += dp[j];
		ans = min(ans, tmp + i * x);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var D, G int
	fmt.Scan(&D, &G)
	var p [10]int
	var c [10]int
	for i := 0; i < D; i++ {
		fmt.Scan(&p[i], &c[i])
	}
	ans := 1000
	for x := 0; x < (1 << uint(D)); x++ {
		sum := 0
		num := 0
		restMax := -1
		for i := 0; i < D; i++ {
			if (uint(x)>>uint(i))&uint(1) > 0 {
				sum += 100*(i+1)*p[i] + c[i]
				num += p[i]
			} else {
				restMax = i
			}
		}
		if sum < G {
			v := 100 * (restMax + 1)
			howmany := (G - sum + v - 1) / v
			if howmany >= p[restMax] {
				continue
			}
			num += howmany
		}
		ans = min(ans, num)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
  ll N;
  scanf("%lld", &N)+1;
  vector<ll> vll;
  for (int i = 0; i < 5; i++) {
    ll tmp;
    scanf("%lld", &tmp)+1;
    vll.push_back(tmp);
  }
  sort(vll.begin(), vll.end());
  
  printf("%lld", N / vll[0] + 5 - (((N % vll[0]) == 0)?1:0));
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <functional>
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  map<pair<int,int>,int> mp;
  vector<int> cnt2(N,0),cnt5(N,0);
  for(int i=0; i<N; i++){
    string S;
    cin >> S;
    ll x = 0;
    bool ext = false;
    int cnt = 10;
    for(int j=0; j<S.size(); j++){
      if(S[j] == '.'){
        ext = true;
      }else{
        x *= 10;
        x += S[j] - '0';
        if(ext) cnt--;
      }
    }
    for(int j=0; j<cnt; j++){
      x *= 10;
    }
    while(x%2 == 0){
      x /= 2;
      cnt2[i]++;
    }
    while(x%5 == 0){
      x /= 5;
      cnt5[i]++;
    }
    chmin(cnt2[i],20);
    chmin(cnt5[i],20);
    mp[P(cnt2[i],cnt5[i])]++;
  }
  ll ans = 0;
  for(int i=0; i<N; i++){
    for(int j=20-cnt2[i]; j<=20; j++){
      for(int k=20-cnt5[i]; k<=20; k++){
        ans += mp[P(j,k)];
        if(cnt2[i]==j && cnt5[i]==k) ans--;
      }
    }
  }
  cout << ans/2 << "\n";
  return 0;
}

Measured memory_bytes: 4776
#include<stdio.h>

int main(void){
  int len = 0;
  scanf("%d", &len);
  int ind = 0;
  scanf("%d", &ind);
  char str[len];
  scanf("%s", str);
  if(str[ind-1] == 'A'){
    str[ind-1] = 'a';
  }else if(str[ind-1] == 'B'){
    str[ind-1] = 'b';
  }else if(str[ind-1] == 'C'){
    str[ind-1] = 'c';
  }else if(str[ind-1] == 'D'){
    str[ind-1] = 'd';
  }
  int i=0;
  for(i=0;i<len;i++){
    printf("%c", str[i]);
  }
  return 0;
}

Measured memory_bytes: 128
def cube(x):
    i=1
    while(True):
        if i**3 >x:
            return i-1
        else:
            i +=1
            
while(True):
    e = int(input())
    if e==0:
        break
    ans = pow(10,16)    

    z_max = cube(e)
    for z in range(z_max+1):
        y = int(pow(e-z**3,1/2))
    
        ans = min(ans,e-y*y+y-z*z*z+z)
    print(ans)


Measured memory_bytes: 5708