akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
using namespace std;
char s[51][51],b[51][51];
int a[51][51];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s[i]);
		for(int j=0;j<m;j++)
		{
			if(s[i][j]=='#')
			{
				a[i][j+1]=1;
				b[i][j+1]='#';
			}
			else
			a[i][j+1]=0;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			ans=0;
			if(a[i][j]==0)
			{
				if(a[i-1][j-1]==1)
				{
					ans++;
				}
				if(a[i-1][j]==1)
				{
					ans++;
				}
				if(a[i][j-1]==1)
				{
					ans++;
				}
				if(a[i][j+1]==1)
				{
					ans++;
				}
				if(a[i+1][j]==1)
				{
					ans++;
				}
				if(a[i+1][j+1]==1)
				{
					ans++;
				}
				if(a[i+1][j-1]==1)
				{
					ans++;
				}
				if(a[i-1][j+1]==1)
				{
					ans++;
				}
				b[i][j]=ans+'0';
			}
			
		}
		
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			printf("%c",b[i][j]);
		} 
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


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

    int t=1,te=0;
    // cin>>t;
    while(t--){
        int a,b;
        cin>>a>>b;


        if(max(a,b)<=8){
            printf("Yay!\n");
        }
        else{
            printf(":(\n");
        }


        //printf("Case %d: ",++te);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    int out=1<<29;
    vector<int> W(N,0);
    cin >> W[0];
    for(int i=1;i<N;i++){
        int t; cin >> t;
        W[i] += W[i-1]+t;
    }
    for(int i=0;i<N;i++){
        int s1=W[i];
        int s2=W[N-1]-W[i];
        if(out>abs(s1-s2)){
            out = abs(s1-s2);
        }
    }
    cout << out << endl;
    return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
typedef long long ll;

int main() {
    int N;
    cin >> N;
    int ans = 1;

    int increase = 0;
    int a, b;
    cin >> a;
    FOR(i, 1, N) {
        cin >> b;
        if(increase == 0) {
            if(a < b) increase = 1;
            else if(a == b) increase = 0;
            else increase = -1;
        } else {
            if(increase == 1) {
                if(a > b) {
                    increase = 0;
                    ++ans;
                }
            } else {
                if(a < b) {
                    increase = 0;
                    ++ans;
                }
            }
        }
        a = b;
    }
    cout << ans << endl;
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

const int N = 2e5 + 5;

vi adj[N];
int vis[N];
int cnt = 0;

void dfs(int nd) {
    cnt++;
    vis[nd] = 1;

    for(auto ch : adj[nd]) {
        if(!vis[ch]) {
            dfs(ch);
        }
    }
}

int main(){
    fIO
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    int n, m;
    cin >> n >> m;

    for(int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;

        adj[x].pb(y);
        adj[y].pb(x);
    }

    int mx = 0;
    for(int i = 0; i < n; i++) {
        if(!vis[i]) {
            cnt = 0;
            dfs(i);
            mx = max(mx, cnt);
        }
    }

    cout << mx;
}








Measured memory_bytes: 21496
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
//const ll MOD = 998244353
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; string s;
    cin >> N >> s;
    rep(i,s.size()) {
        s[i] += N;
        if (s[i] > 'Z') s[i] -= 26;
    }
    cout << s << endl;
}

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

const int inf = 1 << 28;

int main(void){
	int n,k;
	while(cin >> n >> k,n){
		int dist[110][110];
		rep(i,n)rep(j,n) dist[i][j]=inf;
		rep(i,n) dist[i][i]=0;
		rep(loop,k){
			int type;
			cin >> type;
			if(type){
				int a,b,c;
				cin >> a >> b >> c;
				a--,b--;
				dist[a][b]=min(dist[a][b],c);
				dist[b][a]=min(dist[b][a],c);
				rep(i,n)rep(j,n) dist[i][j]=min(dist[i][j],dist[i][a]+dist[a][j]);
				rep(i,n)rep(j,n) dist[i][j]=min(dist[i][j],dist[i][b]+dist[b][j]);
			}else{
				int a,b;
				cin >> a >> b;
				a--,b--;
				if(dist[a][b]==inf)
					cout << -1 << endl;
				else
					cout << dist[a][b] << endl;
			}
		}
	}
}

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

int main() {
    int N;
    std::cin >> N;

    int ct = 0, cx = 0, cy = 0;
    int t, x, y;
    for (int i = 0; i < N; ++i) {
        std::cin >> t >> x >> y;

        const int dt = t - ct;
        const int dist = std::abs(x - cx) + std::abs(y - cy);

        if (dt < dist) {
            std::cout << "No\n";
            return 0;
        }

        if (dist % 2 == 0) {
            if (dt % 2 != 0) {
                std::cout << "No\n";
                return 0;
            }
        } else {
            if (dt % 2 == 0) {
                std::cout << "No\n";
                return 0;
            }
        }

        ct = t;
        cx = x;
        cy = y;
    }

    std::cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int n,i,j,k;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int maior = -1;
    int pos;
    for(i=1;i<n;i++){
        for(j=0;j<i;j++){
            k=a[i]-a[j];
            if(k<0)
                k=k*-1;
            if(k>maior){
                maior = k;
            }
        }
    }
    printf("%d \n",maior);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
typedef long long ll;
#define min(a, b) ((a) < (b) ? (a) : (b))
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数
long long gcd(long long a, long long b)
{
	if (a % b == 0) {
		return(b);
	}
	else {
		return(gcd(b, a % b));
	}
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	// cout << std::fixed << std::setprecision(15);

	string S, T, U;
	int A, B;
	cin >> S >> T >> A >> B >> U;
	if (S == U) {
		cout << --A << " " << B << endl;
	}
	else if (T == U) {
		cout << A << " " << --B << endl;
	}
	else {
		cout << A << " " << B << endl;
	}
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        List<Integer> p = new ArrayList<>();
        for (int i=0; i<N; i++) {
            p.add(sc.nextInt());
        }

        int ans = 0;
        for (int i=0; i<N; i++) {
            if (shouldBeChanged(i, p)) {
                i++; ans++;
            }
        }

        System.out.println(ans);
    }

    private static boolean shouldBeChanged(int index, List<Integer> p) {
        return (p.get(index) == index+1);
    }
}


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

int main() {
  int a,b,c;
  cin >>a >>b;
  if(a+b>a-b){
    if(a+b>a*b){
      cout <<a+b <<endl;
    }
    else{
      cout <<a*b <<endl;
    }
  }
  else{
    if(a-b>a*b){
      cout <<a-b <<endl;
    }
    else{
      cout <<a*b <<endl;
    }
  }
}

Measured memory_bytes: 256
#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);
    int r; cin >> r;
    cout << 3 * r * r << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;
int main(){
  int N,Y;cin>>N>>Y;
  Y /= 1000;
  Y-=N;
  bool ok = false;
  for(int i = 0; N >= i; i++){
    for(int j = 0; N-i >= j; j++){
      if(4*i+9*j == Y){
        cout << j << " " << i << " " << N-i-j << endl;
        ok = true;
        break;
      }
    }
    if(ok)break;
  }
  if(!ok){
    cout << -1 << " " << -1 << " " << -1 << endl;
  }
}

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

using namespace std;

typedef long long ll;

const ll mod = 1000000007;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<bool> broken(n+1, false);
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        broken[a] = true;
    }

    vector<ll> fib(n+1);
    int j = 0;
    fib[0] = 1;
    fib[1] = 1 - broken[1];
    for (int i = 2; i <= n; i++) {
        fib[i] = broken[i] ? 0 : (fib[i-1] + fib[i-2]) % mod;
    }

    cout << fib[n] << endl;
}

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

int A, B, C, X;
int sum, ans;

int main(){

    cin >> A >> B >> C >> X;
    sum = 0;
    ans = 0;

    for (int i=0; i<A+1; i++){
        for (int j=0; j<B+1; j++){
            for (int k=0; k<C+1; k++){
                sum = i*500 + j*100 + k*50;
                if (sum == X) ans++;
                sum = 0;
            }
        }
    }

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


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

int main() {
    int n; cin >> n;

    unordered_map<string, int> M;
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        sort(s.begin(), s.end());
        M[s]++;
    }

    long long ans = 0;
    for (auto& m : M) {
        ans += 1LL * m.second * (m.second - 1) / 2;
    }

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

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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

int main(){
    ll S;
    cin >> S;
    ll x,y;
    const ll a = 1000000000;

    // 10^9 y - x = S

    x = (a-S%a)%a;
    y = (S+x)/a;

    cout << "0 0 " << a << " " << 1 << " " << x << " " << y << endl;
}


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


signed main() {
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    double ans = W * H / 2;
    cout << fixed << setprecision(10) << ans << " ";
    if (W / 2 == x && H / 2 == y) {
        cout << "1" << endl;
    } else {
        cout << "0" << endl;
    }
}


Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.math;      // math functions

void main()
{
  auto n = readln.chomp.to!size_t;
  auto a = readln.split.to!(long[]);

  auto c1 = new long[](n), c2 = new long[](n);

  c1[0] = a[0];
  foreach (i; 1..n) c1[i] = a[i] + c1[i-1];

  c2[n-1] = a[n-1];
  foreach_reverse (i; 0..n-1) c2[i] = c2[i+1] + a[i];

  auto ans = long.max;
  foreach (i; 0..n-1)
    ans = min(ans, (c1[i] - c2[i+1]).abs);

  writeln(ans);
}


Measured memory_bytes: 13568
read N
egrep -o '[^ ]+'|factor|cut -d" " -f 2-|while read i;do egrep -o '[^ ]+'<<<$i|sort|uniq -c;done|awk '$0=$2==2?$0:""'|sort -n>a
[[ `cat a|wc -l` = $N ]]&&head -1 a|awk '$0=$1'||echo 0

Measured memory_bytes: 3032
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define vi vector<int>
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}




class UnionFind{
private:
        vector<int> par,rank,sizes;
        int tree;

public:
        explicit UnionFind(const int n) : tree(n){
            par.resize(n);
            rank.resize(n);
            sizes.resize(n);
            rep(i,n){
                par[i] = i;
                sizes[i] = 1;
            }
        }

        ~UnionFind() = default;

        int root(int x){
            if(par[x] == x) return x;
            else return par[x] = root(par[x]);
        }

        int find(int x){ return root(x);}

        void unite(int x, int y) {
            x = root(x);
            y = root(y);
            if (x == y) return;

            if (rank[x] < rank[y]) swap(x, y);
            par[y] = x;
            tree--;
            sizes[x] += sizes[y];
            if (rank[x] == rank[y]) rank[x]++;
        }

        bool same(int x, int y){
            return root(x) == root(y);
        }

        int size(int x){
            return sizes[x];
        }

        int sumTree(){
            return tree;
        }
};

class segmentTree{

};

class ModInt{

};

class topos{

};


int main() {

    int n,m; cin >> n >> m;
    UnionFind u(n);

    rep(i,m){
        int x,y,z; cin >> x >> y >> z;

        u.unite(x-1,y-1);
    }

    cout << u.sumTree() << endl;

}

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


map<ll,ll> nb;


ll f(ll x){

    if(x<=2) return 0;

    if(nb[x]!=0){
        return nb[x];
    }
    int aux;
    if(x%2==1){
        aux=f((x-1)/2);
    }
    else{
        aux=f((x-2)/2);
    }

    nb[x]=1+aux;

    return nb[x];


}


void cautare(ll stanga,ll dreapta,ll nb,ll &maxim){
    if(stanga>dreapta)
        return;
    ll m=(stanga+dreapta)/2;
    ll miscari=f(m);

    if(miscari==nb){
        maxim=m;
        cautare(m+1,dreapta,nb,maxim);
        return;
    }

    if(miscari>nb){
        cautare(stanga,m-1,nb,maxim);
    }
    else{
        cautare(m+1,dreapta,nb,maxim);
    }
}



int main()
{
    ll x;
    cin>>x;
    ll maxim;
    cautare(2,LONG_MAX,x,maxim);
    cout<<maxim<<"\n";
}

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

ss=len(str(S))

dp=[1 for _ in range(S+1)]
dp[0]=1
for i in range(0,min(S+1,3)):
    dp[i]=0
for i in range(3,min(S+1,10)):
    dp[i]=1

for i in range(3,S+1):
    for j in range(3,S+1):
        if(i+j<=S):
            #print(i,j)

            dp[i+j]=dp[i+j]+dp[i]
            dp[i+j]=dp[i+j]%(10**9+7)
            #print(dp[i+j])

print(dp[S])
#print(dp)
# dpp=[[0 for _ in range()] for _ in range(3)]
#print(dp)
# for i in range(S);
#     for j in range(li):
#         if(dp[j*k])
#         dp[j*k]=dp[j*k]=+1
#         for j in li:
#             if(j<=i):
#
#         dp[i]=dp[i-j]+1+dp[i]
# print(dp[S])
# print(dp)
# while()


Measured memory_bytes: 66652
import bisect
import heapq
import sys
import itertools
import queue


input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7


class V:
    def __init__(self, f):
        self.f = f
        self.v = None

    def __str__(self):
        return str(self.v)

    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n)

    def get(self):
        return self.v


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def P(N):
    D = []
    for n in range(1, int(N ** 0.5) + 1):
        D.append(n)
        if N // n != n:
            D.append(N // n)
    D.sort()
    return D


def main():
    N, K = read_values()
    D = P(N)
    C = [(D[i] - D[i - 1]) % mod if i != 0 else D[i] for i, d in enumerate(D)]
    dp = [0] * len(D)
    S = [D] + [[0] * len(D) for k in range(K - 1)]
    I = [bisect.bisect_left(D, N // d) for d in D]

    for k in range(1, K):
        for i in range(len(D)):
            j = I[i]
            dp[i] = (S[k - 1][j] * C[i]) % mod
            S[k][i] = (S[k][i - 1] + dp[i]) % mod
    print(S[-1][-1] % mod)


if __name__ == "__main__":
    main()


Measured memory_bytes: 95528
n=input()
N=int(n)
num=0

for i in range(1,len(n)+1):
    if i!=len(n):
        if i%2!=0:
            num+=9*10**(i-1)
    else:
        if i%2!=0:
            num+=(int(n[0])-1)*10**(i-1)+(N-int(n[0])*10**(i-1))+1
print(num)
    


Measured memory_bytes: 3316
import Data.List

main = do
    (n:ps) <- map read . words <$> getContents :: IO [Int]
    print $ n - (solve ps)

solve ps = succ . maximum . (0 :) . map length . filter (\g -> head g == LT ) . group $ zipWith compare is (tail is)
    where is = map snd . sort $ zip ps [1..]

Measured memory_bytes: 55892
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int ans = Integer.MAX_VALUE;
        int n2 = (int)Math.pow(n, 0.5)+1;
        for(int i = 1; i < n2; i++){
            if(n % i == 0){
                ans = Math.min(ans,Math.max(String.valueOf(i).length(), String.valueOf(n/i).length()));
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
// https://atcoder.jp/contests/abc156/tasks/abc156_d
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (b)-1; i >= (a); --i)

// https://qiita.com/naru7sh/items/d42dcc720cdc9b8ee3de
// Fermat Combination
const int mod = (int)1e9 + 7;

// mod条件下の高速pow
ll modpow(ll a, ll p) {
    if (p == 0)
        return 1;
    if (p % 2 == 0) {
        ll root = modpow(a, p / 2);
        return root * root % mod;
    } else
        return a * modpow(a, p - 1) % mod;
}

ll fermatComb(ll a, ll b) {
    if (b > a - b)
        return fermatComb(a, a - b);
    ll mul = 1; //分子
    ll div = 1; //分母
    for (int i = 0; i < b; i++) {
        mul *= (a - i);
        mul %= mod;
        div *= (i + 1);
        div %= mod;
    }
    //フェルマーの小定理を利用して掛け算で計算
    return mul * modpow(div, mod - 2) % mod;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, A, B;
    cin >> N >> A >> B;
    // nCrの計算
    ll t = modpow(2, N) - fermatComb(N, A) - fermatComb(N, B) - 1;
    t = (t + mod * 2) % mod;
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
board = [list(input()) for _ in range(h)]

kabe = 0
for x in range(w):
    for y in range(h):
        if board[y][x] == "#":
            kabe += 1
s = [0, 0]
g = [h-1, w-1]
d = [[-1 for _ in range(w)] for _ in range(h)]
queue = []
queue.append(s)
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
while len(queue) != 0:
    p = queue.pop(0)
    if p[0] == g[0] and p[1] == g[1]:
        break
    for x, y in zip(dx, dy):
        nx = p[1] + x
        ny = p[0] + y
        if 0<=nx<w and 0<=ny<h and board[ny][nx] != "#" and d[ny][nx] == -1:
            d[ny][nx] = d[p[0]][p[1]] + 1
            queue.append([ny, nx])
if d[g[0]][g[1]] == -1:
    print(-1)
else:
    print(h*w - d[g[0]][g[1]] - kabe - 2)


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


int main(){
    int n, m;
    scanf("%d %d",&n,&m);
    int c[25],t[50005];
    for(int i=0;i<m;++i){
        scanf("%d",&c[i]);
    }
    for(int i=1;i<=n;++i){
        t[i] = INT_MAX;
    }
    t[0] = 0;
    for(int i=0;i<m;++i){
        for(int j=0;j+c[i]<=n;++j){
            t[j+c[i]] = min(t[j]+1,t[j+c[i]]);
        }
    }
    printf("%d\n",t[n]);
}



Measured memory_bytes: 3400
dp = [0 for i in range(31)]
dp[0] = 0
dp[1] = 1
dp[2] = 2
dp[3] = 4
for i in range(4, 31):
  dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3]

while True:
  n = int(input())
  if n == 0:
    break
  if dp[n] % 3650 == 0:
    print(dp[n] // 3650)
  else:
    print(dp[n] // 3650 + 1)
  


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mset(x, y) memset((x), (y), sizeof(x))
#define sz(x) ((int)(x).size())
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define cerr cout
#define endl '\n'
using namespace std;

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int s, t, d;
	cin >> d >> t >> s;
	cout << ((d <= s * t) ? "Yes" : "No");
}

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

int main(){
        int N,K,X,Y;
        cin >> N >> K >> X >> Y;
        if (N<=K) cout << N*X << endl;
        else cout << K*X + (N-K)*Y << endl;

        return 0;
}


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

int main() {
  int k=0;
  char delims[] = ",. ";
  char ch[1024], *words[100];
  cin.getline(ch,1024);
  char *result;
  result = strtok(ch,delims);
  while(result != NULL ) {
      words[k] = result;
    if((strlen(words[k]) >= 3) && (strlen(words[k]) <= 6)) {
      k++;
    }
    result = strtok(NULL,delims);
  }
  for(int i=0;i<k-1;i++) {
    cout << words[i] << " ";
  }
  cout << words[k-1] << endl;
}

Measured memory_bytes: 0
from collections import deque, Counter
n,m = map(int,input().split())
ls = [deque(map(int,input().split())) for i in range(n)]
seen = [0 for i in range(m+1)]
content = [0 for i in range(n)]
flg = [0 for i in range(n)]
cnt = 0
ans = 500
for i in range(n):
  content[i] = ls[i][0]
c = Counter(content)
while cnt<m:
  for i in range(n):
    if flg[i]:
      while ls[i]:
        ls[i].popleft()
        if seen[ls[i][0]] >= 1:
          continue
        else:
          content[i] = ls[i][0]
          break
      flg[i] = 0
  c = Counter(content)
  x = c.most_common()[0]
  ans = min(ans,x[1])
  seen[x[0]] += 1
  for i in range(n):
    if content[i] == x[0]:
      flg[i] = 1
  cnt += 1
print(ans)

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n, a, b, ans = 0, temp, r=0;
    cin >> n >> a >> b;
    temp = n/(a+b);
    
    ans = temp*(a);
    r = (n-temp*(a+b));
    
    ans += min(r, a);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <bitset>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <deque>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
const LL INF = 2e6;
const LL MOD = 1e9 + 7;
const LL _ = 1e10;

void solve() {
    int x;
    cin >> x;
    if (x == 0) cout << 1 << endl;
    else if (x == 1) cout << 0 << endl;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(20), cout.setf(ios::fixed);
    /*int t;
    cin >> t;
    while (t--) {
        solve();
    }*/
    solve();
}

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

#define M 998244353
#define inf 1e18
#define ins insert
#define pb push_back
#define ff first
#define ss second
#define li long long int
#define ld long double
#define pi pair<li, li>
#define vc vector
#define umap unordered_map
#define uset unordered_set
#define all(x) x.begin(), x.end()
#define fr(i, a, n) for (li i = a; i < n; i++)
#define frr(i, a, n) for (li i = n - 1; i >= a; i--)
#define file_in freopen("a.txt", "r", stdin);

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,m; cin>>n>>m;
    int ans=n*(n-1) + m*(m-1);
    ans/=2;
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){
    int a, b, c, tmp;
    scanf("%d%d%d",&a,&b,&c);

    if(a<c){
        if(c<b){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }else{
        if(b<c){
            printf("Yes\n");
        }else{
            printf("No\n");   
        }
    }

    return 0;
}

Measured memory_bytes: 128
N, M = map(int, input().split())
List = [list(map(int, input().split())) for _ in range(N)]

List.sort(key=lambda x:x[0])

amt = 0
money = 0
i=0
while amt<M:
    money+=List[i][0]*List[i][1]
    amt+=List[i][1]
    i+=1

ans = money-(amt-M)*List[i-1][0]
print(ans)

Measured memory_bytes: 29028
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)
 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace std;

ll powa(ll a, ll b, ll c)
{
    a%=c;
    ll res = 1;
    while(b>0)
    {
        if(b&1)
            res*=a, res%=c;
        a*=a, a%=c;
        b>>=1;
    }
    return res;
}

#define N 3000005

ll fact[N];
ll ifact[N];
ll ncr(ll n, ll r)
{
    if(r>n)
        return 0;
    ll ans = fact[n];
    ans*=ifact[r];
    ans%=mod;
    ans*=ifact[n-r];
    ans%=mod;
    return ans;
}

ll get(string s, ll k)
{
    if(k == 0)
        return 1;
    if(s.length() == 0)
        return 0;
    ll len = s.length();
    if(len<k)
        return 0;
    ll p1 = 0;
    ll mul = 1;
    rep(k)
        mul*=9;
    for(ll i=1;i<=len-1;i++)
        p1+=mul*(ncr(i-1,k-1));
    
    mul = 1;
    rep(k-1)
        mul*=9;
    
    for(ll dig=1;dig<((ll)s[0]-'0');dig++)
        p1+=mul*ncr(len-1,k-1);
    //cout<<"for "<<s<<" = "<<p1<<"\n";
    reverse(s.begin(), s.end());
    s.pop_back();
   while(s.length()>0 && s.back() == '0')
        s.pop_back();
    if(s.length()>0)    
            reverse(s.begin(), s.end());
    return p1 + get(s,k-1);
}


int main()
{
   FAST/**/
   
   fact[0] = 1;
   for(ll i=1;i<N;i++)
        fact[i] = fact[i-1]*i, fact[i]%=mod;
   for(ll i=0;i<N;i++)
        ifact[i] = powa(fact[i],mod-2,mod);
   
   ll r1,c1,r2,c2;
   cin>>r1>>c1>>r2>>c2;
   
   ll ans = 0;
   for(ll c=c1;c<=c2;c++)
   {
       ll temp = ncr(c+r2+1,c+1) - ncr(c+r1,c+1) + mod;
       temp%=mod;
       ans+=temp;
       if(ans>=mod)
            ans-=mod;
   }
   
   cout<<ans;
   
   return 0;        
}  

Measured memory_bytes: 47104
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pll pair<ll, ll>
#pragma GCC optimize ("O3")
using namespace std;
int main () {
    #ifdef LOCAL
        freopen ("input.txt", "r", stdin);
        freopen ("output.txt", "w", stdout);
        freopen ("error.txt", "w", stderr);
    #else
        ios::sync_with_stdio(false);
        cin.tie (NULL);
    #endif
    string s, t; cin>>s>>t;
    ll n1=s.size(), n2=t.size();
    map <char, vector <ll>> pos;
    for (ll i=0;i<n1;++i) pos[s[i]].push_back(i);
    ll now=-1, ans=0;
    for (ll i=0;i<n2;++i) {
        if (pos.count(t[i])==0) {
            cout<<-1;
            return 0;
        }
        ll cur=upper_bound(pos[t[i]].begin(), pos[t[i]].end(), now)-pos[t[i]].begin();
        if (cur==pos[t[i]].size()) {
            ans+=n1;
            now=pos[t[i]][0];
        }
        else now=pos[t[i]][cur];
    }
    cout<<ans+now+1;
    return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2,147,483,647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
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 gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
    string s;cin>>s;
    int si=SIZE(s);
    int a=0,b=0,c=0;
    rep(i,si){
        if(s[i]=='a') a++;
        else if(s[i]=='b') b++;
        else c++;
    }
    while(a!=0 && b!=0 && c!=0){
        a--;b--;c--;
    }
    if(a+b+c>=3 || (a+b+c==2 && (a==2 || b==2 || c==2))){
        cout<<"NO"<<endl;
    }else{
        cout<<"YES"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

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

    string ans;
    for (auto c : s) {
        if ('0' == c) ans.push_back('0');
        if ('1' == c) ans.push_back('1');
        if ('B' == c) {
            if (ans.size() == 0) continue;
            ans.pop_back();
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
  unordered_set<string> t;
  int n;
  string s;
  cin>>n;
  while(n--)
  {
    cin>>s;
    if(t.find(s) == t.end())
      t.insert(s);
  }
  cout<<t.size()<<endl;
  return 0;
}

Measured memory_bytes: 17696
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;

    while(--k >= 0){
        int a, b;
        cin >> a >> b;
        int x = min(a-1, min(n-a, min(b-1, n-b)));
        x %= 3;
        ++ x;
        cout << x << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define st(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;
i64 giant = 4000000000000000000;

using namespace std;

//メモリ置き場
int x,y,z;
int k;
i64 a[1010], b[1010], c[1010];

//inputするじょぉ～
void input(){
	cin >> x >> y >> z >> k;
	ff(i, 0, x) {
		cin >> a[i];
	}
	ff(i, 0, y) {
		cin >> b[i];
	}
	ff(i, 0, z) {
		cin >> c[i];
	}
	sort(a, a + 1010);
	sort(b, b + 1010);
	sort(c, c + 1010);
	reverse(a, a + 1010);
	reverse(b, b + 1010);
	reverse(c, c + 1010);
}

//二分探索の時の正誤判定
bool cond(i64 xx) {
	int cnt = 0;
	ff(i1, 0, x) {
		ff(i2, 0, y) {
			ff(i3, 0, z) {
				if (a[i1] + b[i2] + c[i3] < xx)break;
				cnt++;
				if (cnt >= k)return 0;
			}
		}
	}
	return 1;
}

//二分探索マシーン
i64 binary(i64 xx,i64 yy) {//初めてtrueになる場所をreturnします。
	i64 left = xx;//falseと分かっている範囲の右側を近づける
	i64 right = yy;//trueと分かっている範囲の左側を近づける
	if (cond(right) == 0)return -1;//右端でもfalseなら解なし
	if (cond(left) == 1)return 0;//最初から該当してたら0をreturn
	while (right >= left) {
		if (right - left == 1)return right;
		i64 mid = left + (right - left) / 2;
		if (cond(mid) == 1) right = mid;
		else left = mid;
	}
	return -1;
}

int main() {
	input();
	i64 p=binary(3,30000000001)-1;
	priority_queue<i64> ans;
	ff(i1, 0, x) {
		ff(i2, 0, y) {
			ff(i3, 0, z) {
				if (a[i1] + b[i2] + c[i3] < p+1) break;
				else ans.push(a[i1] + b[i2] + c[i3]);
			}
		}
	}
	ff(i, 0, k) {
		if (ans.empty())cout << p << endl;
		else {
			cout << ans.top() << endl;
			ans.pop();
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順

signed main(){
  int n,k;
  cin >> n >> k;
  if(k==1){
    cout << 0 << endl;
    return 0;
  }
  cout << n-k+1-1 << endl;
  return 0;
}


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


int main()
{
  int k;
  vector<int> antennas(5);
  for (auto idx(0); idx < 5; ++idx) {
    cin >> antennas[idx];
  }
  cin >> k;
  for (auto idx(0); idx < 5 - 1; ++idx) {
    for (auto jdx(idx + 1); jdx < 5; ++jdx) {
      if (k < abs(antennas[idx] - antennas[jdx])) {
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

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

    long long int n;

    while (std::cin >> n, n) {
        long long int ans = 0;
        long long int num = 1;
        for (long long int i = 2; i <= n; ++i) {
            num *= i;
            
            int cnt = 0;
            long long int div = 10;
            for (;;) {
                if (num % div) {
                    break;
                }
                div *= 10;
                ++cnt;
            }

            if (cnt) {
                div /= 10;
                num /= div;
                ans += cnt;
            }

            num %= 1000000000;
        }

        std::cout << ans << std::endl;
    }

    return 0;
}

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

int main(){
    int A,B, max;
    cin >> A >> B;
    max = A+B;
    if (max < A * B) max = A*B;
    if (max < A - B) max = A-B;

    cout<< max << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pi 3.1416
int main()
{
    fastio;
    int a,b,c,five=0,seven=0;
    cin>>a>>b>>c;
    if(a==7)
        seven++;
    else if(a==5)
        five++;
    if(b==7)
        seven++;
    else if(b==5)
        five++;
    if(c==7)
        seven++;
    else if(c==5)
        five++;
    if(five==2 && seven==1)
        printf("YES\n");
    else
        printf("NO\n");
    //system("pause");
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let n = read::<i64>();
  let s = read::<String>();
  let mut max_ans = 0;

  for i in 1..n {
    let usize_i = i as usize;
    let a = &s[0..usize_i];
    let b = &s[usize_i..];
    let mut ans = 0;

    let mut a_vec = vec![];
    for c in a.chars() {
      if !a_vec.contains(&c) {
        a_vec.push(c);
      }
    }

    for i in a_vec {
      if b.contains(&i.to_string()) {
        ans += 1;
      }
    }

    max_ans = max(max_ans, ans)
  }

  println!("{}", max_ans);

}



Measured memory_bytes: 4352
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;

void main()
{
    string s;
    while( (s=readln.strip) != "0 0") {
        string[] str = s.strip.split;
        auto n = map!(to!int)(str);
        if( n[0] > n[1]) writefln("%d %d",n[1],n[0]);
        else writefln("%d %d",n[0],n[1]);
    }
}

Measured memory_bytes: 2352
#include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <vector>
    #include <string>
    #include <string.h>
     
    typedef long long ll;
    using namespace std;
    const ll INF = 1000000000000000000ll;
    const ll MOD = 1000000007ll;
     
    const double EPS = 1e-8;
     
    int main()
    {
		ll N,K,ans;
		 
		cin >> N >> K;

		ans=K;

		for(int i=0;i<N-1;i++){
			ans *= (K-1);
		}

		cout << ans << endl;

		return 0;
    }

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

/*
  // Overview
  グラフの全点間最短路を求める。
  負辺があっても動作。負閉路検出可能。

  // Time complexity
  O(n ^ 3) (n: 頂点の数)

  // Initialization
  WarshallFloyd wf = WarshallFloyd(n); (n: 頂点の数)
  wf.add_edge(u, v, c); (u: start, v: to, c: コスト) (無向グラフの場合は両辺に張る)
  wf.build();
*/
struct WarshallFloyd {
    typedef vector< vector< long long > > Matrix;
    const long long INF = 1LL<<60;
    int n;
    Matrix g;
    WarshallFloyd(int n) : n(n), g(n, vector< long long >(n, INF)) {
        for (int i = 0; i < n; ++i) g[i][i] = 0;
    }
    void add_edge(int u, int v, long long c) {
        g[u][v] = c;
    }
    void build() {
        for (int k = 0; k < g.size(); ++k) {
            for (int i = 0; i < g.size(); ++i) {
                for (int j = 0; j < g.size(); ++j) {
                    if(g[i][k] == INF || g[k][j] == INF) continue;
                    g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
                }
            }
        }
    }
    // Time complexity
    // O(n) (n: 頂点数)
    bool has_negative_cycle() {
        for (int i = 0; i < n; ++i) if (g[i][i] < 0) return true;
        return false;
    }
    long long shortest_path_value(int s, int t) {
        return g[s][t];
    }
    bool is_unreachable(int s, int t) {
        return g[s][t] == INF;
    }
};

/*
    verified http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_C&lang=jp
*/
int main() {
    int v, e; cin >> v >> e;
    WarshallFloyd wf(v);
    for (int i = 0; i < e; ++i) {
        int s, t, d; cin >> s >> t >> d;
        wf.add_edge(s, t, d);
    }
    wf.build();
    if (wf.has_negative_cycle()) {
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }
    for (int i = 0; i < v; ++i) {
        for (int j = 0; j < v; ++j) {
            if (j != 0) cout << " ";
            if (wf.is_unreachable(i, j)) cout << "INF";
            else cout << wf.shortest_path_value(i, j);
        }
        cout << endl;
    }
}


Measured memory_bytes: 3252
#include<iostream>
#include<string>

using namespace std;

int main(){
	string s;
	char b;
	int i,k,max;

	k = 0;
	max = 0;

	cin >> s;

	for(i = 0;i < s.size();i++){
		b = s[i];
		if (b == 'A' || b == 'T' || b == 'C' || b == 'G') {
			k++;
		}
		else {
			k = 0;
		}

		if (max < k)
			max = k;
	}

	cout << max;

	return 0;
}

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

const int mod = 1e9+7;

int main() {
    int n;
    //char alph = {'a','b','c','d'};
    cin >> n;
    vector<vector<int>> A(26, vector<int>(n, 0));
    string S[n];
    rep(i,n) cin >> S[i];
    for(int i=0;i<n;++i) {
        for(char c:S[i]) {
            A[c-'a'][i]++;
        }
    }
    string ans = "";
    int index=0;
    for(vector<int> a:A){
        int num = *min_element(a.begin(), a.end());
        char c = 'a'+index;
        rep(i,num) ans = ans+c;
        ++index;
    }
    cout << ans << endl;

}


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

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

int num[5000];

int main() {
	double v1, v2;
	double l[10];
	while(scanf("%lf,", &l[0]) != EOF) {
		int adis = 0, sum = l[0];
		FOR(i, 1, 10) {
			scanf("%lf,", &l[i]);
			sum += l[i];
		}
		scanf("%lf,%lf", &v1, &v2);
		rep(i, 10) {
			adis += l[i];
			double time = adis / v1;
			double bdis = v2 * time;
			if(sum <= adis + bdis) {
				printf("%d\n", i + 1);
				break;
			}
		} 
	}
	return 0;
}

Measured memory_bytes: 3136
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int> a(n),b(n);
  rep(i,n){
    cin >> a[i];
  }
  rep(i,n){
    cin >> b[i];
  }
  
  const int inf = 1e+9;

  vector<vector<int>> dp((1<<n),vector<int>(51,inf));
  dp[0][1] = 0;
  
  rep(S,(1<<n)){
    int cnt = __builtin_popcount(S);
    rep1(i,50){
      if(dp[S][i]==inf){
	continue;
      }
      int cnt2=0;
      rep(j,n){
	if((S>>j)&1){
	  cnt2++;
	}
	else{
	  if(cnt%2==j%2){
	    if(i<=a[j]){
	      dp[S|(1<<j)][a[j]] = min(dp[S|(1<<j)][a[j]],dp[S][i]+(cnt-cnt2));
	    }
	  }
	  else{
	    if(i<=b[j]){
	      dp[S|(1<<j)][b[j]] = min(dp[S|(1<<j)][b[j]],dp[S][i]+(cnt-cnt2));
	    }
	  }	  
	}
      }
    }
  }

  int res = inf;
  rep1(i,50){
    res = min(res,dp[(1<<n)-1][i]);
  }
  if(res==inf) cout << -1 << "\n";
  else cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 63872