akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define ii pair<int,int>
#define mod 1000000007
#define endl '\n'
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return ans;
}

void sieve(int n){
	bool prime[n+1];
	memset(prime,true,sizeof(prime));
	for(int p=2;p*p<=n;p++){
		if(prime[p]){
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false;
		}
	}
	for(int p=2;p<=n;p++){
		if(prime[p])
			cout<<p<<" ";
	}
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		int n;
		cin>>n;
		n%=10;
		if(n==3)
			cout<<"bon";
		else if(n==0||n==1||n==6||n==8)
			cout<<"pon";
		else
			cout<<"hon";
	}
	return 0;
}

Measured memory_bytes: 3660
n = input()
ans = 100000

for i in range(int(n)):
    add = int(ans*0.05)
    #print("first_add:" + str(add))
    add_list = list(str(add))
    digits = len(add_list)    
    sub3 = int(add_list[digits-3]+add_list[digits-2]+add_list[digits-1])
    add = int("".join(add_list))
    #print("sub3:"+ str(sub3))
    if sub3<1000 and sub3 > 0:
        add = add - sub3 + 1000
        #print("revised_add:" + str(add))
        
    ans = ans + add
    #print("ans:" + str(ans))

print(ans)

Measured memory_bytes: 7564
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define rint register int
using namespace std;
inline ll read(){ll w=1,s=0;char ch=getchar();while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}return w*s;}
int vis[410][410];
int n,m;
int u[1000010],v[1000010];
int ill[100010];
int main()
{	
	//freopen("c.in","r",stdin);
	//freopen("c.out","w",stdout);
	n=read(),m=read();ll ans=0;
	for(rint i=1;i<=m;++i)
	{
		u[i]=read(),v[i]=read();
	}
	for(rint i=1;i<=n;++i)
	{
		vis[i][i]=1;
		for(rint j=m;j>=1;--j)
		{
			int x=u[j],y=v[j];
			if(vis[i][x]&&vis[i][y])
			{
				ill[i]=1;
			}
			else if(vis[i][x]) vis[i][y]=1;
			else if(vis[i][y]) vis[i][x]=1;
		}
//		for(rint j=1;j<=n;++j) cout<<vis[i][j]<<" ";
//		cout<<endl;cout<<ill[i]<<"\n";
	}
	for(rint i=1;i<=n;++i)
	{	if(ill[i]) continue;
		for(rint j=i+1;j<=n;++j)
		{	if(ill[j]) continue;
			int fl=1;
			for(rint k=1;k<=n;++k)
			{
				if(vis[i][k]&&vis[j][k]) fl=0;
			}
			ans+=fl;
		}
	}cout<<ans;
	return 0;
}

Measured memory_bytes: 3328
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
abc = []
for _ in range(n):
    abc.append(tuple(li()))
    
happiness = [[0]*(n+1) for _ in range(3)]

for i in range(n):
    a,b,c = abc[i]
    
    happiness[0][i+1] = max(happiness[1][i],
                            happiness[2][i]) + a
             
    happiness[1][i+1] = max(happiness[0][i],
                            happiness[2][i]) + b
             
    happiness[2][i+1] = max(happiness[0][i],
                            happiness[1][i]) + c
             
print(max(happiness[0][-1],
          happiness[1][-1],
          happiness[2][-1]))

Measured memory_bytes: 62428
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define endl "\n";
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	string s;
	cin>>s;
	int sum=0;
	for (int i = 0; i < SZ(s); ++i)
	{
		sum+=s[i]-'0';
	}
	if(sum%9==0){
		cout<<"Yes"<<endl;
	} else cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 3700
// ?????¬???????????¬??????

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

// Dice library
//         ???????????????
//         ??? back ???
//         ???  (5) ???
// ??????????????????????????????????????¬????????????
// ??? left ??? top  ???right ???bottom???
// ???  (4) ???  (1) ???  (2) ???  (3) ???
// ??????????????????????????????????????´????????????
//         ???front ???
//         ???  (0) ???
//         ???????????????
enum Direction {
    NORTH = 0, SOUTH = 1, EAST = 2, WEST = 3, ROT_R = 4, ROT_L = 5,
};

enum View {
    FRONT = 0, TOP = 1, RIGHT = 2, BOTTOM = 3, LEFT = 4, BACK = 5,
};

struct Dice {
    vector<int> value;
    Dice(int front, int top, int right) {
        int sum = 7;
        assert(front + top   != sum);
        assert(top   + right != sum);
        assert(front + right != sum);
        value = {front, top, right, sum-top, sum-right, sum-front};
    }

    void rotate(int dir) {
        vector<int> fnc, swp(6);
        if(dir == NORTH) fnc = {1, 5, 2, 0, 4, 3};
        if(dir == SOUTH) fnc = {3, 0, 2, 5, 4, 1};
        if(dir == EAST ) fnc = {0, 2, 3, 4, 1, 5};
        if(dir == WEST ) fnc = {0, 4, 1, 2, 3, 5};
        if(dir == ROT_R) fnc = {4, 1, 0, 3, 5, 2};
        if(dir == ROT_L) fnc = {2, 1, 5, 3, 0, 4};

        for(int i=0; i<6; i++) swp[ fnc[i] ] = value[i];
        swap(value, swp);
    }

    int get_value(int view) {
        return value[view];
    }
};

signed main() {
    int N;
    vector<string> pat = {"North", "South", "East", "West", "Right", "Left"};
    while(cin >> N, N) {
        Dice dice(2, 1, 3);
        int ans = 1;
        rep(i,0,N) {
            string s; cin >> s;
            int c = 0;
            while(pat[c] != s) c++;
            dice.rotate(c);
            ans += dice.get_value(TOP);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3204
#include <iostream>

typedef long long ll;

using namespace std;

int main(void){
  ll n, k;
  cin >> n >> k;
  ll num = n / k;
  if (k % 2 == 1){
    cout << (num*num*num) << endl;
  }else{
    if (k*(n/k) + k/2 > n){
      cout << (2*num*num*num) << endl;
    }else{
      cout << (num*num*num + (num+1)*(num+1)*(num+1)) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

pub fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

pub fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}

fn main() {
    let (n, m) = read!(usize, usize);
    let s: String = read!(String);
    let t: String = read!(String);

    let sc: Vec<char> = s.chars().collect();
    let tc: Vec<char> = t.chars().collect();

    // good stringが存在するならばその長さの最小はnとmの最小公倍数に等しい（最小公倍数より大きい場合はXの中にSを作るのにもTを作るのにも使われない文字が存在することになるため）

    let lc = lcm(n as u64, m as u64) as usize;

    let mut x_hm = HashMap::new();
    for i in 0..sc.len() {
        x_hm.insert(i * lc / n, sc[i]);
    }
    for j in 0..tc.len() {
        let index = j * lc / m;
        match x_hm.get(&index) {
            Some(&v) => {
                if v != tc[j] {
                    println!("-1");
                    return;
                }
            }
            None => (),
        }
    }

    println!("{}", lc);
}


Measured memory_bytes: 12540
#include <iostream>
#include <cmath>
using namespace std;
int n, a, b, c, l[9], ans=1e9;

void f(int p, int x, int y, int z, int w) {
	if(p>n) return;
	if(x&&y&&z) {
		ans = min(ans, (int)abs(a-x) + (int)abs(b-y) + (int)abs(c-z) + 10*(w-3));
	}
	f(p+1, x+l[p], y, z, w+1);
	f(p+1, x, y+l[p], z, w+1);
	f(p+1, x, y, z+l[p], w+1);
	f(p+1, x, y, z, w);
}

int main() {
	cin>>n>>a>>b>>c;
	for(int i=0; i<n; i++) cin>>l[i];
	f(0, 0, 0, 0, 0);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)
		cin >> a[i];

	vector<int> count(1e6 + 1, 0);

	rep(i, n) {
		//cout << "i=" << i << endl; //確認用
		int j=1;
		if (count[a[i] * j] > 0) {
			count[a[i] * j]++;
			continue;
		}
		while (a[i] * j < 1e6 + 1) {
			count[a[i] * j]++;
			j++;
		}
	}
	int ans = 0;
	rep(i, n) {
		if (count[a[i]] == 1)
			ans++;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8012
#include <stdio.h>
#include <math.h>

int main(void)
{
	int x, max=0, i, j;
	
	scanf("%d" ,&x);
	
	for(i=1; i<=31; i++)
	{
		for(j=2; j<=10; j++)
		{
			if((int)pow(i, j)>x) continue;
			if(max<(int)pow(i, j)) max=(int)pow(i, j);
		}
	}
	printf("%d" ,max);
	return 0;
}

Measured memory_bytes: 128
import sys
import heapq

heap = []

while True:
    input_line = input()
    input_line = input_line.strip().split()

    # print(input_line[0] == "insert")
    if str(input_line[0]) == 'insert':
        heapq.heappush(heap, -int(input_line[1]))
    elif str(input_line[0]) == "extract":
        print(-heapq.heappop(heap))
    else:
        break

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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); ++i)
#define REP(i,start,end) for(int i=(start);i<=(end);++i)
#define all(n) begin(n),end(n)

#define DEBUG

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

	int ans = 0;
	bool flag = true;
	while (flag)
	{
		REP(i, 2, x+1)
		{
			if(i == x)
			{
				flag = false;
				ans = i;
			}
			if(x % i == 0)
			{
				++x;
				break;
			}
		}
	}

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

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

d = [0]* 101
for i in range(n+1):
    i0 = i + 0
    for j in range(2, i0+1):
        while i % j == 0:
            d[j] += 1
            i = i //j

d.sort()
d1 = [i for i in d if i >=2]

def num(m): # e の要素のうち m-1 以上のものの個数
    return len(list(filter(lambda x: x >= m-1, d1)))

print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1) + num(5) * (num(5) - 1) * (num(3) - 2) // 2)


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

struct Team{
    int id;
    int time;
    bool operator<(const Team& other)const{
        return time < other.time;
    }
};

int main(){
    int n, id, m, s, i, j;
    while(cin >> n, n){
        vector< Team > v(n);
        for(i = 0; i < n; i++){
            cin >> id;
            v[i].id = id;
            v[i].time = 0;
            for(j = 4;j--;){
                cin >> m >> s;
                v[i].time += m*60 + s;
            }
        }
        sort(v.begin(), v.end());
        cout << v[0].id << '\n' << v[1].id
             << '\n' << v[n-2].id << endl;
    }
    return 0;
}

Measured memory_bytes: 1252
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

N = I()
adj = [[] for _ in range(N)]
visited = [False for _ in range(N)]
d = [0 for _ in range(N)]
f = [0 for _ in range(N)]
cur_time = 1

for _ in range(N):
    edge_list = LI()
    u, k = edge_list[0], edge_list[1]
    if k == 0:
        continue
    v_list = edge_list[2:]
    u -= 1
    for v in v_list:
        v -= 1
        adj[u].append(v)

def dfs(u):
    global cur_time
    visited[u] = True
    for v in adj[u]:
        if not visited[v]:
            d[v] = cur_time
            cur_time += 1
            dfs(v)
    f[u] = cur_time
    cur_time += 1
    return

for v in range(N):
    if not visited[v]:
        d[v] = cur_time
        cur_time += 1
        dfs(v)

for v in range(N):
    print(v+1, d[v], f[v])





Measured memory_bytes: 9116
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
using ll = long long;

ll comb(ll a) {
	return a * (a - 1) / 2;
}

int main() {
	int N;
	cin >> N;
	vector<ll> A(N);
	vector<bool> ok(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	map<ll, ll> M;
	for (int i = 0; i < N; i++) {
		if (M[A[i]] >= 1) ok[i] = true;
		M[A[i]]++;
	}
	ll s = 0;
	for (int i = 0; i < N; i++) {
		if (ok[i]) continue;
		s += comb(M[A[i]]);
	}
	for (int i = 0; i < N; i++) {
		cout << s - comb(M[A[i]]) + comb(M[A[i]] - 1) << endl;
	}
	return 0;
}

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

using namespace std;

const int MAXN = 20;

char S[MAXN][MAXN];

int matchl[MAXN], use[MAXN];

int n, m;

void check()
{
	memset(use, 0, sizeof(use));
	int cnt = 0;
	for (int i = 1; i <= m; i++)
	{
		if (use[i])
			continue;
		for (int j = i + 1; j <= m; j++)
		{
			bool ch = 1;
			for (int k = 1; k <= n; k++)
			{
				int l = (matchl[k] ? matchl[k] : k);
				ch &= (S[k][i] == S[l][j]);
			}
			if (ch)
			{
				use[i] = use[j] = 1;
				break;
			}
		}
		if (!use[i])
		{
			if (cnt == 0)
			{
				bool ch = 1;
				for (int k = 1; k <= n; k++)
				{
					int l = (matchl[k] ? matchl[k] : k);
					ch &= (S[k][i] == S[l][i]);
				}
				if (ch)
					cnt = 1, use[i] = 1;
				else
					return;
			}
			else
				return;	
		}
	}
	cout << "YES" << endl;
	exit(0);
}

void dfs1(int h)
{
	if (h == n + 1)
	{
		int cnt = 0;
		for (int i = 1; i <= n; i++)
			if (!matchl[i])
				cnt++;
		if (cnt > 1)
			return;
		check();
		return;
	}
	if (matchl[h])
		dfs1(h + 1);
	else
	{
		dfs1(h + 1);
		for (int i = h + 1; i <= n; i++)
		{
			if (matchl[i] == 0)
			{
				matchl[h] = i, matchl[i] = h;
				dfs1(h + 1);
				matchl[h] = 0, matchl[i] = 0;	
			}
		}
	}
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			cin >> S[i][j];
	dfs1(1);
	cout << "NO" << endl;
	return 0;	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#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             998244353
#define inf             1e18
#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 FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


int pwmd(int a, int n = mod - 2)
{
	if (!n)
		return 1;
	int pt = pwmd(a, n / 2);
	pt *= pt, pt %= mod;
	if (n & 1)
		pt *= a, pt %= mod;
	return pt;
}

int fct[200001];
int inv[200001];

int nCr(int n, int r)
{
	int ans = fct[n];
	int den = (inv[r] * inv[n - r]) % mod;

	ans = (ans * den) % mod;

	return ans;
}

int32_t main()
{
	FIO;
	fct[0] = inv[0] = 1;

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

	for (int i = 1; i <= n; ++i)
	{
		fct[i] = (fct[i - 1] * i) % mod;
		inv[i] = pwmd(fct[i]);
	}

	int ans = 0;

	for (int i = 0; i <= k; ++i)
	{
		int cur = (m * nCr(n - 1, i)) % mod;

		cur = (cur * pwmd(m - 1, n - 1 - i)) % mod;

		ans += cur;
		ans %= mod;
	}

	cout << ans << '\n';


	return 0;
}

Measured memory_bytes: 6664
package main

import (
	"fmt"
)

func main() {
	var s, t string
	fmt.Scan(&s)
	fmt.Scan(&t)
	bs := []byte(s)
	bt := []byte(t)
	//fmt.Println(bt)
	var count int
	count = 0

	/*
		for i, _ := range s {
			ss = append(ss, string(s[i]))
		}
		for i, _ := range t {
			st = append(st, string(t[i]))
		}
	*/

	for i, _ := range bs {
		if bs[i] != bt[i] {
			count++
		}
	}
	fmt.Println(count)
	//fmt.Println(ss)
}

// sをtに変える: 二重ループでもじ判定して書き換えた回数分カウント変数


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

using namespace std;

int main()
{
    int n,c=0;
    string s;
    cin>>n>>s;
    for(int i=0;i<n-2;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
           c++;
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
// Remeber Choose Compiler: GCC9
#include <bits/stdc++.h>

using namespace std;

// Debug Output Utility
#ifdef LOCAL
#define dbg(args...)             \
    do {                         \
        cout << #args << " -> "; \
        err(args);               \
    } while (0)
void err() { std::cout << std::endl; }
template <typename T, typename... Args>
void err(T a, Args... args) {
    std::cout << a << ' ';
    err(args...);
}
template <template <typename...> class T, typename t, typename... A>
void err(const T<t> &arg, const A &... args) {
    for (auto &v : arg)
        std::cout << v << ' ';
    err(args...);
}
#else
#define dbg(...)
#endif

// Macro Definitions:
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

// Type Alias:
using int64 = long long;
using PII   = pair<int, int>;

// Global Const Variable
const int64 INF = 0x3f3f3f3f3f3f3f3f;
const int MOD   = 1000000007;
const int MAXN  = 200005;

int64 a[MAXN];

void run() {
    int n;
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    int64 ans = 1000;
    for(int i=2;i<=n;i++) {
        if(a[i]>a[i-1]) {
            ans = ans%a[i-1] + ans/a[i-1]*a[i];
        }
    }
    cout << ans << endl;
}

// Debug Input Redirection
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    run();
}


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

int main(void){
    
    int n;
    cin >> n;
    std::vector<unsigned long long> data(n);
    for(int i=0; i<n; i++) cin >> data[i];
    
    unsigned long long result = 0;
    for(int i=0; i<n; i++) {
        while(data[i]%2 == 0) {
            data[i] /= 2;
            result++;
        }
    }


    cout << result << endl;

    
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
    int i,n,j,cnt=0;
    cin>>n;
    char s[n];
    cin>>s;
    for(i=0;i<n;i++)
    {
        if(s[i]=='A')
        {
            j=i;
            if(s[j+1]=='B'&&s[j+2]=='C')
            {
                cnt++;
            }
        }

    }
    cout<<cnt;

    return 0;
}


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

def main():
    l = [e for e in input()]
    cnt = 0
    last = ''
    for c in l:
        if c == last:
            cnt+=1
        else:
            cnt = 0
        if cnt == 2:
            print("Yes")
            break
        last = c
    else:
        print("No")

main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  if ((n & -n) == n) return puts("No"), 0;
  printf("Yes\n1 2\n2 3\n3 %d\n%d %d\n%d %d\n", n + 1, n + 1, n + 2, n + 2, n + 3);
  for (int i = 5; i <= n; i += 2) printf("1 %d\n%d %d\n1 %d\n%d %d\n", i - 1, i - 1, i + n, i, i, i - 1 + n);
  if (!(n & 1)) printf("%d %d\n%d %d\n", n, n & -n, n + n, (n & -n) ^ n ^ 1);
}


Measured memory_bytes: 2304
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define inf INT_MAX
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

lint dx[8] = { 0,1,1,1,0,-1,-1,-1 },
dy[8] = { 1,1,0,-1,-1,-1,0,1 };

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


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

	lint n, in; cin >> n;
	vector<int> a;
	rep(i, n) {
		cin >> in;
		a.push_back(in);
	}
	lint p = 0, ctr = 0;
	while (p < n - 2) {
		if (a[p] == a[p + 1]) {
			if (a[p] == 1) {
				if (a[p + 2] == 2)a[p + 1] = 3;
				else a[p + 1] = 2;
			}
			else if (a[p] == 2) {
				if (a[p + 2] == 1)a[p + 1] = 3;
				else a[p + 1] = 1;
			}
			else a[p + 1] = 1;
			p++; ctr++;
		}
		p++;
	}
	if (a[siz(a) - 1] == a[siz(a) - 2]) {
		ctr++;
	}
	co(ctr);
	gc();
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
-- import Data.List
import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: Int -> Int -> [Int] -> [Int] -> [Int]
solve bN bQ as qs = map solveOne qs where

  vA = VU.reverse $ VU.fromListN bN as
  vASum = VU.postscanl' (+) 0 vA
  vAEven = VU.postscanl' (+) 0 (VU.ifilter (\i _ -> even i) vA)

  lX = (bN-1) `div` 2
  vX = VU.fromListN lX
         [((vA VU.! (i+1)) + (vA VU.! (2*(i+1)))) `div` 2 | i <- [0 .. lX-1]]

  solveOne q = ans where

    i0 = binsch (bsJ q) (-1) lX
    bsJ q i = vX VU.! i < q
    ans = vASum VU.! i0 + vAEven VU.! (VU.length vAEven - 1) - vAEven VU.! i0
  
binsch f lo hi | hi == lo + 1 = hi
               | f mid        = binsch f lo mid
               | otherwise    = binsch f mid hi
  where mid = (lo + hi) `div` 2

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> [Int]
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_n,bs_q]:remLines1 = remLines0
      n = readBInt bs_n
      q = readBInt bs_q
      line2:remLines2 = remLines1
      as = map readBInt line2
      qs = map (\[x] -> readBInt x) remLines2
  in solve n q as qs

outAnswer :: [Int] -> IO ()
outAnswer xs = putStr (unlines (map show xs))

main :: IO ()
main = outAnswer . tmain =<< B.getContents

-------------------------------------------------------------------------------

inp1 = "5 5\n3 5 7 11 13\n1\n4\n9\n10\n13\n"
inp2 = "4 3\n10 20 30 40\n2\n34\n34\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2


Measured memory_bytes: 11436
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);


int g[15][15];
const int INF = 1001001001;
const int di[] = { -1,0,1,0 };
const int dj[] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int main() {
	int a, b;
	cin >> a >> b;
	int ans = 0;
	for (int i = 0;i <= a;++i) {
		for (int j = 0;j <= a;++j) {
			if (0 <= b - i - j && b - i - j <= a) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {

  int a, b, c;
  
  scanf("%d""%d""%d", &a, &b, &c);
  
  int Max = a;
  
  if(b > Max)
    Max = b;
    
  if(c > Max)
    Max = c;
    
  printf("%d", a + b + c - Max);
  
  return 0;
  
}


Measured memory_bytes: 128
#include <iostream>

int main(){
  int x;
  int i = 1;
  while(1){
    std::cin >> x;
    if(x==0){
      break;
    } else{
      std::cout << "Case " << i << ": " << x << std::endl;
      i++;
    }
  }
  
  return 0;
}

Measured memory_bytes: 2960
#include <stdio.h>
#include <bits/stdc++.h>
#include <algorithm>
#include <cassert>

using namespace std;

// bool get_answer(array<int,3> &ans, int target){
//     while(ans[0]*500 > target){
//         ans[0]--;
//     }
//     target -= ans[0]*500;
//     while(ans[1]*100 > target){
//         ans[1]--;
//     }
//     target -= ans[1]*100;
//     while(ans[2]*50 > target){
//         ans[2]--;
//     }
//     target -= ans[2]*50;
//     return (target == 0);

// }

int solve(int N, int M, vector<int> A){
    int ans = N;
    for(auto a:A){
        ans -= a;
    }
    if(ans<0){
        ans = -1;
    }
    cout << ans << "\n";
    return ans;
}

// class input{
//     public:
//     input(int _A, int _B, int _C, int _X, int _ans){
//         A = _A;
//         B = _B;
//         C = _C;
//         X = _X;
//         ans = _ans;
//     }
//     int A;
//     int B;
//     int C;
//     int X;
//     int ans;
// };

// int solve(input key){
//     return solve(key.A, key.B, key.C, key.X);
// }

int main(){
    int N, M;
    vector<int> A;
    bool use_stdin = true;
    // use_stdin = false;
    if(use_stdin){    
        cin >> N >> M;
        for (size_t i = 0; i < M; i++)
        {
            int buf;
            cin >> buf;
            A.push_back(buf);
        }
        
        solve(N, M, A);
    }else{
        // input keys[] = {
        //     {30,40,50,6000,213},
        //     {5,1,0,150,0},
        //     {2,2,2,100,2}
        // };
        // for(auto key:keys){
        //     assert(solve(key)==key.ans);
        // }
    }
    return 0;
}

Measured memory_bytes: 3632
import os
import sys

import numpy as np


def solve(n, precalc_x, precalc_y):
    ans = np.full(n + 1, 10 ** 18, dtype=np.int64)

    def get_cost(v, bit):
        cost = 0
        pcx = precalc_x[v]
        pcy = precalc_y[v ^ bit]
        for i in range(n):
            cost += min(pcx[i], pcy[i])
        return cost

    for bit in range(1 << n):
        k = (bit & 0x5555) + (bit >> 1 & 0x5555)
        k = (k & 0x3333) + (k >> 2 & 0x3333)
        k = (k & 0x0f0f) + (k >> 4 & 0x0f0f)
        k = (k & 0x00ff) + (k >> 8 & 0x00ff)
        v = bit
        while v:
            ans[k] = min(ans[k], get_cost(v, bit))
            v = (v - 1) & bit
        ans[k] = min(ans[k], get_cost(0, bit))

    return ans


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8, i8[:,:], i8[:,:])')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    # noinspection PyUnresolvedReferences
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8, i8[:,:], i8[:,:])', cache=True)(solve)
    print('compiled', file=sys.stderr)

inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
n = inp[0]
xxx = inp[1::3]
yyy = inp[2::3]
ppp = inp[3::3]

bit_d = (((np.arange(1 << n)[:, None] & (1 << np.arange(n)))) > 0).astype(np.int64)
precalc_x = abs((xxx[None, :] * bit_d)[..., None] - xxx[None, None, :]).min(axis=1) * ppp[None, :]
precalc_y = abs((yyy[None, :] * bit_d)[..., None] - yyy[None, None, :]).min(axis=1) * ppp[None, :]

ans = solve(n, precalc_x, precalc_y)
print('\n'.join(map(str, ans)))


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
ll n, m;
vll a;
vector<pair<ll, ll>> bc;
map<ll, ll> mp;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  bc.resize(m);
  for (int i = 0; i < m; i++) cin >> bc[i].first >> bc[i].second;
  for (int i = 0; i < n; i++) mp[-a[i]]++;
  for (auto &v : bc) mp[-v.second] += v.first;
  ll sum = 0, c = 0;
  for (auto &v: mp) {
    sum -= v.first * min(n - c, v.second);
    c += min(n - c, v.second);
  }
  cout << sum << endl;

  return 0;
}


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

int main () {
  long N;
  cin >> N;
  for (int i = sqrt(N); i > 0; i-- ) {
    if( N % i == 0) {
      cout << N / i + i - 2 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>

using namespace std;

struct Node
{
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *z;

  z=(Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL)
    {
      y=x;
      if(z->key < x->key)
	{
	  x = x->left;
	}
      else
	{
	  x = x->right;
	}
    }

  z->parent = y;

  if(y == NIL)
    {
      root=z;
    }
  else
    {
      if(z->key < y->key)
	{
	  y->left = z;
	}
      else
	{
	  y->right = z;
	}
    }
}


void inoder(Node *u){
  if(u == NIL)
    return;
  inoder(u->left);
  printf(" %d", u->key);
  inoder(u->right);
}

void preoder(Node *u){
  if(u == NIL)
    return;
  printf(" %d", u->key);
  preoder(u->left);
  preoder(u->right);
}

int main(){
  int n, i, x;
  string com;

  scanf("%d", &n);

  for(i=0; i<n; i++)
    {
      cin >> com;
      if(com == "insert")
	{
	  scanf("%d", &x);
	  insert(x);
	}
      else if(com == "print")
	{
	  inoder(root);
	  printf("\n");
	  preoder(root);
	  printf("\n");
	}
    }

  return 0;
}



Measured memory_bytes: 26692
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>
#include <set>

using namespace std;

#define ALL(co) co.begin(), co.end()

typedef long long LL;
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> Array;
typedef vector<int> LArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

int itiv;
inline int getInt() { return (cin >> itiv, itiv); }
void readAll(Array& vec, int n) { for (int i = 0; i < n; i++) cin >> vec[i]; }
inline bool between(int first, int last, int n) { return first <= n && n <= last; }
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

int m, n;
int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
int dr[] = { 0, -1, 0, 1 }, dc[] = { -1, 0, 1, 0 };


int main(void)
{
	while(cin >> m && m)
	{
		vector<P> goal;
		int sx = getInt(), sy = getInt();
		goal.push_back(P(0, 0));
		for (int i = 0; i < m - 1; i++)
		{
			int x = getInt() - sx, y = getInt() - sy;
			goal.push_back(P(x, y));
		}

		set<P> stars;
		cin >> n;
		for (int i = 0; i < n; i++)
		{
			int x, y; cin >> x >> y;
			stars.insert(P(x, y));
		}

		P ans;
		for (set<P>::iterator it = stars.begin(); it != stars.end(); it++)
		{
			P p = *it;
			bool flag = true;
			for (int j = 0; j < m; j++)
			{
				int nx = p.first + goal[j].first, ny = p.second + goal[j].second;
				if(!stars.count(P(nx, ny)))
				{
					flag = false;
					break;
				}
			}
			if(flag)
			{
				ans = p;
				break;
			}
		}
		cout << ans.first - sx << ' ' << ans.second - sy << endl;
	}
	return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
#define ld long double
int main(){
    int n;
    cin>>n;
    int64_t sum=0;
    vector<int64_t> a(n);
    rep(i,n){
        cin>>a[i];
        sum += a[i];
    }
    all(a);
    if(n==2){
        cout<<a[1]-a[0]<<endl;
        cout<<a[1]<<" "<<a[0]<<endl;
        return 0;
    }

    //a1+a2+a3+.....+anの中から「1個以上n-1個未満」マイナスにする
    if(a[0]>0){//1個目だけ-にする
        int64_t ans = sum-2*a[0];
        cout<<ans<<endl;
        int halfway=a[0];
        rep(i,n-1){
            if(i==n-2){
                cout<<a[i+1]<<" "<<halfway<<endl;
            }
            else{
                cout<<halfway<<" "<<a[i+1]<<endl;
                halfway -= a[i+1];
            }
        }
    }
    else if(a[n-1]<=0){//a[n-1]以外全部マイナスにする
        int64_t ans = -sum + 2*a[n-1];
        cout<<ans<<endl;
        int halfway = a[n-1];
        rep(i,n-1){
            cout<<halfway<<" "<<a[i]<<endl;
            halfway -= a[i];
        }
    }
    else{//正の数なら+に、負の数ならマイナスにする
        int64_t ans=0;
        rep(i,n){
            ans += abs(a[i]);
        }
        cout<<ans<<endl;
        int halfway = a[0];
        rep(i,n){
            if(a[i]>0 && i!=n-1){
                cout<<halfway<<" "<<a[i]<<endl;
                halfway -= a[i];
            }
        }
        int plushalf = a[n-1];
        rep(i,n){
            if(i!=0 && a[i]<=0){
                cout<<plushalf<<" "<<a[i]<<endl;
                plushalf -= a[i];
            }
        }
        cout<<plushalf<<" "<<halfway<<endl;
    }
}

Measured memory_bytes: 4052
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに実装したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			System.out.println(IntStream.rangeClosed(1, n).mapToLong(i -> {
				int y = n / i;
				return i * (long) y * (y + 1) / 2;
			}).sum());
		}
	}
}


Measured memory_bytes: 36764
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<math.h>

using namespace std;

int pow_10(int n) {
	int x = 1;
	for (int i = 0; i < n; i++) {
		x *= 10;
	}
	return x;
}

int main() {
	int N;
	cin >> N;
	int num = 1;
	int x = 10;
	while (true) {
		if (N >= x / 10 && N < x) { break; }
		x *= 10;
		num++;
	}
	int ans = 0;
	if (num % 2 == 1) {
		if (num == 1) {
			ans += N;
		}
		else {
			ans += N - pow_10(num - 1) + 1;
		}
	}
	for (int i = 1; i < num; i++) {
		if (i % 2 == 1) {
			ans += pow_10(i) - pow_10(i - 1);
		}
		N /= 10;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void){
    int x, y;


    while(1){

        scanf("%d %d", &x, &y);
        if(x == 0 && y == 0) break;
        if(x > y){
            printf("%d %d\n", y, x);
        } else {
            printf("%d %d\n", x, y);
        }
        
    }

    return 0;

}


Measured memory_bytes: 2032
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
typedef long long ll;
const int INF = 1<<30, mod = 1000000007;
const double pi = 3.14159265;
const ll LLINF = 1LL << 50;
using namespace std;


int main() {
    int n, q, k;
    vector<int> a(2005);
    cin >> n >> k >> q;
    for (int i = 0; i < n; ++i) cin >> a[i];
    int ans = INF;
    for (int i = 0; i < n; i++) {
        vector<int>t, tt;
        for (int j = 0; j <= n; j++) {
            if (j == n || a[j] < a[i]) {
                sort(t.begin(), t.end());
                if (t.size() >= k)tt.insert(tt.end(), t.begin(), t.end() - k + 1);
                t.clear();
            }
            else t.push_back(a[j]);
        }
        sort(tt.begin(), tt.end());
        if (tt.size() >= q)ans = min(ans, tt[q - 1] - a[i]);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


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


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
# sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def divisor(n):
    ret = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ret.append(i)
            if n // i != i:
                ret.append(n // i)
    return ret


def f(A, B):
    return max(len(str(A)), len(str(B)))


def main():
    N = I()
    ans = 10**9

    for i in divisor(N):
        ans = min(ans, f(N // i, i))

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

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

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

    // うまく並び替えることで、+の数と-の数は任意にできる
    // ただし1個以上、プラスもしくはマイナスを選ぶ必要がある

    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++){
      cin >> A[i];
    }

    // 理想的には絶対値の和になるが、全てがマイナスのとき、もしくはプラスのときは
    // それらで一番影響の少ないものを選ぶ

    // えらびかた
    // 基本的には、マイナスから一個選んで、プラスを引いていって、
    // それを最後

    sort(A.begin(), A.end());
    
    ll ans = 0;
    vector<pair<ll, ll>> op;
    if(A[0] >= 0){ // 全部正のとき{
      if(N > 2){
        // 最小値から
        for(int i = 0; i < N; i++){
          ans += A[i];
        }
        ans -= 2 * A[0];

        ll tmp = A[0] - A[1];
        op.push_back(make_pair(A[0], A[1]));
        for(int i = 2; i < N-1; i++){
          op.push_back(make_pair(tmp, A[i]));
          tmp = tmp - A[i];
        }
          op.push_back(make_pair(A[N-1], tmp)); 
      }else{
        ans = A[1] - A[0];
        op.push_back(make_pair(A[1],A[0]));
      }


    }else if(A[N-1] < 0){//全部負のとき

      for(int i = 0; i < N; i++){
        ans += abs(A[i]);
      }

      ans -= 2 * abs(A[N-1]);
      
      ll tmp = A[N-1] - A[N-2];
      op.push_back(make_pair(A[N-1], A[N-2]));
      for(int i = N-3; i>= 0; i--){
        op.push_back(make_pair(tmp, A[i]));
        tmp = tmp - A[i];
      }
    }else{

      for(int i = 0; i < N; i++){
        ans += abs(A[i]);
      }

      // まずマイナスから一つ選んで、
      ll tmp = A[0];
      for(int i = 0; i < N-1; i++){
        if(A[i] >= 0){
          op.push_back(make_pair(tmp, A[i]));
          tmp = tmp - A[i];
        }
      }

      // 最後に
      op.push_back(make_pair(A[N-1], tmp));
      tmp = A[N-1] - tmp;

      for(int i = 1; i < N; i++){
        if(A[i] < 0){
          op.push_back(make_pair(tmp, A[i]));
          tmp = tmp - A[i];
        }
      }
    }

    cout << ans << endl;
    for(int i = 0; i < op.size(); i++){
      cout << op[i].first << " " << op[i].second << endl;
    }

    return 0;
}



Measured memory_bytes: 4336
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
						 {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

int main() {
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if((a<=c&&c<=b)||(b<=c&&c<=a)){
		printf("Yes");
	}else{
		printf("No");
	}
	
	
	
	
	/* --------------------------------- */
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

    int k,s;
    int cnt = 0;
    cin >> k >> s;

    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            int l = s-i-j;
            if(0<=l && l<=k) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Y = sc.nextInt();
		for(int a=0;a<=N;a++) {
			if(a*10000>Y) {
				break;
			}
			for(int b=0;b<=N;b++) {
				if((a*10000)+(b*5000)>Y) {
					break;
				}
					int c = N-(a+b);
					int sum = (10000*a)+(5000*b)+(1000*c);
					if(sum==Y) {
						System.out.println(a+" "+b+" "+c);
						System.exit(0);
					}
			}
		}
		System.out.print("-1 "+"-1 "+"-1");
	}
}

Measured memory_bytes: 23892
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int main(int argc,char* argv[]){
  int a=1,b=1,x,n;
  cin>>n;
  if(n==1)
    cout<<1<<endl;
  else{
    for(int i=2;i<=n;i++){
      x=a+b;
      a=b;
      b=x;
    }
    cout<<x<<endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}


// end of Template
int n,m;
vi adj[250000];
bool vis[250000];
void bfs(){
    queue <pii> q;
    q.push(mp(1,0));
    while(!q.empty()){
        int node = q.front().fi;
        int steps = q.front().se;
        q.pop();
        if(steps>2)break;
        if(!vis[node]){
            vis[node]=true;
            for(int i=0;i<adj[node].size();i++){
                q.push(mp(adj[node][i],steps+1));
            }
        }
    }
}
int main(){

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int a,b; cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    bfs();
    if(vis[n])cout<<"POSSIBLE\n";
    else cout<<"IMPOSSIBLE\n";
}


Measured memory_bytes: 14704
#include<stdio.h>
int main(void)
{
	int i,j,n,m,a,b,x,z,t[1000];
	scanf("%d %d %d",&n,&a,&b);
	for(i=1;i<=n;i++){
		scanf("%d",&t[i]);
	}
	for(i=1;i<=n;i++){
		for(j=i+1;j<=n;j++){
			if(t[i]>t[j]){
				m=t[i];
				t[i]=t[j];
				t[j]=m;
			}
		}
	}
	x=0;
	z=0;
	for(i=1;i<=n;i++){
		if(a>t[i] && z==0){
			x++;
		}
		if(a<=t[i] && z==0){
			z=1;
		}
		if(b<=t[i] && z==1){
			x++;
		}
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 128