akhauriyash/Code-Regression huggingface dataset:
import sys, collections
range = xrange
input = raw_input

n, p = [int(x) for x in input().split()]
A = [ord(x) - 48 for x in input()]


if p == 2 or p == 5:
    ans = 0
    for i in range(n):
        if A[i]%p == 0:
            ans += i + 1
    print ans
    sys.exit()


DP = [0]*p
ans = 0
POW = 1
ind0 = 0
for a in reversed(A):
    DP[ind0] += 1
    #DP = [DP[(a * POW + i) % p] for i in range(p)]
    ind0 = (a * POW + ind0) % p
    ans += DP[ind0]
    POW = POW * 10 % p
print ans


Measured memory_bytes: 34204
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
using namespace std;
typedef long long ll;
const ll N=1005;
int a[N][8];
ll p[4];
map<ll,ll>g;
ll Hash(ll a,ll b,ll c,ll d){
    return (a<<30)|(b<<20)|(c<<10)|d;
}
void Add(ll f,ll v){
    for(int i=0;i<4;i++){
        g[f]+=v;
        f=(f>>10)|((f&(1023))<<30);
    }
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        for(int j=0;j<4;j++){
            scanf("%d",&a[i][j]);
            a[i][j+4]=a[i][j];
        }
        Add(Hash(a[i][0],a[i][1],a[i][2],a[i][3]),1);
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        Add(Hash(a[i][0],a[i][1],a[i][2],a[i][3]),-1);
        for(int j=i+1;j<n;j++){
            Add(Hash(a[j][0],a[j][1],a[j][2],a[j][3]),-1);
            for(int k=0;k<4;k++){
                ll sum=1;
                p[0]=Hash(a[j][k+1],a[j][k+0],a[i][1],a[i][0]);
                p[1]=Hash(a[j][k+0],a[j][k+3],a[i][2],a[i][1]);
                p[2]=Hash(a[j][k+3],a[j][k+2],a[i][3],a[i][2]);
                p[3]=Hash(a[j][k+2],a[j][k+1],a[i][0],a[i][3]);
                if(g[p[0]]&&g[p[1]]&&g[p[2]]&&g[p[3]]){
                    sum*=g[p[0]];
                    Add(p[0],-1);
                    sum*=g[p[1]];
                    Add(p[1],-1);
                    sum*=g[p[2]];
                    Add(p[2],-1);
                    sum*=g[p[3]];
                    //Add(p[3],-1);
                    //Add(p[3],1);
                    Add(p[2],1);
                    Add(p[1],1);
                    Add(p[0],1);
                    ans+=sum;
                }
            }
            Add(Hash(a[j][0],a[j][1],a[j][2],a[j][3]),1);
        }
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 20352
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define ull unsigned long long
#define size(v) int((v).size())
#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...)
#endif
#define rep(i, n) for (int i = 0; i < int(n); i++)
template<typename T>
inline void read(T &a) {
	register int b=1,c=getchar();a=0;
	for(;!isdigit(c);c=getchar())if(c==45)b*=-1;
	for(;isdigit(c);c=getchar())a=(a<<3)+(a<<1)+(c^48);
	a*=b;
}
// Template end

const int maxn = 4005;
char c[maxn][5];
int pos[2][maxn];
int dp[maxn][maxn];
int cost[maxn][maxn][2];
int n, a[maxn], tp[maxn];
int small[maxn][maxn][2];
int biger[maxn][maxn][2];

inline int MIN(const int &a, const int &b) { return a<b?a:b; }
inline int ABS(const int &a) { return a<0?-a:a; }

int main() {
	// freopen("input.txt","r",stdin);
	// Work start
	read(n);
	for(int i=1;i<=2*n;i++) {
		scanf("%s", c[i]);
		read(a[i]);
		if (c[i][0]=='B') tp[i]=1;
		pos[tp[i]][a[i]]=i;
	}
	for(int i=1;i<=2*n;i++) {
		if (i) for(int j=0;j<=n;j++) {
			small[i][j][0]=small[i-1][j][0];
			small[i][j][1]=small[i-1][j][1];
			biger[i][j][0]=biger[i-1][j][0];
			biger[i][j][1]=biger[i-1][j][1];
		}
		for(int j=0;j<a[i];j++) small[i][j][tp[i]]++;
		for(int j=a[i];j<=n;j++) biger[i][j][tp[i]]++;
	}
	for(int i=0;i<=n;i++) for(int j=0;j<=n;j++) {
		if (i==n) continue;
		int nwpos=-1;
		if (pos[0][i+1]<=i+j) {
			nwpos=i+j+small[pos[0][i+1]][i][0]+small[pos[0][i+1]][j][1];
			eprintf("Case #1 : %d %d\n", small[pos[0][i+1]][i][0], small[pos[0][i+1]][j][1]);
		} else {
			nwpos=pos[0][i+1]+i-biger[pos[0][i+1]][i][0]+j-biger[pos[0][i+1]][j][1];
			eprintf("Case #2 : %d %d\n", biger[pos[0][i+1]][i][0], biger[pos[0][i+1]][j][1]);
		}
		eprintf("%d %d %d %d\n", i, j, pos[0][i+1], nwpos);
		cost[i][j][0]=nwpos-i-j-1;
		eprintf("%d %d %d\n", i, j, cost[i][j][0]);
	}
	for(int i=0;i<=n;i++) for(int j=0;j<=n;j++) {
		if (j==n) continue;
		int nwpos=-1;
		if (pos[1][j+1]<=i+j) {
			nwpos=i+j+small[pos[1][j+1]][i][0]+small[pos[1][j+1]][j][1];
			eprintf("Case #1 : %d %d\n", small[pos[1][j+1]][i][0], small[pos[1][j+1]][j][1]);
		} else {
			nwpos=pos[1][j+1]+i-biger[pos[1][j+1]][i][0]+j-biger[pos[1][j+1]][j][1];
			eprintf("Case #2 : %d %d\n", biger[pos[1][j+1]][i][0], biger[pos[1][j+1]][j][1]);
		}
		eprintf("%d %d %d %d\n", i, j, pos[1][j+1], nwpos);
		cost[i][j][1]=nwpos-i-j-1;
		eprintf("%d %d %d\n", i, j, cost[i][j][1]);
	}
	for(int i=0;i<=n;i++) for(int j=0;j<=n;j++) {
		if (!i && !j) continue;
		dp[i][j]=1000000007;
		if (i) dp[i][j]=MIN(dp[i][j],dp[i-1][j]+cost[i-1][j][0]);
		if (j) dp[i][j]=MIN(dp[i][j],dp[i][j-1]+cost[i][j-1][1]);
	}
	printf("%d\n",dp[n][n]);
#ifdef DEBUG
	printf("\nRunning Time : %ldms", clock());
#endif
	return 0;
}


Measured memory_bytes: 350208
package main

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

func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var n int
	var a, b int64
	fmt.Scan(&n, &a, &b)
	h := make([]int64, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		sc.Scan()
		e, _ := strconv.Atoi(sc.Text())
		h[i] = int64(e)
	}

	f := func(k int64) bool {
		x := int64(0)
		for _, e := range h {
			rem := e - b*k
			if rem > 0 {
				x += (rem + a - b - 1) / (a - b)
			}
		}
		return x <= k
	}
	ok := int64(1e9)
	ng := int64(0)
	for abs(ok-ng) > 1 {
		mid := (ok + ng) / 2
		if f(mid) {
			ok = mid
		} else {
			ng = mid
		}
	}
	fmt.Println(ok)
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c;
  	cin>>a>>b>>c;
  	
  	for (int i=1;i<=b;i++){
    	if(i*a%b==c){
        	cout<<"YES"<<endl;
          	return 0;
        }
    }  
  	cout<<"NO"<<endl;
}


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

using namespace std;

int main(){
  long long n, m, x[1009], y[1009], z[1009],a[1009], mx=0;
  cin >> n >> m;
  for(int i=0;i<n;i++)cin >> x[i] >> y[i] >> z[i];
  for(long long xx: {-1, 1}){
    for(long long yy: {-1, 1}){
      for(long long zz: {-1, 1}){
        for(int i=0;i<n;i++)a[i]=xx*x[i]+yy*y[i]+zz*z[i];
        sort(a, a+n);
        long long sm=0;
        for(int i=0;i<m;i++)sm+=a[n-1-i];
        mx=max(mx, sm);
      }
    }
  }
  cout << mx << endl;
}



Measured memory_bytes: 3640
// コードをここに挿入。
function main(input) {
    const args = input.split(' ');
    const a = parseInt(args[0], 10);
    const b = parseInt(args[1], 10);
    const c = parseInt(args[2], 10);
    const d = parseInt(args[3], 10);    

    var dif_ac = Math.abs(a - c);
    if (dif_ac <= d) {
        console.log("Yes");
    }
    else {
        var dif_ab = Math.abs(a - b);
        var dif_bc = Math.abs(b - c);
        if (dif_ab <= d && dif_bc <= d) {
            console.log("Yes");
        }
        else {
            console.log("No");
        }
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;

int main(){
    string s; cin  >> s;
    int ans=0;
    rep(i,s.size()-1){
        if(s[i]==s[i+1]) ans++;
    }
    if(ans) cout << "Bad" << endl;
    else cout << "Good" << endl;
return 0;
}

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

int main() {
  int n, m; cin >> n >> m;
  if (n==m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  } 
  
  return 0;
}

Measured memory_bytes: 256
S=input()
ans,n=0,len(S)
dp=[0]*(2019)
s,dp[0],k=0,1,1
for i in S[::-1]:
  s=(s+int(i)*k)%2019
  k=(k*10)%2019
  ans+=dp[s]
  dp[s]+=1
print(ans)

Measured memory_bytes: 9316
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    int total = 0;
    if(a-b>=0){
      System.out.println("delicious");
    }else if(a+x>=b){
      System.out.println("safe");
    }else{
      System.out.println("dangerous");
    }    
  } 
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef  long long LL;
typedef  unsigned long long ULL;
typedef  double db;
typedef  long double ld;
#pragma comment(linker, "/STACK:102400000,102400000")
#define fuck(x) cout<<x<<endl
#define fuck1(x,y) cout<<x<<" "<<y<<endl
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define MP(a,b) make_pair(a,b)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
const int INF = 0x3f3f3f3f3f,mod = 1e9+7;
const double eps  =1e-6,PI = acos(-1);
template<typename T> inline void read(T &x){
    x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
const int maxn =1e5+100;
int N;
char ax[maxn];
int main(){
    read(N);
    scanf("%s",ax);
    if(N<3200)cout<<"red"<<endl;
    else cout<<ax<<endl;

    return 0;
}
/*
abc
abc
*/


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b){
    for(int loop1=0;loop1<b;loop1++){
      printf("%d",a);
    }
  }else{
    for(int loop2=0;loop2<a;loop2++){
      printf("%d",b);
    }
  }
  return 0;
}

Measured memory_bytes: 128
// template version 1.0
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  int n;cin>>n;
  int a[n];
  rep(i, n){ cin>>a[i]; }

  int cnt=1;
  int flag = 0;
  rep(i, 1, n){
    if (a[i]-a[i-1]==0){
    }
    else if (a[i]-a[i-1]<0){
      if (flag==1){
        cnt += 1;
        flag = 0;
      }
      else{
        flag = -1;
      }
    }
    else if (a[i]-a[i-1]>0){
      if (flag==-1){
        cnt += 1;
        flag = 0;
      }
      else{
        flag = 1;
      }
    }
  }
  cout << cnt << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  vector<ll> friendly(n);
  for (int i = 0; i < n; i++) cin >> friendly[i];
  sort(friendly.begin(), friendly.end());
  reverse(friendly.begin(), friendly.end());

  priority_queue<ll, vector<ll>> que;
  que.push(friendly[0]);
  ll ans = 0;
  for (int i = 1; i < n; i++) {
    ans += que.top();
    //cout << ans << endl;
    que.pop();
    que.push(friendly[i]);
    que.push(friendly[i]);
  }

  cout << ans << endl;

}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ??????????????????????????????????????????( ^??^)??????????????????????????????????????????

// ????????°????????°?????\?¬???°
int v, e, in[100000];
// ??\?¬???°0???????????????????????\????????????
queue<int> S;
// ????????£??\?????????
mat V(100000);
// ??????
vi ans;

int main() {
	cin >> v >> e;
	rep(i,e) {
		int a, b;
		cin >> a >> b;
		V[a].pb(b);
		in[b]++;
	}
	
	// ??\?¬???°0??????????????????
	rep(i,v) if (in[i]==0) S.push(i);
	while (!S.empty()) {
		int u = S.front(); S.pop();
		ans.pb(u);
		// u?????????????¢???????????????§??°?????????????¶?????????£??\????????¨??????????????\?¬???°???1?????????
		rep(i,V[u].size()) {
			int to = V[u][i];
			in[to]--;
			// ????????????????????£?????\?¬???°???0????????£?????????????????°S?????????
			if (in[to]==0) S.push(to);
		}
	}
	rep(i,v) cout << ans[i] << ln;
}

Measured memory_bytes: 5856
#include <string>
#include <iostream>
#include <unordered_set>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <vector>
using namespace std;


int main() {
    int n,k; cin>>n>>k; 
    vector<int> v(n);
    for (auto& e : v) cin>>e;
    sort (v.begin(), v.end());
    cout<<accumulate(v.begin(), v.begin()+k, 0)<<endl;
    return 0;
}

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


int a[10];

int LCM(int n, int m){
  if (n == 0) return m;
  return LCM(m % n, n);
}

int main()
{
  int n;

  cin >> n;

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

  for (int i = n - 1; i > 0; i--){
    a[i - 1] *= a[i] / LCM(a[i - 1], a[i]);
  }

  cout << a[0] << endl;

  return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;

int main() {
	int n,k=1;
	cin>>n;
	while(1){
		if(k*k>n)break;
		++k;
	}
	--k;
	cout<<k*k<<endl;


		return 0;
}


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

typedef long long ll;

int main() {
  string A, B;
  string S;
  cin >> A >> B >> S;

  // TODO: 埋め込みできるのかな
  regex re = regex("^[0-9]{" + A + "}-[0-9]{" + B + "}$");

  // 全体一致
  bool isValid = regex_match(S, re);

  cout << (isValid ? "Yes" : "No") << endl;
}

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


input_list = input().split()
stack = list()
for i in input_list:
    if i.isdigit():
        stack.append(int(i))
    else:
        b = stack.pop()
        a = stack.pop()
        if i == '+':
            stack.append(a + b)
        elif i == '-':
            stack.append(a - b)
        elif i == '*':
            stack.append(a * b)
print(stack.pop())

Measured memory_bytes: 7640
n,m = map(int,input().split())
ab = []
cd = []
for i in range(n):
    ab.append(list(map(int,input().split())))
for j in range(m):
    cd.append(list(map(int,input().split())))
for i in range(n):
    point = 0
    distance = 3*10**8
    for j in range(m):
        if distance > abs(cd[j][0]-ab[i][0]) + abs(cd[j][1]-ab[i][1]):
            distance = abs(cd[j][0]-ab[i][0]) + abs(cd[j][1]-ab[i][1])
            point = j
    print(point+1)

Measured memory_bytes: 3064
n = int(input())
A = list(map(int, input().split()))
from collections import Counter
# C = reversed(sorted(Counter(A)))
C = Counter(A)
x = None
# for k, v in C.items():
for k, v in reversed(sorted(C.items())):
	if v >= 4:
		if x:
			print(k * x)
			exit()
		else:
			print(k ** 2)
			exit()
	elif v >= 2:
		if x:
			print(k * x)
			exit()
		else:
			x = k
else:
	print(0)

Measured memory_bytes: 70040
N = gets.to_i
c = 0
a = 0
N.times do
  x, y = gets.split.map(&:to_i)
  if x == y then
    c += 1
    a = c if c > a
  else
    c = 0
  end
end

puts a >= 3 ? 'Yes' : 'No'


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

#ifndef errOut
#define errOut(s)
#endif

int64_t sumDigit(int64_t n) {
    int64_t  ret = 0;
    while(n) {
        ret += n % 10;
        n /= 10;
    }
    return ret;
}

int64_t calc(int64_t n) {
    if (n < 10) {
        return n;
    }
    int64_t ret = sumDigit(n);
    int64_t d = 10000000000000000;
    while (d > n) {
        d /= 10;
    }
    int64_t nn = n;
    while (d) {
        int64_t c = nn - 9 * d;
        for (int i = 0; i < 19 && c <= n; ++i) {
            int64_t s = sumDigit(c);
            if (s > ret) {
                ret = s;
                nn = c;
            }
            c += d;
        }
        d /= 10;
    }
    return ret;
}

int main() {
    int64_t n;
    std::cin >> n;
    std::cout << calc(n) << std::endl;
    return 0;
}


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

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;

const ll DIV = (ll)1e9+7;
// const ll MAXN = (ll)1e5+10;

int main(void) {
   string S;
   cin>>S;
   ll N[4] ={};
   rep(i,0,S.size()) {
      if (S[i]=='N') N[0]++;
      if (S[i]=='S') N[1]++;
      if (S[i]=='E') N[2]++;
      if (S[i]=='W') N[3]++;
   }
   // cout<<N[0]<<endl;
   // cout<<N[1]<<endl;
   // cout<<N[2]<<endl;
   // cout<<N[3]<<endl;
   bool flag = true;
   if (N[0]>0 && N[1]==0) flag = false;
   if (N[1]>0 && N[0]==0) flag = false;
   if (N[2]>0 && N[3]==0) flag = false;
   if (N[3]>0 && N[2]==0) flag = false;
   if (flag) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;

   return 0;
}



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

using namespace std;

typedef long long ll;

ll n, m;
vector<ll> a;

// condを満たす最小のxを求める(lower_bound)
// 全てのxが条件を満たさない場合はnを返す(nはとりえない値)

bool cond(ll x){
	ll t = 0;
	rep(i, n){
		auto it = lower_bound(a.begin(), a.end(), x - a[i]);
		t += n - (it - a.begin());
	}
	
	return t < m;
}

ll lower_bound_cond(){
	ll lb = -1, ub = 202020;

	while(ub - lb > 1){
		int mid = (lb + ub) / 2;

		bool ok = cond(mid);
		// cout << mid << "," << ok << endl;
		if(ok) ub = mid;   // Answer is in (lb, mid]
		else lb = mid;            // Answer is in (mid, ub]
	}

	// now lb + 1 = ub
	return ub;
}

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

	cin >> n >> m;

	a.resize(n);
	rep(i, n) cin >> a[i];

	sort(a.begin(), a.end());
	ll c = lower_bound_cond();
	
	vector<ll> s(n+1, 0);
	rep(i, n) s[i+1] = s[i] + a[i];

	ll ans = 0;
	ll v = m;
	rep(i, n){
		auto it = lower_bound(a.begin(), a.end(), c - a[i]);
		ll u = it - a.begin();
		ans += (n - u) * a[i] + (s[n] - s[u]);
		v -= n - u;
	}

	ans += (c - 1) * v;
	cout << ans << endl;
}


Measured memory_bytes: 4764
//#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;


// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T>
constexpr int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F>
constexpr int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T>
void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C>
void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U>
constexpr void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U>
constexpr void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C>
constexpr void reverse(C& c) { reverse(ALL(c)); }
template<typename C>
constexpr void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred>
constexpr void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#pragma endregion


int main()
{
    double x, h;
    ILP {
        cin >> x >> h;
        if(x==0&&h==0) break;
        printf("%.6f\n", x*x+(x*(sqrt(pow(h,2)+pow(x/2,2)))/2)*4);
    }
    return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
constexpr int MOD = 1e9 + 7;
//} END

signed main() {
  ios_base::sync_with_stdio(false);

  int n,m,x;
  cin>>n>>m>>x;

  int ans = INF;

  vector<int> c(n),a[n];
  rep(i,0,n){
    cin>>c[i];
    rep(j,0,m){
      int ne;
      cin>>ne;
      a[i].emplace_back(ne);
    }
  }

  rep(bit,0,bits(n)){
    vector<int> cnt(m,0);
    int next = 0;
    bool jud = true;
    rep(i,0,n){
      if(bit & bits(i)){
        next += c[i];
        rep(j,0,m) cnt[j] += a[i][j];
      }
    }

    rep(i,0,m){
      if(cnt[i] < x){
        jud = false;
        break;
      }
    }
    if(jud == true) chmin(ans,next);
  }

  cout<<(ans == INF ? -1 : ans)<<'\n';
  return 0;
}

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

using namespace std;

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
int cnt[112345];
namespace prime{
int p[112345];
    struct init{
        init(){
            REP(i,112345){p[i]=1;cnt[i]=0;}p[0]=p[1]=0;
            REP(i,112345)if(p[i])for(int j = i+i;j<112345;j+=i)p[j]=0;
            REP(i,112345)if(i%2==1&&p[i]==1)cnt[i]=p[(i+1)/2];
            FOR(i,1,112345)cnt[i]+=cnt[i-1];
        }
    }ini;
}
int main(){
    int Q;
    while(cin>>Q){
        while(Q--){
            int l,r;
            cin>>l>>r;l--;
            cout<<cnt[r]-cnt[l-1]<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1536
N, M = list(map(int, input().split()))
A = set()
B = set()

for i in range(M):
    a, b = list(map(int, input().split()))

    if a == 1:
        A.add(b)
    elif b == N:
        B.add(a)

if len(A & B):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

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

int main(){
  int N;
  cin >> N;
  vector<vector<long long>> h(N, vector<long long>(3));
  for(int i=0; i<N; i++)  for(int j=0; j<3; j++)  cin >> h.at(i).at(j);
  
  vector<vector<long long>> dp(N+1, vector<long long>(3,0));
  
  for(int i=0; i<N; i++){
    for(int j=0; j<3; j++){
      for(int k=0; k<3; k++){
        if(j==k) continue;
        dp.at(i+1).at(k) = max(dp.at(i+1).at(k), dp.at(i).at(j) + h.at(i).at(k));
      }
    }
  }
  
  long long res = 0;
  for(int i=0; i<3; i++)  res = max(res, dp.at(N).at(i));
  cout << res << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	ll N; cin>>N;
	vector<pair<ll,P>> p(N);
	rep(i,N){
		ll x,y; cin>>x>>y;
		p[i].a=x+y;
		p[i].b.a=x;
		p[i].b.b=y;
	}
	sort(all(p),greater<pair<ll,P>>());
	ll ans=0;
	for(int i=0;i<N;i+=2){
		ans+=p[i].b.a;
	}
	for(int i=1;i<N;i+=2){
		ans-=p[i].b.b;
	}
	cout<<ans;
}

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

using namespace std;
using ll = long long;
using pii = std::pair<int, int>;

#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pb push_back
const int mn = 1e5 + 5;

int n;
vector<int> g[mn];
int deg[mn];

vector<int> v;
ll ans = 0;
ll a[mn];
int cur = 0;

void topo() {
    queue<int> q;
    for (int i = 1; i <= n; i++) {
        if (deg[i] == 1) q.push(i);
    }
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        a[u] = v[cur++];
        for (auto &i:g[u]) {
            if (a[i]) ans += a[i];
            deg[i]--;
            if (deg[i]==1){
                q.push(i);
            }
        }
    }
}

int main() {
#ifdef trote
    freopen("../1.txt", "r", stdin);
#endif

    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].pb(v);
        g[v].pb(u);
        deg[u]++;
        deg[v]++;
    }
    for (int i = 1; i <= n; i++) {
        int u;
        scanf("%d", &u);
        v.pb(u);
    }
    sort(all(v));
    topo();
    printf("%lld\n", ans);
    for (int i = 1; i < n; i++) printf("%d ", a[i]);
    printf("%d\n", a[n]);
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <ctime>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define com(a,n) ll a[n];for(ll i=0;i<n;i++) cin>>a[i];
#define pri(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<endl;
/*__builtin_clz();
__builtin_ctz();
__builtin_popcount();*/
int main()
{
    ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    n=n%26;
    for(ll i=0;i<s.length();i++)
    {
        // cout<<s[i]<<" "<<s[i]+n<<"\n";
        if(s[i] +n <='Z')
        {
            s[i]=s[i]+n;
        }
        else
        {
            ll z= 'Z'-s[i];
            ll nn=n-z;
            // cout<<s[i]<<" "<<n<<" "<<z<<endl;
            s[i]='A'+nn-1;
        }
        
    }
    cout<<s<<"\n";
cerr << "\nTime elapsed: " << 1000 * clock()/CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  for (int i = 0; i <= K; ++i) {
    for (int j = 0; j <= K; ++j) {
      int k = S - i - j;
      if (k < 0 || K < k) continue;
      ans++;
    }
  }
  cout << ans << endl;
}

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

#define all(s) s.begin(), s.end()
#define vi vector<int>
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second

const int N = 100005;

vector<ii> g[N];
int res[N];

void dfs(int u, int ban, int c) {
    int cur = 0;
    for (auto v : g[u]) {
        int x = v.x;
        int y = v.y;
        if (x == ban) continue;
        cur++;
        if (cur == c) cur++;
        res[y] = cur;
        dfs(x, u, cur);
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g[u].pb({v, i});
        g[v].pb({u, i});
    }
    dfs(1, 0, 0);
    int mx = 0;
    for (int i = 1; i <= n; i++) {
        mx = max(mx, (int) g[i].size());
    }
    cout << mx << '\n';
    for (int i = 1; i < n; i++) {
        cout << res[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 8448
using System.Collections.Generic;
using System.Linq;
using System;

class B
{
    static void Main()
    {
        var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x));
        var N = input.ElementAt(0);
        var K = input.ElementAt(1);
        var L = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).OrderByDescending(x => x).ToArray();

        int ans = 0;
        for (int i = 0; i < K; i++)
        {
            ans += L[i];
        }

        Console.WriteLine(ans);
    }
}

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

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x = i;
    if (x % 3 == 0) cout << " " << i;
    else {
      do {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
      } while (x /= 10);
    }
  }
  cout << endl;
  return 0;
}


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

int main() {
    vector<int> a(3);
    for(int i=0;i<3;i++){
        cin>>a.at(i);
    }
    sort(a.begin(),a.end());
    cout << a.at(2)*10+a.at(0)+a.at(1) << endl;
}

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

def solve():
    R, G, B, N = map(int, input().split())
    dp = [[0 for __ in range(8)] for _ in range(6002)]
    for n in range(1,N+1):
        if n == R:
            dp[R][4] += 1
        if n == G:
            dp[G][2] += 1
        if n == B:
            dp[B][1] += 1

        dp[n][1] += dp[n-B][1]
        dp[n][2] += dp[n-G][2]
        dp[n][3] += (dp[n-G][1] + dp[n-G][3] + dp[n-B][2] + dp[n-B][3])//2
        dp[n][4] += dp[n-R][4]
        dp[n][5] += (dp[n-R][1] + dp[n-R][5] + dp[n-B][4] + dp[n-B][5])//2
        dp[n][6] += (dp[n-R][2] + dp[n-R][6] + dp[n-G][4] + dp[n-G][6])//2
        dp[n][7] += (dp[n-R][3] + dp[n-R][7] + dp[n-G][5] + dp[n-G][7] + dp[n-B][6] + dp[n-B][7])//3
    return str(sum(dp[N]))

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



Measured memory_bytes: 4192
a = input()
list = list(map(int,input().split()))
b = len(list)
gcd = int(list[0])
for i in range(b):
	m = list[i] 
	n = gcd
	while n != 0:
		m,n = n,m%n
	if(m<gcd):
		gcd = m
print(gcd)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int N,cut=0,ans=0;
  cin >> N;
  vector<long long int> num(N);
  for (int i=0;i<N;i++){
    cin >> num[i];
    if (num[i]<0){
      cut++;
      num[i]*=-1;
    }
    ans+=num[i];
  }
  sort(num.begin(),num.end());
  if(cut%2==1){
    ans-=2*num[0];
  }
  cout << ans << endl;
}
  
  


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 233333;
int n,f[N][5];char s[N];
int main() {
	scanf("%s",s+1);n=strlen(s+1);
	rep(i,1,4)if(i<=n)f[i][i]=1;
	rep(i,1,n)rep(j,1,4)rep(k,1,4)if(i+k<=n){
		if(j!=k)umax(f[i+k][k],f[i][j]+1);
		else{
			bool ok=1;
			rep(l,1,j)ok&=s[i-j+1]==s[i+l];
			if(!ok)umax(f[i+k][k],f[i][j]+1);
		}
	}
	int res=0;rep(i,1,4)umax(res,f[n][i]);
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    string s;
    string ans="";
    cin >> s;
    int len = s.length();
    for(int i=0; i<len ; i++){
        if(s[i]=='1'){
            ans.push_back(s[i]);
        }else if(s[i]=='0'){
            ans.push_back(s[i]);
        }else if(s[i]=='B'){
            if(!ans.empty()){
                ans.pop_back();
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
using namespace std;
typedef bitset<32> b8;
int main(){
	unsigned int n;
	cin>>n;
	b8 b(n);
	cout<<b<<endl;
	cout<<~b<<endl;
	cout<<(b<<1)<<endl;
	cout<<(b>>1)<<endl;
}



Measured memory_bytes: 3176
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class AUOIAUAI {
        private static final String YES = "vowel";
        private static final String NO = "consonant";
        private static final int[] VOWELS = {'a', 'e', 'i', 'o', 'u'};

        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            char c = in.string().charAt(0);
            if (Arrays.stream(VOWELS).anyMatch(x -> x == c)) {
                out.println(YES);
            } else {
                out.println(NO);
            }
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 26708
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
  int s,w;
  cin >> s >> w;
  if(w >= s){
    cout << "unsafe" << endl;
    return 0;
  }else{
    cout << "safe" << endl;
    return 0;
  }
}

Measured memory_bytes: 3588
import java.util.*;
public class Main {
	
	private void doit(){
		Scanner sc =new Scanner(System.in);
		int da = sc.nextInt();
		while(da-- > 0){
			long n = sc.nextLong();
			int count = 0;
			long max = n;
			while(true){
				if(max < 10){
					System.out.println(count);
					break;
				}
				max = solve(max);
				if(max >= n){
					System.out.println(-1);
					break;
				}
				count++;
			}
		}
	}

	private int solve(Long num) {
		String n = "" + num;
		int max = 0;
		for(int i = 1 ; i <n.length(); i++){
			int left = Integer.parseInt(n.substring(0, i));
			int right = Integer.parseInt(n.substring(i));
			int res = left * right;
			max = Math.max(max, res);
		}
		return max;
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

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

int main()
{
    string S;
    cin >> S;
    reverse(S.begin(),S.end());
    int i=0;
    bool truth=1;
    while ((i<S.size()-1) & truth)
    {
        if (S[i]=='m')
        {
            if ((S[i+1]=='a') & (S[i+2]=='e') & (S[i+3]=='r') &(S[i+4]=='d')) i=i+5;
            else
            {
                truth=0;
            }
        }
        if (S[i]=='e')
        {
            if ((S[i+1]=='s') & (S[i+2]=='a') & (S[i+3]=='r') &(S[i+4]=='e')) i=i+5;
            else
            {
                truth=0;
            }
        }
        if (S[i]=='r')
        {
            if ((S[i+1]=='e') & (S[i+2]=='s') & (S[i+3]=='a') &(S[i+4]=='r') &(S[i+5]=='e')) i=i+6;
            else
            {
                if ((S[i+1]=='e') & (S[i+2]=='m') & (S[i+3]=='a') &(S[i+4]=='e') &(S[i+5]=='r') & (S[i+6]=='d')) i=i+7;
                else
                {
                    truth=0;
                }
            }
        }
    }
    if (truth) cout << "YES" << endl;
    else
    {
        cout << "NO" << endl;
    }
return 0;
}

Measured memory_bytes: 512
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)


int main()
{
    
    ll n,m;
    lscf(n),lscf(m);
  
    ll a=1;
 

    for(ll i=m/n;i>1;i--)
    {
        if((m-i*n)%i==0)
        {
            a=i;
            break;
        }
        
    }
    
    
    
    lprin(a);

}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
using namespace std;
const int N=1e5+100;
struct node{
	int a[N];
};int n;
node cheng(node n1,node n2){
	node no;
	for(int i=1;i<=n;i++) no.a[i]=n2.a[n1.a[i]];
	return no;
}
node ni(node n1){
	node no;
	for(int i=1;i<=n;i++) no.a[n1.a[i]]=i;
	return no;
}
node mi(node x,int t){
	node d;
	for(int i=1;i<=n;i++) d.a[i]=i;
	while(t){
		if(t%2) d=cheng(d,x);
		x=cheng(x,x);t/=2;
	}
	return d;
}
int main()
{
	int K;
	scanf("%d%d",&n,&K);
	node n1,n2;
	for(int i=1;i<=n;i++) scanf("%d",&n1.a[i]);
	for(int i=1;i<=n;i++) scanf("%d",&n2.a[i]);
	/*if(K<=2){
		for(int i=1;i<=n;i++){
			if(K==1) printf("%d",n1.a[i]);
			else printf("%d",n2.a[i]);
			if(i<n) printf(" ");
			else printf("\n");
		}
		return 0;
	}*/
	node A=cheng(ni(n2),n1);
	A=cheng(A,n2);A=cheng(A,ni(n1));
	int t=(K-1)%6+1;
	if(t>=2){
		for(int i=3;i<=t;i++){
			node T=n2;
			n2=cheng(ni(n1),n2);
			n1=T;
		}
		n1=n2;
	}
	A=mi(A,(K-t)/6);
	node ans=cheng(A,n1);ans=cheng(ans,ni(A));
	for(int i=1;i<=n;i++){
		printf("%d",ans.a[i]);
		if(i<n) printf(" ");
		else printf("\n");
	}
	return 0;
}

Measured memory_bytes: 7988
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=3e3;
double dp[maxn][maxn];
double a[maxn];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	dp[1][1]=a[1];
	dp[1][0]=1.0000000-a[1];
	for(int i=2;i<=n;++i)
		for(int j=0;j<=i;++j)
			if(j==0){
				dp[i][j]=dp[i-1][j]*(1.0000-a[i]);
				continue;
			}
			else dp[i][j]=dp[i-1][j-1]*a[i]+dp[i-1][j]*(1.00000-a[i]);
	double ans=0.00;
	for(int i=(n+1)/2;i<=n;++i)
		ans+=dp[n][i];
	printf("%.10f\n",ans);
				
			
	return 0;
} 

Measured memory_bytes: 68992
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::Ordering;
pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}
impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();
        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();
        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}

fn main() {
    input! {
        n: usize,
        a: [u64;n],
        b: [u64;n],
        c: [u64;n]
    }
    let mut a = a;
    let mut b = b;
    let mut c = c;
    a.sort();
    b.sort();
    c.sort();

    let mut res = 0;
    for i in b {
        let ac = a.lower_bound(&i);
        let cc = n - c.upper_bound(&i);
        res += ac * cc;
    }
    println!("{}", res);
}


Measured memory_bytes: 12408
#include<iostream>
#include<cmath>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<deque>
#include<tuple>
#include<iomanip>
using namespace std;
#define int                  int64_t
#define double               long double
#define vi                   vector<int>
#define di                   deque<int>
#define si                   set<int>
#define vpii                 vector<pair<int,int>>
#define pi                   pair<int,int>
#define pub                  push_back
#define puf                  push_front
#define pob                  pop_back
#define pof                  pop_front
#define all(a)               (a).begin(),(a).end()
#define rall(a)              (a).rbegin(),(a).rend()
#define PI                   3.1415926535897932384626433832795
#define read(a)              for(auto& x:a) cin>>x
#define speak(a)             for(auto x:a) cout<<x<<' '
#define rep(i,s,n)           for(int i=s;i<n;++i)
#define repe(i,s,n)          for(int i=s;i<=n;++i)
#define repr(i,n,s)          for(int i=n;i>=s;--i)
#define endl                 '\n'
#define gap                  ' '
#define MAX                  LLONG_MAX
#define MIN                  LLONG_MIN
#define min3(a,b,c)          min(a, min(b, c))
#define max3(a,b,c)          max(a, max(b, c))
#define MOD                  5000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int N = 1e5 + 100;
bool p[N];
vector <int> d;
void solve() {
    for (int i = 2; i < N; ++i)
        if (!p[i]) {
            d.pub(i);
            for (int j = i * i; j < N; j += i)
                p[j] = 1;
        }
    int n; cin >> n;
    cout << *lower_bound(all(d), n);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
}


Measured memory_bytes: 3880
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG


signed main() {
  int N; cin >> N;
  vector<int> L(N);
  rep(i, N) cin >> L[i];
  
  sort(all(L));
  
  int ans = 0;
  rep(i, N) for(int j=i+1; j<N; j++) {

    ans += max((int)(0), (int)(distance(upper_bound(L.begin()+j+1, L.end(), L[j]-L[i]), lower_bound(L.begin()+j+1, L.end(), L[j]+L[i]))));
    //cout << L[i] << " " << L[j] << " " << ans << endl;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3588