akhauriyash/Code-Regression huggingface dataset:
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
bool L(int n)
{
	for(int i=2;i*i<=n;++i)
	{
		if(!(n%i))
		{
			return false;
		}
	}
	return true;
}
int a;
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>a;
	for(int i=a;true;++i)
	{
		if(L(i))
		{
			cout<<i;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
#include <utility>
#include <string>
#include <queue>
#include <cmath>
#include <array>

typedef long long ll;

int main(int argc, char *argv[])
{
    int n;
    ll ans = 0;

    std::cin >> n;

    for (int j = 1; j <= n; j++) {
        for (int i = j; i <= n; i += j) {
            ans += i;
        }
    }

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

    return 0;
}

Measured memory_bytes: 3628
H, W, M, *hw = map(int, open(0).read().split())
H_cnt = [0] * (H + 1)
W_cnt = [0] * (W + 1)
bombs = [(h, w) for h, w in zip(*[iter(hw)] * 2)]
for h, w in bombs:
    H_cnt[h] += 1
    W_cnt[w] += 1

H_max_cnt = max(H_cnt)
W_max_cnt = max(W_cnt)

H_max = {i for i in range(1, H + 1) if H_cnt[i] == H_max_cnt}
W_max = {i for i in range(1, W + 1) if W_cnt[i] == W_max_cnt}

comb_cnt = len(H_max) * len(W_max)
for h, w in bombs:
    if H_cnt[h] == H_max_cnt and W_cnt[w] == W_max_cnt:
        comb_cnt -= 1

ans = H_max_cnt + W_max_cnt
print(ans if comb_cnt else ans - 1)


Measured memory_bytes: 101032
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>

using namespace std;

int main() {
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		int in;
		cin >> in;
		a[i] = in;
	}
	long long num = 0;
	int ans = 0;

	std::sort(a.begin(), a.end(), [](const int &i, const int&j) {return i < j;});

	for (int i = 0; i < n; i++) {
		num += a[i];
		ans++;
		if (num >= x)break;
	}

	if (num != x)ans--;

	cout << ans << endl;

	return 0;
}

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

int main() {
    string a, b;

    cin >> a >> b;

    if (a.size() > b.size()) {
        cout << "GREATER" << endl;
    }
    else if (a.size() < b.size()) {
        cout << "LESS" << endl;
    }
    else {
        if (a > b) cout << "GREATER" << endl;
        else if (b > a) cout << "LESS" << endl;
        else cout << "EQUAL" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
mapp = ['.' * (W + 2)]
for _ in range(H):
    mapp += ['.%s.' % input()]
mapp += ['.' * (W + 2)]

dh = [-1, -1, -1, 0, 0, 1, 1, 1]
dw = [-1, 0, 1, -1, 1, -1, 0, 1]
for h in range(1, H + 1):
    line = ''
    for w in range(1, W + 1):
        if mapp[h][w] == '#':
            line += '#'
            continue

        line += str(sum(mapp[h + dhi][w + dwi] == '#' for dhi, dwi in zip(dh, dw)))
    print(line)

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner (System.in);
	int n=sc.nextInt();
	int m=sc.nextInt();
	int a[]=new int[m];
	int d[]=new int[m-1];
	for(int i=0;i<m;i++) {
		a[i]=sc.nextInt();
	}
	Arrays.sort(a);
	for(int i=0;i<m-1;i++) {
		d[i]=a[i+1]-a[i];
	}
	Arrays.sort(d);
	int ans=0;
	for(int i=0;i<m-n;i++) {
		ans+=d[i];
	}
	System.out.println(ans);
	}
}


Measured memory_bytes: 51148
#include <iostream>
#include <cmath>

using namespace std;

long long N;
long long a[3000];

int main(){
    long long m = 0;
    cin >> N;
    for(int i=0;i<N;i++) cin >> a[i];
    for(int i=0;i<N;i++){
        m += (a[i]-1);
    }
    cout << m << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FORD(i, n, 0)

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

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007;

ll aabs(ll a) {
	if(a  >= 0) {
		return a;
	} else {
		return -a;
	}
}

ll max(ll a, ll b) {
	if (a > b) {
		return a;
	}
	return b;
}

int main() {
    ll a,b;
    cin >> a >> b;
	ll ans;

	ans = max(max(a+b, a-b), a*b);

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

ll dp[2510][50];
int m = 1252;

int main() {
    int n, a;
    cin >> n >> a;
    VI x(n);
    REP(i,n) cin >> x[i];
    REP(i,n) x[i] -= a;

    dp[x[0]+m][0]++;
    dp[m][0]++;
    FOR(i,1,n-1){
        FOR(j,50,2450){
            dp[j][i] += dp[j][i-1];
            dp[j+x[i]][i] += dp[j][i-1];
        }
    }

    cout << dp[m][n-1]-1 << endl;


    return 0;
}


Measured memory_bytes: 1152
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(ll i=(x);i<(y);i++)
#define RREP(i,x,y) for(ll i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

struct Point {
    int x, y;
    Point(){};
    Point(int x, int y) : x(x), y(y) {};
};

class C2DPlane2NPoints {
public:
    void solve(std::istream& in, std::ostream& out) {
        int N;
        in >> N;
        vector<Point> red(N), blue(N);
        REP(i,0,N) {
            in >> red[i].x >> red[i].y;
        }
        REP(i,0,N) {
            in >> blue[i].x >> blue[i].y;
        }
        sort(all(red), [](const Point& a, const Point& b) {
            return a.x < b.x || a.x == b.x && a.y <= b.y;
        });
        sort(all(blue),[](const Point& a, const Point& b) {
            return a.x < b.x || a.x == b.x && a.y <= b.y;
        });
        int answer = 0;
        vector<bool> redIsUsed(N, false);
        REP(j,0,N) { // blue
            int candidate = -1;
            REP(i,0,N) { // red
                if (red[i].x >= blue[j].x) break;
                if (!redIsUsed[i] && red[i].x < blue[j].x && red[i].y < blue[j].y) {
                    if ((candidate != -1 && red[candidate].y < red[i].y) || candidate == -1) {
                        candidate = i;
                    }
                }
            }
            if (candidate != -1) {
                redIsUsed[candidate] = true;
                answer++;
            }
        }
        out << answer << "\n";
    }
};


signed main() {
    C2DPlane2NPoints solver;
    std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] S = sc.nextLine().split(" ");
    int[] nums = new int[N];
    int sum = 0;
    for(int i = 0; i < N; i++){
      nums[i] = Integer.parseInt(S[i]);
      sum += nums[i];
    }
    
    int ans = 0;
    double d = (double)sum/N;
    int ave = (int)Math.round(d);
    for(int i = 0; i < N; i++){
      ans += (int)Math.pow(nums[i]-ave, 2);
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23764
import heapq
from collections import defaultdict
n, m= [int(i) for i in input().split()]
a = [(-int(i), -int(i)) for i in input().split()]
heapq.heapify(a)

for _ in range(m):
  n, r = heapq.heappop(a)
  rnew = float(r)/2
  nnew = -1 * (-1 * r // 2) 
  heapq.heappush(a, (nnew, rnew))

ans = 0
for an, ar in a:
  ans += -1 * an
print(int(ans))

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

int main() {
  int N,K,count=0;
  cin >> N >> K;
  vector<int> H(N);
  
  for(int i=0; i<N; i++) {
    cin >> H[i];
    if(H[i]>=K) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3764
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <numeric>

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

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

int main() {
    int n;
    while(cin >> n, n){
        vector<int> v(n);
        for (auto &&i : v) scanf("%d", &i);
        int s = accumulate(v.begin(), v.end(), 0);
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            if(v[i]*n <= s) ans++;
        }
        cout << ans << "\n";
    }
    return 0;
}



Measured memory_bytes: 3252
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (long long i = (a); i < (n); i++)
#define REP(i, n) for(long long i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
using namespace std;

typedef long long ll;

long long Mygcd(long long a, long long b)
{
	if (a % b == 0)return b;
	return Mygcd(b, a % b);
}

int Mygcd(int a, int b)
{
	if (a % b == 0)return b;
	return Mygcd(b, a % b);
}

long long Mylcm(long long a, long long b)
{
	return a * b / Mygcd(a, b);
}

int Mylcm(int a, int b)
{
	return a * b / Mygcd(a, b);
}

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

	int N,ans;

	cin >> N;
	ans = 0;

	FOR(i,1,N+1)
	{
		FOR(j, 1, N + 1)
		{
			FOR(k, 1, N + 1)
			{
				ans += Mygcd(Mygcd(i, j), k);
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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


using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)



int main() {

    ll n; cin >> n;
    vector<ll> h(n);
    rep(i, n) {
        cin >> h[i];
    }


    // しょっぱな下げとく
    ll prev = h[0]-1;
    for(ll i=1; i < n; i++) {
        if(h[i] > prev) {
            prev = h[i]-1;
        } else if(h[i] == prev) {
            prev = h[i];
        } else {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;

}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
    long long n,i,s=1,ma=0;;
    cin>>n;
    long long m[n];
    for(i=0;i<n;i++)
    {
        cin>>m[i];
    }
    long long dp[n];
    dp[0]=1;
    for(i=1;i<n;i++)
    {
        if(m[i]<=m[i-1])
        {
            dp[i]=dp[i-1]+1;
        }
        else
        {
            dp[i]=1;
        }
    }
    for(i=0;i<n;i++)
    {
        ma=max(ma,dp[i]);
    }
    cout<<ma-1<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ep emplace_back

using namespace std;

const int  mod = 1e9 + 7;
const int e = 2000 + 69;
const int base = 311;

ll dp[e][e];

int main()
{
    ll n;
    cin >> n;
    vector<pair<ll, int>> a;
    for(int i=1; i<=n; i++)
    {
        int x;
        cin >> x;
        a.ep(x, i);
    }
    sort(a.rbegin(), a.rend());
    ll ans = 0;
    for(int i=0; i<n; i++)
    {
        for(int le=0; le<=i+1; le++)
        {
            int ri = i - le + 1;
            int dist = n - ri +1 ;
            if(le > 0)
            {
                dp[le][ri] = max(dp[le][ri], dp[le-1][ri] + a[i].first*abs(a[i].second - le));
                ans = max(ans, dp[le][ri]);
            }
            if(ri > 0)
            {
                dp[le][ri] = max(dp[le][ri], dp[le][ri-1] + a[i].first*abs(a[i].second - dist));
                ans = max(ans, dp[le][ri]);
            }
        }
    }
    cout << ans ;
}


Measured memory_bytes: 26544
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];


int prim() {
	int u, minv;
	int d[MAX], p[MAX], color[MAX];

	for (int i = 0; i < n; i++) {
		d[i] = INFTY;
		p[i] = -1;
		color[i] = WHITE;
	}

	d[0] = 0;

	while (1) {
		minv = INFTY;
		u = -1;
		for (int i = 0; i < n; i++) {
			if (minv > d[i] && color[i] != BLACK) {
				u = i;
				minv = d[i];
			}
		}
		if (u == -1)break;
		color[u] = BLACK;
		for (int v = 0; v < n; v++) {
			if (color[v] != BLACK && M[u][v] != INFTY) {
				if (d[v] > M[u][v]) {
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}

	}
	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (p[i] != -1)sum += M[i][p[i]];
	}

	return sum;
}


int main() {
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int e; cin >> e;
			M[i][j] = (e == -1) ? INFTY : e;

		}
	}
	cout << prim() << endl;

	return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;


#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	long double a, b, c;
	cin >> a >> b >> c;
	long double eps = 1.0E-15;
	if (sqrt(a) + sqrt(b) + eps < sqrt(c))  cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;

}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<vector<int>> A(2, vector<int>(N));
	int i, j;
	for(i = 0; i < 2; i++) {
		for(j = 0; j < N; j++) {
			cin >> A[i][j];
		}
	}
	pair<int, int> location(0, 0);
	int result = 0, max = 0;
	for(i = 0; i < N; i++) {
		for(j = 0; j < i; j++) {
			result += A[location.first][location.second];
			location.second++;
		}
		result += A[location.first][location.second];
		location.first++;
		while(location.second < N) {
			result += A[location.first][location.second];
			location.second++;
		}
		if(max < result) max = result;
		result = 0;
		location.first = 0;
		location.second = 0;
	}
	cout << max << endl;
}


Measured memory_bytes: 768
# coding: utf-8
# Your code here!
N=int(input())

A=[]
B=[]
C=[]
for _ in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
    C.append(a+b)

s_A=sum(A)
s_B=sum(B)
C.sort(reverse=True)

ans=s_A
for i in range(N)[1::2]:
    ans-=C[i]

print(ans)



Measured memory_bytes: 15404
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;

int A, B, Q;
int mod = 1e9 + 7;

long long inf = 1e18;
 

int main() {
    cin >> A >> B >> Q;
    vector<long long> s(A), t(B);
    for (int i = 0; i < A; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < B; i++) {
        cin >> t[i];
    }
    for (int i = 0; i < Q; i++) {
        long long x; cin >> x;
        auto itrS = lower_bound(s.begin(), s.end(), x);
        auto itrT = lower_bound(t.begin(), t.end(), x);
        long long leftS, rightS, leftT, rightT;
        if (itrS == s.end()) {
            rightS = inf;
        } else {
            rightS = *itrS;
        }
        if (itrT == t.end()) {
            rightT = inf;
        } else {
            rightT = *itrT;
        }
        if (itrS == s.begin()) {
            leftS = -inf;
        } else {
            leftS = *(itrS - 1);
        }
        if (itrT == t.begin()) {
            leftT = -inf;
        } else {
            leftT = *(itrT - 1);
        }
        rightT -= x; rightS -= x; leftS = x - leftS; leftT = x - leftT;
     //   cout << rightT << " " << rightS << " " << leftS  << " " <<  leftT << endl;
        long long turn = min(min(rightS * 2 + leftT, leftS * 2 + rightT), min(rightT * 2 + leftS, leftT * 2 + rightS));
        long long straight = min(max(leftS, leftT), max(rightT, rightS));
        cout << min(turn, straight) << endl;
    }
}





Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;

int main(void){

    ll A,B,N; cin>>A>>B>>N;
    ll maxim = 0;
    ll ans=1;

    if(N>=B){
        cout<<floor(A*(B-1)/B)-A*floor((B-1)/B)<<endl;
    }else{
        cout<<floor(A*N/B)-A*floor(N/B)<<endl;
    }

}


Measured memory_bytes: 3784
// Problem : E - Colorful Hats 2
// Contest : AtCoder - Sumitomo Mitsui Trust Bank Programming Contest 2019
// URL : https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int n;
    cin>>n;
    vi a(n), cnt(3);
    for(int i=0;i<n;i++) cin>>a[i];
    int ans = 1;
    for(int i=0;i<n;i++){
        int cur = -1, now = 0;
        if(a[i] == cnt[0]) now++, cur = 0;
        if(a[i] == cnt[1]) now++, cur = 1;
        if(a[i] == cnt[2]) now++, cur = 2;
        if(cur == -1){
            cout<<0;
            return;
        }
        ans = (ans*now)%mod;
        cnt[cur]++;
    }
    cout<<ans;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3968
def resolve():
    N, M = map(int, input().split())
    S, C = [0] * M, [0] * M
    for i in range(M):
        S[i], C[i] = map(int, input().split())

    def main():
        if M == 0:
            if N == 1:
                return 0
            elif N == 2:
                return 10
            else:
                return 100
        elif M==1 and N==1 and S[0]==1 and C[i]==0:
            return 0
        else:
            for j in range(10 ** (N - 1), 10 ** (N)):
                for k in range(M):
                    temp=str(j)[S[k] - 1]
                    if temp!=str(C[k]):
                        break
                    elif k == M - 1:
                        return j


    val=main()
    print(val if val != None else -1)

resolve()

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

typedef   long long  int ll;
typedef  long double ld;
typedef std::vector<ll> vi;
typedef std::vector<std::vector<ll> > vv;

#define MOD 1000000007
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,b) for(i=a;i<b;i++)
#define mp make_pair
#define pb(x) push_back(x)
#define fi first
#define se second
#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" ";cout<<endl;
#define all(a) a.begin(),a.end()
#define input(vec,a,b) for(ll i = a;i<b;i++) cin>>vec[i];
#define ms(a,val) memset(a,val,sizeof(a))
using namespace std;

const int N = 1e5 + 5;


void solve(){
            ll i,j,n,m;
            
            string a,b;
            cin>>a>>b;
            n = a.size();
            m = b.size();
            ll lcs[n+1][m+1];
            ms(lcs,0);
            
            fo(i,1,n+1)
            {
				fo(j,1,m+1)
				{
					if(a[i-1]==b[j-1])
					 lcs[i][j] = 1 + lcs[i-1][j-1];
					else
					lcs[i][j] = max(lcs[i-1][j],lcs[i][j-1]);
				}
			}
			vector<char> ans;
			for(i = n,j = m;i>0&&j>0;)
			{
				if(a[i-1]==b[j-1])
				 {ans.push_back(a[i-1]),i--,j--;}
				 else
				 {
					 if(lcs[i-1][j]>lcs[i][j-1])
						i--;
						else
						j--;
				}
			}
			//cout<<ans.size()<<endl;
			
				for(i= ans.size()-1;i>=0;i--)
				 cout<<ans[i];
				 cout<<endl;
				
				
			
            
						            









}

int main()
{
    IO;
      ll t=1,i;
     // cin>>t;


      while(t--)
      {

          solve();
      }
    return 0;
}


Measured memory_bytes: 73836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) {
    cin >> s[i];
  }

  int ans = 0;

  rep(i, n) {
    int tmp = s[i].size()-1;
    rep(j, tmp) {
      if (s[i][j] == 'A' && s[i][j+1] == 'B') {
        ans++;
      }
    }
  }

  int oa = 0, bo = 0, ba = 0;
  rep(i, n) {
    if (s[i][0] == 'B' && s[i][s[i].size()-1] == 'A') ba++;
    else if (s[i][s[i].size()-1] == 'A') oa++;
    else if (s[i][0] == 'B') bo++;
  }

  if (ba > 0) {
    ans += ba-1;
    if (bo >= 1) {
      bo--;
      ans++;
    }
    if (oa >= 1) {
      oa--;
      ans++;
    }
  }
  ans += min(oa, bo);
  cout << ans << endl;
}


Measured memory_bytes: 768
import java.util.Scanner; 
public class Main {
  public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
     int b = sc.nextInt();
     if(a>b){
      System.out.println("a > b");
     }else if(a<b){
      System.out.println("a < b");
     }else{
      System.out.println("a == b");
     }
    sc.close();
  }
}


Measured memory_bytes: 26128
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  int k, a, b;
  while (scanf("%d %d %d", &k, &a, &b) != EOF)
  {
    bool can = false;
    for (int i = 1; i*k <= b; i++)
      if (i*k >= a)
        can = true;
    printf("%s\n", can ? "OK" : "NG");
  }
  return 0;
}

Measured memory_bytes: 3760
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long X = sc.nextLong();

		long cost = 100;
		int ans = 0;
		for(int i=1; i<4000; i++) {
			cost = (long)(cost*1.01);
			if(cost >= X) {
				ans = i;
				break;
			}
		}

		System.out.println(ans);

	}


}


Measured memory_bytes: 35772
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.thief", "r", stdin);
	string str = "";
	int count = 0;

	while (getline (cin, str ) ){
		int max_wight;
		stringstream ssw (str );
		ssw >> max_wight;
		if (max_wight == 0 ){
			break;
		} // end if
		++count;
		
		int n;
		getline (cin, str );
		stringstream ssn(str);
		ssn >> n;

		vector <int> W (n, 0);
		vector <int> V (n, 0);
		vector <int> DP (max_wight+1, 0 );
		int i,j;

		for (i = 0; i < n; ++i){
			getline (cin, str );
			while (str.find(',') != string::npos ){
				str = str.replace(str.find(','), 1, " ");
			} // end while
			stringstream ss(str);
			ss >> V[i] >> W[i];
		} // end for

		for (i = 0; i < n; ++i){
			vector<int> dp = DP;
			for (j = W[i]; j <= max_wight; ++j){
				int p = j - W[i];
				if (dp[p] + V[i] > DP[j] ){
					DP[j] = dp[p] + V[i];
				} // end if 
			} // end for
		} // end for

		int maxvalue = DP[max_wight];
		int minwight = max_wight;

		for (j = max_wight - 1; j >= 0; --j){
			if (DP[j] >= maxvalue){
				minwight = j;
				maxvalue = DP[j];
			} // end if
		} // end for
		cout << "Case " << count << ':' << endl;
		cout << maxvalue << endl;
		cout << minwight << endl;
			
	} // end while	
	
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void)
{
	int height[10];
	int i,j,temp;
	for(i=0;i<10;i++) {
		scanf("%d", &height[i]);
	}
	for(i=0;i<10;i++) {
		for(j=0;j<9;j++) {		
			if(height[j]<height[j+1]) {
				temp=height[j];
				height[j]=height[j+1];
				height[j+1]=temp;
			}
		}
	}
	printf("%d\n%d\n%d\n",height[0], height[1], height[2]);
	return 0;
}

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

int main()
{
  int l;
  cin >> l;
  printf("%lf\n", pow((double)l / 3, 3));

  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		long h = sc.nextLong();
		long[] a = new long[n];
		long[] b = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
			b[i] = sc.nextLong();
		}
		Arrays.sort(a);
		Arrays.sort(b);
		long count = 0;
		int i = n - 1;
		while (i >= 0 && h > 0 && b[i] > a[n - 1]) {
			h -= b[i];
			count++;
			i--;
		}
		if (h > 0) {
			count += (h + a[n - 1] - 1)/ a[n - 1];
		}
		System.out.println(count);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	int ans = 1, temp = 1;
	vector<int> A;
	
	cin>>N;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		ans *= 3;
	}
	for(int i = 0; i < N; i++){
		if(A[i]%2 == 0) temp *= 2;
	}
	ans -= temp;
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);

	int A = sc.nextInt();
	int B = sc.nextInt();
	int C = sc.nextInt();
	int coin = 0;
	int count = 0;

	while(coin < C){ 
	    count++;
	    coin += A;
	    if(count%7==0){
		coin += B;
	    }
	}

	System.out.println(count);
    }
}



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

int main(){
  	int n;
  	cin >> n;
  
    vector<int> p(n), q(n), arr(n);
  	for(int i=0; i<n; i++) cin >> p[i];
  	for(int i=0; i<n; i++) cin >> q[i];
  	for(int i=0; i<n; i++) arr[i] = i+1;
  
  	int cnt1=0, cnt2=0, found1=false, found2=false;
  	do{
      	if(!found1){
            bool flag=true;
            for(int i=0; i<n; i++){
                if(arr[i] != p[i]) {flag=false; break;}
            }
          	if(flag) found1=true;
        }
      	if(!found2){
          	bool flag=true;
            for(int i=0; i<n; i++){
                if(arr[i] != q[i]) {flag=false; break;}
            }
          	if(flag) found2=true;
        }
      	
      	if(!found1) cnt1++;
      	if(!found2) cnt2++;
      	if(found1 && found2) break;
    }while(next_permutation(arr.begin(), arr.end()));
  
  	cout << abs(cnt1-cnt2);

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    static long[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        long[] intarray = new long[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    static void array_sout(int[][] array) {
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }

    static void array_sout(int[] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
        System.out.println();
    }

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

            long[] val = inputval();
            long N,A,B;
            N = val[0];
            A = val[1];
            B = val[2];
            long result;
            
            if(A > B) result = 0;
            else if(N == 1){
                if(A != B) result = 0;
                else result = 1;
            } else {
                result = (B-A) * (N - 2) + 1 ;
            }
            System.out.println(result);
    }

}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, m, all = 0, ans = 0;
	double can;
	cin >> n >> m;
	vector<int>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		all += a[i];
	}
	can = all / (4.0 * m);

	for (int i = 0; i < n; i++) {
		if (!(a[i] < can))ans++;
	}
	if (ans >= m)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#define rep(i,n) REP(i,0,n)
#define REP(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;


int main(void) {
   int N,D;
   cin>>N>>D;
   int X[12][12];
   rep(i,N) {
      rep(j,D) cin>>X[i][j];
   }
   int ans = 0;
   rep(i,N) {
      rep(i2,N) {
         if (i2 <=i) continue;
         int dis2 = 0;
         rep(j,D) dis2 += (X[i][j] - X[i2][j]) * (X[i][j] - X[i2][j]);
         int dis = sqrt(dis2);
         if (dis2 == dis * dis) ans++;
      }
   }
   cout<<ans<<endl;




   return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
const int N=100005;
typedef long long LL;
int n;
LL a[N],ans;

int getint()
{
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

int main()
{
	n=getint();
	rep(i,1,n) a[i]=getint();
	sort(a+1,a+1+n);
	if(n&1)
	{
		int p=n+1>>1;
		if(-a[p-1]-a[p]+2*a[p+1]>-2*a[p-1]+a[p]+a[p+1])
		{
			rep(i,1,n) if(i<=p) ans-=2*a[i]; else ans+=2*a[i];
			ans+=a[p-1]+a[p];
		}
		else
		{
			rep(i,1,n) if(i<p) ans-=2*a[i]; else ans+=2*a[i];
			ans-=a[p]+a[p+1];
		}
	}
	else
	{
		int p=n>>1;
		rep(i,1,n) if(i<=p) ans-=2*a[i]; else ans+=2*a[i];
		ans+=a[p]-a[p+1];
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
    //write code  here
    int A,B,C,D;
    cin >> A >> B >> C >> D;

    for(int i = 0;;i++){
        if (i%2 ==0) C-=B;
        else A-=D;

        if(A<=0||C<=0) break;
    }
    if (A>0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>

#define MIN(a,b) ((a)<(b)?(a):(b))

void run(void){
  int n;
  scanf("%d",&n);
  int *p=(int *)malloc(sizeof(int)*(n+1));
  int i;
  for(i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    p[a]=i;
  }
  int ans=n-1;
  i=1;
  while(i<=n){
    int j=i+1;
    while(j<=n && p[j]>p[j-1]) j++;
    ans=MIN(ans,n-(j-i));
    i=j;
  }
  printf("%d\n",ans);
  return;
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 896
import math
import collections
import sys

#input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]

a,b=MI()
if b%a==0:
    print(a+b)
else:
    print(b-a)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main() {
	char s[55];
	int ans, n;
	while (cin >> n >> s) {
		ans = 0;
		for (int i = 0; i < n; ++i) {
			if (i <= n - 3 && s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main() {
	ll n;
	cin>>n;
	vector<ll> v;
	rep(i,0,n){
		ll a;
		cin>>a;
		v.pb(a);
	}
	ll ans = 0;
	rep(i,0,n-2){
		ll a = v[i+1];
		vector<ll> v1;
		v1.pb(v[i]);
		v1.pb(v[i+1]);
		v1.pb(v[i+2]);
		sort(all(v1));
		if(v1[1]==a)ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, k; cin >> n >> k;
    
    ll ans = 1;
    ll mod = 1e9 + 7;
    for (; k <= n; ++k) {
        ll m = k * (k - 1) / 2, M = k * (n - k + 1 + n) / 2;
        ans += M - m + 1;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
class _0004
{
    public static void Main()
    {
        char[] splitChar = { ' ' };
        List<double> ansx = new List<double>();
        List<double> ansy = new List<double>();
        double det;
        double[] data = new double[6];
        string str;
        while ((str = Console.ReadLine()) != null)
        {
            string[] nums = str.Split(splitChar);
            int l = 0;
            foreach (string num in nums)
            {
                data[l] = double.Parse(num);
                l++;
            }
            det = data[0] * data[4] - data[1] * data[3];
            ansx.Add((data[4] * data[2] - data[1] * data[5]) / det);
            ansy.Add((data[0] * data[5] - data[3] * data[2]) / det);
        }
        for (int i = 0; i < ansx.Count; i++) Console.WriteLine(ansx[i].ToString("f3") + " " + ansy[i].ToString("f3"));
    }
}

Measured memory_bytes: 5796
function Main(input) {
  input = input.split("\n");
  tmp = input[0].split(" ");
  var answer = 0;
  var plug = tmp[1];
  tap = tmp[0]-1;
  if(tmp[1] != 1){
    plug = tmp[1]-tmp[0];
    answer++;
    while(plug > 0){
      plug = plug-tap;
      answer++;
    }
  }
  console.log(answer);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,cnt1=0,cnt2=0,cnt3=0,cnt4=0;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    string s;
    cin>>s;
    if(s=="AC")
    {
      cnt1++;
    }
    else if(s=="TLE")
    {
      cnt2++;
    }
    else if(s=="WA")
    {
      cnt3++;
    }
    else if(s=="RE")
    {
      cnt4++;
    }
  }
  cout<<"AC x "<<cnt1<<endl;
  cout<<"WA x "<<cnt3<<endl;
  cout<<"TLE x "<<cnt2<<endl;
  cout<<"RE x "<<cnt4<<endl;
}


Measured memory_bytes: 3628
#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             1000000007
#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--)
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;
 
 
void c_p_c()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
   
   string s,t ;
   cin >> s >> t;

   int ans = INT_MAX;
   if (s == t) {
   		ans = 0;
   }
   else {
   		ans = t.length();
   }

   for (int i = 0; i <= s.length() - t.length(); i++) {
   		int mismatch = 0;
   		for (int j = 0; j < t.length(); j++) {
   			if (s[i + j] != t[j]) {
   				mismatch++;
   			}
   		}

   		if (mismatch < ans) {
   			ans = mismatch;
   		}
   }

   cout << ans;
}
 
int32_t main()
{
    c_p_c();
    return 0;
}

Measured memory_bytes: 3648
// ABC 057 C - Digits in Multiplication 

#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

//get the number of digits
//整数nの桁数を計算する。
long getDigit(long n){
  return static_cast<long>(log10(static_cast<double>(n))) + 1;
}

long F(long A,long B){
  return max(getDigit(A),getDigit(B)); 
}

int main(void){
  long minimum;
  long N; cin >> N;
  long sqrtN = sqrt(N);
  for(long i=1 ; i<=sqrtN ; i++){
    if(N % i == 0){
      if(i == 1){
        minimum = F(i,N/i); 
      }
      long tmp = F(i,N/i);
      if(tmp < minimum){
        minimum = tmp;
      }
    }
  }
  cout << minimum << endl;
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s[3];
	cin >> s[0] >> s[1] >> s[2];
	cout << char(s[0][0] - ('a' - 'A'));
	cout << char(s[1][0] - ('a' - 'A'));
	cout << char(s[2][0] - ('a' - 'A'));
	cout << endl;
}

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

const int MAX_H = 50, MAX_W = 50;

int h, w;
int c[MAX_H][MAX_W];
int dp[MAX_H][MAX_W];

int solve(int h, int w)
{
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (i == 0 && j == 0)
                dp[i][j] = c[i][j];
            else if (i == 0)
                dp[i][j] = dp[i][j - 1] + c[i][j];
            else if (j == 0)
                dp[i][j] = dp[i - 1][j] + c[i][j];
            else
                dp[i][j] = min(dp[i][j - 1], dp[i - 1][j]) + c[i][j];
        }
    }
    return dp[h - 1][w - 1];
}

int main()
{
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            char ch;
            cin >> ch;
            c[i][j] = ch - '0';
        }
    }

    fill(&dp[0][0], &dp[MAX_H][0], 0);
    cout << solve(h, w) << endl;
}

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

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

    int ans = S.size();

    for (int i = 0; i < S.size(); i++)
    {
        if ((i + 1) < S.size() && (S[i] == S[i + 1]))
        {
            ans--;
            i += 2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
N=int(input())
num=map(int, input().split())
list1=[]
list2=[]
for x in num:
    list1.append(x)
for i in range(0,N-1):
    if list1[i+1]<list1[i]:
        list1[i]+=0
        re=list1[i]-list1[i+1]
        list1[i+1]+=re
        list2.append(re)
    elif list1[i+1]>=list1[i]:
        list1[i+1]+=0
        list1[i]+=0
print(sum(list2))

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n,k;
	cin >> n >> k;
	int r, s, p;
	cin >> r >> s >> p;
	string ss,tmp;
	map<char, int>m;
	cin >> ss;
	string res = "";
	for (auto u : ss) {
		if (u == 'r')tmp = "p";
		else if (u == 's')tmp = "r";
		else tmp = "s";
		res += tmp;
	}
	int cnt = 0;
	for (int i = 0; i < n - k; i++) {
		if (res[i] == res[i + k]) {
			res[i + k] = 'o';
		}
	}
	for (auto q : res)m[q]++;

	ll ans = r * m['r'] + s * m['s'] + p * m['p'];
	cout << ans << endl;
	return 0;
}



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

int main(void) {
  int A, B, C, cnt=1;
  cin >> A >> B;
  
  C=A;
  
  while(A<B){
    A += C-1;
    cnt++;
  }
  
  if(B==1) cnt=0;
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
typedef pair<string,int>P;
typedef pair<P,int>PP;
vector<PP>v;

int main(){
	int N;
	cin>>N;
	REP(i,N){
		string S;
		int p;
		cin>>S>>p;
		v.push_back(PP(P(S,-p),i+1));
	}
	sort(v.begin(),v.end());
	REP(i,N){
		cout<<v[i].second<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    
using namespace std;
    
#define rep(i, n) for (int i = 0; i < (int)n; i++)
    
vector<int> s;
int N, M;
const int INF = 1e9;
    
bool init()
{
    cin >> N >> M;
    if (N == 0) return false;
    s.clear();
    s.resize(N);
    rep(i, N) cin >> s[i];
    return true;
}
    
bool isok(int x)
{
    int l = 1;
    int goal = s[N-1] - x + 1;
    int prev = 0; // 前回倒した敵
    int cnt = 0; // 戦闘回数
    while (l < goal) {
        cnt++;
        int ma = max(1, x - abs(l - s[prev]));
        while (prev != N - 1 && s[prev+1] < l + x && ma <= max(1, x - abs(l - s[prev+1]))) {
            ma = max(1, x - abs(l - s[prev+1]));
            prev++;
        }
        l += ma;
    }
    return cnt + 1 >= M;
}
    
int solve()
{
    int ok = s[0] - 1; 
    int ng = INF;
    // s[0] ~ INF-1 の範囲に答えがあるか2分探索
    while (abs(ok - ng) > 1) { // absを付けているのはokとngの大小関係を意識せずにかけるため(めぐる式2分探索)
        int mid = (ok + ng) / 2;
        if (isok(mid)) ok = mid;
        else ng = mid;
    }
    if (ok == s[0] - 1 || ng == INF) return -1;
    return ok;
}
    
int main()
{
    while (init()) {
        cout << solve() << endl;
    }
}


Measured memory_bytes: 3364
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
from decimal import *
n=I()
x=Decimal("1.08")
for i in range(1,100000):
    if int(i*x)==n:
        print(i)
        sys.exit()
print(":(")
    
    




        
        
    
    
        
    
    


Measured memory_bytes: 185968
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string S, T;
  cin >> S >> T;
  ll ans = INF;
  for (int i = 0; i < S.size(); i++) {
    string substr = S.substr(i, T.size());
    if (substr.size() != T.size()) continue;
    ll same = 0;
    for (int j = 0; j < T.size(); j++) {
      if (substr[j] == T[j]) same++;
    }
    ll cost = (ll)T.size() - same;
    ans = min(cost, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608