akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    for(int i=0; i<N; i++) {
        cin >> x.at(i) >> y.at(i);
    }
    double distance = 0.0;
    for(int i=0; i<N; i++) {
        for(int j=i+1; j<N; j++) {
            int x_diff = x.at(i) - x.at(j);
            int y_diff = y.at(i) - y.at(j);
            distance += sqrt(x_diff*x_diff + y_diff*y_diff);
        }
    }
    cout << scientific << distance*2.0/N << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    int xmax = 100001;
    cin >> n;
    vector<int> val(xmax+1, 0);
    
    for(int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        a++;
        val.at(a-1)++;
        val.at(a)++;
        val.at(a+1)++;
    }

    int max = 0;
    for(int i = 0; i < xmax+1; ++i) {
        if(max < val.at(i)) {
            max = val.at(i);
        }
    }

    cout << max << endl;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            var H = new Dictionary<char,int>();
            for(int i = 0; i < s.Length; i++)
            {
                if (H.ContainsKey(s[i])) H[s[i]]++;
                else H[s[i]] = 1;
            }
            bool flag = true;
            foreach(var h in H)
            {
                if (h.Value != 2) flag = false;
            }
            if (flag) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 26072
#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>;


int main() {
    int N;
    string S;
    cin >> N >> S;
   int ans = 0;
    rep(i,N-1) {
        map<int, int> X, Y;
        int cnt = 0;
        for (int j = 0; j < i + 1; ++j) ++X[S.at(j)];
        for (int j = i + 1; j < N; ++j) ++Y[S.at(j)];
        for (auto x : X) {
            if (Y[x.first] > 0) ++cnt;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}


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

int fib(int n)
{
  long long num[10000] = {1, 1};
  for (int i = 2; i <= n; i++){
    num[i] = num[i - 1] + num[i - 2];
  }
  return (num[n]);
}

int main()
{
  int n;
  cin >> n;
  cout << fib(n) << endl;
}

Measured memory_bytes: 1244
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

string maximum(string &a, string &b){
    if(a.size() != b.size()) return (a.size() > b.size() ? a : b);
    return min(a, b);
}

bool is_parindrome(const string &s){

    return true;
}

int main() {
    int h, w;
    array<int, 8> dy{-1, -1, -1, 0, 0, 1, 1, 1},
                  dx{-1, 0, 1, -1, 1, -1, 0, 1};
    while(cin >> h >> w, h){
        vector<string> v(h);
        for (int i = 0; i < h; ++i) {
            cin >> v[i];
        }
        string ans;
        map<string, int> m;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                for (int k = 0; k < 8; ++k) {
                    int y = i, x = j;
                    string s;
                    vector<vector<int>> visited(h, vector<int>(w, 0));
                    while(!visited[y][x]){
                        s += v[y][x];
                        visited[y][x] = 1;
                        y = (y+dy[k]+h)%h;
                        x = (x+dx[k]+w)%w;
                    }
                    for (int l = 1; l <= s.size(); ++l) {
                        m[s.substr(0, l)]++;
                    }
                }
            }
        }
        for (auto &&i : m) {
            if(i.second >= 2){
                string s = i.first;
                ans = maximum(ans, s);
            }
        }
        cout << (ans.size() <= 1 ? "0" : ans) << "\n";
    }
    return 0;
}


Measured memory_bytes: 31132
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
long long int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 

ll i,j,k,ii,jj;
ll n,m,num,sum;
ll ans;
ll a,b,c,d,e,f,g,h,w,v;
char s[500][500];
ll x[800005],y[800005],z[900005];
ll timee[500005];
ll color[500005];
ll kyori[500005];

void paint(ll v,ll d,ll c,ll t){
	//p("結果");
	//pe(v);pe(d);p(c);
	if(color[v]==0){
		//pe(c);p(v);
		color[v] = c;
		num++;
	}
	if(num==n || kyori[v] > d)return;
	timee[v] = t;
	kyori[v] = d;
	if(d==0)return ;
	for(int i=0;i<G[v].size();i++){
		if(timee[G[v][i]] == t && kyori[G[v][i]] >= d)continue;
		paint(G[v][i],d-1,c,t);
	}
}

int main(){	
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>a>>b;
		G[a].pb(b);
		G[b].pb(a);
	}
	cin>>k;
	for(i=0;i<k;i++){
		cin>>x[i]>>y[i]>>z[i];
	}
	reverse(x,x+k);
	reverse(y,y+k);
	reverse(z,z+k);
	for(a=0;a<k;a++){
		paint(x[a],y[a],z[a],a+5);
	}
	for(i=1;i<=n;i++){
		p(color[i]);
	}	
	return 0;
}

Measured memory_bytes: 27124
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n,m = i_map()
    ab = [i_list() for i in range(m)]

    def dfs(table):
        visited = [1]
        que = [1]

        while que != []:
            now = que[0]
            del que[0]

            for index, e in enumerate(table[now]):
                if (e==1) & (index not in visited):
                    visited.append(index)
                    que.append(index)
        if len(visited) == n:
            return 0
        else:
            return 1

    ans = 0
    for i in range(m):
        graph = ab.copy()
        del graph[i]
        table = [[0]*(n+1) for i in range(n+1)]
        for a,b in graph:
            table[a][b] = 1
            table[b][a] = 1

        ans += dfs(table)
    print(ans)



if __name__=="__main__":
    main()


Measured memory_bytes: 9344
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N = I()

if N%2==0:
    print(0.5)
else:
    print(((N+1)//2)/N)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int a[105];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	int ans=0;
	for(int i=2;i<=n;++i)
	{
		if(a[i]==a[i-1])
		{
			++ans;
			a[i]=2147483647;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
const long long INF = 1LL << 60;


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


// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(200001);




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

    mint n,m,k;
    n=N;
    m=M;
    k=K; 


    mint summation = 0;
    mint ans = 0;


    rep(i,K+1){
        ans += m*(m-1).pow(N-i-1)*comb(N-1,i);
    }


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6252
#include <stdio.h>
#include <stdlib.h>
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

void insert(int);
void inorder(Node);
void preorder(Node);

int main(){
  int i,m,*s,x,n;
  char com[20];
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
      scanf("%s", com);
      if( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
      }
      else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

void insert(int k){
    Node y=NULL;
    Node x=root;
    Node z;
    z=malloc(sizeof(struct node));
    z->key=k;
    z->left=NULL;
    z->right=NULL;
    while(x!=NULL){
        y=x;
        if(z->key < x->key) x=x->left;
        else x=x->right;
    }
    z->parent=y;
    if(y==NULL) root=z;
    else if(z->key < y->key) y->left=z;
    else y->right=z;
}

void inorder(Node u){
    if(u!=NULL){
        inorder(u->left);
        printf(" %d",u->key);
        inorder(u->right);
    }
}

void preorder(Node u){
    if(u!=NULL){
        printf(" %d",u->key);
        preorder(u->left);
        preorder(u->right);
    }
}


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

using namespace std;

/**templates**/
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;

#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sull(x) scanf("%llu",&x)
#define sf(x) scanf("%lf",&x)
#define ss(x) scanf(" %s",x)
#define sc(x) scanf(" %c",&x)
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define aa first
#define bb second
#define sz(x) (ll)(x).size()
#define cas printf("Case %lld: ",++t)
#define casline printf("Case %lld:\n",++t)
//#define cas cout<<"Case "<<++t<<": "
//#define casline cout<<"Case "<<++t<<":"<<endl;
#define distance(x1,y1,x2,y2)((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
#define endl "\n"
#define bug cout<<"bugggggggggggg "<<endl;
#define fast ios_base::sync_with_stdio(0);cin.tie(nullptr); ///no printf/scanf
#define clean fflush(stdout)

const ll mod = 1000000007;
const ll inf = 1LL<<62;
const ll mx = 100005;
const double eps = 1e-10;

ll dx[10]={1,0,-1,0};
ll dy[10]={0,-1,0,1};

ll power(ll a,ll b)
{
    if(b==0)return 1;
    ll x=power(a,b/2);
    x=x*x;
    if(b%2)x=x*a;
    return x;
}

ll bigmod(ll a,ll b)
{
    if(b==0)return 1;
    ll x=bigmod(a,b/2)%mod;
    x=(x*x)%mod;
    if(b%2)x=(x*a)%mod;
    return x;
}


ll Set(ll N,ll pos){return N=N | (1LL<<pos);}
ll reset(ll N,ll pos){return N= N & ~(1LL<<pos);}
bool check(ll N,ll pos){return (bool)(N & (1LL<<pos));}

/**
double cosine_rule(double a,double b,double c)
{
    double res=(a*a+b*b-c*c)/(2*a*b);
    res=acos(res);
    return res;
}
*/
ll dp[1005][10005];
ll aa[1005],bb[1005];
ll n;
ll solve(ll pos,ll val)
{
    ll &ret=dp[pos][val];
    if(ret!=-1)
        return ret;
    if(pos==n+1)
    {
        if(val==0)
            return 0;
        else
            return inf;
    }
    if(val==0)
    {
        return 0;
    }
    ret=0;
    ll a=bb[pos]+solve(pos,val-min(val,aa[pos]));
    ll b=solve(pos+1,val);
    return ret=min(a,b);
}
int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    fast; ///no printf/scanf
    /** Use "long double"(%Lf) instead of double for precision safety*/
    ll tst,a,b,c,k,m,res=0,ans=0,t=0;
    sl(m),sl(n);
    for(ll i=1;i<=n;i++)
    {
        sl(aa[i]),sl(bb[i]);
    }
    memset(dp,-1,sizeof(dp));
    cout<<solve(1,m)<<endl;




    return 0;
}


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

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

	if (N % 2 == 0) {
		cout << 0.5 << endl;
		return 0;
	}

	cout << ((double)(N / 2 + 1) / (double)N) << endl;
}

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 100
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x)
{ //bit計算
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num)
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
signed main()
{
    int N, M;
    cin >> N >> M;
    int ab[N + 1];
    rep(i, N + 1)
    {
        ab[i] = 0;
    }
    rep(i, M)
    {
        int A, B;
        cin >> A >> B;
        ab[A]++;
        ab[B]++;
    }
    int odd = 0;
    for (int i = 1; i <= N; i++)
    {
        if (ab[i] % 2 == 1)
        {
            odd++;
        }
    }
    if (odd % 2 == 0 && odd > 0)
    {
        cout << "NO" << endl;
    }
    else
    {
        cout << "YES" << endl;
    }
}


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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===


int ans[510][510];

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

	int N, M, Q;
	cin >> N >> M >> Q;

	memset(ans, 0, sizeof(ans));
	for (int i = 0; i < M; ++i) {
		int L, R;
		cin >> L >> R;
		--L; --R;
		++ans[0][R];
		--ans[L + 1][R];
		--ans[0][N];
		++ans[L + 1][N];
	}
	for (int i = 0; i < N; ++i) {
		for (int j = i; j < N; ++j) {
			ans[i + 1][j] += ans[i][j];
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int j = i; j < N; ++j) {
			ans[i][j + 1] += ans[i][j];
		}
	}

	for (int i = 0; i < Q; ++i) {
		int L, R;
		cin >> L >> R;
		--L; --R;
		cout << ans[L][R] << '\n';
	}

	return 0;
}

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

using namespace std;

int64_t solve(int64_t n, std::vector<int64_t> hs) {
  int64_t ret = 1;
  int64_t maximum = hs[0];
  for ( int i = 1; i < n; ++i) {
    if (hs[i] >= maximum) {
      ret ++;
    }
    maximum = std::max(hs[i],  maximum);
  }
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> hs(n);
  for (int i = 0; i < n; i++) {
    std::cin >> hs[i];
  }
  auto const res = solve(n, std::move(hs));
  std::cout << res << std::endl;
  return 0;
}


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

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

  if (s.size() % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }

  sort(s.begin(), s.end());
  int cnt = 1;
  for (int i = 1; i < s.size(); i ++) {
    if (s.at(i) == s.at(i - 1)) {
      cnt ++;
    } else if (s.at(i) != s.at(i - 1) && cnt % 2 == 0) {
      cnt = 1;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


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

ans = [0 for _ in range(10050)]
for i in range(1,105):
    for j in range(1,105):
        for k in range(1,105):
            v = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if v < 10050:
                ans[v] += 1

for i in range(n):
    print (ans[i+1])


Measured memory_bytes: 9268
n = $stdin.readline.to_i
res = 0
d = Array.new(n) { $stdin.readline.chomp.split.map(&:to_i) }

d.sort_by! {|a, b| - a - b }
n.times do |i|
  a, b = d[i]
  if i.even?
    res += a
  else
    res -= b
  end
end
puts res


Measured memory_bytes: 23800
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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/gcd(a,b)*b;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,k;
    cin>>n>>k;
    vec<ll> a(n);
    rep(i,n) cin>>a[i];
    
    if((n-1)%(k-1)==0) cout<<(n-1)/(k-1)<<endl;
    else cout<<(n-1)/(k-1) + 1<<endl;
    return 0;
}


Measured memory_bytes: 1024
// SPDX-License-Identifier: X11
// 2020-08-31
// Coprime (500pt)

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

#define MAX 1000005

// !NOTE you have more than enough memory to scan in all of the numbers

bool *erato(uint_least32_t bound);

int main() {
  uint_least32_t N;
  scanf("%u\n", &N);

  bool *P = erato(MAX);
  uint_least32_t *Ap = calloc(MAX, sizeof(uint_least32_t));

  bool set = true;
  bool pair = true;

  uint_least8_t s;
  uint_least32_t A, i, j;
  for (i = 0; i < N; i++) {
    scanf("%u", &A);

    if (A == 1) {
      continue;
    }

    if (P[A]) {
      if (Ap[A])
        pair = false;
      Ap[A]++;

      if (Ap[A] == N)
        set = false;

      continue;
    }

    if (!(A & 1)) {
      if (Ap[2])
        pair = false;
      Ap[2]++;

      if (Ap[2] == N)
        set = false;

      while (!(A & 1))
        A >>= 1;

      if (A == 1) {
        continue;
      }

      if (P[A]) {
        if (Ap[A])
          pair = false;
        Ap[A]++;

        if (Ap[A] == N)
          set = false;

        continue;
      }
    }

    if (!(A % 3)) {
      if (Ap[3])
        pair = false;
      Ap[3]++;

      if (Ap[3] == N)
        set = false;

      while (!(A % 3))
        A /= 3;

      if (A == 1) {
        continue;
      }

      if (P[A]) {
        if (Ap[A])
          pair = false;
        Ap[A]++;

        if (Ap[A] == N)
          set = false;

        continue;
      }
    }

    for (j = 5, s = 2; j * j <= A; j += s, s = 6 - s)
      if (!(A % j)) {
        if (Ap[j])
          pair = false;
        Ap[j]++;

        if (Ap[j] == N)
          set = false;

        while (!(A % j))
          A /= j;

        if (A == 1) {
          break;
        }

        if (P[A]) {
          if (Ap[A])
            pair = false;
          Ap[A]++;

          if (Ap[A] == N)
            set = false;

          break;
        }
      }
  }

  if (pair)
    printf("pairwise coprime\n");
  else if (set)
    printf("setwise coprime\n");
  else
    printf("not coprime\n");

  free(P);
  free(Ap);
}

bool *erato(uint_least32_t bound) {
  if (!bound)
    return NULL;

  bool *array = calloc(bound, sizeof(bool));
  uint_least32_t i,j;
  uint_least8_t s,ss;

  if (bound < 3)
    return array;
  array[2] = true;

  if (bound < 4)
    return array;
  array[3] = true;

  if (bound < 5)
    return array;

  for (i = 5, s = 2; i < bound; i += s, s = 6 - s)
    array[i] = true;

  for (i = 5, s = 2; i < bound; i += s, s = 6 - s)
    if (array[i])
      for (j = i, ss = s; i * j < bound; j += ss, ss = 6 - ss)
        array[i * j] = false;

  return array;
}


Measured memory_bytes: 6328
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL N = 1000000007;

LL n;
LL dp[25][1 << 21] = {0};
LL a[25][25];

LL countone(LL x){
	LL cnt = 0;
	while(x){
		if(x & 1) cnt ++;
		x >>= 1;
	}
	return cnt;
}

LL cnt[1 << 21];

int main(){
	dp[0][0] = 1;
	scanf("%lld",&n);
	for(LL i = 1;i <= n;i ++){
		for(LL j = 1;j <= n;j ++){
			scanf("%lld",&a[i][j]);
		}
	}
	for(LL s = 0;s < (1 << n);s ++) cnt[s] = countone(s);
	for(LL i = 1;i <= n;i ++){
		for(LL s = 0;s < (1 << n);s ++){
			if(cnt[s] != i) continue;
			for(LL j = 1;j <= n;j ++){
				if(((s >> (j - 1)) & 1) && a[i][j]) dp[i][s] += dp[i - 1][s ^ (1 << (j - 1))];
				dp[i][s] %= N;
			}
		}
	}
	printf("%lld\n",dp[n][(1 << n) - 1]);
	return 0;
}

Measured memory_bytes: 329984
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, (int)1e9, sizeof(mat))
typedef long long ll;
int main()
{
  int W, H, N; cin >> W >> H >> N;
  ll ans = 0;
  int nowx, nowy; cin >> nowx >> nowy;
  FOR(i,0,N-1) {
    int x, y; cin >> x >> y;
    // ???????????????
    if((nowx - x) > 0 && (nowy - y) > 0) {
      ans += max(nowx-x, nowy-y);
    }
    // ???????????????
    else if((x - nowx) > 0 && (y - nowy) > 0) {
      ans += max(x-nowx, y-nowy);
    }
    else{
      ans += abs(nowx-x) + abs(nowy-y);
    }
    nowx = x;
    nowy = y;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3080
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;


int main(void) {
  string s;
  cin >> s;
  REP(i, s.size()) {
    cout << "x";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
const int MAX = 1000001;
const int MOD = 1000000007;

long long fac[1000001], finv[1000001], inv[1000001];
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;
}
int main(void){
    int x, y;
    scanf("%d%d", &x, &y);
    int n;
    if((x + y) % 3 != 0){
        printf("0\n");
        return 0;
    }
    n = (x + y)/3;

    int x_, y_;
    x_ = x - n;
    y_ = y - n;

    if(x_ < 0 || y_ < 0){
        printf("0\n");
        return 0;
    }

    COMinit();
    printf("%lld\n", COM(x_+y_, x_)% MOD);
    return 0;

}

Measured memory_bytes: 25132
dw = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')
dm = (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)

while True:
    m, d = map(int, input().split())
    if m == d == 0: break

    total = sum(dm[i] for i in range(m - 1)) + d - 1
    print(dw[(total + 4) % 7])

Measured memory_bytes: 6724
using System;
using System.Linq;

class name
{

    static　void Main()
    {

        int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int m = 0;
        for(int k = 1; k < 11; k++)
        {
            m = 1000 * k;
            if (m >= n[0]){

            n[0] = m - n[0];
                break;
        }

        }
    Console.WriteLine(n[0]);



    }



}

Measured memory_bytes: 28284
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
void solve(long long N){
  ll ans = 0;
  for (int i = 0; i < N+1; i++) {
    if(i % 3 != 0 && i%5 != 0){
      ans += i;
    }
  }
  cout << ans << endl;
}

int main(){
    long long N;
	scanf("%lld",&N);
    solve(N);
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type &a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	string s;
	int k;
	cin>>s>>k;
	
	if(k==1){
		int ans=0;
		for(int i=1;i<s.size();++i){
			if(s[i-1]==s[i]){
				ans++;
				s[i]='0';
			}
		}
		cout<<ans<<endl;
		return 0;
	}
	
	string t=s+s;
	llong cnt=0;
	llong cntt=0;
	for(int i=1;i<t.size();++i){
		if(t[i-1]==t[i]){
			if(0<=i and i<s.size()) cnt++;
			if(i>=s.size()) cntt++;
			t[i]='0';
		}
	}
	bool jud=(t[0]==t[t.size()-1]);
	llong ans;
	if(jud) ans=cnt+cntt*(k-1);
	else ans=cnt*(k/2+k%2)+cntt*(k/2);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>

int main() {
	int n, y;
	std::cin >> n >> y;
		int c = y;
		int flag = 0;
		for (int i = 0;i <= y/10000;i++) {
			int c = y;
			c -= i * 10000;
			if (c == 0 && i == n) {
				std::cout << i << ' ' << 0 << ' ' << 0 << std::endl;
				flag = 1;
				break;
			}
			if (c > 5000 * (n - i)) {
				continue;
			}
			for (int j = 0;j <= y/5000;j++) {
				int c = y;
				c -= i * 10000 + j * 5000;
				if (c == 0 && i + j == n) {
					std::cout << i << ' ' << j << ' ' << 0 << std::endl;
					flag = 1;
					break;
				}
				for (int k = 0; k <= y/1000;k++) {
					int c = y;
					c -= i * 10000 + j * 5000 + k * 1000;
					if (c == 0 && i + j + k == n) {
						std::cout << i << ' ' << j << ' ' << k << std::endl;
						flag = 1;
						break;
					}
				}
				if (flag == 1)
					break;
			}
			if (flag == 1)
				break;
		}
		if (flag == 0) {
			std::cout << -1 << ' ' << -1 << ' ' << -1 << std::endl;
		}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from itertools import islice
import operator

N, K = map(int, input().split())
sushi = [tuple([i] + [int(x) for x in input().split()]) for i in range(N)]
sushi.sort(key=operator.itemgetter(2), reverse=True)

from collections import OrderedDict, deque, Counter
left = OrderedDict((x[0], x) for x in sushi)

base = 0
choosen = OrderedDict()
choosen_kind = set()
for x in sushi:
    i, t, _ = x
    if t not in choosen_kind:
        choosen[t] = x
        choosen_kind.add(t)
        del left[i]

choosen = list(islice(choosen.values(), K))
base = sum(d for _,_,d in choosen)
kinds = len(choosen)

cands = islice(left.values(), K)
fixed = islice(cands, K - len(choosen))
base += sum(d for _,_,d in fixed)

score = base + kinds**2

for cand in cands:
    if cand[2] <= choosen[-1][2]:
        break

    base_n = base - choosen[-1][2] + cand[2]
    kinds_n = kinds - 1
    
    score_n = base_n + kinds_n**2
    if score_n > score:
        choosen.pop()
        base, kinds, score = base_n, kinds_n, score_n
    else:
        break

print(score)

Measured memory_bytes: 71408
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		long mod = (long)(1e9+7);
		int N = input.nextInt();
		long K = input.nextLong();
		long ans = 0;
		long choose2Right = K*(K+1)/2; //Sum of first N numbers is N*(N+1)/2;
		//For K concatenations, sum of 1 through K pairs exist
		K--;
		long choose2Left = K*(K+1)/2; //One less choice when choosing in reverse since you 
		//have to wait for a future cycle to cash out pairings
		choose2Right%=mod;
		choose2Left%=mod;
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = input.nextInt();
		}
		for (int cur = 0; cur < N; cur++) {
			int curNum = arr[cur];
			long left = 0;
			long right = 0;
			for (int L = 0; L < cur; L++) {
				if (curNum>arr[L]) left++;
			}
			for (int R = cur+1; R < N; R++) {
				if (curNum>arr[R]) right++;
			}
			long curAns = right*choose2Right;
			curAns%=mod;
			curAns+=left*choose2Left;
			curAns%=mod;
			ans+=curAns;
			ans%=mod;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 26028
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long num = scanner.nextLong();
        boolean b = true;
        for (long i = (long)Math.sqrt(num);i>0&&b;i--){
            if (num%i==0){
                System.out.println(i+num/i-2);
                b = false;
            }
        }
    }

}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
#define rep(i,n) for (ll i = 0; i < (n); ++i)
typedef long long int ll;
using ipair = pair<int,int>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
const int MOD=1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){ 
    int n,p,c=0,b=0;cin>>n>>p;
    vector<int>a(n);
    ll sum = 0;
    int ok=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]%2==1)ok=1;
        sum+=a[i];
    }
    int num;
    ll ans=0;
    if(ok){
        ans = pow(2,n-1);
    }else{
        if(p==0)ans=pow(2,n);
        else ans =0;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4024
#include<bits/stdc++.h>
using namespace std;
int main (){
    long long int a,b,c,d,sum,mul,total;

    cin>>a>>b;
    c=a+b;
    d=a-b;
    mul=a*b;

    cout<<max(mul,max(c,d))<<endl;



return 0;
}

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

using LL = long long;
using LD = long double;
 
LL mod = 1e9+7;

LL binpow(LL x, LL p, LL m) {
	LL res = 1;
	while (p) {
		if (p%2) {
			res *= x;
			res %= m;
		}
		p>>=1;
		x *= x;
		x %= m;
	}
	return res;
}

LL g[400][400];

int main()
{
	LL n;
	cin >> n;
	
	vector<LL> a(n);

	for (auto &e : a) {
		cin >> e;
	}

	for (LL i = 0; i < n; ++i) {
		for (LL j = 0; j < n; ++j) {
			g[i][j] = 0;
		}
	}

	
	LL pre[n+1] = {0};

	for (LL i = 1; i <= n; ++i) {
		pre[i] = pre[i-1] + a[i-1];
	}
	
	for (LL k = 1; k < n; ++k) {
		for (LL i = 0; i+k < n; ++i) {
			// end pt: i+k
			// st pt: i
			LL mn = LLONG_MAX;
			for (LL j = i; j < i+k; ++j) {
				LL cur = g[i][j]+g[j+1][i+k];
				mn = min(mn, cur+pre[i+k+1]-pre[i]);
			}
			g[i][i+k] = mn;
		}
	}

	// for (LL i = 0; i < n; ++i) {
	// 	for (LL j = 0; j < n; ++j) {
	// 		cout << g[i][j] << "\t";
	// 	}cout << "\n";
	// }

	cout << g[0][n-1] << "\n";
}



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

//pdf見て回答

int main(){
    int n, k, mini = 0, ans = 1e9;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        if(a[i] == 1){ mini = i; }
    }

    /*
    mini++;
    for(int i = -k + 1; i < 1; i++){
        int left = mini + i;
        int right = left + k - 1;
        if(left < 1 || right > n) continue;
        int leftNum = (left - 1) / (double)(k - 1) + 0.5;
        int rightNum = (n - right) / (double)(k - 1) + 0.5;
        if(leftNum < 0) leftNum = 0;
        if(rightNum < 0) rightNum = 0;
        ans = min(ans, leftNum + rightNum + 1);
        //cout << left << " " << right << endl;
        //cout << leftNum << " " << rightNum << endl;
        //cout << "---" << endl;
    }*/

    ans = (n - 2) / (k - 1) + 1;

    put(ans);
}

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

using namespace std;

int main() {
map<int,int> m;
  int a,b,c;
  cin>>a>>b>>c;
  m[a]++;
  m[b]++;
  m[c]++;
  
  if((m[5]==2) && (m[7]==1))
    cout<<"YES";
  else cout<<"NO";
    
         
    
    
    
    return 0;
}

Measured memory_bytes: 256
function main(input){
    const args=input.split(' ');
    const p=parseInt(args[0],10);
    const q=parseInt(args[1],10);
    const r=parseInt(args[2],10);
    const array=[p+q,p+r,r+q];
    console.log(Math.min.apply(null,array));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
# coding: utf-8
def factorial_cor(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 3000  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

a = int(input())
b = a // 3 - 1
n = int(0)
r = int(0)
temp = int()
ans = int(0)
mod = int(1000000007)

for i in range(b):
    n = a - 5 - int(i) * 2
    r = int(i) + 1 
    temp = cmb(n, r, p)
    ans += temp

if a >= 6:
    print((int(ans)+1) % mod)
elif a == 3 or a == 4 or a == 5:
    print("1")
else:
    print("0")

Measured memory_bytes: 9468
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, q;
ll maxx = 0;
ll ans[1000005];
ll a[1000005];
ll b[1000005];
ll c[1000005];
ll d[1000005];
void dfs(ll step, ll last)
{
    if(step == n + 1)
    {
        ll sum = 0;
        for(int i = 1; i <= q; i++)
        {
            if(ans[b[i]] - ans[a[i]] == c[i])
            {
                sum += d[i];
            }
        }
        if(sum > maxx)
        {
            maxx = sum;
        }
        return;
    }
    for(int i = last; i <= m; i++)
    {
        ans[step] = i;
        dfs(step + 1, i);
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> m >> q;
    for(int i = 1; i <= q; i++)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    ans[0] = 1;
    dfs(0, 1);
    cout << maxx << "\n";
    return 0;
}


Measured memory_bytes: 3664
using System;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        // 整数の入力

        //// スペース区切りの整数の入力
        string S = Console.ReadLine();


        //T の末尾に dream dreamer erase eraser のいずれかを追加する


        //出力
        Console.WriteLine(Hantei(S));
    }

    static string dream = "maerd";
    static string dreamer = "remaerd";
    static string erase = "esare";
    static string eraser = "resare";

    private static string Hantei(string S)
    {
        string s = new string(S.Reverse().ToArray());

        var can = true;
        while (can)
        {
            if (s.StartsWith(dream))
            {
                s = s.Remove(0, dream.Length);
            }
            else if (s.StartsWith(dreamer))
            {
                s = s.Remove(0, dreamer.Length);
            }
            else if (s.StartsWith(erase))
            {
                s = s.Remove(0, erase.Length);
            }
            else if (s.StartsWith(eraser))
            {
                s = s.Remove(0, eraser.Length);
            }
            else
            {
                return "NO";
            }

            if (s == "")
            {
                return "YES";
            }
        }
        return "NO";
    }
}


Measured memory_bytes: 32608
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	ans=15
	n=II()

	nn=int(n**0.5)+10

	for i in range(1,nn):
		if n%i==0:
			a=len(str(i))
			b=len(str(n//i))
			ans=min(ans,max(a,b))
			#print(a,b)

	print(ans)




if __name__ == "__main__":
	main()


Measured memory_bytes: 9460
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2009 + 30, Mod = 1e9 + 7;
const ll SQ = 330 ;
const ll INF = 1e17;

char c[N][N];
ll dp[N][N];
int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    ll h, w;
    cin >> h >> w;
    for (int i = 1; i <= h; i ++) {
    	for (int j = 1; j <= w; j ++) {
    		cin >> c[i][j];
		}
	}
	memset(dp, 63, sizeof(dp));
	dp[1][1] = (c[1][1] == '#');
	for (int i = 1; i <= h; i ++) {
		for (int j = 1; j <= w; j ++) {
			if (i + j == 2) continue;
			ll res = 1e18;
			if (j > 1)  {
				dp[i][j] = dp[i][j - 1] + (c[i][j] == '#' && c[i][j - 1] == '.');
			} 
			if (i > 1) {
				dp[i][j] = min(dp[i][j], dp[i - 1][j] + (c[i][j] == '#' && c[i - 1][j] == '.'));
			}
		}
	}
	cout << dp[h][w];
    return (0);
}

Measured memory_bytes: 33024
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

struct Graph
{
    int n;
    vector<vector<int>> g;
    
    Graph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to){
        g[from].push_back(to);
    }
};

struct Tree	//create tree(directed) from graph(undirected)
{
    int n;
    int root;
    vector<vector<int>> t;
    vector<int> par;
    vector<int> dpt;
    
    void init(Graph &g, int root_){
        n = g.n;
        root = root_;
        t.resize(n);
        par.resize(n);
        dpt.resize(n);
        fill(dpt.begin(), dpt.end(), -1);
        queue<int> que;
        par[root] = -1;
        dpt[root] = 0;
        que.push(root);
        while(que.size()){
            int pa = que.front();
            que.pop();
            for(int ch : g.g[pa]){
                if(dpt[ch] == -1){
                    t[pa].push_back(ch);
                    par[ch] = pa;
                    dpt[ch] = dpt[pa] + 1;
                    que.push(ch);
                }
            }
        }
    }

    Tree(){}
    
    Tree(Graph &g, int root_){
        init(g, root_);
    }
};

int main()
{
    int n;
    cin >> n;
    Graph g(n);
    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g.add_edge(a, b);
        g.add_edge(b, a);
    }
    Tree t1(g, 0);
    int l = 0;
    for(int i = 0; i < n; i++){
        if(t1.dpt[i] > t1.dpt[l]) l = i;
    }
    Tree t2(g, l);
    int r = 0;
    for(int i = 0; i < n; i++){
        if(t2.dpt[i] > t2.dpt[r]) r = i;
    }
    bool b[100005]{0};
    int k = r;
    while(k != -1){
        b[k] = true;
        k = t2.par[k];
    }
    Tree t3(g, r);
    int s = -1;
    if(t2.dpt[r] % 2){
        for(int i = 0; i < n; i++){
            if(!b[i]){
                s = max(s, max(t2.dpt[i], t3.dpt[i]));
            }
        }
    }
    else{
        int m = -1;
        vector<int> v;
        for(int i = 0; i < n; i++){
            if(b[i] && t2.dpt[i] == t3.dpt[i]){
                m = i;
            }
            if(!b[i]){
                if(max(t2.dpt[i], t3.dpt[i]) == t2.dpt[r]) v.push_back(i);
                else s = max(s, max(t2.dpt[i], t3.dpt[i]));
            }
        }
        if(v.size()){
            bool f = true;
            for(int x : v){
                int j = x;
                while(true){
                    if(b[j]){
                        if(j != m) f = false;
                        break;
                    }
                    b[j] = true;
                    j = t2.par[j];
                }
            }
            if(!f) s = t2.dpt[r];
            else s = t2.dpt[r] - 1;
        }
    }
    for(int i = 1; i <= n; i++){
        if(i == 1 || i == 2) cout << 1;
        else if(i <= s) cout << 0;
        else cout << 1;
    }
    cout << endl;
}


Measured memory_bytes: 27180
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define mrep(p,mp) for(auto p : mp)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
int k,x;
cin >>k >>x;
if(x > k*500)
    cout << "No" << endl;
else
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))

#aを大きい順にならべかえる。
a.sort(reverse=True)

dif=0
for i in range(len(a)):
    if i%2==0:
        dif+=a[i]
    else:
        dif-=a[i]
print(dif)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int n;
	cin >> n;
	ll p = 1;
	for(int i=1;i<=n;i++) {
		p *= i;
		p %= MOD;
	}
	cout << p << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	int[][][] houses = new int[4][3][10];	
	int n = scan.nextInt();
	int m = scan.nextInt();
	int[][] a = new int[n][m];
	int[] b = new int[m];
	int[] c = new int[n];
	for (int i = 0; i < n; i++) {
	    for (int j = 0; j < m; j++) {
		int element = scan.nextInt();
		a[i][j] = element;
	    }
	}
	for (int i = 0; i < m; i++) {
	    int element = scan.nextInt();
	    b[i] = element;
	}
	for (int i = 0; i < n; i++) {
	    for (int j = 0; j < m; j++) {
		c[i] += a[i][j] * b[j];
	    }
	    System.out.println(c[i]);
	}
    }
}

Measured memory_bytes: 40804
#include <iostream>
#include <vector>
#include <deque>

using namespace std;
typedef long long ll;

int main(){
    ll k;
    cin >> k;
    vector<vector<pair<ll, ll>>> net(k);
    for(ll i = 0; i < k; ++i){
        net.at(i).push_back(make_pair((i + 1) % k, 1));
        net.at(i).push_back(make_pair((i * 10) % k, 0));
    }

    vector<ll> ans(k, 0);
    vector<bool> visited(k, false);
    ans.at(1) = 1;
    visited.at(1) = true;
    deque<ll> q;
    q.push_front(1);
    while(!q.empty() && !visited.at(0)){
        ll x = q.front();
        q.pop_front();
        for(auto p : net.at(x)){
            if(visited.at(p.first)){ continue; }
            if(p.second){
                ans.at(p.first) = ans.at(x) + 1;
            }else{
                ans.at(p.first) = ans.at(x);
                q.push_front(p.first);
            }
            q.push_back(p.first);
            visited.at(x) = true;
        }
    }
    cout << ans.at(0) << endl;

    return 0;
}

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

int main(void){
    int n, m;
    string result = "Yes";
    
    cin >> n >> m;
    
    if(n != m){
        result = "No";
    }
    
    cout << result << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;
vector <int> n;

int main(){
	int n,m,t,u,num=0;
	vector <int> h;
	set <int> a;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>t;
		h.push_back(t);
	}
	for(int i=0;i<m;i++){
		cin>>t>>u;
		if(h[t-1]>=h[u-1]){
			if(!a.count(u)){
				a.insert(u);
				num++;
			}
		}
		if(h[u-1]>=h[t-1]){
			if(!a.count(t)){
				a.insert(t);
				num++;
			}
		}
	}
	cout<<n-num<<endl;
	return 0;
}

Measured memory_bytes: 6324
def calc(x):
    smallest = x * (x - 1) // 2
    largest = smallest + (N - x + 1) * x
    return largest - smallest + 1


N, K = map(int, input().split())
M = 10 ** 9 + 7
res = 0
for x in range(K, N + 2):
    res = (res + calc(x)) % M

print(res)

Measured memory_bytes: 9180