akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vl vector<long long>
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,k;
    cin>>n>>k;
    vl A(n);
    rep(i,n)cin>>A[i];
    auto solve=[&](ll l,ll r,auto solve)->ll{
        if(r-l<=1)return r;
        ll m=(l+r)/2;
        ll c=0;
        rep(i,n)c+=(A[i]+m-1)/m-1;
        if(c>k)return solve(m,r,solve);
        else return solve(l,m,solve);
    };
    cout<<solve(0,1000000000,solve)<<endl;
}

Measured memory_bytes: 4684
#include<stdio.h>

int main(){
	int x[4],y[4];
	scanf("%d%d%d%d",&x[0],&y[0],&x[1],&y[1]);
	int dx=x[1]-x[0],dy=y[1]-y[0];
	// - + 
	x[2] = x[1] - dy,y[2]=y[1]+dx;
	x[3] = x[0] - dy,y[3] = y[0] + dx;
	//printf("%d\n",x[0]*y[1]+x[1]*y[2]+x[2]*y[0]-x[1]*y[0]-x[2]*y[1]-x[0]*y[2]);
	if(x[0]*y[1]+x[1]*y[2]+x[2]*y[0]>x[1]*y[0]+x[2]*y[1]+x[0]*y[2]){
		printf("%d %d %d %d",x[2],y[2],x[3],y[3]);
		return 0; 	
	}
	
	// + - 
	x[2] = x[1] + dy,y[2]=y[1]-dx;
	x[3] = x[0] + dy,y[3] = y[0] - dx;
	//printf("%d\n",x[0]*y[1]+x[1]*y[2]+x[2]*y[0]-x[1]*y[0]-x[2]*y[1]-x[0]*y[2]);
	if(x[0]*y[1]+x[1]*y[2]+x[2]*y[0]>x[1]*y[0]+x[2]*y[1]+x[0]*y[2]){
		printf("%d %d %d %d",x[2],y[2],x[3],y[3]);
		return 0; 	
	}
	
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i = 0; i < n; i++) cin >> a[i];
  ll q;
  cin >> q;
  vector<ll> m(q);
  for(ll i = 0; i < q; i++) cin >> m[i];

  vector<ll> num((1<<n), 0);
  for(ll bit = 0; bit < (1<<n); bit++){
    ll sum = 0;
    for(ll i = 0; i < n; i++){
      if(bit & (1 << i)) sum += a[i];
    }
    num[bit] = sum;
  }

  for(ll i = 0; i < q; i++){
    bool ok = false;
    for(ll j = 0; j < (1<<n); j++){
      if(m[i] == num[j]) ok = true;
    }
    if(ok) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  return 0;
}


Measured memory_bytes: 10936
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <random>

#include <fstream>
#include <vector>
#include <algorithm>

#define ll long long int

using namespace std;

int main(void)
{

    
    string s, t;
    int res = 0;
    
    cin >> s >> t;
    
    for(int i = 0; i < (int)s.length(); i++)
    {
        if(s[i] != t[i]) res++;
    }
    
    cout << res;
    
    return 0;
}

Measured memory_bytes: 3836
#include <fstream>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <cassert>
#include <deque>
#include <set>
#include <map>
#include <vector>
#include <regex>

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

//#define LOCAL_DEBUG

int aa[41];
int ba[41];
int ca[41];
int dp[51][401][401];

int main() {
#ifdef LOCAL_DEBUG
	freopen("input1.txt","r", stdin);
#endif
	int N, Ma, Mb;
	cin >> N >> Ma >> Mb;

	REP(i, N) {
		int a, b, c;
		cin >> a >> b >> c;
		aa[i] = a;
		ba[i] = b;
		ca[i] = c;
	}
	int inf = 100000;
	REP(i, 51) REP(j, 401) REP(k, 401) dp[i][j][k] = inf;
	dp[0][0][0] = 0;
	REP(i, N) {
		REP(a, 401) {
			REP(b, 401) {
				if (dp[i][a][b] == inf) continue;
				dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a][b]);
				dp[i + 1][a + aa[i]][b + ba[i]] = min(dp[i + 1][a + aa[i]][b + ba[i]], dp[i][a][b] + ca[i]);
			}
		}
	}
	int ans = inf;
	FOR(a, 1, 401) {
		FOR(b, 1, 401) {
			if (a * Mb == b * Ma) {
				if (dp[N][a][b] < ans) {
					ans = dp[N][a][b];
				}
			}
		}
	}
	if (ans == inf) ans = -1;
	cout << ans << endl;

 	return 0;
}


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

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

    if (S == "SUN"){
        cout << 7 << endl;
    }
    else if (S == "MON") {
        cout << 6 << endl;
    }
    else if (S== "TUE") {
        cout << 5 << endl; 
    }
    else if (S == "WED") {
        cout << 4 << endl;
    }
    else if (S == "THU") {
        cout << 3 << endl;
    }
    else if (S == "FRI") {
        cout << 2 << endl;
    }
    else if (S == "SAT") {
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<list>
#include<map>
#include<iomanip>
#include<iostream>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
#include<memory.h>
using namespace std;
int main(){
	int n;
	
	cin>> n;
	
	
	cout<< "ABC"<<n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
int main()
{
	long long int i,n,t,a,s=0;	
	cin>>n>>t>>a;
	long double b[n],h[n];
	
	for(i=0;i<n;i++)
	{
		cin>>h[i];
		b[i]=t-(h[i]*0.006);
		
	}
	long double z=abs(b[0]-a);
	for(i=0;i<n;i++)
	{
		long double x;
		x=abs(b[i]-a);
		if(x<z)
		{
			z=x;
			s=i;
			
		}
	}
	cout<<s+1<<endl;
	
	
}

Measured memory_bytes: 3688
S=str(input())
l=len(S)-1
ans=0

M = 2#bit探査をしたい時はM=2
def dfs(A):
    global ans
    # 終端条件 --- l 重ループまで回したら処理して打ち切り
    if len(A) == l:
        memo=0
        for i in range(l):
            if A[i]==1:
                ans+=int(S[memo:i+1])
                memo=i+1
        ans+=int(S[memo:])
        return
    for v in range(M):
        A.append(v)
        dfs(A)
        A.pop() # これが結構ポイント

dfs([])
print(ans)

Measured memory_bytes: 9180
#include <iostream>
#include <utility>

using namespace std;

double table[100][100];
double result[100][100];

int main(){
	while(true){
		int n, m;
		cin >> n >> m;
		if(n == 0 && m == 0){ break; }
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cin >> table[i][j];
			}
		}
		for(int i = 0; i < n; i++){ result[0][i] = 1.0; }
		for(int i = 1; i < m; i++){
			for(int j = 0; j < n; j++){
				double maxval = 0.0;
				for(int k = 0; k < n; k++){
					maxval = max(maxval, result[i - 1][k] * table[k][j]);
				}
				result[i][j] = maxval;
			}
		}
		double answer = 0.0;
		for(int i = 0; i < n; i++){
			answer = max(answer, result[m - 1][i]);
		}
		printf("%.2lf\n", answer);
	}
	return 0;
}

Measured memory_bytes: 1132
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
char s[15]; 
int main(){
	int i,j,ans=0;
	scanf(" %s",s+1);
	n=strlen(s+1);
	for(i=1;i<=n;i++){
		for(j=i;j<=n;j++){
			if(s[j]=='A'||s[j]=='C'||s[j]=='G'||s[j]=='T') ans=max(ans,j-i+1);
			else break;
		}
	}
	printf("%d",ans);
	return 0;
}

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

int main() {
    int a, b;
    int ans = 0;
    
    cin >> a >> b;
    
    ans = a - 1;
    ans += ((a <= b) ? 1 : 0);
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]

for i in range(N):
  S[i] = "".join(sorted(S[i]))

ans = {}
for i in range(N):
  if S[i] in ans:
    ans[S[i]] += 1
  else:
    ans[S[i]] = 1

cnt = 0
for a in ans:
  cnt += ans[a] * (ans[a] - 1) // 2
print(cnt)

Measured memory_bytes: 19472
#include<iostream>
#include<vector>
#include<string>

int main()
{
	std::string s;
	while( std::cin >> s )
	{
		std::vector<int> v;
		for( int i = 0; i != 10; ++i )
			v.push_back( s[i] - '0' );

		std::vector<int> t;
		for( int i = 10; i >= 2; --i )
		{
			t.clear();

			for( int j = 0; j != i - 1; ++j )
				t.push_back( ( v[j] + v[j+1] ) % 10 );

			v = t;
		}

		std::cout << v[0] << std::endl;
	}

	return 0;
}

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


struct TreeNode {
	static const size_t null = (size_t)-1;
	int depth = -1;
	size_t parent = null;
	size_t child = null;
	size_t sister = null;
};


int main() {
	int n; cin >> n;
	vector<TreeNode> g(n);

	for (int i = 0; i < n; i++) {
		int p; cin >> p;
		int nchild; cin >> nchild;
		for (int i = 0; i < nchild; i++) {
			int child; cin >> child;
			g[child].parent = p;
			g[child].sister = g[p].child;
			g[p].child = child;
		}
	}

	for (int i = 0; i < n; i++) {
		stack<size_t> st; st.push(i);
		while (!st.empty()) {
			if (g[st.top()].parent == -1) {
				g[st.top()].depth = 0;
				st.pop();
			}
			else if (g[g[st.top()].parent].depth != -1) {
				g[st.top()].depth = g[g[st.top()].parent].depth + 1;
				st.pop();
			}
			else {
				st.push(g[st.top()].parent);
			}
		}
	}

	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": ";
		cout << "parent = " << (int)g[i].parent << ", ";
		cout << "depth = " << g[i].depth << ", ";
		if (g[i].parent == TreeNode::null) cout << "root, ";
		else if (g[i].child == TreeNode::null) cout << "leaf, ";
		else cout << "internal node, ";
		cout << "[";
		if (g[i].child != TreeNode::null) {
			vector<size_t>children = { g[i].child };
			for (size_t j = g[g[i].child].sister; j != TreeNode::null; j = g[j].sister)
				children.push_back(j);
			reverse(children.begin(), children.end());
			for (size_t j = 0; j < children.size(); j++) {
				if (j != 0) cout << ", ";
				cout << children[j];
			}
		}
		cout << "]";
		cout << endl;
	}

	return 0;
}





Measured memory_bytes: 7012
import collections

n=int(input())
a=list(map(int, input().split()))  
a = collections.Counter(a)
a=a.most_common()
b=0
c=0
a.sort(key=lambda x:x[0])

for i in range(len(a)):
    if a[len(a)-i-1][1]>=4:
        if b==0:
            b=a[len(a)-i-1][0]
            print(b**2)
            exit()
            
    if a[len(a)-i-1][1]>=2:
        if b==0:
            b=a[len(a)-i-1][0]
        else:
            c=a[len(a)-i-1][0]
            print(b*c)
            exit()
        
print(0)

Measured memory_bytes: 21412
#include<bits/stdc++.h>
using namespace std;
long long n,m;
char a[100010],b[100010];
int main(void)
{
	cin>>n>>m;
	scanf("%s%s",a,b);
	if(a[0]!=b[0]) return cout<<-1,0;
	long long d=__gcd(n,m);
	long long L=n/d*m;
	for(long long i=0;i<n;i++){
		long long x=i*L/n;
		if(x>=L) continue;
		if((x*m)%L!=0)
			continue;
		long long j=(x*m)/L;
		if(j<m&&a[i]!=b[j])
			return cout<<-1,0; 
	}
	return cout<<L,0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;
typedef vector<long long int> vll;

int main() {
	int n;
	i64 a, b;
	cin >> n >> a >> b;
	vll x(n);
	rep(i, 0, n) cin >> x[i];
	i64 ans = 0;
	rep(i, 0, n - 1) {
		ans += min((x[i + 1] - x[i])*a, b);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
//I am so vegetable
//#define _LOCAL_
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define CT count
#define EP empty
#define _for(i,a,b) for(ll i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 2e5 + 5;
const int MOD = 998244353;
const double eps = 1e-6;
const double pi = acos(-1);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(int x, int y) { ll ans = 1; for (; y; y >= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll comb(int n, int m) {
	ll ans = 1;
	if (m > n - m)m = n - m;
	_for(i, n - m + 1, n + 1)ans *= i;
	_for(i, 1, m + 1)ans = ans /i;
	return ans;
}
int cnt[N];
int a[N];
int main(){
	FIO;
	int n,x;cin>>n;
	_for(i,0,n){
		cin>>a[i];
		++cnt[a[i]];
	}
	ll ans = 0;
	_for(i,1,n + 1)ans+= (1ll*cnt[i]*(1ll*cnt[i]-1))/2;
	_for(i,0,n){
		cout<<ans-cnt[a[i]]+1<<'\n';
	}
	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int lli;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    lli t, i, j, zc=0, oc=0;
    string s;
    cin >> s;
    for(i=0; i<s.size(); i++) {
        if(s[i]=='0') zc++;
        else oc++;
    }
    t = min(zc, oc);
    cout << t*2 << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
int main()
{
  ll n;
  cin >> n;
  vl a(5);
  re(i, 5) cin >> a[i];

  ll s = 0, r = 0;
  re(i, 5) {
    s = (n + a[i] - 1) / a[i];
    if (r < s) r = s;
  }

  cout << r + 4 << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <iomanip>
#include <functional>
#include <array>
#include <climits>
#include <cmath>

using namespace std;
using ll = long long;
const ll MOD = (ll)1e9 + 7;

int main()
{
    string s;
    cin >> s;
    ll sum = 0;
    ll ct = 0;

    for (auto c : s)
    {
        if (c == 'B')
        {
            ct++;
        }
        else
        {
            sum += ct;
        }
    }

    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 640
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //input
        Scanner sc = new Scanner(System.in);
        //int n = sc.nextInt();
        String s = sc.next();
        if (s.equals("SUN"))
        {
            System.out.println(7);
        }else if (s.equals("MON"))
        {
            System.out.println(6);
        }else if (s.equals("TUE"))
        {
            System.out.println(5);
        }else if (s.equals("WED"))
        {
            System.out.println(4);
        }else if (s.equals("THU"))
        {
            System.out.println(3);
        }else if (s.equals("FRI"))
        {
            System.out.println(2);
        }else if (s.equals("SAT"))
        {
            System.out.println(1);
        }
        sc.close();
    }

    public class Pair<F,S>
    {
        private final F first;
        private final S second;

        Pair(F first,S second)
        {
            this.first = first;
            this.second = second;
        }

        public void print() { System.out.println("("+this.first+","+this.second+")"); }

        //get
        public F first() {return this.first;}
        public S second() {return this.second;}

        @Override
        public boolean equals(Object object)
        {
            if (object instanceof Pair)
            {
                Pair pair = (Pair)object;
                return this.first==pair.first && this.second==pair.second;
            }else
            {
                return false;
            }
        }

        @Override
        public int hashCode()
        {
            return Objects.hash(first,second);
        }
    }
}

Measured memory_bytes: 23124
// Problem : D - Knapsack 1
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;

#define ff first
#define fs second
#define lb lower_bound
#define ub upper_bound

#define int long long
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector< vi >
#define vpii vector< pii >
#define vb vector<bool>
#define si set<int>
#define mii map<int, int>
#define mci map<char, int>
#define md 1000000007
#define pb push_back
#define eb emplace_back
#define fio ios_base::sync_with_stdio (false); cin.tie (NULL);  cout.tie (NULL);
#define qw1(x) cerr<<#x<<": "<<x<<" "<<endl
#define qw2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define qw3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define qw4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl


#define f(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define rl(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define all(x) x.begin(),x.end()
#define endl '\n'
void printv(vector<int>  v){ for(int i=0;i<v.size();i++) cout<<v[i]<<' '; cout<<endl;   }
int bem(int m , int n, int mod) { int res=1; while(n){
	     			        if(n%2!=0) { res*=m; res%=mod; }
	    			        m*=m;   m%=mod;   n/=2;
			                          }
				return res;	}
int be(int a, int b) { int res=1; 	while(b){
				if(b%2!=0) res*=a;
				a*=a; b/=2;
				}
			return res;	}
void sieve(int n, vb &prime){
    prime[0]=false;     prime[1]=false;
    for(int i=2;i*i<=n;i++){
         if(prime[i]==true){
              for(int j=i*i;j<=n;j+=i)    prime[j]=false;
             	  }
    	 }
	}

void solve()
  {
	int n, wt; cin>>n>>wt;
	vi v(n), w(n);
	f(i, 0, n-1) cin>>w[i]>>v[i];
	vector< vector< int> > dp(wt+1, vi (n+1, 0));
// printv(v); printv(w);
for( int i=1; i<=wt; i++){
  for(int j=1; j<=n; j++)
  {
  	if(i-w[j-1]>=0)
  	  dp[i][j]=max(dp[i][j-1], dp[i-w[j-1]][j-1]+v[j-1]);
  	else dp[i][j]=dp[i][j-1];
  }
  // cout<<i<<' ';printv(dp[i]);
  }
  cout<<*max_element(dp[wt].begin()+1, dp[wt].end())<<endl;
  }
 /*vi v,w;
 vvi dp;
 int fun(int wt, int n)
 {
 	if(n<0) return 0;
 	if(dp[wt][n]!=-1) return dp[wt][n];
 	if(wt==0) return dp[wt][n]=0; 
 	if(wt<w[n]) return dp[wt][n]=fun(wt, n-1);
 	else
 	return dp[wt][n]=max(fun(wt, n-1), fun(wt-w[n], n-1)+v[n]);
 	
 }
 void solve()
 {
 	int n, wt; cin>>n>>wt;
 	v.resize(n); w.resize(n);
 	f(i, 0, n-1) cin>>w[i]>>v[i];
 	dp.resize(wt+1, vi(n, -1));
 	cout<<fun(wt, n-1)<<endl;
 } 
  */

int32_t main ()
{
//fio
int t=1; 
//cin>>t; 
while(t--){
	solve();
}
 
}








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

using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end() //昇順
#define enb(a) a.rbegin(),a.rend() //降順
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	ll n;
	cin >> n;
	ll a = 0,b;
	for(ll i = 1; i * i <= n; i++){
		if(n % i == 0){
			a = max(a,i);
			b = n / i;
		}
	}
	string s = to_string(max(a,b));
	cout << s.size() << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> a;
  for(int i=0;i<n;i++){
  	int x; cin >> x;
    a.push_back(--x);
  }
  int y=0;
  int ans=0;
  vector<bool> used(n,false);
  while(y!=1 && !used[y]){
    used[y] = true;
    y = a[y];
    ans++;
  }
  if(y!=1) ans =-1;
  cout << ans << endl;
}


Measured memory_bytes: 892
'use strict';
(function(stdin) {
  var lines = stdin.toString();
  var result = (function(data) {
    return data.map(function(v) {
      var param = v.split(' ').map(Number);
      var count = 0;
      for (var i = 1; i < param[0] + 1; i++) {
        for (var j = i + 1; j < param[0] + 1; j++) {
          for (var k = j + 1; k < param[0] + 1; k++) {
            if (i + j + k === param[1]) {
              count++;
            }
          } 
        }
      }
      return count;
    }).join('\n');

  }(
    lines.split('0 0')[0].trim().split('\n')
  ));
  console.log(result);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

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

int a,b,c,d;

int main(){
    cin>>a>>b>>c>>d;
    if(a+b>c+d)cout<<"Left"<<endl;
    else if(a+b==c+d)cout<<"Balanced"<<endl;
    else cout<<"Right"<<endl;
    return 0;
}

Measured memory_bytes: 256
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


A, B = read_ints()
from fractions import gcd
G = gcd(A, B)
a = A // G
b = B // G
print(G * a * b)


Measured memory_bytes: 5716
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

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


int NL_num[100];
int NL[100][100];
int found[100];
int d[100];
int f[100];
int tim;

/*
 * NL:??£??\????????????????????????
 * NL_num:??£??\?????????NL???????????????????´??????????????´???°
 * ans:???????´???°?????°????????????????????????????´??????????????????????
 * ans_num:2?????\???
 * found:???????´???°?????????????????§???????????????????????????????????????????????°
 * ?¬??????¢?????????????´??????????
 */
void dfs(int n){
    
    int i;
    
    if (found[n-1]) {
        return;
    }else{
        found[n-1] = 1;
        d[n-1] = tim++;
    }
    
    for (i=0; i < NL_num[n-1]; i++) {
        if ( !found[ NL[n-1][i] -1 ] ) {
            dfs(NL[n-1][i]);
        }
    }
    f[n-1]= tim++;
    
    return;
    
}

int main(){
    
    int i,j,n, cn, v, u;
    
    //the number
    scanf("%d",&n);
    
    tim = 1;
    u = 0;
    
    for (i=0; i < n; i++) {
        scanf("%d %d",&u, &cn);
        NL_num[u-1] = cn;
        for (j=0; j < cn; j++) {
            scanf("%d",&v);
            NL[u-1][j] = v;
        }
    }
    
    for (i=0; i < n; i++) {
        d[i] = 0;
        f[i] = 0;
        found[i] = 0;
    }
    
    for (i=1; i<=n; i++) {
        if(!d[i-1]) dfs(i);
    }
    
    for (i=0; i<n; i++) {
        printf("%d %d %d\n", i+1, d[i], f[i]);
    }
    
    return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int a,b;
  cin>>a>>b;
  double ans=0;
  for(int i=1;i<=a;i++){
    double prob=1.0/a;
    int now=i;
    while(now<b){
      now*=2;
      prob/=2;
    }
    ans+=prob;
  }
  cout << fixed << setprecision(13);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int N;
	string S;
	cin >> N >> S;
	vector<int> E(N+2, 0);//→
	vector<int> W(N+2, 0);//←
	for (int i = 0; i < N; ++i) {
		if (S[i] == 'E') {
			E[i+1]++;
		}
		else {
			W[i+1]++;
		}
		if (i) {
			E[i+1] += E[i];
			W[i+1] += W[i];
		}
	}
	E[N + 1] = E[N];
	W[N + 1] = W[N];

	int ans = INF;
	for (int i = 1; i <= N; ++i) {
		int res=0;
		if (i == 1) {
			res = E[N] - E[1];
			ans = min(ans, res);
		}
		else if (i == N) {
			res = W[N - 1];
			ans = min(ans, res);
		}
		else {
			res = W[i - 1] + E[N] - E[i];
			ans = min(ans, res);
		}
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 2964
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    while(true){
        int taro, hanako; cin >> taro >> hanako;
        if(taro == 0 and hanako == 0) return 0;
        else {
            vector<int> TaroCard(taro), HanakoCard(hanako);
            int taroSum = 0, hanakoSum = 0;
            REP(i, taro){
                cin >> TaroCard[i];
                taroSum += TaroCard[i];
            }
            REP(i , hanako){
                cin >> HanakoCard[i];
                hanakoSum += HanakoCard[i];
            }
            bool flag = false;
            pair<int, int> ans = make_pair(INF, INF);
            REP(i, taro){
                REP(j, hanako){
                    if(taroSum - TaroCard[i] + HanakoCard[j] == hanakoSum - HanakoCard[j] + TaroCard[i] 
                    and ans.first + ans.second > TaroCard[i] + HanakoCard[j]){
                        flag = true;
                        ans = make_pair(TaroCard[i], HanakoCard[j]);
                    }
                }
            }
            if(flag) cout << ans.first << " " << ans.second << endl;
            else cout << -1 << endl;
        }
    }
}


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

int main(void) {
    int N;
    int sum = 0;
    cin >> N;

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

    sort(s.begin(), s.end());

    if(sum % 10) {
        cout << sum << "\n";
        return 0;
    }
    for(int i=0;i<s.size();i++) {
        if(s[i] % 10) {
            cout << sum - s[i] << "\n";
            return 0;
        }
    }

    cout << "0\n";
    return 0;
}


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

using namespace std;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	
	if(a==5&&b==7&&c==5||a==5&&b==5&&c==7||a==7&&b==5&&c==5){
		cout<<"YES"<<endl;
		}
	else{
		cout<<"NO"<<endl;
		}
	}


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

int main() {
  int N;
  cin >> N;
  
  for (int i; i<N; i++) {
    string S;
    cin >> S;
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    else if (i == N - 1) {
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 3548
#!/usr/bin/env python
# coding: utf-8

import fractions

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def calc(n, x):
    return n // x

def lcm(a, b):
    return (a * b) // fractions.gcd(a, b)

def main():
    a, b, c, d = rli()
    lcm_cd = lcm(c, d)
    n_a = a-1 - calc(a-1, c) - calc(a-1, d) + calc(a-1, lcm_cd)
    n_b = b - calc(b, c) - calc(b, d) + calc(b, lcm_cd)
    print(n_b-n_a)


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef long double ld;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef vector<v2> v3;

typedef unordered_map<ll, unordered_map<ll, ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

ll n;
tuple<ll,ll,ll> a;
tuple<ll,ll,ll> b;
ll x = 0;
ll ans = 0;

vector<ld> get_rate(tuple<ll,ll,ll> a, tuple<ll,ll,ll> b){
    vector<ld> r(3);
    ll ga, sa, ba;
    tie(ga, sa, ba) = a;
    ll gb, sb, bb;
    tie(gb, sb, bb) = b;
    r[0] = (ld)ga/(ld)gb;
    r[1] = (ld)sa/(ld)sb;
    r[2] = (ld)ba/(ld)bb;
    return r;
}

ll inc(ll x, tuple<ll,ll,ll> a, tuple<ll,ll,ll> b){
    v1 av(3);
    tie(av[0], av[1], av[2]) = a;
    v1 bv(3);
    tie(bv[0], bv[1], bv[2]) = b;
    v1 dp(5000*5000+10, -INF);
    ll dp_size = 5000*5000+10;
    dp[0] = 0;
    for(ll i = 0;i < dp_size;i++){
        for(ll j = 0;j < 3;j++){
            if(i+av[j] < dp_size)
                dp[i+av[j]] = max(dp[i+av[j]], dp[i] + bv[j]);
        }
    }
    ll ret = x;
    for(ll i = 0;i <= x;i++){
        ret = max(ret, dp[i] + x-i);
    }
    return ret;


}


int main(){
    cin >> n;
    ll g, s, br;
    cin >> g >> s >> br;
    a = make_tuple(g,s,br);
    cin >> g >> s >> br;
    b = make_tuple(g,s,br);
    // for(ll i = 0;i <= n;i++){
    //     x = max(x, inc(i, a, b) + (n-i));
    // }
    // for(ll i = 0;i <= x;i++){
    //     ans = max(ans, inc(i, b, a) + (x-i));
    // }
    x = inc(n, a, b);
    ans = inc(x, b, a);
    cout << ans << endl;



}


Measured memory_bytes: 198576
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i=0; i<n; i++)
 
using namespace std;
const double PI = acos(-1);
using Graph = vector<vector<int>>;
 
int main() {
  string s;
  cin >> s;
  if (s == "ABC")
    cout << "ARC" << endl;
  else
    cout << "ABC" << endl;
}

Measured memory_bytes: 3604
import java.util.*;

public class Main{
  public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    int ab_distance = Math.abs(a-b);
    int bc_distance = Math.abs(b-c);
    int ac_distance = Math.abs(a-c);
    if(ac_distance <= d){
    	System.out.println("Yes");
    }else if(bc_distance<= d && ab_distance <= d){
    	System.out.println("Yes");
    }else{
    	System.out.println("No");
    }
  }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define MAX 500005
 #include<iomanip>
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define x first
 #define y second
using namespace std;
 
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}

 int32_t main()
{
    Need_for_speed(activated);
//    satisfy
//    {}
    string s;
    ll n;cin>>n;
    ll dp[10][10]={0};
    for(ll i=1;i<=n;i++)
    {
        s=to_string(i);
        ll l=s[0]-'0';
        ll r=s[s.length()-1]-'0';
        dp[l][r]++;
    }
    ll ans=0;
    for(ll i=0;i<10;i++)
    {
        for(ll j=0;j<10;j++)
        {
            ans+= dp[i][j]*dp[j][i];
        }
    }
    cout<<ans<<endl;
    return 0;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

const int mod=998244353;

template<class Type_k,class Type_p>
Type_p mod_pow(long long n,Type_k k,Type_p p){//n^k(mod p).
	if(k==0) return 1;
	long long res=mod_pow(n*n%p,k/2,p);
	if(k&1) res=res*n%p;
	return res;
}

int main(){
	int n;
	cin>>n;
	
	vi d(n);
	vi cnt(n,0);
	int hoge=-1;
	REP(i,n){
		cin>>d[i];
		cnt[d[i]]++;
		chmax(hoge,d[i]);
	}
	
	if(d[0]==0 and cnt[0]==1){}
	else{
		cout<<0<<endl;
		return 0;
	}
	
	llong ans=1;
	REP(i,hoge){
		ans=ans*mod_pow((llong)cnt[i],cnt[i+1],mod)%mod;
	}
	
	cout<<ans<<endl;
}

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


int main()
{
  int n;
  std::cin >> n;
  enum JUDGE
  {
    AC = 0,
    WA,
    TLE,
    RE,
    COUNT
  };
  std::vector<int> sums(4, 0);
  for (int i = 0; i < n; ++i)
  {
    std::string s;
    std::cin >> s;

    if (s == std::string("AC"))
    {
      sums[AC]++;
    }
    else if (s == std::string("WA"))
    {
      sums[WA]++;
    }
    else if (s == std::string("TLE"))
    {
      sums[TLE]++;
    }
    else if (s == std::string("RE"))
    {
      sums[RE]++;
    }
  }
  std::cout << "AC x " << sums[JUDGE::AC] << std::endl;
  std::cout << "WA x " << sums[JUDGE::WA] << std::endl;
  std::cout << "TLE x " << sums[JUDGE::TLE] << std::endl;
  std::cout << "RE x " << sums[JUDGE::RE] << std::endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define what_is(x) cerr << #x <<" is " << x << endl;
typedef long long ll;
const int MOD = 998244353;
const double PI = 3.141592653589793;
const ll INF =  1e18 + 7;
const int nax = 200005;


double power(double a, ll b) {
	double ans = 1;
	while (b) {
		if (b & 1) {
			ans = (ans * a);
		}
		a = (a * a);
		b = b >> 1;
	}
	return ans;
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tc = 1;
	// cin >> tc;
	while (tc--) {
		int n,m;
		cin >>n >> m;
		
		vector<int> h(n+1);
		for(int i=1;i<=n;i++){
			cin >> h[i];
		}
		vector<int> adj[n+10];
		for(int i=1;i<=m;i++){
			int x,y;
			cin >>x >> y;
			adj[x].emplace_back(y);
			adj[y].emplace_back(x);
		}
		int ans = 0;
		for(int i=1;i<=n;i++){
			bool good = true;
			for(int j : adj[i]){
				good &= (h[i] > h[j]);
			}
			if(good) ans++;
		}
		cout<<ans;
	}
	return 0;
}




















Measured memory_bytes: 8752
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 998244353;
const ll MAX = 2000001;

ll mod(ll a){
  if(a % MOD < 0) return MOD + (a % MOD);
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  vl cusum(1000000);
  queue<ll> q; set<ll> prime;
  prime.insert(2);
  
  for(ll i=3; i < 100001; i += 2){
    bool isprime = true;
    
    for(ll j=2; j*j <= i; j++){
      if(i % j == 0){
        isprime = false;
        break;
      }
    }
    
    if(isprime){
      q.push(i);
      prime.insert(i);
    }
  }
  
  while(!q.empty()){
    ll x = q.front();
    
    if(prime.count((x+1)/2)){
      cusum[x]++;
    }
    
    q.pop();
  }
  
  ll now = 0;
  for(ll i=0; i < 1000000; i++){
    if(cusum[i] == 1) now++;
    cusum[i] = now;
  }
  
  ll query; cin >> query;
  
  rep(i,query){
    ll l,r; cin >> r >> l;
    cout << cusum[l] - cusum[r-1] << endl;
  }
  
  /*for(ll i=0; i < 100; i++){
    cout << cusum[i];
  }*/
}

Measured memory_bytes: 11548
#include<bits/stdc++.h>
#define nl "\n"
#define fi(init, n) for(int i = init; i < n; i++)
#define fj(init, n) for(int j = init; j < n; j++)
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);
typedef long long ll;
using namespace std;

int main()
{
	ios
	int x;
	cin >> x;
	if(x >= 30)
		cout << "Yes";
	else
		cout << "No";

    return 0;
}

Measured memory_bytes: 3648
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
C = [list(map(int,input().split())) for _ in range(M)]
mina = min(a)
minb = min(b)
ans = mina+minb
for i in range(M):
    if ans > a[C[i][0]-1] + b[C[i][1]-1] - C[i][2]:
        ans = a[C[i][0]-1] + b[C[i][1]-1] - C[i][2]
print(ans)


Measured memory_bytes: 38572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			long[] dg = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
			long d = dg[0];
			long g = dg[1];
			var pcs = new Tuple<long, long>[(int)d];
			for (int i = 0; i < d; i++) {
				long[] pc = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
				pcs[i] = new Tuple<long, long>(pc[0], pc[1]);
			}

			List<long> scores = new List<long>(1000);
			for (int i = (int)d - 1; i >= 0; i--) {
				for (int j = 0; j < pcs[i].Item1; j++) {
					scores.Add(i + 1);
				}
			}

			long gg = g / 100;
			long ans = 100000000;
			for (int bit = 0; bit < 0x1 << 10; bit++) {
				long cost = 0;
				long score = 0;
				for (int i = 0; i < d; i++) {
					if ((bit & (1 << i)) != 0) {
						score += pcs[i].Item1 * (i + 1) + (pcs[i].Item2 / 100);
						cost += pcs[i].Item1;
					}
				}

				int count = 0;
				while (score < gg) {
					if (count >= scores.Count) {
						break;
					}

					if ((bit & (1 << (int)(scores[count] - 1))) == 0) {
						score += scores[count];
						++cost;
					}

					++count;
				}

				if (score >= gg) {
					ans = Math.Min(ans, cost);
				}
			}


			Console.WriteLine(ans);
		}
	}
}


Measured memory_bytes: 13380
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <vector>
using namespace std;
typedef long long LL;

LL ans = 0x3f3f3f3f3f3f3f3f;
LL ca[20005],cb[20005],ba[20005];
string a,b,c;

void solve(string x,string y,string z){
	LL lx = x.length(),ly = y.length(),lz = z.length();
	x = ' ' + x; y = ' ' + y; z = ' ' + z;
	for(LL i = 1;i <= 20000;i ++){ ba[i] = 1; cb[i] = 1; ca[i] = 1; }
	
	for(LL i = 0;i <= 6005;i ++){
		LL flg = 1;
		for(LL j = 1;j <= ly;j ++){
			if(i + j > lx) break;
			if(x[i + j] != y[j] && x[i + j] != '?' && y[j] != '?') flg = 0;
		}
		ba[i + 1] = flg;
	}
	for(LL i = 0;i <= 6005;i ++){
		LL flg = 1;
		for(LL j = 1;j <= lz;j ++){
			if(i + j > ly) break;
			if(y[i + j] != z[j] && y[i + j] != '?' && z[j] != '?') flg = 0;
		}
		cb[i + 1] = flg;
	}
	for(LL i = 0;i <= 6005;i ++){
		LL flg = 1;
		for(LL j = 1;j <= lz;j ++){
			if(i + j > lx) break;
			if(x[i + j] != z[j] && x[i + j] != '?' && z[j] != '?') flg = 0;
		}
		ca[i + 1] = flg;
	}
	
	for(LL i = 1;i <= 6005;i ++){
		for(LL j = 1;j <= 6005;j ++){
			if(ba[i] && cb[j] && ca[i + j - 1]) ans = min(ans,max(lx,max(i + ly - 1LL,i + j + lz - 2LL)));
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin >> a >> b >> c;
	solve(a,b,c);
	solve(a,c,b);
	solve(b,a,c);
	solve(b,c,a);
	solve(c,a,b);
	solve(c,b,a);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#define INF 0
using namespace std;
int main(){
	int n,m;
	double t[200][200];
	while(cin>>n>>m,n||m){
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				cin>>t[i][j];
		double dp[200][200];
		for(int i=0;i<=m;i++)
		for(int j=0;j<n;j++)
		dp[j][i]=INF;
		for(int i=0;i<n;i++)
		dp[i][0]=1.0;
		for(int i=1;i<m;i++)
		for(int j=0;j<n;j++)
		for(int k=0;k<n;k++)
		dp[j][i]=max(dp[j][i],dp[k][i-1]*t[k][j]);
		double ans=INF;
		for(int i=0;i<n;i++)
		ans=max(ans,dp[i][m-1]);
		printf("%.2lf\n",ans);
		
	}
	return 0;
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	VPi a(n,mp(0,0));
	rep(i, n) { cin >> a[i].F;
		a[i].S = i + 1;
	}
	sort(all(a));
	rep(i, n) { cout << a[i].S; 
	if(i!=n-1){
		cout << " ";
	}}
	cout << endl;

//	cout<<ans<<endl;
}

Measured memory_bytes: 4008
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int gcd(int x,int y){
	
	if(x%y==0){
		return y;
	}else{
		return gcd(y,x%y);
	}
	
}

int main() {
	
	int A,B;
	cin>>A>>B;
	if(B%A==0){
		ce(A+B)
	}else{
		ce(B-A)
	}
	
	
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,m;
char t[100],ch;
void putA();
void putB();
void putC();
void putD();
int main(){
  while(cin>>n>>m){
    if(n==0&&m==0)break;
    for(int i=0;i<n;i++)t[i]='#';
    for(int i=0;i<m;i++){
      cin>>ch;
      if(ch=='A')putA();
      else if(ch=='B')putB();
      else if(ch=='C')putC();
      else putD();
    }
    for(int i=0;i<n;i++)cout<<t[i];
    cout<<endl;
  }
  return 0;
}
void putA(){
  for(int i=0;i<n;i++){
    if(t[i]!='#')continue;
    t[i]='A';
    return;
  }
}
void putB(){
  for(int i=n-1;i>=0;i--){
    if(t[i]!='#')continue;
    if(i-1>=0&&t[i-1]=='A')continue;
    if(i+1<n&&t[i+1]=='A')continue;
    t[i]='B';
    return;
  }
  for(int i=0;i<n;i++){
    if(t[i]=='#'){
      t[i]='B';
      return;
    }
  }
}
void putC(){
  for(int i=0;i<n;i++){
    if(t[i]=='#')continue;
    if(i+1<n&&t[i+1]=='#'){
      t[i+1]='C';return;
    }else if(i-1>=0&&t[i-1]=='#'){
      t[i-1]='C';return;
    }
  }
  t[n/2]='C';
}
void putD(){
  bool flg=true;
  for(int i=0;i<n;i++)if(t[i]!='#')flg=false;
  if(flg){
    t[0]='D';return;
  }

  int l[100],r[100],m[100];
  l[0]=(t[0]=='#'?100:0);
  for(int i=1;i<n;i++){
    if(t[i]=='#')l[i]=l[i-1]+1;
    else l[i]=0;
  }
  r[n-1]=(t[n-1]=='#'?100:0);
  
  for(int i=n-2;i>=0;i--){
    if(t[i]=='#')r[i]=r[i+1]+1;
    else r[i]=0;
  }
  //for(int i=0;i<n;i++)cout<<t[i];cout<<endl;
  for(int i=0;i<n;i++){
    m[i]=min(l[i],r[i]);
    //cout<<m[i];
  }
  //cout<<endl;

  int pos=-1,maxm=0;
  for(int i=0;i<n;i++){
    if(t[i]!='#')continue;
    if(m[i]>maxm){
      pos=i;
      maxm=m[i];
    }
  }
  if(pos!=-1){
    t[pos]='D';
  }
}

Measured memory_bytes: 1156
def ints
  gets.split.map(&:to_i)
end

A, B = ints

def f(n)
  r = n % 2 == 0 ? n : 0
  ((n / 2.0).ceil % 2 == 0 ? 0 : 1) ^ r
end

puts f(A - 1) ^ f(B)


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

int main()
{
	string s;
	cin >> s;
	int a = s[0]-48;
	int b = s[1]-48;
	int c = s[2]-48;
	int d = s[3]-48;
	char x,y,z;
	int ans = 0;
	if (a+b+c+d == 7)
	{
		cout << a << "+"<< b << "+" << c << "+" << d << "=7";
		return 0;
	}
	else
	{
		if (a + b + c - d == 7)
		{
			x = '+'; y = '+'; z = '-';
		}
		if (a + b - c + d == 7)
		{
			x = '+'; y = '-'; z = '+';
		}
		if (a - b + c - d == 7)
		{
			x = '-'; y = '+'; z = '-';
		}
		if (a - b + c + d == 7)
		{
			x = '-'; y = '+'; z = '+';
		}
		if (a - b - c + d == 7)
		{
			x = '-'; y = '-'; z = '+';
		}
		if (a + b - c - d == 7)
		{
			x = '+'; y = '-'; z = '-';
		}
		if (a - b - c - d == 7)
		{
			x = '-'; y = '-'; z = '-';
		}
		cout << a << x << b << y << c << z << d << "=7";
	}
	return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define PB push_back
#define INF 1e9+5;
#define F(i,a,b)  for(i=a;i<b;i++)
#define FE(i,a,b)  for(i=a;i<=b;i++)
#define FR(i,a,b) for(i=a;i>b;i--)
#define LL long long
#define MAX(a,b) (a<b?b:a)
#define ABS(x) (x<0?(-x):x)
#define ALL(c) (c).begin(),(c).end()
#define WATCH(x) cout << (#x) << " is " << (x) << endl
#define vi vector<int>
#define vs vector<string>
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
using namespace std;
string ConvertToBin(LL s)
{
    string res = "";
    while(s != 0) {
        res += (char)('0' + s % 2);
        s /= 2;
    }
    reverse(res.begin() , res.end());
    return res;
}

void PrintVec(vector<int> &v)
{
    for(vector<int>::iterator it = v.begin() ; it != v.end(); ++it)
    cout<<*it<<" ";
}

vector<int> Populate(vector<int> &v,int n)
{
    int num;
    for(int i=0;i<n;i++)
    {
        cin>>num;
        v.push_back(num);
    }
    return(v);
}

int sumofdigits(int n)
{
    int sm=0;
    while(n)
    {
        sm=sm+(n-(n/10)*10);
         n=n/10;
    }
    return(sm);
}

bool isprime(int n)
{
    int i=0;
    FE(i,2,sqrt(n))
    {
        if(n%i==0)
        return(false);
    }
    return(true);
}


/*--------------------------time to code-------------------------------*/



int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    int cost[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        cost[i]=INF;
    }
    cost[0]=0;
    for(int i=1;i<n;i++)
    {
        int k1=k;
        int j=i-1;
       // d2(k1,j);
        while(j>=0 && k1>0)
        {
            cost[i]=min(cost[i],cost[j]+abs(arr[i]-arr[j]));
            k1--;
            j--;
        }
       // cout<<i<<" "<<cost[i]<<endl;
    }
    cout<<cost[n-1];
    return(0);
}









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

int main(){
    int n,ming=114514,maks=0,tmp;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&tmp);
        if(tmp>maks) maks = tmp;
        if(tmp<ming) ming = tmp;
    }
    printf("%d\n",maks-ming);
}

Measured memory_bytes: 256