akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
class DisjointSetUnion():
  def __init__(self, n):
    self.n = n
    self.root = [-1] * (n + 1)
    self.rank = [0] * (n + 1)
  def leader(self, x):
    rt = self.root[x]
    if rt < 0: return x
    else: self.root[x] = self.leader(rt)
    return self.root[x]
  def merge(self, x, y):
    leader = self.leader
    xrt = leader(x)
    yrt = leader(y)
    if xrt == yrt: return
    if self.rank[xrt] > self.rank[yrt]:
      self.root[xrt] += self.root[yrt]
      self.root[yrt] = xrt
    else:
      self.root[yrt] += self.root[xrt]
      self.root[xrt] = yrt
      self.rank[yrt] += self.rank[xrt] == self.rank[yrt]
  def same(self, x, y): return self.leader(x) == self.leader(y)
  def size(self, x):  return -self.root[self.leader(x)]
  def group(self):
    n = self.n
    leader = self.leader
    res = [[] for _ in range(n + 1)]
    for x in range(n + 1): res[leader(x)].append(x)
    return [res[i] for i in range(n + 1) if len(res[i])]
dsu = DisjointSetUnion(N)
for _ in range(Q):
  q, u, v = map(int, input().split())
  if q: print(int(dsu.same(u, v)))
  else: dsu.merge(u, v)

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

#define pb push_back
#define mp make_pair

typedef long long ll;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int dp[100001];

int main()
{
  int n;
  cin >> n;
  
  int h[n];
  for(int i = 0; i < n; i++){
    cin >> h[i];
    dp[i] = inf;
  }

  dp[0] = 0;

  for(int i = 0; i+2 < n; i++){
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]));
    dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]));
  }

  dp[n-1] = min(dp[n-1], dp[n-2] + abs(h[n-1] - h[n-2]));

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

  return 0;
}


Measured memory_bytes: 1024
n, m = map(int, input().split())

students = [list(map(int, input().split())) for _ in range(n)]
checks = [list(map(int, input().split())) for _ in range(m)]

for s in students:
    dis = [abs(s[0] - c[0]) + abs(s[1] - c[1]) for c in checks]
    print(dis.index(min(dis))+1)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
map<int,list<int> > m;
ll int dp[100001];
ll int mi;
ll int upperdp[100000][2];
ll int ans[100001];
void go(ll int node,ll int par)
{
 
bool c=true;
dp[node]=1;
for(auto child: m[node])
{
if(child!=par)
{
	go(child,node);
	dp[node]=( dp[node] *(dp[child]+1))%mi;
	//allwhite=allwhite*(dp[i][1]);
	//allblack=allblack*dp[i][0];
	//second=second+dp[i][0];
	c=false;
}
 
}

return;
}
 void solve2(ll int node,ll int par,ll int parans)
 {ans[node]=(dp[node]*(1+parans))%mi;

 	vector<ll int> prefix,suffix;
 	for(auto i: m[node])
 	{if(i!=par)
 		{prefix.push_back(1+dp[i]);
          suffix.push_back(1+dp[i]);
 		}

 	}

for(int i=1;i<prefix.size();i++)
{prefix[i]=(prefix[i-1]*prefix[i])%mi;

}
for(int i=suffix.size()-2;i>=0;i--)
{
	suffix[i]=(suffix[i+1]*suffix[i])%mi;
}

int cno=0;
for(auto i: m[node])
{if(i!=par)
	{ll int ways=(1+parans);
		ways=(cno>0) ? (ways*prefix[cno-1])%mi : ways;
		ways=(cno<suffix.size()-1) ? (ways*suffix[cno+1])%mi : ways; 
          solve2(i,node,ways);
	cno++;
	}



}
return;

 }
int main()
{
 
ll int n;
cin>>n>>mi;
for(ll int i=1;i<=n-1;i++)
{ll int a,b;
	cin>>a>>b;
	m[a].push_back(b);
	m[b].push_back(a);
}

go(1,-1);
solve2(1,-1,0);
for(ll int i=1;i<=n;i++)
{
	cout<<ans[i]%mi<<endl;
}
 
 
}

Measured memory_bytes: 33152
S = gets.chomp
n = S.length

ans = n
i = 1
while i < n
	if S[i] == S[i - 1]
		ans -= 1
		i += 2
		if i == n - 2
			if S[n - 1] == S[n - 2]
				ans -= 1
            	i += 1
			end
		end
	end
	i += 1
end
puts ans

Measured memory_bytes: 2172
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
LL lpow(LL a,LL n){LL ans=pow(a,n)*10;if(ans%10<5)return ans/10;return ans/10+1;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}

DB dist(DB x1,DB y1,DB x2,DB y2){
  return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}
void eqd(DB* vx1,DB* vy1,DB* vx2,DB* vy2,DB x1,DB y1,DB x2,DB y2,DB r){
  DB x=(x1+x2)/2,y=(y1+y2)/2,d=dist(x1,y1,x2,y2),h=sqrt(r*r-d*d/4);
  if(d<ERR)*vx1=x,*vy1=y,*vx2=x,*vy2=y;
  else if(d-r*2>ERR)*vx1=-1,*vy1=-1,*vx2=-1,*vy2=-1;
  else if(r*2-d>ERR)*vx1=x-(y2-y1)*h/d,*vy1=y+(x2-x1)*h/d,*vx2=x+(y2-y1)*h/d,*vy2=y-(x2-x1)*h/d;
  else *vx1=x,*vy1=y,*vx2=x,*vy2=y;
}

int main(){
  LL N,i,j,k,l,flag;
  DB min=0-ERR,max=720.0,mid;
  scanf("%lld",&N);
  LL x[N],y[N];
  FOR(i,0,N)scanf("%lld%lld",&x[i],&y[i]);
  while(max-min>ERR){
    mid=(max+min)/2;
      FOR(i,0,N){
        FOR(j,i+1,N){
          DB nx[2],ny[2];
          eqd(&nx[0],&ny[0],&nx[1],&ny[1],x[i],y[i],x[j],y[j],mid);
          FOR(l,0,2){
          flag=0;
          FOR(k,0,N)if(dist(x[k],y[k],nx[l],ny[l])>mid+ERR){
            flag=1;break;
          }
          if(flag==0)break;
        }
        if(flag==0)break;
      }if(flag==0)break;
    }
    if(flag==0)max=mid;
    else min=mid;
  }

  printf("%.10f\n",max);
	return 0;
}


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

int main() {
  int A=0;
  int B=0;
  int S=0;

  cin >> A;
  cin >> B;
  
  S=A*B;
  
  if(0<A && A<10){
    if(0<B && B<10){
      cout << S << endl;
    }
    else{
    cout << -1 << endl;
    }
  }
  else{
    cout << -1 << endl;
  }
  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int n, m;

    rep(i, 3)
    {
        int a, b, c;
        cin >> a >> b >> c;

        if (!i)
        {
            n = abs(a - b);
            m = abs(b - c);
        }
        else
        {
            if ((n != abs(a - b)) || (m != abs(b - c)))
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
	if(fopen("INPUT.txt","r"))
	{
	freopen ("INPUT.txt" , "r" , stdin);
	freopen ("OUTPUT.txt" , "w" , stdout);
	}
#endif  

	int n;
	cin>>n;
	int a[n+1];
	int temp[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		temp[i]=a[i];
		a[i]=i-a[i];
		// cout<<a[i]<<" ";
	}

	int cnt=n;
	vector<int>ans;
	while (cnt--)
	{
		bool flag=false;
		for(int i=n;i>=1;i--)
		{
			if(a[i]==0)
			{
				flag=true;
				ans.push_back(temp[i]);
				a[i]=-1;
				for(int j=i+1;j<=n;j++)
				{
					a[j]--;
				}
				break;
			}
		}

		if(!flag)
		{
			cout<<-1;
			return 0;
		}
	}
	reverse(ans.begin(),ans.end());
	for(int i=0;i<n;i++)
	{
		if(ans[i]>i+1)
		{
			cout<<-1;
			return 0;
		}
	}
	for(auto i:ans)
		cout<<i<<'\n';

}


Measured memory_bytes: 256
k= int(input(). strip())
a, b = map(int,input().split())

if k == 1:
  print('OK')
  exit( )
else:
  pass
  
num = a
for num in range(a,b+1):
    if num % k != 0:
        num += 1
    else:
        print('OK')
        break
else:
	print('NG')


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

int H, W;
int A[200][200];
int dp[10][10];

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

    cin >> H >> W;

    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            cin >> dp[i][j];
        }
    }

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> A[i][j];
        }
    }

    for(int k=0; k<10; k++){
        for(int i=0; i<10; i++){
            for(int j=0; j<10; j++){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }

    int total = 0;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(A[i][j] != -1){
                total += dp[A[i][j]][1];
            }
        }
    }

    cout << total << endl;
    return 0;
}


Measured memory_bytes: 384
//Author: Rahul Purohit

#include<bits/stdc++.h>
#define vi vector<int>
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll  long long int
#define pi pair<ll,ll>
#define f first
#define mp make_pair
#define mod 1000000007
#define s second
#define pb push_back
#define mp make_pair
#define N 100001
using namespace std;
int gcd(int a, int b)
{
	if(b==0)
		return a;
	else
		return (b,a%b);
}
/*ll isp[N]={1};
void sieve(int n)
{
	isp[0]=isp[1]=0;
	for(int i=2;i<=n;i++)
	{
		if(isp[i]==1)
		{
			for(int j=i*i;j<=n;j+=i)
			{
				isp[j]==0;
			}
		}
	}
}*/
ll pow(int x,int  y,int m)
{
	ll ans=1;
	while(y!=0)
	{
		if(y%2==1)
		{
			ans=(ans*x)%m;
		}
		x=(x*x)%m;
		y/=2;
	}
	return ans;
}
template <class x>
void swap(x &a,x &b)
{
	x tp;
	tp=a;
	a=b;
	b=tp;
}
template <class x>
void max(x &a,x &b)
{
	return (a>=b?a:b);
}
template <class x>
void min(x &a,x &b)
{
	return (a>=b?b:a);
}
int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll a,b;
	cin>>a>>b;
	cout<<(b-a)*(b-a+1)/2-b;
	return 0;
}


Measured memory_bytes: 256
/* maybemaybemaybeno */
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef long double lld ;
#define f(i,s,n) for(int i=s;i<(int)n;i++) 
const int MAXN = 13 ;
#define pb push_back 
#define X first 
#define Y second 
#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define pli pair<ll,int> 
#define pil pair<int,ll> 
#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(10) ;
#define is(x) cout<<#x<<" : "<<x<<endl ;
// #define DEBUG
int c[MAXN] ;
int a[MAXN][MAXN] ;
int main()
{
    fio ;
    /* ======================Start of code ================ */
    int n,m,x;cin>>n>>m>>x ;
    f(i,0,n)
    {   
        cin>>c[i] ;
        f(j,0,m) cin>>a[i][j] ;
    }
    int ans = INT_MAX ;
    f(mask,0,(1<<n))
    {
        vector<int> ul(m,0) ;
        int cost = 0 ;
        f(j,0,n)
        {
            if((1<<j)&mask) // jth book is bought
            {
                cost+=c[j] ;
                f(k,0,m) ul[k]+=a[j][k] ;
            }
        }
        bool done = true ;
        f(k,0,m) if(ul[k]<x) 
        {
            done = false ;
            break ;
        }
        if(done)
            ans = min(ans,cost) ;
    }
    cout<<(ans==INT_MAX?-1:ans)<<"\n" ;
    /* ======================End of code ================== */
}

Measured memory_bytes: 3676
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}

void solve()
{
  ll N;
  std::cin >> N;

  std::vector< std::vector<ll> > num(10, std::vector<ll>(10, 0LL));
  for (ll i = 1; i <= N; i++) {
    std::string s = std::to_string(i);
    num[s[0] - '0'][s.back() - '0']++;
  }

  ll ans = 0LL;
  for (ll a = 1; a <= 9; a++) {
    for (ll b = 1; b <= 9; b++) {
      ans += num[a][b] * num[b][a];
    }
  }
  print(ans);
  return;
}

int main()
{
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  std::ios::sync_with_stdio(false);

  solve();
  return 0;
}



Measured memory_bytes: 256
import collections
n=int(input())
a=list(map(int, input().split()))
ans=0
b=[]
c=[]
for i in range(n):
    b.append(i+a[i])
    c.append(i-a[i])
b=collections.Counter(b)
c=collections.Counter(c)
for i in range((10**5)*2):
    ans+=b[i]*c[i]



print(ans)


Measured memory_bytes: 144028
fun main(args: Array<String>) {
	val (N, M, X, Y) = readLine()!!.split(" ").map { it.toInt() }
	val x = readLine()!!.split(" ").map { it.toInt() }.sorted()
	val y = readLine()!!.split(" ").map { it.toInt() }.sorted()
	var flg = false

	for (z in X + 1 .. Y) {
		if (z in x[x.size - 1] + 1 .. y[0]) {
			flg = true
		}
	}

	if (flg) {
		println("No War")
	} else {
		println("War")
	}
}


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

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

    int a_x = a, b_x = b;
    for (int i = 1; i < b; i++) {
        a_x *= 10;
        a_x += a;
    }
    for (int i = 1; i < a; i++) {
        b_x *= 10;
        b_x += b;
    }

    if (a < b) {
        cout << a_x << endl;
    } else {
        cout << b_x << endl;
    }

    return 0;
}


Measured memory_bytes: 3648
#include "math.h"
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define ifor(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--)
using namespace std;
typedef long double ld;
typedef long long int lli;
typedef complex<double> P;
const double eps = 1e-11;
int vex[4] = {1, 0, -1, 0};
int vey[4] = {0, 1, 0, -1};
typedef vector<double> Vec;
typedef vector<int> vec;
typedef vector<Vec> MAT;
typedef vector<vec> mat;
lli MOD = 1000000007;
int main()
{
    string s;
    cin >> s;
    lli k;
    cin >> k;
    rep(i, s.size())
    {
        if (k == 0)
            break;
        if (i == s.size() - 1) {
            s[i] = (char)((s[i] + k - 'a') % 26 + 'a');
            //s[i] = (char)(((s[i] - 'a') + k) % 26 + 'a');
            k = 0;
        } else {
            int n = 26 - (s[i] - 'a');
            if (s[i] == 'a')
                continue;
            if (n <= k) {
                k -= n;
                s[i] = 'a';
            } else {
            }
        }
        //cout << k << ": " << s << endl;
    }
    cout << s << endl;
}


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

int main()
{
	int num = 1;
	
	for (int i = 1;  num > 0; i++) {
		cin >> num;
		
		 if(num>0) {
			cout << "Case" << ' ' << i << ':' << ' ' << num << '\n';
		}
		 else if (num = 0) {

		 }
	}
	return 0;
}

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

int main(void) {

        int a,b;
        char op;

        while(1) {
                scanf("%d %c %d", &a, &op, &b);
                if(op == '?') break;
                else if(op == '+') printf("%d\n", a+b);
                else if(op == '-') printf("%d\n", a-b);
                else if(op == '*') printf("%d\n", a*b);
                else if(op == '/') printf("%d\n", a/b);
        }

        return 0;
}



Measured memory_bytes: 2116
import java.util.*;


public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int numbers[] = new int[n];
        for(int i = 0; i < n; i++){
            numbers[i] = sc.nextInt();
        }
        for(int i = n-1; i >= 0; i--){
            if(i != 0){
                System.out.print(numbers[i] + " ");
                
            }else{
                System.out.println(numbers[i]);
            }
        }

    }
}



Measured memory_bytes: 26228
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<128>>;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << (x) << '\n'
typedef long long lint;
const int INF = 2e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const lint LINF = 1e18;
typedef vector<int> vint;
typedef pair<int, int> pint;
template <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}
void print() { cout << endl; }
template <class T, class... A> void print(const T &first, const A &... rest) {
    cout << first;
    print(rest...);
}
template <class... A> void print(const A &... rest) { print(rest...); }
template <class T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
int modulo(int a, int b, int n) {
    long long x = 1, y = a;
    while(b > 0) {
        if(b % 2 == 1) {
            x = (x * y) % n; // multiplying with base
        }
        y = (y * y) % n; // squaring the base
        b /= 2;
    }
    return x % n;
}
/* templates */ /* templates */ /* templates */ /* templates */ /* templates */

const int MAXN = 300;
vector<vector<vector<bool>>>
    flag(MAXN + 10,
         vector<vector<bool>>(MAXN + 10, vector<bool>(MAXN + 10, false)));
vector<vector<vector<double>>>
    dp(MAXN + 10,
       vector<vector<double>>(MAXN + 10, vector<double>(MAXN + 10, 0.0)));
int N;

double f(int c1, int c2, int c3) {
    double fans;
    double prov;
    if(flag[c1][c2][c3]) {
        return dp[c1][c2][c3];
    }
    prov = 1 / (1 - (double)(N - c1 - c2 - c3) / N);
    flag[c1][c2][c3] = true;
    fans = prov;
    if(c1 > 0) {
        fans += f(c1 - 1, c2, c3) * ((double)c1 / N) * prov;
    }
    if(c2 > 0) {
        fans += f(c1 + 1, c2 - 1, c3) * ((double)c2 / N) * prov;
    }
    if(c3 > 0) {
        fans += f(c1, c2 + 1, c3 - 1) * ((double)c3 / N) * prov;
    }
    // cerr << c1 << " " << c2 << " " << c3 << endl;
    // debug(fans);
    return dp[c1][c2][c3] = fans;
}

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

    cin >> N;
    int a[N + 10];
    vint c(4, 0);
    rep(i, 1, N + 1) { cin >> a[i]; }
    rep(i, 1, N + 1) { c[a[i]]++; }
    dp[0][0][0] = 0;
    flag[0][0][0] = true;
    double ans = f(c[1], c[2], c[3]);
    cout << fixed << setprecision(14) << ans << endl;
}

Measured memory_bytes: 245888
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
 
const int N = 2e2 + 22;
int a, b, d[N][N], f[N][N];
 
int main() {
	scanf("%d%d", &a, &b);
	for (int i = 1; i <= a; i++)
		for (int j = 1; j <= b; j++) scanf("%d", d[i] + j);
	for (int i = 0; i <= 100; i++)
		for (int j = 0; j <= 100; j++)
			for (int x = 1; x <= a; x++)
				for (int y = 1; y <= b; y++)
					f[i][j] = std::max(f[i][j], d[x][y] - i * x - j * y);
	for (int x = 1; x <= a; x++)
		for (int y = 1; y <= b; y++) {
			int tmp = 1e9;
			for (int i = 0; i <= 100; i++)
				for (int j = 0; j <= 100; j++)
					tmp = std::min(tmp, f[i][j] + i * x + j * y);
			if (tmp != d[x][y]) return puts("Impossible"), 0;
		}
	puts("Possible\n202 10401");
	for (int i = 0; i < 100; i++)
		printf("%d %d X\n%d %d Y\n", i + 1, i + 2, i + 103, i + 102);
	for (int i = 0; i <= 100; i++)
		for (int j = 0; j <= 100; j++) printf("%d %d %d\n", i + 1, j + 102, f[i][j]);
	puts("1 102");
}

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

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 1100

int cost[MAX][MAX];
string mp[MAX];
int sy, sx, gy, gx;
int H, W, A, B;
int dxy[4] = {1,-1,0,0};

string solve(){
	priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int>>>> Q;
	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cost[i][j] = INF;
		}
	}
	
	Q.push(make_pair(0,make_pair(sy,sx)));
	
	cost[sy][sx] = 0;
	
	while(!Q.empty()){
		pair<int,pair<int,int>> P = Q.top(); Q.pop();
		int y = P.second.first, x = P.second.second, tcost = P.first;
		bool b = false, w = false;
		
		// cout<<y<<" "<<x<<endl;
		// cout<<" cost "<<tcost<<" "<<mp[y][x]<<endl;
		if(tcost < cost[y][x]) continue;
		if(y == gy && x == gx) return to_string(tcost);
		
		for(int i = -1; i <= 1; i++){
			for(int j = -1; j <= 1; j++){
				if(y+i < 0 || y+i >= H || x+j < 0 || x+j >= W) continue;
				// cout<<y+i<<"  TTT "<<x+j<<endl;
				if(mp[y+i][x+j] == '*') b = true;
			}
		}
		// cout<<"GGGGG "<<endl;
		for(int i = 0; i < 4; i++){
			int ny = y + dxy[i], nx = x + dxy[3-i];
			// cout<<" ny nx "<<ny<<" "<<nx<<endl;
			if(ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
			
			// if(mp[ny][nx] == '#' || mp[ny][nx] == '*') continue;
			if(mp[ny][nx] == '#') continue;
			
			// cout<<cost[ny][nx]<<"  cost"<<cost[y][x] + A<<endl;
			if(cost[ny][nx] <= cost[y][x] + A) continue;
			
			Q.push(make_pair(cost[y][x] + A,make_pair(ny,nx)));
			
			cost[ny][nx] = cost[y][x] + A;
		}
		
		if(b == true) continue;
		// cout<<"FFFFF"<<endl;
		for(int i = -1; i <= 1; i++){
			for(int j = -1; j <= 1; j++){
				if(i == j && i == 0) continue;
				int ny = y + i, nx = x + j, co = A+B;
			
				if(i&&j) co += A;
				
				if(ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
			
				if(cost[ny][nx] <= cost[y][x] + co) continue;
			
				Q.push(make_pair(cost[y][x] + co,make_pair(ny,nx)));
			
				cost[ny][nx] = cost[y][x] + co;
			}
		}
		
	}
	return "INF";
}

signed main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	
	cin>>H>>W>>A>>B;
	
	for(int i = 0; i < H; i++){
		cin>>mp[i];
		for(int j = 0; j < W; j++){
			if(mp[i][j] == 's'){
				sy = i, sx = j;
			}
			if(mp[i][j] == 'g'){
				gy = i, gx = j;
			}
		}
	}
	
	cout<<solve()<<endl;
	
	return 0;
}


Measured memory_bytes: 12716
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)

int main() {

	int n;
	cin >> n;

	int count = 0;

	map<string, int> m;

	vector<string> s(n);
	rep(i, 0, n) {
		cin >> s[i];
		if (m[s[i]] != 1) {
			m[s[i]] = 1;
			count++;
		}
	}

	cout << count << endl;

	return 0;
}


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

import sys


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


def resolve():
    n = input().rstrip()

    if n[-1] == "3":
        print("bon")
    elif n[-1] == "2" or n[-1] == "4" or n[-1] == "5" or n[-1] == "7" or n[-1] == "9":
        print("hon")
    else:
        print("pon")


if __name__ == "__main__":
    resolve()



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

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

    int max_val = 0;
    for(int i=0; i<S.length(); i++){
        int cnt = 0;
        for(int j=i; j<S.length(); j++){
            if(S[j]=='A' || S[j]=='G' || S[j]=='C' || S[j]=='T'){
                cnt++;
                continue;
            }
            break;
        }
        max_val = max(max_val, cnt);
    }

    printf("%d\n", max_val);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 8
#define free -1
#define not_free 1

void putQueen(int);
void printBoard();
void print();

int row[N],col[N],dpos[2 * N - 1],dneg[2 * N - 1],x[N][N];

int main()
{
  int i,j,d,r,c;
  for(i=0;i<N;i++){
    row[i] = free;
    col[i] = free;
  }
  for(i=0;i<2*N-1;i++){
    dpos[i] = free;
    dneg[i] = free;
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      x[i][j] = 0;
    }
  }
  scanf("%d",&d);
  for(i=0;i<d;i++){
    scanf("%d %d",&r,&c);
    x[r][c] = 1;
  }//printf("a");
  putQueen(0);

  return 0;
  
}

void putQueen(int i)
{
  int j;

  if(i == N){
    printBoard();
    return;
  }
  for(j=0;j<=N-1;j++){
    if(col[j] == not_free || dpos[i + j] == not_free || dneg[i - j + N - 1] == not_free){
      continue;
    }
    //put a queen at (i,j)
    row[i] = j;
    col[j] = dpos[i + j] = dneg[i - j + N - 1] = not_free;
    //try the next row
    putQueen(i + 1);
    // remove the queen at (i,j) for backtracking
    col[j] = dpos[i + j] = dneg[i - j + N - 1] = free;
  }
}

void printBoard()
{
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(x[i][j]){
	if(row[i] != j) return;
      }
    }
  }
  print();
}

void print()
{
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}


  
  



Measured memory_bytes: 2108
building1 = [[0] * 10, [0] * 10, [0] * 10]
building2 = [[0] * 10, [0] * 10, [0] * 10]
building3 = [[0] * 10, [0] * 10, [0] * 10]
building4 = [[0] * 10, [0] * 10, [0] * 10]
all_building = [building1, building2, building3, building4]
separator = '#' * 20


def int_decre(str_num):
    return int(str_num) - 1


n = int(input())
for i in range(n):
    b, f, r, v = map(int_decre, input().split(' '))
    all_building[b][f][r] += v + 1

for j in range(4):
    for i in range(3):
        print(' {0[0]} {0[1]} {0[2]} {0[3]} {0[4]} {0[5]} {0[6]} {0[7]} {0[8]} {0[9]}'.format(all_building[j][i]))
    if j == 3:
        pass
    else:
        print(separator)



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

typedef long long            ll;
typedef unsigned long long   ull;
typedef vector<int>          vi;
typedef vector<ll>           vl;
typedef pair<int, int>       pi;
typedef pair<ll, ll>         pl;
typedef vector<pi>           vpi;
typedef vector<pl>           vpl;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define read        freopen("in.c", "r", stdin)
#define write       freopen("out.c", "w", stdout)
#define all(a)      a.begin(), a.end()
#define bye         exit(0)
#define mp          make_pair
#define ff          first
#define ss          second
#define L(x)        ((x) << 1)
#define R(x)        ((x) << 1 | 1)
#define SZ(a)       (ll)(a).size()
#define pb          push_back
#define eb          emplace_back
#define eps         1e-9
#define inf         (1000000000)
#define infl        (1000000000000000000LL)
#define cs(p)       printf("Case %d:", (p)++)
#define ptc(c)      putchar(c)
#define gtc()       getchar()
#define nl          puts("")
#define sp          printf(" ")
#define out(a)      printf("%lld", (ll)(a))
#define SET(a, x)   memset((a), x, sizeof(a))
#define dbg(x)      cout << "--- " << #x << " = " << (x) << '\n'

ll bgm(ll a, ll b, ll m) {
    b = (b == -1) ? (m - 2) : b;
    a %= m;
    ll rem = 1;
    while(b != 0) {
        if(b&1)
            rem = (rem * a) % m;
        a = (a * a) % m;
        b >>= 1;
    }
    return rem;
}

inline ll in() {
    ll a;
    assert(scanf("%lld", &a) != EOF);
    return a;
}

const int MAX = 1000000 + 5;
const int LEN = 50;
const ll MOD = 1000000007;

int cnt[30];

int main() {
    //read,write;
    string s,s1,str="",input;
    cin >> s;
    while(getline(cin,input)){
        if(input=="END_OF_TEXT") break;
        s1+=input;
        s1+=" ";
    }
    int sz = s.size();
    int sz1=s1.size();
    int cnt=0;
    //cout << s1 << endl;
    //cout << sz << "    " << sz1 << endl;
    for(int i=0;i<sz1-sz;i++){
        while(s1[i]!=' ') {
            str+=s1[i];
            i++;
        }
        int strsz=str.size();
        for(int k=0;k<strsz;k++){
            if(str[k]>='A' && str[k]<='Z') str[k]+=32;
        }
        //cout << str << "----" << i << endl;
        if(str==s) {
            cnt++;
            //cout << str << "----" << i << endl;
        }
        str="";
    }
    cout << cnt << endl;

    return 0;
}



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


namespace ConsoleApplication72
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                string a = line;
                string c = "";
                for (int b = 0; b < a.Length; b++)
                {
                    if (a[b] == '@')
                    {
                        for (int d = 0; d < a[b + 1] - 49; d++)
                        {
                            c += a[b + 2];
                        }
                        b = b + 1;
                    }
                    else c += a[b];

                }
                Console.WriteLine(c);
            }
        }
    }
}

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

int digits_sum(int N)
{
	int sum = 0;
	
	while  (N > 0)
	{
		int d = N % 10;
		N /= 10;
		
		sum += d;
	}
	
	return sum;
}

int main(){
    int n;
    cin>>n;
    
    if(n % digits_sum(n) == 0)
        cout<<"Yes";
    else
        cout<<"No";

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    string n;  cin >> n;
    for(int i = 0; i < n.size() / 2; i++){
        if(n[i] != n[n.size() - 1 - i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main()
{
    std::vector<int> high(10);

    for(int i = 0; i < 10; ++i) std::cin>> high[i];

    std::sort(high.begin(), high.end());
    std::reverse(high.begin(), high.end());
    for(int i = 0; i < 3; ++i) std::cout << high[i] << std::endl;

    return 0;
}

Measured memory_bytes: 3160
use std::io;

fn main() {
    let pi : f64 = 3.1415926535 ;
    let r = scan_input().trim().parse::<f64>().unwrap();
    println!("{}", 2.0 * pi * r);
}

fn scan_input() -> String {
    let mut input = String::new();
    match io::stdin().read_line(&mut input) {
        Ok(_) => input,
        Err(_) => "".to_string(), 
    }
}


Measured memory_bytes: 2148
#include<iostream>
using namespace std;
int L, R;
int main()
{
	scanf("%d%d", &L, &R);
	if (R - L >= 2018)printf("%d\n",0);
	else {
		int tmp;
		int ans = 2019 * 2019;
		for(int i=L;i<=R;++i){
			for(int j=i+1;j<=R;++j){
				tmp = ((i % 2019)*(j % 2019))%2019;
				ans = ans > tmp ? tmp : ans;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define up_b upper_bound
#define low_b lower_bound
#define nl '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

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

const int N=2e5+11;
const int M=1e6+1;
const int inf=2e9+1;
const ld EPS=1e-6;
const ll INF=1e18;
const ll mod=/*998244353*/1e9+7;
const int dx[8]={0,0,-1,1,-1,1,1,-1};
const int dy[8]={-1,1,0,0,1,-1,1,-1};

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0),cout.tie(0);
  int h,w;
  cin>>h>>w;
  set<pair<int,int>>st;
  multiset<int>ans;
  st.insert(mp(0,0));
  ans.insert(inf);
  st.insert(mp(w+1,w+1));
  ans.insert(inf);
  for(int i=1;i<=w;i++){
    st.insert(mp(i,i));
    ans.insert(0);
  }
  for(int i=1;i<=h;i++){
    int a,b;
    cin>>a>>b;
    while(1){
      auto it1=st.low_b(mp(a,0));
      pair<int,int>p=*it1;
    //    cout<<p.x<<" "<<p.y<<endl;
      if(p.x>b)break;
      auto it2=it1;
      it2++;
      if((*it2).x<=b+1){
        st.erase(p);
        ans.erase(ans.find(p.x-p.y));
      }
      else if(p.x<=b){
        st.erase(p);
        ans.erase(ans.find(p.x-p.y));
        st.insert(mp(b+1,p.y));
        ans.insert(b+1-p.y);
        break;
      }
      else break;
    }
    int val=*ans.begin();
    if(val==inf)val=-1;
    else val+=i;
    cout<<val<<endl;
  }
}


Measured memory_bytes: 22364
//#pragma comment(linker, "/STACK:1024000000,1024000000")
/* vim: set fdm=marker */
//{{{
#define __ return
int ATTENTION() {
	/* pls IGNORE this function and go down and HACK me
	 * read this AFTER contest
	 * this function is empty and it will not be called !
	 */

	http://codeforces.com/group/Pmz2A2x7ES
	/* I created a group there.
	 * I hope with the group, people can finish
	 * past contests, which is important for 
	 * increasing rating.
	 * I am still getting familiar with this function.
	 */
	 __ 0;
}
// deprecated because mac doesn't support this...
/* #include <bits/stdc++.h> */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < 0) return gcd(-a, b);
	if(b < 0) return gcd( a,-b);
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}

ll qpow(ll a, ll n, ll mod) {
	a %= mod;
	ll ans = 1LL;
	while(n) {
		if(n & 1) ans = (ans*a % mod);
		a = (a*a % mod);
		n >>= 1;
	}
	return ans;
}

inline ll rev(ll a, ll p) {
	return qpow(a, p - 2, p);
}

#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define rep(x, st, en) for(int x = st; x < en; x++)
#define rer(x, st, en) for(int x = st; x >= en; x--)
#define pb push_back
#define mp make_pair
#define dbgm(msg, var) cerr<<#msg<<" "<<#var<<" = "<<var<<endl; 
#define dbg(var) cerr<<#var<<" = "<<var<<endl;
#define X first
#define Y second
// build prefix sum
template<typename T>
inline void BPS(T* DST, T* SRC, int N, int s = 0) {
	DST[s] = SRC[s];
	rep(i, 1, N) DST[s + i] = DST[s + i - 1] + SRC[s + i];
}
inline int in() { int x; cin>>x; return x; }
#ifdef ALNDBG
namespace alndbg {
	clock_t s, e;
}
#endif

inline void tic() {
#ifdef ALNDBG
	alndbg::s = clock();
#endif
}

inline void toc() {
#ifdef ALNDBG
	alndbg::e = clock();
	cerr<<1000.0 * (alndbg::e - alndbg::s) / CLOCKS_PER_SEC<<" ms"<<endl;
#endif
}



//}}}

// -------------------- Spliters ------------------------
// BFS求最短路小心vis可能访问过
const int maxn = 100555;
int a[maxn];
int main() {
  int n, k; scanf("%d%d", &n,&k);
  rep(i,0,n) scanf("%d", &a[i]);
  int x = (n - k) / (k - 1);
  if(x * (k - 1) != (n - k)) x++; // ceil
  printf("%d\n", 1 + x);
	return 0;
}
// --USE C++11
// *-USE O2



Measured memory_bytes: 640
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> dist(n, 0);
    int max_a = 0;
    rep(i,n){
        int a;
        cin >> a;
        ++dist[a];
        chmax(max_a, a);
    }
    bool ok = true;
    if(max_a%2 == 0){
        for(int i = 1; i < max_a/2; ++i) ok &= (dist[i] == 0);
        ok &= (dist[max_a/2] == 1);
        for(int i = max_a/2+1; i <= max_a; ++i) ok &= (dist[i] >= 2);
    }
    else{
        for(int i = 1; i < (max_a + 1)/2; ++i) ok &= (dist[i] == 0);
        ok &= (dist[(max_a + 1)/2] == 2);
        for(int i = (max_a + 1)/2 + 1; i <= max_a; ++i) ok &= (dist[i] >= 2);
    }
    if(ok) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>

int main(void)
{
	unsigned long long int a, b, c;
	unsigned long long int max;
	

	scanf("%lld%lld%lld", &a, &b, &c);

	if (c >= b) {
		max = (unsigned long long int)(a * (b - 1) / b);
	}

	else {
		max = (unsigned long long int)(a * c / b);
	}

	printf("%lld", max);

	return 0;
}

Measured memory_bytes: 1732
#include <cstdio>
#include <algorithm>

using namespace std ;

int main( void ) {
        int n, x, y, z ;
        scanf( "%d", &n ) ;
        x = y = z = 0 ;
        for( int i = n; i--; ) {
                int a, b, c ;
                scanf( "%d %d %d", &a, &b, &c ) ;
                int xx, yy, zz ;
                xx = max( y + b, z + c ) ;
                yy = max( x + a, z + c ) ;
                zz = max( x + a, y + b ) ;
                x = xx ;
                y = yy ;
                z = zz ;
        }
        printf( "%d\n", max( x, max( y, z ) ) ) ;
        return 0 ;
}


Measured memory_bytes: 128
def input_from_console():
    n, a, b = map(int, input().split())
    return n, a, b


def solve(n, a, b):
    result = min(a * n, b)
    return result


def main():
    n, a, b = input_from_console()
    print(solve(n, a, b))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

Measured memory_bytes: 3060
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 1; i <= (int)(n); i++)
using namespace std;

int main() {
    int N;
    cin >> N;
    cout << N * 3.14159 * 2 << endl;
    return 0;
}


Measured memory_bytes: 3784
/** "Ever tried.
         Ever failed.
               No matter.
                   Try Again.
                        Fail again.
                             Fail better.**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define pb push_back
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define setdp memset(dp,-1,sizeof(dp))
#define fr first
#define sc second
#define NumofDigits(n)   ((long long)log10(n)+1)
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-9;
const int MOD = 1e9+7;
/*
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}
int dx[] = {- 1, 0, 0, 1, 0 };
int dy[] = { 0,- 1, 1, 0, 0 };*/
void File()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    ll n;
    cin>>n;
    int ans=NumofDigits(n);
    for(ll a=1ll; a*a<=n; a++)
    {
        if(n%a!=0)
            continue;
        ll b=n/a;
        int cnt=max(NumofDigits(a),NumofDigits(b));
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3812
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
pair<int, int> P[2011];

LL dp[2011][2011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", &P[i].first), P[i].second = i;
    sort(P, P+N);

    memset(dp, 0xc0, sizeof dp);
    dp[0][0] = 0;
    REP (i, N) {
	LL val = P[N-1-i].first;
	LL x = P[N-1-i].second;
	REP (j, i+1) {
	    amax(dp[i+1][j+1], dp[i][j] + val * abs(x - j));
	    LL y = N-1-i+j;
	    amax(dp[i+1][j], dp[i][j] + val * abs(x - y));
	}
    }

    LL ans = -(1LL<<60);
    REP (i, N+1) amax(ans, dp[N][i]);
    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 35392
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder res = new StringBuilder();
        int t = 1000000000;
        int n = sc.nextInt(), k = sc.nextInt(), s = sc.nextInt();
        int[] A = new int[n];
        for(int i = 0; i < k; i++) A[i] = s;
        if(s == t) t = 1;
        for(int i = k; i < n; i++) A[i] = t;
        for(int i = 0; i < n-1; i++) res.append(A[i] + " ");
        res.append(A[n-1]);
        System.out.println(res);
    }
}


Measured memory_bytes: 46576
#include <bits/stdc++.h>
using  namespace std;
#define ll    long long int
#define pai     pair<int,int>
#define vi      vector<int>
#define vd      vector<double>
#define mpi     map<int,int>
#define mps     map<string,int>
#define sti     stack<int>
#define stc     stack<char>
#define sei     set<int>
#define ses     set<string>
#define multii  multiset<int>

 int main()
{
  /*#ifndef ONLINE_JUDGE
  freopen("tin.txt","r",stdin);
  freopen("tout.txt","w",stdout);
  #endif*/
  ll a,b;
  string s;
  while(cin>>a>>b){
   s=to_string(a+b);
   cout<<s.size()<<endl;
  }

}







Measured memory_bytes: 3104
open Scanf;;
open Printf;;

let () =
  let s = read_line () in
  let t = read_line () in
  let ans = ref 0 in
  for i = 0 to String.length s - 1 do
    if s.[i] = t.[i] then incr ans;
  done;
  printf "%d\n" (!ans);


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
signed main()
{
    fastio();   
    int t=1;
    //cin>>t;
    ll a,b;
    cin>>a>>b;
    cout<<((b>=a)?"unsafe":"safe")<<endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <numeric>
#include <vector>

int count_num(int x)
{
    int ret = 0;
    if (x % 2 != 0) {
        return ret;
    }
    
    while (x % 2 == 0) {
        ++ret;
        x /= 2;
    }

    return ret;
}

int main() {
    int N;
    std::cin >> N;

    std::vector<int> a;
    a.reserve(N);
    int z;
    for(int i = 0; i < N; ++i) {
        std::cin >> z;
        a.push_back(z);
    }

    const int ret = std::accumulate(
        a.cbegin(), a.cend(), 0,
        [](int x, int y) { return x + count_num(y); }
    );
    
    std::cout << ret << std::endl;
}


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

int main() {
  int n;
  while(cin >> n && n) {
    int t[1000],z[1000];
    memset(t,-1,sizeof(t));
    memset(z,0,sizeof(z));
    while(n--) {
      int h,m;
      string _,a,b;
      cin >> _;
      scanf("%d%*c%d",&h,&m);
      cin >> a >> b;
      int x,y=h*60+m;
      stringstream ss;
      ss << b;
      ss >> x;
      if(a=="I") t[x]=y;
      else {
	if(x==0) {
	  for(int i=1; i<1000; i++) {
	    if(t[i]!=-1) z[i]+=y-max(t[0],t[i]);
	  }
	} else {
	  if(t[0]!=-1) z[x]+=y-max(t[0],t[x]);
	}
	t[x]=-1;
      }
    }
    int ans=0;
    for(int i=1; i<1000; i++) ans=max(ans,z[i]);
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int c = a * b;
  int r = c % 2;
  
  if (r == 0) {
    cout << "Even" << endl;
  }
  else if (r == 1) {
      cout << "Odd" << endl;
  }
}


Measured memory_bytes: 256
import math
N,K = map(int, input().split())
a = list(map(int,input().split()))
l = 0
r = K - 1
Min = float("inf")
for i in range(N - K + 1):
    if(a[l]*a[r]<=0):#原点を跨ぐとき
        Min = min(Min,abs(a[l])+abs(a[l]-a[r]),abs(a[r])+abs(a[r]-a[l]))
    elif(l == 0 and r == N-1):
        Min = min(Min,abs(a[l])+abs(a[l]-a[r]),abs(a[r])+abs(a[r]-a[l]))        
    elif(l==0):#左端の時
        if(a[r]*a[r+1]<0 or a[0]>0 or (a[N-1]<0 and r == N-1)):
            Min = min(Min,abs(a[l])+abs(a[l]-a[r]),abs(a[r])+abs(a[r]-a[l]))
    elif(r==N-1):#右端の時
        if(a[l-1]*a[l]<0 or (a[l]>0 and l == 0) or a[r] <= 0):
            Min = min(Min,abs(a[l])+abs(a[l]-a[r]),abs(a[r])+abs(a[r]-a[l]))
    else:
        if(a[r]*a[r+1]<0 or a[l-1]*a[l]<0):
            Min = min(Min,abs(a[l])+abs(a[l]-a[r]),abs(a[r])+abs(a[r]-a[l]))
    l = l + 1
    r = r + 1
print(Min)

Measured memory_bytes: 14172
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        Set S = new HashSet<>();
        for (int i = 0; i < N;i++) {
			S.add(sc.next());
        }
        System.out.println(S.size());

    }
}


Measured memory_bytes: 78188