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

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_N = 300000, MAX_M = 100000;
int N, M;
int l[MAX_N], r[MAX_N];

const int DATA_SIZE = 1 << 18;
int n;
ll data1[2*DATA_SIZE-1], data2[2*DATA_SIZE-1]; // data1は区間全てに足される数、data2は区間の一部に足される数の総和。

void init(int n_) {
  n = 1;
  while (n <= n_) n*=2;
  return;
}

// range = [a,b), add = x, node number = k, node range = [l,r)
void update(int a, int b, ll x, int k, int l, int r) {
  if (r <= a || b <= l) return;
  if (a <= l && r <= b) {
    data1[k] += x;
  } else {
    data2[k] += (min(b,r)-max(a,l)) * x;

    int chl = 2*k+1, chr = 2*k+2;
    update(a, b, x, chl, l, (l+r)/2);
    update(a, b, x, chr, (l+r)/2, r);
  }
  return;
}

// range = [a,b), node number = k, node range = [l,r)
ll sum(int a, int b, int k, int l, int r) {
  if (r <= a || b <= l) return 0;
  if (a <= l && r <= b) {
    return data1[k]*(r-l) + data2[k];
  } else {
    ll res = (min(b,r)-max(a,l)) * data1[k];

    int chl = 2*k+1, chr = 2*k+2;
    res += sum(a, b, chl, l, (l+r)/2);
    res += sum(a, b, chr, (l+r)/2, r);
    
    return res;
  }
  return 0;
}

int ans[MAX_M+1];

int main() {
  cin >> N >> M;
  rep(i,N) cin >> l[i] >> r[i];

  vector<pii> v(N);
  rep(i,N) {
    v[i].fi = r[i]-l[i]+1; v[i].sc = i;
  }
  sort(all(v));

  init(M+1);

  for (int d = 1; d <= M; ++d) {
    ans[d] =  v.end() - lower_bound(all(v), pii(d, -1));
    for (vector<pii>::iterator ite = lower_bound(all(v), pii(d-1, -1)); ite != v.end() && ite->fi < d; ++ite) { 
      update(l[ite->sc], r[ite->sc]+1, 1, 0, 0, n); 
    }

    for (int k = 1; k*d <= M; ++k) {
      ans[d] += sum(k*d, k*d+1, 0, 0, n);
    }
  }

  for (int d = 1; d <= M; ++d) printf("%d\n", ans[d]);

  return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a; i<n; i++)
#define ll long long
#define MOD 1000000007
using namespace std;;
 
int main() {
  int N; scanf("%d",&N); 
  printf("ABC%d\n",N);
  
}

Measured memory_bytes: 3788
def bubbeSort(arr):
    for i in range(len(arr)):
        for j in range(len(arr) - 1, i, -1):
            if arr[j][1] < arr[j - 1][1]:
                arr[j], arr[j - 1] = arr[j - 1], arr[j]

def selectSort(arr):
    for i in range(len(arr)):
        Min = i
        for j in range(i, len(arr)):
            if arr[j][1] < arr[Min][1]:
                Min = j
        if i != Min:
            arr[i], arr[Min] = arr[Min], arr[i]

n = int(input())
arr = list(map(str, input().split()))
arr1 = arr[:]
bubbeSort(arr)
selectSort(arr1)
print(*arr)
print("Stable")
print(*arr1)
print(["Not stable", "Stable"][arr == arr1])


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

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

        public static void Solve()
        {
            var nm = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(nm[0] == nm[1] ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13396
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
 
#define $(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) cout << #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("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#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 = 5e5 + 10, INF = 2e9 + 10, BASE = 37; 

void solve() {
    int n;
    cin >> n;
    vec<int> a(n);
    cin >> a;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (i % 2 == 0 && a[i] % 2 == 1) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)a;i<=(sign)b;++i)
#define Fordown(i,a,b) for(register sign i=(sign)a;i>=(sign)b;--i)
const int N=100+5;
bool cmax(sign &a,sign b){return (a<b)?a=b,1:0;}
bool cmin(sign &a,sign b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
  T ans=0,f=1;
  char ch=getchar();
  while(!isdigit(ch)&&ch!='-')ch=getchar();
  if(ch=='-')f=-1,ch=getchar();
  while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
  return ans*f;
}
template<typename T>void write(T x,char y)
{
  if(x==0)
  {
      putchar('0');putchar(y);
      return;
  }
  if(x<0)
  {
      putchar('-');
      x=-x;
  }
  static char wr[20];
  int top=0;
  for(;x;x/=10)wr[++top]=x%10+'0';
  while(top)putchar(wr[top--]);
  putchar(y);
}
void file()
{
  #ifndef ONLINE_JUDGE
      freopen("d.in","r",stdin);
      freopen("d.out","w",stdout);
  #endif
}
int a,b;
char f,d;
void input()
{
	f='.';d='#';
	a=read<int>(),b=read<int>();
	if(a<b)swap(a,b),f='#',d='.';
}
int n=100,m=100;
char s[500][500];
void work()
{
	cout<<n<<' '<<m<<endl;
	For(j,1,100)s[51][j]=f;
	a--;
	int i=1,j=1;
	while(a--)
	{
		s[i][j]=f;
		j+=2;
		if(j>100)i+=2,j=1;
	}
	For(i,1,50)For(j,1,100)if(s[i][j]!=f)s[i][j]=d;
	i=100,j=1;
	b--;
	while(b--)
	{
		s[i][j]=d;
		j+=2;
		if(j>100)i-=2,j=1;
	}
	For(i,51,100)For(j,1,100)if(s[i][j]!=d)s[i][j]=f;
	For(i,1,100)printf("%s\n",s[i]+1);
}
int main()
{
	
	input();
	work();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;  
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define repr(i, a, b) for(ll i = b-1; i >= a; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
// const ll INF = 1LL << 60;
const ll INF = 1000000000;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

// rep(i, 0, sz(v)) cout << v[i] << " \n"[i==sz(v)-1];


////////////////////////////////////////////////////////

ll y[300010], x[300010], vy[300010], vx[300010];

int main() {
    ll H, W, m; cin >> H >> W >> m;
    Vl h(m), w(m);
    rep(i, 0, m){
        cin >> h[i] >> w[i];
        y[h[i]]++, x[w[i]]++;
    } 

    ll yi, xi;
    ll mx_y = 0, mx_x = 0;
    rep(i, 0, 300001) chmax(mx_y, y[i]);
    rep(i, 0, 300001) chmax(mx_x, x[i]);

    ll a = 0, b = 0;
    rep(i, 0, 300001) if(y[i] == mx_y) vy[i]++, a++;
    rep(i, 0, 300001) if(x[i] == mx_x) vx[i]++, b++;

    ll t = a*b;    
    ll ans = mx_y + mx_x - 1;

    rep(i, 0, m){
        if(vy[h[i]] && vx[w[i]]) t--;
    }
    if(t >= 1) co(++ans);
    else co(ans);

    // co(t);
    // for(auto i : vy) cout << i << " ";
    // coel;
    // for(auto i : vx) cout << i << " ";
    // coel;

    // rep(i, 0, sz(vy)) rep(j, 0, sz(vx)){
    //     bool f = true;
    //     rep(k, 0, m){
    //         if(vy[i] == h[k] && vx[j] == w[k]) f = false;
    //     }
    //     if(f){
    //         co(++ans);
    //         return 0;
    //     }
    // }


    return 0;
}
 
 


Measured memory_bytes: 17172
/*
* Welcome to my code!
*---------------------------------------------*
* author : lynmisakura(twitter : @andoreiji11)
*/

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define repn for(int i = 0;i < n;i++)
#define ain(a) for(auto& i : a)cin >> i;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size()) 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define cont continue

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pi = pair<int,int>;
using vpi = vector<pi>;
using pl = pair<ll,ll>;
using vpl = vector<pl>;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
template<class T> void print(std::vector<T> a){ int sz = a.size();
for(int i=0;i<a.size();i++)cout << a[i] << (i < sz-1 ? ' ' : '\n'); }
void ioboost(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}
///////////////////////////////////////////////////////////
int n;
int a[200020];
vi g[200020];
vector<int> dp(200020,INT_MAX);
int ans[200020];

void dfs(int x,int p = -1){
	auto it = lower_bound(all(dp),a[x]);

	int pre = *it;
	int preid = it - dp.begin();

	*it = a[x];
	ans[x] = lower_bound(all(dp),INT_MAX) - dp.begin() - 1;

	for(int i : g[x]){
		if(i != p){
			dfs(i,x);
		}
	}

	dp[preid] = pre;
}

int main(int argc, char const *argv[])
{
	cin >> n;
	rep(i,n)cin >> a[i];
	rep(i,n-1){
		int f,t;cin >> f >> t;
		f--,t--;
		g[f].pb(t);
		g[t].pb(f);
	}
	dfs(0);
	rep(i,n)cout << ans[i] + 1 << '\n';

	return 0;
}

Measured memory_bytes: 27924
/*	MASTER HAS FAILED MORE TIMES
	THAN BEGINNER HAS EVER TRIED
*/

#include <bits/stdc++.h>

using namespace std;

#define endl             '\n'
#define all(a)           a.begin(), a.end()
#define mem(a, n)        memset(a, n, sizeof(a))
#define Unique(n)        (n).erase(unique(all(n)), (n).end())
#define NumofDigits(n)   ((long long)log10(n)+1)
#define repeat(i, a, n)  for(int i=a; i<n; i++)
#define isPowerOfTwo(n)  (n && !(n & (n - 1)))

typedef long long ll;
typedef long double ld;

int sieve(int n);
unsigned long long pow(long long base, long long power);
long long gcd(long long a, long long b){ return a%b ? gcd(b, a%b) : b; }
long long lcm(long long a, long long b){ return a*b/gcd(a, b); }

void quicken(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
void file(){
#ifdef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif /*ONLINE_JUDGE*/
}

int main(){
    quicken();

    vector<int> v(3), a = {5, 5, 7};
    repeat(i, 0, 3) cin >> v[i];

    sort(all(v));
    if(v == a) cout << "YES\n";
    else cout << "NO\n";

    return 0;
}

unsigned long long pow(long long base, long long power){  /// mod?
    if(power==0)
        return 1;
    if(power==1)
        return base;

    unsigned long long ans = pow(base, power/2); /// mod?
    ans *= ans; /// ((ans%mod)*(ans%mod))%mod;

    if(power&1)
        return ans*base; /// ((ans%mod)*(base%mod))%mod;
    return ans;
}

int sieve(int n){
    int c = 0;
    vector<bool> isPrime(n+1, true);
    isPrime[0] = isPrime[1] = 0;

    for(long long i=2; i*i<=n; i++)
        if(isPrime[i])
            for(long long j=i*2; j<=n; j+=i)
                isPrime[j] = 0;
    repeat(i, 0, n+1)
    if(isPrime[i])
        c++;
    return c; /// primeCount [1:n]
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define f(i,a,b) for(ll i=a;i<=b;++i)
#define mod 1000000007
const double pi =3.14159265358979323846;
bool isprime(ll n)
{
    if(n<2) return false;
    for(ll i=2;i*i<=n;++i)
    {
        if(n%i==0) return false;
    }
    return true;
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll a,b; char c; cin>>a>>c>>b;
    if(c=='+') cout<<a+b;
    else cout<<a-b;
    return 0;
}
/**
pair<ll,ll>fib(ll n)
{
    if(n==0) return {0,1};
    pair<ll , ll >p=fib(n/2);
    ll c=p.first*(2*p.second - p.first) ;
    ll d=p.second*p.second + p.first*p.first;
    if(n&1) return {d,c+d};
    else return {c,d};
}
**/
/**
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
**/
/**check for perfect square.
ll is_perfect_square(ll n)
{
    ll tp=floor(sqrt(n));
    if(n==(tp*tp)) return tp;
    else return -1;
}
**/
/**
ll biexp(ll a,ll n)
{
    if(n==0) return 1;
    ll res=1;
    while(n>0)
    {
        if(n%2!=0) res*=a;
        a=a*a;
        n=n/2;
    }
    return res;
}
**/
/** sieve implementation**/
/**
    ll N=1299827; // first 100008 primes;
    vector<ll>lp(N+1,0);
    vector<ll>pr;
    for(ll i=2;i<=N;++i)
    {
        if(lp[i]==0)
        {
            lp[i]=i;
            pr.push_back(i);
        }
        for(ll j=0;j<pr.size() and i*pr[j]<=N ;++j)
        {
            lp[i*pr[j]]=pr[j];
        }
    }
**/
/**
bool isprime(ll n)
{
    if(n<2) return false;
    for(ll i=2;i*i<=n;++i)
    {
        if(n%i==0) return false;
    }
    return true;
}
**/
/**factors in sqrt(n);
    ll N=100000;
    vector<vector<ll> >factors(N+1);
    for(ll j=1;j<=N;++j)
    {
        for(ll x=1;x*x<=j;++x)
         {
            if(j%x==0)
            {
                factors[j].push_back(x);
                if(j/x != x) factors[j].push_back(j/x);
            }
         }
    }
**/
/**
vector<pair<ll,ll> >prime_factors(ll n)
{
    vector<pair<ll,ll> >res; ll ct=0;
    if(!(n&1))
    {
        while(!(n&1))
        {
            ct++; n/=2;
        }
        res.push_back({2,ct});
    }
    ct=0;
    for(ll i=3;i*i<=n;i+=2)
    {
        while(n%i==0)
        {
            ct++; n/=i;
        }
        if(ct>0) res.push_back({i,ct});
        ct=0;
    }
    if(n!=1) res.push_back({n,1});
    return res;
}
**/
/** calculating n_C_r();
ll ncr(ll n, ll k) {
    ll res = 1;
    for (ll i = 1; i <= k; ++i)
        res = (res*(n-k+i))/i;

    return res;
}
**/


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>

using namespace std;

void solve(vector<int> coo) {
    int maxcoo = *max_element(coo.begin(), coo.end());
    int mincoo = *min_element(coo.begin(), coo.end());
    std::cout << maxcoo - mincoo << std::endl;
}

int main() {
    struct timeval start,end;
    long long span;
    int t;

    gettimeofday(&start,NULL);

    std::cin >> t;
    vector<int> coo(t);
    for (int i = 0; i < t; i++) {
        std::cin >> coo[i];
    }
    solve(coo);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


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

using namespace std;

void solve()
{
    double x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << setprecision(30) << sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) << endl;
}

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



Measured memory_bytes: 3256
#include <stdio.h>
#include <stdlib.h>
int puz[3][3];
int temp[3][3];

int dx[4]={0,1,0,-1}; 
int dy[4]={1,0,-1,0}; 
// for changing position up,down,left,right
void empty(int x[],int y[])
{
  int i,j;
  for(i=0;i<3;i++) 
  {
    for(j=0;j<3;j++) 
    {
      if(puz[i][j]==0) 
      {
        *x = j;
        *y = i;
        return;
      }
    }
  }
}
void swap(int a[],int b[])
{
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}
int calcum(){
  int a;
  int N=0;
  for(int i=0; i<9; i++){
    a = puz[i/3][i%3];
    if(a!=0)
    {
      a=a-1;
      N =N + abs((i/3)-(a/3))+abs((i%3)-(a%3));
    }
  }
  return N;
}
int dfs(int x,int y,int p,int dep, int lim) 
{
  int i,h,x2,y2,res;
  h=calcum();
  
  if(h==0) return dep;
  if(dep+h>lim) return -1;
  for(i=0;i<4;i++)
  {
    x2=x+dx[i];  
    y2=y+dy[i];
    if(~p && i==(p+2)%9) //////
        continue;
    if(!(0<=x2 && x2<3 && 0<=y2 && y2<3)) 
        continue;
    swap(&puz[y][x],&puz[y2][x2]);
    res = dfs(x2,y2,i,dep+1,lim);
    if(~res) 
        return res;
    swap(&puz[y][x],&puz[y2][x2]);
  }
  return -1;
}
int main() {
  int def,x,y;
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++)
    {
        scanf("%d",&puz[i][j]);
        temp[i][j]= puz[i][j];
    }  
  }
  empty(&x,&y);
  
  for(int i=0;i<100;i++)
  {
    def=dfs(x,y,-1,0,i);
    if(def!=-1)
    {
      printf("%d\n",def);
      break;
    }
  
    def = -1;  
    if(i==99) 
        printf("%d\n",def);
  }
  return 0;
}



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

Measured memory_bytes: 256
import collections

N = int(input())
A = list(map(int, input().split()))
B = collections.defaultdict(int)
C = collections.defaultdict(int)

for i in range(N):
    B[i-A[i]] += 1 
    C[i+A[i]] += 1
#print(B)
#print(C)
ans = 0
for i in B:
    #print(i) i=Key
    ans += B[i]*C[i]
print(ans)

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

#define fastio std::ios::sync_with_stdio(false);
#define ll long long
#define scann(n) scanf("%d",&n)
#define scand(n) scanf("%lf",&n)
#define scans(s) scanf("%s",&s)
#define pb push_back
#define ppb pop_back
#define full v.begin(),v.end()
#define debug cout<<"Bug! Vag! Bagh!"<<endl;
#define pi acos(-1)
#define mx 10010
#define inf 10e10

int main()
{
    int tc;
    cin>>tc;
    cout<<tc+tc*tc+tc*tc*tc<<endl;
    return 0;
}
///arBishal_2017331022


Measured memory_bytes: 3620
#include <iostream>

int main(int argc, char const *argv[]) {
    /* code */
    int n, y;
    std::cin >> n >> y;

    int yen1 = 10000;
    int yen2 = 5000;
    int yen3 = 1000;

    int maxyen1 = y / yen1;
    while(maxyen1 >= 0){
        int remain1 = y - maxyen1 * yen1;
        int maxyen2 = remain1 / yen2;
//        std::cout << maxyen1 << " " << remain1 <<  " " << maxyen2 << std::endl;
        while(maxyen2 >= 0){
            int l = (y - maxyen1 * yen1 - maxyen2 * yen2) / yen3;
            if(maxyen1 + maxyen2 + l == n) {
                std::cout << maxyen1 << " " << maxyen2 << " " << l << std::endl;
                return 0;
            }
            --maxyen2;
        }
        --maxyen1;
    }

    std::cout << "-1 -1 -1" << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>=0;++i)

using namespace std;

int main() {
	int tmp, a, b, c, d, ans = 0; cin >>tmp;
	a = tmp / 1000; tmp %= 1000; b = tmp / 100; tmp %= 100; c = tmp / 10; d = tmp%10;
	string op = "+++";
	REP(i, 2) {
		switch (i) {
		case 1:
			ans = a + b + c + d;
			if (ans == 7) { goto anser; }
			else {
				ans = a + b - c + d;
				if (ans == 7) { op[1] = '-'; goto anser; }
				else {
					ans = a + b - c - d;
					if (ans == 7) { op[1] = '-'; op[2] = '-'; goto anser; }
					else {
						ans = a + b + c - d;
						if (ans == 7) { op[2] = '-'; goto anser; }
		case 2:
			ans = a - b + c + d;
			if (ans == 7) { op[0] = '-'; goto anser; }
			else {
				ans = a - b - c + d;
				if (ans == 7) { op[0] = '-'; op[1] = '-'; goto anser; }
				else {
					ans = a - b - c - d;
					if (ans == 7) { op[0] = '-'; op[1] = '-'; op[2] = '-'; goto anser; }
					else {
						ans = a - b + c - d;
						if (ans == 7) { op[0] = '-'; op[2] = '-'; goto anser; }
					}
				}
			}
					}
				}
			}
		}
	}

	anser:
	printf("%d%c%d%c%d%c%d=7\n", a, op[0], b, op[1], c, op[2], d);
	return 0;
}

Measured memory_bytes: 256
// g++ temp.cpp
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <string>
#include <climits>
using namespace std;

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EACH(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
const unsigned long long MOD = 100000000000000000;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 50
ll dp[MAX_N+1][MAX_N+1][MAX_N*MAX_N+1]={0};
void solve(){
  ll N,A;
  ll x[MAX_N+1];
  cin>>N>>A;
  ll max_cost=0;
  for(ll i=1;i<=N;i++){
    cin>>x[i];
    max_cost+=x[i];
  }
  ll ans=0;
  dp[0][0][0]=1;
  for(ll j=1;j<=N;j++){
    for(ll k=0;k<=N;k++){
      for(ll s=0;s<=max_cost;s++){
          dp[j][k][s]+=dp[j-1][k][s];
         if(k>0&&s>=x[j]){
          dp[j][k][s]+=dp[j-1][k-1][s-x[j]];
         }
      }
    }
  }
  for(ll i=1;i<=N;i++){
    if((i*A)>max_cost) break;
    ans+=dp[N][i][i*A];
    //if(i>max_cost) break;
   // cout<<ans<<endl;
  }
  cout<<ans<<endl;
}
int main(){
  solve();
  return 0;
}

Measured memory_bytes: 50048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i > n; --i)
const int MOD = 1000000007;

int main() {
  int N, K;
  cin >> N >> K;
  if(K == 1) cout << 0 << endl;
  else cout << N - K << endl;
  return 0;
}


Measured memory_bytes: 256
s = input()

ans = 0
# for i in range(n):
i = 0
while i <= len(s) - 1:
    index = i
    length = 0
    while i <= len(s) - 1:
        if s[i] in ["A", "C", "G", "T"]:
            length += 1
            i += 1
        else:
            # ans = [index, length]
            ans = max(ans, length)
            i += 1
            break


print(max(ans, length))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define nes ios_base :: sync_with_stdio(0); cin.tie(0);
using namespace std;
int main(){
	nes;
	int n;
	cin>>n;
	vector<ll>v(n);
	int ans=0;
	for(int i=0;i<n;++i) cin>>v[i];
	for(int i=0;i<n;++i){
		for(int j=i+1;j<n;++j){
			for(int k=j+1;k<n;++k){
				if(v[i]!=v[j]&&v[j]!=v[k]&&v[i]!=v[k]){
					if(v[i]+v[j]>v[k]&&v[i]-v[j]<v[k]&&v[k]+v[j]>v[i]&&v[k]-v[j]<v[i]&&v[i]+v[k]>v[j]&&v[i]-v[k]<v[j]) ++ans;
				}
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3652
N=int(input())
a=list(map(int,input().split()))
x=[]
k0=0
k1=0
k2=0

for i in range(N):
    if a[i]%4==0:
        x.append(2)
        k2+=1
    elif a[i]%4==2:
        x.append(1)
        k1+=1
    else:
        x.append(0)
        k0+=1


if (k1)%2==0:
    if k2+1>=k0:
        print("Yes")
    else:
        print("No")
else:
    if k2>=k0:
        print("Yes")
    else:
        print("No")



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

using namespace std;

typedef long long ll;

int main(){
  ll n,k,x,y;
  cin>>n>>k>>x>>y;
  ll fk;
  if(n<k){
    fk=n;
    n=0;
  } else{
    fk=k;
    n-=k;
  }
  cout<<(x*fk+y*n);
  return 0;
}

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

a = S[1:].count("E")
ans = [a]
for i in range(1,N):
  if S[i]=="E" and S[i-1]=="E":
    a -= 1
  elif S[i]=="E" and S[i-1]=="W":
    a += 0
  elif S[i]=="W" and S[i-1]=="E":
    a += 0
  elif S[i]=="W" and S[i-1]=="W":
    a += 1
  ans.append(a)

print(min(ans))

Measured memory_bytes: 60872
#include <cstdio>

using namespace std;

char a[101];
char b[101];
char c[101];

int main() {
    int n, ans = 0, i;
    
    scanf("%d", &n);
    scanf("%s", a);
    scanf("%s", b);
    scanf("%s", c);
    
    for (i = 0; i < n; i++) {
        if (a[i] == b[i] && b[i] == c[i]) continue;
        
        if (a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) {
            ans++;
        } else {
            ans += 2;
        }
    }
    
    printf("%d\n", ans);
    
    return 0;
}


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

int main() {
	int D, N;
	cin >> D >> N;
	int t[D], a[N], b[N], c[N];
	for (int i = 0; i < D; i++) cin >> t[i];
	for (int i = 0; i < N; i++) cin >> a[i] >> b[i] >> c[i];
	int dp[D][N];
    for (int i = 0; i < D; i++) {
		for (int j = 0; j < N; j++) {
          dp[i][j] = 0;
        }
    }
	bool dq[D][N];
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < N; j++) {
			if (t[i] >= a[j] && t[i] <= b[j]) {
				dq[i][j] = true;
			}
			else {
				dq[i][j] = false;
			}
		}
	}
	for (int i = 1; i < D; i++) {
		for (int j = 0; j < N; j++) {
			if (dq[i][j]) {
				for (int k = 0; k < N; k++) {
					if (dq[i - 1][k]) {
						int x = abs(c[j] - c[k]);
						dp[i][j] = max(dp[i][j], dp[i - 1][k] + x);
					}
				}
			}
		}
	}
  int ans = 0;
	for (int i = 0; i < N; i++) {
	  ans = max(ans, dp[D-1][i]);
	}
  cout << ans << endl;
}


Measured memory_bytes: 3276
N = gets.to_i
max = gets.to_i
max_2 = 0
array = [max]
(N-1).times do
  res = gets.to_i
  if res >= max
    max_2 = max
    max = res
  elsif res > max_2
    max_2 = res
  end
  array.push(res)
end

N.times do |i|
  if array[i] == max
    puts max_2
  else
    puts max
  end
end


Measured memory_bytes: 5172
import numpy as np
import sys

def combinationlist(n):
    p_sets = []
    for i in range(2 ** n):
        lst = [x + 1 for x in range(i) if 2 **x & i]
        if lst != []:
            p_sets.append(lst)
    p_sets = sorted(p_sets, key=lambda x: len(x))
    return p_sets


def main():
    data = input().split()
    h = int(data[0])
    w = int(data[1])
    k = int(data[2])
    c = np.empty((h,w),dtype=str)
    for i in range(h):
        s = input()
        c[i,:] = np.array([c for c in s])
    rowset = []
    colset = []
    all_black = 0
    for i in range(h):
        data = c[i,:]
        count = len(data[data == '#'])
        all_black += count
        rowset.append([count, data])
    for j in range(w):
        data = c[:,j]
        count = len(data[data=='#'])
        colset.append([count,data])
    ans = 0
    if k == all_black:
        ans += 1
    rowList = combinationlist(h)
    colList = combinationlist(w)
    for comb in rowList:
        if w*len(comb) > h*w - k:
            continue
        count = 0
        for i in  comb:
            count += rowset[i-1][0]
        if count == all_black - k:
            ans += 1
        if count <= all_black - k:
            for comb_2 in colList:
                comb_count = count
                for j in comb_2:
                    comb_count += colset[j-1][0]
                    for s in comb:
                        if '#' == colset[j-1][1][s-1]:
                            comb_count = comb_count -1
                if comb_count == all_black - k:
                    ans += 1
    for comb in colList:
        if h*len(comb) > h*w - k:
            continue
        count = 0
        for i in  comb:
            count += colset[i-1][0]
        if count == all_black - k:
            ans += 1
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 26868
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxm=1e5+5;
int d[1<<15];
int a[maxm];
int b[maxm];
int n,m;
signed main(){
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>a[i];
        int k;cin>>k;
        int t=0;
        while(k--){
            int x;cin>>x;x--;
            t|=(1<<x);
        }
        b[i]=t;
    }
    for(int i=0;i<(1<<n);i++)d[i]=1e18;
    d[0]=0;
    for(int i=1;i<=m;i++){
        for(int j=(1<<n)-1;j>=0;j--){
            d[j|b[i]]=min(d[j|b[i]],d[j]+a[i]);
        }
    }
    int ans=d[(1<<n)-1];
    if(ans==1e18)ans=-1;
    cout<<ans<<endl;
    return 0;
}
/*


*/


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

int main(){
	
	double x;
	while(cin>>x){
	if(x<=48.00)
		cout<<"light fly"<<endl;
	else if(x<=51.00)
		cout<<"fly"<<endl;
	else if(x<=54.00)
		cout<<"bantam"<<endl;
	else if(x<=57.00)
		cout<<"feather"<<endl;
	else if(x<=60.00)
		cout<<"light"<<endl;
	else if(x<=64.00)
		cout<<"light welter"<<endl;
	else if(x<=69.00)
		cout<<"welter"<<endl;
	else if(x<=75.00)
		cout<<"light middle"<<endl;
	else if(x<=81.00)
		cout<<"middle"<<endl;
	else if(x<=91.00)
		cout<<"light heavy"<<endl;
	else
		cout<<"heavy"<<endl;
	}
	
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

vvc<ll> to(2505);
vvc<ll> rto(2505);
vc<bool> re1(2505);
vc<bool> ren(2505);
vc<bool> ok(2505,false);

void dfs(ll v, vc<bool> &re, vvc<ll> t){
    if(re[v]) return;
    re[v] = true;
    for(ll u: t[v]) dfs(u,re,t);
}

ll bell(ll start, ll goal, vvc<pair<ll,ll>> beto, vc<ll>& dist){
    ll n = SIZE(beto);
    dist[start] = 0;
    rep(roop,n) {
        bool ch = false;
        rep(i,n){
            for (pair<ll,ll> p: beto[i]){
                if(!ren[p.first]) continue;
                if(dist[i] != INF && dist[i]+ p.second < dist[p.first]){
                    dist[p.first] = dist[i] + p.second;
                    ch = true;
                    //cout << i+1 << "->" << p.first+1 << " " << dist[p.first]<< endl; //確認用
                    if(roop == n-1) return -1*INF;
                }
            }
        }
        if(!ch) break;
    }
    return dist[goal];
}

int main(){
    cout << fixed << setprecision(20);
    ll n,m,p; cin >> n >> m >> p;
    vvc<pair<ll,ll>> beto(n,vc<pair<ll,ll>>());
    vc<ll> dist(n,INF);
    rep(i,m){
        int a,b,c; cin >> a >> b >> c;
        a--; b--;
        c -= p;
        beto[a].eb(make_pair(b,-1*c));
        to[a].eb(b);
        rto[b].eb(a);
    }
    //dfs(0,re1,to);
    dfs(n-1,ren,rto);
    //rep(i,n) if(re1[i]&&ren[i]) ok[i]=true;
    ll ans = -1*bell(0,n-1,beto,dist);
    if(ans == INF) cout << -1 << endl;
    else cout << MAX(ans,0) << endl;
    return 0;
}


Measured memory_bytes: 343296
#include <stdio.h>
#include <string>

using namespace std;

int main(void) {
	int row, col;
	char direction = 'R';

	//char str[11][6] = { "00000","1111","00001","0110","01011","0010","01111","0010","01001","0111","00000" };
	char str[11][6] = {'\0'};
	for (int i = 1; i < 10; i++) {
		scanf("%s", str[i]);
	}

	printf("R");
	row = 1;
	col = 1;
	while (1) {
		switch (direction) {
		case 'U':
			//left
			if (col != 0 && str[row][col - 1] == '1') {
				direction = 'L';
				col = col - 1;
				printf("L");
			}
			//up
			else if (row != 1 && str[row - 1][col] == '1') {
				direction = 'U';
				row = row - 2;
				printf("U");
			}
			//right
			else if (col != 4 && str[row][col] == '1') {
				direction = 'R';
				col = col + 1;
				printf("R");
			}
			//down
			else if (row != 9 && str[row + 1][col] == '1') {
				direction = 'D';
				row = row + 2;
				printf("D");
			}
			break;
		case 'D':  
			//right
			if (col != 4 && str[row][col] == '1') {
				direction = 'R';
				col = col + 1;
				printf("R");
			}
			//down
			else if (row != 9 && str[row + 1][col] == '1') {
				direction = 'D';
				row = row + 2;
				printf("D");
			}
			//left
			else if (col != 0 && str[row][col - 1] == '1') {
				direction = 'L';
				col = col - 1;
				printf("L");
			}
			//up
			else if (row != 1 && str[row - 1][col] == '1') {
				direction = 'U';
				row = row - 2;
				printf("U");
			}
			break;
		case 'L':  
			//down
			if (row != 9 && str[row + 1][col] == '1') {
				direction = 'D';
				row = row + 2;
				printf("D");
			}
			//left
			else if (col != 0 && str[row][col - 1] == '1') {
				direction = 'L';
				col = col - 1;
				printf("L");
			}
			//up
			else if (row != 1 && str[row - 1][col] == '1') {
				direction = 'U';
				row = row - 2;
				printf("U");
			}
			//right
			else if (col != 4 && str[row][col] == '1') {
				direction = 'R';
				col = col + 1;
				printf("R");
			}
			break;
		case 'R':  
			//up
			if (row != 1 && str[row - 1][col] == '1') {
				direction = 'U';
				row = row - 2;
				printf("U");
			}
			//right
			else if (col != 4 && str[row][col] == '1') {
				direction = 'R';
				col = col + 1;
				printf("R");
			}
			//down
			else if (row != 9 && str[row + 1][col] == '1') {
				direction = 'D';
				row = row + 2;
				printf("D");
			}
			//left
			else if (col != 0 && str[row][col - 1] == '1') {
				direction = 'L';
				col = col - 1;
				printf("L");
			}
			break;
		}
		if (row == 1 && col == 1) {
			printf("L");
			break;
		}
	}

	printf("\n");

	return 0;
}




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

#define int long long 
#define ll long long
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    set<ll> s;
    ll m = sqrt(n + 0.5);
    for (int i = 2; i <= m; i++) {
        if (n % i == 0) {
            ll nn = n;
            while(nn % i == 0){
                nn /= i;
            }
            if(nn % i == 1)s.insert(i);
        }
    }
    // cout << "ss";
    ll tp = n-1;
    for(int i = 1 ; i * i <= tp;i++){
        if(tp % i == 0){
            s.insert(i);
            if(i != tp/i){
                s.insert(tp/i);
            }
        }
    }
    cout << s.size();
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 30 + 5;
const int H = 10 + 5;
const int W = 1000 + 5;
const int OO = 2e9;
const int mod = 1e9 + 7;

int h,w,k,ans=OO,b[H],c[H];
char s[H][W];

int main() {

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

    cin >> h >> w >> k;

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> s[i][j];
        }
    }

    for (int mask = 0; mask < (1<<(h-1)); ++mask) {
        int p = __builtin_popcount(mask);
        int curAns = p;
        bool ok = 1;
        memset(b,0,sizeof b);

        for (int col = 0; col < w; ++col) {

            memset(c,0,sizeof c);
            bool ex = 0;
            int g = 0;

            for (int row = 0; row < h; ++row) {

                if(s[row][col]=='1') {

                    if(++c[g]>k) ok = 0;
                    if(b[g]+c[g]>k) ex = 1;

                }

                if(mask&(1<<row)) ++g;

            }

            if(!ok) break;

            if(ex) {

                ++curAns;

                for (int i = 0; i <= p; ++i) {
                    b[i] = c[i];
                }

            } else {

                for (int i = 0; i <= p; ++i) {
                    b[i] += c[i];
                }

            }

        }

        if(ok) ans = min(ans,curAns);

    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class FEngines {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N;
        in >> N;
	    vector<int> X(N), Y(N);
	    REP(i,0,N) in >> X[i] >> Y[i];

	    vector<tuple<double,int,int>> xy(N);
	    REP(i,0,N) {
            tuple<double,int,int> t{atan2((double)Y[i], (double)X[i]), X[i], Y[i]};
            xy[i] = move(t);
	    }
	    sort(all(xy));

	    ll answer = 0;
	    REP(length,1,N+1) {
	        int x = 0, y = 0;
	        REP(i,0,length) {
	            x += get<1>(xy[i]);
	            y += get<2>(xy[i]);
	        }
	        answer = max(answer, ((ll)x * x + (ll)y * y));
	        REP(left, 1, N) {
	            int plus = (left + length - 1) % N;
	            int minus = (left - 1 + N) % N;
	            x -= get<1>(xy[minus]);
	            y -= get<2>(xy[minus]);
                x += get<1>(xy[plus]);
                y += get<2>(xy[plus]);
                answer = max(answer, ((ll)x * x + (ll)y * y));
	        }
	    }
	    out << setprecision(20) << pow(answer, 0.5) << "\n";
	}
};


int main() {
	FEngines solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 512
use strict;
use warnings;
package SuffixArray;
sub sa_is(\@$);
sub sa_is(\@$){
	my@s=@{$_[0]};
	my$upper=$_[1];
	my$n=@s;
	if($n==0){
		return();
	}
	elsif($n==1){
		return(0);
	}
	my@sa;
	my@ls;
	for(my$i=$n-2;$i>=0;$i--){
		$ls[$i]=$s[$i]==$s[$i+1]?$ls[$i+1]:$s[$i]<$s[$i+1];
	}
	my@sum_l=(0)x($upper+1);
	my@sum_s=(0)x($upper+1);
	$ls[$_]?$sum_l[$s[$_]+1]++:$sum_s[$s[$_]]++for 0..$n-1;
	for(0..$upper){
		$sum_s[$_]+=$sum_l[$_];
		$sum_l[$_+1]+=$sum_s[$_]if$_<$upper;
	}
	my$induce;
	$induce=sub{
		my@sa=(-1)x$n;
		my@buf=@sum_s;
		for(@_){
			next if$_==$n;
			$sa[$buf[$s[$_]]++]=$_;
		}
		@buf=@sum_l;
		$sa[$buf[$s[$n-1]]++]=$n-1;
		for(@sa){
			$sa[$buf[$s[$_-1]]++]=$_-1if$_>=1&&!$ls[$_-1];
		}
		@buf=@sum_l;
		for(my$i=$n-1;$i>=0;$i--){
			my$v=$sa[$i];
			$sa[--$buf[$s[$v-1]+1]]=$v-1if$v>=1&&$ls[$v-1];
		}
		return@sa;
	};
	my@lms=grep!$ls[$_-1]&&$ls[$_],1..$n-1;
	my@lms_map=(-1)x($n+1);
	my$m=@lms;
	for(0..$m-1){
		$lms_map[$lms[$_]]=$_;
	}
	@sa=$induce->(@lms);
	if($m){
		my@sorted_lms=grep$lms_map[$_]!=-1,@sa;
		my@rec_s;
		my$rec_upper=0;
		$rec_s[$lms_map[$sorted_lms[0]]]=0;
		for(1..$m-1){
			my$l=$sorted_lms[$_-1];
			my$r=$sorted_lms[$_];
			my$end_l=$lms[$lms_map[$l]+1]//$n;
			my$end_r=$lms[$lms_map[$r]+1]//$n;
			my$different=0;
			if($end_l-$l!=$end_r-$r){
				$different=1;
			}
			else{
				$l++,$r++while$l<$end_l&&$s[$l]==$s[$r];
				$different=1if$l==$n||$s[$l]!=$s[$r];
			}
			$rec_s[$lms_map[$sorted_lms[$_]]]=$rec_upper+=$different;
		}
		my@rec_sa=sa_is(@rec_s,$rec_upper);
		$sorted_lms[$_]=$lms[$rec_sa[$_]]for 0..$m-1;
		@sa=$induce->(@sorted_lms);
	}
	return@sa;
}
sub suffix_array(\$){
	my@s=map ord,split"",${$_[0]};
	return sa_is(@s,255);
}
package LcpArray;
sub lcp(\@\@){
	my@s=@{$_[0]};
	my$n=@s;
	my@sa=@{$_[1]};
	my@rnk;
	$rnk[$sa[$_]]=$_ for 0..$n-1;
	my@lcp;
	my$h=0;
	for(0..$n-1){
		$h--if$h>0;
		next if$rnk[$_]==0;
		my$j=$sa[$rnk[$_]-1];
		$h++while$j+$h<$n&&$_+$h<$n&&$s[$j+$h]==$s[$_+$h];
		$lcp[$rnk[$_]-1]=$h;
	}
	return@lcp;
}
sub lcp_array(\$\@){
	my@s=map ord,split"",${$_[0]};
	return lcp(@s,@{$_[1]});
}
package main;
my$s=<>;
chomp$s;
my@sa=SuffixArray::suffix_array($s);
my@lcp=LcpArray::lcp_array($s,@sa);
my$ans=@sa*(@sa+1)/2;
$ans-=$_ for@lcp;
print$ans,$/;


Measured memory_bytes: 251952
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  for(int i = 0; i < h; ++i) cin >> s[i];
  vector<vector<int>> x(h,vector<int>(w)),y(h,vector<int>(w));
  int ans = 0;
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      if(s[i][j] == '.'){
        if(j > 0 and x[i][j-1] > 0) x[i][j] = x[i][j-1];
        else{
          int cnt = 1;
          for(int k = j+1; k < w; ++k){
            if(s[i][k] == '.') ++cnt;
            else break;
          }
          x[i][j] = cnt;
        }
        if(i > 0 and y[i-1][j] > 0) y[i][j] = y[i-1][j];
        else{
          int cnt = 1;
          for(int k = i+1; k < h; ++k){
            if(s[k][j] == '.') ++cnt;
            else break;
          }
          y[i][j] = cnt;
        }
        ans = max(ans,x[i][j]+y[i][j]-1);
      }
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 35968
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

class UFT {
public:
  UFT(ll N) : par(N, -1) {};
  ll root(ll i);
  void unite(ll i, ll j);
  ll size(ll i);
  bool inSameTree(ll i, ll j);
  void print();
  
private:
  vector<ll> par;
};

ll UFT::root(ll i) {
  if (par[i] < 0)
    return i;
  else
    return par[i] = root(par[i]);
}
void UFT::unite(ll i, ll j) {
  i = root(i);
  j = root(j);
  if (i == j)
    return;
  if (par[i] > par[j])
    swap(i, j);
  par[i] += par[j];
  par[j] = i;
}
ll UFT::size(ll i) {
  return -par[root(i)];
}
bool UFT::inSameTree(ll i, ll j) {
  return root(i) == root(j);
}
void UFT::print() {
  REP(i, par.size())
    printf("%lld:%lld:%lld ", i, par[i], root(i));
  printf("\n");
}

void solve(long N, long M, vector<long> A, vector<long> B) {
  UFT uft(N);
  REP(i, M)
    uft.unite(A[i] - 1, B[i] - 1);

  long ans(0);
  REP(i, N)
    ans = max(ans, (long)uft.size(i));
  cout << ans << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  long N, M;
  cin >> N >> M;
  vector<long> A(M);
  vector<long> B(M);
  REP(i, M)
    cin >> A[i] >> B[i];

  solve(N, M, move(A), move(B));

  return 0;
}


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

using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define ll	long long
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())


int main() {
	char a;
	cin>>a;
	if(a!='z')
	cout<<++a; 
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main(void){
	int n, k;
	cin >> n >> k;
	ll ans = k;
	rep(i, n - 1) ans *= (k - 1);
	cout << ans << endl;
	return 0;
}

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

int main(){
  ll a;
  string s;
  cin >> a >> s;
  ll b = (s[0]-'0')*100 + (s[2]-'0')*10 + (s[3]-'0');
  a *= b;
  a /= 100;
  cout << a << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int n;
    cin>>n;
    set<int> s;
    rep(i, n) {
        int e;
        cin>>e;
        s.insert(e);
    }

    int m;
    cin>>m;
    rep(i, m) {
        int e;
        cin>>e;
        s.insert(e);
    }

    for (auto e : s) cout<<e<<endl;
}


Measured memory_bytes: 21904
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	int N, K; cin >> N >> K; N++;
    ll H[N]; F0R(i, N-1) cin >> H[i];
    H[N-1] = 0;
    ll dp[N+1][K+1];
    F0R(i, N+1) F0R(j, K+1) {
        dp[i][j] = 1000000000000;
    }

    dp[0][0] = 0;
    FOR(i, 1, N+1) {
        F0R(j, K+1) {
            F0R(k, j+1) {
                int pos = i - 1 - k;
                if (pos < 0) break;
                int dif = 0;
                int lst = 0; if (pos != 0) lst = H[pos-1];
                dp[i][j] = min(dp[i][j], dp[pos][j-k] + max(0ll, H[i-1] - lst));
            }
        }
    }

    ll ans = 1000000000000;

    F0R(j, K+1) ans = min(ans, dp[N][j]);
    cout << ans << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



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

int main() {
	int N, M;
  cin >> N >> M;
  vector<vector<int>> a(M);
  for(int i = 0; i < M; i++){
    int k;
    cin >> k;
    a.at(i).resize(k);
    for(int j = 0; j < k; j++){
      cin >> a.at(i).at(j);
      a.at(i).at(j)--;
    }
  }
  
  vector<int> p(M);
  for(int i = 0; i < M; i++){
    cin >> p.at(i);
  }
  
  int ans = 0;
  for(int i = 0; i < (1 << N); i++){
    bool f = true;
    for(int j = 0; j < M; j++){
      int c = 0;
      for(int id : a.at(j)){
        if((i >> id) & 1){
          c++;
        }
      }
      c %= 2;
      if(c != p.at(j)){
        f = false;
      }
    }
    if(f) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <math.h>
using namespace std;
int main() {
  int h,w,i,j;
  char ch;
  cin>>h>>w;
  int a[h][w];
  int b[h][w];
  for (i=0;i<h;i++){
    for(j=0;j<w;j++){
      cin>>ch;
      if(ch=='c') a[i][j]=0;
      if(ch=='.') a[i][j]=-1;
    }
  }
  for (i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(j==0) b[i][j]=a[i][j];
      if(j!=0) {
        if(a[i][j]==0){
          b[i][j]=0;
        }else{
          if(b[i][j-1]==-1){
            b[i][j]=-1;
          }else{
            b[i][j]=b[i][j-1]+1;
          }
        }
      }
    }
  }
  for (i=0;i<h;i++){
    for(j=0;j<w;j++){
      cout<<b[i][j];
      if(j<w-1) cout<<" ";
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1236