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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll int, null_type,less<ll int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,m,n;
        vi v;
        cin>>n;
        rs(v,n+1);
        for(i=1;i<=n;i++)
            cin>>v[i];
        ll dp[100005];
        clr(dp,hell);
        dp[1]=0;
        for(i=2;i<=n;i++)
        {
            dp[i]=min(dp[i-1]+abs(v[i-1]-v[i]),dp[i-2]+abs(v[i-2]-v[i]));
        }
        cout<<dp[n];
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#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<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (int)1e9
#define d(x) cerr<<#x<<"="<<x<<endl;

ll a[100001],n,k,dp[100001],tmp;

int main(void){
    cin>>n>>k;
    rep(i,n)cin>>a[i];
    repi(i,1,n){
        ll min=inf;
        rep(j,k){
            if(i-(j+1)<0)continue;
            tmp=dp[i-(j+1)]+abs(a[i]-a[i-(j+1)]);
            if(tmp<min)min=tmp;
        }
        dp[i]=min;
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

void rec(vector<ll> &b)
{
  if(b.size() == 0) return;
  bool ok = false;
  for(ll i = b.size()-1; i >= 0; i--) {
    if(b[i] == i + 1) {
      ok = true;
      b.erase(b.begin() + i);
      rec(b);
      cout << i + 1 << endl;
      break;
    }
  }
  if(!ok) {
    cout << -1 << endl;
    exit(0);
  }
}

void solve()
{
  ll N; cin >> N;
  vector<ll> b(N); rep(i, N) cin >> b[i];
  rec(b);
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3552
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


# SegTreeの関数
def segfunc(x, y):
    return max(x, y)
# 単位元
# min->inf, max->-inf, add->0, mul->1
ide_ele = -1

# セグメント木
class SegTree:
    """
    init(init_val, segfunc, ide_ele): 配列init_valで初期化、構築
    update(k, x): k番目の値をxに更新
    query(l, r): 区間[l, r)をsegfuncしたものを返す
    """
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n-1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセットする
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2*i], self.tree[2*i+1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        :param k: index(0-index)
        :param x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k>>1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        :param l: 0-index
        :param r: 0-index
        :return:
        """
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r-1])
            l >>= 1
            r >>= 1
        return res

def main():
    N, K = NMI()
    A = [NI() for _ in range(N)]
    seg = SegTree([0]*300010, segfunc, ide_ele)
    for i, a in enumerate(A):
        n = seg.query(max(a - K, 0), min(300010, a + K + 1))
        seg.update(a, n+1)
    print(seg.query(0, 300010))



if __name__ == "__main__":
    main()

Measured memory_bytes: 96272
#include <stdio.h>
#include <algorithm>
using namespace std;

#define REP(i, N) for(int (i) = 0; (i) < (N); i++)

int main(){
    int x_low = 0, x_up, y_low = 0, y_up;
    int n, xn[100], yn[100], an[100];
    scanf("%d %d %d", &x_up, &y_up, &n);
    REP(i, n){
        scanf("%d %d %d", &xn[i], &yn[i], &an[i]);
    }
    REP(i, n){
        switch(an[i]){
            case 1:
            x_low = max(x_low, xn[i]); break;
            case 2:
            x_up = min(x_up, xn[i]); break;
            case 3:
            y_low = max(y_low, yn[i]); break;
            case 4:
            y_up = min(y_up, yn[i]); break;
            default: break;
        }
    }
    int x = max(0, x_up - x_low), y = max(0, y_up - y_low);
    printf("%d", x*y);
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> cnum(N+1);
  int _i;
  for (int i=2; i<=N; i++) {
    _i = i;
    for (int j=2; j<=_i; j++) {
      while (!(_i%j)) {
        cnum.at(j)++;
        _i /= j;
      }
    }
  }
  
  long long k=1;
  for (int i=0; i<N+1; i++)
    if (cnum.at(i) > 0) {
      k *= cnum.at(i) + 1;
      k %= 1000000007;
    }
  
  if (N == 1)
    cout << 1 << endl;
  else
    cout << k << endl;
}

Measured memory_bytes: 256
from operator import itemgetter

N, M = map(int, input().split())
P = []
Y = []
IDX = []

for idx in range(M):
    p, y = map(int, input().split())
    P.append(p)
    Y.append(y)
    IDX.append(idx)
    
PYIDX = zip(P,Y,IDX)
PYIDX = sorted(PYIDX, key=itemgetter(1))
PYIDX = sorted(PYIDX, key=itemgetter(0))
PYIDX = [list(x) for x in PYIDX]

for i in range(M):
    if i == 0 or PYIDX[i-1][0] != PYIDX[i][0]:
        city_number = 1
    else:
        city_number += 1
    PYIDX[i].append(str(PYIDX[i][0]).zfill(6) + str(city_number).zfill(6))

PYIDX = sorted(PYIDX, key=itemgetter(2))

for idx in range(M):
    print(PYIDX[idx][3])

Measured memory_bytes: 43296
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=1000010;
const ll mod=1e9+7;

int main(){  
  int n;
  cin >> n;
  vector<ll> t(n),a(n);
  rep(i,n){ cin >> t[i] >> a[i]; }
  rep(i,n-1){
    if(t[i+1]>=t[i] && a[i+1]>=a[i]){ continue; }
    ll tmpt = (t[i+1]+t[i]-1)/(t[i+1]);
    ll tmpa = (a[i+1]+a[i]-1)/(a[i+1]);
    t[i+1] *= max(tmpt,tmpa);
    a[i+1] *= max(tmpt,tmpa);
  }
  ll ans=t[n-1]+a[n-1];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
p = list(map(int, input().split()))
sort_p = sorted(p)
count1 = 0

for count, i in enumerate(p):
    if(i != sort_p[count]):
        count1 = count1 + 1


if(count1 > 2):
    print("NO")
else:
    print("YES")


Measured memory_bytes: 2940
N, M = map(int, input().split())
Lmax = -1
Rmin = N + 1

for _ in range(M):
    l, r = map(int, input().split())
    Lmax = max(Lmax, l)
    Rmin = min(Rmin, r)

if Rmin - Lmax >= 0:
    print(Rmin - Lmax + 1)
else:
    print(0)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    vvi v(3,vi(3,0));
    rep(i,3)rep(j,3)cin>>v[i][j];
    vi p(3,0);
    vi q(3,0);
    rep(i,3)q[i]=v[i][0]-p[0];
    rep(j,3)if(j)p[j]=v[0][j]-q[0];
    bool flag=true;
    rep(i,3)rep(j,3)if((v[i][j]!=p[j]+q[i]))flag=false;
    cout<<(flag?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;



ll N, K;

int main(){
	cin >> N >> K;
	
	vector<ll> v(N*2);
	for ( int i = 0; i < N; i++ ){
		cin >> v[i];
		v[i+N] = v[i];
	}
	
	ll score = LLONG_MIN;
	vector<ll> vv(N);
	for ( int i = 0; i <= N; i++ ){
		for ( int j = N; j-i <= N && j-i <= K; j++ ){
			int len = j - i;
			
			copy(v.begin()+i, v.begin()+j, vv.begin());
			sort(vv.begin(),vv.begin()+len);
			
			ll sum = 0;
			for ( int k = 0; k < len; k++ )
				sum += vv[k];
			
			for ( int mlen = 0; len + mlen <= K; ){
				score = max( score, sum );
				
				if ( mlen >= len )
					break;
				sum -= vv[mlen];
				mlen++;
			}
		}
	}
	
	cout << score << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, m;
    cin >> n >> m;
    ATYN(n==m)

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll W,H,x,y;
    cin>>W>>H>>x>>y;
    
    ld ans=W*H/2.0;
    cout<<fixed<<setprecision(12)<<ans<<" ";
    
    if(W/2.0==x&&H/2.0==y){
        cout<<1;
    }else{
        cout<<0;
    }
    
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
def floor_sum(n, m, a, b):
    """ sum( (a*i + b)//m ), i = 0..n-1 を返す"""
    ans = 0
    if a >= m:
        ans += n * (n - 1) * (a // m) // 2
        a %= m
    if b >= m:
        ans += n * (b // m)
        b %= m
    y_max = (a * n + b) // m
    x_max = y_max * m - b
    if y_max == 0:
        return ans
    ans += (n - (x_max + a - 1) // a) * y_max
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a)
    return ans


if __name__ == "__main__":
    import sys
    input = sys.stdin.buffer.readline
    sys.setrecursionlimit(10 ** 7)

    T = int(input())
    for _ in range(T):
        ans = floor_sum(*map(int, input().split()))
        print(ans)

Measured memory_bytes: 9420
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  long long int sum=0;
  for(int i=1;i<=n;i++)
  {
     if(i%3!=0&&i%5!=0)
     {
     sum+=i;
     }
  }
  cout<<sum;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, x;
  std::cin >> n >> x;
  std::vector<int64_t> l(n);
  std::cin >> l;

  int64_t count = 1;
  int64_t p = 0;

  for (const auto i : l) {
    p += i;
    if (p <= x) {
      count++;
    }
  }

  std::cout << count << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int x, n;
	long int money = 0;
	int sumqua = 0;
	int ave;
	int number = 0;
	while (scanf("%d,%d", &x, &n) != EOF) {
		sumqua += n;
		money += x * n;
		number++;
	}
	ave = (double)sumqua / (double)number + 0.5;
	printf("%ld\n%d\n", money, ave);
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
const ll MINF = LLONG_MIN;
const int INT_INF = INT_MAX;
using Tree = vector<pair<int, int>>;

int main()
{
    int n, k;
    cin >> n >> k;
    int r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    vector<bool> win(n, false);
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (i >= k && win[i - k] && t[i - k] == t[i])
            continue;
        switch (t[i])
        {
        case 'r':
            ans += p;
            break;
        case 's':
            ans += r;
            break;
        case 'p':
            ans += s;
            break;
        }
        win[i] = true;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

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

        int a = x % 100;
        int b = x / 100;
        if (a == 0) {
            System.out.println("1");
            return;
        }


        for (int i = 0; i < b; i++) {
            if (a > 5) {
                a = a - 5;
            } else {
                System.out.println("1");
                return;
            }
        }

        if (a == 0) {
            System.out.println("1");
            return;
        }
        System.out.println("0");
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
ll n,p;
cin >> n >> p;
map<ll, ll> mp;
for (ll i = 0; i < n;i++){
    ll t;
    cin >> t;
    mp[t % 2]++;
}
if(mp[0]==n){
    if (p == 0) cout << (1LL<<n) << endl;
    else
        cout << 0 << endl;
}
else
    cout << (1LL<<(n-1)) << endl;
}


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

int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    int ans = 100 * r + 10 * g + b;
    if (ans % 4 == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

LL N, M;

int main() {
    scanf("%lld %lld", &N, &M);
    LL ans = 0;

    while (1) {
	LL g = min(N, M/2);
	ans += g;
	N -= g;
	M -= g * 2;

	g = M / 4;
	N += g;
	M -= g + g;

	if (N <= 0 && M <= 3) break;
	if (M < 2) break;
    }

    printf("%lld\n", ans);

    return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N, ma = 0;
	map<string, int> m;
	string s;
	cin >> N;
	REP(i,0, N){
		cin >> s;
		auto it = m.find(s);
		if(it != m.end()){
			++it->second;
			ma = max(ma, it->second);
		}else{
			m[s] = 1;
			if(ma == 0) ma = 1;
		}
	}
	
	for(auto it=m.begin(); it != m.end(); it++){
		if(ma == it->second) cout << it->first << endl;
	}

}


Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main()
{
    FIO
    int n;
    cin>>n;
    string s[n];
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }
    sort(s,s+n);
    int maxx=INT_MIN;
    int countd=0;


    for(int i=0;i<n;i++)
    {
         countd=0;
        for(int j=i;j<n;j++)
        {
            if(s[i]==s[j])
            {
                countd++;
            }
            else
                break;
        }
        if(countd>=maxx)
        {
            maxx=countd;
        }
        i=i+countd-1;

    }
    string m[n];
    int z=0;
   
        for(int i=0;i<n;i++)
    {
        countd=0;
        for(int j=i;j<n;j++)
        {
            if(s[i]==s[j])
            {
                countd++;
            }
            else
                break;
        }
        if(countd==maxx)
        {
            m[z]=s[i];
            z++;
        }
        i=i+countd-1;

    }
    sort(m,m+z);
    for(int i=0;i<z;i++)
    {
        cout<<m[i]<<endl;

    }



    return 0;
}


Measured memory_bytes: 14464
#include<bits/stdc++.h>
#include<stdlib.h>
using namespace std;
int main()
{
    long long int n,k,a,b,i,j,sum=0,c;
    vector<long long int>vec;
    cin>>k;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a;
        vec.push_back(a);
    }
    a=vec[0]+(k-vec[n-1]);
    for(i=1;i<n;i++)
    {
        a=max(a,vec[i]-vec[i-1]);
    }
    cout<<k-a<<endl;

    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a,b,c,d,n,m,p,q,x,y,k,h,w,sum,mi,ma,ans,l,r,res;
string s;
typedef vector<int> VI;
typedef vector<pair<int,int> > VP;

int main() {
    cin>>n;
    rep(i,1,n+1){
        if(i%2==0)continue;
        c=0;
        rep(j,1,i+1){
            if(i%j==0)c++;
        }
        if(c==8){ans++;d(i);}
    }
    p(ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=2005,mod=1e9+7;
int n,k;
int Fac[N*N],Inv[N*N],dp[N][N];
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=1LL*x*x%mod)
		if (y&1)
			ans=1LL*ans*x%mod;
	return ans;
}
int C(int n,int m){
	if (m<0||m>n)
		return 0;
	return 1LL*Fac[n]*Inv[m]%mod*Inv[n-m]%mod;
}
int main(){
	scanf("%d%d",&n,&k);
	if (k==1){
		puts("1");
		return 0;
	}
	for (int i=Fac[0]=Inv[0]=1;i<=n*k;i++){
		Fac[i]=1LL*Fac[i-1]*i%mod;
		Inv[i]=1LL*Inv[i-1]*Pow(i,mod-2)%mod;
	}
	dp[0][0]=1;
	for (int i=0;i<=n;i++)
		for (int j=i;j<=n;j++){
			dp[i][j+1]=(dp[i][j+1]+dp[i][j])%mod;
			dp[i+1][j]=(1LL*dp[i][j]*C(k*(n-i)-(j-i)-1,k-2)+dp[i+1][j])%mod;
		}
	printf("%lld",1LL*dp[n][n]*Fac[n]%mod);
	return 0;
}

Measured memory_bytes: 47360
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
int N,A,B;
cin>>N>>A>>B;

if((B-A)%2==1){
	ce("Borys")
}else{
	ce("Alice")
}


}

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

string S;
int chk[3];

int main() {
    cin >> S;

    for(int i = 0; i < S.size(); i++) {
        chk[ S[i] - 'a' ]++;
    }
    int cnt = 0;
    for(int i = 0; i < 3; i++) cnt += (chk[i] != 0);

    if(cnt == 1) {
        if(S.size() == 1) printf("YES");
        else printf("NO");
        return 0;
    }
    if(cnt == 2) {
        if(S.size() == 2) printf("YES");
        else printf("NO");
        return 0;
    }

    sort(chk, chk + 3);

    if(chk[2] - 1 <= chk[0] && chk[2] - 1 <= chk[1]) printf("YES");
    else printf("NO");
}


Measured memory_bytes: 512
// https://atcoder.jp/contests/abc174/tasks/abc174_f

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <class Abel>
struct BIT {
  vector<Abel> dat[2];
  Abel UNITY_SUM = 0;

  BIT(int n) { init(n); }
  void init(int n) {
    for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM);
  }

  inline void sub_add(int p, int a, Abel x) {
    for (int i = a; i < (int)dat[p].size(); i += i & -i)
      dat[p][i] = dat[p][i] + x;
  }
  inline void add(int a, int b, Abel x) {
    sub_add(0, a, x * -(a - 1));
    sub_add(1, a, x);
    sub_add(0, b, x * (b - 1));
    sub_add(1, b, x * (-1));
  }

  inline Abel sub_sum(int p, int a) {
    Abel res = UNITY_SUM;
    for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
    return res;
  }
  inline Abel sum(int a, int b) {
    return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) -
           sub_sum(1, a - 1) * (a - 1);
  }
};

void solve() {
  ll N, Q;
  cin >> N >> Q;

  VL cs(N);
  rep(i, N) cin >> cs[i];

  VL lefts(Q), rights(Q), ids(Q);
  for (int i = 0; i < Q; ++i) {
    cin >> lefts[i] >> rights[i];
    --lefts[i];
    ids[i] = i;
  }

  sort(ids.begin(), ids.end(),
       [&](int i, int j) { return rights[i] < rights[j]; });

  BIT<int> bit(N + 5);
  VL prev(N + 5, -1);
  VL res(Q, 0);

  ll r = 0;
  for (auto i : ids) {
    for (; r < rights[i]; ++r) {
      bit.add(prev[cs[r]] + 2, r + 2, 1);
      prev[cs[r]] = r;
    }
    ll t = bit.sum(lefts[i] + 1, lefts[i] + 2);
    res[i] = max(res[i], t);
  }
  for (int i = 0; i < Q; ++i) cout << res[i] << "\n";
}


Measured memory_bytes: 31132
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    static Parser parser = new Parser();

    public static void main(String[] args) {
        long N = parser.parseLong();

        long ans = (N - 1) * N / 2;
        System.out.println(ans);
    }
}

class Parser {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final Iterator<String> stringIterator = br.lines().iterator();
    private static final Deque<String> inputs = new ArrayDeque<>();

    void fill() {
        if(inputs.isEmpty()){
            if(!stringIterator.hasNext()) throw new NoSuchElementException();
            inputs.addAll(Arrays.asList(stringIterator.next().split(" ")));
        }
    }

    Integer parseInt() {
        fill();
        if(!inputs.isEmpty()) {
            return Integer.parseInt(inputs.pollFirst());
        }
        throw new NoSuchElementException();
    }

    Long parseLong() {
        fill();
        if(!inputs.isEmpty()) {
            return Long.parseLong(inputs.pollFirst());
        }
        throw new NoSuchElementException();
    }

    Double parseDouble() {
        fill();
        if(!inputs.isEmpty()) {
            return Double.parseDouble(inputs.pollFirst());
        }
        throw new NoSuchElementException();
    }

    String parseString() {
        fill();
        return inputs.removeFirst();
    }

}

Measured memory_bytes: 21204
# -*- coding: utf-8 -*-

N = int(input())

flag = False
for h in range(1,3500):
    for n in range(h,3500):
        if 4 * h * n - N * h - N * n == 0:
            continue
        if (N * n * h) % (4 * h * n - N * h - N * n) != 0:
            continue
        w = int((N * n * h) / (4 * h * n - N * h - N * n))
        if w <= 0:
            continue
        print(n,h,w)
        flag = True
        break
    if flag:
        break


Measured memory_bytes: 41836
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        
        int n = stdIn.nextInt();
        int i = stdIn.nextInt();
        //int b = stdIn.nextInt();
        //int num[] = new int[3];
        //String s = stdIn.next();
        //char c[] = s.toCharArray();
        //boolean flag = true;
        
        System.out.println(n - i + 1);
        
        
        
        
        //System.out.println();
        //System.out.print();
    }
}


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

signed main() {
  string S;
  cin >> S;

  int l = (S[0] - '0') * 10 + (S[1] - '0');
  int r = (S[2] - '0') * 10 + (S[3] - '0');

  cerr << l << " " << r << endl;

  bool lm = l <= 12 && l > 0;
  bool rm = r <= 12 && r > 0;

  if (!lm && !rm) puts("NA");
  else if (!lm && rm) puts("YYMM");
  else if (lm && !rm) puts("MMYY");
  else puts("AMBIGUOUS");
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long S = scan.nextLong();
		long h = S / 3600;
		long m = Math.floorMod(S, 3600) / 60;
		long s = Math.floorMod(S, 60);
		System.out.println(h + ":" + m + ":" + s);
	}
}

Measured memory_bytes: 26236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
int gcd(int a,int b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    int n,ans = 0;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        while(a[i] %2 == 0){
            a[i] /= 2;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
  int i;
  int N,A;
  int aa[200000]={};
  long cnt = 0;
  scanf("%d", &N);
  for (i = 0; i < N-1; i++) {
    scanf("%d", &A);
    aa[A - 1]++;
  }
  for (i = 0; i < N; i++) {
    printf("%d\n", aa[i]);
  }
    return 0;
  }


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

int main(){
  int a[5];
  for(int i=0;i<5;i++){
    cin>>a[i];
  }
  sort(a,a+5,greater<int>());
  cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<" "<<a[3]<<" "<<a[4]<<endl;
  
  return 0;
}

Measured memory_bytes: 1180
inFomula = raw_input()

listFomula = inFomula.split()

leftNum = listFomula[0]
rightNum = listFomula[2]
op = listFomula[1]

result = 0

if op == "+":
    result = int(leftNum) + int(rightNum)
elif op == "-":
    result = int(leftNum) - int(rightNum)

print result

Measured memory_bytes: 2568
#include<cstdio>
#include<cstring>
#ifdef LOCAL
#define debug(...)  fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
typedef long long ll;

const int N=5010;
const int P=1e9+7;
int n;
int head[N],nxt[N<<1],to[N<<1],lst=0;
inline void adde(int x,int y) {
  nxt[++lst]=head[x]; to[lst]=y; head[x]=lst;
}
ll f[N][N],tmp[N],val[N];
int sz[N];
inline int Add(int x,int y) {x+=y; if(x>=P) x-=P; return x;}
void DP(int u,int fr) {
  f[u][1]=1; sz[u]=1;
  for(int i=head[u];i;i=nxt[i]) if(to[i]!=fr) DP(to[i],u);
  for(int i=head[u];i;i=nxt[i])
    if(to[i]!=fr) {
      int v=to[i];
      for(int j=0;j<=sz[u]+sz[v];j++) tmp[j]=0;
      for(int j=0;j<=sz[u];j++)
	for(int k=0;k<=sz[v];k++)
	  tmp[j+k]=Add(tmp[j+k],1ll*f[v][k]*f[u][j]%P);
      for(int j=0;j<=sz[u]+sz[v];j++) f[u][j]=tmp[j];
      sz[u]+=sz[v];
    }
  if(sz[u]%2==0) {
    for(int i=2;i<=sz[u];i+=2)
      f[u][0]=Add(f[u][0],1ll*f[u][i]*val[i]%P);
    f[u][0]=(P-f[u][0])%P;
  }
}
signed main() {
  debug("%d\n", 233);
  scanf("%d",&n);
  for(int i=1;i<n;i++) {
    int x,y; scanf("%d %d",&x,&y);
    adde(x,y); adde(y,x);
  }
  val[2]=1; for(int i=4;i<=n;i++) val[i]=1ll*val[i-2]*(i-1)%P;
  DP(1,0);
  // for(int i=1;i<=n;i++) {
  //   for(int j=0;j<=sz[i];j++)
  //     printf("%lld ",f[i][j]);
  //   printf("\n");
  // }
  printf("%lld\n",(P-f[1][0])%P);
  return 0;
}

Measured memory_bytes: 194944
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 330000
using namespace std;
inline char gc(){
	/*static char now[1<<16],*T,*S;
	if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
	return *S++;*/return getchar();
}
inline int read(){
	int x=0;char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
	return x;
}
struct node{
	int l,r;
}line[N];
inline bool cmp(node a,node b){return a.l<b.l;}
struct node1{
	int left,right,v;
}tree[N*20];
int num,n,m,root[N];
inline void insert1(int &x,int l,int r,int p){
	tree[++num]=tree[x];x=num;tree[x].v++;if (l==r) return;
	int mid=l+r>>1;if (p<=mid) insert1(tree[x].left,l,mid,p);else insert1(tree[x].right,mid+1,r,p);
}
inline int query(int rt1,int rt2,int l,int r,int l1,int r1){
	if (l1<=l&&r1>=r) return tree[rt2].v-tree[rt1].v;
	int mid=l+r>>1;int tmp=0;if (l1<=mid) tmp+=query(tree[rt1].left,tree[rt2].left,l,mid,l1,r1);
	if (r1>mid) tmp+=query(tree[rt1].right,tree[rt2].right,mid+1,r,l1,r1);return tmp;
}
int main(){
//	freopen("arc.in","r",stdin);
	n=read();m=read();
	for (int i=1;i<=n;++i) line[i].l=read(),line[i].r=read();
	sort(line+1,line+n+1,cmp);int tot=0;printf("%d\n",n);
	for (int i=1;i<=m;++i){root[i]=root[i-1];
	while(line[tot+1].l==i) insert1(root[i],1,m,line[tot+1].r),++tot;}
	for (int len=2;len<=m;++len){
		int j=len,tmp=0,now=m%len;now=m-now;
		for (;j<=m;j+=len) tmp+=query(root[j-len],root[j-1],1,m,j-len+1,j-1);
		if(now<m) tmp+=query(root[now],root[m],1,m,now+1,m);
		printf("%d\n",n-tmp);
	}
	return 0;
}

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

using namespace std;

// Prioridade
typedef long long   ll;
typedef pair<ll,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i = a; i < (b); i++)
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (((a)*(b))/__gcd((a), (b)))

// fim da Prioridade
ll dp[10004][104][2];
int k, n;
string t;
ll solve(int i,int r,int ok){
	if(i == n && r == 0){
		return 1LL;
	}else if(i == n){
		return 0LL;
	}
	if(dp[i][r][ok] != -1){
		return dp[i][r][ok] ;
	}
	int digit = t[i] - '0';
	if(ok)
		digit = 9;
	ll ans = 0LL;
	for(;digit >=0;digit--){
		ans = (ans + solve(i+1,(r+digit)%k,ok || ((t[i] - '0') > digit)))%MOD;
	}
	return dp[i][r][ok]=  ans%MOD;
}
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cin >> t >> k;
	n = t.size();
	memset(dp,-1,sizeof dp);
	cout << (solve(0,0,0) - 1LL +MOD)%MOD << endl;
	return 0;
}


Measured memory_bytes: 17280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define endl "\n" 
#define p pair<int, int>
#define arrinp(i, a, start, end); for(ll i = start; i <= end; i++) cin >> a[i];
#define arrout(i, a, start, end); for(ll i = start; i <= end; i++) cout << a[i] << " ";
#define swap(a, b) {a = a + b; b = a - b; a = a - b;
#define forfront(i, start, end) for(ll i = start; i <= end; i++)
#define forback(i, start, end) for(ll i = start; i >= end; i--)
#define out(x) cout << x << " "
#define outline(x) cout << x << endl;
#define sortvector(v) sort(v.begin(), v.end());
#define sortvectorrev(v) sort(v.rbegin(), v.rend());
int main()
{
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int count = 0;
    for(int i = 0; i < n; i++)
    {
        if(s[i] != t[i]) count++;
    }
    outline(count);
    return 0;
}

Measured memory_bytes: 3816
s = list(map(int,input().split("/")))
state = 0
if s[0] <=2019:
    state = 1
    if s[1] <= 4:
        state = 1
        if s[2]<=30:
            state = 1
        else:
            state = 0
    else:
        state = 0
else:
    state = 0
if state == 1:
    print("Heisei")
else:
    print("TBD")

Measured memory_bytes: 3060
N = int(input())
P = list(map(int,input().split()))

cnt = 0
for i in range(1,N-1):
    ppp = [P[i-1], P[i], P[i+1]]
    ppp.sort()
    if ppp[1] == P[i] and ppp[1] != ppp[0]:
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    // int a[n];
    // for (int i = 0; i < n; ++i) {
    //     cin >> a[i];
    // }
    // int count = 0;
    // if (a[0] > x) {
    //     a[0] = x;
    //     count += a[0];
    // }

    long long int count = 0;
    int last = -1;
    int curr;
    for (int i = 0; i < n; ++i) {
        cin >> curr;
        if (last >= 0) {
            if (last + curr > x) {
                count += last + curr - x;
                curr = x - last;
            }
        } else {
            if (curr > x) {
                count += curr - x;
                curr = x;
            }
        }
        // cout << curr << '\t';
        last = curr;
    }
    cout << count << endl;
}

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

int main(){
  int n,i,l;
  int max;
  string str;
  int dp[2][1001];
  
  while(cin>>n,n){
    fill(dp[0],dp[2],0);
    max=0;
    
    for(l=0;l<n;l++){
      cin>>str;
        
      for(i=1;i<=n;i++)
        if(str[i-1]=='*') dp[1][i]=-1;
        
      for(i=1;i<=n;i++){
        if(dp[1][i]!=-1){
          dp[1][i]=min(dp[0][i-1],min(dp[1][i-1],dp[0][i]))+1;
        }
        else dp[1][i]=0;

        if(max<dp[1][i]) max=dp[1][i];
      }
     
      for(i=1;i<=n;i++){
        dp[0][i]=dp[1][i];
        dp[1][i]=0;
      }
    }
    printf("%d\n",max);
  }
  return 0;
}

Measured memory_bytes: 940
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

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

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    string s;
    cin>>s;
    ll tot=0;
    for(auto y:s)
        tot+=(y-'0');
    if(tot%9==0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
	printclock;
	return 0;
}

Measured memory_bytes: 3896
n = int(input())
s = input()
one = [False for _ in range(10)]
two = [False for _ in range(100)]
three = [False for _ in range(1000)]
for i in range(n):
	x = int(s[i])
	for j in range(100):
		if three[j*10+x]:
			continue
		if two[j]:
			three[j*10+x] = True
	for j in range(10):
		if two[j*10+x]:
			continue
		if one[j]:
			two[j*10+x] = True
	one[x] = True
print(sum(three))

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

signed main()
{
    int h , w , k , ans = 0 , brack;
    char c[6][7];

    cin >> h >> w >> k;

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

            brack = 0;
            for(int x=0 ;x<h ;x++ ){
                for(int y=0 ;y<w ;y++ ){
                    if( i&(1<<x) && j&(1<<y) ){
                        if(c[x][y] == '#'){
                            brack++;
                        }
                    }
                }
            }

            if(brack == k){
                ans++;
            }
      
        }
    }

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

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>



using namespace std;
typedef long long ll;
int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}

int moji(char in)
{
    int ans = (int)in-(int)'a'+1;
    if((in < 1) || (in > 26)){
        ans = 100;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}





int main() {
  int N;
  cin>>N;
  int S[4];
  int sum=0;
  for(int i=0;i<4;i++){
    S[i]=0;
  }
  for(int i=0;i<N;i++){
    char x;
    cin>>x;
    if(x=='P'){
      S[0]++;

    }
    if(x=='W'){
      S[1]++;

    }
    if(x=='G'){
      S[2]++;

    }
    if(x=='Y'){
      S[3]++;

    }
  }
  for(int i=0;i<4;i++){
    if(S[i]>0){
      sum++;

    }
  }
  if(sum==3){
    cout<<"Three"<<endl;
  }else{
    cout<<"Four"<<endl;
  }









  


  

  


  

    


  

  
  
  
  
}


  

Measured memory_bytes: 256
n,m,d=map(int,input().split())
if d==0:
    ans=((m-1)*10**7)//n
    print('{:.7g}'.format(ans/10**7))
else:
    ans=(2*(n-d)*(m-1)*10**7)//n**2
    print("{:.7g}".format(ans/(10**7)))

Measured memory_bytes: 38256
import sys
input = sys.stdin.readline

N,K = map(int,input().split())
A = list(map(int,input().split()))

X = A * 2

Nextcount = [-1] * (2 * (10**5+1))
Nextind = [-1]*N

for i,x in enumerate(X):
    if 0 <= Nextcount[x] < N:
        Nextind[Nextcount[x]] = i

    Nextcount[x] = i

Repeatcount=0
NOW = 0

Repeatcount+=Nextind[NOW]-NOW+1
NOW=(Nextind[NOW]+1)%N

while NOW!=0:
    Repeatcount+=Nextind[NOW]-NOW+1
    NOW=(Nextind[NOW]+1)%N
    

Rep=(N*K)%Repeatcount
NOW=0

while True:
    if Nextind[NOW]-NOW+1<Rep:
        Rep-=Nextind[NOW]-NOW+1
        NOW=(Nextind[NOW]+1)%N

    else:
        break
    
#print(Rep,NOW)

from collections import Counter
C=Counter()
s=[]
for i in range(Rep):
    if X[(NOW+i)%N] in C:
        while X[(NOW+i)%N] in C:
            po=s.pop()
            C[po]-=1
            if C[po]==0:
                del C[po]

    else:
        s.append(X[(NOW+i)%N])
        C[X[(NOW+i)%N]]+=1

    #print(s,C)

print(*s)
        
            



Measured memory_bytes: 45300