akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i <= (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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


int main() {
  long n;
  cin >> n;
  long ans = 0;
  rep (i, n) {
    if (i * i > n) break;
    ans = i * i;
  }
  P(ans);

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//
		int a = sc.nextInt();sc.nextLine();
                String b = sc.nextLine();
String p = "P";
String w = "W";
String g = "G";
String y = "Y";

int result1 = b.indexOf(p);
if (result1 != -1) {
    result1 = 1;
} else {
    result1 = 0;
}
int result2 = b.indexOf(w);
if (result2 != -1) {
    result2 = 1;
} else {
    result2 = 0;
}
int result3 = b.indexOf(g);
if (result3 != -1) {
    result3 = 1;
} else {
    result3 = 0;
}
int result4 = b.indexOf(y);
if (result4 != -1) {
    result4 = 1;
} else {
    result4 = 0;
}

int c = result1 + result2 + result3 + result4;
if(c == 3){
System.out.println("Three");
	}else if(c == 4){
System.out.println("Four");
}else{
System.out.println("ERROR");
}
}
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
    using namespace std;
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define int long long
    signed main() {
		    	int x;
		    	cin>>x;
		    	int ans;
		    	if(x>=400&&x<=599)ans=8;
		    	else if(x>=600&&x<=799)ans=7;
		    	else if(x>=1800&&x<=1999)ans=1;
		    	else if(x>=800&&x<=999)ans=6;
		    	else if(x>=1000&&x<=1199)ans=5;
		    	else if(x>=1200&&x<=1399)ans=4;
		    	else if(x>=1400&&x<=1599)ans=3;
		    	else if(x>=1600&&x<=1799)ans=2;
		    	cout<<ans<<endl;
		    		
    	return 0;
    }


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    ll now = 0, l, r;
    char x;
    while(true){
        l = 0, r = 10;
        if(now == 0) l = 1;
        while(r-l > 1){
            ll n = (l+r)/2;
            cout << "? " << now*10+n << endl;
            cin >> x;
            if(x == 'Y') l = n;
            else r = n;
        }
        if(l < 9){
            now = now*10+l;
            continue;
        }
        if(now == 0){
            cout << "? " << 10 << endl;
            cin >> x;
            if(x == 'N'){
                l = 1, r = 9;
                while(r-l > 1){
                    ll n = (l+r)/2;
                    cout << "? " << n*10 << endl;
                    cin >> x;
                    if(x == 'Y') r = n;
                    else l = n; 
                }
                cout << "! " << now*10+r << endl;
                break;
            }
            else{
                cout << "? " << 10000000000 << endl;
                cin >> x;
                if(x == 'Y'){
                    cout << "! " << 1 << endl;
                    break;
                }
                else{
                    now = 9;
                    continue;
                }
            }
        }
        cout << "? " << now*100 << endl;
        cin >> x;
        if(x == 'N'){
            l = 0, r = 9;
            while(r-l > 1){
                ll n = (l+r)/2;
                cout << "? " << now*100+n*10 << endl;
                cin >> x;
                if(x == 'Y') r = n;
                else l = n; 
            }
            cout << "! " << now*10+r << endl;
            break;
        }
        else{
            cout << "? " << now*1000000000 << endl;
            cin >> x;
            if(x == 'Y'){
                cout << "! " << now*10 << endl;
                break;
            }
            else{
                now = now*10+9;
                continue;
            }
        }
    }
}

Measured memory_bytes: 716
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = (1 << 29);
using namespace std;

int dis(int a, int b){
    return (a - b) * (a - b);
}

int solve(int c[20], int x[20001], int n, int m){
    int dp[256][2];
    rep(i,256) rep(j,2) dp[i][j] = INF;
    dp[128][0] = 0;

    rep(j,n){
        rep(i,256){
            rep(k,m){
                int temp = i + c[k];
                if(temp < 0) temp = 0;
                else if(temp > 255) temp = 255;
                dp[temp][(j + 1) % 2] = min(dp[temp][(j + 1) % 2], dp[i][j % 2] + dis(temp, x[j]));
                /*
                if(dp[i][(j + 1) % 2] < 0){
                    cout << i << ' ' << j << ' ' << k << endl;
                    cout << dp[i][(j + 1) % 2] << endl;
                    cout << dp[temp][j % 2] + dis(i, x[j]) << endl;
                }
                */
            }
        }
        rep(i,256) dp[i][j % 2] = INF;
    }
    int ret = INF;
    rep(i,256){
        ret = min(ret, dp[i][n % 2]);
    }
    return ret;
}

int main(){
    int n, m;
    while(cin >> n >> m,n||m){
        int c[20], x[20001];
        rep(i,m) cin >> c[i];
        rep(i,n) cin >> x[i];
        cout << solve(c,x,n,m) << endl;
    }

}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(y==0)return x;
    return gcd(y,x%y);
}
ll LCM(ll a, ll b){
    return a/gcd(a,b)*b;
}

int main(void)
{
    int x,y;
    cin>>x>>y;
    int a=x*4;
    int turu=(a-y)/2;
    if((a-y)%2)cout<<"No"<<endl;
    else{
        int kame=x-turu;
//        cout<<turu<<" "<<kame<<endl;
        if(turu<0||kame<0)cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 int arr[3001][3001];
int main()
{
    int i,j,k,l1,l2,p=0;
    string s,t,ans;
    cin>>s>>t;
    l1=s.size();
    l2=t.size();
    for(i=0;i<=l1;i++)
    {
        for(j=0;j<=l2;j++)
        {
            if(i==0 || j==0)
            {
                arr[i][j]=0;
            }
            else
            {
                if(s[i-1]==t[j-1])
                {
                    arr[i][j]=arr[i-1][j-1]+1;
                }
                else
                {
                   arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
                }
            }
        }
    }
    k=arr[l1][l2];

    char lcs[k+1];
   lcs[k] = '\0';
   int  m=l1,  n=l2;
   while (m > 0 && n > 0)
   {

      if (s[m-1] == t[n-1])
      {
          lcs[k-1] = s[m-1];
          m--; n--; k--;
      }


      else if (arr[m-1][n] > arr[m][n-1])
         m--;
      else
         n--;
   }


   cout << lcs<<endl;;
}





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

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

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define pcnt __builtin_popcount
#define pcntll(x) __builtin_popcountll(x)
#define DMAX DBL_MAX;
#define IMIN INT_MIN;
#define IMAX INT_MAX;

//const ll MOD = 1e9+7;
//const ll MOD = 998244353;
//const ll MAX = 3e5+1;
//const ll INF = 1e18;
//const ld PI = acos(-1L);

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int x, y;
    in(x); in(y);
    if (y % 2 == 0 && 2 * x <= y && y <= 4 * x) out("Yes");
    else out("No");

    return 0;
}


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

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

  vector<int> a(N);

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

  sort(a.begin(),a.end());
  int Alice = 0;
  int Bob = 0;

  for (int i=0; i<N; i++) {

    if (i%2 == 0) {
      Alice += a[N-i-1];
    }

    else {
      Bob += a[N-i-1];
    }
  
  }
  cout << Alice-Bob << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {  
  int N,K;//Kは種類
  cin >> N >> K;
  vector<int> P(N);
  
  for(int i = 0;i < N;i++){
    cin >> P.at(i);
    //cout << P.at(i) <<endl;
  }
  
  sort(P.begin(), P.end() );
  
  int total = 0;
  for(int i = 0;i < K;i++){
    //cout << P.at(i) <<endl;
    total += P.at(i);
  }
  
  cout << total <<endl;
  return 0;
}


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

int main() {
    int r, D, x2000;
    cin >> r >> D >> x2000;

    for (int i = 0; i < 10; i++) {
        cout << (r * x2000 - D) << endl;
        x2000 = r * x2000 - D;
    } 
}

Measured memory_bytes: 256
//
#include<bits/stdc++.h>
using namespace std;
#define maxnn 200000
int n;
int h[maxnn];
int ans=0;
int f[maxnn];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
{
	scanf("%d",&h[i]);
}
	
	for(int i=1;i<=n;i++)
{
	if(h[i]<=h[i-1]) 
	f[i]=f[i-1]+1;
else
{
	f[i]=0;
}
	ans=max(ans,f[i]);
} 
cout<<ans;
} 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vi a(n);
    cin >> a;
    ll ans = 0;
    int now = 1;
    rep(i,n) {
        if(a[i]%now == 0) {
            ans += a[i]/now-1;
            if(a[i] == now or now == 1) {
                now++;
            }
        } else {
            ans += a[i]/now;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3704
M=1000003
f=[1]
for i in range(1,M):f.append(f[i-1]*i%M)
for _ in'_'*int(input()):
	x,d,n=map(int,input().split())
	t=x*pow(d,M-2,M)%M
	print([pow(x,n,M),M-n>=t>0and f[t+n-1]*pow(f[t-1],M-2,M)*pow(d,n,M)%M or 0][d>0])

Measured memory_bytes: 94188
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let mut a_vec: Vec<usize> = Vec::new();
    for _ in 0..n {
        let a: usize = input();
        a_vec.push(a);
    }
    let mut max = 0usize;
    let mut max_2 = 0usize;
    for a in &a_vec {
        if *a > max {
            max_2 = max;
            max = *a;
        } else if *a > max_2 {
            max_2 = *a;
        }
    }
    for a in a_vec {
        if a == max {
            println!("{}", max_2)
        } else {
            println!("{}", max);
        }
    }
}


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

int main() {
	int a, b;
	double c;
	cin>>a>>b;
	c = (double)a/b;
	cout<<fixed<<setprecision(5) <<a/b << " " << a%b << " " << c <<endl;
	return 0;
}


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

using namespace std;

#define db(x) cout << (x) << '\n';
#define all(x) x.begin(),x.end()
#define UNIQUE(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define LB(v,x) lower_bound(all(v),x)
#define UB(v,x) upper_bound(all(v),x)
#define endl "\n"
#define F first
#define S second
#define PB push_back
#define PF push_front
#define int long long
#define trick int m = (l+r)>>1,lc=n<<1,rc=lc|1

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;

int dy[]={0,1,1,1,0,-1,-1,-1};
int dx[]={-1,-1,0,1,1,1,0,-1};
const int maxn = 1e5;
const int OO = 1e18;
const int mod = 1e9 + 7;
const double PI = acos(-1);

void maxself(int &a,int b)
{a=max(a,b);}
void minself(int &a,int b)
{a=min(a,b);}

int n,m,x,y,mx;
vi v;
vector<vi> g(maxn);
int a[maxn],b[maxn];
string s;

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

//	freopen("name.in","r",stdin);
//	freopen("name.out","w",stdout);

	cin >> x >> y;
	
	for(int i=0;i<0;i++)
	{

	}
	cout << x * y;

	return 0;
}



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

using namespace std;
typedef long long int lli;
typedef vector<int> iv;
typedef vector<bool> bv;
typedef vector<string> sv;
typedef vector<long long int> llv;
typedef vector<double> dv;
#define debug_ printf("OK\n")

#define sor_(vec) sort(vec.begin(),vec.end())
#define rev_(vec) reverse(vec.begin(),vec.end())
#define rep(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define reps(i,n,s) for(int i=static_cast<int>(s);i<static_cast<int>(n);i++)
#define isposi(num) if(num>0)

const long long mod = 1000000007;

void solve(int N,int M,vector<pair<int,string>> PS){
    int AC[N],WA[N],ac=0,wa=0;
    for(int i=0;i<N;i++){
        AC[i]=0;
        WA[i]=0;
    }
    for(int i=0;i<M;i++){
        if(PS[i].second=="AC"){
            AC[PS[i].first-1]=1;
        }
        if(PS[i].second=="WA"&&AC[PS[i].first-1]==0){
            WA[PS[i].first-1]+=1;
        }
    }
    for(int i=0;i<N;i++){
        if(AC[i]==1){
            ac+=AC[i];
            wa+=WA[i];
        }
    }
    cout<<ac<<" "<<wa;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin>>N>>M;
    int ntmp;
    string stmp;
    vector<pair<int,string>> PS;
    for(int i=0;i<M;i++){
        std::cin>>ntmp>>stmp;
        PS.push_back(make_pair(ntmp,stmp));
    }
    solve(N,M,PS);
    return 0;
}


Measured memory_bytes: 8816
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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 (b<a) { a=b; return 1; } return 0; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

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

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 3624
using namespace std;
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include <unordered_set>
#include <set>
#include <unordered_map>

#define INT_MIN     (-2147483647 - 1)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(c) for(int i = 0; i <(c); ++i)
#define rrep(n) for(int i = (n) ; i >=0 ; --i)
#define fora(i, s, c) for(int i = (s); i < (c); ++i)
#define forr(i, s, c) for(int i = (s); i > (c); --i)
#define endl "\n"
#define ret(n) return n
#define pb push_back
#define eb emplace_back
#define ff first;
#define ss second;
#define mp make_pair;
#define all(p) p.begin(),p.end()
#define mid(s,e) (s+(e-s)/2)
//Typedefs
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef priority_queue<int> pqint;
typedef priority_queue<ll> pqll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
ll Knapsack_Memoize(vi& w, vll& p, int idx, int wt, vvll& dp)
{
	//it is important to put this weight as first statement for base case
	//if not : if wt becomes -ve and idx is last index and this statement is 2nd
	// it will return 0 and counted as a valid case rather than a invalid case
	if (wt < 0)
		return INT_MIN;

	if (idx == w.size() || wt == 0)
		return 0;

	if (dp[idx][wt] != -1)
		return dp[idx][wt];
	// Case 1. include current item n in knapSack (v[n]) and recur for
	// remaining items (n - 1) with decreased capacity (W - w[n])
	ll include = p[idx] + Knapsack_Memoize(w, p, idx + 1, wt - w[idx], dp);

	// Case 2. exclude current item n from knapSack and recur for
	// remaining items (n - 1)
	ll exclude = Knapsack_Memoize(w, p, idx + 1, wt, dp);

	// return maximum value we get by including or excluding current item
	dp[idx][wt] = max(include, exclude);
	return dp[idx][wt];
}
int main()
{
	int n, w;
	cin >> n >> w;
	vi wts(n);
	vll price(n);
	rep(n)
	{
		cin >> wts[i] >> price[i];
	}
	//auto ans = Knapsack_naive(wts, price, 0, w);
	//cout << ans;
	vvll dp(n);
	for (int i = 0; i < n; ++i)
	{
		dp[i].resize(w + 1, -1);
	}
	auto ans = Knapsack_Memoize(wts, price, 0, w , dp);
	cout << ans;
	ret(0);
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 998244353;

struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {
    if (x > P || x < 0) { cerr << "Invalied FiniteField!" << endl; exit(1); }
  }
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

FiniteField ParseBinary(string s) {
  FiniteField x = 0;
  for (int d = 0; d < s.size(); d++) {
    x *= 2;
    if (s[d] == '1') x += 1;
  }
  return x;
}

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

  int n;
  string s;
  cin >> n >> s;

  FiniteField x = ParseBinary(s);
  if (DEBUG) cout << "x: " << x.Value() << endl;
  FiniteField sum = (x + 1) * 2 * n;
  vector<FiniteField> as(n + 1);
  for (int l = 1; l <= n; l++) {
    if (n % l == 0) {
      int d = n / l;
      if (d % 2 == 0) continue;
      if (d == 1) continue;
      if (DEBUG) cout << "l: " << l << endl;
      string t = s.substr(0, l);
      FiniteField y = ParseBinary(t);
      FiniteField count = y;
      string tr = t;
      for (int i = 0; i < tr.size(); i++) {
        if (tr[i] == '1') tr[i] = '0';
        else tr[i] = '1';
      }
      string u = "";
      for (int i = 0; i < d; i++) {
        if (i % 2 == 0) u.append(t);
        else u.append(tr);
      }
      if (DEBUG) cout << "u: " << u << endl;
      if (u <= s) {
        count += 1;
      }
      if (DEBUG) cout << "count before ajudst: " << count.Value() << endl;
      count -= as[l];
      if (DEBUG) cout << "count: " << count.Value() << endl;
      FiniteField cycle = 2 * l;
      sum -= count * (FiniteField(2 * n) - cycle);
      for (int k = 2; l * k <= n; k++) {
        as[l * k] += count;
      }
    }
  }
  cout << sum.Value() << endl;
}

Measured memory_bytes: 2640
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  int64_t ans = 0;
  for (int i = 0; i < (N / 2); i++) {
    if (i == 0) {
      ans += A.at(i);
    }
    else {
      ans += A.at(i) + A.at(i);
    }
  }
  
  if (N % 2 == 1) {
    ans += A.at(N / 2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4044
import           Data.Char
main = do
    [_, k] <- map read . words <$> getLine
    s <- getLine
    putStrLn $ f k 1 s
  where
    f :: Int -> Int -> String -> String
    f _ _ [] = []
    f k n (x:xs) =
        if k == n
           then toLower x : f k (n+1) xs
           else x : f k (n+1) xs



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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


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

  int ans = 0;
  bool chk[n];
  rep(i,n)chk[i] = false;

  rep(i,n){
    if(chk[a[i]] == true)continue;
    if(a[i] == a[a[a[i]]]){
      ans++;
      chk[a[i]] = chk[a[a[i]]] = true;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;

int main(){
int ans=0,n=read(),k=read(),now=1;
for (;now<n;++ans) now+=k-1;
write(ans); 
}

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

using namespace std;

vector<long long int> power;
long long int INF = 10000000000;
int COUNT = 0;

bool check();

void display(){
  for(int i = 0; i < power.size(); i++){
    cout << power[i] << " ";
  }
  cout << endl;
}

int getMaxIndex(){
  int max = 0;
  int index = 0;
  for(int i = 0; i < power.size(); i++){
    if(max < power[i]){
      max = power[i];
      index = i;
    }
  }
  return index;
}

void attack(int A, int B, long long int &count){
  int MaxIndex = getMaxIndex();
  for(int i = 0; i < power.size(); i++){
    if(i == MaxIndex) power[i] -= A;
    else power[i] -= B;
  }
  bool flag = check();
  if(flag){
    cout << count << endl;
    return;
  }
  else{
    count++;
    attack(A, B, count);
  }
}

bool check(){
  bool flag = true;
  for(int i = 0; i < int(power.size()); i++){
    if(power[i] > 0){
      flag = false;
      break;
    }
  }
  return flag;
}

bool enough(long long int T, int A, int B){
  long long int damage = T * B;
  bool flag = true;
  long long int add_num = 0;
  for(int i = 0; i < power.size(); i++){
    if(power[i] > damage){
      long long int tmp = long((power[i] - damage) / (A - B));
      add_num += tmp;
      if((power[i] - damage) % (A - B) != 0) add_num++;
    }
  }
  if(add_num > T) flag = false;
  
  return flag;
}

void calcT(int A, int B, long long int s, long long int e){
  long long int T = (s + e) / 2;
  //cout << "T = " << T << endl;
  if(s + 1 >= e){
    cout << T + 1 << endl;
    return;
  }
  if(enough(T, A, B)){
    long long int new_s = s;
    long long int new_e = T;
    calcT(A, B, new_s, new_e);
  }
  else{
    long long int new_s = T;
    long long int new_e = e;
    calcT(A, B, new_s, new_e);
  }
}

int main(){
  long long int N, A, B;
  cin >> N >> A >> B;
  for(int i = 0; i < N; i++){
    long long int tmp;
    cin >> tmp;
    power.push_back(tmp);
  }

  calcT(A, B, 0, INF);

  return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main(){
   int n,k,q;
   cin >> n >> k >> q;
   vector<int> v(n);
   for(int i=0;i<q;i++){
       int a;
       cin >> a;
        v[a-1]++;
   }
   for(int i=0;i<n;i++){
       if(v[i]+k-q > 0)cout << "Yes" << endl;
       else cout << "No" << endl;
   }
}

Measured memory_bytes: 3780
#!/usr/bin/env python3
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    H, N = map(int, readline().split())
    As = map(int, readline().split())
    if sum(As) >= H:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 8480
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int r = in.nextInt();
        int s = in.nextInt();
        if (r >= 1 && r <= 20 && s >= 1 && s <= 20) {
            if (r >= 1 && r <= 9 && s >= 1 && s <= 9) {
                System.out.println(r * s);
            } else {
                System.out.println(-1);
            }

        }
    }
}


Measured memory_bytes: 21844
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
   
#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
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>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n;
bool used[3000][6000];
ld p[N], dp[3000][6000];

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n;
   for (int i = 1; i <= n; i ++) cin >> p[i];
   dp[0][3000] = 1.0;
   used[0][3000] = 1;
   for (int i = 1; i <= n; i ++)
      for (int j = 0; j <= 6000; j ++)
         dp[i][j] = 0.0;
   for (int i = 1; i <= n; i ++) {
      for (int has = 0; has <= 3000 + i; has ++) {
         if (used[i - 1][has]) {
            used[i][has + 1] = 1;
            dp[i][has + 1] += (dp[i - 1][has] * p[i]);
            used[i][has - 1] = 1;
            dp[i][has - 1] += (dp[i - 1][has] * (1.0 - p[i]));
         }
      }
   }
   ld ans = 0;
   for (int i = 3001; i <= 6000; i ++)
      if (used[n][i])
         ans += dp[n][i];
   cout << fixed << setprecision (10) << ans;
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

Measured memory_bytes: 301696
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std; 
using namespace __gnu_pbds;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
 
template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;
 
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define F0Rd(i,a) for (int i = a - 1; i >=0 ; i--)
#define FORd(i,a,b) for (int i = b - 1; i >= a; i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'
 
#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define print(x) cout << x << newl;
#define finish(x) return cout << x << "\n", 0;
#define bug(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " " << 
 
const int MXN = 2e5 + 5;
const ll MOD = 998244353;
const ll INF = 1e9 + 7;


double A,B;
int H, M;

int main(){ FAST
    //ifstream cin("/Users/konwoo/input.txt");
    //ofstream cout("/Users/konwoo/output.txt");

    cin >> A >> B >> H >> M;
    double ang = abs(6*M - (30*H + M*0.5));
    ang = min(ang,360.0-ang);
    cout << setprecision(10) << sqrt(A*A+B*B-2.0*A*B*cos(ang * acos(-1)/180.0)) << newl;



    

 
 
 
    return 0;
}


Measured memory_bytes: 4240
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
#define l(i,a,b) for(auto i=a;i<b;i++)
#define lr(i,a,b) for(auto i=a;i>=b;i--)
#define ll long long
#define lli long long int
#define ld long double
#define vec vector<int>
#define mii map<ll,ll>
#define vl vector<long long>
#define se set <long long int>
#define pi pair<long long,long long>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define all(v) v.begin(), v.end()
#define in(x) cin>>x
#define o(x) cout<<x
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.14159265359
using namespace std;


//const string k = "enterstringtobechecked";



int main()
{
    SYNC
   // clock_t tStart = clock();
   // freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n; in(n);
    if(n>=30)
        o("Yes")<<endl;
    else
        o("No")<<endl;





    //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);   
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	vector<int> v;

	for(int i=0;i<5;i++){
		int a;
		cin>>a;
		v.push_back(a);
	}

	sort(v.rbegin(),v.rend());

	
	cout<<v[0]<<" "<<v[1]<<" "<<v[2]<<" "<<v[3]<<" "<<v[4]<<endl;
	

	return 0;
} 

Measured memory_bytes: 3152
#include<bits/stdc++.h>
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i,n) for(int i = 0; i < n; i++)
#define for1(i,n) for(int i = 1; i <= n; i++)
#define ford(i,n) for(int i = n-1; i >= 0; i--)
#define fore(i,a,b) for(int i = a; i <= b; i++)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
 
 
const  int MAXn= 3e5+5;
const  long long INF= 1e18;
const long long mod= 1e9+7;
 
 
int main(){
	int n, k,r,s,p;
	cin >> n >> k >> r >> s >> p;
	string st,ans;
	cin >> st;
	ans = "";
	for(auto x :st) {
		if(x == 'r') ans += 'p';
		else if(x == 'p') ans += 's';
		else ans += 'r';
	}
	for(int i = k ; i < n; i++) {
		if(ans[i - k] == ans[i]) { ans[i] ='!';}
	}
	long long a = 0;
	for(int i = 0; i < n; i++) {
		if(ans[i] == '!') continue;
		if(ans[i] == 'r') a += r;
		else if(ans[i] == 'p') a += p;
		else a += s;
	}
	cout << a;
}
	


Measured memory_bytes: 512
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var x int
	fmt.Fscan(r, &x)

	fmt.Fprintln(w, getMaxHappy(x))
}

func getMaxHappy(x int) int {
	five_hundled_count := x / 500
	five_count := (x - five_hundled_count*500) / 5

	return five_hundled_count*1000 + five_count*5
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=1e5;
int n,t,m,ans,sum,b,c;
char a[55][55];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
		cin>>a[i][j];
		}
	}
	for(int i=2;i<n;i++){
		for(int j=2;j<m;j++){
		if(a[i][j]=='#'&&a[i-1][j]=='.'&&a[i+1][j]=='.'&&a[i][j-1]=='.'&&a[i][j+1]=='.'){
			t=1;
		//	printf("1");
			break;
			}
		}
	}
		if(a[1][1]=='#'&&a[1][2]=='.'&&a[2][1]=='.'){t=1;
		//	printf("2");
		}
		if(a[n][1]=='#'&&a[n][2]=='.'&&a[n-1][1]=='.'){
			t=1;
		//	printf("3");
		}
		if(a[n][m]=='#'&&a[n-1][m]=='.'&&a[n][m-1]=='.'){
			t=1;
		
	//		printf("4");
		}
		if(a[1][m]=='#'&&a[2][m]=='.'&&a[1][m-1]=='.'){
			t=1;
		//	printf("5");
		}

	for(int i=2;i<n;i++){
		if(a[i][1]=='#'&&a[i][2]=='.'&&a[i-1][1]=='.'&&a[i+1][1]=='.'){
			t=1;
	//		printf("6");
		}
		if(a[i][m]=='#'&&a[i][m-1]=='.'&&a[i-1][m]=='.'&&a[i+1][m]=='.'){
			t=1;
		//	printf("7");
		}
	}
	for(int j=2;j<m;j++){
		if(a[1][j]=='#'&&a[1][j-1]=='.'&&a[1][j+1]=='.'&&a[2][j]=='.'){
			t=1;
		//	printf("8");
		}
		if(a[n][j]=='#'&&a[n][j-1]=='.'&&a[n][j+1]=='.'&&a[n-1][j]=='.')t=1;
	}
	if(t==1)
	printf("No\n");
	
	else
		printf("Yes\n");
}




Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int outX = sc.nextInt();  	
      	if (outX == 1) {
        System.out.println("0");
        } else {
        System.out.println("1");
        }
	}
}

Measured memory_bytes: 27044
#include<iostream>
using namespace std;
int main()
{
    string s;
    cin>>s;
    string t;
    cin>>t;
    int cnt=0;
    for(int i=0;i<3;i++)
        if(s[i]==t[i])
        cnt++;
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
//  s.at(0) = toupper(s.at(0));//小文字なら大文字へ//大文字の場合はそのまま
//  s.at(i) = tolower(s.at(i));//大文字なら小文字へ//小文字の場合はそのまま
//s配列に格納した単語を、辞書順にソートする
//getline(cin, s);
//  sort(s.begin(), s.end());
//  string t = "keyence";//で文字列入力ができる
//s.empty() //emptyなら1を出力 入っていれば0を出力
/*//ABC018-B 部分的にreverseをかける解法
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  rep(i,n) cin>>a.at(i)>>b.at(i);
  rep(i,n)a.at(i)--;
  rep(i,n)b.at(i)--;
  string t;
  rep(i,n){
    t = s;
    for(int k=0;k<=b.at(i)-a.at(i);k++){
      t.at(a.at(i)+k) = s.at(b.at(i)-k);
    }
    s = t;
  }
  cout << s << endl;
}
*///ABC018-B
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int kan_hyaku(int n){
  int kurai = 0;
  for(int i=0;i<3;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int kan_ju(int n){
  int kurai = 0;
  for(int i=0;i<2;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int kan_ichi(int n){
  int kurai = 0;
  for(int i=0;i<1;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int main() {
  double w,h,x,y;
  cin >> w >> h >> x >> y;
  if(w*0.5 == x && h*0.5 ==y){
    cout << w * 0.5 * h << " " << 1 << endl;
  }
  else{
    cout << w * 0.5 * h << " " << 0 << endl;
  }
}

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

int n, m;
bool f;
class Edge{
	public:
		long long cost;
		int from, to;
		Edge(long long c, int f, int t){
			cost = c;
			from = f;
			to = t;
		}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void readGraph(Graph &g, int E, bool D, bool C){ // E:NumofEdges, D:Directed, C:Costed
	for(int i=0; i<E; ++i){
		Edge e(0, 0, 0);
		if(!C) cin >> e.from >> e.to;
		else cin >> e.from >> e.to >> e.cost;
		--e.from;
		--e.to;
		g[e.from].push_back(e);
		if(!D){
			swap(e.from, e.to);
			g[e.from].push_back(e);
		}
	}
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> m;
	Graph g(n);
	readGraph(g, m, false, false);
	for(int i=0; i<g[0].size(); ++i)
		for(int j=0; j<g[g[0][i].to].size(); ++j)
			if(g[g[0][i].to][j].to == n-1)
				f = true;
	cout << (f ? "POSSIBLE\n" : "IMPOSSIBLE\n");
}

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

typedef long long ll;

int main(){

	ll N;

	scanf("%lld",&N);

	ll stop=(ll)(sqrt((double)N)+1ll);

	ll i;

	int ans=114514;

	for(i=1ll;i<=stop;i+=1ll){

		if(N%i==0ll){

			ll j=N/i;

			int digit=0;

			while(j!=0ll){
				j/=10ll;
				digit++;
			}
			if(ans>digit){ans=digit;}
		}
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    string s;
    rep(i, tx - sx) s.push_back('R');
    rep(i, ty - sy) s.push_back('U');
    rep(i, tx - sx) s.push_back('L');
    rep(i, ty - sy) s.push_back('D');
    s.push_back('L');
    rep(i, ty - sy + 1) s.push_back('U');
    rep(i, tx - sx + 1) s.push_back('R');
    s.push_back('D');
    s.push_back('R');
    rep(i, ty - sy + 1) s.push_back('D');
    rep(i, tx - sx + 1) s.push_back('L');
    s.push_back('U');
    cout << s << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)
#define N 150


signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase < 1234567;testcase++){
    string s;
    for(;getline(cin, s);){
      bool fl = true;
      int lh[N] = {0}, rh[N] = {0};
      int lhx[N] = {0}, rhx[N] = {0};
      for(i = s.size() - 1;;--i){
        if(s[i] == '=')break;
        else if(s[i] == 'X')rhx[s.size() - 1 - i]++;
        else rh[s.size() - 1 - i] += (int)(s[i] - '0');
      }
      if(s[i + 1] == 'X' && i + 2 != s.size())fl = false;
      --i;
      for(j = i;;--j){
        if(s[j] == '+')break;
        else if(s[j] == 'X')lhx[i - j]++;
        else lh[i - j] += (int)(s[j] - '0');
      }
      if(s[j + 1] == 'X' && s[j + 2] != '=')fl = false;
      i = j - 1;
      for(j = i;j >= 0;--j){
        if(s[j] == 'X')lhx[i - j]++;
        else lh[i - j] += (int)(s[j] - '0');
      }
      if(s[0] == 'X' && s[1] != '+')fl = false;
/*
      rep(i, 10){
        debug(i);
        printf("%d + %dx == %d + %dx\n", lh[i], lhx[i], rh[i], rhx[i]);
      }*/

      rep(k, 10){
        if(k == 0 && !fl)continue;
        int l = 0, r = 0;
        rep(i, N){
          if((lh[i] + lhx[i] * k + l) % 10 != (rh[i] + rhx[i] * k + r) % 10)break;
          l = (lh[i] + lhx[i] * k + l) / 10;
          r = (rh[i] + rhx[i] * k + r) / 10;
        }
        if(i == N){
          pri(k); break;
        }
      }
      if(k == 10)pri("NA");
      s.clear();
    }

/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 1180
// https://atcoder.jp/contests/abc056/tasks/abc056_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
const int INF = 1e9;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a, b;
    cin >> a >> b;
    if ((a == "H") ^ (b == "H")) {
        cout << "D\n";
    } else {
        cout << "H\n";
    }

    return 0;
}


Measured memory_bytes: 256
INF = 1 << 29

def contain(names)
  contained = []
  names.permutation(2).each do |s, t|
    contained << t if s.include?(t)
  end
  contained.each{ |name| names.delete(name) }
  names
end

def overlap(names, size)
  mapping = size.times.map{ [0] * size }
  (0...size).to_a.permutation(2).each do |i, j|
    k = [@len[i], @len[j]].min
    loop do
      if names[i][@len[i]-k..-1] == names[j][0,k]
        mapping[i][j] = k
        break
      end
      k -= 1
    end
  end
  mapping
end


while n = gets.to_i
  break if n == 0
  s = n.times.map{ gets.chomp }
  s = contain(s)
  m = s.size
  @len = s.map{ |name| name.size }
  dp_table = overlap(s, m)
  dp_cache = (1<<m).times.map{ [INF] * m }
  m.times{ |i| dp_cache[1<<i][i] = @len[i] }
  (1<<m).times do |bits|
    m.times do |i|
      next if dp_cache[bits][i] == INF
      pre = dp_cache[bits][i]
      m.times do |j|
        next if i == j || (bits | (1<<j)) == bits
        if dp_cache[bits | (1<<j)][j] > pre + @len[j] - dp_table[i][j]
          dp_cache[bits | (1<<j)][j] = pre + @len[j] - dp_table[i][j]
        end
      end
    end
  end
  
  p dp_cache[(1<<m)-1].min
end

Measured memory_bytes: 20832
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
  string a;
  cin >> a;
  int b = 0;
  for(int i = 0;i <= a.size() - 1;i++){
    if(i % 2 == 0 && a[i] == 'h'){
      
    }
    else if(i % 2 == 1 && a[i] == 'i'){
      
    }
    else{
      b = 1;
    }
  }
  if(a.size() == 0 || a.size() % 2 != 0){
    b = 1;
  }
  if(b == 1){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

void yes(){
   cout<<"Yes"<<endl;
   //exit (0);
}
void no(){
   cout<<"No"<<endl;
   //exit (0);   
}

int n, a[N];
string s, t;

int32_t main(){_
   
   cin >> s;

   if (s == "ABC"){
        cout<<"ARC";
     }  
     else{
      cout<<"ABC";
     }

   return 0;
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  LL h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;

  LL t1 = h1 * 60 +   m1;
  LL t2 = h2 * 60 +   m2;

  cout << t2 - t1 - k << endl;
}


Measured memory_bytes: 3608