akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long a,long long b);

int main(){
  int n,m;
  string s,t;
  cin>>n>>m;
  cin>>s>>t;
  long long q=gcd(n,m);
  long long p=q*n/q*m/q;
  for(int i=0;i<q;i++){
    //cout<<s[n/q*i]<<' '<<t[m/q*i]<<endl;
    if(s[n/q*i]!=t[m/q*i]){
      cout<<-1<<endl;
      return(0);
    }
  }
  cout<<p<<endl;
  return(0);
}

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


Measured memory_bytes: 512
//https://codeforces.com/contest/1323/problem/A
//BROWNIE TK

#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()

#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en

#define le length()
#define mp make_pair
#define mt make_tuple
#define acc(v) accumulate(all(v), 0)
#define F first
#define S second

#define pll pair<lli, lli>
#define pii pair<int, int>
#define pil pair<int, lli>

#define forz(i, n) for (int i = 0; i < n; i++)
#define fore(i, m, n) for (int i = m; i <= n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rfore(i, m, n) for (int i = n; i >= m; i--)

#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)

#define bset(a, p) ((a) | (1ll << (p)))
#define bchk(a, p) ((a) & (1ll << (p)))
#define bxor(a, p) ((a) ^ (1ll << (p)));
#define brem(a, p) (bchk(a, p) ? (bxor(a, p)) : (a))
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/

#define lb lower_bound
#define ub upper_bound
#define er equal_range

#define findnot find_first_not_of

#define maxe *max_element
#define mine *min_element

#define mod 1000000007
#define mod2 998244353
#define gcd __gcd
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetlli tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements sbtriectly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order
using namespace std;

/*STD funcions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli modi(lli a, lli m) { return power(a, m - 2, m); }
/*CODE BEGINS*/

int main()
{
    kira;
    string s;
    cin>>s;
    int c=0;
    forz(i,3)if(s[i]=='A')c++;
    if(c!=3&&c!=0)p1("Yes");
    else p1("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define vi vector<int>
#define F(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define print(x) cout << x << endl;
#define print_array(arr) F(i, arr.size()){cout << arr[i] << "-";}cout << endl;
#define print_line F(i, 60){cout << "--";}cout << endl;
const int mod = 1e9+7;
using namespace std;

void pre(){
	
}
void solve(){
	int n;
	cin >> n;
	
}
int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	pre();
	ll a;
	string s;
	cin >> a >> s;
	int yes = 100*((int)s[0] - (int)'0') + 10*((int)s[2] - (int)'0') + (int)s[3] - (int)'0';
	print((a*yes)/100)
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
typedef long long ll;
const ll MOD = 1000003;

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

ll fact[2000010];

int main()
{
    fact[0] = 1;
    for(int i = 1; i < 2000010; i++){
        fact[i] = fact[i - 1] * i % MOD;
    }
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        ll x, d, n;
        cin >> x >> d >> n;
        if(d == 0) cout << modpow(x, n) << endl;
        else if(n >= MOD || x == 0) cout << 0 << endl;
        else cout << modpow(d, n) * fact[(x * modpow(d, MOD - 2) % MOD + n - 1)] % MOD *
            modpow(fact[x * modpow(d, MOD - 2) % MOD - 1], MOD - 2) % MOD << endl;
    }
}

Measured memory_bytes: 16512
from bisect import bisect_left
n = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))
ans = 0
for t in T:
    x = bisect_left(S,t)
    if x != len(S):
        if S[x] == t:
            ans += 1
print(ans)



Measured memory_bytes: 16736
#include <stdio.h>

int main(void) {
    int n, r, ir;
    scanf("%d %d", &n, &r);

    if (n >= 10) {
        ir = r;
    } else {
        ir = r + 100 * (10 - n);
    }

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

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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

ll bsize(ll l){
  if(l==0){
    return 1;
  }
  return 3+bsize(l-1)*2;

}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,x;
    cin>>n>>x;

    vector<ll> p(51);
    vector<ll> b(51);
    p[0]=1;
    b[0]=1;
    FOR(i,1,51){
      p[i]+=p[i-1]*2+1;
      b[i]+=b[i-1]*2+3;
    }
    ll i=n;
    ll sum=0;
    ll res=0;
    while(sum<x){
      while(sum<x){
        if(sum+b[i]<=x){
          sum+=b[i];
          res+=p[i];
          break;
        }
        sum++;
        i--;
      }
      if(sum==x)break;
      res++;
      sum++;
    }

    cout<<res<<endl;

}


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

int main()
{
    
    int a,b,c;
    cin>>a>>b>>c;
    vector<int>values;
    values.push_back(a+c);
    values.push_back(a+b);
    values.push_back(c+b);
    values.push_back(b+c);
    values.push_back(c+a);
    values.push_back(b+a);
    sort(values.begin(),values.end());
    cout<<values[0]<<endl;
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ANS(ans) cout << ans << endl
#define FLG(flg) if(flg) cout << "Yes" << endl; else cout << "No" << endl;
#define YES cout << "Yes" << endl;
#define NO cout << "No" << endl;
#define COUT(s) cout << s << endl;
#define AN vector<int> a(n); for(int i = 0; i < n; i++) cin >> a[i];
#define IN  int n;  cin >> n;
#define VI  vector<int> 
#define SS stringstream ss;
#define SOLVE cout << solve() << endl;

int main () {
    IN
    bool flg = false;
    for(int i = 1; i <= 9; i++) {
        for(int j = i; j <= 9; j++) {
            if(i * j == n) flg = true;
        }
    }
    FLG(flg)
}

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

int main() {
    int n, m, ans = 0;
    map<int, int> mp;
    cin >> n >> m;
    rep(i, n) {
        int k;
        cin >> k;
        rep(j, k) {
            int temp;
            cin >> temp;
            mp[temp]++;
        }
    }
    for(pair<int, int> p : mp) if(p.second == n) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import math

input = sys.stdin.readline

def main():
    n = int(input().rstrip())
    x = list(map(int, input().rstrip().split()))
    y = list(map(int, input().rstrip().split()))
    
    d1, d2, d3 = 0, 0, 0
    temp_y = y
    
    for i in range(n):
        d1 += math.fabs(x[i] - y[i])
        d2 += math.fabs(x[i] - y[i]) ** 2
        d3 += math.fabs(x[i] - y[i]) ** 3
        temp_y[i] = math.fabs(x[i] - y[i])
    
    print(d1)
    print(math.sqrt(d2))
    print(d3**(1/3))
    print(max(temp_y))
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 5712
n,m,c = map(int,input().split())
B = list(map(int,input().split()))
li2=[input() for i in range(n)]
A = []
for i in range(n):
    A.append( [int(x.strip()) for x in li2[i].split()])

ans = 0

for i in range(n):
    var = c
    for j in range(m):
        var += A[i][j]*B[j]
    if var > 0:
       ans += 1
       
print(ans)

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 998244353

ll mod_pow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll n;
vector<ll> a;

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

  cin>>n;
  a.resize(n);
  rep(i,n)cin>>a[i];

  ll res=0;
  rep(i,n){
    ll add=mod_pow(a[i]+1,i);
    add*=a[i]; add%=mod;
    add*=mod_pow(2,n-1-i);
    add%=mod;
    (res+=add)%=mod;
  }
  cout<<res<<endl;

  return 0;
}



Measured memory_bytes: 10612
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  i64 x,y;
  cin >> x >> y;
  if(x == 0 && y == 0){
    cout << "Brown" << endl;
    return 0;
  }

  // | X - Y - 3i| <= 1 に必ずできる
  if(abs(x - y) <= 1){
    cout << "Brown" << endl;
  }
  else{
    cout << "Alice" << endl;
  }
}


Measured memory_bytes: 256
using System;

class ABC_132_A
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        bool ans = false;

        if (s[0] == s[1] && s[0] == s[2] && s[0] == s[3])
        {
            Console.WriteLine("No");
            return;
        }

        if (s[0] == s[1] && s[2] == s[3]) ans = true;
        if (s[0] == s[2] && s[1] == s[3]) ans = true;
        if (s[0] == s[3] && s[1] == s[2]) ans = true;

        if (ans)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13140
n,m=map(int,input().split())
xy=[]
for _ in range(m):
  xy.append(list(map(int,input().split())))

ans=1
n0=xy[0][1]
rb=[1]
rb[1:1]=[0]*(n-1)
cb=[1]*n
for i in range(m):
  if rb[xy[i][0]-1]==1:
    rb[xy[i][1]-1]=1
  cb[xy[i][1]-1]+=1
  cb[xy[i][0]-1]-=1
  if cb[xy[i][0]-1]==0:
    rb[xy[i][0]-1]=0

print(sum(rb))


Measured memory_bytes: 28964
def ABC076C_DubiousDocument2():
    Sd = list(input().strip())
    T = list(input().strip())

    tlen = len(T)
    slen = len(Sd)

    ans = 'UNRESTORABLE'
    nowPos = 0
    for pos in range(slen - 1, -1, -1):
        if pos < (tlen - 1):
            break
        if(T[tlen - 1] == Sd[pos]) or (Sd[pos] == '?'):
            nowPos = pos
            match = True
            for chk in range(nowPos, nowPos - tlen, -1):
                if(T[tlen - (nowPos - chk) - 1] != Sd[chk]) and (Sd[chk] != '?'):
                    match = False
                    break

            if match:
                # 書き換え
                for chk in range(nowPos, nowPos - tlen, -1):
                    Sd[chk] = T[tlen - (nowPos - chk) - 1]
                for i in range(0, slen):
                    if Sd[i] == '?':
                        Sd[i] = 'a'
                # 答えはこれ
                ans = ''.join(Sd)

    print(ans)

def main():
    ABC076C_DubiousDocument2()

if __name__ == "__main__":
    main()


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 3005;

/* ...o(^-^)o... */
lint a[17][17];
lint dp[1<<17];

int main(){
    int n; cin >> n;
    rep(i, n) rep(j, n) cin >> a[i][j];
    rep(s, 1<<n){
        rep(i, n-1) repp(j, i+1, n){
            if(s&(1<<i) && s&(1<<j)) dp[s] += a[i][j];
        }
        dp[s] = max(dp[s], 0LL);
        for(int t = (s-1)&s; t>0; t=(t-1)&s){
            int u = s^t;
            dp[s] = max(dp[s], dp[t]+dp[u]);
        }
    }
    out(dp[(1<<n)-1]);
}


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

using ll = long long;
const ll MOD = 998244353;
const ll INF = 1e18;

int main() {
    int N, M, L, Q, s, t;
    cin >> N >> M >> L;
    vector<int> A(M), B(M), C(M);
    vector<vector<ll>> d(N, vector<ll>(N, INF));
    rep(i, M) {
        cin >> A[i] >> B[i] >> C[i];
        A[i]--;
        B[i]--;
        d[A[i]][B[i]] = C[i];
        d[B[i]][A[i]] = C[i];
    }
    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                ll x = d[i][k] + d[k][j];
                if (x < d[i][j]) d[i][j] = x;
            }
        }
    }
    vector<vector<ll>> e(N, vector<ll>(N, INF));
    rep(i, N) rep(j, N) {
        if (d[i][j] <= L) e[i][j] = 1;
    }
    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                ll x = e[i][k] + e[k][j];
                if (x < e[i][j]) e[i][j] = x;
            }
        }
    }
    cin >> Q;
    rep(i, Q) {
        cin >> s >> t;
        s--;
        t--;
        if (e[s][t] >= INF) cout << -1 << endl;
        else cout << e[s][t] - 1 << endl;
    }
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; ++i) {
		cin >> d[i];
	}

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

	int half = n / 2;
	int ret = 0;
	if (d[half - 1] != d[half]) {
		ret = d[half] - d[half - 1];
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>

using namespace std;

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

    int T_length = T.length();

    int S_length = S.length();

    if(T_length - S_length != 1){
        cout << "No" << endl;
        return 0;
    }

    for (int i = 0; i < S_length; ++i) {
        if(S[i] != T[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
#define all(obj) obj.begin(), obj.end()
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

const long long INF = 1LL << 60;

using namespace std;

typedef unsigned long long ull;
typedef int long long ll;
constexpr ll bigNum = 1000000007;

signed main()
{
    fast;
    string s;
    long long t = 0;
    cin >> s;
    cin >> t;
    string s1 = s;
    ll count = 0;
    ll neko = 0;
    ll last = 0;
    map<char, int> a;
    for (int i = 0; i < s.size(); i++)
    {
        a[s[i]]++;
    }
    if (s.size() == 1)
    {
        cout << t / 2;
    }
    else
    {
        s += s;
        for (int i = 0; i < s.size() - 1; i++)
        {
            if (s[i] == s[i + 1])
            {
                count++;
                s[i + 1] = 'A';
            }
        }
        for (int i = 0; i < s1.size() - 1; i++)
        {
            if (s1[i] == s1[i + 1])
            {
                last++;
                s1[i + 1] = 'A';
            }
        }
        if (t % 2 == 0 && a[s1[0]] % 2 == 0 && s1[0] == s1[s1.size() - 1])
        {
            cout << count * t / 2 + t / 2 - 1;
        }
        else if (t % 2 == 0)
        {
            cout << count * t / 2;
        }
        else if (t == 1)
        {
            cout << last;
        }
        else if (a[s1[0]] % 2 == 0)
        {
            last = count - last;
            cout << count * (t - 1) / 2 + last;
        }
        else
        {
            cout << count * (t - 1) / 2 + last;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define TR(X) ({ if(1) cerr << "Trace: " << (#X) << " = " << (X) << endl; })

ll n;
const ll MAXN = 210000LL;
vector<ll> BIT(MAXN, -1e18);
void update(ll x, ll value) {
	for(++x; x <= n + 1; x += x & -x) {
		BIT[x] = max(BIT[x], value);
	}
}
ll query(ll x) {
	ll res = -1e18;
	for(++x; x; x -= x & -x) {
		res = max(res, BIT[x]);
	}
	return res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	vector<ll> h(n), a(n);
	vector<pair<ll, ll> > idx(n);
	for(ll i = 0; i < n; i++) {
		cin >> h[i]; h[i]--;
		idx[h[i]].first = i;
	}
	for(auto &k: a) cin >> k;
	for(ll i = 0; i < n; i++) {
		idx[h[i]].second = a[i];
	}

	for(ll i = 0; i < n; i++) {
		ll bf = query(idx[i].first);
		ll cur = idx[i].second;
		if(bf != -1e18) cur += bf;
		update(idx[i].first, cur);
	}
	cout << *max_element(BIT.begin(), BIT.end()) << '\n';
}


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

int main() {
	int N,i,a,b,c;
	cin >> N;
	for(i=0;i<N;i++){
		cin >> a >> b >> c;
		if(a*a+b*b==c*c || a*a+c*c==b*b || b*b+c*c==a*a){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    int S, W;
    cin >> S >> W;
    if (W >= S) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n,k,s;
    cin >> n >> k >> s;
    if(s!=1000000000){
        rep(i,k){
            cout << s << " ";
        }
        rep(i,n-k){
            cout << s+1 << " ";
        }
    }
    else{
        rep(i,k){
            cout << s << " ";
        }
        rep(i,n-k){
            cout << 1 << " ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1280
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()
    A = LI()

    # 最大の長さがxになるような切断回数
    def cut_num(x):
        ret = sum([math.ceil(i / x) - 1 for i in A])
        return ret

    ng = 0
    ok = max(A)
    while abs(ok-ng)>10**(-6):
        m = (ng+ok)/2
        if cut_num(m) <= K:
            ok = m
        else:
            ng = m

    print(math.ceil(ok))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 32688
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 123;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

int a[N];

void solve(){
    ll n, m;
    cin >> n >> m;
    n %= m;
    cout << min(n, m-n);
}

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; i++){
        //cout << "case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

bool compareHeight(const pair<lli,lli> &a,const pair<lli,lli> &b){
	return a.second > b.second;
}

signed main(){

	lli n;
	cin>>n;
	vector<pair<lli,lli>> a;
	REP(i,0,n){
		lli tmp;
		cin>>tmp;
		a.push_back(make_pair(i,tmp));
	}

	sort(a.begin(),a.end(),compareHeight);

	REP(i,0,n){
		if(a[0].first==i)cout<<a[1].second<<endl;
		else cout<<a[0].second<<endl;
	}

	return 0;
}

Measured memory_bytes: 6384
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;

struct edge{int to,cap,rev;};

class FF
{
public:
  vector<vector<edge>>G;
  vector<bool> used;
  FF(int maxv)
  {
    G.resize(maxv);
    used.resize(maxv);
  }
  void add_edge(int from,int to,int cap,bool directed=1)
  {
    G[from].push_back({to,cap,(int)G[to].size()});
    G[to].push_back({from,cap*(!directed),(int)G[from].size()-1});
  }
  int dfs(int v,int t,int f)
  {
    if(v==t)return f;
    used[v]=1;
    for(auto &nv:G[v])
    {
      if(!used[nv.to] && nv.cap>0)
      {
        int d=dfs(nv.to,t,min(f,nv.cap));
        if(d>0)
        {
          nv.cap-=d;
          G[nv.to][nv.rev].cap+=d;
          return d;
        }
      }
    }
    return 0;
  }
  int solve(int s,int t)
  {
    int res=0;
    while(1)
    {
      for(int i=0;i<used.size();i++)used[i]=0;
      int f=dfs(s,t,(1<<30)-1);
      if(f==0)break;
      res+=f;
    }
    return res;
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h,w;
  cin>>h>>w;
  vector<string>hw(h);
  rep(i,h)cin>>hw[i];
  int s,t;
  FF ff(h*w*2);
  rep(i,h*w)
  {
    ff.add_edge(i*2,i*2+1,1,0);
  }
  rep(i,h)
  {
    vector<int>leaf;
    leaf.clear();
    rep(j,w)
    {
      if(hw[i][j]!='.')
      {
        int num=(i*w+j)*2;
        if(hw[i][j]=='S')s=num+1;
        if(hw[i][j]=='T')t=num;
        for(auto k:leaf)
        {
          ff.add_edge(k+1,num,200,1);
          ff.add_edge(num+1,k,200,1);
        }
        leaf.push_back(num);
      }
    }
  }
  rep(j,w)
  {
    vector<int>leaf;
    leaf.clear();
    rep(i,h)
    {
      if(hw[i][j]!='.')
      {
        int num=(i*w+j)*2;
        for(auto k:leaf)
        {
          ff.add_edge(k+1,num,200,1);
          ff.add_edge(num+1,k,200,1);
        }
        leaf.push_back(num);
      }
    }
  }
  if((s-1)/2/w==t/2/w || (s-1)/2%w==t/2%w){cout<<-1<<endl;return 0;}
  ll res=ff.solve(s,t);
  cout<<res<<endl;
  return 0;

}


Measured memory_bytes: 61952
#include<stdio.h>

#define N 44

int F[N];

int fibonacci(int n){
  if(n==1 || n==0) return F[n]=1;
  if(F[n]!=0) return F[n];
  return F[n] = fibonacci(n-2) + fibonacci(n-1);
}

int main(){

  int i;

  for(i=0;i<N;i++) F[i]=0;

  int n,x;
  scanf("%d",&n);

  x = fibonacci(n);

  printf("%d\n",x);

  return 0;
}



Measured memory_bytes: 2104
#include <cstdio>
typedef long long int64;

int main()
{
    int64 x;
    scanf("%lld", &x);

    int64 base = x / 11, rem = x % 11;
    printf("%lld\n", base * 2 + (rem > 6 ? 2 : (rem == 0 ? 0 : 1)));

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include<stdlib.h>
int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(abs(a-c)<=d){
		printf("Yes\n");
	}
	else if(abs(a-b)<=d && abs(b-c)<=d){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func solve() {
	var N int
	fmt.Scan(&N)

	if N/100 == N%10 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func main() {
	solve()
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

vu64 S;
map<u64, u64> m;

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

    int N, K;
    u64 A;
    // cin >> N >> K;
    scanf("%d%d", &N, &K);

    S.resize(N + 1, 0);
    rep (i, N)
    {
        //cin >> A;
        scanf("%lu", &A);
        S[i + 1] = A + S[i];
    }

    rep (i, N + 1)
    {
        S[i] = (S[i] - i) % K;
    }

    u64 ans = 0;
    for (int j = 1; j <= N; ++j)
    {
        if (j - K >= 0) --m[S[j - K]];
        ++m[S[j - 1]];
        ans += m[S[j]];
    }

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



Measured memory_bytes: 14336
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll r, d, x;

	cin>>r>>d>>x;

	rep(i, 10){
		x=r*x-d;
		cout<<x<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<pii, Int> ppi;
typedef pair<double,Int> pdp;
typedef vector<Int> veci;
typedef vector<double> vecd;
typedef vector<int> veci;
typedef vector<double> vecd;
typedef vector<veci> mati;
typedef vector<vecd> matd;
#define A first
#define B second
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(auto i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
template<typename T> vector<T> getVector(const int n) { return vector<T>(n); }
template<typename T> vector<T> getVector(const int n, const T a) { return vector<T>(n, a); }
template<typename T> vector<T> getEmptyVector() { return vector<T>(); }
template<typename T> void appendAll(vector<T> &a, vector<T> b) { a.insert(a.end(), b.begin(), b.end()); }
// #define X first
// #define Y second
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const ll MOD = 1000000007;
const int MAXN = 1<<17;
const int inf = 1<<28;
const int NIL = -inf;
int popcount(int x)  { return __builtin_popcount(x); }
#define DUMP(a) \
    do { std::cout << #a " = " << (a) << ", "; } while(false)
#define DUMPLN(a) \
    do { std::cout << #a " = " << (a) << std::endl; } while(false)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, Q;
    cin >> N >> Q;
    veci S(N), T(N), X(N);
    vector<pip> V;
    FORO(i, N) {
        cin >> S[i] >> T[i] >> X[i];
        V.EB(pip(pip(X[i], pii(S[i] - X[i], T[i] - X[i]))));
    }
    set<pii> D;
    FORO(i, Q) {
        int d;
        cin >> d;
        D.insert(pii(d, i));
    }
    sort(ALL(V));
    veci ans(Q, -1);
    FORO(i, N) {
        // DUMP(V[i].B.A); DUMPLN(V[i].B.B);
        auto le = D.lower_bound(pii(V[i].B.A, 0));
        auto ub = D.lower_bound(pii(V[i].B.B, 0));
        vector<pii> toBeRemoved;
        for(;le != ub;le++) {
            toBeRemoved.EB(*le);
            if(ans[le->B] == -1) ans[le->B] = V[i].A;
            // DUMP(le->B); DUMPLN(V[i].A);
        }
        FORIT(it, toBeRemoved) D.erase(*it);
    }
    FORO(i, Q) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 20844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long int64;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

int main(int argc, char const* argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	unsigned long long x, y;
	cin >> x >> y;
	if (x == 1 || y == 1) {
		cout << 1;
		return 0;
	}
	if (x % 2 == 1 && y % 2 == 1) {
		cout << x * y / 2 + 1;
		return 0;
	}
	else {
		cout << x * y / 2;
		return 0;
	}
}

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

int main()
{
    int n;
    string s;
    cin >> n >> s;

    int r[n + 1] = {};
    int l[n + 1] = {};
    for (int i = 0; i < n; i++) {
        if (s[i] == 'E') {
            r[i + 1] = r[i] + 1;
            l[i + 1] = l[i];
        }
        else {
            l[i + 1] = l[i] + 1;
            r[i + 1] = r[i];
        }
    }

    for (int i = 0; i < n; i++) cerr << r[i] << " "; cerr << endl;
    for (int i = 0; i < n; i++) cerr << l[i] << " "; cerr << endl;
  
    int ans = n, t;
    for (int i = 0; i < n; i++) {
        t = l[i] - l[0] + r[n] - r[i + 1];
        // cerr << t << " " << l[i] << " " << l[0] << " " << r[n] << " " << r[i + 1] << " " << endl;
        ans = min(ans, t);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3076
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ABC042C
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var N = NN;
            var K = NN;
            var DList = NNList(K);
            for (var i = N; ; i++)
            {
                if (i.ToString().All(e => !DList.Contains(e - '0')))
                {
                    Console.WriteLine(i);
                    return;
                }
            }
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
}


Measured memory_bytes: 17488
#include<bits/stdc++.h>
using namespace std;
int main(){
  string str[6]={"afkpuz","bglqv.","chmrw?"
		 ,"dinsx!","ejoty "};
  string str2;
  while(cin>>str2){
    if(str2.size()%2==1)
      cout<<"NA"<<endl;
    else{
      string ans="";
      for(int i=0;i<str2.size();i+=2){
	if(str2[i+1]-'0'<=5&&str2[i]-'0'<=6&&str2[i+1]-'0'>0&&str2[i]-'0'>0){
	ans+=str[str2[i+1]-'0'-1][str2[i]-'0'-1];
	}
	else{
	  ans="NA";
	  break;
	}
      }
      cout<<ans<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3104
def factor(num)
  result = [1]
  i = 2
  while i<=num do
    if num%i==0
      result << i
    end
    i += 1
  end
  result
end

a,b,x = gets.split(" ").map{|e| e.to_i}
ab = [a,b].sort
fa = factor(ab[0])
fb = factor(ab[1])
f = fb & fa
puts f[-x]

Measured memory_bytes: 1788
import std.stdio,
    std.array,
    std.conv,
    std.string,
    std.algorithm;

void main(){
  string s;
  for(;;){
    s=readln();
    if(stdin.eof()) break;
    int num = to!int(chomp(s));
    int a,b,c,d,result=0;
    for(a = 0;a < 10;++a){
      for(b = 0;b < 10;++b){
        for(c = 0;c < 10;++c){
          for(d = 0;d < 10; ++d){
            if(a+b+c+d == num) ++result;
          }
        }
      }
    }
    writeln(result);
  }
}

Measured memory_bytes: 2408
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;++i)
int main(){int n,a=0;cin>>n;vector<string>g(n),h(n);r(i,n)cin>>g[i];r(i,n){r(j,n)h[(j+i)%n]=g[j];int f=1;r(p,n){r(q,p){if(h[p][q]!=h[q][p])f=0;}}if(f)a+=n;}cout<<a<<endl;return 0;}

Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
int main() {
  int n, ans = 0;
  string s;
  cin >> n >> s;
  for (int i = 0; i < n - 2; i++) {
    if (s.substr(i, 3) == "ABC") {
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main() {
	int N;
    int l , r ;
    cin >> N ;
    int count = 0;
    for(int i = 0; i < N; i++){
    	cin >> l >> r ;
        count += r - l + 1 ;
    }
    cout << count << endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long ll;
const int INF = 1e9;
int n;

int main() {
  cin >> n;
  int ans = 0;
  if (n < 10) {
    ans = n;
  } else if (10 <= n && n < 100) {
    ans = 9;
  }
  if (100 <= n && n < 1000) {
    ans = n - 99 + 9;
  } else if (1000 <= n && n < 10000) {
    ans = 900 + 9;
  }
  if (10000 <= n && n < 100000) ans += n - 9999 + 900 + 9;
  if (100000 == n) ans = 90000 + 900 + 9;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let v: Vec<u32> = buf.split_whitespace().map(|x| x.parse().unwrap()).collect();
    let v_max = v.iter().fold(0, |max, &x| std::cmp::max(max, x));

    let mut ans = 0;
    let mut rest = 0;
    for &x in v.iter() {
        ans += (v_max - x) / 2;
        rest += (v_max - x) % 2;
    }
    ans += match rest {
        2 => 1,
        1 => 2,
        _ => 0,
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Network{
	private:
	int V;
	struct edge{
		int to,cap,cost,rev;
	};
	vector<vector<edge> > g;
	vi h,d,pv,pe;
	public:
	Network(int v){
		V=v;
		g=vector<vector<edge> >(v);
	}
	void add_edge(int s,int t,int cap,int cost){
		g[s].push_back(edge{t,cap,cost,(int)g[t].size()});
		g[t].push_back(edge{s,0,-cost,(int)g[s].size()-1});
	}
	int min_cost_flow(int s,int t,int f){
		int res=0;
		h=pv=pe=vi(V);
		while(f>0){
			priority_queue<P> q;
			d=vi(V,inf);
			d[s]=0;
			q.push({0,s});
			while(!q.empty()){
				P p=q.top();
				q.pop();
				int v=p.second;
				if(d[v]<-p.first) continue;
				for(int i=0;i<g[v].size();i++){
					edge &e=g[v][i];
					if(e.cap>0&&d[e.to]>d[v]+e.cost+h[v]-h[e.to]){
						d[e.to]=d[v]+e.cost+h[v]-h[e.to];
						pv[e.to]=v;
						pe[e.to]=i;
						q.push({-d[e.to],e.to});
					}
				}
			}
			if(d[t]==inf) return -1;
			for(int i=0;i<V;i++) h[i]+=d[i];
			int D=f;
			for(int i=t;i!=s;i=pv[i]) D=min(D,g[pv[i]][pe[i]].cap);
			f-=D;
			res+=D*h[t];
			for(int i=t;i!=s;i=pv[i]){
				edge &e=g[pv[i]][pe[i]];
				e.cap-=D;
				g[i][e.rev].cap+=D;
			}
		}
		return res;
	}
};

int n,m,k;

int main(){
	cin>>n>>m>>k;
	Network nt(n+m+4);
	vvi a(m+1,vi(n));
	vi sum(n);
	int res=0;
	for(int i=0;i<n;i++) nt.add_edge(0,i+1,1,0);
	for(int i=0;i<=m;i++) for(int j=0;j<n;j++){
		cin>>a[i][j];
		sum[j]+=a[i][j];
		res+=a[i][j];
	}
	for(int i=0;i<=m;i++) for(int j=0;j<n;j++){
		nt.add_edge(j+1,n+i+1,1,sum[j]-a[i][j]);
	}
	for(int i=0;i<m;i++){
		int T;
		cin>>T;
		nt.add_edge(n+i+2,n+m+2,T,0);
	}
	nt.add_edge(n+1,n+m+3,inf,0);
	nt.add_edge(n+m+2,n+m+3,n-k,0);
	cout<<res-nt.min_cost_flow(0,n+m+3,n)<<endl;
}

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

int main(void){
  int n,m,k;
  cin >> n >> m >> k;
  for(int i = 0;i <= n;++i){
    for(int j = 0;j <= m;++j){
      if(i*m+j*n-i*j*2 == k){
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 256
import collections
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    S = [input().rstrip() for _ in range(N)]
    c = collections.Counter(S).most_common()
    max_freq = None
    max_S = []
    for s, freq in c:
        if max_freq is None:
            max_freq = freq
            max_S.append(s)
        elif freq == max_freq:
            max_S.append(s)
        else:
            break
    print('\n'.join(sorted(max_S)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 149052
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
int n,ans;
signed main(){
	char a;
	cin>>a;
	if('a'<=a && a<='z')cout<<"a"<<endl;
	else cout<<"A"<<endl;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
using Graph = vector<vector<int>>;

struct UnionFind {
  //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
  //そうでなければ親のid
  vector<int> r;
  UnionFind(int N) {
    r = vector<int>(N, -1);
  }
  int root(int x) {  // データxが属する木の根を再帰で得る
    if (r[x] < 0) return x;  //根
    return r[x] = root(r[x]);  //経路圧縮
  }
  bool unite(int x, int y) {  //xとyの属する木を併合
    x = root(x);
    y = root(y);
    if (x == y) return false; //もともと一つならスルー
    if (r[x] > r[y]) swap(x, y);
    r[x] += r[y];
    r[y] = x;
    return true;
  }
  int size(int x) {
    return -r[root(x)]; //木のサイズ
  }
  bool same(int x, int y) { //xとyが同じ木に属するならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  int p[N];
  FOR(i,0,N) cin >> p[i];
  //友達集合を作る
  UnionFind UF(N);
  for (int i = 0; i < M; i++) {
    int A,B;
    cin >> A >> B;
    A-=1; B-=1;
    UF.unite(A, B);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int I = p[i]-1;
    if (UF.same(i, I)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4048
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[a[0]%m]
for i in a[1:]:b.append((b[-1]+i)%m)
b.sort()
b+=[-1]
a=x=1
for i in range(n):
  if b[i]==0:a+=1
  if b[i]!=b[i+1]:
    a+=x*(x-1)//2
    x=1
  else:x+=1
print(a-1)

Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i <= k;++i)
#define repp(i,j,k) for(int i = j;i >= k;--i)
#define rept(i,x) for(int i = linkk[x];i;i = e[i].n)
#define P pair<int,int>
#define Pil pair<int,ll>
#define Pli pair<ll,int>
#define Pll pair<ll,ll>
#define pb push_back 
#define pc putchar
#define mp make_pair
#define file(k) memset(k,0,sizeof(k))
#define ll long long
int rd()
{
    int sum = 0;char c = getchar();bool flag = true;
    while(c < '0' || c > '9') {if(c == '-') flag = false;c = getchar();}
    while(c >= '0' && c <= '9') sum = sum * 10 + c - 48,c = getchar();
    if(flag) return sum;
    else return -sum;
}
bool f[101000],g[101000];
int cnt[101000];
int main()
{
	int n = rd(),m = rd(),x,y;
	f[1] = true;rep(i,2,n) g[i] = true;rep(i,1,n) cnt[i] = 1;
	rep(i,1,m)
	{
		x = rd(),y = rd();
		cnt[y]++;cnt[x]--;
		f[y] |= f[x];g[y] |= g[x];
		if(cnt[x] == 0) f[x] = g[x] = false;
	}
	int ans = 0;
	rep(i,1,n) ans += f[i];
	printf("%d\n",ans);
}

Measured memory_bytes: 768
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	string s;
	cin >> s;
	int i = 0;
	int sz = s.size();
	string correct("keyence");
	for (int i = 0; i < 8; ++i){
		bool flag = true;
		for (int j = 0; j < i; ++j) if(s[j] != correct[j]) flag = false;
		for (int j = i; j < 7; ++j) if(s[sz + j - 7] != correct[j]) flag = false;
		if(flag){
			printf("YES\n");
			return 0;	
		}
	}
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
A, V = list(map(int, input().split()))
B, W = list(map(int, input().split()))
T = int(input())

d = abs(A - B)
V_AB = V - W

if (V_AB <= 0):
    print("NO")
elif (d / V_AB > T):
    print("NO")
else:
    print("YES")


Measured memory_bytes: 9176