akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Text;

public class Program
{
    private int N;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();

        int r;

        for (r = 1; (r + 1) * r / 2 < N; r++) ;

        if ((r + 1) * r / 2 != N)
        {
            Console.WriteLine("No");
            return;
        }

        List<int>[] ans = new List<int>[r + 1];

        for (int i = 0; i <= r; i++)
        {
            ans[i] = new List<int>();
        }

        int n = 1;

        for (int i = 0; i < r; i++)
        {
            int t = ans[i].Count;
            for (int j = 0; j < r - t; j++)
            {
                ans[i].Add(n);
                ans[i + j + 1].Add(n);
                n++;
            }
        }

        var sb = new StringBuilder();

        sb.AppendLine("Yes");
        sb.AppendLine((r + 1).ToString());
        foreach (List<int> list in ans)
        {
            sb.AppendLine($"{list.Count} {string.Join(" ", list)}");
        }

        Console.Write(sb.ToString());
    }


    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 21968
#include <iostream>
#include <vector>

int main() {
    long long n, sum = 0, t;
    std::cin >> n;
    std::vector<long long> p(n);
    for (long long i = 1; i <= n; i++) std::cin >> t, p[t - 1] = i;

    for (long long i = 0; i < n; i++) {
        sum += p[i];
        std::cout << sum;
        if (i != n - 1) std::cout << " ";
    }
    std::cout << std::endl;

    for (long long i = 0; i < n; i++) {
        std::cout << sum;
        if (i != n - 1) std::cout << " ";
        sum -= p[i];
    }
    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e5 + 7;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

int main() {
    long long x;
    cin >> x;
    long long cant = 100;
    int ans = 0;
    while (cant < x) {
        cant += cant / 100;
        ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    long long n, t; cin >> n >> t;
    vector<long long> a(n);
    rep(i, n) cin >> a[i];

    long long mini = a[0];
    map<long long, int> diffs;
    rep(i, n - 1) {
        mini = min(mini, a[i]);
        auto diff = a[i + 1] - mini;
        diffs[diff]++;
    }
    auto ans = *(diffs.rbegin());
    cout << ans.second << endl;
}


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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;
        private static List<long> numList = new List<long>();
        private static StringBuilder numWorkStringBuilder = new StringBuilder();
        static void Solve()
        {
            string w = Console.ReadLine();
            var table = new int[26];
            for(int i=0;i<w.Length;++i)
            {
                int idx = w[i] - 'a';
                table[idx]++;
            }
            bool beautiful = true;
            foreach(int total in table)
            {
                if( total % 2 != 0)
                {
                    beautiful = false;
                    break;
                }
            }
            string ans = beautiful ? "Yes" : "No";
            Console.WriteLine(ans);
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> A;
    rep(i,N) {
        int a;
        cin >> a;
        rep(j,a) {
            A.push_back(i+1);
        }
    }

    int ans[H][W] = {};

    rep(h,H) {
        rep(w,W) {
            if (h%2==0) {
                ans[h][w] = A.back();
                A.pop_back();
            }
            else {
                ans[h][W-1-w] = A.back();
                A.pop_back();
            }
        }
    }

    rep(h,H) {
        rep(w,W) {
            cout << ans[h][w] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int digits(int n) {
  int ret = 0;
  for (; n; n /= 10) ++ret;
  return ret;
}

int main() {
  int n, ret = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    if (digits(i) % 2) ++ret;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#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--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

ll x[100010];
ll y[100010];
ll z[100010];
vector<int> g[100010];

bool seen[100010];

void dfs(int v){
    seen[v] = true;
    for(auto nv : g[v]){
        if (seen[nv]) continue;
        seen[nv] = true;
        dfs(nv);
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, m) cin >> x[i] >> y[i] >> z[i];
    rep(i, m) x[i]--, y[i]--;

    rep(i, m){
        g[x[i]].push_back(y[i]);
        g[y[i]].push_back(x[i]);
    }

    int cnt = 0;

    rep(i, n){
        if (seen[i]) continue;
        dfs(i);
        cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 11264
S = int(input())
MOD = 10 ** 9 + 7

#dp[i]最後に切った場所がi　スタートが1なのは、そこまでの切り方が1通りなので
#３以下はダメなので、3個前の結果を見るようにする
dp =  [0] * (S+1)
dp[0] = 1

#これまでの和をxに保存しておく
x = 0
for i in range(1, S+1):
    if i-3 >= 0:
        x += dp[i-3]
        x %= MOD
    dp[i] = x
print(dp[S])        

Measured memory_bytes: 63756
K=int(input())
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[K-1])


Measured memory_bytes: 2940
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll N,M;
	cin >> N>>M;
	vector<pair<pair<ll,ll>,pair<ll,string>>> vec(M);
	for (ll i = 0; i < M; ++i){
		ll p,y;cin>>p>>y;
		vec[i].first.first = p;
		vec[i].first.second = y;
		vec[i].second.first = i;
		vec[i].second.second = "";
	}
 
	// 解法
	sort(vec.begin(), vec.end());
	// REP(i,M){
	// 	printf("%lld %lld %lld\n", vec[i].first.first, vec[i].first.second, vec[i].second.first);
	// }
	
	vector<pair<ll,pair<ll,ll>>> bangou(M); //市番号, 県番号, 誕生番号
	ll kenbangou = -1;
	ll tanjoubangou = 0;
	REP(i,M){
		bangou[i].first = vec[i].second.first;
		if (kenbangou!=vec[i].first.first){
			kenbangou = vec[i].first.first;
			tanjoubangou = 1;
		}
		else tanjoubangou++;
		bangou[i].second.first = kenbangou;
		bangou[i].second.second = tanjoubangou;
	}
	sort(bangou.begin(), bangou.end());
	// REP(i,M){
	// 	printf("%lld %lld %lld\n", 
	// 	bangou[i].first, bangou[i].second.first, bangou[i].second.second);
	// }
	REP(i,M){
		cout << setfill('0') << right << std::setw(6) << bangou[i].second.first;
		cout << setfill('0') << right << std::setw(6) << bangou[i].second.second;
		cout << endl;

	}
}


Measured memory_bytes: 8320
#include <stdio.h>
int main(){
  int n,x,i,j,k;
  for(;;){
    scanf("%ld %ld",&n,&x);
    if(n==0&&x==0){
      return 0;
    }
    int p=0;
    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
        for(k=1;k<=n;k++){
          if(i+j+k==x&&i!=j&&j!=k&&k!=i){
            p++;
          }
        }
      }
    }
    printf("%d\n",p/6);
  }
}

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

using namespace std;
const int Max_Num=100010;
typedef pair<int,int> P;

int col[Max_Num];
vector<P> G[Max_Num];
int K;

void dfs(int n, int color){
	int c=1;
	rep(i,G[n].size()){
		if(col[G[n][i].second]!=-1) continue;
		if(c==color) c++;
		K=max(K,c);
		col[G[n][i].second]=c;
		dfs(G[n][i].first,c);
		c++;
	}
}

int main(){
	int N;
	cin >> N;
	rep(i,N-1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].emplace_back(make_pair(b,i));
		G[b].emplace_back(make_pair(a,i));
	}
	rep(i,N-1) col[i]=-1;
	K=0;
	dfs(0,0);
	cout << K << endl;
	rep(i,N-1) cout << col[i] << endl;

  return 0;
}


Measured memory_bytes: 9344
#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 itn int
#define all(c) c.begin(),c.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define ll long long
#define ull unsigned long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;

const ll MAX_N = 1e6 + 5, inf = 1e18, mod = (int)1e9+7;
const double PI = 3.1415926536;
int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool is_prime(int n) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

inline ll getPow(ll a,ll b) {
    ll res = 1ll, tp = a;
    while (b){
       if (b&1ll) {
           res *= tp;
       }
       tp *= tp;
     //  tp %= mod; res %= mod;
       b >>= 1ll;
    }
    return res;
}

ll vec_mult(const pll &t1, const pll &t2, const pll &t3) {
   const ll &x1 = t1.first, y1 = t1.second;
   const ll &x2 = t2.first, y2 = t2.second;
   const ll &x3 = t3.first, y3 = t3.second;
   return ((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1));
}

void ok() {
   cout << "YES" << endl;
}

void no() {
   cout << "NO" << endl;
}

inline ll nxt() {
    ll x;
    cin >> x;
    return x;
}

int main()
{
    //freopen("hall.in", "r", stdin); freopen("hall.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int n = nxt();
    vector<int> last(21, -1);
    ll ans = 0;
    int l = 0;
    for (int i = 0; i < n; i++) {
        int x = nxt();
        for (int j = 0; j <= 20; j++) {
            if (x & (1 << j)) {
                l = max(last[j] + 1, l);
                last[j] = i;
            }
        }
        ans += i - l + 1;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	double n,w,l,f=0;
	for(;~scanf("%lf,%lf,%lf",&n,&w,&l);)
		if(25*l*l<=w)
			printf("%.0f\n",f=n);
	if(!f)
		puts("該当なし");
	return 0;
}

Measured memory_bytes: 648
n,m,k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_c_sum = [0]*(n + 1)
for i in range(n):
  a_c_sum[i + 1] = a_c_sum[i] + a[i]
b_c_sum = [0]*(m + 1)
for i in range(m):
  b_c_sum[i + 1] = b_c_sum[i] + b[i]

ans, best_b = 0, m
for i in range(n + 1):
  if a_c_sum[i] > k:
    break
  else:
    while 1:
      if b_c_sum[best_b] + a_c_sum[i] <= k:
        ans = max(ans, i + best_b)
        break
      else:
        best_b -= 1
        if best_b == 0:
          break
print(ans)

Measured memory_bytes: 47444
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ll n,a,b;
    cin>>n>>a>>b;

    ll ans = min(n-a,b-1);
    if((b-a)%2==0){
        ans = min(ans,(b-a)/2);
    }
    ll aside,bside,diff;
    diff = b-a;
    aside = 0;
    bside = 0;
    if(diff%2==1){
        diff--;
        aside++;
        bside++;
    }
    aside += a-1 + diff/2;
    bside += n-b + diff/2;

    ans = min(ans,min(aside,bside));
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<map>
using namespace std;

int main() {
	int N, R;
	cin >> N>>R;
	if (N < 10) {
		cout << R + 100 * (10 - N) << endl;
	}
	else {
		cout << R << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

ll a[1001],b[1001],c[1001];
int x,y,z,k;
ll st1[3000001],st2[3000001];
int main(){
    cin>>x>>y>>z>>k;
    rep(i,x) cin>>a[i];
    rep(i,y) cin>>b[i];
    rep(i,z) cin>>c[i];
    rep(i,x)rep(j,y) st1[i*y+j]=a[i]+b[j];
    sort(st1,st1+x*y,greater<ll>());
    int p=min(k,x*y);
    rep(i,p)rep(j,z){
        st2[i*z+j]=st1[i]+c[j];
    }
    sort(st2,st2+p*z,greater<ll>());
    rep(i,k){
        cout<<st2[i]<<endl;
    }
    return 0;
}


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

int main(){
  double n;
  while(1){
    cin >> n;
    if(n < 0) break;
    int sei = (int)n;
    int st = sei;
    double syo = n - (double)sei;
    double d = 1;
    double temp = syo;
    for(int i=8;i>0;i--){
      int tmp = (int)pow(2.0,(double)i-1);
      if(st >= tmp){
	st -= tmp;
      }
    }
    for(int i=0;i<4;i++){
      d = d / 2.0;
      if(temp >= d){
	temp -= d;
      }
    }
    if(st != 0 || temp != 0){
      cout << "NA" << endl;
      continue;
    }
    for(int i=8;i>0;i--){
      int tmp = (int)pow(2.0,(double)i-1);
      if(sei >= tmp){
	cout << "1";
	sei -= tmp;
      }
      else cout << "0";
    }
    cout << ".";
    double tt=1;
    for(int i=0;i<4;i++){
      tt = tt / 2.0;
      if(syo >= tt){
	cout << "1";
	syo -= tt;
      }
      else cout << "0";
    }
    cout << endl;
  }
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
//cout << fixed << setprecision(8) << a << endl;
//cout << "Case " << ca << ": " << ans << endl;
#define Fast_Input ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
int main ()
{
    long long int n,i,j;
    cin >> n;
    map <long long int,long long int> ma;
    vector <long long int > v;
    vector <long long int > m;

    for(i=0;i<n;i++)
    {
        long long int x;
        cin >> x;
        v.push_back(x);
        m.push_back(x);
    }

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

    for(i=0;i<(n/2);i++)
    {
        ma[v[i]]=v[(n/2)];
    }

    for(i=(n/2);i<n;i++)
    {
        ma[v[i]]=v[(n/2)-1];
    }

    for(i=0;i<n;i++)
    {
        cout << ma[m[i]] << endl;
    }


    return 0;
}


Measured memory_bytes: 17508
package main

import (
	"fmt"
	"sort"
)

func main() {
	A := make([]int, 3)
	for i := 0; i < 3; i++ {
		fmt.Scan(&A[i])
	}
	sort.Ints(A)

	ans := (A[2]*2-A[1]-A[0])/2 + ((A[2]*2-A[1]-A[0])%2)*2
	fmt.Println(ans)
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (true) {
        c -= b;
        if (c <= 0) {
            cout << "Yes\n";
            return 0;
        }
        a -= d;
        if (a <= 0) {
            cout << "No\n";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3652
N, A, B = gets.split.map(&:to_i)
V = gets.split.map(&:to_i).sort.reverse

freq = V.inject(Hash.new(0)) {|h, x| h[x] += 1; h}
nums = V.take(A) 
puts "%.6f\n" % (nums.inject(:+) / nums.size.to_f)

def nCr(n, r)
  ((r + 1)..n).inject(1, :*) / (1..(n - r)).inject(1, :*)
end

if nums.first == nums.last
  X = freq[nums.first]
  puts (A..[X, B].min).map{|r| nCr(X, r)}.inject(:+)
else
  c = nums.last
  m = freq[c]
  r = nums.reverse.inject(0) {|tot, x| tot += 1 if x == c; tot}
  puts nCr(m, r)
end

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>

using namespace std;

#define fori(x) for(int i=0;i<x;++i)
#define forj(x) for(int j=0;j<x;++j)

constexpr int maximum = 100100;


int main() {
	int n, k; vector<int> p(200100,0),q(200000,0);
	cin >> n >> k;
	fori(n)cin >> p[i];
	int hoge = 0;
	for (int i = 0; i < k; ++i) {
		hoge += p[i];
	}
	q[0] = hoge;
	for (int i = 1; i <= n - k; ++i) {
		q[i] = (hoge = hoge - p[i - 1] + p[i + k - 1]);
	}
	sort(q.begin(), q.end(),greater<int>());
	cout << fixed<< setprecision(15) <<(((float)q[0] - k) / 2.0f) + k;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
  int N=0;
  int K=0;
  int max=0;
 scanf("%d %d\n",&N,&K);
  max=N-K;
  if(K==1)
  {
    max=0;
  }
  printf("%d",max);
  return 0;
}

Measured memory_bytes: 128
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

type Node struct {
	id, to int
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, M := sc.nextInt(), sc.nextInt()
	G := make([][]Node, N)
	for i := 0; i < M; i++ {
		from := sc.nextInt() - 1
		to := sc.nextInt() - 1
		G[from] = append(G[from], Node{i, to})
		G[to] = append(G[to], Node{i, from})
	}
	var dfs func(id, to int, visited []bool)
	dfs = func(id, to int, visited []bool) {
		visited[to] = true
		for _, node := range G[to] {
			if id != node.id && !visited[node.to] {
				dfs(id, node.to, visited)
			}
		}
	}
	ans := 0
	ids := make([]bool, M)
	for _, nodes := range G {
		for _, node := range nodes {
			if !ids[node.id] {
				visited := make([]bool, N)
				dfs(node.id, 0, visited)
				ids[node.id] = true
				ok := false
				for _, b := range visited {
					if !b {
						ok = true
					}
				}
				if ok {
					ans++
				}
			}
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 640
#include <stdio.h>

void trace(int A[], int N){
  int i;
  for(i=0; i<N; i++){
    if(i>0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}
void insort(int A[], int N){
    int i, j, v;
    for(i=0; i<N; i++){
      v = A[i];
      j = i-1;
     while(j>=0 && A[j]>v){
	  A[j+1] = A[j];
	  j--;
     }
	  A[j+1] = v;
	  trace(A, N);
    }
}
int main(){
  int i, j, N;
   int A[100];
   
   scanf("%d", &N);
   for(i=0; i<N; i++)
   scanf("%d", &A[i]);

   
   insort(A, N);
     
    return 0;
 }



Measured memory_bytes: 2040
from collections import deque

N=int(input())
L=[[] for _ in range(N+1)]
for a in range(N-1):
    u,v,w=map(int,input().split())  #これで良いのか
    L[u].append((v,w))
    L[v].append((u,w))

dist=[-1]*(N+1)
q=deque()
color=[-1]*(N+1)

dist[1]=0
q.append(1)
color[1]=0
while q:
    now=q.popleft()
    for next in L[now]:
        if dist[next[0]]==-1:
            q.append(next[0])
            dist[next[0]]=dist[now]+next[1]
            if dist[next[0]]%2==0:
                color[next[0]]=0
            else:
                 color[next[0]]=1

for b in range(1,N+1):
    print(color[b])
        

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

int main() {
    string s, t;
    cin >> s;
    for (int i = 1; i <= s.size(); i++) {
        if (s[i] == 'C' && s[i - 1] == 'B') {
            t.push_back('D');
            i++;
        } else {
            t.push_back(s[i - 1]);
        }
    }
    long long result = 0;
    for (int i = 0, count = 0; i < t.size(); i++) {
        if (t[i] == 'B' || t[i] == 'C') {
            count = 0;
        } else if (t[i] == 'A') {
            count++;
        } else {
            result += count;
        }
    }
    cout << result;
    return 0;
}

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

using namespace std;
int main(void)
{
    int x, n, ans;
    cin >> x >> n;
    set<int> p;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        p.insert(tmp);
    }
    ans = x;
    for (int i = 0;; i++) {
        if (p.count(x - i) == 0) {
            ans = x - i;
            break;
        } else if (p.count(x + i) == 0) {
            ans = x + i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
def gcm(a,b):
    if a < b:
        a,b = b,a
    while True:
        if a % b == 0:
            return b
        else:
            a,b = b,a % b

def lcm(a,b):
    g = gcm(a,b)
    return a*b//g;

n = int(input())
Data = list(map(int,input().split()))
ans = lcm(Data[0],Data[1])
for i in range(2,len(Data)):
    ans = lcm(ans,Data[i])
print(ans)


Measured memory_bytes: 5600
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

pair<int, int> dp[1000001]; // scroll, last cave
int isVisited[1000001];
bool pcheck[1000001];

int n, m;
int caseN;

vector <int> sqr;

int arr[2000][2000];
int hash[1000001][2];

vector <int> getNext(int tar)
{
	vector <int> ret;
	int y = hash[tar][0], x = hash[tar][1];
	ret.push_back(arr[y - 1][x - 1]);
	ret.push_back(arr[y - 1][x]);
	ret.push_back(arr[y - 1][x + 1]);
	return ret;
}

pair<int, int> getAns(int ith)
{
	if(ith > m || ith == 0) return make_pair(0, 0);
	pair<int, int> &ret = dp[ith];
	if(isVisited[ith] == caseN) return ret;
	isVisited[ith] = caseN;

	bool flag = (pcheck[ith] == false);

	if(flag) ret = make_pair(1, ith);
	else ret = make_pair(0, 0);
	
	vector <int> next = getNext(ith);
	for(int i=0;i<next.size();i++)
	{
		pair<int, int> res = getAns(next[i]);
		if(ret.first < res.first + flag)
		{
			ret = res;
			ret.first += flag;
		}
		else if (ret.first == res.first + flag) ret.second = max(ret.second, res.second);
	}

	return ret;		
}

int main(void)
{
	pcheck[1] = true;
	for(int i=2;i<=1000000;i++)
	{
		if(pcheck[i]) continue;
		for(int j=i*2;j<=1000000;j+=i) pcheck[j] = true;
	}

	for(int i=1;i*i<=1000000;i+=2) sqr.push_back(i*i);

	int y = 1000, x = 1000;
	arr[y][x] = 1;
	hash[1][0] = y, hash[1][1] = x;
	int cur = 2;
	int len = 3;
	x++;
	int mov[4][2] = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}};
	do
	{
		for(int i=0;i<4;i++)
		{
			for(int j=0;j<len-1;j++) 
			{ 
				hash[cur][0] = y, hash[cur][1] = x; 
				arr[y][x] = cur++;
				y += mov[i][0];
				x += mov[i][1];

			}
			
			if(i < 3)
			{
				y -= mov[i][0], x -= mov[i][1];
				y += mov[i + 1][0], x += mov[i + 1][1];
			}
		}
		len += 2;
	} while(cur <= 1000000);

	while(scanf("%d %d", &m, &n), n)
	{
		caseN++;
		pair <int, int> ans = getAns(n);
		printf("%d %d\n", ans.first, ans.second);
	}

	return 0;
}

Measured memory_bytes: 33196
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    char X[200100];
    ins(X);
    //後ろからなめる
    //Sが表れかつ左にTが存在すれば-2
    ll ans=strlen(X), T=0, N=strlen(X);
    rep(i, N){
        if(X[N-1-i]=='T') T++;
        else if(T){
            T--;
            ans -= 2;
        }
    }
    put(ans);
    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		int kyougi[] = new int[N];
		int shinsain[] = new int[M];
		int vote[] = new int[N];
		
		for(int j = 0; j < N; j++){
			kyougi[j] = sc.nextInt();
		}
		
		for(int j = 0; j < M; j++){
			shinsain[j] = sc.nextInt();
		}
		
		
		for(int i = 0; i < M; i++){
			for(int j = 0; j < N; j++){
				if(shinsain[i] >= kyougi[j]){
					vote[j]++;
					break;
				}
			}
		
		}
		int MAX = 0;
		for(int i = 0; i < N; i++){
			if(vote[MAX] < vote[i]){
				MAX = i;
			}
		}
		System.out.println(MAX+1);
		
		
		
	}
				
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
#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,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll x;cin>>x;
    for(ll a=0;a<=200;a++){
        for(ll b=-200;b<=200;b++){
            if(a*a*a*a*a-b*b*b*b*b==x){
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }
}

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

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

string input, ss;
int a[3], it, cnt;

int Not(int x) {
    return 2-x;
}

int And(int x, int y) {
    if (x*y == 0) return 0;
    if (x == 2 && y == 2) return 2;
    return 1;
}

int Or(int x, int y) {
    if (x == 2 || y == 2) return 2;
    if (x == 1 || y == 1) return 1;
    return 0;
}

int parse() {
    char c = ss[it++];
    if ('0' <= c && c <= '2') return c-'0';
    if (c == '-') return Not(parse());

    int x = parse();
    c = ss[it++];
    int y = parse();
    ++it;
    return c == '*' ? And(x, y) : Or(x, y);
}

int main() {
    while (cin >> input && input != ".") {
        rep (i,3) a[i] = i;
        cnt = 0;
        rep (i,3) rep (j,3) rep (k,3) {
            a[0] = i; a[1] = j; a[2] = k;
            ss = input;
            for (char& c : ss) {
                if (c == 'P') c = a[0]+'0';
                if (c == 'Q') c = a[1]+'0';
                if (c == 'R') c = a[2]+'0';
            }
            it = 0;
            if (parse() == 2) cnt++;
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 1196
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int k,t;
	int a[102];
	scanf("%d%d",&k,&t);
	rep(i,t)scanf("%d",&a[i]);
	
	int A = 0;
	rep(i,t)A = max ( A , a[i] );
	
	if(A <= (k+1)/2)puts("0");
	else {
		cout << (k-1)-2*(k-A) << endl;
	}
}



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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    int N,x; cin>>N>>x;
    int a[N]; REP(i,N) cin>>a[i];
    i64 ans=0;
    REP(i,N-1) {
        i64 d = a[i]+a[i+1]-x;
        if (d>0) {
            ans += d;
            if (d<a[i+1]) a[i+1] -= d;
            else a[i+1] = 0;
          
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
const long long MAX = (ll)1e5+100;

ll dp[MAX];

int main(void) {
   ll X;
   cin>>X;
   rep(i,0,MAX) dp[i] = 0;
   dp[0] = 1;
   rep(i,0,MAX) {
      rep(j,0,6) {
         if (i-100-j>=0 && dp[i-100-j]>0) dp[i]=1;
      }
   }
   cout<<dp[X]<<endl;







   return 0;
}

Measured memory_bytes: 1024
/*

Author: @karngyan
Team: BlundersPride

*/

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

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<ll,ll> pll;
typedef std::vector<vll> vvll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define max3( a, b, c ) max( a , max(b , c))
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair
vll a;
vll b;
signed main()
{

	fast;
////////////////////////////////////////////////////////////////////////////////////////////
	ll n , m;
	cin >> m >> n;
	cres(a,n);
	rep(i,0,n)
		cin >> a[i];
	sort(all(a));

	ll ans = 0;
	for(ll i = 1 ; i<n ; ++i)
	{
		b.pb(a[i] - a[i-1]);
	}

	sort(all(b));
	for(ll i = 0 ; i<n-m and i<b.size() ; ++i)
	{
		ans+=b[i];
	}

	cout<<ans<<endl;







////////////////////////////////////////////////////////////////////////////////////////////

	return 0;
}


Measured memory_bytes: 2168
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
string S;
ll N,M;
 
 
 
int main(){
    cin >> N >> M;
    if(N==M){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define f first
#define s second
#define sz(x) int(x.size())
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define SIZE 26     
#define watch1(x) cout << (x) << endl
#define watch2(x,y) cout << (x) << " " << (y) << endl
#define watch3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
 
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
 
const ll mod = 1e9 + 7;
const int inf = 1e9 + 5;
const int N = 2e5 + 5;

signed main(){
    fastio;
    int i,j,n,ans=0;
    cin>>n;
    for(i=1;i<=n;++i){
        int last=i%10;
        int dig=0,lol=i;
        while(lol){
            ++dig;
            lol/=10;
        }
        int first=i/pow(10,dig-1);
        if(last==0) continue;
        if(first==last) ++ans;
        for(j=1;j<=5;++j){
            int num=last*pow(10,j)+10*(pow(10,j-1)-1)+first;
            if(num<=n){
                ans+=pow(10,j-1);
            }
            else break;
        }
        int val=last*pow(10,j)+first;
        if(val<=n) ans+=(n-val)/10+1;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
	ll n;
	cin>>n;
	vector<ll> v;
	rep(i,0,n){
		ll a;
		cin>>a;
		v.pb(a);
	}
	sort(all(v));
	double d = (0.+v[0]+v[1])/2.;	
	rep(i,2,n){
		d += 1.*v[i];
		d /= 2.;
	}
	printf("%20.20f\n", d);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE


void solve(void)
{
  int N;
  cin>>N;
  int A = N;
  int DIGIT = 0;
  while(A != 0)
  {
    DIGIT += A - A/10*10;
    A /=10;
  }
  cout<<(N%DIGIT == 0?"Yes":"No")<<endl;
  


  return;
}


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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 384
// https://atcoder.jp/contests/abc174/tasks/abc174_e
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    ll amx = -1;
    REP(i, N)
    {
        cin >> A[i];
        amx = max(amx, A[i]);
    }
    if (0 == K)
    {
        cout << amx << endl;
        return 0;
    }
    ll left = 0, right = amx;
    while (right - left > 1)
    {
        ll mid = (left + right) / 2;
        ll cnt = 0;
        REP(i, N)
        {
            cnt += (A[i] + mid - 1) / mid - 1;
            if (cnt > K) break;
        }

        if (cnt <= K) right = mid;
        else left = mid;

    }

    cout << right << endl;
    return 0;
}


Measured memory_bytes: 4756
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


int n;
pii a[N],b[N],c[N],L,R;
pii add(pii a, pii b) {
	if (!a.x) return b;
	if (!b.x) return a;
	return pii(max(a.x,b.x),min(a.y,b.y));
}
int len(pii a) {
	if (!a.x) return -INF;
	return a.y-a.x+1;
}

int main() {
	scanf("%d",&n);
	REP(i,1,n) scanf("%d%d",&a[i].x,&a[i].y);
	sort(a+1,a+1+n,[](pii a,pii b){return a.y-a.x<b.y-b.x;});
	int ans = len(a[n]), cnt = 0;
	sort(a+1,a+1+n,[](pii a,pii b){return a.y<b.y;});
	L = a[1];
	REP(i,2,n) {
		pii t(add(L,a[i]));
		if (t.x>t.y) R = add(R,a[i]);
		else b[++cnt] = a[i];
		if (R.x>R.y) return printf("%d\n",ans),0;
	}
	sort(b+1,b+1+cnt,greater<pii>());
	c[cnt] = b[cnt];
	PER(i,1,cnt-1) c[i] = add(c[i+1],b[i]);
	ans = max(ans, len(add(c[1],L))+len(R));
	if (!R.x) {
		int ma = -INF;
		REP(i,1,cnt) ma = max(ma, len(b[i]));
		ans = max(ans, len(add(c[1],L))+ma);
	}
	REP(i,1,cnt) {
		R = add(R,b[i]);
		ans = max(ans, len(add(c[i+1],L))+len(R));
	}
	printf("%d\n", ans);
}








Measured memory_bytes: 9216
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp
vector<bool> seen;
vector<ll> ans;
void dfs(vector<vector<pair<ll,ll>>> &g, ll node, ll cost){
    seen[node] = true;
    ans[node] = cost % 2;

    for(ll i = 0; i < g[node].size(); i++){
        ll next_node = g[node][i].second;
        if(seen[next_node]){
            continue;
        }else{
            ///////
            //今見てるnodeに対する処理
            ///////
            cost += g[node][i].first;
            dfs(g, next_node, cost);
            cost -= g[node][i].first;
        }
    }
    
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n; cin >> n;
    vector<vector<pair<ll, ll>>> g(n);
    rep(i, n - 1){
        ll u, v, w; cin >> u >> v >> w; u--; v--;
        g[u].push_back({w, v});
        g[v].push_back({w, u});
    }
    
    seen.resize(n);
    ans.resize(n, -1);
    ans[0] = 0;
    dfs(g, 0, 0);

    rep(i, n){
        cout << ans[i] << endl;
    }

}

Measured memory_bytes: 10752