akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long long ll;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 2000000009
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  int i,n,l;cin>>n>>l;vector<string> s(n);
  for(i=0;i<n;i++){cin>>s[i];}
  //caricurate
  vsort(s);
  //output
  for(i=0;i<n;i++){
  cout<<s[i];
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int MOD = 1000000007;

ll gcd(ll a, ll b){
    if (b == 0) return a;
    else return gcd(b, a % b);
}

bool solve(string s){
    int N = s.size();
    
    for(int i = 0; i < N; i++){
        if (s[i] != s[N-1-i]) return false; 
    }
    
    int first = 0, end = (N - 1) / 2;
    for(int i = 0; i < end; i++){
        if (s[i] != s[end-1-i]) return false; 
    }
    
    first = (N + 3) / 2 - 1 , end = N;
    for(int i = first; i < N; i++){
        if (s[i] != s[end-1-i]) return false; 
    }
    
    return true;
}

int main(void){
    double l; cin >> l;
    printf("%.10lf\n", l*l*l/27.0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxN = 1e5+7;
const int maxV = 90010;
//const int INF = 1e9+9;
const ll INF = (1ll)<<60;
const int MOD = 998244353;

int n;
int a[maxN];
int b[maxN];
int c[maxN];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	b[1] = a[1];
	for(int i=2;i<=n;i++)
	{
		b[i] = __gcd(b[i-1],a[i]);
	}
	c[n] = a[n];
	for(int i=n-1;i>=1;i--)
	{
		c[i] = __gcd(c[i+1],a[i]);
	}
	int ans = 1;
	for(int i=1;i<=n;i++)
	{
		if(i==1)
		{
			ans = max(ans,c[i+1]);
		}
		else if(i==n)
		{
			ans = max(ans,b[i-1]);
		}
		else
		{
			ans = max(ans,__gcd(b[i-1],c[i+1]));
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int H, W; cin >> H >> W;
    vector<vector<char>> pic(H, vector<char>(W));
    rep(i, H) {
        rep(j, W) cin >> pic.at(i).at(j);
    }

    rep(i, H) {
        vector<char> pic2(W);
        rep(j, W) {
            pic2.at(j) = pic.at(i).at(j);
            cout << pic.at(i).at(j);
        }
        cout << endl;
        rep(k, W) cout << pic2.at(k);
        cout << endl;
    }
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define vpll vector <pll>
#define pb push_back
#define f(i,a,n) for(ll i=a;i<=n;i++)
int main(){
    string s,t;
    cin>>s>>t;
    int l=t.length();
    string s1=t.substr(0,l-1);
    if(s==s1)
        cout<<"Yes";
    else cout<<"No";
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    ll d;
    cin >> d;
    int ans = 0;
    for(int i = 0; i < n; i++){
        ll x, y;
        cin >> x >> y;
        if(d*d >= x*x + y*y) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int main()
{
	long long int n, k;
	cin >> n >> k;
	if(n%k < k-n%k)
	{
		cout << n%k;
	}
	else
	{
		cout << k-n%k;
	}
}



Measured memory_bytes: 3624
#include "bits/stdc++.h"

using namespace std;

void Main() {
    string S;
    cin >> S;

    int ans = 0;
    int took = -1;
    string last = "";
    for (int i = 0; i < S.size(); ++i) {
        if (i == 0) {
            last = S.substr(0, 1);
            ++ans;
            took = 0;
            continue;
        }
        string sub = S.substr(took + 1, i - took);
        if (last == sub) {
            continue;
        }
        else {
            last = sub;
            ++ans;
            took = i;
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define all(obj) (obj).begin(),(obj).end()
typedef long long ll;
ll mod=1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;cin>>n>>k;
  vector<bool> a(n,0);
  rep(i,k){
    int d;cin>>d;
    rep(j,d){
      int f;cin>>f;
      f--;
      a[f]=1;
    }
  }
  int tot=0;
  rep(i,n)if(a[i]==0)tot++;
  cout<<tot<<endl;
  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll INF = 1e17;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    ll a,b,c;
    cin >> a >> b >> c;

    ll d=c-a-b;
    if (d>0 && 4*a*b < d*d) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#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>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  int N; cin>>N;
  string s, t;
  cin>>s>>t;
  int x = 0;
  FOR(i,0,N)
  {
    bool ok = true;
    FOR(j,0,N-i)
    {
      if(s[i+j]!=t[j]) ok = false;
    }
    if(ok)
    {
      x = N - i;
      break;
    }
  }
  cout << s.length() + t.length() - x << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
namespace CS.Solve1
{
    class Program
    {
        static void Main(string[] args)
        {
            var givenN = int.Parse(Console.ReadLine());
            int [] vs = new int[givenN + 1];
            int[] Money = new int[] { 1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049 };
            vs[0] = 0;
            for(int i = 0; i <= givenN; i++)
            {
                for(int j = 0;j < Money.Length; j++)
                {
                    if (i + Money[j] > givenN) continue;
                    if (vs[i + Money[j]] == 0)
                    {
                        vs[i + Money[j]] = vs[i]+1;
                    }
                    else
                    {
                        vs[i + Money[j]] = Math.Min(vs[i + Money[j]], vs[i] + 1);
                    }
                }
            }
            Console.WriteLine(vs[givenN]);
        }
    }
}


Measured memory_bytes: 11232
A,B,C=map(int,input().split())
K=int(input())
i=0
while A>=B:
  B2=2*B
  B=B2
  i=i+1
while B>=C:
  C2=2*C
  C=C2
  i=i+1
print('No'if i>K else'Yes')



Measured memory_bytes: 9176
#include<bits/stdc++.h>
 using namespace std;
 
#define FIO                     ios_base::sync_with_stdio(false); cin.tie(0)
#define mod                     1000000007
#define setbits                 __builtin_popcount
#define gcd                     __gcd
#define rep(i,a,b)              for(int i=a;i<=b;i++)
#define repr(i,b,a)             for(int i=b;i>=a;i--)
#define forn(i,n)               for(int i=0;i<n;i++)
#define all(a)                  a.begin(), a.end()
#define in(a,b)                 ( (b).find(a) != (b).end())
#define pb                      push_back
#define fill(a,v)               memset(a, v, sizeof a)
#define endl                    "\n"
#define ff                      first
#define ss                      second
#define mp                      make_pair
#define minin(a)                *min_element (all(a))
#define maxin(a)                *max_element(all(a))
#define asort(c)                sort(all(c))
#define dsort(c)                sort(all(c), greater<int>()) 
typedef  long long                   ll;
typedef  vector<int>                 vi;
typedef  pair<int, int>              ii;
typedef  vector<ii>                 vii;
typedef  set<int>                    si;
typedef  unordered_map<int, int>    mii;
typedef  vector<ll>                 vll;

const int N=5e5+5;

int dsum(int n)
{
    int sum=0;
    while(n)
    {
        sum+=n%10;
        n/=10;
    }
    return sum;
}


int main()
{
  FIO;
  
 
 int n;
 cin>>n;
 //cout<<dsum(n)<<endl;
 if(n%dsum(n)==0)
    cout<<"Yes";
else
    cout<<"No";

 return 0;
}

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

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

    std::string ans;
    for (auto c : s) {
        if (c != 'B') {
            ans += c;
        } else if (ans.size()) {
            ans.pop_back();
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long

const int N=(int)1e5+5;

int dp[N];
int a[N];

int n;
int solve(int idx)
{
    int i=idx;
    if(idx==n)return 0;
    
    int &ans=dp[idx];
    if(ans!=-1)return ans;
    ans=INT_MAX;
    int op1=INT_MAX,op2=INT_MAX;
    if(idx+2<=n)
    op1=abs(a[i+2]-a[i])+solve(idx+2);
    
    op2=abs(a[i+1]-a[i])+solve(idx+1);
   
   
    return ans=min(op1,op2);
}
	
void solve()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    memset(dp,-1,sizeof dp);
    int ans=solve(1);
    cout<<ans;
}

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    
	int t=1;
	//cin>>t;
	while(t--)solve();
	    
   
}

Measured memory_bytes: 7556
/* low_link.cpp
    グラフの関節点・橋の列挙をする

    verified: AOJ GRL_3_A
        http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_A
    verified: AOJ GRL_3_B
        http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_B
*/
#include <bits/stdc++.h>
using namespace std;

struct Edge {
    int to;
};
using Graph = vector<vector<Edge>>;
using P = pair<long, long>;

/* Lowlink: グラフの関節点・橋を列挙する構造体
    作成: O(E+V)
    関節点の集合: vector<int> aps
    橋の集合: vector<P> bridges
*/
struct LowLink {
    vector<int> aps;  // articulation points
    vector<P> bridges;

    const Graph &G;
    vector<int> used, ord, low;
    LowLink(const Graph &G_) : G(G_) {
        used.assign(G.size(), 0);
        ord.assign(G.size(), 0);
        low.assign(G.size(), 0);
        int k = 0;
        for (int i = 0; i < G.size(); i++) {
            if (!used[i]) k = dfs(i, k, -1);
        }
    }

    int dfs(int id, int k, int par) {
        used[id] = true;
        ord[id] = k++;
        low[id] = ord[id];
        bool is_aps = false;
        int count = 0;
        for (auto &e : G[id]) {
            if (!used[e.to]) {
                count++;
                k = dfs(e.to, k, id);
                low[id] = min(low[id], low[e.to]);
                if (par != -1 && ord[id] <= low[e.to]) is_aps = true;
                if (ord[id] < low[e.to]) bridges.emplace_back(min(id, e.to), max(id, e.to));
            } else if (e.to != par) {
                low[id] = min(low[id], ord[e.to]);
            }
        }
        if (par == -1 && count >= 2) is_aps = true;
        if (is_aps) aps.push_back(id);
        return k;
    }
};

/*
//verified: AOJ GRL_3_A
//    http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_A
int main() {
    long long V, E;
    cin >> V >> E;
    Graph G(V);
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        G[s].push_back({t});
        G[t].push_back({s});
    }

    LowLink lowlink(G);

    sort(lowlink.aps.begin(), lowlink.aps.end());
    for (auto i : lowlink.aps) {
        cout << i << endl;
    }
    return 0;
}
*/

/*
// verified: AOJ GRL_3_B
//    http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_B
*/
int main() {
    long long V, E;
    cin >> V >> E;
    Graph G(V);
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        s--, t--;
        G[s].push_back({t});
        G[t].push_back({s});
    }

    LowLink lowlink(G);

    sort(lowlink.bridges.begin(), lowlink.bridges.end());
    cout << lowlink.bridges.size() << endl;
    return 0;
}


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

int main(){
	int n,m,c, count =0;
	cin >> n >> m >> c;
	vector<int> b(m);
	for (int &x: b) cin >> x;
	for (int i =0; i<n; i++){
		long long sum=c;
		for (int j=0; j<m; j++){
			int temp;
			cin >> temp;
			sum+= temp*b[j];
		}
		if (sum>0) count++;
	}
	cout << count;
}


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

if __name__ == '__main__':
    N = int(input())
    line1 = list(map(int, input().split()))
    line2 = list(map(int, input().split()))
    # 1行目の累積和
    dp1 = [line1[0]]
    for i in range(1, N):
        dp1.append(dp1[i-1]+line1[i])
    # 2行目の累積和
    dp2 = [line2[0]]
    for i in range(1, N):
        dp2.append(dp2[i-1]+line2[i])
    # 最大を探す
    maxv = 0
    for i in range(N):
        if i == 0:
            candies = dp1[i] + dp2[N-1]
        else:
            candies = dp1[i] + (dp2[N-1]-dp2[i-1])
        if candies > maxv:
            maxv = candies
    print(maxv)


Measured memory_bytes: 3188
n,d = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(n)]
B = []
ans = 0
for j in range(n-1):
  for k in range(j+1,n):
    for l in range(d):
      B.append((A[j][l]-A[k][l])**2)
    if sum(B)**0.5 == int(sum(B)**0.5):
      ans += 1
    B = []
print(ans)

Measured memory_bytes: 38384
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    ll n = 0;
    cin >> n;
    vector<ll> a(n);
    for (ll i=0; i<n; i++) {
        cin >> a.at(i);
    }
    vector<ll> b(n);
    for (ll i=0; i<n; i++) {
        cin >> b.at(i);
    }
    vector<ll> c(n);
    for (ll i=0; i<n; i++) {
        cin >> c.at(i);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    vector<ll> cnt_b(n);
    ll now_a = 0, now_b = 0, now_c = 0;
    while (now_b < n) {
        while (now_c < n && c.at(now_c) <= b.at(now_b)) {
            now_c++;
        }
        if (now_c == n) {
            break;
        }
        cnt_b.at(now_b) = n - now_c;
        now_b++;
    }
    for (ll i=n-2; i>=0; i--) {
        cnt_b.at(i) += cnt_b.at(i+1);
    }
    now_b = 0;
    ll ans = 0;
    while (now_a < n) {
        while (now_b < n && b.at(now_b) <= a.at(now_a)) {
            now_b++;
        }
        if (now_b == n) {
            break;
        }
        ans += cnt_b.at(now_b);
        now_a++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
    int N, x;
    cin >> N >> x;
    vector<int> a;
    int tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        a.emplace_back(tmp);
    }
    sort(a.begin(), a.end());

    int sum = 0;
    int cnt = 0;
    for (auto itr = a.begin(); itr != a.end(); itr++)
    {
        sum += *itr;
        if (sum > x)
        {
            cout << cnt << endl;
            return 0;
        }
        cnt += 1;
    }
    if (sum != x) cnt -= 1;
    
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = null;
		while (sc.hasNext()) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0 && W == 0) {
				sc.close();
				break;
			}
			for (int i=0; i < H; i++) {
				for (int j=0; j < W; j++) {
					s = i % 2 == 0 ? j % 2 == 0 ? "#" : "." :  j % 2 == 0 ? "." : "#";
					System.out.print(s);
					if (j == W-1)
						System.out.println();
				}
				if (i == H-1)
					System.out.println();
			}
		}
	}
}

Measured memory_bytes: 26872
import java.io.*;
  
class Main{
    public static void main (String[ ] args) throws IOException{
  
        BufferedReader in = new BufferedReader (new InputStreamReader (System.in));
        boolean sift[] = new boolean[1000000];
        int prim[] = new int[1000000];
        int cnt=0;
        String str;
  
        sift[0] = false;
        sift[1] = false;
        prim[0]=0;
  
        for(int i = 2;i < 1000000;i++){
            sift[i] = true;
        }
  
        for(int i = 1;i < 1000000;i++){
            if(sift[i] == true){
                cnt++;
                for(int j = i*2;j < 1000000;j+=i){
                    sift[j]=false;
                }
            }
        prim[i]=cnt;
        }
  
        while((str = in.readLine()) != null){
            System.out.println(prim[Integer.parseInt(str)]);
        }
    }
}

Measured memory_bytes: 30084
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb emplace_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define ll long long
#define INF 2000000000
struct tri{
        string name;
        int p,id;
}t[105];
bool cmp(tri a,tri b){
        if(a.name==b.name) return a.p>b.p;
        return a.name<b.name;
}
int main(){
        int n;
        while(~getI(n)){
                F(i,0,n){
                        cin>>t[i].name>>t[i].p;
                        t[i].id=i;
                }
                sort(t,t+n,cmp);
//              F(i,0,n){
//                      debug(t[i].name);
//                      debug(t[i].p);
//                      debug(t[i].id);
//              }
                F(i,0,n) printf("%d\n",t[i].id+1);
        }
}

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

using namespace std;

int main(){
	int a;
	
	cin >> a;
	
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			if(a == i*j){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	
	cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Char (isSpace)

main :: IO ()
main = do
  solve <$> f <*> f >>= print
  where
    f = readil B.readInt <$> B.getLine

solve :: [Int] -> [Int] -> Int
solve [_, x] xs = foldl1' gcd . (tail >>= zipWith (-)) . sort $ (x:xs)

readil :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> [a]
readil f = unfoldr g
  where
    g s = do
      (n, s') <- f s
      return (n, B.dropWhile isSpace s')


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

int main() {
    vector< int > y(3);
    rep(i, 3) cin >> y[i];
    sort(y.begin(), y.end());
    cout << y[0] + y[1] << endl;
}


Measured memory_bytes: 384
from sys import exit, setrecursionlimit
from itertools import product

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(10000)

(A, B, C) = reads()

if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
  print(0)
else:
  print(min(A*B, B*C, C*A))


Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	s := getString()

	t := "keyence"
	l := 0
	for i := 0; s[i] == t[i]; i++ {
		l++
		if l == len(t) {
			break
		}
	}
	// out(l)

	rt := "ecneyek"
	r := 0
	for i := 0; i < 7; i++ {
		if s[len(s)-1-i] != rt[i] {
			break
		}
		r++
	}
	// out(r)

	if r+l >= 7 {
		out("YES")
	} else {
		out("NO")
	}

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define println(cont, type) copy(cont.begin(), cont.end(), ostream_iterator<type>(cout, " "))
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

int main()
{
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < int(s.size() / 2); i++)
        ans += int(s[i] != s[s.size() - i - 1]);
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define read(arr,n)	for(int i=0;i<n;i++) cin>>arr[i];
#define print(arr,n) for(int i=0;i<n;i++) cout << arr[i]<<' ';cout << endl;

using namespace std;

typedef long long ll;

void solve() {
	ll k, x;
	cin >> k >> x;
	if (500*k >= x) {
		cout <<"Yes\n";
	} else {
		cout << "No\n";
	}
}

int main() {
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();	
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    } 
    int x;
    cin>>x;
    cout<<((x>=30)?"Yes":"No")<<"\n";
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <tuple>
#include <list>
#include <deque>
#include <stack>
#include <complex>
#include <functional>
#include <regex>
#include <map>

using namespace std;

#define REP(i,a,b) for(int i=(a); i<(b); ++(i))
#define rep(i,n) REP(i,0,n)

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

using ll = long long;
using ld = long double;
using ull = unsigned long long;

const int PI = acos(-1);
const int INF = numeric_limits<int>::infinity() / 2;
const ll INFLL = numeric_limits<ll>::infinity() / 2;

int A[2][100];
int F[2][100];
int N;

int solve(int x, int y) {
  if (x == N - 1 and y == 1)
    return A[1][N-1];

  F[y][x] = 1;
  int maxi = 0;
  rep(i, 2) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (nx < 0 or ny < 0 or nx >= N or ny >= 2)
      continue;
    if (F[ny][nx] > 0)
      continue;
    maxi = max(maxi, solve(nx, ny) + A[y][x]);
  }
  F[y][x] = 0;
  return maxi;
}

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

  cin >> N;

  rep(i, 2) rep(j, N) cin >> A[i][j];
  cout << solve(0, 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

ll dp[101][2][101];
int K;
ll rec(string &S, int k = 0, bool tight = true, int state = 0) {
  if (k == S.size()) {
    if (state == K)
      return 1;
    else
      return 0;
  }

  if (dp[k][tight][state] != -1)
    return dp[k][tight][state];

  int x = S[k] - '0';
  int r = tight ? x : 9;
  ll res = 0;
  rep(i, 0, r + 1) {
    int st = i == 0 ? state : state + 1;
    res += rec(S, k + 1, tight && i == r, st);
  }

  return dp[k][tight][state] = res;
}

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

  string n;
  cin >> n >> K;
  memset(dp, -1, sizeof(dp));
  ll ans = rec(n);

  cout << ans << endl;
}


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

using namespace std;

int main() {
    int n,m;

    cin >> n >> m;

    int wa[n]={0};
    int ac[n]={0};

    int x=0;

    int p=0;
    
    for(int i = 0; i < m; i++) {
        int a;
        string s;

        cin >> a >> s;

        a=a-1;
        
        if(s=="WA"){
            wa[a]++;
        }else{
            if(ac[a]==0){
                p+=wa[a];
                ac[a]=1;
            }
        }
    }

    cout << accumulate(ac,ac+n,0) << " " << p << endl;
    return 0;
}

Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut dp = vec![vec![0; n + 1]; n + 1];
    for s in 1 .. n + 1 {
        for i in 0 .. n - s + 1 {
            let j = i + s;
            dp[i][j] = max(a[i] - dp[i + 1][j], a[j - 1] - dp[i][j - 1]); 
        }
    }
    puts!("{}\n", dp[0][n]);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 94460
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


N = int(input())

word = input()
S = [word]
judge = True
for _ in range(N - 1):
    t = word[-1]
    word = input()
    if word[0] != t or word in S:
        judge = False
        break
    S.append(word)

if judge:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        k: u64
    }
    let n = 50usize;
    let mut ret = vec![0u64;n];
    for i in 0..n {
        ret[i] = k/50 + i as u64;
    }
    for i in 0..(k%50) as usize {
        ret[i] += n as u64;
        for j in 0..50 {
            if i != j {
                ret[j] -= 1;
            }
        }
    }
    println!("{}", n);
    println!("{}", join(&ret, " "));
}

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }
using namespace std;

int N, K;
string s;

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

    int res = 0;
    rep(i, N-1) {
        if (s[i] == s[i+1]) res++;
    }
    cout << min(res + K * 2, N - 1) << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
typedef pair<int, int> PII;
typedef long long ll;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


int n, ans = 1;
string s;

int main() {

	cin >> n >> s;

	REP(i, 1, n) {
		if (s[i] != s[i - 1]) {
			ans++;
		}
	}
	
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cctype>
#include <algorithm>
#include <functional>
#include <utility>
#include <vector>
#include <queue>
const int maxn = 200005;
const int INF = 0x7fffffff;
using pii = std::pair<int, int>;
int n, A[maxn]; int log2[maxn];
pii minv[2][19][maxn];
inline void process() {
  for(int typ = 0; typ < 2; typ ++) {
    for(int i = 1; i <= n; i ++) {
      pii &th = minv[typ][0][i];
      th.second = i;
      if((i & 1) == typ) th.first = A[i];
      else th.first = INF;
    }
    for(int j = 1; (1 << j) <= n; j ++) {
      pii *las = minv[typ][j - 1], *B = minv[typ][j];
      const int len = 1 << j;
      for(int i = 1; i <= n; i ++) {
        if(i + len - 1 > n) {
          B[i].first = INF;
        } else {
          B[i] = std::min(las[i], las[i + (len >> 1)]);
        }
#ifdef LOCAL
        printf("minv[%d][%d][%d] : (%d, %d)\n", typ, j, i, B[i].first, B[i].second);
        fflush(stdout);
#endif
      }
    }
  }
  log2[1] = 0;
  for(int i = 2; i <= n; i ++) {
    log2[i] = log2[i - 1];
    if((1 << (log2[i] + 1)) <= i) log2[i] ++;
  }
}
inline pii query(int typ, int L, int R) {
  int p = log2[R - L + 1];
  return std::min(minv[typ][p][L], minv[typ][p][R - (1 << p) + 1]);
}

struct Node {
  int v, p, L, R;
  bool operator <(const Node &res) const {
    return v < res.v;
  }
  bool operator >(const Node &res) const {
    return v > res.v;
  }
};
std::priority_queue<Node, std::vector<Node>, std::greater<Node> > Q;
inline void ins_seg(int L, int R) {
  if(L > R) return;
  pii th = query(L & 1, L, R);
  Q.push((Node){th.first, th.second, L, R});
}

int main() {
  scanf("%d", &n);
  for(int i = 1; i <= n; i ++) scanf("%d", &A[i]);
  process(); ins_seg(1, n);
  std::vector<int> ret;
  while(!Q.empty()) {
    Node pr = Q.top(); Q.pop();
    ret.push_back(pr.v);
    pii rp = query((pr.p & 1) ^ 1, pr.p + 1, pr.R);
    ret.push_back(rp.first);
    ins_seg(pr.L, pr.p - 1);
    ins_seg(pr.p + 1, rp.second - 1);
    ins_seg(rp.second + 1, pr.R);
  }
  for(int i = 0; i < n; i ++) {
    if(i > 0) putchar(' ');
    printf("%d", ret[i]);
  }
  puts("");
  return 0;
}

Measured memory_bytes: 63988
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cassert>
#include <queue>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define fst first
#define snd second
#define SZ(x) ((int)x.size())
typedef long long ll;
#define dforn(i, n) for(int i = n - 1; i >= 0; i--)

const int MAXN = 200050;

int n, A[MAXN];

int main() {
    //~ freopen("input.in", "r", stdin);
    while( scanf("%d", &n) >= 1 ){
        forn(i, n){
            scanf("%d", &A[i]);
        }
        bool ok = A[0] == 0;
        forr(i, 1, n){
            if(A[i] > A[i-1]+1) ok = false;
        }
        if(!ok){
            printf("-1\n");
            continue;
        }
        ll ans = 0;
        forr(i, 1, n){
            if(A[i] == 0) continue;
            ans++;
            if(A[i] != A[i-1] + 1) ans += (A[i] - 1);
        }
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int compare_int( int *a,  int *b);
int main(void){
  int i,n,k;
  scanf("%d%d",&n,&k);
    if(k>=n){
      printf("0");
           return 0;
          }
  int a[n+1];
  long sum=0;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);  
   }
  qsort(a,n,sizeof(int),compare_int);
  for(i=k;i<n;i++){
     sum+=(long)a[i];
  }
  
  
  printf("%ld",sum);
  return 0;
}
int compare_int( int *a,  int *b){
    return *b - *a;
}

Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
using std::cout;
using std::endl;
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::multiset;


// ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
// ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// ll pow(ll a, ll b) { ll ans = 1; while (b > 0) { if (b % 2 == 1) { ans *= a; ans %= MOD; }b /= 2; a *= a; a %= MOD; }return ans%MOD; }
// ll comb(ll n, ll r) { if (n - r < r) { return comb(n, n - r); }static VVL memo = {{1}}; if (memo.size() < n + 1) { memo.reserve(n + 1); FOR(i, memo.size(), n + 1) { memo.emplace_back(i + 1, 0); REP(j, i + 1) { memo[i][j] = 0;	if (j < i) { memo[i][j] += memo[i - 1][j]; }if (j > 0) { memo[i][j] += memo[i - 1][j - 1]; }memo[i][j] %= MOD; } } }return memo[n][r]; }
// ll comb_L(ll a, ll b) { if (a - b < b) { return comb(a, a - b); }static unordered_map<ll, ll> memo; ll c = 1; FOR(i, a - b + 1, a + 1) { c *= i; c %= MOD; }if (memo.find(b) == memo.end()) { ll k = 1; FOR(i, 2, b + 1) { k *= i;	k %= MOD; }memo[b] = pow(k, MOD - 2); }	c *= memo[b]; return c % MOD; }
// multiset<ll> prime_decomposition(ll n) { ll i = 2; multiset<ll> table{}; while (i * i <= n) { while (n % i == 0) { n /= i;	table.emplace(i); }++i; }if (n > 1) { table.emplace(n); return table; }return table; }
//-- bit -- REP(i, (1 << n)) {REP(j, n) {cout << (1 & (i >> j));}cout << endl;}

//==============================================================================================


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

	ll mn = 1e10;
	REP(i, str.size() - 2) {
		string s = str.substr(i, 3);
		mn = std::min(mn, (ll)abs((ll)753 - (ll)(stod(s)+0.1)));
	}
	cout << mn << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<tuple>
#include<string>
int rank[100010];
int par[100010];
int p[100010];
void init(int N){
    for(int i=0;i<=N;i++){
        par[i]=i;
        rank[i]=0;
    }
}

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

void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(rank[x]<rank[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(rank[x]==rank[y])rank[x]++;
    }
}

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

int main(){
    int N,M;
    std::cin>>N>>M;
    init(N);
    for(int i=1;i<=N;i++){
        int tmp;
        std::cin>>tmp;
        p[tmp]=i;
    }
    for(int i=1;i<=M;i++){
        int x,y;
        std::cin>>x>>y;
        unite(x,y);
    }
    int ans=0;
    for(int i=1;i<=N;i++){
        if(same(i,p[i]))ans++;
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
string S, T;

void input() { cin >> N; }

template <typename T>
map<T, int> factorize(T x) {
  map<T, int> res;
  for (int i = 2; i * i <= x; i++) {
    while (x % i == 0) {
      x /= i;
      res[i]++;
    }
  }
  if (x != 1) res[x]++;
  return res;
}
int dig(int n) {
  int r = 0;
  while (n) {
    n /= 10;
    r++;
  }
  return r;
}
int ck(int a, int b) { return max(dig(a), dig(b)); }

void solve() {
  map<int, int> fac = factorize(N);
  vi vc;
  for (auto x : fac) {
    while (x.second) {
      vc.push_back(x.first);
      x.second--;
    }
  }

  int ans = INF;
  // debugv(vc);
  int k = vc.size();
  // debug(vc.size());
  rep(i, 0, 1 << (k)-1) {
    int m1 = 1;
    int m2 = 1;
    rep(j, 0, k - 1) {
      if (i >> j & 1) {
        m1 *= vc[j];
      } else {
        m2 *= vc[j];
      }
    }
    // debug(m1);
    // debug(m2);
    ans = min(ans, ck(m1, m2));
  }
  cout << ans << endl;
}

signed main() {
  input();
  solve();
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;


int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    int left = 0;
    int right = INF;

    while (right - left > 1) {
        int mid = (right + left) / 2;

        ll num = 0;
        for (int i = 0; i < n; ++i) {
            if (a[i] % mid == 0) num += a[i] / mid - 1;
            else num += a[i] / mid;
        }
        if (num <= k) right = mid;
        else left = mid;
    }
    cout << right << endl;
}

Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

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

  ll n;
  cin >> n;
  ll res = 0;
  for (ll i = 1; i <= n; i++) {
    ll x;
    cin >> x;
    if ((x & 1) && (i & 1))
      res++;
  }
  cout << res << en;

  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    int n; cin >> n;
    vector<int> p(n);
    REP(i, n) cin >> p[i];

    int cnt = 0;
    FOR(i, 1, n-1) {
        array<int, 3> a = {p[i-1], p[i], p[i+1]};
        sort(a.begin(), a.end());

        if(p[i] == a[1]) cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var parts []string = []string{
	"dream",
	"dreamer",
	"erase",
	"eraser",
}

func main() {
	S := ReadString()
	for {
		if len(S) <= 9 {
			for _, part := range parts {
				if S == part {
					fmt.Println("YES")
					return
				}
			}
			fmt.Println("NO")
			return
		}

		if S[:6] == "eraser" {
			S = S[6:]
			continue
		}
		if S[:5] == "erase" {
			S = S[5:]
			continue
		}
		if S[:7] == "dreamer" {
			if S[7] == 'a' { // dream + era...
				S = S[5:]
				continue
			}
			// dreamer
			S = S[7:]
			continue
		}
		if S[:5] == "dream" {
			S = S[5:]
			continue
		}
		fmt.Println("NO")
		return
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadString() (s string) { Scan(&s); return }


Measured memory_bytes: 2492
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPI(i,a,b) for(ll i=b-1;i>=a;i--)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define G(a,b) get<a>(b)
#define VI vector<int>
#define VLL vector<long long>

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[],ll b[],ll n);
ll logint(ll x,ll y);


ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}

ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

void pairsort(int a[],int b[],int n)
{
    pair<int,int> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}

void pairsortll(ll a[],ll b[],ll n)
{
    pair<ll,ll> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}

ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<=x;i++)
    {
        if(x<a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}

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

    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */

    ll q=1;
    //cin>>q;
    while(q--)
    {
        ll n;
        cin>>n;
        ll a[n];
        ll x[n];
        REP(i,0,n)
        {
            ll t;
            cin>>t;
            a[i]=t;
            x[i]=i;
        }
        pairsortll(a,x,n);
        REP(i,0,n)
        {
            cout<<x[i]+1<<'\n';
        }
    }

    return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void answer1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void answer2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void answer3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void answer(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i, j;
  //ll n;
  //cin >> n;
  ll h,w;
  cin >> h >> w;
  //string s; cin >> s;
  ll result = 0;
  bool judge = true;

  
  char a[h][w];
  for(i=0;i<h;i++)
    for(j=0;j<w;j++)
      cin >> a[i][j];
  for(i=0;i<h&&judge;i++)
    for(j=0;j<w&&judge;j++){
      if(a[i][j]=='#'){
        if(
          (i>=1&&a[i-1][j]=='.')&&
          (i<=h-1&&a[i+1][j]=='.')&&
          (j>=1&&a[i][j-1]=='.')&&
          (j<=w-1&&a[i][j+1]=='.')
        )
          judge = false;
      }
    }
  
  answer1(judge);





  return 0;
}

Measured memory_bytes: 256