akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL); cout.tie(NULL);}
#define f first
#define s second
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
typedef long long ll;
typedef long double lld;
typedef unsigned long long ull;
 
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
	cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
	cin >> p.first;
	return cin >> p.second;
}
 
mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(61378913);
/* usage - just do rng() */
 
void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}
 
const lld pi = 3.14159265358979323846;
const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;
 
 
 
ll n, m, k, q, l, r, x, y, z;
const ll template_array_size = 1e6 + 1389;
ll a[template_array_size];
ll b[template_array_size];
ll c[template_array_size];
string s, t;
ll ans = 0;
 
pair<ll, ll> p[200005];
 
void solve(int tc = 0) {
	cin >> n;
	
	for (ll i = 0; i < n; i++) {
		cin >> p[i];
	}
	
	sort(p, p + n);
	
	ans = 0;
	ll mxabove = -p[0].f + p[0].s;
	ll mnbelow = p[0].f + p[0].s;
	
	for (ll i = 1; i < n; i++) {
		ans = max({ans, p[i].f - p[i].s + mxabove, p[i].f + p[i].s - mnbelow});
		mxabove = max(mxabove, -p[i].f + p[i].s);
		mnbelow = min(mnbelow, p[i].f + p[i].s);
	}
	
	cout << ans << '\n';
}
 
int main() {
	#ifdef galen_colin_local
		auto begin = std::chrono::high_resolution_clock::now();
	#endif
	
	send help
 
	#ifndef galen_colin_local
		// usaco("moop");
	#endif
	
	// usaco("cowland");
	
	// freopen("tc.cpp", "r", stdin);
 
	int tc = 1;
	// cin >> tc;
	for (int t = 0; t < tc; t++) solve(t);
	
	#ifdef galen_colin_local
		auto end = std::chrono::high_resolution_clock::now();
		cout << setprecision(4) << fixed;
		// cout << "Execution time: " << std::chrono::duration_cast<std::chrono::duration<double>>(end - begin).count() << " seconds" << endl;
	#endif
} 

Measured memory_bytes: 6720
#include <cstdio>

using namespace std;

bool count[30];

int main(){
  for(int i = 0; i < 30; i++){
    count[i] = true;
  }
  for(int i = 0; i < 28; i++){
    int a;
    scanf("%d", &a);
    count[a - 1] = false;
  }
  for(int i = 0; i < 30; i++){
    if(count[i]){
      printf("%d\n", i + 1);
    }
  }
  return 0;
}

Measured memory_bytes: 1028
fun main(args:Array<String>):Unit {
    val n = readLine()!!.toInt()
    val nums = readLine()!!.split(' ').map(String::toInt)
    val sorted = nums.sorted().toIntArray()
    val mid = sorted[n / 2 - 1]
    val midNext = sorted[n / 2]
    for (xi in nums){
        println(if (mid >= xi) midNext else mid)
    }
}

Measured memory_bytes: 100984
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <numeric>
#include <map>
using namespace std;

int main(){
    long double a ;
    long double b ;
    cin >> a >> b ;
    int64_t ans = a*b/1 ;
    cout << ans << endl ;
}

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

using namespace std;

typedef long long ll;

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

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

	if(m == 0){
		if(n == 1){
			cout << 0 << endl;
			return 0;
		}

		if(n == 2){
			cout << 10 << endl;
			return 0;
		}

		if(n == 3){
			cout << 100 << endl;
			return 0;
		}
	}

	vector<int> s(m), c(m);
	rep(i, m) cin >> s[i] >> c[i];

	if(n == 1){
		int x = c[0];
		rep(i, m){
			if(s[i] > n || c[i] != x){
				cout << -1 << endl;
				return 0;
			}
		}
		cout << x << endl;
	}else{
		int INF = 100;
		vector<int> v(n, INF);
		rep(i, m){
			if(s[i] > n){
				cout << -1 << endl;
				return 0;
			}

			if(s[i] == 1 && c[i] == 0){
				cout << -1 << endl;
				return 0;
			}

			if(v[s[i]-1] != INF && v[s[i]-1] != c[i]){
				cout << -1 << endl;
				return 0;
			}

			v[s[i]-1] = c[i];
		}

		int ans = 0;
		int d = 1;
		for(int i = n - 1; i >= 0; i--){
			if(v[i] == INF){
				if(i == 0) ans += d;
			}else{
				ans += v[i] * d;
			}

			d *= 10;
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef complex<int> P;
string S;
int p,overflow;
P bnf();

bool isOverflow(P a){return abs(a.real()) > 10000 || abs(a.imag()) > 10000;}

P getNum(){
  P res = 0;
  if(S[p] == 'i'){p++;return P(0,1);}

  if(S[p] == '('){
    p++, res = bnf(), p++;
    return res;
  }
  
  while(p<(int)S.size()&&isdigit(S[p])){
    res = P(res.real()*10 + S[p++] - '0',0);
    overflow |= isOverflow(res);
  }                                      
  return res;
}
 
P calc(){
  P num = getNum();
  while(S[p] == '*')p++, num *= getNum(),overflow |= isOverflow(num);
  overflow |= isOverflow(num);
  return num;
}

P bnf(){
  P res = calc();
  overflow |= isOverflow(res);
  while(p<(int)S.size()){
    char ch = S[p];
    if(ch == '+')p++,res+=calc();
    else if(ch == '-')p++,res-=calc();    
    else if(ch == '*')p++,res*=calc();
    else if(ch == ')') break;
    else assert(ch==')');
     overflow |= isOverflow(res);
  }
  return res;
}
 
 
signed main(){
  int cnt = 0;
  while(cin>>S){
    p = overflow = 0;
    P ans = bnf();
    if(overflow) cout<<"overflow"<<endl;
    else if(ans.real() == 0 && ans.imag() == 0)cout<<0<<endl;
    else if(ans.real() == 0 ) cout<<ans.imag()<<"i"<<endl;
    else if(ans.imag() == 0) cout<<ans.real()<<endl;
    else if(ans.imag() > 0) cout<<ans.real()<<"+"<<ans.imag()<<"i"<<endl;
    else  cout<<ans.real()<<ans.imag()<<"i"<<endl;
  }

   
  return 0;
}

Measured memory_bytes: 3068
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
	class Program5
	{
		static void Main(string[] args)
		{
			var abt = Console.ReadLine().Split(' ');

			int a = int.Parse(abt[0]);
			int b = int.Parse(abt[1]);
			int t = int.Parse(abt[2]);

			int n = t / a;
			int num = n * b;

			Console.Write(num.ToString() + "\n");
			//Console.ReadLine();
		}
	}
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define reep(i,n) for(ll i = n; i >-1; i--)
#define deb(variable) cout<<#variable<<"="<<variable<<endl
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
const ll INF=99999999999999999;
const ll MOD=128;
const ll MAX_N=500010;
ll a,b,c,d,e,x,y,z,k,m,n,l,q,ans=0;
vl v(100010,0),anss(100010,0);
vp p[100010];
string s;
ll solve(void){
    a=0;
    b=0;
    if(n/100<13&&(n/100>0))a++;
    if(n%100<13&&(n%100>0))b++;
    if(a==1&&b==1){
        cout<<"AMBIGUOUS"<<endl;
    }
    if(a==0&&b==1){
        cout<<"YYMM"<<endl;
    }
    if(a==1&&b==0){
        cout<<"MMYY"<<endl;
    }
    if(a==0&&b==0){
        cout<<"NA"<<endl;
    }
    return 0;
}
int main(){
    cin>>n;
    solve();
}

Measured memory_bytes: 4096
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX=200000;

int main(){
    int n;
    int minv;
    int maxv=-2000000000;
    int R[MAX];

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>R[i];
    }
    minv=R[0];
    for(int j=1;j<n;j++){
        maxv=max(maxv,R[j]-minv);
        minv=min(minv,R[j]);
    }
    cout<<maxv<<endl;

    return 0;
}


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

ll mpower(ll a,ll b,ll c){
  int z;
  if(b==0){
    z=1;
    z%=c;
    return z;
  }
  if(b==1){
    z=a;
    z%=c;
    return z;
  }
  else{
    return (((mpower(a,b/2,c))*(mpower(a,b/2,c))%c)*mpower(a,b%2,c)%c);
  }
}

int main() {
  ll mod=1e9+7;
  int n;
  cin>>n;
  ll vec[n];
  ll copyvec[n];
  ll lcma[1000007]={0};
  for(int i=0;i<n;i++){
    cin>>vec[i];
    copyvec[i]=vec[i];
  }
  ll x=0,y=1;
  for(int i=0;i<n;i++){
    for(int j=2;j*j<=vec[i];j++){
      if(vec[i]%j==0){
        x=0;
        while(vec[i]%j==0){
          x++;
          vec[i]/=j;
        }
        lcma[j]=max(lcma[j],x);
      }
    }
    if(vec[i]>0){
      lcma[vec[i]]=max(lcma[vec[i]],y);
    }
  }
  ll q=1;
  for(int i=0;i<1000007;i++){
    if(lcma[i]>0){
      q*=mpower(i,lcma[i],mod);
      q%=mod;
    }
  }
  ll ans=0;
  for(int i=0;i<n;i++){
    ans+=q*mpower(copyvec[i],mod-2,mod);
    ans%=mod;
  }
  cout<<ans<<endl;
}

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

 
 
int main()
{
    int k, a, b;
 
    cin >> k >> a >> b;
 
    int x = b/k - (a-1)/k;
 
    if(x == 0){
        cout << "NG" << endl;
    } else {
        cout << "OK" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3052
n, m = gets.strip.split.map(&:to_i)
l = []
r = []
m.times do |i|
  l[i], r[i] = gets.strip.split.map(&:to_i)
end 

low = l[0]
high = r[0]

(1..m-1).each do |i|
  if l[i] <= high || r[i] >= low
    low = [low, l[i]].max
    high = [high, r[i]].min
    if high < low 
      puts '0'
      exit 
    end
  else
    puts '0'
    exit
  end
end

puts (high-low + 1).to_s

Measured memory_bytes: 3436
import sys

readline = sys.stdin.readline

N, K = map(int, readline().split())
S = readline().rstrip()

c = S[K - 1]
c_ = chr(ord('a') + (ord(c) - ord('A')))

s = [c for c in S]
s[K - 1] = c_
print(''.join(s))


Measured memory_bytes: 38384
#include <stdio.h>

int main(){
  int n, k, sunu[101] = {0};
  scanf("%d%d", &n, &k);

  for(int i=0; i<k; i++){
    int d;  scanf("%d", &d);
    for(int j=0; j<d; j++){
      int aaa;  scanf("%d", &aaa);
      sunu[aaa] = 1;
    }
  }

  int counter = 0;
  for(int i=1; i<=n; i++){
    if(sunu[i] == 0)  counter++;
  }
  printf("%d\n", counter);
  return 0;
}


Measured memory_bytes: 1732
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //c
  long long n;
  cin >> n;
  long long ans = 1LL << 60;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i) continue;
    ans = min(ans, i + n / i - 2);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>

int main() {
  static const double pi = 3.141592653589793;
  int a, b, C;
  std::cin >> a >> b >> C;
  double ang = C * pi / 180;
  double S = a * b * sin(ang) / 2;
  double L = a + b + sqrt(pow(a,2) + pow(b,2) - 2 * a * b * cos(ang));
  double h = b * sin(ang);
  printf("%lf\n%lf\n%lf\n", S, L, h);
  return 0;
}

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

int main(){
  ll A, B, C ,K;
  cin >> A >> B >> C >> K;
  if(A+B>K){
    if(A<K){
      K = A;
    }
  }else{
    K = A - (K-A-B);
  }
  cout << K <<endl;

  return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll a[100010], b[100010], rt[100010], lf[100010], c[100010];
int main(){
  ll n, x, q;
  cin>>x>>n;
  for(int i=1; i<=n; ++i){
    scanf("%lld",&a[i]);
  }
  lf[0]=0;rt[0]=x;
  a[n+1]=1e9 + 10;
  n+=2;
  b[0]=0;c[0]=x;
  for(int i=1; i<n; ++i){
    if(i%2==0){
      if(c[i-1]+a[i]-a[i-1] > x){
        rt[i]= max(0ll, rt[i-1] - (c[i-1]+a[i]-a[i-1] - x));
      }
      else{
        rt[i]=rt[i-1];
      }
      lf[i]=lf[i-1];
      b[i]=min(x, b[i-1]+a[i]-a[i-1]);
      c[i]=min(x, c[i-1]+a[i]-a[i-1]);
    }
    else{
      if(b[i-1]-(a[i]-a[i-1]) < 0){
        lf[i]= min(x, lf[i-1] +(0 - (b[i-1]-(a[i]-a[i-1]))));
      }
      else{
        lf[i]=lf[i-1];
      }
      rt[i]=rt[i-1];
      b[i]=max(0ll, b[i-1]-(a[i]-a[i-1]));
      c[i]=max(0ll, c[i-1]-(a[i]-a[i-1]));
    }
//    cout<<lf[i]<<"--"<<rt[i]<<endl;
//    cout<<b[i]<<"(())"<<c[i]<<endl;
  }
  cin>>q;
  ll ans, tmp, r, t, p;
  for(int i=0; i<q; ++i){
    scanf("%lld%lld",&t,&r);
    p=upper_bound(a, a+n, t)-a;
    --p;
//    cout<<p<<endl;
    if(r>=rt[p]){
      ans=c[p];
    }
    else if(r<=lf[p]){
      ans=b[p];
    }
    else{
      ans=min(c[p], b[p]+r-lf[p]);
    }
//    cout<<ans<<endl;
    tmp=t-a[p];
    if(p%2){
      ans=min(x, tmp+ans);
    }
    else{
      ans=max(0ll, -tmp+ans);
    }
    printf("%lld\n",ans);
  }

  return 0;
}




Measured memory_bytes: 5120
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
	int K;
	string S, ans;
	cin >> K;
	cin >> S;
	if (K < S.size()) {
		ans = S.substr(0, K) + "...";
	}
	else {
		ans = S;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3612
import qualified Data.Vector.Unboxed as U
import qualified Data.IntMap         as M

main :: IO ()
main = do
  n <- readLn
  as <- U.fromListN n . map read . words <$> getLine
  print $ solve as

solve :: U.Vector Int -> Int
solve as = M.foldr (+) 0 $ M.intersectionWith (*) lmp rmp
  where
    ls = U.imap (\i a -> i + a) as
    rs = U.imap (\i a -> i - a) as
    lmp = U.foldr (\x mp -> M.insertWith (+) x 1 mp) M.empty ls
    rmp = U.foldr (\x mp -> M.insertWith (+) x 1 mp) M.empty rs

Measured memory_bytes: 86276
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    mod = 1000000007

    H, W = map(int, input().split())
    a = [list(input().rstrip()) for _ in range(H)]
    for i in range(H):
        for j in range(W):
            if a[i][j]=='#':
                a[i][j] = 0
    a[0][0] = 1
    for i in range(H):
        for j in range(W):
            if a[i][j]=='.':
                if i==0:
                    a[i][j] = a[i][j-1]
                elif j==0:
                    a[i][j] = a[i-1][j]
                else:
                    a[i][j] = a[i-1][j] + a[i][j-1]
    print(a[H-1][W-1]%mod)



if __name__ == '__main__':
    main()


Measured memory_bytes: 235176
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forN(i, n) for(int i = 0; i <n ; ++i)
#define endl "\n"
#define noob (main)
typedef long long ll;
using namespace  std;
typedef vector<ll> vi;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const int N = 55 ;

bool is_sorted(vector<int> V){
    for(int i = 1 ; i< V.size();i++){
        if(V[i]<V[i-1]){
            return false;
        }
    }
    return true;
}
int noob(){
    fastIO;
    int n ;
    cin>>n;
    vector<int> A(N);
    int cnt = 0;
    for(int i = 1 ; i<= n; i++){
        cin>>A[i];
        if(A[i] != i ){
            cnt++;
        }
    }
    if(cnt>2){
        cout<<"NO";
    }
    else cout<<"YES";

}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a - c) <= d)
        cout << "Yes" << endl;
    else if (abs(a - b) <= d && abs(c - b) <= d)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

using namespace std;

typedef pair<int, int> P;
typedef long long LL;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int st = max(a, c);
    int ed = min(b, d);

    if (ed - st >= 0) {
        cout << ed - st << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
// by newbiechd
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>

// DELETE the debugging information!
#define debug(x) std::cerr << #x << " = " << (x) << std::endl

long long gcd(long long x, long long y) {
  return y == 0 ? x : gcd(y, x % y);
}

int main() {
  long long n, x;
  scanf("%lld%lld", &n, &x);
  printf("%lld\n", (n - gcd(n, x)) * 3);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
int main(){
    int x;
    cin>>x;
    bool p=false;
    if(x==2) p=true;
    while(!p){
        for(int i=2;i*i<=x;i++){
            if(x%i==0){
                p=true;
                break;
            }
            
        }
        if(p){
            x++;
            p=false;
        }
        else p=true;
    }
    cout<<x<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF LLONG_MAX
int n;

int main()
{
    cin>>n;
    ll h[n];
    
    for(ll i=0;i<n;i++)
    {
        cin>>h[i];
    }
    
    ll t[n+1];

     for(ll i=1;i<=n;i++)
    {
        t[i]=INF;
    }
        t[0]=0;
    
    for(int i=0;i<=n;i++)
    {
        if(i+1<=n)
            t[i+1] = min(t[i+1],t[i]+abs(h[i]-h[i+1]));
        
        if(i+2<=n)
        {
            t[i+2]=min(t[i+2],t[i]+abs(h[i]- h[i+2]));
        }
    }
    
    cout<<t[n-1]<<"\n";
    
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
typedef long long ll;

const int MAX_N=1e5;

int N,K;
int A[MAX_N];

ll sum1[MAX_N+1],sum2[MAX_N+1];

int main(){
	cin>>N>>K;
	REP(i,N){
		cin>>A[i];
	}
	REP(i,N){
		sum1[i+1]=sum1[i]+A[i];
		sum2[i+1]=sum2[i]+max(A[i],0);
	}
	ll ans=0;
	REP(i,N-K+1){
		ans=max(ans,max(sum1[i+K]-sum1[i],0LL)+sum2[i]+sum2[N]-sum2[i+K]);
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

vector<int> vector_compare;
int cont, valor_i, valor_j, valor_em_i;

bool encounter_occurrences(int numero) {
	vector<int>::iterator number_to_find = find(vector_compare.begin(), vector_compare.end(), numero);
	if(number_to_find != vector_compare.end()) {
		valor_j = cont;
		valor_em_i = numero;
		valor_i = distance(vector_compare.begin(), number_to_find);
		return true;
	}
	return false;
}

int max_number(int numero, int tamanho) {
	int numero_max;
	
	ostringstream convert;
	convert << numero;
	string result = convert.str();
	
	for(int index = result.size(); index < tamanho; ++ index)
		result += '0';
		
	sort(result.begin(), result.end());
	
	reverse(result.begin(), result.end());
	
	istringstream number_string(result);
	number_string >> numero_max;
	
	return numero_max;
}

int min_number(int numero, int tamanho) {
	int numero_min;
	
	ostringstream convert;
	convert << numero;
	string result = convert.str();
	
	for(int index = result.size(); index < tamanho; ++ index)
		result += '0';
		
	sort(result.begin(), result.end());
	
	istringstream number_string(result);
	number_string >> numero_min;
	
	return numero_min;
}

int compare_number(int numero, int tamanho) {
	if(encounter_occurrences(numero))
		return 0;
		
	vector_compare.push_back(numero);
	
	int numero_max = max_number(numero, tamanho);
	int numero_min = min_number(numero, tamanho);
	
	int difereca = numero_max - numero_min;
	
	cont += 1;
	
	compare_number(difereca, tamanho);
}

int main() {
	int numero, tamanho;
	
	while(true) {
		cin >> numero >> tamanho;
		
		if(numero == 0 && tamanho == 0)
			break;
			
		vector_compare.clear();
		cont = 0;
		valor_i = 0;
		valor_j = 0;
		valor_em_i = 0;
		
		compare_number(numero, tamanho);
		
		cout << valor_i << " " << valor_em_i << " " << (valor_j - valor_i) << endl;
	}
	return 0;
}


Measured memory_bytes: 3164
/*//////////////////////////////////////*/
/*/  NULLCT$ (｀･ω･´) <<"Be accept!!"  /*/
/*//////////////////////////////////////*/
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <type_traits>
#include <cstdint>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(counter, limit) for (int counter = 0; counter < limit; counter++)
typedef long long ll; using namespace std;
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

  int a;
  cin>>a;
  vector<int> l(a);
  rep(i,a)cin>>l[i];
  rep(i,a){
    if(l[i] % 2==0){
      if(!(l[i] % 3==0 || l[i] % 5==0)){
        cout<<"DENIED"<<endl;
        return 0;
      }
    }
  }
  cout<<"APPROVED"<<endl;
  return 0;

return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

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

  if(N%10==9 || N/10==9) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <vector>
#include <sstream>
using namespace std;
template<class T=int> inline T toint(string s) { T r; istringstream iss(s); iss >> r; return r; }

int main() {
    string s; cin >> s;
    int n = s.length();
    int mi = 753;
    for (int i = 0; i + 3 <= n; i++) {
        mi = min(mi, abs(753 - toint(s.substr(i, 3))));
    }
    cout << mi << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i,a) for(ll i=a-1;i>=0;i--)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)
#define printall(n,array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

map<int,int>res;
ll ncr[102][102];

void prime_factor(int n){
    for(int i=2;i*i<=n;i++){
        while(n%i==0){
            ++res[i];
            n/=i;
        }
    }
    if(n!=1)res[n]++;
}


//nCnまで計算
void nCr(int n){
    REP(i,n+1)REP(j,i+1){
            if(j==0)ncr[i][j]=1;
            else ncr[i][j]=ncr[i-1][j]+ncr[i-1][j-1];
        }
}


int main(){
    int n;
    cin >> n;
    rep(i, 1, n + 1)prime_factor(i);
    nCr(100);
    ll gt2 = 0, gt4 = 0, gt14 = 0, gt24 = 0, gt74 = 0;
    for(auto itr = res.begin(); itr != res.end();itr++){
        if(itr->second >= 2)gt2++;
        if(itr->second >= 4)gt4++;
        if(itr->second >= 14)gt14++;
        if(itr->second >= 24)gt24++;
        if(itr->second >= 74)gt74++;
    }
    ll ans = 0;
    ans += ncr[gt4][2] * (gt2-2);
    ans += gt14 * (gt4-1);
    ans += gt24 * (gt2-1);
    ans += gt74;
    print(ans);
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long ll;
typedef pair<int, int> P;


int main() {
    ll x, y;
    cin >> x >> y;
    if (abs(x-y) <= 1) cout << "Brown" << endl;
    else cout << "Alice" << endl;



    return 0;
}


Measured memory_bytes: 256
package main

// Solution for https://atcoder.jp/contests/abc175/tasks/abc175_a

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var s string
	con.Scan(&s)
	c := 0
	switch s {
	case "RRR":
		c = 3
	case "RRS", "SRR":
		c = 2
	case "SSS":
		c = 0
	default:
		c = 1
	}
	con.Println(c)
	return nil
}


Measured memory_bytes: 1848
#include <bits/stdc++.h>
#define ll long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define rep(i, init, n) for (int i = init; i < n; i++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define gcd __gcd
using namespace std;
const ll mod = 1e9 + 7;
const int N = 2e5 + 1;
const ll MOD = 998244353;
int c = 0;
set<int> s[N];
vector<bool> visited(N, 0);

ll POW(ll base, ll exponent){
    ll result = 1;
    while (exponent > 0)
    {
        if (exponent % 2 == 1)
            result = (result * base) % mod;
        exponent = exponent >> 1;
        base = (base * base) % mod;
    }
    return result;
}

ll Inv(ll x){
    return POW(x, mod - 2);
}

void DFS(int src){
    c++;
    visited[src] = 1;
    for(auto i : s[src]){
        if(!visited[i]) DFS(i);
    }
}

/*void BFS(int s, vector<int> &d){
    d[s] = 0;
    set<pair<int, int>> st;
    st.insert(mp(0, s));
    while (!st.empty()){
        pair<int, int> x = *(st.begin());
        st.erase(st.begin());
        int v = x.S;
        for (auto to : edge[v]){
            int u = to.F, w = to.S;
            if (d[u] > d[v] + w){
                if(d[u] != INT_MAX) st.erase(st.find(mp(d[u], u)));
                d[u] = d[v] + w;
                st.insert(mp(d[u], u));
            }
        }
    }
}

int dijkstra(int n){
    set<pair<int, int>> setds;
    vector<int> dist;
    dist.resize(n + 1, INT_MAX);
    setds.insert(mp(0, 1));
    dist[1]=0;
    while(!setds.empty()){
        pair<int, int> pu = *(setds.begin());
        setds.erase(setds.begin());
        int u = pu.S;
        vector<pair<int, int>> &temp = edge[u];
        for(int i = 0; i < (int)temp.size(); i++){
            int v = temp[i].F;
            int w = temp[i].S;
            if(dist[u] + w < dist[v]){
                if(dist[v] != INT_MAX)
                    setds.erase(setds.find(mp(dist[v], v)));
                dist[v] = dist[u] + w;
                setds.insert(mp(dist[v], v));
            }
        }
    }
    return dist[n];
}

void DFS_Mat(int x, int y){
    visited[x][y] = 1;
    if(x + 1 < n){
        if(s[x + 1][y] == '1' and !visited[x + 1][y]){
            DFS_Mat(x + 1, y);
        }
    }
    if(x - 1 >= 0){
        if(s[x - 1][y] == '1' and !visited[x - 1][y]){
            DFS_Mat(x - 1, y);
        }
    }
    if(y + 1 < m){
        if(s[x][y + 1] == '1' and !visited[x][y + 1]){
            DFS_Mat(x, y + 1);
        }
    }
    if(y - 1 >= 0){
        if(s[x][y - 1] == '1' and !visited[x][y - 1]){
            DFS_Mat(x, y - 1);
        }
    }
}*/

int main(){
    IOS
    int n, m;
    cin>>n>>m;
    rep(i, 0, m){
        int u, v;
        cin>>u>>v;
        if(s[u].find(v) != s[u].end()) continue;
        s[u].insert(v);
        s[v].insert(u);
    }
    int ans = 0;
    rep(i, 1, n + 1){
        if(!visited[i]){
            c = 0;
            DFS(i);
            ans = max(ans, c);
        }
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 38012
#include<stdio.h>
int main()
{
  int N,M,A[100],i,num,wa,j,k,l,list[100];
  scanf("%d%d",&N,&M);
  wa=0;
  for(i=0;i<N;i++)
  {
    scanf("%d",&A[i]);
    wa=wa+A[i];
  }
  num=0;
  for(j=0;j<N;j++)
  {
    if(4*M*A[j]>=wa)
    {
      num=num+1;
    }
  }
  if(num>=M)
  {
    printf("Yes");
  }
  else
  {
    printf("No");
  }
}

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

#define F first
#define S second
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const long long max_n = 100011, inf = 1000111222;

int a[max_n];

long long get_max(int n) {
	int k = n / 2;
	int l = 0, r = n - 1;
	long long ans = abs(a[k] - a[l]);
	k = l;
	while (l + 2 <= r) {
		ans += abs(a[r] - a[l]);
		if (k == l) {
			++l;
			k = r;
		} else {
			--r;
			k = l;
		}
	}
	return ans;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}
	sort(a, a + n);
	long long ans = get_max(n);
	reverse(a, a + n);
	ans = max(ans, get_max(n));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			
			int L = 0;
			int Lc = 0;
			int D = 0;
			int Dc = 0;
			int M = 0;
			int Mc = 0;
			
			String s;
			int a, b, c;
			for(int i=0;i<n;i++){
				s = sc.next();
				a = Integer.valueOf(s.substring(0,2));
				b = Integer.valueOf(s.substring(3,5));
				c = sc.nextInt();
				if(11<=a && a<=14){
					L++;
					if(b>c) c+=60;
					if(c-b<=8) Lc++;
				}else if(18<=a && a<=20){
					D++;
					if(b>c) c+=60;
					if(c-b<=8) Dc++;					
				}else if((21<=a && a<=24) || a==0 || a==1){
					M++;
					if(b>c) c+=60;
					if(c-b<=8) Mc++;					
				}		
			}
			System.out.print("lunch ");
			if(L==0) System.out.println("no guest");
			else System.out.println((100*Lc)/L);
			System.out.print("dinner ");
			if(D==0) System.out.println("no guest");
			else System.out.println((100*Dc)/D);
			System.out.print("midnight ");
			if(M==0) System.out.println("no guest");
			else System.out.println((100*Mc)/M);	
		}	
	}	
}

Measured memory_bytes: 22656
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

using namespace std;
typedef long long ll;

int main() {
  string N;
  cin >> N;
  int m;
  for (int i=N.size()-1; i >= 0; i--) {
    m = (m+(N[i]-'0')) % 9;
  }
  if (m==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3748
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1 << 30
#define MAX 1000000000
#define SIZE 1000000000
const ll mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 0, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll k) { ll a = 1, b = 1; rep(i, 0, k) { a = a * (n - i + 1) % mod; b = b * i % mod; }return a * mpower(b, mod - 2) % mod; }
//---------------------------------------------------------------------------------------------------
ll BIG_C(int n, int r) {
	ll X = 1, Y = 1;
	for (ll i = n; i > n - r; i--) {
		X *= i;
		X %= mod;
	}
	for (ll i = r; i > 0; i--) {
		Y *= i;
		Y %= mod;
	}
	return ((mpower(Y, mod - 2) % mod) * (X % mod)) % mod;
}
int main() {
	int n, a, b;
	scanf("%d%d%d", &n, &a,&b);
	ll r = mpower(2, n) - BIG_C(n, a) - BIG_C(n, b) - 1;
	//printf("%lld %lld %lld\n", mpower(2, n), BIG_C(n, a), BIG_C(n, b));
	while (r < 0) {
		r += mod;
	}
	r %= mod;
	printf("%lld\n", r);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if (a < b && b < c )
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


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

int main() {
	ll h,w;
	cin >> h >> w;
	ll ans = 0;
	if (h == 1 || w == 1) ans = 1;
	else {
		ans += ((w + 1) / 2) * ((h + 1) / 2);
		ans += (w / 2) * (h / 2);
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
const int N = 4e4+100;
long long dp[N],a[N],b[N];
int main(){
	int h,n;
	cin>>h>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
	}
	for(int i=0;i<=N-1;i++) dp[i]=(1e18);
	dp[0]=0;
	for(int i=1;i<=n;i++){
		for(int j=a[i];j<=h+10000;j++){
			dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
		}
	} 
	long long ans=(1e18);
	for(int i=h;i<=h+10000;i++){
		ans=min(ans,dp[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int,input().split()))
MAX = max(A)
r_A = MAX / 2
del A[A.index(MAX)]
B = list(map(lambda a:abs(a-r_A),A))
B.sort()
r1 = int(r_A + B[0])
r2 = int(r_A - B[0])
if r1 in A:
    print(MAX, r1)
else:
    print(MAX, r2)


Measured memory_bytes: 14060
#include <iostream>                                                             
#include <cstring>                                                              
                                                                                
using namespace std;                                                            
                                                                                
int main (void) {                                                               
  int n, m;                                                                     
  cin >> n >> m;                                                                
  int a[n][m];                                                                  
  for (int i=0; i<n; i++) {                                                     
    for (int j=0; j<m; j++) {                                                   
      cin >> a[i][j];                                                           
    }                                                                           
  }                                                                             
  int b[m];                                                                     
  for (int i=0; i<m; i++) {                                                     
    cin >> b[i];                                                                
  }                                                                             
  int c[n];                                                                     
  memset(c,0,sizeof(c));                                                        
  for (int i=0; i<n; i++) {                                                     
    for (int j=0; j<m; j++) {                                                   
        c[i] += a[i][j]*b[j];                                                   
      }                                                                         
    }                                                                           
                                                                                
  for (int i=0; i<n; i++) {                                                     
    cout << c[i] << endl;                                                       
  }                                                                             
}                                             

Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int d,g;
  cin >> d >> g;
  g /= 100;
  vector<int> p(d), c(d);
  rep(i,d) cin >> p[i] >> c[i];
  rep(i,d) c[i] /= 100;

  int ans = 1e9;
  rep(b,1<<d){
    int res = 0, r = g;
    vector<int> n(11);
    rep(i,d){
      if(b>>i&1){
        r -= (i+1)*p[i] + c[i];
        res += p[i];
      }else{
        n[i+1] += p[i]-1;
      }
    }
    for(int i = 10; i>0; --i){
      if(r<=0) break;
      int cnt = min(n[i],(r+i-1)/i);
      r -= cnt*i;
      res += cnt;
    }
    if(r<=0) ans = min(ans,res);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int start_apple[200],start_peach[200],flag1=0,flag2=0,judge1=0,judge2=0,i,j,k;
	char apple[]="apple";
	char peach[]="peach";
	char buf[1001];
	fgets(buf,1000,stdin);
	for(i=0;i<996;i++){
		for(j=0;j<5;j++){
			if(buf[i+j]==apple[j]){judge1++;}
			if(buf[i+j]==peach[j]){judge2++;} //同上
		}
		if(judge1==5){start_apple[flag1]=i; flag1++; judge1=0; judge2=0;}
			else if(judge2==5){start_peach[flag2]=i; flag2++; judge1=0; judge2=0;} //同上
			else{judge1=0; judge2=0;}
	}
		for(j=0;j<5;j++){
			for(k=0;k<flag1;k++){
				if(start_apple[0]==0&&flag1==0)break;
				buf[start_apple[k]+j]=peach[j];
			}
			for(k=0;k<flag2;k++){
				if(start_peach[0]==0&&flag2==0)break;
				buf[start_peach[k]+j]=apple[j];
			}
		}
		buf[1000]='\n';
	printf("%s",buf);
	return 0;
}

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

int n,pos,cnt;
string str;
char ans;

void factor();

void exp(){
  while(str[pos] >= 'A' && str[pos] <= 'Z' && pos < str.size()){
    if(n == cnt) ans = str[pos];
    pos++;
    cnt++;
  }
}

void factor(){
  while(pos < str.size() && ans == '0' && cnt <= 1000010 && str[pos] != ')'){
    int num = 0;
    //cout << pos << '-';
    while(str[pos] >= '0' && str[pos] <= '9' && pos < str.size()){
      num *= 10;
      num += str[pos++] - '0';
    }    
    //cout << pos << ' ' << num << endl;
    if(str[pos] == '('){
      pos++;
      int prev = pos;
      for(int i=0;i<num;i++) {
        //if(str[pos] >= 'A' && str[pos] <= 'Z') factor(); //
        /*else*/ factor();
        if(i != num - 1) pos = prev;
      }
      pos++;
    } else {
      //cout << pos << '-';
      if(num == 0) exp();
      else {
        if(cnt <= n && n < cnt + num) ans = str[pos];
        cnt += num;
        pos++;
        //cout << pos;
      }
      //cout << endl;
    }
  }
}

void solve(){
  pos = cnt = 0;
  ans = '0';
  factor();
  cout << ans << endl;
}

int main(){
  while(cin >> str >> n && (str != "0" || n)) solve();
}

Measured memory_bytes: 1204
// In the name of God //
 
#include <bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(), (x).end()
#define pii pair <int, int>
using namespace std;
const ll mod = 998244353;

int power(ll x, ll y, ll p)  
{  
    if(y == 0) {
        return 1%p;
    }
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  

void solve() {
    int n;
    cin >> n;
    string t;
    cin >> t;
    vector<int> a(n);
    int p = 0;
    for (int i = 0; i < n; i++) {
        a[i] = t[i] - '0';
        if(a[i])    p++;
    }
    if(p == 0) {
        for (int i = 0; i < n; i++) {
            cout << 1 << "\n";
        }
        return;
    }
    // if(p == 1) {
    //     for (int i = 0; i < n; i++) {
    //         if(a[i]) {
    //             cout << 0 << "\n";
    //         } else {
                
    //         }
    //     }
    //     return;
    // }
    // cout << p << "\n";
    // cout << power(2, 0, 2);
    ll s1 = 0, s2 = 0;
    vector<ll> m1(n), m2(n);
    for (int i = 0; i < n; i++) {
        if(p > 1) m1[i] = power(2, n - 1 - i, p - 1);
        m2[i] = power(2, n - 1 - i, p + 1);
        // cout << m1[i] << " " << m2[i] << "\n";
        if(a[i]) {
            if(p > 1)s1 = ((s1%(p - 1)) + (m1[i]%(p - 1))%(p - 1));
            s2 = ((s2%(p + 1)) + (m2[i]%(p + 1))%(p + 1));
        }
    }
    // cout << s1 << " " << s2 << "\n";
    vector<int> ans(n, 1);
    for (int i = 0; i < n; i++) {
        if(a[i]) {
            if(p == 1) {
                ans[i] = 0;
                continue;
            }
            int x = (s1 - m1[i] + p - 1)%(p - 1);
            // cout << x << " ";
            while(x) {
                // cout << x << " ";
                x %= __builtin_popcount(x);
                ans[i]++;
            }
        }
        else {
            int x = (s2 + m2[i] + p + 1)%(p + 1);
            // cout << x << " ";
            while(x) {
                // cout << x << " ";
                x %= __builtin_popcount(x);
                ans[i]++;
            }
        }
        // cout << "\n";
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i] << "\n";
    }
}

int main()  {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        solve();
    } 
    // cout << 15*modInverse(6, mod)%mod << " " << 39*modInverse(10, mod)%mod;
}                               

Measured memory_bytes: 8344
#define _USE_MATH_DEFINES
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <cctype>
#include <cstdlib>
using namespace std;

#define INF (1 << 20)
int main(){
	int l[100000], r[100000], a[100000];
	int w;
	cin >> w;
	for (int i = 0; i < w; ++i) {
		cin >> a[i];
	}
	l[0] = a[0] == 0 ? INF : 0;
	r[w-1] = a[w-1] == 0 ? INF : 0;
	for (int i = 1; i < w; ++i) {
		if (a[i] == 0) {
			l[i] = INF;
		} else if (a[i] < 0) {
			l[i] = min(-a[i], l[i-1] - 1);
		} else {
			l[i] = l[i-1] - 1;
		}
	}
	for (int i = w-2; i >= 0; --i) {
		if (a[i] == 0) {
			r[i] = INF;
		} else if (a[i] < 0) {
			r[i] = min(-a[i], r[i+1] - 1);
		} else {
			r[i] = r[i+1] - 1;
		}
	}
	long long int result = 0;
	for (int i = 0; i < w; ++i) {
		l[i] = max(l[i], r[i]);
		l[i] = min(l[i], a[i]);
		l[i] = max(l[i], 0);
		result += l[i];
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 2328
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    vector<int>v1,v2;
    for(int i=a+1;i<=b;i++)v1.push_back(i);
    for(int i=c+1;i<=d;i++)v2.push_back(i);
    int l1=v1.size();
    int count=0;
    int l2=v2.size();
    for(int i=0;i<l1;i++){
        for(int j=0;j<l2;j++){
            if(v1[i]==v2[j])count++;
        }
    }
    cout<<count;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <string.h>
#include <iomanip>

using namespace std;

int main()
{
	int n;
	string s;
	cin>>n>>s;
	
	for (int i = 0; i<s.size(); i++)
	{
		int res = (s[i] + n);
		if (res<=90)
		printf("%c", res);
		else {
			printf("%c", res%90 + 64);
		}
	}
	
	cout <<endl;
	
	
	
	
	
	
	
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
#define double long double
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-6;
const int MOD=1000000007;

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

signed main(){
	int a,b,c;
	cin >> a >> b >> c;
	cout << min({a + b,b + c,c + a}) << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, K) = readInputLine().split(" ").map { it.toInt() }
    val (R, S, P) = readInputLine().split(" ").map { it.toInt() }
    val T = readInputLine().toCharArray()

    val lose = BooleanArray(N)

    var ans = 0L

    for (i in 0 until N) {
        if (i < K) {
            when (T[i]) {
                'r' -> ans += P
                's' -> ans += R
                'p' -> ans += S
            }
        } else {
            if (T[i] != T[i - K] || lose[i - K]) {
                when (T[i]) {
                    'r' -> ans += P
                    's' -> ans += R
                    'p' -> ans += S
                }
            } else {
                lose[i] = true
            }
        }
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 40800
#![allow(dead_code)]
use std::io;

fn main() {
    solve_b();
}

fn solve_d() {
    let mut x = String::new();

    io::stdin().read_line(&mut x).unwrap();

    let v: Vec<u32> = x.trim()
        .split(' ')
        .map(|s| s.parse::<u32>().unwrap())
        .collect();

    let a = v[0];
    let b = v[1];
    let c = v[2];
    let mut count = 0;
    for i in a..(b + 1) {
        if (c % i) == 0 {
            count += 1;
        }
    }
    println!("{}", count);
}

fn solve_c() {
    loop {
        let mut x = String::new();
        io::stdin().read_line(&mut x).unwrap();

        let mut v: Vec<u32> = x.trim()
            .split(' ')
            .map(|s| s.parse::<u32>().unwrap())
            .collect();

        v.sort();
        if v[0] == 0 && v[1] == 0 {
            break;
        } else {
            println!("{} {}", v[0], v[1]);
        }
    }
}

fn solve_b() {
    let mut x = String::new();
    io::stdin().read_line(&mut x).unwrap();
    let r = x.trim().parse::<f64>().unwrap();

    println!(
        "{:.6} {:.6}",
        r * r * std::f64::consts::PI,
        2_f64 * r * std::f64::consts::PI
    );
}

fn solve_a() {
    let mut x = String::new();
    io::stdin().read_line(&mut x).unwrap();

    let v: Vec<u64> = x.trim()
        .split(' ')
        .map(|s| s.parse::<u64>().unwrap())
        .collect();

    let a = v[0];
    let b = v[1];

    println!("{} {} {:.5}", a / b, a % b, a as f64 / b as f64);
}



Measured memory_bytes: 5052