akhauriyash/Code-Regression huggingface dataset:
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

#define ll long long
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}


ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

ll N, A;
vec x;
ll dp[60][3000][60];

int main(){
  cin >> N >> A;
  x.resize(N); rep(i, N) cin >> x[i];
  dp[0][0][0] = 1;
  for(int i = 1; i <= N; i++){
    for(int j = 0; j < 3000; j++){
      for(int k = 0; k < 60; k++){
        if(k == 0 || j-x[i-1] < 0) dp[i][j][k] = dp[i-1][j][k];
        else dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-x[i-1]][k-1];
      }
    }
  }
  ll ans = 0;
  for(int i = 1; i <= N; i++){
    ans += dp[N][i*A][i];
  }
  cout << ans << endl;
}


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

void out(deque<int> v) {
    int sz = v.size();
    for (int i = 0; i < sz; i++) {
        cout << v.front() << " \n"[i == sz - 1];
        v.pop_front();
    }
}

int main() {
    ll n,a,b;
    cin >> n >> a >> b;
    if (a * b < n) {
        cout << -1 << endl;
        return 0;
    }
    if (a + b - 1 > n) {
        cout << -1 << endl;
        return 0;
    }
    int pos = n;
    deque<int> dq;
    for (int i = 0; i < a; i++) {
        dq.push_front(pos--);
    }
    while (--b) {
        int tmp = a;
        vector<int> v;
        while (tmp-- > 0 && pos >= b) {
            v.push_back(pos--);
        }
        for (int i = 0; i < v.size(); i++) {
            dq.push_back(v[v.size() - i - 1]);
        }
    }
    out(dq);
    return 0;
}


Measured memory_bytes: 4608
n = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

ans = 0
for i in range(n):
    s1 = sum(A1[:i+1])
    s2 = sum(A2[i:])
    ans = max(ans, s1 + s2)
print(ans)

Measured memory_bytes: 9136
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll t, n;
int main()
{
    cin>>n;
    if(n%10==3)
        cout<<"bon";
    else if(n%10==0 || n%10==1 || n%10==6 || n%10==8)
        cout<<"pon";
    else
        cout<<"hon";
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;

    for (int i = 1; i <= N; i++){
        if(i % 3 == 0){
            cout << " " << i;
            continue;
        }

        bool flag = true;
        int x = i;
        while(flag) {
            if(x % 10 == 3){
                cout << " " << i;
                flag = false;
                continue;
            }
            x /= 10;
            if(x == 0){
                flag = false;
                continue;
            }
        }

    }
    cout << endl;
}



Measured memory_bytes: 3084
n,k=[int(x) for x in input().split()]
s=[]
for i in [None]*n:
    a,b=[int(x) for x in input().split()]
    s.append((a,b))
s=sorted(s,key=lambda x : x[0])
for i in s:
    if i[1]>=k:
        print(i[0])
        break
    else:
        k-=i[1]

Measured memory_bytes: 59224
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl

int main() {
    string s;
    cin >> s;
    int ans=100000;
    rep(i,s.size()-2) {
        int a = 0;
        a += s.at(i)-'0';
        a = a*10+s.at(i+1)-'0';
        a = a*10+s.at(i+2)-'0';
        a = 753 - a;
        if (a < 0) a *= (-1);
        ans = min(ans, a);
    }
    ct(ans);
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define quickIO()	{cin.tie(0);	cout.sync_with_stdio(false);}
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<(int)n;i++)
#define REP(i,n)	for(int i=0;i<=(int)n;i++)
#define srep(i,a,n)	for(int i=a;i<(int)n;i++)
#define SREP(i,a,n)	for(int i=a;i<=(int)n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll sqrt(ll x) {
	ll left = 0, right = x;
	rep(i, 100) {
		ll mid = (left + right) >> 1;
		if (mid*mid <= x)	left = mid;
		else	right = mid;
	}
	return left;
}
ll gcd(ll a, ll b) {
	return a%b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	printf("Case #%d: ", x)
#define DEBUG 0
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0,0 };
const int dy[] = { 0,1,0,-1,0 };

ll fact[1000010];
ll inv[1000010];
ll dp[1000010];

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

ll nCm(ll n, ll m) {
	return fact[n] * ((inv[m] * inv[n - m]) % mod) % mod;
}

int main() {
	int n;	cin >> n;
	if (n == 2) {
		cout << 1 << endl;
		return 0;
	}
	else if (n == 3) {
		cout << 4 << endl;
		return 0;
	}
	fact[0] = fact[1] = inv[0] = inv[1] = 1;
	SREP(i, 2, n) {
		fact[i] = (fact[i - 1] * i) % mod;
		inv[i] = (inv[i - 1] * modpow(i, mod - 2)) % mod;
	}
	ll ret = 0;
	srep(i, 2, n) {
		if (i * 2 < n)	continue;
		dp[i] = ((nCm(i - 1, n - i - 1)*fact[i]) % mod)*fact[n - i - 1] % mod;
		(ret += ((dp[i] - dp[i - 1] + mod) % mod)*i) %= mod;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 21632
class Node
  attr_accessor :id, :parent, :children, :depth

  def initialize(n)
    @id = n
    @parent = -1   # 初期値-1, add_childで上書き
    @children = []
  end

  def add_child(child)
    @children << child
    child.parent = self
  end
  
  def set_depth(n)
    @depth = n
    @children.each do | c |
      c.set_depth(n+1)
    end
  end

  def to_s; "#{@id}"; end

  def type
    if self.parent == -1
      "root"
    elsif children.size > 0
      "internal node"
    else
      "leaf"
    end
  end

  def children_id
    s = '['
    @children.each_with_index do | c,i |
      s += "#{c.id}"
      s += ', ' if i != @children.size - 1
    end
    s += ']' 
  end

end

n = gets.to_i
kcs = n.times.map{ gets.split.map(&:to_i) }

tree = Array.new(n){ | i | Node.new(i) }

kcs.each do | kc |
  id = kc.shift; kc.shift
  kc.each do | c |
    tree[id].add_child(tree[c])
  end
end

# nodeを作ってく中でdepthを設定すると, node:0から
# 読み込まれなかった場合にerr
root = nil;
tree.each{ |node| root = node if node.parent == -1}
root.set_depth(0)

tree.each do | c, i |
  print "node #{c.id}: "
  print "parent = #{c.parent}, "
  print "depth = #{c.depth}, "
  print "#{c.type}, "
  print "#{c.children_id}"
  puts ''
end



Measured memory_bytes: 170748
#include<iostream>
using namespace std;
int main()
{
    char c[12];
    for(int i=0;i<12;i++)
    {
        cin>>c[i];
    }
    for(int i=0;i<4;i++)
    {
        cout<<c[i];
    }
    cout<<" ";
    for(int i=4;i<12;i++)
    {
        cout<<c[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
// AIZU ONLINE JUDGE http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=10022
//*
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(){
    char search[21], word[21];
    int count=0;
    int i;
    
    scanf("%s", search);
    while(1){
        scanf(" %s", word);
        if(strcmp(word, "END_OF_TEXT")==0)break;
        for(i=0;word[i]!='\0';i++){
            word[i]=tolower(word[i]);
        }
        if(strcmp(word, search)==0){
            count++;
        }
    }
    printf("%d\n", count);

    return 0;
}
//*/


Measured memory_bytes: 2724
import heapq
from collections import defaultdict, deque
from math import ceil, factorial
from fractions import gcd
import sys
sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 10**9+7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))


def get_divisor(n):
    divs = set()
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divs.add(i)
            divs.add(n // i)
    return divs


n = ii()
ans = 0

# K が N の約数のとき
for x in get_divisor(n):
    if x == 1:
        continue
    tmp = n
    while tmp % x == 0:
        tmp //= x
    if tmp % x == 1:
        ans += 1

# K が N の約数でないとき
# 1 は除く
ans += len(get_divisor(n-1)) - 1

print(ans)



Measured memory_bytes: 5836
import java.util.Scanner;

public class Main {
    static int N;
    static int THRESHOLD = 111;

    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        scanner.close();

        for(int i = 0; i < 9; i++) {
            if(N > THRESHOLD * i && N <= THRESHOLD * (i + 1)) {
                System.out.println(THRESHOLD * (i + 1));
                break;
            }
        }
    }
}

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

using namespace std;

int main()
{
    int n,x;
    while(cin >> n >> x)
    {
        if(n== 0 && x == 0) break;
        int ans = 0;
        for(int i = 1; i <= n; i++)
        {
            for(int j = i+1; j <= n; j++)
            {
                for(int k = j+1; k <= n; k++)
                {
                    if(i + j + k == x) ans++;
                }
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3104
#include<iostream>


#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
using namespace std;

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




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

	long long t = sqrt(s);
	if (floor(sqrt(s)) != ceil(sqrt(s))) {
		t++;
	}
	
	cout << 0 << endl<<0 <<endl<< t <<endl<< 1 <<endl<< t*t-s <<endl<< t << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new File("c:\\0509-input.txt"));

		while (true) {
			int n = scan.nextInt();
			if (n == 0)
				break;
			String s = scan.next();
			run(n, s);
		}

		scan.close();
		System.exit(0);
	}

	private static void run(int n, String s) {
		if (n == 0) {
			System.out.println(s);
			return;
		}

		StringBuilder ss = new StringBuilder("");
		
		for (int i = 0; i < s.length(); i++) {
			int repeat = 1;
			for (int j = i + 1; j < s.length(); j++)
				if (s.charAt(i) == s.charAt(j)) {
					repeat++;
					i++;
				} else
					break;
			ss.append(String.valueOf(repeat));
			ss.append(String.valueOf(s.charAt(i)));
		}

		run(n - 1, ss.toString());
	}

}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x; cin>>x;
    ll now = 100;
    ll ans=0;
    while(now<x){
        now += now/100;
        ans++;
    }
    cout<<ans<<"\n";
    return 0;
}


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

int main(){
    int n, k, l;
    cin >> n >> k;
    vector<int> lst;
    for(int i = 0; i < n; i++){
        cin >> l;
        lst.push_back(l);
    }
    sort(lst.begin(), lst.end());
    int ans = 0;
    for(int i = 0; i < k; i++){
        ans += lst[i];
    }
    cout << ans << endl;
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N;
string S[202020];

template<class V, int ME> class BIT {
public:
	V bit[1<<ME];
	V operator()(int e) {if(e<0) return 0;V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
	void add(int e,V v) { e++; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
};
BIT<int,18> bt[26];

int same[202020][20];
int num[202020][26];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	vector<int> cand;
	cin>>N;
	FOR(i,N) {
		cand.push_back(i);
		cin>>S[i];
		reverse(ALL(S[i]));
	}
	sort(S,S+N);
	
	FOR(i,N-1) {
		j=0;
		while(j<S[i].size()&&j<S[i+1].size()&&S[i][j]==S[i+1][j]) j++;
		same[i][0]=j;
	}
	FOR(i,N) {
		//cout<<i<<" "<<S[i]<<endl;
		FORR(c,S[i]) {
			c-='a';
			num[i][c]++;
		}
		FOR(j,26) if(num[i][j]) bt[j].add(i,1);
	}
	
	FOR(i,18) {
		FOR(j,N) {
			same[j][i+1]=min(same[j][i],same[min(N,j+(1<<i))][i]);
		}
	}
	
	ll ret=0;
	for(i=1;i<=1010000;i++) {
		vector<int> cand2;
		FORR(c,cand) {
		//	cout<<i<<c<<endl;
			if(S[c].size()==i) {
				char tc=S[c].back();
				bt[tc].add(c,-1);
				
				x=c;
				y=c;
				for(j=18;j>=0;j--) {
					if(same[x][j]>=i-1) x+=1<<j;
					if(x>=N) x=N;
					if(y-(1<<j)>=0 && same[y-(1<<j)][j]>=i-1) y-=1<<j;
				}
				ret+=bt[tc](x)-bt[tc](y-1);
				//cout<<"!"<<c<<" "<<x<<" "<<y<<" "<<bt[tc](x+1)-bt[tc](y-1)<<endl;
			}
			else {
				cand2.push_back(c);
			}
		}
		FORR(c,cand2) {
			char tc=S[c][i-1];
			num[c][tc]--;
			if(num[c][tc]==0) bt[tc].add(c,-1);
		}
		swap(cand,cand2);
	}
	
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 68760
import math
N,M = map(int,input().split())
A = list(map(int,input().split()))
m = 0
s = sum(A)
for i in range(N):
  if A[i] < math.ceil(s/(4*M)):
    pass
  else:
    m += 1

if m >= M:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
S = input()

answer = 1

if S[0] != S[1]:
	answer = answer + 1

if S[0] != S[2] and S[1] != S[2]:
	answer = answer + 1

if S[0] != S[3] and S[1] != S[3] and S[2] != S[3]:
	answer = answer + 1

count0 = 0
count1 = 0
count2 = 0
count3 = 0

for i in range(4):
    if S[0] == S[i]:
    	count0 = count0 + 1
    if S[1] == S[i]:
    	count1 = count1 + 1
    if S[1] == S[i]:
    	count2 = count2 + 1
    if S[2] == S[i]:
    	count3 = count3 + 1

if answer == 2 and count0 ==2 and count1 == 2 and count2 == 2 and count3 == 2 :
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

vi TopologicalSort(const vector<vi>& g) {
  const int v = g.size();
  vi indeg(v, 0);
  stack<int> st;

  for (auto& out_edges : g)
    for (auto& v : out_edges) indeg[v]++;

  rep(i, v) {
    if (indeg[i] == 0) st.push(i);
  }

  vi ans;
  while (st.size() > 0) {
    int u = st.top();
    st.pop();
    ans.emplace_back(u);
    for (auto& v : g[u]) {
      indeg[v]--;
      if (indeg[v] == 0) st.push(v);
    }
  }
  return ans;
}



int main() {
  int n,m;
  cin >> n >> m;
  vector<vi> G(n,vi());
  vi depth(n,0),ans(n,0);
  rep(i,n-1+m){
    int u,v;
    cin >> u >> v;
    u--;v--;
    G[u].push_back(v);
  }
  auto res = TopologicalSort(G);
  for(auto u:res){
    for(auto v: G[u]){
      maxs(depth[v],depth[u]+1);
    }
  }

  rep(u,n){
    for(auto v: G[u]){
      if(depth[u]+1 == depth[v]) ans[v] = u+1;
    }
  }
  rep(i,n){
    cout<<ans[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 7548
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	ll h; scanf("%lld", &h);
	ll cnt = 1, ans = 0;
	while(h){
		ans += cnt;
		cnt *= 2;
		h /= 2;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a=sc.nextLong(),b=sc.nextLong();
    System.out.println(lcm(a,b));
  }
  static long lcm (long a, long b) {
	long temp;
	long c = a;
	c *= b;
	while((temp = a%b)!=0) {
		a = b;
		b = temp;
	  }
	return (long)(c/b);
  }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
 
using lli = long long int;
using ld=long double;
 
int main(){
    string s;
    cin>>s;
    int flag=1;
    for(int i=0;i<s.length();i++){
        if(i%2==0){
            if(s[i]=='U' || s[i]=='R' || s[i]=='D' )
            flag=1;
            else{
                flag=0;
                break;
            }
        }
        if(i%2!=0){
            if(s[i]=='U' || s[i]=='L' || s[i]=='D' )
            flag=1;
            else{
                flag=0;
                break;
            }
        }
    }
    if(flag==1)
    cout<<"Yes";
    else
    cout<<"No";
    
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int cnt = 0;

    for(int i = 0, j = s.size()-1; i < s.size()/2; i++,j--){
        if(s[i] != s[j])
            cnt++;
    }
    cout << cnt << endl;

}


Measured memory_bytes: 256
import * as fs from "fs";

function main(lines: string[][]) {
  const number = parseInt(lines[0][0]);
  const numbers: number[] = [];
  for (let i = 1; i <= number; i++) {
    numbers.push(i);
  }

  const commonDivisor = (a: number, b: number) => (b ? commonDivisor(b, a % b) : a);
  const greatestCommonDivisor = (a: number, b: number, c: number): number => {
    return commonDivisor(commonDivisor(a, b), c);
  };
  let point = 0;
  numbers.forEach((n1) => {
    numbers.forEach((n2) => {
      numbers.forEach((n3) => {
        point += greatestCommonDivisor(n1, n2, n3);
      });
    });
  });

  console.log(point);
}

const lines = fs
  .readFileSync("/dev/stdin", "utf8")
  .split("\n")
  .map((l) => l.split(" "))
  .filter((input) => !(input.length === 1 && input[0] === ""));

main(lines);


Measured memory_bytes: 33556
def counting_sort(a, b, k):
	c = [0] * (k + 1)
	for i in range(len(a)):
		c[a[i]] += 1
	for i in range(1, k + 1):
		c[i] += c[i - 1]
	for i in range(len(a) - 1, -1, -1):
		c[a[i]] -= 1
		b[c[a[i]]] = a[i]
		
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
counting_sort(a, b, max(a))
print(b[0], end='')
for i in range(1, n):
	print(' ' + str(b[i]), end='')
print()



Measured memory_bytes: 224380
package main

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

func main() {
	protagonist(os.Stdin, os.Stdout)
}

func protagonist(r basicIO.Reader, w basicIO.Writer) {
	io := NewIO(r, w)
	A, _ := io.nextInt()
	B, _ := io.nextInt()

	sol := B
	if A < 13 {
		if A < 6 {
			sol = 0
		} else {
			sol = B / 2
		}
	}
	io.PutInt(sol)
}

type IO struct {
	Scanner *bufio.Scanner
	Writer  basicIO.Writer
}

func NewIO(r basicIO.Reader, w basicIO.Writer) *IO {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &IO{
		Scanner: s,
		Writer:  w,
	}
}

func (io *IO) nextString() string {
	io.Scanner.Scan()
	return io.Scanner.Text()
}

func (io *IO) nextInt() (int, error) {
	io.Scanner.Scan()
	i, err := strconv.Atoi(io.Scanner.Text())
	return i, err
}

func (io *IO) PutInt(v int) {
	fmt.Fprintf(io.Writer, "%d\n", v)
}

func (io *IO) PutString(s string) {
	fmt.Fprintf(io.Writer, "%s\n", s)
}


Measured memory_bytes: 640
// Last Change: 10/19/2019 21:28:21.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll N;
  string S;
  cin >> N;
  cin >> S;
  vector<char> ss(N);
  for (ll i = 0; i < N; ++i) {
    ss[i] = S[i];
  }
  ss.erase(unique(ss.begin(), ss.end()), ss.end());

  cout << ss.size() << endl;
}


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

int main() {
    int H,N;
    cin >> H >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++) cin >> A.at(i);

    int sum = 0;
    for(int i:A) sum += i;

    if(sum>=H) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

int main(){
  int n, x;
  cin >> n >> x;
  vector<int> m(n);
  int sum = 0, min = 1001001001;
  for(int i = 0; i < n; i++){
    cin >> m[i];
    sum += m[i];
    if(m[i] < min){
      min = m[i];
    }
  }
  int ans = n + (x - sum) / min;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
/*
 *	Argorithms and Data Structures
 *	Lectuire 3 
 *  Stack
 */

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

void push(int);
int pop(void);

int dig(int);

#define N 101
int stack[N] = {0};
int top = 0;

int main(void){
	int x, y;
	char input[2022];
	char *point;

	point = input;

	scanf("%[^\n]", input);

	while( *point != '\0'  ){
		if( *point == ' ') point++;
		if( '0' <= *point && *point <= '9' ){
			push( atoi(point) );
			point += dig(atoi(point));
		}
		else
		{
			y = pop();
			x = pop();
			if( *point == '+' ){
				push( x+y );
			}
			else if( *point == '*' ){
				push( x*y );
			}
			else if (*point == '-'){
				push( x-y );
			}
		}
		point++;
	}
	
	printf("%d\n", pop() );

	return 0;
};


void push(int x){
	stack[++top] = x;
}

int pop(void ){
	return stack[top--];
}

int dig(int hoge){
	int count=0;
	while( hoge/10 >= 1 ){
		count++;
		hoge /= 10;
	}
	return count;
};

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

using namespace std;

int main()
{
    int cnt = 0;
    string s, t;
    cin >> s >> t;
    for(int i=0; i<3; i++) {
        if(s[i] == t[i]) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

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

const int N_MAX = 100;

int N;
int a[N_MAX];

void inputInfo(){
    scanf("%d", &N);
    for(int i = 0; i < N; ++i){
        scanf("%d", a + i);
    }
}

int solve(){
    int alice_score = 0;
    int bob_score = 0;

    sort(a, a + N);
    reverse(a, a + N);

    for(int i = 0; i < N; ++i){
        if(i % 2 == 0){
            alice_score += a[i];
        }
        else{
            bob_score += a[i];
        }
    }
    return alice_score - bob_score;
}

int main(){
    inputInfo();
    int ans = solve();
    printf("%d", ans);
}

Measured memory_bytes: 256
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(1000000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline--------------------------------------------
    s = input()
    sl = [i for i in s]
    n = len(s)-1
    ans = []
    anslist = []
    sublist = [-1]*n
    for i in range(1 << n):
        for j in range(n):
            if (i>>j)&1:
                sublist[j] = "+"
        anslist.append(sl[0])
        for j in range(n):
            if sublist[j] == "+":
                anslist.append("+")
                anslist.append(sl[j+1])
            else:
                anslist.append(sl[j+1])
        ans.append(eval("".join(anslist)))
        anslist = []
        sublist = [-1]*n
    print(sum(ans))
if __name__ == "__main__":
    main() 
    
#endline===============================================
    

Measured memory_bytes: 13672
#include <iostream>
#include <stdio.h>      /* printf, scanf, NULL */
#include <stdlib.h>
#include <math.h>
#include <iomanip>      // std::setprecision
#include <algorithm>
#include <vector>
using namespace std;

int n,a,b,c,d,e;

int main(){
    cin >> n >> a >> b >> c >> d;
    long long i, j, k;
    long long dist = b - a;
    long long minp, maxp, minn, maxn;
    minp = b + c - a; maxp = b + d - a; minn = b - d - a; maxn = b - c - a;
    //cout << minp << " " << maxp << " " << minn << " " << maxn << "\n";
    for(i = 0; i <= n - 2; i++){
        long long mini,maxi;
        mini = i * c - (n - 2 - i) * d;
        maxi = i * d - (n - 2 - i) * c;
        //cout << i << " " << mini << " " << maxi <<"\n";
        if(minp <= maxi && maxp >= mini){
            cout << "YES" << "\n";
            return 0;
        }
        else if(minn <= maxi && maxn >= mini){
            cout << "YES" << "\n";
            return 0;
        }
    }
    cout << "NO" << "\n";
    return 0;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[200001];
int n;
int c(int v, int x){
  return v >= x ? 1 : 0;
}
int bigeq(int x){
  int m = n - 1;
//  cout << m << endl;
  if(a[m] >= x && a[m + 1] >= x
  || a[m] >= x && a[m - 1] >= x)return 1;
  if(a[m] < x && a[m + 1] < x
  || a[m] < x && a[m - 1] < x)return 0;

  int mxall, mxalr;
  mxall = m - 1;
  mxalr = m + 1;
  while(mxall > 0 && c(a[mxall - 1], x) != c(a[mxall], x))mxall--;
  while(mxalr < 2 * n - 2 && c(a[mxalr + 1], x) != c(a[mxalr], x))mxalr++;
  int v = c(a[m], x);
  while(mxall <= m - 1 && mxalr >= m + 1){
    mxall++;
    mxalr--;
    v ^= 1;
  }
  return v;
}
int main(){
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  scanf("%d", &n);
  for(int i = 0;i < 2 * n - 1;i++)
    scanf("%d", a + i);


  int lo = 1, hi = 2*n - 1;
  while(lo < hi){
    int mid = (lo + hi + 1) / 2;
    if(bigeq(mid))
      lo = mid;
    else
      hi = mid - 1;
  }
  cout << lo;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long X;
  cin >> X;
  long long money = 100;
  long long count = 1;
  while(true){
    money *= 1.01;
    if(money >= X){
      cout << count << endl;
      break;
    }
    count++;
  }
}

Measured memory_bytes: 3632
n = int(input())
h = [list(map(int, input().split())) for _ in range(n)]
#i(0~n-1)日目にa,b,cで得られる幸福度はh[n-1][0,1,2]でアクセス

def solve():
#0日目～n-1日目と考えるので注意
    dp = [[0]*3 for _ in range(n)] #初期化
    for i in range(n):
        if i == 0:
            dp[i] = [h[0][j] for j in range(3)]
            continue
        for j in range(3):
            dp[i][j] = max([dp[i-1][jk] for jk in ({0,1,2} - {j}) ]) + h[i][j]
            #0,1,2からjを除いたものをjkとし、それの合計の高い方にh[i][j]を足す
    print(max(dp[n-1]))

solve()

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

#define ll long long

const ll M = 1e9 + 7;

ll Mod(ll a)
{
    return (a % M + M) % M;
}

ll MulMod(ll a, ll b)
{
    return Mod(Mod(a) * Mod(b));
}

ll AddMod(ll a, ll b)
{
    return Mod(Mod(a) + Mod(b));
}

ll SubMod(ll a, ll b)
{
    return Mod(Mod(a) - Mod(b));
}

void test()
{
    string s = "0";
    ll cnt = 0;

    while(s != "99999")
    {
        if(s.length() < 5)
        {
            for(ll i = 0; i < s.length(); i++)
            {
                if(s[i] == '9')
                {
                    cnt++;
                    break;
                }
            }
        }
        else
        {
            bool has9 = false;
            bool has0 = false;
            
            for(ll i = 0; i < s.length(); i++)
            {
                if(s[i] == '0')
                {
                    has0 = true;
                }

                if(s[i] == '9')
                {
                    has9 = true;
                }
            }

            if(has0 && has9)
            {
                cnt++;
            }
        }
        
        
        s = to_string(stoi(s) + 1);
    }

    cout << cnt << "\n";
}

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

    if(s < 3)
    {
        cout << 0 << "\n";
        return 0;
    }

    vector<ll> dp(s + 1);

    dp[0] = 0;
    dp[1] = 0;
    dp[2] = 0;

    for(ll i = 3; i <= s; i++)
    {
        dp[i] = 1;
        
        for(ll j = 3; j <= s; j++)
        {
            if(i - j >= 3)
            {
                dp[i] = AddMod(dp[i], dp[i - j]);
            }
        }
    }

    // for(ll i = 1; i <= s; i++)
    // {
    //     cout << dp[i] << " ";
    // }

    // cout << "\n";

    cout << dp[s];

    return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
int main()
{
    int a,b,c,d,n,i;
    scanf("%d",&n);
    int ar[n+1];
    for(i=1;i<=n;i++)
    {
        ar[i]=0;
    }
    for(i=1;i<n;i++)
    {
        scanf("%d",&a);
        ar[a]++;
    }
    for(i=1;i<=n;i++)
    {
        printf("%d\n",ar[i]);
    }
}


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

int main () {
    long long int a, b, c ;
    scanf ( "%lld %lld", &a, &b ) ;
    if ( a == 1 && b == 1 ) {
        printf ( "1\n" ) ;
    }
    else if ( a == 1 || b == 1 ) {
        c = a * b - 2 ;
        printf ( "%lld\n", c ) ;
    }
    else {
        c = a * b - ( a + a + b + b - 4 ) ;
        printf ( "%lld\n", c ) ;
    }
    return 0 ;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i,m,n) for (int i = (n)-1; (i) >= (m); --(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
typedef long long ll;
using namespace std;
template <class T> void setmax(T & a, T const & b) { if (a < b) a = b; }
template <class T> void setmin(T & a, T const & b) { if (b < a) a = b; }
template <typename T, typename X> auto vectors(T a, X x) { return vector<T>(x, a); }
template <typename T, typename X, typename Y, typename... Zs> auto vectors(T a, X x, Y y, Zs... zs) { auto cont = vectors(a, y, zs...); return vector<decltype(cont)>(x, cont); }
vector<int> func(int n, int k) {
    vector<int> result;
    for (; k >= 1 and n != 0; k = min(k-1, n)) {
        if (n >= k) {
            n -= k;
            result.push_back(k);
        }
    }
    if (n) result.clear();
    return result;
}
int main() {
    int n; cin >> n;
    repeat (k,n+1) {
        vector<int> xs = func(n, k);
        if (not xs.empty()) {
            for (int x : xs) cout << x << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 384
use std::cmp::min;
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n: usize = read();
    let p: Vec<f32> = (1..n + 1)
        .map(|_| {
            let number: f32 = read();
            number
        })
        .collect();
    let q: Vec<f32> = (0..n + 1)
        .map(|_| {
            let number: f32 = read();
            number
        })
        .collect();

    let mut k: Vec<Vec<usize>> = vec![vec![0; n + 1]; n + 1];
    let mut c: Vec<Vec<f32>> = vec![vec![0.0; n + 1]; n + 1];
    let mut s: Vec<f32> = vec![0.0; (2 * n) + 2];
    for index in 0..2 * n + 1 {
        if index % 2 == 1 {
            s[index + 1] = s[index] + p[index / 2];
        } else {
            s[index + 1] = s[index] + q[index / 2];
        }
    }

    for index in 0..n + 1 {
        c[index][index] = q[index];
        k[index][index] = index;
    }

    for index_i in 1..n + 1 {
        for index_j in 0..n + 1 - index_i {
            let m = index_i + index_j;
            let k0 = k[index_j][m - 1];
            let k1 = k[index_j + 1][m];

            let mut temp = 1e30;

            let mut k2: Option<usize> = None;

            for index_k in k0..min(k1 + 1, m) {
                let v = c[index_j][index_k] + c[index_k + 1][m];
                if v < temp {
                    k2 = Some(index_k);
                    temp = v;
                }
            }
            k[index_j][m] = k2.unwrap();

            c[index_j][m] = temp + (s[2 * m + 1] - s[2 * index_j]);
        }
    }
    println!("{}", c[0][n]);
}



Measured memory_bytes: 7132
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  ll sum = 0;
  rep(i,N)
  {
    sum += i;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3592
import math

def factorical(n):
    if n == 1:
        return n
    return n * factorical(n-1)

n = int(input())
a = []
for i in range(n):
  t = list(map(int,input().split()))
  a.append(t)
tot=0
mul = factorical(n-1)
for i in range(n):
  for j in range(n):
    tot += (math.sqrt((a[i][0]-a[j][0])**2 + (a[i][1]-a[j][1])**2))*mul
print(tot/(mul*n))



Measured memory_bytes: 3064
def gcd(a,b):
  c=0
  while True:
    c=a%b
    if 0==c: break
    a,b=b,c
  return b

N=int(input())
arr=list(map(int,input().split()))
d=arr[0]
for a in arr[1:]:
  d=gcd(d,a)
print(d)  


Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 998244353
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}

int main() {
   fast();
  long long n;
  cin>>n;
  long long l=n;
  int ans=0;
  while(l){
    l=l/10;
    ans++;
  }
  for(long long i=1;i<=sqrt(n);i++){
    if(n%i==0){
      long long c=i;
      long long d=n/i;
      int f=0;
      int g=0;
      while(c){
        c=c/10;
        f++;
      }
      while(d){
        d=d/10;
        g++;
      }
      ans=min(ans,max(f,g));
    }
  }
  cout<<ans<<"\n";



}

Measured memory_bytes: 3684
#include <iostream>
using namespace std;
typedef long long ll;
ll x, y, a, b;
int main(void){
    // Your code here!
    cin >> x >> y >> a >> b;
    a -= x, b -= y;
    cout << x + a - b << ' ' << y + a + b << ' ';
    cout << x - b << ' ' << y + a << endl;
}


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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

char maze[1000][1000];
bool G[1000][1000];

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

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    REP(y, h) REP(x, w) {
        cin >> maze[y][x];
    }
    vector<pii> cheese(n+1);
    REP(y, h) REP(x, w) {
        if (maze[y][x] == 'S') {
            cheese[0] = {x, y};
        } else if (isdigit(maze[y][x])) {
            cheese[maze[y][x] - '0'] = {x, y};
        }
    }
    int res = 0;
    REP(i, n) {
        fill_n((bool *)G, 1000*1000, false);
        pii sentinel = {-1, -1};
        pii goal = cheese[i+1];
        queue<pii> que;
        que.push(cheese[i]);
        que.push(sentinel);
        int cnt = 0;
        while (1) {
            pii p = que.front(); que.pop();
            if (p == sentinel) {
                if (que.empty()) break;
                que.push(sentinel);
                cnt++;
                continue;
            }
            if (p == goal) {
                break;
            }
            REP(i, 4) {
                int sx = p.first + dx[i], sy = p.second + dy[i];
                if (0 <= sx && sx < w && 0 <= sy && sy < h && maze[sy][sx] != 'X') {
                    if (!G[sy][sx]) {
                        G[sy][sx] = true;
                        que.push({sx, sy});
                    }
                }
            }
        }
        res += cnt;
    }
    cout << res << endl;
}

Measured memory_bytes: 3164
#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 - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

	ll h, w;
	cin >> h >> w;

	vvll a(h, vll(w));
	REP(i, h){
		REP(j, w) cin >> a[i][j];
	}
	vector<P> cur, dst;
    cur.reserve(h*w);
    dst.reserve(h*w);
	REP(i, h){
		REP(j, w - 1){
			if(a[i][j] % 2){
				cur.push_back(P{i + 1, j + 1});
				dst.push_back(P{i + 1, j + 2});
				a[i][j + 1]++;
			}
		}
	}
	REP(i, h - 1){
		if(a[i][w - 1] % 2){
			cur.push_back(P{i + 1, w});
			dst.push_back(P{i + 2, w});
			a[i + 1][w - 1]++;
		}
	}
	ll n = cur.size();
	cout << n << endl;
	REP(i, n){
		cout << cur[i].first << " " << cur[i].second << " ";
		cout << dst[i].first << " " << dst[i].second << "\n";
	}
  cout<<flush;
    return 0;
}


Measured memory_bytes: 11520
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define pb(a) push_back(a)
#define MAX(a, b) ((a < b)?b:a)
#define MIN(a, b) ((a > b)?b:a)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

ull gcd(ull a, ull b) { return b ? gcd(b, a%b) : a; }
ull lcm(ull m, ull n) {	return ((0 == m) || (0 == n)) ? 0 : ((m / gcd(m, n)) * n); }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int h, w;
vector<vector<char>> field;

bool func(int x, int y, int cnt)
{
	bool ret = false;
	if ( x < 0 ) return 0;
	if ( y < 0 ) return 0;
	if ( x >= w ) return 0;
	if ( y >= h ) return 0;

	if ( field[y][x] == '#' )
	{
		ret = true;
		rep(i, 4)
		{
			if ( field[y][x] != '.' ) field[y][x] = 'A';
			int next_x = x + dx[i];
			int next_y = y + dy[i];
			
			bool f = func(next_x, next_y, cnt + 1);
			if ( f || cnt > 0 ) field[y][x] = '.';
		}
	}

	return ret;
}

int main()
{
	cin >> h >> w;
	
	field.reserve(h);

	rep(y, h)
	{
		vector<char> v;
		v.reserve(w);
		rep(x, w)
		{
			char p;
			cin >> p;
			v.pb(p);
		}
		field.pb(v);
	}
	cout << endl;

	rep(y, h)
	{
		rep(x, w)
		{
			func(x, y, 0);
		}
	}

	bool isYes = true;
	rep(y, h)
	{
		rep(x, w)
		{
			if ( field[y][x] != '.' ) isYes = false;
		}
	}

	if ( isYes )
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define vi vector <int>
#define vl vector <long long>
#define pb push_back
#define mk make_pair
#define pi pair <int,int>
#define pl pair <ll,ll>
#define rep(i,a,n) for(int i=a;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define rep_(i,a,n) for(int i=(n-1);i>=a;i--)
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    a=a-b;
    if(c<=a)
    {
    	cout<<"0";
	}
	else
		cout<<c-a<<endl;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
from collections import deque

def main():
    def solve(i):
        C=[0]*n
        C[i]=1
        q=deque()
        q.append(i)
        while q:
            v=q.popleft()
            for to in Edges[v]:
                if C[to]==0:
                    q.append(to)
                    C[to]=C[v]+1
                else:
                    if C[to]!=C[v]+1 and C[to]!=C[v]-1:
                        return -1
        return max(C)
    n=int(input())
    S=[input().strip() for _ in range(n)]
    Edges=[[] for _ in range(n)]
    for i,s in enumerate(S):
        for j in range(n):
            if s[j]=='1':
                Edges[i].append(j)
    ans=-1
    for i in range(n):
        #print(solve(i))
        ans=max(ans,solve(i))
    return ans

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

Measured memory_bytes: 40816