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

using Lint=long long;

template<int mod> class ModInt
{
 private:
    Lint val;
 public:
    Lint value(){ return val; }
    ModInt(Lint x=0){ val=x%mod; }
    ModInt pow(int n){
        ModInt res(1),x(val);
        while(n>0){ if(n&1) res*=x; x*=x; n>>=1; }
        return res;
    }
    ModInt inv(){ return pow(mod-2); }
    ModInt& operator+=(ModInt rhs){ val+=rhs.val; if(val>=mod) val-=mod; return *this; }
    ModInt& operator-=(ModInt rhs){ val+=mod-rhs.val; if(val>=mod) val-=mod; return *this; }
    ModInt& operator*=(ModInt rhs){ val=val*rhs.val%mod; return *this; }
    ModInt& operator/=(ModInt rhs){ *this*=rhs.inv(); return *this; }
    ModInt operator+(ModInt rhs){ return ModInt(val)+=rhs; }
    ModInt operator-(ModInt rhs){ return ModInt(val)-=rhs; }
    ModInt operator*(ModInt rhs){ return ModInt(val)*=rhs; }
    ModInt operator/(ModInt rhs){ return ModInt(val)/=rhs; }
};
using mint=ModInt<1000000007>;

mint dp[100010][2][100];

int main()
{
   string K; cin>>K;
   int D; cin>>D;
   int N=K.size();

   dp[0][0][0]=1;
   for(int i=0;i<N;i++) for(int less=0;less<2;less++) for(int j=0;j<D;j++){
      int maxD=(less? 9:K[i]-'0');
      for(int d=0;d<=maxD;d++){
         dp[i+1][less|(d<maxD)][(j+d)%D]+=dp[i][less][j];
      }
   }
   mint ans=dp[N][0][0]+dp[N][1][0]-1;
   cout<<ans.value()<<endl;
   return 0;
}


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

int main(){
  long n,k;
  std::cin >> n>>k;
  std::vector<long> ar(1000001,0);
  rep(i,n){
    long a,b;
    std::cin >> a>>b;
    
    ar[a]+=b;
  }
  
  long counter=0,j;
  for (j = 1; k>counter ; j++) {
    /* code */
    counter+=ar[j];
  }
  std::cout << j-1 << std::endl;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf =1 << 30;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n, ma, mb; cin >> n >> ma >> mb;
    vi a(n), b(n), c(n);
    rep(i, n) cin >> a[i] >> b[i] >> c[i];

    const int N = 400;
    vector<vector<vi>> dp(n + 1, vector<vi>(N + 1, vi(N + 1, inf)));
    dp[0][0][0] = 0;

    rep(i, n){
        rep(j, N + 1){
            rep(k, N + 1){
                int& cur = dp[i][j][k];
                if(cur == inf) continue;

                chmin(dp[i + 1][j][k], cur);
                int nj = j + a[i];
                int nk = k + b[i];
                if(nj <= N and nk <= N) chmin(dp[i + 1][nj][nk], cur + c[i]);
            }
        }
    }

    int res = inf;
    rep(j, 1, N + 1){
        rep(k, 1, N + 1){
            int& cur = dp[n][j][k];
            if(cur != inf and j * mb == k * ma){
                chmin(res, cur);
            }
        }
    }
    if(res == inf) res = -1;
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 27264
import sys
from io import StringIO
import unittest
import itertools

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    n=int(readline())
    dat = [[-1 for i in range(n)] for j in range(n)]
    for i in range(n):
        m=int(readline())
        for j in range(m):
            x,y=map(int, readline().rstrip().split())
            x-=1
            dat[i][x] = y
    
    ans=0
    for ptn in itertools.product([False,True], repeat=n):
        ok=True
        for i in range(n):
            if ptn[i]==False:
                continue
            for j in range(n):
                if dat[i][j] == -1:
                    continue
                if dat[i][j] == 1 and ptn[j]==False:
                    ok=False
                    break
                if dat[i][j] == 0 and ptn[j]==True:
                    ok=False
                    break
            if ok==False:
                break
        if ok==True:
            ans=max(ans,ptn.count(True))
    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

Measured memory_bytes: 16172
#include"bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int, int> P;
string s[100006];
signed main() {
	int n, l; cin >> n >> l;
	rep(i, n)cin >> s[i];
	sort(s, s + n);
	int grundy = 0;
	rep(i, s[0].size()) {
		int g = l - i;
		g &= -g;
		grundy ^= g;
	}

	rep(i, n - 1) {
		int p;
		rep(j, s[i].size()) {
			if (s[i][j] != s[i + 1][j]) {
				p = j; break;
			}
		}
		grundy ^= (l - p)&(p - l);
		for (int j = p + 1; j < s[i + 1].size(); j++) {
			int g = l - j;
			g &= -g;
			grundy ^= g;
		}
	}
	if (grundy)cout << "Alice" << endl;
	else cout << "Bob" << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;


int main() {
    string n;
    cin >> n;
    if (n.at(n.size() - 1) == '2' || n.at(n.size() - 1) == '4' || n.at(n.size() - 1) == '5'
     || n.at(n.size() - 1) == '7' || n.at(n.size() - 1) == '9') {
         cout << "hon" << endl;
     }
     else if (n.at(n.size() - 1) == '0' || n.at(n.size() - 1) == '1' || n.at(n.size() - 1) == '6' || n.at(n.size() - 1) == '8') {
         cout << "pon" << endl;
     }
     else if (n.at(n.size() - 1) == '3') {
         cout << "bon" << endl;
     }
}

Measured memory_bytes: 3560
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstring>
 
using namespace std;
 
typedef long long LL;
 
const int N = 1<<13;
const int M = 200 + 5;
const int INF = 1000000000 + 5;
 
int n, m;
int x[N];
int a[M];
LL tag[N << 1];
LL maxv[N << 1];
vector<pair<int, int> > st[M];

void push(int x) {
    if (tag[x]) {
        tag[2*x] += tag[x];
        maxv[2*x] += tag[x];
        tag[2*x+1] += tag[x];
        maxv[2*x+1] += tag[x];
        tag[x] = 0;
    }
}

void modify(int t, int l, int r, int a, int b, LL v)
{
    if (b < l || r < a) return;
    if (a <= l && r <= b) {
        tag[t] += v;
        maxv[t] += v;
        return;
    }
    push(t);
    int mid = (l + r) >> 1;
    modify(t << 1, l, mid, a, b, v);
    modify(t << 1 | 1, mid + 1, r, a, b, v);
    maxv[t] = max(maxv[t << 1], maxv[t << 1 | 1]);
}
 
LL query(int t, int l, int r, int a, int b)
{
    if (b < l || r < a) return 0;
    if (a <= l && r <= b) {
        return maxv[t];
    }
    push(t);
    int mid = (l + r) >> 1;
    return max(query(t << 1, l, mid, a, b), query(t << 1 | 1, mid + 1, r, a, b));
}
 
void solve()
{
    cin >> n >> m;
    for(int i = 0; i < n - 1; ++ i) {
        scanf("%d", x + i);
    }
 
    long long ans = 0;
    for(int j = 0; j < m; ++ j) {
        st[j].push_back(make_pair(INF, -1));
    }
 
    for(int i = 0; i < n; ++ i) {
        long long tmp = 0;
        for(int j = 0; j < m; ++ j) {
            scanf("%d", a + j);
            tmp += a[j];
        }
        ans = max(ans, tmp);
 
        for(int j = 0; j < m; ++ j) {
            while (a[j] >= st[j].back().first) {
                int r = st[j].back().second;
                int v = st[j].back().first;
                st[j].pop_back();
                int l = st[j].back().second + 1;
                modify(1, 0, n - 1, l, r, -v);
            }
            modify(1, 0, n - 1, st[j].back().second + 1, i, a[j]);
            st[j].push_back(make_pair(a[j], i));
        }
 
        if (i > 0) {
            modify(1, 0, n - 1, 0, i - 1, -x[i - 1]);
        }
        ans = max(ans, query(1, 0, n - 1, 0, i));
    }
    cout << ans << endl;
}
 
int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 640
import sys
x, k, d = [int(i) for i in input().split(" ")]
if x < 0:
    x *= -1
if x-k*d >= 0:
    print(x-k*d)
    sys.exit(0)
k -= (x//d)
x = x%d
k %= 2
if k == 0:
    print(x)
else:
    print(abs(x-d))


Measured memory_bytes: 9160
#include <bits/stdc++.h>
#define lli long long int
using namespace std;

 
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int x, a;
	
	cin >> x >> a;
	
	if(x < a) cout << 0 << "\n";
	else cout << 10 << "\n";
	
	
	return 0;
}


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

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n-1; i++){
    int tmp; cin >> tmp;
    a.at(tmp-1)++;
  }
  for(int i = 0; i < n; i++){
    cout << a.at(i) << endl;
  }
}

Measured memory_bytes: 4000
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
#define maxv 100001
#define che 1LL<<32
#define mod 1000000007
int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll lcm=(c*d)/(__gcd(c,d));
    ll ans=b/c+b/d-b/lcm;
    a--;
    ans=b-ans;
    //cout<<ans<<endl;
    ll ans1=(a/c+a/d-a/lcm);
    ans1=a-ans1;
    cout<<ans-ans1<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n;
  scanf("%d", &n);
  int array[n];
  int i , count = 0;
  int l, c, r; //left, center, right

  for(i=0 ; i<n ; i++)
    scanf("%d", &array[i]);

  for(i=1 ; i<n-1 ; i++){
    l = array[i-1]; c = array[i]; r = array[i+1]; 
    if( (l<= c && c<=r)     //a<b<c
       || ( r<=c && c<=l ) ) //c<b<a
      count++;
  }

  printf("%d\n", count);

  return 0;
}


Measured memory_bytes: 128
# coding: utf-8
# Your code here!
a, b = map(int,input().split())

if a <= 0 and b >= 0:
    ans = "Zero"
elif a < 0 and b < 0:
    if (b-a)%2 == 0:
        ans = "Negative"
    else:
        ans = "Positive"
else:
    ans = "Positive"

print(ans)

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

using namespace std;

int main()
{

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

    int n=s.size();
    int m=t.size();
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
             if(i==0||j==0)
                dp[i][j]=0;
            else
            {

                if(s[i-1]==t[j-1])
                {
                    dp[i][j]=1+dp[i-1][j-1];
                    //ans=ans+s[i-1];
                }
                else
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }


        }

    }
    int index=dp[n][m];
char ans[index+1];
ans[index]='\0';
int i = n, j = m;
   while (i > 0 && j > 0)
   {
      if (s[i-1] == t[j-1])
      {
          ans[index-1] = s[i-1];
          i--; j--;
          index--;
      }
      else if (dp[i-1][j] > dp[i][j-1])
         i--;
      else
         j--;
   }
cout<<ans;






}


Measured memory_bytes: 35456
N, M, K = map(int, input().split())

mod = 10**9+7
frac = [1]*200100
for i in range(2,200100):
    frac[i] = i * frac[i-1]%mod
fraci = [None]*200100
fraci[-1] = pow(frac[-1], mod -2, mod)
for i in range(-2, -200100 - 1, -1):
    fraci[i] = fraci[i+1] * (200100 + i + 1) % mod
def comb(a, b):
    if not a >= b >= 0:
        return 0
    return frac[a]*fraci[b]*fraci[a-b]%mod


mod = 10**9+7

t = N**2*(M+1)*M*(M-1)//6 + M**2*(N+1)*N*(N-1)//6
print(t*comb(N*M-2,K-2)%mod)


Measured memory_bytes: 41968
#include <bits/stdc++.h>
#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

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

const long long INF = LLONG_MAX/3;

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; }
inline void Yes (bool condition) { if(condition) { cout << "Yes" << endl; } else { cout << "No" << endl;} }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;
  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main(){
	int n;
	cin>>n;
	multiset<int> s;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		auto b=s.upper_bound(-a);
		if(b==s.end()){
			s.insert(-a);
		}else{
			s.erase(b);
			s.insert(-a);
		}
	}
	cout<<s.size()<<endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
using namespace std;
int main(){
	long long a, b, c, a1, b1;
	cin >> a >> b;
	a1 = a;
	b1 = b;
	for (;;) {
		if (b > a) {
			c = a;
			a = b;
			b = c;
		}
		if (a % b == 0) {
			cout << a1 * b1 / b << endl;
			return 0;
		}
		a = a % b;
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    vvl vec(n,vl(n));
    REP(i,n){
        REP(j,n){
            cin>>vec[i][j];
        }
    }
    REP(i,n){
        REP(j,n){
            if(vec[i][j]!=vec[j][i]){
                cout<<-1<<endl;
                return 0;
            }
        }
    }
    vvl d(vec);
    REP(k,n){
        REP(i,n){
            REP(j,n){
                chmin(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    REP(i,n){
        REP(j,n){
            if(vec[i][j]!=d[i][j]){
                cout<<-1<<endl;
                return 0;
            }
        }
    }
    ll ans=0;
    REP(i,n){
        REP(j,i){
            bool f=true;
            REP(k,n){
                if(k==i||k==j){
                    continue;
                }
                if(d[i][j]==d[i][k]+d[k][j]){
                    f=false;
                }
            }
            if(f){
                ans+=d[i][j];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  string s; cin >> s;
  int q; cin >> q;

  set<int> cnt[26];

  rep(i, n) {
    int d = s[i] - 'a';

    cnt[d].em(i);
  }

  rep(i, q) {
    int t; cin >> t;

    if (t == 1) {
      int iq; cin >> iq;
      char cq; cin >> cq;
      int d = s[iq - 1] - 'a';
      s[iq - 1] = cq;

      cnt[d].erase(iq - 1);
      cnt[cq - 'a'].em(iq - 1);
    } else {
      int l, r; cin >> l >> r;
      --l, --r;

      int ret = 0;
      rep(j, 26) {
        auto itr = cnt[j].lower_bound(l);
        if (itr != cnt[j].end() && *itr <= r) ++ret;
      }

      cout << ret << endl;
    }
  }

  return (0);
}


Measured memory_bytes: 27224
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using ull = unsigned long long;

int main(int argc, char* argv[]) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  /* */
  int w, h, n;
  cin >> w >> h >> n;
  int s[100][100] = {{0}};

  for (int i = 0; i < n; ++i) {
    int x, y, a;
    cin >> x >> y >> a;
    --x;  --y;
    if (a == 1) {
      for (int a = 0; a < h; ++a) {
        for (int b = 0; b <= x; ++b) {
          s[a][b] = 1;
        }
      }
    } else if (a == 2) {
      for (int a = 0; a < h; ++a) {
        for (int b = w - 1; b > x; --b) {
          s[a][b] = 1;
        }
      }
    } else if (a == 3) {
      for (int a = 0; a <= y; ++a) {
        for (int b = 0; b < w; ++b) {
          s[a][b] = 1;
        }
      }
    } else if (a == 4) {
      for (int a = h - 1; a > y; --a) {
        for (int b = 0; b < w; ++b) {
          s[a][b] = 1;
        }
      }
    }
  }

  int c = 0;
  for (int i = 0; i < h; ++i) {
    c += count(s[i], s[i] + w, 0);
  }
  cout << c << endl;
  /* */

  return EXIT_SUCCESS;
}


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

map<long long, long long> cnt;
long long arr[100050];
bool isPrime[3060];
vector<long long> prime;
long long Slove(long long n)
{
    for(vector<long long>::size_type i = 0; i < prime.size(); ++i)
    {
        while(n % prime[i] == 0)
            n /= prime[i];
    }
    return n;
}
int main()
{
    memset(isPrime, true, sizeof(isPrime));
    for(long long i = 2; i <= 3000; ++i)
    {
        if(!isPrime[i])
            continue;
        prime.push_back(i * i * i);
        for(long long j = i + i; j <= 3000; j += i)
            isPrime[j] = false;
    }
    long long n;
    scanf("%lld", &n);
    for(long long i = 1; i <= n; ++i)
        scanf("%lld", &arr[i]);
    for(long long i = 1; i <= n; ++i)
        ++cnt[ Slove(arr[i]) ];
    long long ans;
    if(cnt.find(1) != cnt.end())
        ans = 1;
    else
        ans = 0;
    for(auto it = cnt.begin(); it != cnt.end(); ++it)
    {
        if(it->first == 1)
            continue;
        long long a = it->first;
        long long b = Slove(a * a);
        ans += max(cnt[a], cnt[b]);
        cnt[a] = 0;
        cnt[b] = 0;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 19456
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    ll N, a[5];
    cin >> N;
    REP(i, 5){
        cin >> a[i];
    }

    sort(a, a+5);

    ll x = ceil((double)N/a[0]);
    ll ans = x + 4;

    cout << ans << endl;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

set<ll> div(ll n)
{
  set<ll> ret;
  ret.insert(n);
  for (int i = 2; i <= sqrt(n); ++i)
  {
    if(n%i==0) 
    {
      ret.insert(i);
      ret.insert(n/i);
    }
  }
  return ret;
}

int main()
{
  ll n;
  cin>>n;
  if(n==2)
  {
    cout<<1;
    return 0;
  }
  ll ans=div(n-1).size();
  set<ll> divn=div(n);
  for(const auto& e: divn) 
  {
    if(e>sqrt(n)) break;
    ll m=n;
    while(m%e==0)
    {
      m/=e;
    }
    if(m%e==1) ans++;
  }
  cout<<ans+1;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

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

	vector<ll> sum;
	sum.push_back(0);
	vector<ll> sum2;
	sum2.push_back(0);
	for (auto i = 0; i <= N; ++i)
	{
		sum.push_back(sum[i] + (N - i));
		sum2.push_back(sum2[i] + i);
	}

	auto mod = (ll)1e9 + 7;
	auto ans = 0ll;
	for (auto i = K; i <= N + 1; ++i)
	{
		ans = (ans + sum[i] - sum2[i] + 1) % mod;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6552
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long Y = sc.nextLong();
		long temp = X;
		long count = 0;
		while (temp <= Y) {
			count++;
			temp *= 2;
		}

		System.out.println(count);
	}

	public static class Pair {
		private int key;
		private int value;

		public Pair(int key, int value) {
			super();
			this.key = key;
			this.value = value;
		}

		public int getKey() {
			return key;
		}

		public int getValue() {
			return value;
		}

		@Override
		public String toString() {
			return "{" + key + ", " + value + "}";
		}
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 22868
N = int(input())
A = [int(i) for i in input().split()]
 
A.sort(reverse=True)
 
if N % 2 == 1:
    if A[-1] == 0:
        A.pop()
    else:
        print(0)
        quit()
 
for i in range(0, N - 2, 2):
    if A[i] != N - i - 1 or A[i] != A[i + 1]:
        print(0)
        quit()
 
print(2 ** (N // 2) % (10 ** 9 + 7))

Measured memory_bytes: 52332
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
ll dp[2][4];
int now = 0;
int t[3];
void Irreversibleoperation() {
	string s;
	cin >> s;
	int n = s.size();
	int wc = 0;
	for (size_t i = 0; i < n; i++)
	{
		wc += s[i] == 'W';
	}
	ll res = 0;
	for (size_t i = 0; i < n; i++)
	{
		if (s[i] == 'W') wc--;
		else res += wc;
	}
	cout << res << endl;
}
int main() {
	Irreversibleoperation();
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int main(){
    int n, r;
    cin >> n >> r;
    if(n>=10){
        cout << r << endl;
    }else{
        cout << r + 100 * (10 - n) << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
import java.util.*;


public class Main {
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
//        String s = sc.nextLine();
//        int k = sc.nextInt();
//        int a = sc.nextInt();
//        int b = sc.nextInt();        
//        int r = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();   
//        String n = sc.nextLine();
        sc.close();
        System.out.println(z + " " + x + " " + y);
//        if(n.contains("7")){
//            System.out.println("Yes");
//        }else{
//            System.out.println("No");
//        }
//        System.out.println(n);
//        if(s <= w){
//            System.out.println(Math.PI);
//        }else{
//            System.out.println("safe");
//        }
//        System.out.println(s);
//        if(s.contains("RRR")){
//            System.out.println(3);
//        }else if(s.contains("RR")){
//            System.out.println(2); 
//        }else if(s.contains("R")){
//            System.out.println(1);
//        }else{
//             System.out.println(0);
//        }
//        String s = sc.nextLine();
//        String t = sc.next();
//        String[] arr =  s.split("　");
//        sc.close();
//        System.out.println("input: "+ s);
//        System.out.println("k:" + k);
//        System.out.println("a:" + a);
//        System.out.println("b:" + b);
//        String ans = "NG";
//        for(int x = a; x<=b; x++){
//            if(x%k == 0){
//                ans = "OK";
//            }
//        }
//        System.out.println(ans);
//        \
//        System.out.println("arr[1]:" + arr[1]);
//
//        if(s.equals("ABC")){
//            System.out.println("ARC");
//        }else{
//            System.out.println("ABC");
//        }
//        String[] arr1 =  s.split("");
//        String[] arr2 =  t.split("");
////        List<String> list1 = Arrays.asList(s.split(""));
//        List list1 = new LinkedList(Arrays.asList(s.split("")));
////        List<String> list2 = Arrays.asList(t.split(""));
//        List list2 = new LinkedList(Arrays.asList(t.split("")));
////        int num = Integer.parseInt(arr[arr.length - 1]);
//        list2.remove(arr2.length - 1);
////        System.out.println(list1);
////        System.out.println(list2);
//         if(list1.toString().contentEquals(list2.toString())){
//             System.out.println("Yes");
//         }else{
//             System.out.println("No");
//         }
//        switch(num){
//            case 3:
//                System.out.println("bon");
//                break;
//            case 0:
//            case 1:
//            case 6:
//            case 8:
//                System.out.println("pon");
//                break;
//            default:
//                System.out.println("hon");
//                break;
//        }
//        String[] array = str.split(" ");
//        int sum = 0;
//        for(int i=0; i<array.length; i++) {
//            int num = Integer.parseInt(array[i]);
//            sum += num;
//        }
//        System.out.println(15-sum);
    }
}

Measured memory_bytes: 39076
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x,y,z; cin >> x >> y >> z;
  x -= z;
  cout << x / (y + z) << endl;
  return 0;
}

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

public class Main {

    int[] arr;

    int size;

    int swaps;

    public static void main(String[] args)
    {

        Main g = new Main();

        g.readArray();

        g.insertionSort();

        //g.printArray();

        //System.out.println(g.swaps);
    }

    private void readArray() {

        InputReader reader = new InputReader(System.in);

        size = reader.nextInt();

        arr = new int[size];

        for(int i=0; i<size; ++i)
            arr[i] = reader.nextInt();
    }

    private void printArray() {

        PrintWriter writer = new PrintWriter(System.out);

        for(int i=0; i<size; ++i) {

            writer.write("" + arr[i]);

            if(i<size-1) writer.write(" ");
        }

        writer.write("\n");

        writer.flush();
    }


    private void insertionSort() {

        printArray();

        for(int i=1; i<size; ++i) {

            int t1=arr[i];
            int j=i-1;

            while(j>=0) {
                if(t1 < arr[j]) {
                    arr[j+1] = arr[j];
                    --j;
                }
                else break;
            }

            arr[j+1]=t1;

            printArray();
        }
    }


    private void selectionSort() {

        for(int i=0; i<size-1; ++i) {

            int min=i+1;

            for(int j=i+1; j<size; ++j) {
                if(arr[j] < arr[min])
                    min=j;
            }

            if(arr[min] < arr[i]) {

                ++swaps;

                int tmp = arr[min];
                arr[min] = arr[i];
                arr[i] = tmp;
            }
        }
    }


    private void bubbleSort() {

        boolean flag=false;

        for(int i=0; i<size-1; ++i) {

            flag=false;

            for(int j=0; j<size-1-i; ++j) {

                if(arr[j]>arr[j+1]) {

                    flag=true;

                    ++swaps;

                    int tmp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = tmp;
                }
            }

            // no swap has taken place so array is already sorted at this point
            if(!flag) break;
        }

    }


    class InputReader {

        private BufferedReader reader;

        private StringTokenizer tokenizer;

        InputReader(InputStream ip) {

            reader = new BufferedReader(new InputStreamReader(ip));
        }

        String next() {

            if(tokenizer==null || !tokenizer.hasMoreTokens()) {

                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            return tokenizer.nextToken();
        }

        int nextInt() {

            return Integer.parseInt(next());
        }
    }
}



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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        int R, C, K;
        cin >>R >>C >>K;
        vector<vector<ll>> v(R+2, vector<ll> (C+2, 0));
        Rep0(i, K) {
                ll r, c, vv;
                cin >>r >>c >>vv;
                v.at(r).at(c)=vv;
        }
        vector<vector<vector<ll>>> DP(R+2, vector<vector<ll>> (C+2, vector<ll> (5, -1)));
        DP.at(1).at(1).at(0)=0;
        if (v.at(1).at(1)>0)
                DP.at(1).at(1).at(1)=v.at(1).at(1);
        Rep1(i, R)
                Rep1(j, C)
                        Rep0(h, 4) {
                                ll V=DP.at(i).at(j).at(h);
                                if (-1==V)
                                        continue;
                                DP.at(i).at(j+1).at(h)=max(DP.at(i).at(j+1).at(h), V);
                                int vv=v.at(i).at(j+1);
                                if (vv>0)
                                        DP.at(i).at(j+1).at(h+1)=max(DP.at(i).at(j+1).at(h+1), V+vv);
                                vv=v.at(i+1).at(j);
                                DP.at(i+1).at(j).at(0)=max(DP.at(i+1).at(j).at(0), V);
                                if (vv>0)
                                        DP.at(i+1).at(j).at(1)=max(DP.at(i+1).at(j).at(1), V+vv);
                        }
        ll S=0;
        Rep0(h, 4)
                S=max(S, DP.at(R).at(C).at(h));
        cout <<S <<endl;
        return 0;

}

Measured memory_bytes: 706992
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAX_N=100+5;
int abs(int x)
{
    if(x<0)
        return -x;
    return x;
}
struct Data
{
    int x,y;
    int h;
} data[MAX_N];
int arr[MAX_N];
int main()
{
    int N;
    scanf("%d",&N);
    for(int i=0; i<N; i++)
    {
        scanf("%d%d%d",&data[i].x,&data[i].y,&data[i].h);
    }
    bool flag=true;
    int temp;
    int H;
    bool first;
    int count=0;
    for(int cx=0; cx<=100; cx++)
    {
        for(int cy=0; cy<=100; cy++)
        {
            first=false;
            count=0;
            H=1;
            for(int i=0; i<N; i++)
            {
                if(data[i].h==0)
                {
                    arr[count++]=i;
                    continue;
                }
                temp=abs(data[i].x-cx)+abs(data[i].y-cy)+data[i].h;
                if(!first)
                {
                    H=temp;
                    first=true;
                    continue;
                }
                if(temp!=H)
                {
                    flag=false;
                    break;
                }
                H=temp;
            }
            if(flag)
            {
                for(int i=0; i<count; i++)
                {
                    if(H-abs(data[arr[i]].x-cx)-abs(data[arr[i]].y-cy)>0)
                    {
                        flag=false;
                        break;
                    }
                }
                if(flag)
                {
                    printf("%d %d %d\n",cx,cy,H);
                    return 0;
                }
            }
            flag=true;
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
#define N 300005
#define rev reverse
using namespace std;
int n,t[N],st[N],top,m;
int y[N],sum[N],f1[N],f2[N];
void yu(int *f)
{
    f[0]=0;top=0;st[++top]=0;
    for(int i=1;i<=n;i++)sum[i]=sum[i-1]+t[i];
    for(int i=1;i<=n;i++)
    {
        f[i]=f[i-1];
        while(top>1&&y[st[top]]-y[st[top-1]]<=2*i*(st[top]-st[top-1]))top--;
        f[i]=max(f[i],f[st[top]]+(i-st[top])*(i-st[top]+1)/2-sum[i]+sum[st[top]]);
        y[i]=i*i-i+2*f[i]+2*sum[i];
        while(top>1&&(y[st[top]]-y[st[top-1]])*(i-st[top-1])<=(y[i]-y[st[top-1]])*(st[top]-st[top-1]))top--;
        st[++top]=i;
    }
}
int f[N],tmp[N];
void solve(int *f1,int *f2,int l,int r)
{
    if(l==r){f[l]=max(f[l],f1[l-1]+f2[l+1]-t[l]+1);return ;}
    int mid=(l+r)>>1;top=0;
    for(int i=l-1;i<mid;i++)
    {
        y[i]=i*i-i+2*f1[i]+2*sum[i];
        while(top>1&&(y[st[top]]-y[st[top-1]])*(i-st[top-1])<=(y[i]-y[st[top-1]])*(st[top]-st[top-1]))top--;
        st[++top]=i;
    }
    for(int i=mid;i<=r;i++)
    {
        while(top>1&&y[st[top]]-y[st[top-1]]<=2*i*(st[top]-st[top-1]))top--;
        tmp[i]=f2[i+1]+f1[st[top]]-sum[i]+sum[st[top]]+(i-st[top])*(i-st[top]+1)/2;
    }
    for(int i=r-1;i>=mid;i--)tmp[i]=max(tmp[i],tmp[i+1]);
    for(int i=mid;i<=r;i++)f[i]=max(f[i],tmp[i]);
    solve(f1,f2,l,mid);solve(f1,f2,mid+1,r);
}
signed main()
{
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)scanf("%lld",&t[i]);

    yu(f1);rev(t+1,t+n+1);
    yu(f2);
    rev(t+1,t+n+1);rev(f2+1,f2+n+1);
    for(int i=1;i<=n;i++)f[i]=-t[i];
    for(int i=1;i<=n;i++)sum[i]=sum[i-1]+t[i];
    solve(f1,f2,1,n);

    rev(t+1,t+n+1);rev(f+1,f+n+1);rev(f1+1,f1+n+1);rev(f2+1,f2+n+1);
    for(int i=1;i<=n;i++)sum[i]=sum[i-1]+t[i];
    solve(f2,f1,1,n);
    rev(t+1,t+n+1);rev(f+1,f+n+1);rev(f2+1,f2+n+1);rev(f1+1,f1+n+1);


    scanf("%lld",&m);
    for(int i=1;i<=m;i++)
    {
        int t1,t2;scanf("%lld%lld",&t1,&t2);
        printf("%lld\n",max(f1[t1-1]+f2[t1+1],f[t1]-t2+t[t1]));
    }
    return 0;
}


Measured memory_bytes: 19328
program double_landscape
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer :: n, m, a(1000), b(1000), ac, bc, i
  logical :: au(1000000), bu(1000000)
  integer(8) :: x
  a = 0
  b = 0
  au = .false.
  bu = .false.
  read(*,*) n, m
  read(*,*) a(1:n)
  read(*,*) b(1:m)
  do i = 1, n
    if (au(a(i))) then
      write(*,'(i0)') 0
      stop
    end if
    au(a(i)) = .true.
  end do
  do i = 1, m
    if (bu(b(i))) then
      write(*,'(i0)') 0
      stop
    end if
    bu(b(i)) = .true.
  end do
  ac = 0
  bc = 0
  x = 1_8
  do i = n*m, 1, -1
    if (au(i).and.bu(i)) then
      ac = ac+1
      bc = bc+1
    else if (au(i)) then
      ac = ac+1
      x = mod(x*int(bc,8),md)
    else if (bu(i)) then
      bc = bc+1
      x = mod(x*int(ac,8),md)
    else
      x = mod(x*(int(ac,8)*int(bc,8)-int(n*m-i,8)),md)
    end if
  end do
  write(*,'(i0)') x
  stop
end program double_landscape

Measured memory_bytes: 8064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();

            var count = 0;
            for (int i = 0; i < n; i++)
            {
                var a = cin.nextInt();
                var b = cin.nextInt();
                if (a == b)
                {
                    count++;
                }
                else
                {
                    count = 0;
                }
                if (count == 3)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }

            Console.WriteLine("No");

        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; i++) {
        cin >> A.at(i);
    }

    // 最小で何個の数列に分ければよいか->端から順にできるだけ長い列を切り出す
    int divide = 0;
    bool up = false;
    bool down = false;
    for (int i=0; i<N-1; i++) {
        if (!up && !down) {
            if (A.at(i) < A.at(i+1)) up = true;
            if (A.at(i) > A.at(i+1)) down = true;
        }

        if (up) {
            if (A.at(i) > A.at(i+1)) {
                up = false;
                divide++;
            }
        }
        if (down) {
           if (A.at(i) < A.at(i+1)) {
               down = false;
               divide++;
           }
        }
    }    

    int ans = divide + 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < (int)N; ++i) {
    int A;
    cin >> A;
    if (A % 2 == 0 && (A % 3 != 0 && A % 5 != 0)) {
      cout << "DENIED" << endl;
      return 0;
    }
  }

  cout << "APPROVED" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
string s;
int K,L,N;
int dp[1<<17][101];
main()
{
	cin>>K>>s;
	N=s.size();
	L=N/(K+1);
	if(N%(K+1)==0)
	{
		string ans=s.substr(0,L);
		for(int i=L;i<N;i+=L)ans=max(ans,s.substr(i,L));
		cout<<ans<<endl;
	}
	else if(K<100)
	{
		int A=N%(K+1);
		for(int i=0;i<=N;i++)for(int j=0;j<=A;j++)dp[i][j]=-1;
		dp[0][A]=-2;
		for(int i=0;i<N;i++)
		{
			for(int j=0;j<=A;j++)
			{
				if(dp[i][j]==-1)continue;
				if(i+L<=N)
				{
					if(j==A)dp[i+L][j]=-2;
					else if(dp[i+L][j]==-1)dp[i+L][j]=dp[i][j];
					else
					{
						if(s.substr(dp[i+L][j],L+1)>s.substr(dp[i][j],L+1))dp[i+L][j]=dp[i][j];
					}
				}
				if(j>0&&i+L+1<=N)
				{
					int now;
					if(j==A)now=i;
					else
					{
						if(s.substr(i,L+1)<s.substr(dp[i][j],L+1))now=dp[i][j];
						else now=i;
					}
					if(dp[i+L+1][j-1]==-1)dp[i+L+1][j-1]=now;
					else
					{
						if(s.substr(dp[i+L+1][j-1],L+1)>s.substr(now,L+1))dp[i+L+1][j-1]=now;
					}
				}
			}
		}
		cout<<s.substr(dp[N][0],L+1)<<endl;
	}
	else
	{
		string ans(L+1,'9');
		for(int i=0;i<=L;i++)
		{
			int l=0,r=9;
			while(r-l>1)
			{
				int m=l+r>>1;
				ans[i]=m+'0';
				bool flag=true;
				int id=0;
				for(int j=0;j<=K;j++)
				{
					if(s.substr(id,L+1)<=ans)
					{
						id+=L+1;
					}
					else id+=L;
					if(id>=N)break;
				}
				if(id>=N)r=m;
				else l=m;
			}
			ans[i]=r+'0';
		}
		cout<<ans<<endl;
	}
}

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

int main() {
  int n,k;
  cin>>n>>k;
  
  ll kotae=1;
  
  while(n>=k){
  	kotae++;
    n/=k;
  }
  
  cout<<kotae<<endl;
  
	
}

Measured memory_bytes: 256
S = list(input())
T = list(input())
defolt = 1000
for i in range(len(S)-len(T)+1):
    ans = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            ans += 1
    defolt = min(defolt,ans)
print(defolt)

Measured memory_bytes: 65340
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] A = new int[N+1];
		
		for(int i=0; i<=N; i++) {
			A[i] = sc.nextInt();
		}
		
		System.out.println(solve(N, A));
		sc.close();
	}
	
	static long solve(int N, int[] A) {
		if(A[0]>0) {
			if(N==0 && A[0]==1)
				return 1;
			else
				return -1;
		}
		
		long sum = 0;
		for(int i=0; i<=N; i++) {
			sum += A[i];
		}
	
		
		long leaf = 1;
		long node = 1;

		for(int i=0; i<N; i++) {
			leaf = Math.min(leaf*2, sum);
			node += leaf;
			if(leaf < A[i+1]) {
				return -1;
			}
			leaf -= A[i+1];
			sum -= A[i+1];
		}
	
		return node;
	}
}


Measured memory_bytes: 48788