akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

class UnionFind {
  vector<int> info;
  // 親、もしくは根の場合はそのsize*-1
  int num_group;

public:
  UnionFind(int n) {
    info.assign(n, -1);
    num_group = n;
  }

  int find_root(int x) {
    return info[x] < 0 ? x : info[x] = find_root(info[x]);
  }

  void unite(int x, int y) {
    // union-by-size
    int rx = find_root(x);
    int ry = find_root(y);
    if (rx == ry)
      return;
    if (info[rx] > info[ry])
      swap(rx, ry);
    info[rx] += info[ry];
    info[ry] = rx;
    num_group--;
  }

  bool is_same_group(int x, int y) { return find_root(x) == find_root(y); }

  int get_group_size(int x) { return -info[find_root(x)]; }

  int get_num_of_groups() { return num_group; }
};

int main() {
  int n, m;
  cin >> n >> m;
  auto uf = UnionFind(n);
  int x, y, z;
  for (int i = 0; i < m; i++) {
    cin >> x >> y >> z;
    x--;
    y--;
    uf.unite(x, y);
  }
  cout << uf.get_num_of_groups() << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); i++)

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  REP(i, N) {
    ll a;
    cin >> a;
    ans = __gcd(a, ans);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3580
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a=sc.nextInt();
    int b=a/15;
    System.out.println(800*a-200*b);
  }
}

Measured memory_bytes: 21844
def main():
    x = int(input())

    ans = 1
    for b in range(2, x + 1):
        for p in range(2, x + 1):
            cand = b ** p
            if cand > x: break
            ans = max(ans, cand)
    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
#
# sys.setrecursionlimit(10 ** 7)
#
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


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

int main(){
  cout << fixed << setprecision(5);
  int a, b;
  cin >> a >> b;
  int d = a / b;
  int r = a % b;
  double f = (double)a / (double)b ;
  cout << d << " " << r << " " << f << endl;
}



Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c; cin>>a>>b>>c;
    cout << min(b/a, c) <<endl;
}

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

int main(){
  int h,w;
  cin>>h>>w;
  char s[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>s[i][j];
    }
  }
  bool flag=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='.') continue;
      if(i>0){
        if(s[i-1][j]=='#') continue;
      }
      if(j>0){
        if(s[i][j-1]=='#') continue;
      }
      if(i<h-1){
        if(s[i+1][j]=='#') continue;
      }
      if(j<w-1){
        if(s[i][j+1]=='#') continue;
      }
      flag=1;
      break;
    }
    if(flag) break;
  }
  if(flag){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
  return 0;
}


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

int main()
{
    int H,N,A = 0;
    cin >> H >> N;
    for (int i = 0; i < N ;i++)
    {
        cin >> A;
        H -= A;
        if (H <= 0)
        {
            cout << "Yes" << endl;
            break;
        }
    }
    if (H > 0)
    {
        cout << "No" << endl;
    }

}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;
int N,W;
int w[200];
int s[200];

int dp[10001];

signed main(){
    cin>>N>>W;
    rep(i,N)cin>>w[i];
    sort(w,w+N);
    rep(i,N)s[i]=w[i]+(i?s[i-1]:0);

    if(s[N-1]<=W){
        cout<<1<<endl;
        return 0;
    }

    dp[0]=1;
    int ans=0;
    for(int i=N-1;i>=0;i--){
        for(int j=W-s[i]+1;j<=W-s[i]+w[i];j++)if(j>=0)ans=(ans+dp[j])%mod;
        for(int j=W-w[i];j>=0;j--)dp[j+w[i]]=(dp[j+w[i]]+dp[j])%mod;
    }

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

Measured memory_bytes: 1248
#include <stdio.h>
#include <string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar (char ch)
{
	if (ch=='A') return 1;
	else if (ch=='C') return 2;
	else if (ch=='G') return 3;
	else if (ch=='T') return 4;
	else return 0;
}

long long getKey(char str[])
{
	long long sum=0,p=1,i;
	for (i=0;i<strlen(str);i++)
	{
		sum+=p*(getChar(str[i]));
		p*=5;
	}
	return sum;
} 

int h1(int key)
{
	return key%M;
}

int h2(int key)
{
	return 1+(key%(M-1));
}

int find (char str[])
{
	long long key,i,h;
	key=getKey(str);
	for(i=0;;i++)
	{
		h=(h1(key)+i*h2(key))%M;
		if (strcmp(H[h],str)==0) return 1;
		else if (strlen(H[h])==0) return 0;
	} 
	return 0;
}

int insert (char str[])
{
	long long key,i,h;
	key=getKey(str);
	for (i=0;;i++)
	{
		h=(h1(key)+i*h2(key))%M;
		if (strcmp(H[h],str)==0) return 1;
		else if (strlen(H[h])==0)
		{
			strcpy(H[h],str);
			return 0;
		}
	}
}
int main ()
{
	int i,n,h;
	char str[L],com[9];
	for (i=0;i<M;i++) H[i][0]='\0';
	scanf ("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf ("%s %s",com,str);
		if (com[0]=='i')
		{
			insert(str);
		}
		else {
			if (find(str)) printf ("yes\n");
			else printf ("no\n");
		}
	}
	return 0;
}


Measured memory_bytes: 17020
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <queue>

using namespace std;

long long n,k,a[200010],dif;

int main()
{
    cin>>k>>n;
    for (int i=0;i<n;i++) cin>>a[i];
    dif=a[0]+(k-a[n-1]);
    for (int i=1;i<n;i++){
        if (a[i]-a[i-1]>dif){
            dif=a[i]-a[i-1];
        }
    }
    cout<<k-dif<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

ll b[]={1,-1};

ll N,M;
ll x[1000];
ll y[1000];
ll z[1000];

int main(){
    cin>>N>>M;
    rep(i,N) cin>>x[i]>>y[i]>>z[i];

    ll ans=0;
    rep(i,2){
        rep(j,2){
            rep(k,2){
                vector<ll> v(N,0);
                rep(l,N){
                    v[l]+=x[l]*b[i];
                    v[l]+=y[l]*b[j];
                    v[l]+=z[l]*b[k];
                }
                sort(v.begin(),v.end(),greater<>());
                ll res=0;
                rep(l,M) res+=v[l];
                ans=max(ans,res);
            }
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  while (cin >> N, N) {
    int cnt = 0;
    bool isNA = false;
    while (N != 6174) {
      int tmp[20];
      rep(i, 4) {
        tmp[i] = N % 10;
        N /= 10;
      }
      if( tmp[0] == tmp[1] && tmp[1] == tmp[2] && tmp[2] == tmp[3] ) {
        isNA = true;
        break;
      }
      else {
        sort(tmp, tmp + 4, greater<int>());
        int L = tmp[0] * 1000 + tmp[1] * 100 + tmp[2] * 10 + tmp[3];
        int S = tmp[3] * 1000 + tmp[2] * 100 + tmp[1] * 10 + tmp[0];
        N = L - S;
        ++cnt;
        if( N == 6174 ) break;
      }
    }
    if( isNA ) cout << "NA" << endl;
    else cout << cnt << endl;
  }
  return 0;
}



Measured memory_bytes: 3132
n,k=map(int,input().split())
dp2=list(map(int,input().split()))
    
k=min(k,41)
for ki in range(1,k+1):
    ims=[0]*(n+1)
    for ni in range(n):
        if 0>ni-dp2[ni]:
            ims[0]+=1
        else:
            ims[ni-dp2[ni]]+=1
        if n<ni+dp2[ni]+1:
            ims[n]-=1
        else:
            ims[ni+dp2[ni]+1]-=1

    dp2[0]=ims[0]
    for ni in range(1,n):
        dp2[ni]=dp2[ni-1]+ims[ni]
    
for i in range(n):
    print(dp2[i],end=" ")
print()


Measured memory_bytes: 156972
#include<iostream>
using namespace std;
using ll=long long;

int main(){
    int N;
    cin>>N;
    int A[N+1];
    for(int i=1;i<=N;i++){
        cin>>A[i];
    }
    ll sum=1000;
    for(int i=1;i+1<=N;i++){
        if(A[i]<A[i+1]){
            ll cnt=sum/A[i];
            sum+=cnt*(A[i+1]-A[i]);
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    s = 'S' + s + 'S';
    int x = s.length();
    int m = 0,count = 0,min = 0;
    for(int i = 0;i<x;i++){
        if(s[i] == 'R'){
            min = 1;
        }
        if(s[i] == s[i+1] && s[i] == 'R'){
            count++;
        }
        else{
            count = 0;
        }
        if(count>m){
            m = count;
        }
    }
    if(min == 1){
        m++;
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main()
{
    int i, j, k, h, w;
   
    cin >> h >> w;
    while(h>0 || w>0)
    {
        for(i=1; i<=h; i++)
        {
            for(j=1; j<=w; j++)
            {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;
    rep(i, n)
    {
        char s;
        cin >> s;
        if (s == 'Y')
        {
            OP("Four");
            return 0;
        }
    }

    OP("Three");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main(){
  int n,m ;
  cin >>n>> m ;
  graph g(n) ;//nは頂点数
  rep(i,m){
  int a,b ;
  cin>> a>> b;
  a--;b--;
  g[a].pb(b) ;
  g[b].pb(a) ;
  }
 //ここからbfs
 
 vector<int> dist(n,-1) ;// n全て-1
 queue<int> q ;
  dist[0] =0 ;//通った頂点０との距離を記録
  q.push(0) ;
  //すたーと
  while(!q.empty()){ //qが空になるまで
  int v=q.front() ;
      q.pop() ;//出して記録してすぐ消す

      for(int u:g[v]){
        if(dist[u]!=-1) continue;//無視
        dist[u]=v;//親を記録
        
        q.push(u) ;}
  }
   //全部の距離がdistに記録済み

    cout <<"Yes"<<endl;
    rep(i,n-1) cout<<dist[i+1]+1<<endl;
    return 0;
  }

Measured memory_bytes: 10152
/*
        |___________________________Arshit Mangukiya_____________________________|
        |_______________________________DA-IICT__________________________________|
        |_____________________________201801173__________________________________|
*/
        /*______________________WRITE  YOUR  CODE  HERE_________________________*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;            
typedef long double ld;
#define ff first
#define ss second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define all(a)      a.begin(),a.end()
//#define F(i,n) for(ll i=0;i<n;i++)
#define MOD 1000000007
#define MAX 200005
#define sz size()
#define p(x) 		cout<< x << " ";
#define pe(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
		const ll N=1e5;
		ll i,j,k;
    		bool fun(pair<int,int>a , pair<int,int>b)
			{
				if(a.ff == b.ff)	return a.ss < b.ss;
				else			return a.ff > b.ff;
			}
	bool fun(string s,string t)
	{
		ll c=0;
		for(ll i=0;i<s.sz;i++)
		{
			if(c<t.sz && s[i]==t[c])c++;
			
		}
		return c==t.sz;
	}
	signed main(){
	FAST;
	ll n,m,sum=0;
	cin>>n>>m;
	cout<<min(n%m,abs(n%m -m));
	
}
	
				


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

namespace AtCoder.abc111 {
    class ProgramA {
        /**
         * in
         *  112
         * out
         *  222
         */
        main(inp: string): void {
            const n: number = parseInt(inp, 10);
            for (let i: number = 0; i < 1000; i++) {
                if ((n + i) % 111 === 0) {
                    console.log(n + i);
                    break;
                }
            }
        }
    }

    const func = new ProgramA();
    func.main(fs.readFileSync('/dev/stdin', 'utf8').trim());
}


Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
int INF = pow(2,31) - 1;
int n;
void powset(int size){
  n = 1;
  while( n < size ) n *= 2;
}

struct RMQ{
  vector< int > seg;
  void update( int i, int x){
    i += n - 1;
    seg[i] = x;
    while(i > 0){
      i = ( i - 1 ) / 2;
      seg[i] = min( seg[i * 2 + 1], seg[i * 2 + 2]);
    }
  }
  int query( int a, int b, int k, int l, int r){
    if( r <= a || b <= l ) return INF;
    if( a <= l && r <= b ) return seg[k];
    int vl = query( a, b, k * 2 + 1, l, (l + r) / 2);
    int vr = query( a, b, k * 2 + 2, (l + r) / 2, r);
    return min( vl, vr);
  }
  int query( int a, int b){
    return query( a, b, 0, 0, n);
  }
  RMQ(){
    seg.assign( n * 2 - 1, INF);
  }
};

int main(){
  int R, C, Q;
  while(scanf("%d %d %d", &R, &C, &Q), R){
    if(R < C){
      powset(C);
      vector< RMQ > rmq( R, RMQ());
      for(int i = 0; i < R; i++){
        for(int j = 0; j < C; j++){
          int grid;
          scanf("%d", &grid);
          rmq[i].update(j,grid);
        }
      }
      while(Q--){
        int r1, c1, r2, c2;
        scanf("%d %d %d %d", &r1, &c1, &r2, &c2);
        int ret = INF;
        for(int i = r1; i <= r2; i++){
          ret = min( ret, rmq[i].query( c1, c2 + 1));
        }
        printf("%d\n", ret);
      }
    }else{
      powset(R);
      vector< RMQ > rmq( C, RMQ());
      for(int i = 0; i < R; i++){
        for(int j = 0; j < C; j++){
          int grid;
          scanf("%d",&grid);
          rmq[j].update(i,grid);
        }
      }
      while(Q--){
        int r1, c1, r2, c2;
        scanf("%d %d %d %d", &r1, &c1, &r2, &c2);
        int ret = INF;
        for(int i = c1; i <= c2; i++){
          ret = min( ret, rmq[i].query( r1, r2 + 1));
        }
        printf("%d\n", ret);
      }
    }
  }
}

Measured memory_bytes: 17488
#include <stdio.h>

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


Measured memory_bytes: 2148
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int k = scanner.nextInt();
			scanner.nextLine();
			char[] s = scanner.nextLine().toCharArray();
			List<Result> list = new ArrayList<>();
			int max = 0;
			boolean isOne;
			if (s[0] == '0') {
				list.add(new Result(k, 0, 0));
				isOne = true;
			} else {
				isOne = false;
			}
			for (int i = 0; i < s.length; i++) {
				if (isOne && ('0' == s[i])) {
					for (int j = 0; j < list.size(); j++) {
						Result result = list.get(j);
						if (result.k > 0) {
							result.k--;
						} else {
							result.count = i - result.start;
							if (result.count > max) {
								max = result.count;
							}
							list.remove(j);
							j--;
						}
					}
					isOne = false;
				} else if (!isOne && ('1' == s[i])) {
					if (i < n - max) {
						list.add(new Result(k, i, 0));
					}
					isOne = true;
				}
			}
			if (!list.isEmpty()) {
				Result result = list.get(0);
				result.count = n - result.start;
				if (result.count > max) {
					max = result.count;
				}
			}
			System.out.println(max);
		}
	}

	private static class Result {
		int k;
		int start;
		int count;

		Result(int k, int start, int count) {
			super();
			this.k = k;
			this.start = start;
			this.count = count;
		}

		@Override
		public String toString() {
			return "k=" + k + ",start=" + start + ",count=" + count;
		}
	}
}


Measured memory_bytes: 27476
#include<bits/stdc++.h>
#define Abra_Ka_Dabra ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;

const long long mod = 1e9 + 7;
const double PI = acos(-1);
const double EPS = 1e-9;

bool comp(pair<int, int> a, pair<int, int> b) {
	if (a.second == b.second) return a.first > b.first;
	return a.second < b.second;
}

bool isLeap(int a) {
	if (a % 100 == 0) {
		if (a % 400 == 0) return true;
		else return false;
	} else if (a % 4 == 0) return true;
	return false;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

	Abra_Ka_Dabra

	ll n;
	cin >> n;
	cout << 1000 * (n / 500) + ((n % 500) / 5) * 5 << "\n";

	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<stack>

using namespace std;
int main(){
	int n; cin >> n;
	stack<string> stack;
	for (int i = 0; i < n; i++){
		string str; cin >> str;
		if (str == "A"){
			stack.push("A");
		}else if (str == "Un"){
			if (stack.empty()){
				cout << "NO" << endl;
				return 0;
			}
			stack.pop();
		}
	}
	if (stack.empty()){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
		
return 0;
}

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

int main()
{
     int a,b,c,d;
     while(~scanf("%d%d%d%d",&a,&b,&c,&d))
     {
         if(a*b>c*d)
            printf("%d\n",a*b);
         else printf("%d\n",c*d);
     }return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
    int n; cin >> n;
    if (n == 1) {
        cout << 1 << endl;
        cout << 0 << endl;
    }
    else if (n == 2) {
        cout << 2 << endl;
        cout << 0 << endl;
        cout << 11 << endl;
    }
    else {
        cout << n - 1 << endl;
        for (int i = 2; i <= n; i++) {
            cout << 1;
            for (int j = 0; j < i - 2; j++) {
                cout << 0;
            }
            cout << 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3104
from math import *
PI = 3.1415926535898
x = "this"
y = "the"
z = "that"
while True:
	try:
		s = str(raw_input())
		res = ""
		ans = ""
		for i in range(26):
			res = ""
			for a in s:
			 	if a.isalpha():
			 		c = chr(ord(a) + i)
			 		if ord(c) > ord('z'):
			 			c = chr(ord(c) - 26)
			 		elif ord(c) < ord('a'):
			 			c = chr(ord(c) + 26)
			 		res += c
			 	else:
			 		res += a
			if res.find(x) >= 0 or res.find(y) >= 0 or res.find(z) >= 0:
				ans = res
		print ans
	except EOFError:
		break

Measured memory_bytes: 6516
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define cont continue  
#define rep(i, n) for(int i = 0 ; i < (n) ; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 2147483646;
const double pi = 3.141592653589793;



int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);

  int v;
  int max_col = 0;
  vector< vector<pii> > adj(200001);

  cin >> v;
  int color[200001] = {};
  queue< pair<int, int> > q;
  for(int i = 0 ; i < v - 1 ; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].pb(mp(b,i));
  }
  q.push(mp(1, 0));

  while(!q.empty()) {
    int p_color = q.front().second;
    int cur = q.front().first;
    q.pop();
    set<int> c;
    c.insert(p_color);
    int s_color = 1;
    for(int i = 0 ; i < adj[cur].size() ; i++) {
      int nxt = adj[cur][i].first;
      int idx = adj[cur][i].second;
      if(s_color == p_color) {
        s_color++;
      }
      color[idx] = s_color;
      q.push(mp(nxt, s_color));
      max_col = max(max_col, s_color);
      s_color++;
    }
  }

  cout << max_col << endl;
  for(int i = 0 ; i < v - 1 ; i++) {
    cout << color[i] << endl;
  }
} 

Measured memory_bytes: 7936
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        h: usize,
        w: usize,
        v: [chars; h]
    }
    let mut r = vec![vec!['.'; w]; h];
    let mut b = vec![vec!['.'; w]; h];
    for i in 0..h {
        r[i][0] = '#';
        b[i][w - 1] = '#';
        for j in 1..w - 1 {
            if i % 2 == 0 || v[i][j] == '#' {
                r[i][j] = '#';
            }
            if i % 2 == 1 || v[i][j] == '#' {
                b[i][j] = '#';
            }
        }
    }
    for l in &r {
        println!("{}", l.iter().cloned().collect::<String>());
    }
    println!("");
    for l in &b {
        println!("{}", l.iter().cloned().collect::<String>());
    }
}


Measured memory_bytes: 6908
#include "bits/stdc++.h"
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define all(V) (V).begin(), (V).end() 
using namespace std;
typedef long long ll;

int main() {fio;
	int N, M;
	cin >> N >> M;
	vector <int> d(N, 0);
	int a, b;
	while(cin >> a >> b) {
		d[a - 1] ^= 1;
		d[b - 1] ^= 1;
	}
	cout << (count(all(d), 1) ? "NO" : "YES");
    return 0;
}

Measured memory_bytes: 3720
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
        ll x;
        scanf("%ld", &x);
        rep(i, -150, 151){
                rep(j, -150, 151){
                        if(i*i*i*i*i-j*j*j*j*j==x){
                                printf("%ld %ld\n", i, j);
                                return 0;
                        }
                }
        }
        return 0;
}

Measured memory_bytes: 3780
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int q = sc.nextInt();
			Map<String, Integer> m = new HashMap<>();
			for(int i = 0; i < q; i++) {
				int query = sc.nextInt();
				switch(query) {
				case 0:
					m.put(sc.next(), sc.nextInt());
					break;
				case 1:
					System.out.println(m.get(sc.next()));
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 194828
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
const int INF = 1e9+7;

int main(int argc, char **argv)
{
	int a, b;
	char *op = "==";
	scanf("%d %d", &a, &b);
	if (a < b) op = "<";
	if (a > b) op = ">";
	printf("a %s b\n", op);
	return 0;
}

Measured memory_bytes: 592
N = int(input())
targets = []
for i in range(N):
    targets.append([int(x) for x in input().split()])

now = [0,0]
now_t = 0

for target in targets:
    distance = abs(now[0] - target[1]) + abs(now[1] - target[2])
    limit = target[0] - now_t
    if distance > limit :
            print("No")
            exit()
    elif (distance - limit) %2 !=0:
            print("No")
            exit()
    else:
            now[0] = target[1]
            now[1] = target[2]
            now_t  = target[0]
print("Yes")

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 2e5+5;

const ll MOD = 1000000007LL;

void solve() {

}

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

    int n;
    cin >> n;
    vector<pair<ll, ll>> jobs(n);

    for (int i=0; i<n; i++) {
        cin >> jobs[i].second >> jobs[i].first;
    }
    sort(jobs.begin(), jobs.end());
    ll time = 0;

    for (int i=0; i<n; i++) {
        time += jobs[i].second;
        if (time > jobs[i].first) {
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";


    return 0;
}


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

int getDigit(int in) {
  int threshold = 10;
  for(int i=0; i<10; i++) {
    if(in < threshold) return i+1;
    threshold *= 10;
  }
  return -1;
}

int main(){
  int in1,in2;

  while( cin >> in1 >> in2 ) {
    cout << getDigit(in1+in2) << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var numsS = new int[n + 1];
            {
                var strs = Console.ReadLine().TrimEnd().Split();
                var j = 0;
                while (n != j)
                {
                    numsS[j] = int.Parse(strs[j]);
                    j++;
                }
            }
            Console.ReadLine();
            var numsT = Array.ConvertAll(Console.ReadLine().TrimEnd().Split(), int.Parse);
            int ans = 0;

            for (int i = 0; i < numsT.Length; i++)
            {
                numsS[n] = numsT[i];
                var j = 0;
                while (numsS[j] != numsT[i])
                {
                    j++;
                }
                if (n != j) ans++;

            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 19952
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

vector<int> divisor;



ll llmax(ll x, ll y){
	if (x > y) return x;
	return y;
}

int main(){
	int n, m;
	cin >> n >> m;

	for (int i = 1; i <= sqrt(m); i++){
		if (m % i == 0){
			divisor.push_back(i);
			divisor.push_back(m/i);
		}
	}
	sort (divisor.begin(), divisor.end());
	for (int i = 0; i < divisor.size(); i++){
		if (divisor[i] >= n){
			cout << m/divisor[i] << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(long long int*)a - *(long long int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int N, M;
  scanf("%d %d", &N, &M);
  long long int A[MAX];
  rep(i, 0, N) scanf("%lld", &A[i]);

  // 累積和(A_l~A_rの合計 → sum[r]-sum[l-1])
  long long int sum[MAX] = {0};
  rep(i, 0, N) {
    sum[i + 1] = sum[i] + A[i];
  }

  long long int ans = 0;
  rep(i, 1, N + 1) {
    sum[i] %= M; 
  }
  qsort(sum, N + 1, sizeof(lli), acs);

  long long int cnt = 1;
  rep(i, 0, N) {
    if ( sum[i] == sum[i + 1] )
      cnt++;
    else {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  ans += cnt * (cnt - 1) / 2;
  printf("%lld\n", ans);
  return 0;
}


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

int main(){
    int N, x;
    cin >> N;
    int ans[N+1];
    for(int i=1; i<N+1; i++){
        cin >> x;
        ans[x] = i;
    }
    for(int i=1; i<N; i++){
        cout << ans[i] << " ";
    }
    cout << ans[N] << endl;
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,j=0;
    cin>>a;
    long long int b[a],c[a]={0};
    for(int i=0;i<a;i++) cin>>b[i];
    sort(b,b+a);
    reverse(b,b+a);
    for(int i=1;i<a;i++){
        if(b[i]==b[i-1]) {
            c[j]=b[i];
            j++;
            b[i]=-1;
            b[i-1]=-1;
        }
    }
    cout<<c[0]*c[1]<<endl;
}


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

#ifdef DONLINE_JUDGE
//freopen("a.in", "r", stdin);
//freopen("a.out","w",stdout); // console output is better (in most cases)
#else
// add i/o method of specific testing system
#endif

using namespace std;

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

    bool card[4][14];
    memset(card, 0, sizeof(card));
    int n;
    cin >> n;
    while (n--)
    {
        char s;
        int r;
        cin >> s >> r;
        switch (s)
        {
        case 'S':
            card[0][r] = true;
            break;
        case 'H':
            card[1][r] = true;
            break;
        case 'C':
            card[2][r] = true;
            break;
        case 'D':
            card[3][r] = true;
            break;
        }
        //cout << n << endl;
    }
    for (int i = 0; i < 4; ++i)
    {
        char s;
        switch (i)
        {
        case 0:
            s = 'S';
            break;
        case 1:
            s = 'H';
            break;
        case 2:
            s = 'C';
            break;
        case 3:
            s = 'D';
            break;
        }
        for (int j = 1; j <= 13; ++j)
        {
            if (!card[i][j])
                cout << s << " " << j << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3124
N = int(input())
Numbers = {}
A = list(map(int,input().split()))
for i in range(N):
    Av = A.pop()
    if Av not in Numbers:
        Numbers[Av] = 1
    else:
        Numbers[Av] += 1
Ans = 0
for v,i in Numbers.items():
    Ans += v*i
Q = int(input())
for i in range(Q):
    B,C = map(int,input().split())
    if B in Numbers:
        Mo = Numbers[B]
        if C not in Numbers:
            Numbers[C] = Mo
            Numbers[B] = 0
        else:
            Numbers[C] += Mo
            Numbers[B] = 0
        Ans += Mo *C - Mo*B
        print(Ans)
    else:
        print(Ans)

Measured memory_bytes: 20584
#include <stdio.h>
#include <array>
#include <bitset>
#include <vector>
#include <tuple>
#include <queue>

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

constexpr int N = 700;
std::array<std::bitset<N>, N> E;
std::array<int, N> D;
std::bitset<N+1> P, PP;

int main(void){
    int n, m; scanf("%d%d", &n, &m);
    REP(i, n){ E[i].flip(); E[i][i] = false;}
    REP(_, m){
        int a, b; scanf("%d%d", &a, &b); a--; b--;
        E[a][b] = false; E[b][a] = false;
    }
    std::queue<int> Q;
    std::vector<std::pair<int, int>> S;
    REP(i, n) if(D[i] == 0){
        std::array<int, 2> A{0, 0};
        Q.push(i);  D[i] = 1; A[0]++;
        while(not Q.empty()){
            int v = Q.front(); Q.pop();
            int nm = (D[v] & 1) + 1;
            REP(u, n) if(E[u][v]){
                if(D[u] == 0){ D[u] = nm; Q.push(u); A[nm-1]++;}
                else if(D[u] != nm){ puts("-1"); return 0; }
            }
        }
        S.emplace_back(A[0], A[1]);
    }
    P[0] = true;
    for(auto& itr : S) PP = (P << itr.first) | (P << itr.second), std::swap(P, PP);
    int ans = 2e9;
    REP(i, n) if(P[i]){
        int p = i * (i - 1) + (n - i) * (n - i - 1); p /= 2;
        if(ans > p) ans = p;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
// nomura2020_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string T;
    cin >> T;

    string s = T;
    REP(i, T.size()){
        if (T[i] == '?'){
            s[i] = 'D';
        } else {
            s[i] = T[i];
        }
    }
    print(s);

//    int ans = 0;
//    REP(i, T.size()){
//
//        if (T[i] == 'P'){
//            if (i < T.size()-1){
//                if (T[i+1] == 'D'){
//                    ans++;
//                }
//            }
//        } else {
//            ans++;
//        }
//    }
//    print(ans);



    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,k,ma=0,g=0,a;
	cin >> n >> k;
	rep(i,n){
		cin >> a;
		chmax(ma,a);
		g=gcd(g,a);
	}
	if(k%g==0 && k<=ma) cout << "POSSIBLE\n";
	else cout << "IMPOSSIBLE\n";
	return 0;
}

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

int main() {
	int N, K, A[105] = { 0 }, d;
	cin >> N >> K;
	rep(i, K) {
		cin >> d;
		rep(j, d) {
			int a;
			cin >> a;
			A[a] += 1;
		}
	}
	int count = 0;
	rep(i, N) {
		if (A[i + 1] == 0) count += 1;
	}
	cout << count << endl;
	return 0;
}

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



int main(){
  int S;
  cin >> S;
  int tmp = S;
  int s = 0;
  while(tmp >= 1){
    s += tmp % 10;
    tmp = tmp / 10;
  }
  cerr << s << " " << S << endl;
  
  if(S % s == 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
  


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

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> v;
    for(int i = 1; i <= min(a, b); i++){
        if(a % i == 0 && b % i == 0){
            v.push_back(i);
        }
    }
    reverse(v.begin(), v.end());
    cout << v[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range (0, N):
	if A[i] == 0:
		ans = 0
		break
	else:
		if ans > 0:
			ans *= A[i]
		if ans > 10 ** 18:
			ans = -1

print(ans)

Measured memory_bytes: 21764
import java.util.Scanner;

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

		while (true) {
			int n = sc.nextInt();
			int r = sc.nextInt();
			if (n == 0 && r == 0) {
				break;
			}

			int[] w;
			w = new int[n];
			for (int i = 0; i < n; i++) {
				w[i] = n - i;
			}

			for (int i = 0; i < r; i++) {
				int[] a, b;
				int p = sc.nextInt();
				int c = sc.nextInt();
				a = new int[p - 1];
				b = new int[c];
				for (int j = 0; j < p - 1; j++) {
					a[j] = w[j];
				}
				for (int j = 0; j < c; j++) {
					b[j] = w[p - 1 + j];
				}
				for (int j = 0; j < c; j++) {
					w[j] = b[j];
				}
				for (int j = 0; j < p - 1; j++) {
					w[j + c] = a[j];
				}
			}

			System.out.println(w[0]);

		}

	}
}


Measured memory_bytes: 37812
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		int ans = 100100;
		for(long i = 1 ; i * i <= n ; i++) {
			if(n % i == 0) {
				ans = Math.min(ans, kouta(i, n / i));
			}
		}
		System.out.println(ans);
	}

	public static int kouta(long i, long j) {
		int ret = 0;
		if(i >= j) {
			while(i > 0) {
				ret++;
				i /= 10;
			}
		} else {
			while(j > 0) {
				ret++;
				j /= 10;
			}
		}
		return ret;
	}

}


Measured memory_bytes: 23636
#include <iostream>
#include <algorithm>

#define SIZE 1001

using namespace std;

int main() {
    long  long int B,i,j,k,M,K,Q;
    long  long int X,N,Y,Z;
    long  long int P[SIZE];
    string S,T;

    cin >> S >> T;
    j = 0;
    for (i=0;i<S.length();i++) {
      if (S[i] != T[i])
        j++;
    }

      cout << j << endl;
  return 0;

}


Measured memory_bytes: 3904
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        calc(a,b);
        in.close();
    }
    
    public static void calc(int a,int b){
        int dev = a / b;
        int surplus = a % b;
        double devB = ((double)a / (double)b);
        System.out.printf("%d %d %f%n",dev,surplus,devB);
    }
}


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

#include <algorithm>

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<char>> f(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> f[i][j];
    }
  }
  int ans = INF;
  for (int bits = 0; bits < 1 << (H - 1); bits++) {
    int tmp = __builtin_popcount(bits);
    int size = __builtin_popcount(bits) + 1;
    vector<int> row(size, 0);
    bool flag = false;
    for (int i = 0; i < W; i++) {
      int cur = 0;
      int m = 0;
      for (int j = 0; j < H; j++) {
        if (f[j][i] == '1') row[cur]++;
        m = max(m, row[cur]);
        if ((bits >> j) & 1) cur++;
      }
      if (m > K) {
        if (flag) {
          tmp = INF;
          break;
        }
        tmp++;
        i--;
        flag = true;
        for (auto &x : row) x = 0;
        continue;
      }
      flag = false;
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.Map.*;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner();
		int n = sc.nextInt();
		List<Map.Entry<String, Integer>> list = new ArrayList<>();
		List<Entry<String, Integer>> l2 = new ArrayList<>();
		for(int i = 0;i < n; i++){
			String s = sc.next();
			int p = sc.nextInt();
			Entry<String, Integer> entry = new AbstractMap.SimpleEntry<>(s,p);
			l2.add(entry);
			list.add(entry);
		}
		Comparator<Entry<String, Integer>> comparator = new Comparator<Entry<String, Integer>>() {
			@Override
			public int compare(Map.Entry<String, Integer> stringIntegerEntry, Map.Entry<String, Integer> t1) {
				String s1 = stringIntegerEntry.getKey();
				String s2 = t1.getKey();
				if(s1.compareTo(s2) !=0)
					return s1.compareTo(s2);

				return -(stringIntegerEntry.getValue() - t1.getValue());
			}
		};

		Collections.sort(list, comparator);

		for(Entry<String, Integer> entry : list){
			System.out.println(l2.indexOf(entry) + 1);
		}
	}
}

class Scanner {
	private static final int SPACE = (int)' ';
	private static final int LINE_END_0 = 13;
	private static final int LINE_END_1 = 10;
	private static final int BEFORE = -1;
	private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public String next(){
		StringBuilder sb = new StringBuilder();
		
		int length = BEFORE;
		readLoop: while(true) {
			try {
				int value = br.read();
				switch(value) {
				case LINE_END_1:
					if(length == BEFORE)
						break;
					
					if((int)sb.charAt(length) == LINE_END_0)
						sb.deleteCharAt(length);
				case SPACE:
					break readLoop;
				}
				sb.append((char)value);
				length++;

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return sb.toString();
	}
	
	public String[] nextArray(int length) {
		String[] array = new String[length];
		for(int i = 0; i < length; i++)
			array[i] = next();
		return array;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	
	public double[] nextDoubleArray(int length) {
		double[] array = new double[length];
		for(int i = 0; i < length; i++)
			array[i] = nextDouble();
		return array;
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public int[] nextIntArray(int length) {
		int[] array = new int[length];
		for(int i = 0; i < length; i++)
			array[i] = nextInt();
		return array;
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
	
	public long[] nextLongArray(int length) {
		long[] array = new long[length];
		for(int i = 0; i < length; i++)
			array[i] = nextLong();
		return array;
	}
	
	public boolean ready() {
		try {
			return br.ready();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
}


Measured memory_bytes: 21460
//### In The Name Of GOD ###

//%% Remember; (((He))) is The (((Accepter))) %%

// GOD IS GREATER ...

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;

#define sz(a) (int)(a.size())

const int MAXN = 1e5 + 10, MAXD = 11;
int mark[MAXN], ans[MAXN];

struct relax{
	int v, d, c;
} a[MAXN];

vector <int> adj[MAXN];

void bfs(int v, int d, int c) {
	if(mark[v] >= d)
		return ;
	if(!ans[v])
		ans[v] = c;
	mark[v] = d;
	queue <pair <int, int>> q;
	q.push({v, d});
	while(sz(q)) {
		int v = q.front().first;
		int d = q.front().second;
		if(!ans[v])
			ans[v] = c;
		for(int i : adj[v]) {
			if(mark[i] < d - 1) {
				mark[i] = d - 1;
				q.push({i, d - 1});
			}
		}
		q.pop();
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	int q;
	cin >> q;
	for(int i = 0; i < q; i++) {
		cin >> a[i].v >> a[i].d >> a[i].c;
		a[i].v --;
	}
	for(int i = 0; i < n; i++)
		mark[i] = -1;
	reverse(a, a + q);
	for(int i = 0; i < q; i++) {
		bfs(a[i].v, a[i].d, a[i].c);
	}
	for(int i = 0; i < n; i++)
		cout << ans[i] << '\n' ;
}




Measured memory_bytes: 8952
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    for(int i = 0; i < N; i++){
        cin >> l.at(i);
    }
    sort(l.begin(), l.end(), greater<int>());
    int result = 0;
    for(int i = 0; i < K; i++){
        result += l.at(i);
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256