akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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; }

const long long INF = 1LL << 60;

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

  cout << a + a*a + a*a*a << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <map>
#include <iomanip>

using namespace std;



int main() 
{
	int n;
	cin >> n;
	vector<int> all;
	for (int i = 0; i < n; i++)
	{
		int t;
		cin >> t;
		all.push_back(t);
	}
	int ans = 0;
	for (auto i : all)
	{
		ans += i - 1;
	}


	cout << ans << "\n";


}

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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int maxn = 3000+1;
const int oo = numeric_limits<int>::max();
int dp[maxn][maxn];
string s1,s2;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> s1 >> s2;
	forn(i,0,s1.size()){
		forn(j,0,s2.size()){
			if(i == 0 || j == 0){
				dp[i][j] = (s1[i] == s2[j]);
				if(j-1 >= 0)dp[i][j] = max(dp[i][j],dp[i][j-1]);
				if(i-1 >= 0)dp[i][j] = max(dp[i][j],dp[i-1][j]);
			}else{
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
				if(s1[i] == s2[j]){
					dp[i][j] = 1+dp[i-1][j-1];
				}
			}
		}
	}
	int i = s1.size()-1;
	int j = s2.size()-1;
	string res = "";
	while(1){
		int act = dp[i][j];
		if(i == 0 || j == 0){
			if(j-1 >= 0 && dp[i][j-1] == act){
				j--;
				continue;
			}
			if(i-1 >= 0 && dp[i-1][j] == act){
				i--;
				continue;
			}
			if(s1[i] == s2[j]){
				res += s1[i];
			}
			break;
		}else{
			if(act == dp[i-1][j-1]+(s1[i] == s2[j])){
				if(s1[i] == s2[j])res += s1[i];
				i--;
				j--;
			}else if(act == dp[i-1][j]){
				i--;
			}else if(act == dp[i][j-1]){
				j--;
			}
		}
	}
	//cout << dp[s1.size()-1][s2.size()-1] << '\n';
	reverse(all(res));
	cout << res << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 35456
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define forn(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define ford(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define int long long
#define ii pair<int,int>
#define ar array
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define sz(x) ((int)(x).size())
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
#define ff first
#define ss second

const int N = 2e5+7 ;
const int MOD = 998244353 ;
int n , k ;
int m ;
vector<ii> a ;
class Fenwick{
    public :
    vector<int> ft ;
    void init(int n) {
        ft.resize(n+1) ;
    }
    int g(int x) {
        return x&(-x) ;
    }
    void get(int& x, int y){ // change it 
        x += y ;
        x += MOD ;
        x %= MOD ;
    }
    int sum(int pos){
        int ans = 0 ;
        for(; pos ; pos -= g(pos)) get(ans,ft[pos]) ;
        return ans ;
    }
    int sum(int l,int r){
        return sum(r) - (l == 0 ? 0 : sum(l-1)) ;
    }
    void upd(int pos,int val){
        for(; pos < ft.size() ; pos += g(pos)){
            get(ft[pos],val) ;
        }
    }
};

void solve(){
    cin >> n >> k ;
    a.resize(k) ;
    forn(i,k){
        cin >> a[i].ff >> a[i].ss ;
    }
    sort(all(a)) ;
    Fenwick ft ;
    ft.init(4*N) ;
    ft.upd(1, 1) ;
    ft.upd(2, -1);
    for(int i = 1 ; i < n ; i++){
        int here = ft.sum(i) ;
        for(auto [x,y] : a){
            int l = i + x ;
            int r = i + y ;
            int left = min(l,r) ;
            int right = max(l,r)+1 ;
            ft.upd(left, here) ;
            ft.upd(right, -here) ;    
        }
    }
    cout << ft.sum(1,n)%MOD << endl ;
}


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



Measured memory_bytes: 9528
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100010
int Adj[MAXN],V[MAXN*2],nxt[MAXN*2],c,n;
void AddEdge(int u,int v)
{
	c++;V[c]=v,nxt[c]=Adj[u];Adj[u]=c;
}
int dfs(int u,int p)
{
	int ret=0;
	for(int i=Adj[u];i;i=nxt[i])
		if(V[i]!=p)
		{
			ret^=dfs(V[i],u)+1;
		}
	return ret;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		AddEdge(u,v);
		AddEdge(v,u);
	}
	int ans=dfs(1,0);
	if(ans) printf("Alice\n");
	else printf("Bob\n");
}

Measured memory_bytes: 6784
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <map>

using namespace std;

int n, m;

struct Segm{
    int l, r;
    long long c;
};

Segm a[500000];

bool comp(Segm a, Segm b)
{
    return a.l < b.l;
}

vector<long long> d[500000];

int main()
{
    cin >> n >> m;
    for (int i = 0; i < m; i++) cin >> a[i].l >> a[i].r >> a[i].c;
    sort(a, a + m, comp);
    long long len = 0;
    map<long long, int> kek;
    int j = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i > 1 && kek.size() == 0)
        {
            cout << -1;
            return 0;
        }
        if (i > 1)
        {
            auto it = kek.begin();
            len = (*it).first;
        }
        for (; j < m && a[j].l == i; j++)
        {
            kek[len + a[j].c]++;
            d[a[j].r].push_back(len + a[j].c);
        }
        for (int j = 0; j < d[i].size(); j++)
        {
            kek[d[i][j]]--;
            if (kek[d[i][j]] == 0) kek.erase(d[i][j]);
        }
    }
    cout << len;
}


Measured memory_bytes: 19584
import sys

inf = float('inf')

n, m = map(int, sys.stdin.readline().split())
a = []
b = []
c = []
for _ in range(m):
    ai, bi, ci = map(int, sys.stdin.readline().split())
    a.append(ai - 1)
    b.append(bi - 1)
    c.append(-ci)
abc = list(zip(a, b, c))

def main():
    dist = [inf] * n
    dist[0] = 0
    for _ in range(n-1):
        for a, b, c in abc:
            dist[b] = min(dist[b], dist[a] + c)

    res = dist[n-1]

    for _ in range(n):
        for a, b, c in abc:
            dist[b] = min(dist[b], dist[a] + c)

    if dist[n-1] == res:
        return -res
    else:
        return 'inf'

if __name__ == '__main__':
    ans = main()
    print(ans)

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

int main()
{
    long long n, m;
    scanf("%lld%lld", &n, &m);
    if (n * m == 1) printf("1\n");
    else if (n == 1) printf("%d\n", m - 2);
    else if (m == 1) printf("%d\n", n - 2);
    else printf("%lld\n", (n - 2) * (m - 2));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

bool reachable(int u, int v, string S) {
    for (int i = u; i < v; i++) {
        if (S.substr(i, 2) == "##") {
            return false;
        }
    }
    return true;
}

int main() {
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;
    A--;
    B--;
    C--;
    D--;

    if (!reachable(A, C, S) || !reachable(B, D, S)) {
        cout << "No" << endl;
        return 0;
    }
    if (C > D) {
        bool ok = false;
        for (int i = B; i <= D; i++) {
            if (S.substr(i - 1, 3) == "...") {
                ok = true;
            }
        }
        if (!ok) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int count = 1;
        int min = sc.nextInt();


        for (long i = 0; i < n-1; i++) {
            int a = sc.nextInt();
            if (a <= min) count++;
            min = Math.min(min, a);
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 63796
#include<stdio.h>

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int h[n];
  for(int i = 0; i < n; i++) {
    scanf("%d", &h[i]);
  }
  int count = 0;
  for(int i = 0; i < n; i++) {
    if(h[i] < k) count++;
  }
  printf("%d\n", n - count);
  return 0;
}

Measured memory_bytes: 512
#encoding:utf-8 No.0050 2014.10.7
while gets
  sentence = $_.chomp.split
  
  sentence.length.times do |i|
    if /apple/ =~ sentence[i]
      sentence[i].gsub!(/apple/,"peach")
    elsif /peach/ =~ sentence[i]
      sentence[i].gsub!(/peach/,"apple")
    end

    unless i == sentence.length - 1
      print sentence[i] + " "
    else
      print sentence[i] + "\n"
    end
  end
end

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

#define ll long long
// #define MULTI_TEST



void solve() {
	string s;
	cin >> s;
	int ok = 1;
	for(int i=0; i<s.size(); i++) {
		if(i&1) {
			if(s[i] == 'R') ok = 0;
		} else {
			if(s[i] == 'L') ok = 0; 
		}
	}
	if(ok) cout << "Yes";
	else cout << "No";
}



int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
#ifdef MULTI_TEST
	int t;
	cin >> t;
	while(t--) {
		solve();
		cout << "\n";
	}
#else
	solve();
	cout << "\n";
#endif

	return 0;
}


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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

int a, b, c, A[1000], B[1000], C[1000], D[1000][1000];
string s, t, r;

int main(){
	cin >> a >> b;
	cout << max(max(a-b, a+b), a*b) << endl;

	return 0;
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007)
#define IINF (1<<28)
#define LINF (1LL<<60)
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"

namespace solver {
  using namespace std;
  using ll = long long;

  static const int MAX = 100010;
  int N, M;
  vector<vector<int>> G;
  vector<vector<ll>> dp, dpl, dpr;

  void init() {
    cin >> N >> M;
    G.resize(N);
    dp.resize(N);
    dpl.resize(N);
    dpr.resize(N);
    int x, y;
    rep(i, N-1) {
      cin >> x >> y;
      x--;
      y--;
      G[x].push_back(y);
      G[y].push_back(x);
    }
  }
  
  ll dfs(int s, int p) {
    ll res = 1;
    dp[s].resize(G[s].size());
    rep(i, G[s].size()) {
      int t = G[s][i];
      if(t != p) {
        dp[s][i] = dfs(t, s);
      }
      res *= (dp[s][i] + 1);
      res %= M;
    }
    return res;
  }

  void dfs2(int s, int p, ll s2p) {
    int sz = G[s].size();
    dpl[s].resize(sz+1);
    dpr[s].resize(sz+1);
    dpl[s][0] = 1;
    dpr[s][sz] = 1;
    rep(i, sz) if(G[s][i] == p) dp[s][i] = s2p % M;
    rep(i, sz) {
      dpl[s][i+1] = dpl[s][i] * (dp[s][i] + 1) % M;
      dpr[s][sz-i-1] = dpr[s][sz-i] * (dp[s][sz-i-1] + 1) % M;
    }
    rep(i, sz) {
      int t = G[s][i];
      if(t != p) {
        dfs2(t, s, dpl[s][i] * dpr[s][i+1] % M);
      }
    }
  }

  void solve() {
    dfs(0, -1);
    dfs2(0, -1, 0);
    rep(i, N) cout << dpl[i][G[i].size()] << endl;
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 28800
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};



int main(){
    LL n,m;cin >> n >> m;
    if(min(n,m) == 1){
        cout << 1 << endl;
    }
    else{
        cout << (n * m + 1) / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=2e5+5;
int ct[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i=2;i<=n;i++)
	{
		int x;
		cin>>x;
		ct[x]++;
	}
	for(int i=1;i<=n;i++)
		cout<<ct[i]<<"\n";
	return 0;
}

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

int main() {
	int A,B;
	cin >> A >> B;
	cout << 6 - A - B << endl;
}

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

using namespace std;

string s1,s2;

int str_to_num(string s){
	int a=0;
	for(int i=0; i<s.size(); i++){
		int b=s.at(s.size()-1-i)-'0';
		for(int j=0; j<i; j++){
			b*=10;
		}
		a+=b;
	}
	return a;
}

int calcMax(string s){
	sort(s.begin(),s.end());
	reverse(s.begin(),s.end());
	return str_to_num(s);
}

int calcMin(string s){
	sort(s.begin(),s.end());
	return str_to_num(s);
}

int main(){
	int n;
	string s;
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>s;
		cout<<calcMax(s)-calcMin(s)<<endl;
	}
}

Measured memory_bytes: 1224
n,m,k=map(int,input().split())

if k>n*m:
    print('No')
    exit()
    
if k%n==0 or k%m==0:
    print('Yes')
    exit()
k=min(m*n-k,k)
for i in range(1,n):
    for j in range(1,m):
        if i*m+j*n-2*i*j==k:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
    int N,K,P;
    scanf("%d",&N);
    while(N--){
        scanf("%d %d",&K,&P);
        K=K%P;
        if(K==0){
            K=P;
        }
        printf("%d\n",K);
    }
    return 0;
}


Measured memory_bytes: 2052
input()
x = input() # x = "4 0 2"
list_a = x.split() # list_moji = ["4", "0", "2"]
list_num = []
for i in list_a:
    list_num.append(int(i))
answer = max(list_num) - (min(list_num) + max(list_num))//2
print(answer)



Measured memory_bytes: 5620
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let n = input::<i64>();
    let m = input::<i64>();
    let a = (0..n)
        .map(|_| {
            let k = input();
            (0..k).map(|_| input()).collect()
        })
        .collect::<Vec<Vec<i64>>>();

    let mut food = vec![0i64; m as usize];
    for v in a {
        for i in v {
            food[i as usize - 1] += 1;
        }
    }

    let ans = food.iter().filter(|&i| *i == n).count();
    println!("{}", ans);
}


Measured memory_bytes: 4352
//<--sbhmsh-- Shubham Jaiswal>//

#include <bits/stdc++.h>
#include <iostream>
#define FASTIO std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lli long long int
#define endl '\n'
#define deb cout<<"sab_badhiya"<<endl;
// const long long INF = 1000 * 1000 * 1000 * 1ll * 1000 * 1000 * 1000;
const long INF = 1000 * 1000 * 1000;
const long long int mod = 1000000007;

int main(){
  FASTIO
  int a, b;
  cin >> a >> b;
  if(a >=10 || b >=10){
    cout << -1 << endl;
  }
  else {
    cout << a * b<< endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
#define INF 1<<30

int main()
{
    string S;
    cin >> S;
    if(S=="hi"||S=="hihi"||S=="hihihi"||S=="hihihihi"||S=="hihihihihi")cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
//isaf27

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <vector>
#include <queue>
#include <bitset>
#include <cmath>
#include <time.h>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <deque>
#include <iomanip>
#include <complex>
//#include <ext/rope>

using namespace std;
//using namespace __gnu_cxx;

//defines
typedef long long ll;
typedef long double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define fast_read cin.sync_with_stdio(0)
#define PREX(number) cout << fixed << setprecision(number)
#define nul point(0, 0)
#define random srand(time(NULL))
#define rand_int abs((rand() << 15) | rand())
#define str_to_int(stroka) atoi(stroka.c_str())
#define str_to_ll(stroka) atoll(stroka.c_str())
#define str_to_double(stroka) atof(stroka.c_str())
#define what_is(x) cerr << #x << " is " << x << endl
#define solve_system int number; cin >> number; for (int i = 0; i < number; i++) solve()
#define solve_system_scanf int number; scanf("%d", &number); forn(i, 0, number) solve()

//easy functions
template< typename T >
T gcd(T a, T b) { return a ? gcd(b % a, a) : b; }
template< typename T >
T lcm(T a, T b) { return (a / gcd(a, b)) * b; }
bool is_down(char x) { return ('a' <= x && x <= 'z'); }
bool is_upper(char x) { return ('A' <= x && x <= 'Z'); }
bool is_digit(char x) { return ('0' <= x && x <= '9'); }

//constants
const ld pi = 3.141592653589793238462643383279;
const ld log23 = 1.58496250072115618145373894394781;
const ld eps = 1e-10;
const ld zero = 0;
const ll INF = 1e18;
const int COUT = 30;
const int prost = 239;
const ll prost64 = 239;
const int two = 2;
const int thr = 3;
const ll sr = 31;
const ll MOD = 1e9 + 7;
const ll MOD2 = MOD * MOD;
const int BIG = 1e9 + 239;
const int alf = 26;
const int M = 2 * 1e5 + 239;
const int N = 2 * 1e3 + 239;
const int T = (1 << 20);
const int B = trunc(sqrt(M)) + 1;
const int MAX_LOG = 19;
const int km = (1 << 18);
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int bit_max = 32;
const int dig = 10;
const string str_alf = "abcdefghijklmnopqrstuvwxyz";
const string str_alf_big = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int bt = 31;

// Code starts here

int n, a[M];

int main()
{   /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif /**/
    fast_read;
    cin >> n;
    a[0] = 0;
    n++;
    for (int i = 0; i < n - 1; i++)
        cin >> a[i + 1];
    int ans = 0;
    for (int i = 0; i < n; i++)
        ans += abs(a[(i + 1) % n] - a[i]);
    for (int x = 1; x < n; x++)
        cout << ans - abs(a[x] - a[x - 1]) - abs(a[(x + 1) % n] - a[x]) + abs(a[(x + 1) % n] - a[x - 1]) << "\n";
    return 0;
}


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

int N;
int A[21]; // 価値
int B[21]; // コスト

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];
  	for (int i = 0; i < N; ++i) cin >> B[i];
  
  int cnt = 0;
  for (int i = 0; i < N; ++i){
    if(A[i] > B[i]) cnt = cnt + A[i] - B[i];
  }
  
  cout << cnt << endl;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    string A, B;
    cin >> A >> B;
    if(SZ(A) > SZ(B)) PR("GREATER");
    else if(SZ(A) < SZ(B)) PR("LESS");
    else {
        ll f = true;
        REP(i,0,SZ(A)) {
            if(A[i] > B[i]) {
                PR("GREATER");
                f = false;
                break;
            }
            else if(A[i] < B[i]) {
                PR("LESS");
                f = false;
                break;
            }
        }
        if(f) PR("EQUAL");
    }

    return 0;
}

/*



*/

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define int long long
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
using namespace std;
static const int INF = 1ll<<60;
typedef pair<int,int> pii;

int W,H;
int N;
int dis[100010];
vector<int> posx;
vector<int> posy;
vector<pii> pos;

int dist(int x,int y){
    int res=0;
    for(int i=0;i<N;++i){
        int disx=abs(x-pos[i].FI);
        int disy=abs(y-pos[i].SE);
        dis[i]=disx+disy;
    }
    sort(dis,dis+N);
    for(int i=0;i<N-1;++i)res+=dis[i]*2;
    res+=dis[N-1];
    return res;
}

signed main(){
    cin>>W>>H;
    cin>>N;
    for(int i=0;i<N;++i){
        int x,y;
        cin>>x>>y;
        posx.PB(x);
        posy.PB(y);
        pos.PB(pii(x,y));
    }
    if(N%2!=0){
        sort(posx.begin(),posx.end());
        sort(posy.begin(),posy.end());
        int x=posx[N/2];
        int y=posy[N/2];
        int ans=dist(x,y);
        cout<<ans<<endl;
        cout<<x<<" "<<y<<endl;
    }
    else{
        sort(posx.begin(),posx.end());
        sort(posy.begin(),posy.end());
        int ans=INF;
        int x,y;
        int d1=dist(posx[N/2-1],posy[N/2-1]);
        int d2=dist(posx[N/2-1],posy[N/2]);
        int d3=dist(posx[N/2],posy[N/2-1]);
        int d4=dist(posx[N/2],posy[N/2]);
        if(ans>d1){
            ans=d1;
            x=posx[N/2-1];
            y=posy[N/2-1];
        }
        if(ans>d2){
            ans=d2;
            x=posx[N/2-1];
            y=posy[N/2];
        }
        if(ans>d3){
            ans=d3;
            x=posx[N/2];
            y=posy[N/2-1];
        }
        if(ans>d4){
            ans=d4;
            x=posx[N/2];
            y=posy[N/2];
        }
        cout<<ans<<endl;
        cout<<x<<" "<<y<<endl;
    }
}

Measured memory_bytes: 5324
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(8e18);

ll d[MAXn];
ll dp[60][2];
ll n, k;

ll ct(ll t)
{
    ll tt = 0;
    REP(i,n)if(t & d[i])tt++;
    return tt;
}

int main()
{
    IOS();
    cin>>n>>k;
    REP(i,n)cin>>d[i];
    dp[41][0] = -INF;
    for(int i = 40;i >= 0;i --)
    {
        ll t = ct((1LL<<i));
        if((1LL<<i) & k)
        {
            dp[i][0] = max(max(dp[i+1][0], dp[i+1][1]) + t * (1LL<<i), dp[i+1][0] + (n-t) * (1LL<<i));
            dp[i][1] = dp[i+1][1] + (n-t) * (1LL<<i);
        }
        else
        {
            dp[i][0] = max(dp[i+1][0] + t * (1LL<<i), dp[i+1][0] + (n-t) * (1LL<<i));
            dp[i][1] = dp[i+1][1] + t * (1LL<<i);
        }
    }
    cout<<max(dp[0][0], dp[0][1])<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (size_t i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (size_t k = 1; k < v.size(); k++)
	{
		for (size_t j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int a, b;
	cin >> a >> b;
	if (a > 12)
	{
		cout << b << endl;
	}
	else if (6 <= a && a <= 12)
	{
		cout << b / 2 << endl;
	}
	else
	{
		cout << 0 << endl;
	}
	return 0;
}

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


signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    string s;
    cin>>s;
    s = 'A' + s;
    int n = s.size();
    int ans = 0;
    for(int i=1;i<n;i++){
        if(s[i] <= s[i-1]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define vv(type)		vector<vector<type>>
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define db(x) 			cout<<x<<" "
#define db1(x) 			cout<<x<<'\n'
#define db2(x,y) 		cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) 		cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) 		for(int i=0;i<(n);++i)
#define repA(i,a,n) 	for(int i=a;i<=(n);++i)
#define repD(i,a,n) 	for(int i=a;i>=(n);--i)
#define so(a) 			sort(a.begin(),a.end())
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
// to find all local maximaa and minima in O(n)
//	 for (int i=1;i<=n;i++)
//        {
//            if (i==1 || i==n || (p[i-1]<p[i])!=(p[i]<p[i+1]))
//           ans.push_back(p[i]);
//        }
int dx[] = { -1, 1, -1, 0, 0, -1, 1, 1 };
int dy[] = { -1, -1, 1, -1, 1, 0, 0, 1 };
int gcd(int a, int b)
{
	if (!b)
		return a;
	return gcd(b, a % b);
}
int modular_expo(int x, int y, int m)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans % m * x % m) % m;
		x = (x % m * x % m) % m;
		y /= 2;
	}
	return ans % m ;
}
int power(int x, int y)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans * x);
		x *= x;
		y /= 2;
	}
	return ans;
}

void solve()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	vi h(n);
	rep(i, n)
	cin >> h[i];
	vi dp(n);
	repA(i, 1, n - 1)
	{
		dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
		repA(j, 2, k)
		if (i - j >= 0)
			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
	}
	db1(dp[n - 1]);
}

int32_t main()
{
	solve();
	return 0;
}


Measured memory_bytes: 4712
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef int64_t Int;
const double pi = M_PI;

int main()
{
    bool cards[52] = {};
    int n;
    cin >> n;

    char suits;
    int rank;
    for (int i = 0; i < n; i++)
    {
        cin >> suits >> rank;
        switch (suits)
        {
        case 'S':
            cards[rank - 1] = true;
            break;

        case 'H':
            cards[13 + rank - 1] = true;
            break;

        case 'C':
            cards[26 + rank - 1] = true;
            break;

        case 'D':
            cards[39 + rank - 1] = true;
            break;

        default:
            break;
        }
    }

    for (int i = 0; i < 52; i++)
    {
        if (!cards[i])
        {
            switch (i / 13)
            {
            case 0:
                cout << "S " << i + 1 << endl;
                break;

            case 1:
                cout << "H " << i + 1 - 13 * 1 << endl;
                break;

            case 2:
                cout << "C " << i + 1 - 13 * 2 << endl;
                break;

            case 3:
                cout << "D " << i + 1 - 13 * 3 << endl;
                break;

            default:
                break;
            }
        }
    }
}



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

using namespace std;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}

int main(){

    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    //freopen("input.txt", "r", stdin);

    int n, best = 0;
    long long POW = 1, src = 0, tgt = 0, MOD = 1000000007;

    string s, t;

    cin >> n >> s >> t;

    for(int i = n - 1; i >= 0; --i){

        src = (src * 26 % MOD + s[i] - 97) % MOD;
        tgt = (tgt + (t[n - i - 1] - 97) * POW) % MOD;

        if(src == tgt)
            best = n - i;

        POW = POW * 26 % MOD;

    }

    cout << 2 * n - best;

    return 0;
}


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

int main(void){
    std::string S, ans="yes";
    std::cin >> S;
    std::map<char, int> mp;
    for (char c: S){
        if (mp.find(c) == mp.end()){
            mp[c] = 0;
        } else {
            ans = "no";
            break;
        }
    }

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


Measured memory_bytes: 3632
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

ans = 0

s = input()
tmp = s[0]
cnt = 1
back = False
for c in s[1:]:
    if tmp == c:
        cnt += 1
    else:
        # print(cnt)
        ans += (cnt // 3) * 2
        cnt = cnt % 3
        if cnt == 1:
            ans += 1
            back = False
        elif cnt == 2:
            if back:
                ans += 2
                back = False
            else:
                ans += 1
                back = True
        else:
            pass
        # print(cnt, tmp, ans)
        cnt = 1
        tmp = c


print(ans)

Measured memory_bytes: 43244
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	while(1){
	  int h,w; cin >> h >>w;
	  if(h==0 && w==0)break;
	  for(int i=0;i<h;i++){
	  	if(i==0 || i==h-1){
	  		for(int j=0;j<w;j++){
	  			cout <<"#";
	  		}
	  		cout << endl;
	  	}
	  	else{
	  		cout << "#";
	  		for(int j=1;j<w-1;j++){
	  			cout << ".";
	  		}
	  		cout << "#";
	  		cout << endl;
	  	}
	  }
	  cout << endl;
    }
}



Measured memory_bytes: 3068
#include <iostream>
using namespace std;
int main() {
  string N;
  cin >> N;
  int counter = 0;
  for(int i = 1;i <= stoi(N); i++) {
    if ((int)(to_string(i).length()) % 2 == 1) {
      counter++;
    }
  }
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var s = Console.ReadLine();

            s = s.Replace("0", "");


            Console.WriteLine(s.Length);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 11092
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 500000

int n;
char s[MAXN];
int left[MAXN], right[MAXN];

int input() {
	if (scanf("%s", s) < 0) return 0;
	n = strlen(s)+1;
	return 1;
}

void init() {
}

long solve() {
	left[0] = 0;
	for (int i=0; i<n-1; i++) {
		if (s[i]=='<')
			left[i+1] = left[i]+1;
		else
			left[i+1] = 0;
	}
	right[n-1] = 0;
	for (int i=n-2; i>=0; i--) {
		if (s[i]=='>')
			right[i] = right[i+1]+1;
		else
			right[i] = 0;
	}
	long r =0;
	for (int i=0; i<n; i++)
		r += max(left[i], right[i]);
	return r;
}

void output(long ans) {
	printf("%ld\n", ans);
}

void cleanup() {
}

int main() {
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 4608
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> //required
//#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define lb long double
#define pb push_back
#define loop(i,start,n) for(ll i=start;i<n;i++)
#define rloop(i,n,start)for(ll i=n;i>=start;i--)
#define mod 1000000007
#define endl "\n"
#define INF     1e15
#define NEG_INF -1e15
#define pll pair<ll,ll>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
//using namespace __gnu_pbds;

int main(){
	IOS;
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	ll moves = x / d;
	x -= d * min(moves, k);
	k -= min(moves, k);

	if(k % 2 == 0)
		cout << x << endl;
	else
		cout << abs(x - d) << endl;
}

Measured memory_bytes: 3652
N = int(input())
s = [input() for i in range(N)]
S = [[0]*len(s[i]) for i in range(N)]
for i, x in enumerate(s):
    res = []
    q = 0
    for j in range(len(x)):
        if x[j] == ')':
            S[i][j] = -1
        else:
            S[i][j] = 1
s = [0]*N
m = [len(S[i]) for i in range(N)]
for i, x in enumerate(S):
    tmp = 0
    for j in range(len(x)):
        tmp += S[i][j]
        m[i] = min(tmp, m[i])
    s[i] = tmp

if sum(s) == 0:
    sp = [(m[i], s[i]) for i in range(N) if s[i] > 0]
    mp = [(-(s[i]-m[i]), -s[i]) for i in range(N) if s[i] <= 0]#右から見た場合
    sp.sort(key=lambda x: x[0], reverse=True)
    tmp = 0
    for x, y in sp:
        if tmp + x < 0:
            print("No")
            exit(0)
        tmp += y
    mp.sort(key=lambda x: x[0], reverse=True)
    tmp2 = 0
    for x, y in mp:
        if tmp2 + x < 0:
            print("No")
            exit(0)
        tmp2 += y
    print("Yes")

else:
    print("No")


Measured memory_bytes: 328648
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n; cin>>n;
    vl as(n); cin>>as;

    ll ans = 0;
    rep(i, n) {
        if (i % 2 == 0 && as[i] % 2 == 1) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3656
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CDigitsInMultiplication solver = new CDigitsInMultiplication();
        solver.solve(1, in, out);
        out.close();
    }

    static class CDigitsInMultiplication {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long n = in.nextLong();
            int min = 100;
            for (long i = 1; i < Math.sqrt(n) + 1; i++) {
                if (n % i == 0) {
                    min = Math.min(min, f(i, n / i));
                }
            }
            out.println(min);
        }

        int f(long a, long b) {
            return Math.max(Long.toString(a).length(), Long.toString(b).length());
        }

    }
}



Measured memory_bytes: 36012
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${sL!EWL(5Qgtayu*lURVXHDwR@=0a@{B3)<u=ECy9k)yY>Xyx8HFHOIn&sqWOOR{%0n4piQEVj7@8>($$@;aif;Y>Ev#Vj8nGL_^M4zo0qcjEtbkV!bH+hSy->6Ev?y?;e#6QeiqMVGK8xj)qyQj>AE(2@R^9^U?!mSfl5irYmBQzc9(Bey}=sxzH>UM2GwEnN7{sAc#1N}m=zbMG**D`gwa72eG9X%?w9YfLU%IiKoPNMLYRS*EhbKiFdH;n^R=<-=>+)cy;TUx%9LO@{+iFfY<GhuKVvdCj=(Lh@aT;OsdW#6fGxa_=oV7f_Q(pzugI|P<J@w=?MiFWf--IJku4&x3kMNTUKNS7@&9>^q#79o3)!z4CX}s}ar4D(gBk4wDA>T`xqNDjMR*!@xMw&R&qwJ^#pE~qdgir7l!q(HZVDdY=@FK!S+V8}BT~n!Qlnf(fXnh6Pr%#tlLT}Ej)U~m{H=HO4j%S~Snlxj4V~vLoD4OeTCRKq!`BXTWD#dKRP-AX=bIPbOWziwiO?nHwbb2~j<+SA8Lfxq%<q3#{ny=#K0^Kza=(j_8u=%`2JGo{@(;l+ACd")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 14028
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int a[n],i;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  int k=0,m;
  for(i=0;i<n;i++){
    if(a[i]>=k){
      k=a[i];
      m=i;
    }
  }
  int l=0;
  for(i=0;i<n;i++){
    if(a[i]>=l&&i!=m){
      l=a[i];
    }
  }
  for(i=0;i<n;i++){
    if(m==i){
      printf("%d\n",l);
    }
    else{
      printf("%d\n",k);
    }
  }
}


Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main() {
    ll n,m;
    cin >> n >> m;
    vector<string> a(n),b(m);
    for (ll i=0;i<n;++i){
        cin >> a[i];
    }
    for (ll i=0;i<m;++i){
        cin >> b[i];
    }
    for (ll i=0;i<n-m+1;++i){
        for (ll j=0;j<n-m+1;++j){
            bool flag=true;
            for (ll k=i;k-i<m;++k){
                for (ll l=j;l-j<m;++l){
                    if (a[k][l]!=b[k-i][l-j]){
                        flag=false;
                    }
                }
            }
            if (flag){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e6+1;

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n;
	cin >> n;
	ll a[n + 1];
	for (int i = 0; i <= n; i++)
		cin >> a[i];
	ll ans = 0, x;
	for (int i = 0, x; i < n; i++)
	{
		cin >> x;
		if (x > a[i])
		{
			ans += a[i], x -= a[i];
			if (x > a[i + 1])
				ans += a[i + 1], x -= a[i + 1], a[i + 1] = 0;
			else
				ans += x, a[i + 1] -= x;
		}
		else
			ans += x, a[i] -= x;
	}
	cout << ans;
	return 0;
}


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

vector<string> field;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
  int h, w;
  cin >> h >> w;
  int sy = 1, sx = 1, gy = h, gx = w;

  field.resize(h);
  for(int i = 0; i < h; ++i)cin >> field[i];

  int count = 0;
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      if(field[i][j] == '.')++count;
    }
  }

  vector<vector<int>> dist(h, vector<int>(w, -1)); // init
  queue<pair<int, int>> que;

  dist[sy - 1][sx - 1] = 1;
  que.push(make_pair(sx - 1, sy - 1));

  while(!que.empty()){
    pair<int, int> v = que.front(); // pick head element
    que.pop();

    if(v.first == gx - 1 && v.second == gy - 1)cout << count - dist[v.second][v.first] << endl;

    for(int i = 0; i < 4; ++i){
      int nx = v.first + dx[i];
      int ny = v.second + dy[i];

      if(ny < 0 || ny >= h || nx < 0 || nx >= w)continue;
      if(field[ny][nx] == '#')continue;

      if(dist[ny][nx] != -1)continue;

      dist[ny][nx] = dist[v.second][v.first] + 1;
      que.push(make_pair(nx, ny));
    }
  }
  if(dist[gy - 1][gx - 1] == -1)cout << -1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int maxn = 3010;
const int mod = 1e9 + 7;
long long power(long long x, long long k)
{
	long long ans = 1;
	while(k)
	{
		if(k & 1)
			(ans *= x) %= mod;
		k >>= 1;
		(x *= x) %= mod;
	}
	return ans;
}
int v[maxn];
int n, q;
long long dp[maxn][maxn] = {0};
long long fx1[maxn], fx2[maxn], fy1[maxn], fy2[maxn];
void out()
{
	for(int i = 1; i <= n; i ++)
		for(int j = 1; j <= n; j ++)
			cout << i << " " << j << " " << dp[i][j] << endl;
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> q;
	for(int i = 1; i <= n; i ++)
		cin >> v[i];
	//bool asd = 0;
	for(int i = 1; i <= n; i ++)
		for(int j = 1; j <= n; j ++)
			if(v[i] > v[j])
				dp[i][j] = 1;
	//out();
	long long inv2 = power(2, mod - 2);
	for(int t = 1; t <= q; t ++)
	{
		//cout << t << " : " << endl;
		//asd ^= 1;
		int x, y;
		cin >> x >> y;
		for(int i = 1; i <= n; i ++)
		{
			fx1[i] = dp[x][i];
			fx2[i] = dp[i][x];
			fy1[i] = dp[y][i];
			fy2[i] = dp[i][y];
		}
		for(int i = 1; i <= n; i ++)
			if(x != i && i != y)
			{
				dp[i][x] = (fx2[i] * inv2 + fy2[i] * inv2) % mod;
				dp[x][i] = (fx1[i] * inv2 + fy1[i] * inv2) % mod;
				dp[i][y] = (fy2[i] * inv2 + fx2[i] * inv2) % mod;
				dp[y][i] = (fy1[i] * inv2 + fx1[i] * inv2) % mod;
			}
		dp[x][y] = (fx1[y] * inv2 + fy1[x] * inv2) % mod;
		dp[y][x] = (fy1[x] * inv2 + fx1[y] * inv2) % mod;
		//out();
	}
	long long ans = 0;
	for(int i = 1; i <= n; i ++)
		for(int j = i + 1; j <= n; j ++)
			(ans += dp[i][j]) %= mod;
	cout << ans * power(2, q) % mod << endl;
	return 0;
}
/*
3 2
1
2
1
1 2
1 3
*/

Measured memory_bytes: 70912
/* ITP1_5_C */
import java.io.*;

class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();

    while(true){
      // input
      String str[] = br.readLine().split(" ");
      int height = Integer.parseInt(str[0]);
      int width = Integer.parseInt(str[1]);
      //finish
      if(height == 0 && width == 0) break;
      if(height > 300 || width > 300) break;
      // drow
      for(int i = 0; i < height; i++){
        for(int j = 0; j < width; j++){
          sb.append((i + j) % 2 == 0 ? "#" : ".");
        }
        sb.append("\n");
      }
      sb.append("\n");
    }
    // output
    System.out.print(sb);
  }
}

Measured memory_bytes: 25216