akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)

int main () {
    
    int n, s;
    cin >> n >> s;
    vector<int> x(n);
    REP(i,n) {cin >> x[i];}
    REP(i,n) {
        x[i] = abs(x[i] - s);
    }

    sort(x.begin(), x.end(), greater<int>());
    while (true) {
        int ok = -1;
        int ng = n;
        while (abs(ng - ok) > 1) {
            int m = (ng + ok) / 2;
            if (x[m] > 0) {
                ok = m;
            } else {
                ng = m;
            }
        }
        if(ng == 1) {
            break;
        } else {
            for (int i = 0; i < ok; i++) {
                x[i] = x[i] % x[ok];
            }
        }
        sort(x.begin(), x.end(), greater<int>());
    }
    cout << x[0] << endl;

    return 0;
}


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

using namespace std;


int main()
{
	int N;
	cin >> N;
	vector<int> d(N);
	for (int i = 0; i < N; i++)
	{
		cin >> d[i];
	}

	int sum = 0;
	for (int i = 0; i < N - 1; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			sum += d[i] * d[j];
		}
	}

	cout << sum << endl;

	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    if (s[0] != s[1] || s[1] != s[2])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(ll, n, a, b, c, d);

    For(i, n){
        ll al = a + c*i;
        ll au = a + d*i;
        ll bl = b + c*(n-1-i);
        ll bu = b + d*(n-1-i);
        if(al <= bu && bl <= au){
            Cout("YES");
            return 0;
        }
    }
    Cout("NO");
}


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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int a[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;    
    vector<bool> used(101);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        used[x] = true;
    }

    for (int i = 0; i < 3; i++) {
        bool ok = true;
        for (int j = 0; j < 3; j++) {
            if (!used[a[i][j]]) ok = false;
        }
        if (ok) {
            cout << "Yes";
            return 0;
        }
    }
    for (int i = 0; i < 3; i++) {
        bool ok = true;
        for (int j = 0; j < 3; j++) {
            if (!used[a[j][i]]) ok = false;
        }
        if (ok) {
            cout << "Yes";
            return 0;
        }
    }
    {
        bool ok = true;
        for (int j = 0; j < 3; j++) {
            if (!used[a[j][j]]) ok = false;
        }
        if (ok) {
            cout << "Yes";
            return 0;
        }
    }
    {
        bool ok = true;
        for (int j = 0; j < 3; j++) {
            if (!used[a[2 - j][j]]) ok = false;
        }
        if (ok) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
typedef long long ll;
using namespace std;

int main() {
    int n, q;
    string s;
    cin >> n >> s >> q;
    while (q--) {
        int k;
        cin >> k;

        ll ans=0, d=0, m=0, dm=0;
        for (int i = 0; i < n; i++) {
            if (i >= k) {
                if (s[i-k] == 'D') {
                    d--;
                    dm -= m;
                } else if (s[i-k] == 'M') {
                    m--;
                }
            }
            if (s[i] == 'D') {
                d++;
            } else if (s[i] == 'M') {
                m++;
                dm += d;
            } else if (s[i] == 'C') {
                ans += dm;
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1412
times = list()
dish_num = 5
for i in range(dish_num):
    times.append(int(input()))

last = 0
for i in range(1, dish_num):
    if ((times[last]+9) % 10) > ((times[i]+9) % 10):
        last = i

for i in range(dish_num):
    if i != last:
        times[i] += (10 - times[i] % 10) % 10

result = 0
for t in times:
    result += t

print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/


struct BIT{
    int n;
    vector<int> bit;
    BIT(){}
    BIT(int n_) : n(n_){
        bit.assign(n_,0);
    }
    int sum(int i){
        int s=0;
        while(i>0){
            s+=bit[i];
            i-=i&-i;
        }
        return s;
    }
    void add(int i,int x){
        while(i<=n){
            bit[i]+=x;
            i+=i&-i;
        }
    }
};

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> l(n),r(n);
    vector<pii> range[100005];
    rep(i,n){
        cin >> l[i] >> r[i];
        int ra = r[i]-l[i]+1;
        range[ra].pb(mp(l[i],r[i]));
    }

    BIT bit(m+1);
    int large = n;
    for(int d=1;d<=m;d++){
        // ステップのある累積和をBITで計算
        int cnt = 0;
        for(int i=d;i<=m;i+=d){
            cnt += bit.sum(i);
        }

        cout << large + cnt << endl;

        // d+1ずつのステップではr-l+1==dのものは非自明
        for(pii p : range[d]){
            bit.add(p.fi,1);
            bit.add(p.se+1,-1);
        }
        large -= range[d].size();
    }
}


Measured memory_bytes: 12160
N,*A=map(int,open(0).read().split());r=range;S=[0]*-~N
for l in r(N):S=[max(S[i+1]+A[i],S[i]+A[i+l])if(l^N)&1else min(S[i+1]-A[i],S[i]-A[i+l])for i in r(N-l)]
print(S[0])

Measured memory_bytes: 44636
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
    ll int jhogeo = 1;
    rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
    return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}

int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  ll int dp[110][100100]={0};
  ll int N,W; cin>>N>>W;
  vector<ll int> w(N+1);
  vector<ll int> v(N+1);
  rep(i,1,N+1) cin>>w[i]>>v[i];
  int check=0;
  
  rep(i,1,N+1){
    dp[i][v[i]]=w[i];
    
    rep(j,1,100101){
      if(dp[i-1][j]){
        dp[i][j+v[i]]=dp[i-1][j]+w[i];
       
      }
      if(dp[i][j]==0) dp[i][j]=dp[i-1][j];
      else if(dp[i][j]&&dp[i-1][j]){
      dp[i][j]=min(dp[i][j],dp[i-1][j]);
      }
    }
  }
  ll int max=-1;
  rep(i,0,100101){
    if(dp[N][i]&&dp[N][i]<=W) max=i;
  }
  cout<<max<<endl;//<<" "<<check;
 // cout<<dp[1][v[1]]<<w[1];
/* rep(i,1,N+1){
   rep(j,0,18){
     cout<<dp[i][j]<<" ";
   }
   cout<<endl;
 }*/
  
  
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順

Measured memory_bytes: 86272
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 2010, md = 924844033;
int c[MAXN][MAXN];
int combination(int k, int n) {
    if (k > n)
        return 0;
    if (c[k][n])
        return c[k][n];
    if (!k || !n)
        return c[k][n] = 1;
    return c[k][n] = ( combination(k, n - 1) + combination(k - 1, n - 1) ) % md;
}
int dp[2 * MAXN][MAXN], fact[MAXN];
int32_t main () {
    fact[0] = 1;
    for (int i = 1; i < MAXN; ++i)
        fact[i] = fact[i - 1] * i % md;
    int n, k;
    cin >> n >> k;
    dp[0][0] = 1;
    for (int i = 0; i < 2 * k; ++i) {
        int cnt = n - 1 - (i % k);
        cnt /= k;
        ++cnt;
        --cnt;
        for (int now = 0; 2 * now - 1 <= cnt; ++now) 
            for (int j = 0; j + now <= n; ++j) {
                dp[i + 1][j + now] += dp[i][j] * combination(now, cnt - now + 1) % md;
                if (dp[i + 1][j + now] >= md)
                    dp[i + 1][j + now] %= md;
            }
    }
    int ans = 0;
    for (int i = 0; i <= n; ++i) {
        ans += (dp[2 * k][i] * (i & 1 ? md - 1 : 1) % md) * fact[n - i] % md;
        if (ans >= md)
            ans %= md;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 63744
'use strict'

const main = (input) => {
    const a = input.split('\n')[0]
    const b = input.split('\n')[1]

    if(a.length > b.length){
        console.log('GREATER')
        return 
    }else if(a.length < b.length){
        console.log('LESS')
        return
    }

    const aStr = a.split('')
    const bStr = b.split('')

    for(let i = 0; i <= aStr.length; i++){
        if(aStr[i] > bStr[i]){
            console.log('GREATER')
            return
        }else if(aStr[i] < bStr[i]){
            console.log('LESS')
            return
        }
    }
    console.log('EQUAL')
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

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

int main() {
 int N, Y;
 cin >> N >> Y;
  
 int res10 = -1, res5 = -1, res1 = -1;
  
  for(int a = 0; a <= N; a++){
    for(int b = 0; b + a <= N; b++){
      int c = N - a - b;
      int sum = 10000 * a + 5000 * b + 1000 * c;
      if ( Y == sum ){
        res10 = a;
        res5 = b;
        res1 = c;
      }
    }
  }
  cout << res10 << ' ' <<res5 << ' ' << res1 << endl;
}

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

using namespace std;
typedef long long ll;
const int MAXL = 1.5e6;

int L;
int cv[MAXL];
int cnext[MAXL][26];
int ccnt[MAXL][26];
int ssize[MAXL];
int par[MAXL];
bool has[MAXL];

int N;

int main()
{
    ios_base::sync_with_stdio(0);

    L = 1;
    cv[0] = -1;
    
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        string S; cin >> S;

        int cloc = 0;
        for (int j = S.length() - 1; j >= 0; j--)
        {
            int nc = S[j] - 'a';
            if (!cnext[cloc][nc])
            {
                cnext[cloc][nc] = L;
                par[L] = cloc;
                cv[L] = nc;
                L++;
            }
            cloc = cnext[cloc][nc];
        }
        has[cloc] = true;
    }

    for (int i = L - 1; i > 0; i--)
    {
        if (has[i]) ssize[i]++;
        ssize[par[i]] += ssize[i];
        for (int j = 0; j < 26; j++)
        {
            int v = ccnt[i][j];
            if (j == cv[i]) v = ssize[i];
            ccnt[par[i]][j] += v;
        }
    }

    ll ans = 0;
    for (int i = 1; i < L; i++)
        if (has[i])
        {
            ans += ccnt[par[i]][cv[i]] - 1;
            //cout << par[i] << " " << cv[i] << " " << ccnt[par[i]][cv[i]] << "\n";
        }
    cout << ans << "\n";
}

Measured memory_bytes: 219144
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


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

	cout << (A-1)*(B-1) << endl;


	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long

int main() {
 int right,up,n;
 cin>>right>>up>>n;
 int x[n],y[n],a[n];
 int left=0,down=0;
 int siro=0;
 rep(i,n){
    cin>>x[i]>>y[i]>>a[i];
 }
 rep(i,n){
     if(a[i]==1)left=max(left,x[i]);
     if(a[i]==2)right=min(right,x[i]);
     if(a[i]==3)down=max(down,y[i]);
     if(a[i]==4)up=min(up,y[i]);
 }
 if(right>=left&&up>=down){
  siro=(right-left)*(up-down);
  cout<<siro<<endl;
 }
 else cout<<0<<endl;
 
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define MOD 1000000007

int main() {
  ll N;

  cin >> N;

  vector<vector<vector<double> > > lst(
      N + 2, vector<vector<double> >(N + 2, vector<double>(N + 2, 0.0)));
  vector<ll> cnts(3 + 1, 0);

  for (int i = 0; i < N; i++) {
    ll tmp;
    cin >> tmp;
    cnts[tmp]++;
  }

  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      for (int k = 0; k <= N; k++) {
        if(i == 0 && j == 0 && k == 0){
          lst[i][j][k] = 0.0;
          continue;
        }
        double cntr3 = (i >= 1) ? ((double)i/N)*lst[i-1][j+1][k] : 0.0;
        double cntr2 = (j >= 1) ? ((double)j/N)*lst[i][j-1][k+1] : 0.0;
        double cntr1 = (k >= 1) ? ((double)k/N)*lst[i][j][k-1] : 0.0;
        lst[i][j][k] = (1.0 + cntr3 + cntr2 + cntr1)*N/(i+j+k);
      }
    }
  }

  double ans = lst[cnts[3]][cnts[2]][cnts[1]];

  printf("%.15f\n", ans);

  return 0;
}


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

int A,B,K;

void solve(){
  if(B-A+1>=2*K){
    for(int i=0; i<K; i++){
      cout << A+i << endl;
    }
    for(int i=K-1; i>=0; i--){
      cout << B-i << endl;
    }  
  }else{
    for(int i=A; i<=B; i++){
      cout << i << endl;
    }
  }
}

int main(){
  cin >> A >> B >> K;
  solve();
}

Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var k = int.Parse(line[1]);
            if (n == 0 && k == 0) break;
            string[] line2 = Console.ReadLine().Trim().Split(' ');
            var s = Array.ConvertAll(line2, int.Parse);
            string[] line3 = Console.ReadLine().Trim().Split(' ');
            var b = Array.ConvertAll(line3, int.Parse);
            if (n > 1)
                for (int i = 1; i < n; i++)
                {
                    string[] line4 = Console.ReadLine().Trim().Split(' ');
                    for (int j = 0; j < k; j++)
                        b[j] += int.Parse(line4[j]);
                }
            for (int i = 0; i < k; i++)
                if (b[i] > s[i]) { Console.WriteLine("No"); goto end; }
            Console.WriteLine("Yes");
            end:;
        }
    }
}

Measured memory_bytes: 9544
//--- pD ---//
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Scanner scanner;
	int mod = (int)1e9+7;

	public Solution() {
		scanner = new Scanner(System.in);

		// scanner.nextLine();
		while (scanner.hasNext()) {
			run_case();
		}
	}

	private void run_case() {
		int[] arr = strToIntArray(scanner.nextLine());
		int n = arr[0], m = arr[1], k = arr[2];

		// boolean[][] vis = new boolean[n][n];

		// int[] res = new int[n];
		// Arrays.fill(res, n-1);

		DJSet uf = new DJSet(n);

		Map<Integer, Set<Integer>> map = new HashMap<>();
		for (int i=0; i<m; i++) {
			arr = strToIntArray(scanner.nextLine());
			int a = Math.min(arr[0], arr[1]);
			int b = Math.max(arr[0], arr[1]);
			a--;
			b--;

			// if (vis[a][b]) continue;
			// vis[a][b] = true;
			uf.union(a, b);
			map.putIfAbsent(a, new HashSet<>());
			map.get(a).add(b);
			map.putIfAbsent(b, new HashSet<>());
			map.get(b).add(a);
		}

		for (int i=0; i<k; i++) {
			arr = strToIntArray(scanner.nextLine());
			int a = Math.min(arr[0], arr[1]);
			int b = Math.max(arr[0], arr[1]);
			a--;
			b--;
			map.putIfAbsent(a, new HashSet<>());
			map.get(a).add(b);
			map.putIfAbsent(b, new HashSet<>());
			map.get(b).add(a);
		}

		int[] res = new int[n];
		for (int i=0; i<n; i++) {
			int t = uf.getSize(i) - 1;
			if (map.get(i) != null) {
				for (int u: map.get(i)) {
					if (uf.equiv(i, u)) t--;
				}
			}
			res[i] = t;
		}

		StringBuilder sb = new StringBuilder();
		for (int i=0; i<n; i++) {
			sb.append(String.valueOf(res[i]) + " ");
		}
		System.out.println(sb.toString().trim());
		return;
	}

	private int[] strToIntArray(String str) {
	    String[] vals = str.split("\\s+");
	    int sz = vals.length;
	    int[] res = new int[sz];
	    for (int i=0; i<sz; i++) {
	        res[i] = Integer.parseInt(vals[i]);
	    }
	    return res;
	}
}

class DJSet {
	public int[] upper;
    public int[] size;

	public DJSet(int n) {
		upper = new int[n];
		Arrays.fill(upper, -1);

        size = new int[n];
        Arrays.fill(size, 1);
	}

	public int find(int x) {
		return upper[x] < 0 ? x : (upper[x] = find(upper[x]));
	}

	public boolean equiv(int x, int y) {
		return find(x) == find(y);
	}

	public boolean union(int x, int y) {
		x = find(x);
		y = find(y);
		if (x != y) {
			if (upper[y] < upper[x]) {
				int d = x;
				x = y;
				y = d;
			}
            size[x] += size[y];
			upper[x] += upper[y];
			upper[y] = x;
		}
		return x == y;
	}

	public int count() {
		int ct = 0;
		for (int u : upper)
			if (u < 0)
				ct++;
		return ct;
	}

    public int getSize(int x) {
        return size[find(x)];
    }
}


// 1 2 3 4
//
//  1 0 2


Measured memory_bytes: 322588
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
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);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int n,k;
    cin >> n >> k;
    vector <ll> a(n+1);
    for(ll i =1;i <=n ;i++) {
        cin >> a[i];
    }
    // vector <ll> b(n+1);
    // ll tmp = 1;
    // for (ll i = 1; i < k; i++) {
    //     tmp *= a[i];
    // }

    // for (ll i = k; i<= n; i++) {
    //     tmp *= a[i];
    //     b[i] = tmp;
    //     tmp /= a[i-k+1];
    // }
    for (ll i = k+1; i<= n; i++) {
        if (a[i] > a[i-k]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 4448
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 1005;

void p0() {
	cout << "0\n";
	exit(0);
}

int power(int base, int exp) {
	int ans = 1;
	while(exp) {
		if(exp&1)
			ans = (ans * base) % MOD;
		base = (base * base) % MOD;
		exp /= 2;
	}
	return ans;
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
    
    int n, te;
    cin >> n;
    vector<int> a(n);
    rep(i,n) {
    	cin >> te;
		if(te >= n)
			p0();
		a[te]++;
    }

    int st = (n%2 == 0);

    for(int i = st; i <= n - 1; i += 2) {

    	if(((i == 0 and a[i]==1) || a[i]==2)) 
    		continue;
    	else
    		p0();
    }

    cout << power(2, n/2) << '\n';
}	

Measured memory_bytes: 1024
/*
* @Author: Nazrul Islam
* @Date:   2020-09-19 13:36:18
* @Last Modified by:   Nazrul Islam
* @Last Modified time: 2020-09-19 13:39:15
*/

#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll; 
typedef double dd;
typedef vector<int> vi;
typedef vector<char> vc;
typedef list<int> li;
typedef set<int> si;
typedef map<int,int> mp;
#define pb push_back
#define pf push_front
#define mk make_pair
#define sc scanf
#define pr printf
#define pi acos(-1.0)
#define endl '\n'
// char s[200009];
// char st[200009];
// int a[600][600];
// int b[29][10];
// int a[200009];
// int c[200009];
void solve()
{
	ll n, m, i, j, k, l; 
	cin >> n; m = n; ll sm = 0;
	while(n) {
		ll p = n%10;
		n = n/10;
		sm = sm + p;
	}
	if(m % sm == 0) cout << "Yes" << endl;
	else cout << "No" << endl; 
}
int main()
{
	IO;
	int t; 
	t = 1;
	// cin >> t;
	while(t--)
		solve();
	return 0;
}

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

using namespace std;

int main() {

    int N, D;
    cin >> N >> D;

    int p = 0, q = 0, cnt = 0;
    for (int i = 0; i < N; i++) {
        cin >> p >> q;
        if (sqrt(pow(abs(p), 2) + pow(abs(q), 2)) <= D) {
            cnt++;
        }
    }

    cout << cnt << endl;

}

Measured memory_bytes: 3700
k=int(input())
a,b=map(int,input().split())
if b-a>=k:
    print("OK")
else:
    m=0
    for i in range(a,b+1):
        if i%k==0:
            print("OK")
            m=1
            break
    if m==0:
        print("NG")

Measured memory_bytes: 9096
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(){
  int N,M;
  scanf("%d %d",&N,&M);
  int i,j,k=0;
  int A[M];
  
  for(i=0;i<M;i++)
    scanf("%d ",&A[i]);
  
  qsort(A, sizeof(A) / sizeof(int), sizeof(int), asc);
  int B[M-1];
  for(i=0;i<M-1;i++){
    B[i] = abs(A[i]-A[i+1]);
  }
  qsort(B, sizeof(B) / sizeof(int), sizeof(int), asc);
  if(N >= M){
    puts("0");
    return 0;
  }
  
  else{
    for(i=0;i<M-N;i++)
      k+=B[i];
    printf("%d\n",k);
    return 0;
  }
}
  
  

Measured memory_bytes: 1396
/*
	容斥原理, 状压 dp
	状态 f[i][s] 表示考虑了前 i 个 M 集合的元素, 状态为 S 的位置集合不合法 
	从大到小考虑 M 集合, 转移没有后效性
	状态设的 S 表示选的位置集合 
*/
#include <bits/stdc++.h>
#define N 16

using namespace std;

const int mod = 1e9 + 7;

int n, m;
int fac[(1 << N) + 3], ifac[(1 << N) + 3];
int a[N + 3], f[N + 1][1 << N];

inline int fpm(int x, int y) {
	int re = 1;
	while(y) {
		if(y & 1) re = 1LL * re * x % mod;
		x = 1LL * x * x % mod, y >>= 1;
	}
	return re;
}
void init(int n) {
	fac[0] = 1;
	for(int i = 1; i <= n; ++i) fac[i] = 1LL * i * fac[i - 1] % mod;
	ifac[n] = fpm(fac[n], mod - 2);
	for(int i = n; i; --i) ifac[i - 1] = 1LL * i * ifac[i] % mod;
}

inline int perm(int n, int k) { return 1LL * fac[n] * ifac[n - k] % mod; }
inline int comb(int n, int k) { return 1LL * perm(n, k) * ifac[k] % mod; }

int main() {
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; ++i)
		scanf("%d", &a[i]);
	reverse(a + 1, a + m + 1);
	
	f[0][0] = 1;
	int upp = 1 << n;
	
	init(upp);
	
	for(int i = 0; i < m; ++i) {
		for(int s = 0; s < upp; ++s) {
			if(!f[i][s]) continue;
			f[i + 1][s] = (f[i + 1][s] + f[i][s]) % mod; // 不做决策
			int rem = upp - a[i + 1];
			for(int j = 0; j < n; ++j)
				if(s >> j & 1)
					rem -= (1 << j);
			for(int j = 0; j < n; ++j)
				if(~s >> j & 1) {
					if(rem < (1 << j) - 1) continue;
					f[i + 1][s | (1 << j)] = (f[i + 1][s | (1 << j)] +
					1LL * f[i][s] * fac[1 << j] % mod
					 * comb(rem, (1 << j) - 1)) % mod;
				}
		}
	}
	
	int ans = 0;
	for(int s = 0; s < upp; ++s) {
		int re = f[m][s], rem = upp - 1, cnt = 0;
		for(int i = 0; i < n; ++i)
			if(s >> i & 1) {
				++cnt;
				rem -= 1 << i;
			}
		re = 1LL * re * fac[rem] % mod;
		if(cnt & 1) {
			ans = (ans - re + mod) % mod;
		} else {
			ans = (ans + re) % mod;
		}
	}
	ans = 1LL * ans * fpm(2, n) % mod;
	
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4096
# -*- coding: utf-8 -*-
"""
Network Flow - Maximum Flow
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A&lang=jp

"""
import sys
from sys import stdin
from collections import namedtuple
input = stdin.readline

edge = namedtuple('edge', ['to', 'cap', 'rev'])

def add_edge(G, f, t, c):
    G[f].append(edge(t, c, len(G[t])))
    G[t].append(edge(f, 0, len(G[f]) - 1))


def dfs(G, used, v, t, f):
    if v == t:
        return f
    used[v] = True
    for i in range(len(G[v])):
        e = G[v][i]
        if (not used[e.to]) and (e.cap > 0):
            d = dfs(G, used, e.to, t, min(f, e.cap))
            if d > 0:
                G[v][i] = edge(e.to, e.cap - d, e.rev)
                G[e.to][e.rev] = edge(G[e.to][e.rev].to, G[e.to][e.rev].cap + d, G[e.to][e.rev].rev)
                return d
    return 0


def max_flow(G, V,s, t):
    used = [False] * V
    flow = 0
    while True:
        for i in range(len(used)):
            used[i] = False
        f = dfs(G, used, s, t, float('inf'))
        if f == 0:
            return flow
        flow += f


def main(args):
    V, E = map(int, input().split())

    G = [[] for _ in range(V)]
    for _ in range(E):
        u, v, c = map(int, input().split())
        add_edge(G, u, v, c)

    ans = max_flow(G, V, 0, V - 1)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])



Measured memory_bytes: 6084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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()
{
    ll x, k, d; cin >> x >> k >> d;

    ll m = abs(x) / k;
    ll ans;
    if(d <= m){
        ans = abs(abs(x) - k*d); 
    }else{
        ll t = abs(x) / d;
        ll s = t + 1;

        if(t%2 == k%2){
            ans = abs(abs(x) - t*d);
        }else{
            ans = abs(abs(x) - s*d);
        }
    }
    pr(ans);
    return 0;}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h, w;
    cin >> h >> w;
    vvi a(h, vi(w));
    rep(i, h) rep(j, w) {
        cin >> a[i][j];
        a[i][j] %= 2;
    }
    vector<pair<P, P>> ans;
    rep(i, h) {
        rep(j, w) {
            if (i == h-1 && j == w-1) break;
            if (j == w-1 && a[i][j] == 1) {
                ans.eb(P(i+1, j+1), P(i+2, j+1));
                a[i][j] = 0;
                a[i+1][j] = 1 - a[i+1][j];
                break;
            }
            if (a[i][j] == 1) {
                ans.eb(P(i+1, j+1), P(i+1, j+2));
                a[i][j] = 0;
                a[i][j+1] = 1 - a[i][j+1];
            }
        }
    }
    cout << sz(ans) << endl;
    rep(i, sz(ans)) printf("%d %d %d %d\n", ans[i].fi.fi, ans[i].fi.se, ans[i].se.fi, ans[i].se.se);
}

Measured memory_bytes: 5236
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = (int)1e9 + 7;
int INF = (int)2e18;


signed main() {
    int N;
    cin >> N;
    deque<int> negative, positive;
    for (int i = 0; i < N; i++) {
        int temp;
        cin >> temp;
        if (temp <= 0) negative.push_back(temp);
        else positive.push_back(temp);
    }
    sort(negative.begin(), negative.end());
    sort(positive.begin(), positive.end());
    vector<pair<int, int>> ans;
    if (negative.empty()) {
        int big = positive.back();
        int small = positive.front();
        positive.pop_back();
        positive.pop_front();
        ans.emplace_back(small, big);
        negative.push_back(small - big);
    } else if (positive.empty()) {
        int big = negative.front();
        int small = negative.back();
        negative.pop_back();
        negative.pop_front();
        ans.emplace_back(small, big);
        positive.push_back(small - big);
    }
    while (positive.size() != 1) {
        int big = positive.back();
        int small = negative.front();
        positive.pop_back();
        negative.pop_front();
        ans.emplace_back(small, big);
        negative.push_back(small - big);
    }
    while (!negative.empty()) {
        int big = positive.back();
        int small = negative.front();
        positive.pop_back();
        negative.pop_front();
        ans.emplace_back(big, small);
        positive.push_back(big - small);
    }
    cout << positive.front() << endl;
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i].first << " " << ans[i].second << endl;
    }
}


Measured memory_bytes: 4468
#include <iostream>
#include<cstring>
using namespace std;
char s[200005];
int vc[28];
int main()
{
    char c;
    long long sm=1;
    int n=1;
    cin>>(s+1);
    while(s[n]!=0)
    {
        vc[s[n]-'a']++;
        sm+=n-vc[s[n]-'a'];
        n++;
    }
    cout<<sm;
    return 0;
}


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

const double eps = 1e-9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define FORD(i,a,b) for (int i = int(b)-1; i >= (a); i--)
#define FORIT(i,c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define mp make_pair
#define pb push_back
#define mscanf(...) if(0 == scanf(__VA_ARGS__)){fprintf(stderr, "Could not parse arguments\n");}

const int MAXN = 712;
int par[MAXN];
int msize[MAXN];
int gpar(int n){
    if(par[n] == n)return n;
    return par[n] = gpar(par[n]);
}

bool adjm[MAXN][MAXN];
vi forbidden[MAXN];
bool fail;
void resolve(int n){
    if(gpar(n) != n || fail)return;
    bool merged = false;
    int id = -1;
    for(auto to: forbidden[n]){
        to = gpar(to);
        if(to == n)fail = true;
        else if(id == -1)id = to;
        else if(id != to){
            merged = true;
            msize[id] += msize[to];
            msize[to] = 0;
            par[to] = id;
            for(auto it: forbidden[to])forbidden[id].push_back(it);
            forbidden[to].clear();
        }
    }
    forbidden[n].clear();
    if(id != -1)forbidden[n].push_back(id);
    if(merged)resolve(id);
}

bool dp[MAXN];

int main(){
    int N,M;
    mscanf("%d%d",&N,&M);
    FOR(i,0,N)FOR(j,0,N)adjm[i][j] = (i==j);
    FOR(i,0,M){
        int a,b;
        mscanf("%d%d",&a,&b);
        --a;--b;
        adjm[a][b] = adjm[b][a] = 1;
    }
    FOR(i,0,N)forbidden[i].clear();
    FOR(i,0,N)FOR(j,0,N)if(!adjm[i][j])forbidden[i].push_back(j);
    FOR(i,0,N)par[i] = i;
    FOR(i,0,N)msize[i] = 1;
    fail = false;
    FOR(i,0,N)resolve(i);
    if(fail){
        cout << -1 << endl;
    } else {
        int NH = N/2+1;
        FOR(j,0,NH)dp[j] = false;
        dp[0] = true;
        FOR(n,0,N)if(gpar(n) == n){
            assert(sz(forbidden[n]) <= 1);
            if(sz(forbidden[n]) == 1){
                assert(forbidden[n][0] != n);
                assert(sz(forbidden[forbidden[n][0]]) == 1);
                assert(forbidden[forbidden[n][0]][0] == n);
                if(n > forbidden[n][0])continue;
            }
            if(sz(forbidden[n]) == 1){
                int s1 = msize[n], s2 = msize[forbidden[n][0]];
                FORD(j,0,NH)dp[j] = (((j>=s1)?dp[j-s1]:false) | ((j>=s2)?dp[j-s2]:false));
            } else {
                assert(sz(forbidden[n]) == 0);
                int s = msize[n];
                FORD(j,0,NH)dp[j] = (dp[j] | ((j>=s)?dp[j-s]:false));
            }
        }
        --NH;
        while(!dp[NH])--NH;
        int nH = N - NH;
        cout << ((NH * (NH-1)) + (nH * (nH-1)))/2 << endl;
    }
	return 0;
}


Measured memory_bytes: 5760
#include "bits/stdc++.h"
using namespace std;
 
typedef long long ll;
typedef long double f80;
 
// #define int long long
#define pii pair<int,int>
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ef emplace_front
#ifndef LOCAL
#define endl '\n'
#endif

const int mod = 1e9 + 7;

ll pwr(ll a, ll b) {
    ll ans = 1;
    while(b) {
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

const int N = 3e5 + 5;
ll dp[N], a[N];

multiset<int> s;

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int n;
    cin >> n;
    ll cur = 0;
    fr(i, 1, 3 * n) {
        cin >> a[i];
        s.insert(a[i]);
        cur += a[i];
        if(sz(s) > n){
            cur -= *s.begin();
            s.erase(s.begin());
        }
        dp[i] = cur;
    }
    s.clear();
    cur = 0;
    ll ans = -1e18;
    for(int i = 3 * n; i >= 1; i--) {
        cur += a[i];
        s.insert(a[i]);
        if(sz(s) > n) {
            auto it = s.end();
            it--;
            cur -= *it;
            s.erase(it);
        }
        if(i > n && sz(s) == n) {
            ans = max(ans, dp[i - 1] - cur);
        }
    }
    cout << ans;
    return 0;
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

const int dx[4] = {+1, 0, -1, 0};
const int dy[4] = {0, -1, 0, +1};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    ll ans = 0, d = 5;
    if(n %2 == 0){
        while(1){
            ans += ((n / d) / 2);
            if(n < d) break;
            d *= 5;
        }
        cout << ans << endl;
    }else{
        cout << 0 << endl;
    }
}

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

int main()
{
  string s;
  int k;
  cin >> k >> s;

  if(s.length()<=k)cout << s <<endl;
  else{
    for(int i=0; i<k; i++){
      cout << s[i];
    }
    cout << "...\n";
  }

  return 0;
}

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

static long p[200200];

int main()
{
	long i,j,N,K,tmp,max,m_id=0;
	i=0;
	scanf("%ld%ld",&N,&K);
	//for(i=0;i<100010100;i++)obj[i].h=0;
	for(i=0;i<N;i++){
		scanf("%ld",&p[i]);
	}
	max=-1;tmp=0;
	for(i=0;i<=N-K;i++){
		if(i==0){
			for(j=i;j<i+K;j++){
			tmp += p[j];
			}
		}
		else{
			tmp += p[i+K-1]-p[i-1]; 
		}
		if(tmp>max){
			max = tmp;
			m_id=i;
		}
	}
	//printf("%ld ",m_id);	
	double ans=0;
	for(i=m_id;i<m_id+K;i++){
		
		ans += (double)(p[i]*(p[i]+1))/2. /(double)p[i];
	}
	
	printf("%lf\n",ans);
	return 0;
}

Measured memory_bytes: 1664
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  return a < b ? b - a : a - b;
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a)
    a = b;
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b)
    a = b;
}
template <class F> class rec_lambda {
  F f;

public:
  rec_lambda(F &&f) : f(std::move(f)) {}
  template <class... Args> auto operator()(Args &&... args) const {
    return f(*this, std::forward<Args>(args)...);
  }
};
template <class F> auto make_rec(F &&f) { return rec_lambda<F>(std::move(f)); }
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const usize n = scan<usize>();
  const u64 m = scan<u64>();
  const auto add = [&](u64 &l, const u64 r) { l = (l + r) % m; };
  auto dp = md_vec(3 * n + 1 + 3, n + 1 + 1, u64(0));
  dp[0][0] = 1;
  for (const usize i : rep(0, 3 * n + 1)) {
    for (const usize j : rep(0, n + 1)) {
      add(dp[i + 1][j], dp[i][j]);
      add(dp[i + 2][j + 1], dp[i][j] * (i + 1) % m);
      add(dp[i + 3][j + 1], dp[i][j] * (i + 1) % m * (i + 2) % m);
    }
  }
  u64 ans = 0;
  for (const usize i : rep(0, n + 1)) {
    add(ans, dp[3 * n][i]);
  }
  std::cout << ans << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 94464
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define testcase int t;cin>>t;while(t--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<long long int,long long int>
#define ub upper_bound // '>'
#define lb lower_bound // '>='
//erase,count,find,make_unique
#define len(arr) (sizeof(arr)/sizeof(arr[0]))
#define make_unique(arr) arr.erase(unique(arr.begin(),arr.end()),arr.end()) //Makes a sorted array unique
#define rep(a,b) for(int i=a;i<b;i++)
#define updiv(a,b) (ceil)((a)*(1.0)/(b))
//LLONG_MAX, ULLONG_MAX INT_MAX
typedef long long int ll;
typedef unsigned long long int ull;
#define M 1000000007
using namespace std;
int main()
{
    fast
ll n;
cin>>n;
int a[n+1],b[n+1],c[n+1];
for(ll i=1;i<=n;i++)
{
    cin>>a[i]>>b[i]>>c[i];
}
ll dp[n+1],m[n+1];//dp[]={a1,b1,c1}
dp[1]=a[1];dp[2]=b[1];dp[3]=c[1];
for(ll i=2;i<=n;i++)
{
    m[1]=max(a[i]+dp[2],a[i]+dp[3]);
    m[2]=max(b[i]+dp[1],b[i]+dp[3]);
    m[3]=max(c[i]+dp[1],c[i]+dp[2]);
    //3 times here 3 is number of activities
    dp[1]=m[1];dp[2]=m[2];dp[3]=m[3];
}//dp[]={x,y,z}
//Here
//x is total points if 'a' activity is performed on nth day
//y is total points if 'b' activity is performed on nth day
//z is total points if 'c' activity is performed on nth day

//cout<<dp[1]<<" "<<dp[2]<<" "<<dp[3]<<endl;
 ll res=max({dp[1],dp[2],dp[3]});
 cout<<res<<endl;
return 0;
}








Measured memory_bytes: 1408