akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	const LL P = 998244353;
	int N, S;
	cin >> N >> S;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	/*
	dp[i][j]
	A_iまで見たときに
	合計がjになる場合の数。
	更新A_(i+1)で更新される
	dp[i+1][j] += dp[i][j] mod
	dp[i+1][j+A_(i+1)] += dp[i][j] mod
	*/
	vector<vector<LL>> dp(N+1, vector<LL>(S+1,0));
	dp[0][0] = 1;
	for (int i = 0; i < N; ++i) {
		//A[i]
		LL ter = A[i];
		dp[i + 1][0] = 1;
		if (ter == S) {
			dp[i + 1][ter] = ((i + 1) * (N - i)) % P;
		}
		else if (ter < S) {
			dp[i + 1][0 + ter] = (i + 1) % P;
		}

		for (int s = 1; s < S; ++s) {
			dp[i + 1][s] += dp[i][s];
			dp[i + 1][s] %= P;
			LL wa = s + A[i];
			if (wa == S) {
				LL res = (dp[i][s] * (N - i)) % P;
				dp[i + 1][wa] += res;
				dp[i + 1][wa] %= P;
			}
			else if(wa<S){
				dp[i + 1][wa] += dp[i][s];
				dp[i + 1][wa] %= P;
			}
		}
	}
	LL ans = 0;
	for (int i = 0; i <= N; ++i) {
		ans += dp[i][S];
		ans %= P;
	}
	cout << ans << endl;
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 70784
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;

using ld = long double;
ld L;

int main()
{
    cin >> L;
    ld a = L/((ld)3.0);
    ld ans = a*a*a;
    std::cout << std::fixed;
    std::cout << std::setprecision(7) << ans << endl;

    return 0;
}

Measured memory_bytes: 888
#include <cstdio>
#define ll long long
int n, a, b, h[100005];
bool ok(ll T)
{
	ll sum = 0;
	/*
	for (int i = 1; i <= n; i++) {
		ll L = 0, R = T;
		ll ret = -1;
		while (L <= R) {
			ll mid = (L + R) / 2;
			if ((ll)h[i] - mid*(ll)a - (T - mid)*(ll)b <= 0) {
				ret = mid, R = mid - 1;
			}
			else L = mid + 1;
		}
		if (ret == -1)return false;
		sum += ret;
	}
	*/
	for (int i = 1; i <= n; i++) {
		ll var = (h[i] - (ll)b*T);
		if (var <= 0)continue;
		var = (ll)(var + a - b - 1) / (ll)(a - b);
		sum += var;	
	}


	return (sum <= T);
}
ll find()
{
	ll L = 1, R = 1e10;
	ll ret = -1;
	while (L <= R) {
		ll mid = (L + R) / 2;
		if (ok(mid))ret = mid, R = mid - 1;
		else L = mid + 1;
	}
	return ret;
}
int main() {
	scanf("%d %d %d", &n, &a, &b);
	for (int i = 1; i <= n; i++)scanf("%d", &h[i]);
	ll ans = find();
	printf("%I64d", ans);
}

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

using namespace std;

int main(void){
  vector<int> data(3); 
  int i;
  for(i=0; i<3; i++)
    cin >> data[i];

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

  cout << data[2]-data[0] << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
	static final int MOD = (int)1e9+7;

	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			
			int sum = 1;
			
			while(true) {
				if(sum * a + 1 > d) break;
				sum++;
			}
			
			x+=sum;
		}
		
		out.println(x);
	}

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

	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}

	public static long factorial(int n) {
		long a;

		if(n > 0) {
			a = n * factorial(n - 1);
		}else{
			a = 1;
		}

		return a;
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(K key, V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

class UnionFind {
	int[] par;

	public UnionFind(int n) {
		par = new int[n];

		Arrays.fill(par, -1);
	}

	int root(int x) {
		if(par[x] < 0) return x;
		return par[x] = root(par[x]);
	}

	boolean unite(int x,int y) {
		x = root(x);
		y = root(y);

		if(x == y) return false;

		if(size(x) < size(y)) {
			int tmp = x;
			x = y;
			y = tmp;
		}

		par[x] += par[y];
		par[y] = x;

		return true;
	}

	boolean same(int x,int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}

	int size(int a) {
		return -par[root(a)];
	}
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 21204
def bi(x):
    o = [0]*4
    for i in range(4):
        o[i] = ['A',''][x % 2]
        x //= 2
    return o

S = input()
for i in range(64):
    o = bi(i)
    if S == ''.join([o[0],'KIH',o[1],'B',o[2],'R',o[3]]):
        print("YES")
        exit()

print("NO")

Measured memory_bytes: 3064
import static java.lang.Integer.parseInt;

public class Main {
    public static void main (String[] args) {
        String line = new java.util.Scanner ( System.in ).nextLine();
        String hour = watch (line);
        System.out.println(hour);
    }
    public static String watch(String line){
        int hour,min,second;
        second = parseInt(line);
        if (second < 0 || second > 86400) {
            System.out.println("Constraints Error");
            return null;
        }
        hour = second / 3600;
        min = (second % 3600 ) / 60;
        second = second % 60;
        
        return hour + ":" + min + ":" + second;
    }
}

Measured memory_bytes: 25992
module Main where

import Data.Functor
import Data.Maybe

main :: IO ()
main =  do
 { [n] <- getInts
 ; ns  <- getInts
 ; putStrLn $ unwords $ map show $ [minimum ns, maximum ns, sum ns]
 }

getInts :: IO [Int]
getInts = map read . words <$> getLine

Measured memory_bytes: 11208
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	int A,B,K;
	cin >> A >> B >> K;
	rep(i, K){
		if (i % 2 == 0) {
			A /= 2;
			B += A;
		}
		if (i % 2 == 1) {
			B /= 2;
			A += B;
		}
	}
	cout <<A << " " <<B ;
}

Measured memory_bytes: 256
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          (x).begin(),(x).end()
#define     rz(x)           resize(x)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=2e3+5;

int dp[N][N];
vector<pii> v;
int n;

int rec(int ind,int l)
{
    int r=n-((ind+1)-l);

    if(l>r)
        return 0;

    int& res=dp[ind][l];
    if(res!=-1)
        return res;

    res=max(v[ind].F*abs(v[ind].S-l)+rec(ind+1,l+1),v[ind].F*abs(v[ind].S-r)+rec(ind+1,l));

    //cout<<ind<<" "<<l<<" "<<r<<" "<<res<<"\n";

    return res;
}

void solve()
{
    mem(dp,-1);

    cin>>n;

    v.rz(n);
    for(int i=0;i<n;++i)
        cin>>v[i].F,v[i].S=i+1;

    sort(all(v));
    reverse(all(v));

    int ans=rec(0,1);
    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        //cout<<"Case #"<<z<<": ";
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 35216
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,A,B;
    cin>>n>>A>>B;
    string s;
    cin>>s;
    int count=0,countb=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='a' and count<A+B)
        {
         count++;
         cout<<"Yes"<<endl;
        }
        else if(s[i]=='b' and count<A+B and countb<B)
        {
         count++;
         countb++;
         cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
} 

Measured memory_bytes: 3688
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    /**
     * @param args
     * @throws IOException
     * @throws NumberFormatException
     */
    public static void main(String[] args) throws NumberFormatException,
            IOException {

         BufferedReader reader = new BufferedReader(new InputStreamReader(
         System.in));
         String arrStr = reader.readLine();
         StringTokenizer tokenizer = new StringTokenizer(arrStr, " ");

         int a = Integer.parseInt(tokenizer.nextToken());
         int b = Integer.parseInt(tokenizer.nextToken());

        System.out.println(gcd(a, b));
//        System.out.println(gcd(54, 20));
    }

    static int gcd(int m, int n) {
        
        int r;
        while((r = m % n) != 0){
            m = n;
            n = r;
        }
        return n;
    }

}

Measured memory_bytes: 9368
N = int(input())

c = [[0 for _ in range(9)] for _ in range(9)]
for i in range(1, 10):
  for j in range(1, 10):
    cnt = 0
    for n in range(1, N + 1):
      if n // (10 ** (len(str(n)) - 1)) == i and n % 10 == j:
        cnt += 1
    c[i - 1][j - 1] = cnt

ans = 0
for i in range(9):
  for j in range(9):
    ans += c[i][j] * c[j][i]
print(ans)

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

const int NIL = -1;

template <typename T> struct Node {
  T parent = NIL;
  T left = NIL;
  T right = NIL;
};

template <typename T>
void setDepth(std::vector<int> &d, const std::vector<Node<T>> &t, T u = 0,
              int depth = 0) {
  d.at(u) = depth;
  T left = t.at(u).left;
  T right = t.at(u).right;
  if (left != NIL)
    setDepth(d, t, left, depth + 1);
  if (right != NIL)
    setDepth(d, t, right, depth + 1);
}

template <typename T>
int setHeight(std::vector<int> &h, const std::vector<Node<T>> &t, T u = 0) {
  int h1 = 0, h2 = 0;
  T left = t.at(u).left;
  T right = t.at(u).right;
  if (left != NIL)
    h1 += setHeight(h, t, left) + 1;
  if (right != NIL)
    h2 += setHeight(h, t, right) + 1;
  return h.at(u) = std::max(h1, h2);
}

template <typename T> T getRoot(const std::vector<Node<T>> &t) {
  for (std::size_t i = 0; i < t.size(); ++i) {
    if (t.at(i).parent == NIL)
      return i;
  }
  return NIL;
}

template <typename T> int countDegree(const std::vector<Node<T>> &t, T u) {
  return (t.at(u).left != NIL) + (t.at(u).right != NIL);
}

template <typename T> T getSibling(const std::vector<Node<T>> &t, T u) {
  if (t.at(u).parent == NIL)
    return NIL;
  auto parent = t.at(t.at(u).parent);
  return (parent.left == u) ? parent.right : parent.left;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<Node<int>> t(n, Node<int>{});
  int u, l, r;
  for (int i = 0; i < n; ++i) {
    std::cin >> u >> l >> r;
    t.at(u).left = l;
    t.at(u).right = r;
    if (l != NIL)
      t.at(l).parent = u;
    if (r != NIL)
      t.at(r).parent = u;
  }

  auto root = getRoot(t);
  std::vector<int> d(n, 0), h(n, 0);
  setDepth(d, t, root);
  setHeight(h, t, root);

  for (int i = 0; i < n; ++i) {
    std::cout << "node " << i << ": parent = " << t.at(i).parent
              << ", sibling = " << getSibling<int>(t, i)
              << ", degree = " << countDegree(t, i) << ", depth = " << d.at(i)
              << ", height = " << h.at(i) << ", ";
    if (t.at(i).parent == NIL)
      std::cout << "root";
    else if (t.at(i).left == NIL && t.at(i).right == NIL)
      std::cout << "leaf";
    else
      std::cout << "internal node";
    std::cout << std::endl;
  }
}



Measured memory_bytes: 3092
#include <stdio.h>
#include <stdlib.h>

static int n;

main()
{
  int i;
  
  scanf("%d", &n);
  printf("%d:", n);
  for (i = 2; i * i <= n; ) {
    if (n % i == 0) {
      printf(" %d", i);
      n /= i;
    } else {
      ++i;
    }
  }
  printf(" %d\n", n);
  
  return EXIT_SUCCESS;
}

Measured memory_bytes: 596
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
void f(string &s){
	vector<int> a(27,0);
	rep(i,s.size()){
		a[(s[i]-'a')]+=1;
	}
	int head=0;
	rep(i,27){
		rep(j,a[i]) {
			s[head]='a'+i;
			head++;
		}
	}
	return;
}
int main(){
	int n;
	cin>>n;
	vector<string>s(n);
	rep(i,n)cin>>s[i];
	rep(i,n)f(s[i]);
	sort(s.begin(),s.end());
	//rep(i,n)cout<<s[i]<<endl;

	long long int cnt=0,sum=0;
	rep(i,n-1){
		if(s[i]==s[i+1])cnt++;
		else if(cnt>0){
			sum+=cnt*(cnt+1)/2;
			cnt=0;
		}
	}
	sum+=cnt*(cnt+1)/2;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 7296
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

//gcdやり直す

void swap (int *x, int *y) {
  int temp;    

  temp = *x;
  *x = *y;
  *y = temp;
}




/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}




/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  long int l,r;
  scanf("%ld%ld",&l,&r);
  if(r-l>=2019){
    printf("0\n");
    return 0;
  }
  l%=2019;
  r%=2019;

  if(r<l){
    int a=l;
    l=r;
    r=a;
  }


  int i,j;
  int ans=2020;
  for(i=l;i<r;i++){
    for(j=i+1;j<=r;j++){
      int a=(i*j)%2019;

      if(a<ans){
        ans=a;
      }
    }
  }

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

  return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<db> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[] = { -1,-2,1,-2,2,-1,2,1 }, ddy[] = { -2,-1,-2,1,-1,2,1,2 };

int a[200001],ne[200001][18],pr[200001][18];
ll Ls[200001][18],Rs[200001][18];
int main() {
	int n,k;
	scanf("%d%d",&n,&k);
	fup(i,1,n,1)scanf("%d",a+i);
	int t=1;
	fup(i,1,n,1){
		while(t<=n && a[t]-a[i]<k)t++;
		ne[i][0]=t;
	}
	t=n;
	fdn(i,n,1,1){
		while(t>=0 && a[i]-a[t]<k)t--;
		pr[i][0]=t;
	}
	fup(j,0,16,1){
		fup(i,1,n,1){
			if(ne[i][j]<=n)ne[i][j+1]=ne[ne[i][j]][j];
			if(pr[i][j]>0)pr[i][j+1]=pr[pr[i][j]][j];
		}
	}
	fup(i,1,n,1){
		Ls[i][0]=-(i-1);
		Rs[i][0]=i;
	}
	fup(j,0,16,1){
		fup(i,1,n,1){
			if(ne[i][j]<=n)Ls[i][j+1]=Ls[i][j]+Ls[ne[i][j]][j];
			if(pr[i][j]>0)Rs[i][j+1]=Rs[i][j]+Rs[pr[i][j]][j];
		}
	}
	int q;
	scanf("%d",&q);
	while(q--){
		int l,r;
		scanf("%d%d",&l,&r);
		int now=l;
		int cnt=0;
		fdn(j,17,0,1){
			if(ne[now][j]>0 && ne[now][j]<=r){
				cnt+=1<<j;
				now=ne[now][j];
			}
		}
		cnt++;
		ll ans=0;
		fdn(j,17,0,1){
			if(cnt&(1<<j)){
				ans+=Ls[l][j]+Rs[r][j];
				l=ne[l][j],r=pr[r][j];
			}
		}
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 88952
/**
 * SortingThreeNumbers.cpp
 * Create:20180417
 * Description:三つの数値a,b,cを読み込み、
 * 値が小さい順番に並べて出力する
 */
#include <iostream>

int main(int argc, char* argv[]){
  int size = 3;
  int array[size];

  std::cin >> array[0] >> array[1] >> array[2];

  for(int i = 0; i < size; i++){
    for(int j = 0; j < size - 1; j++){
      if(array[j] > array[j + 1]){
        int tmp = array[j];
        array[j] = array[j + 1];
        array[j + 1] = tmp;
      }
    }
  }

  std::cout << array[0] << " " << array[1] << " " << array[2] << std::endl;

  return 0;
}



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

using namespace std;
 
int N, K;
vector<int> d;
vector<vector<int>> A;

int main() {
  // N すぬけの種類
  // K お菓子の種類
  cin >> N >> K;
  
  d.resize(K); 
  A.resize(K, vector<int>()); 
  
  for(int i = 0; i < K; i++) {
    cin >> d[i]; //お菓子をもってるすぬけの合計人数
    A[i].resize(d[i]);
    
    for(int j = 0; j < d[i]; j++) {
      cin >> A[i][j];//すぬけID
    }
  }
  
  int a = 0;
  for(int i = 1; i <= N; i++) {// お菓子の種類文loop
    bool have = false;
    for(auto v : A) {
      for(auto p : v) {
        if(p == i) have = true;
      }
    }
    if(!have) a++;
  }
  cout << a << endl;
}

Measured memory_bytes: 3612
#include <iostream>  
#include <cstdio>  
#include <cstring>  
#include <algorithm>  
  
using namespace std;  
const int maxn=2e5+100;  
int par[maxn],sum[maxn];  
int N,K,p,tot;  
  
void init(int n)  
{  
    for(int i=0;i<=n;i++)  
        par[i]=i;  
}  
  
int find(int x)  
{  
    if(par[x]==x)  
        return x;  
    return par[x]=find(par[x]);  
}  
void unit(int a,int b)  
{  
    int fx=find(a),fy=find(b);  
    if(fx!=fy)  
        par[fx]=fy;  
}  
bool same(int x,int y)  
{  
    return find(x)==find(y);  
}  
int main()  
{  
    while(~scanf("%d%d",&N,&K))  
    {  
        int ans=0;  
        memset(sum,0,sizeof(sum));  
        memset(par,0,sizeof(par));  
        tot=0;  
        init(N);  
        int t;  
        scanf("%d",&t);  
        sum[t]++;  
        p=t;  
        tot++;  
        for(int i=2;i<=N;i++)  
        {  
            scanf("%d",&t);  
            sum[t]++;  
            if(!same(t,p))  
            {  
                tot++;  
                unit(t,p);  
            }  
        }  
        sort(sum,sum+N+1);  
        if(tot<=K)  
            ans=0;  
        else  
        {  
            int cnt=tot-K;  
            int pos=lower_bound(sum,sum+N+1,1)-sum;  
            while(cnt--)  
                ans+=sum[pos++];         
        }  
        printf("%d\n",ans);  
    }  
    return 0;  
}  

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

#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
typedef long long ll;

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

  vector<int> LW(n+1,0); //i番目より左にいる人でWestを向いている人
  vector<int> RE(n+1,0); //i番目より右にいる人でEastを向いている人

  for (int i=1; i<=n-1; i++){
    if (str[i-1] == 'W') LW[i] = LW[i-1] + 1;
    else LW[i] = LW[i-1];
  }
  for (int i=n-2; i>=0; i--){
    if (str[i+1] == 'E') RE[i] = RE[i+1] + 1;
    else RE[i] = RE[i+1];
  }
  long long res = 100000000000;
  rep(i,n){
    if (LW[i]+RE[i] < res) res = LW[i]+RE[i];
  }
  cout << res << endl;
  return 0;
}


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

#define _ cin.tie(0);ios::sync_with_stdio(false);
using namespace std;
using LL = long long;
const int N = 100000 + 5;

LL tree[N << 1];
LL read(int k){
    LL sum = 0;
    while(k){
        sum+=tree[k];
        k-= k&-k;
    }
    return sum;
}

void add(int k,LL num){
    while(k<=N){
        tree[k]+=num;
        k+=k&-k;
    }
}
vector<LL> a, b, c;
int main(){ _
    LL  n, m;
    memset(tree, 0, sizeof(tree));
    cin >> n;
    for(int i = 0; i < n; i++) { cin >> m; a.push_back(m); }
    for(int i = 0; i < n; i++) { cin >> m; b.push_back(m); }
    for(int i = 0; i < n; i++) { cin >> m; c.push_back(m); }
    sort(a.begin(), a.end()); sort(b.begin(), b.end()); sort(c.begin(), c.end());

    for(int i = 0; i < n; i++){
        auto tmp = lower_bound(a.begin(), a.end(), b[i]);
        int num = tmp - a.begin();
        add(i + 1, num);

    }
    LL sum = 0;
    for(auto &i : c){
        auto tmp = lower_bound(b.begin(), b.end(), i);
        int cur = tmp - b.begin();
        LL num = read(cur);
        sum += num;
    }
    cout << sum << endl;
}


Measured memory_bytes: 4980
#include<iostream>
#include<cstring>
using namespace std;
int road[60];
int main(){
	int a,b;
	cin>>a>>b;
	int roada,roadb;
	memset(road,0,sizeof(road));
	for(int i=0;i<b;i++){
		cin>>roada>>roadb;
		road[roada]++;
		road[roadb]++;
	}
	for(int i=1;i<=a;i++){
			cout<<road[i]<<endl;
		
	}
}


Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
$vArray = explode(" ", trim(fgets(STDIN)));

$divmax = $vArray[0];
foreach($vArray as $i => $v){
    $dArray = divisor($v, $divmax);
    foreach($dArray as $d){
        @$map[$d]++;
    }
    $tmpmax = 0;
    foreach($map as $k => $c){
        if($c > $i - 1){
            $tmpmax = max($tmpmax, $k);
        }
    }
    $divmax = $tmpmax;
}
$max = 1;
foreach($map as $value => $count){
    if($count >= $n - 1){
        $max = max($max, $value);
    }
}
echo $max;

function divisor($n, $divmax){
    if(!isset($GLOBALS["cache"][$n])){
        for($i = min(ceil(sqrt($n)), $divmax); $i >= 1; $i--){
            if($n % $i == 0){
                $f[] = $i;
                $f[] = $n / $i;
            }
        }
        sort($f);
        $GLOBALS["cache"][$n] = array_unique($f);
    }
    return $GLOBALS["cache"][$n];
}

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    li n,k;

    cin>>n>>k;

    li a[n];

    f(i,0,n-1)
    {
        cin>>a[i];
    }

    sort(a,a+n);

    li ans=0;

    f(i,0,k-1)
    {
        ans+=a[i];
    }

    cout<<ans;
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3660
// E - Sequence Sum
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

int main(){
	ll n; int x, m; cin>>n>>x>>m;
	int mn = min(n, (ll)m);
	vector<int> P; // value of pre & cycle
	ll sum_p = 0; // sum of pre + cycle
	vector<int> X(m, -1); // for cycle check & pre_len
	while(mn--){
		if(X[x] > -1){
			int pre_len = X[x];
			int cyc_len = P.size() - pre_len;
			int nxt_len = (n - pre_len) % cyc_len;
			ll pre = 0; rp(i, 0, pre_len) pre += P[i];
			ll nxt = 0; rp(i, pre_len, pre_len + nxt_len) nxt += P[i];
			ll cyc = (sum_p - pre) * ((n - pre_len) / cyc_len);
			cout<< pre + cyc + nxt <<endl;
			return 0;
		}
		X[x] = P.size();
		P.push_back(x);
		sum_p += x;
		x = (ll)x*x % m;
	}
	cout<< sum_p <<endl;
}


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

int main() {
	string s;
    cin >> s;
    int sum;
    for(char c = 'a'; c < 'z'; c++){
      int count = 0;
      for(int i = 0; i < s.size(); i++){
        if(s.at(i) == c){
          count++;
        }
      }
      if(count%2 == 1){
        sum++;
      }
    }
    if(sum == 0){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
}


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

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a + b == 15) printf("+\n");
    else if (a * b == 15) printf("*\n");
    else printf("x\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;

using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

//A 65
//a 97
//pairの比較関数(昇順)
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
//降順
bool compare_by_b_high(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
  ll tmp;cin>>tmp;
  ll zatu=pow(tmp,0.5);
  ll min=100000000;

  for(ll i=1;i<=zatu;i++){
    ll t=0;
    if(tmp%i==0){
      t=tmp/i;
      t=to_string(t).length();
      if(t<min){
        min=t;
      }
    }
  }
  cout<<min<<endl;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};

int main(void){
    int H,N;
    cin >> H >> N;
    int A[N],B[N];
    rep(i,N) cin >> A[i] >> B[i];
    int dp[H+10000];
    rep(i,H+10000) dp[i]=INF;
    dp[0]=0;
    rep(i,H) rep(j,N) dp[i+A[j]]=min(dp[i+A[j]],dp[i]+B[j]);
    int ans=INF;
    for(int i=H;i<H+10000;i++) ans=min(ans,dp[i]);
    cout << ans << endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N;
    cin >> N;
    int L[N];
    cins(L, L + N);
    vector<int> sum(3000, 0);
    for(int i = 0; i < N; i++){
        sum[L[i] + 1]++;
    }
    for(int i = 1; i < 3000; i++){
        sum[i] += sum[i - 1];
    }
    lint ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(i == j){
                continue;
            }
            int a = L[i], b = L[j];
            int left = abs(a - b), right = a + b;
            ans += sum[right] - sum[left + 1];
            if(left < a && a < right){
                ans--;
            }
            if(left < b && b < right){
                ans--;
            }
        }
    }
    cout << ans / 6 << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{   
    int n;
    ll y;
    cin >> n >> y;

    int ansI = -1, ansJ = -1, ansK = -1;
    rep(i, n+1) rep(j, n+1) {
        int k = n-i-j;
        if(k < 0) continue;
        if(10000*i+5000*j+1000*k == y) {
            ansI = i, ansJ = j, ansK = k;
        }
    }

    cout << ansI << " " << ansJ << " " << ansK << endl;

    return 0;
}


Measured memory_bytes: 3628
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        s: chars, t: chars,
    }
    for i in 0..n {
        puts!("{}{}", s[i], t[i]);
    }
    puts!("\n");
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

bool is753(string s){
  int a=0,b=0,c=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='3')a++;
    if(s[i]=='5')b++;
    if(s[i]=='7')c++;
  }
  if(a>0 && b>0 && c>0)return 1;
  else return 0;
}

int main(){
  int i,j,cnt=0;
  const int M=19683;
  int n;
  cin>>n;
  string a[7*M];
  for(i=0;i<M;i++)a[i]="";
  for(int k=0;k<7;k++){
    for(i=k*M;i<k*M+M;i++){
      for(j=0;j<9-k;j++){
        int p=(i/(int)round(pow(3,j)))%3;
        if(p==0)a[i]+='3';
        if(p==1)a[i]+='5';
        if(p==2)a[i]+='7';
      }
    }
  }
  sort(a,a+7*M);
  string b[4*M];
  for(i=1;i<7*M;i++){
    if(a[i-1]!=a[i])b[cnt++]=a[i];
  }
  int m=cnt;cnt=0;
  string c[m];
  for(i=0;i<m;i++){
    if(is753(b[i]))c[cnt++]=b[i];
  }
  m=cnt;cnt=0;
  int d[m];
  for(i=0;i<m;i++)d[i]=stoi(c[i]);
  sort(d,d+m);
  for(i=0;i<m;i++){
    if(d[i]>n)break;
    cnt++;
  }
  cout<<cnt;
}

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

#define rep(x, y) for (int i = (x); i < (y); i++)

typedef long long ll;

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;

    vector<int> digits;
    while (0 < n) {
        digits.push_back(n % k);
        n = n / k;
    }

    cout << digits.size() << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	as, err := nextInts(n, sc)
	if err != nil {
		panic(err)
	}
	q, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	ms, err := nextInts(q, sc)
	if err != nil {
		panic(err)
	}
	for _, v := range ms {
		if exhaustiveSearch(v, as) {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}
}

func exhaustiveSearch(x int, elements []int) bool {
	return solve(x, 0, elements)
}

func solve(target int, index int, elements []int) bool {
	if target == 0 {
		return true
	} else if target < 0 || index >= len(elements) {
		return false
	} else {
		return solve(target-elements[index], index+1, elements) ||
			solve(target, index+1, elements)
	}
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

func nextInts(n int, sc *bufio.Scanner) ([]int, error) {
	rs := make([]int, n)
	for i, _ := range rs {
		x, err := nextInt(sc)
		if err != nil {
			return nil, err
		}
		rs[i] = x
	}
	return rs, nil
}



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

int main() {
  int h,w;
  cin>>h>>w;
  vector<vector<char>> vec(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>vec[i][j];
    }
  }
  vector<bool> row(h,false);
  vector<bool> col(w,false);
    for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(vec[i][j]=='#'){
        row[i]=true;
        col[j]=true;
      }
    }
    }
  for(int i=0;i<h;i++){
    if(row[i]){
    for(int j=0;j<w;j++){
     if(col[j])cout<<vec[i][j];
    }
      cout<<endl;
    }
  }
}

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

using namespace std;

int main() {
  ll l, r, mi = INT_MAX;
  cin >> l >> r;
  if(r - l >= 2018)
    cout << 0 << endl;
  else {
    for(ll i = l; i <= r - 1; i++)
      for(ll j = i + 1; j <= r; j++)
        mi = min(mi, i % 2019 * j % 2019);
    cout << mi << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fir first
#define sec second
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int n , t , a;
	cin >> n >> t >> a;

	int h[n];
	rep(i,0,n) cin >> h[i];

	double ans = INF;
	int idx;
	rep(i,0,n){
		double num = abs( (t - h[i] * 0.006) - a );
		if(num < ans ){
			ans = num;
			idx = i + 1;
		}
	}

	cout << idx << endl;
	ret 0;
}

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

main(){

  ll n,m;
  cin>>n>>m;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  vector<ll> b(m),c(m);
  rep(i,m)cin>>b[i]>>c[i];

  priority_queue<pair<ll,ll>> que;
  rep(i,n)que.emplace(a[i],1);
  rep(i,m)que.emplace(c[i],b[i]);

  ll sum=0,card=0;
  while(card<n){
    ll val,num;
    tie(val,num)=que.top();
    que.pop();
    if(card+num<n){
      sum+=val*num;
      card+=num;
    }
    else{
      while(card<n){
        sum+=val;
        card++;
      }
    }
  }
  cout<<(sum)<<endl;


}


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

# In[14]:


from collections import deque


# In[21]:


S = deque(input())
Q = int(input())
rev_cnt = 0
for _ in range(Q):
    q = input().split()
    if len(q) == 1:
        rev_cnt += 1
    else:
        if (rev_cnt+int(q[1]))%2 == 0:
            S.append(q[2])
        else:
            S.appendleft(q[2])
if rev_cnt%2 == 0:
    print("".join(S))
else:
    print("".join(list(reversed(S))))    


# In[ ]:






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

int main() {
    int n;
    cin >> n;
    vector<int> v;
    int max=0;
    int max2=0;
    REP(i,n){
        int a;
        cin >> a;
        v.push_back(a);
        if(a>max2){
            max2=a;
        }
        if(a>max){
            max2=max;
            max=a;
        }
    }
    REP(i,n){
        if(v[i]==max){
            cout << max2 << endl;;
        }
        else{
            cout << max << endl;
        }
    }
}


Measured memory_bytes: 2548
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

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

	ll n, m;
	cin >> n >> m;

	ll ans = 1;

	if (abs(n - m) >= 2) {
		cout << 0 << endl;
		return 0;
	}

	// 基本 n! * m!
	Rep(i, 1, n + 1) {
		ans *= i;
		ans %= mod;
	}
	Rep(j, 1, m + 1) {
		ans *= j;
		ans %= mod;
	}

	if (n == m) {
		ans *= 2;
		ans %= mod;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn is_ok(n: usize, k: usize, a: &Vec<usize>, i_s: usize) -> bool {
    let a_s = a[i_s];
    let mut dp = vec![vec![false; k]; n];
    dp[0][0] = true;
    for i in 0..n {
        if i == i_s {
            continue;
        }
        let a_i = a[i];
        let i = if i > i_s { i - 1 } else { i };
        for j in 0..k {
            dp[i + 1][j] |= dp[i][j];
            if j + a_i < k {
                dp[i + 1][j + a_i] |= dp[i][j];
            }
        }
    }
    !dp[n - 1][k.saturating_sub(a_s)..k].iter().any(|&b_i| b_i)
}

fn main() {
    input! {
        n: usize,
        k: usize,
        mut a: [usize; n],
    };
    a.sort();
    let mut l = 0;
    let mut r = n;
    while r - l > 1 {
        let m = l + (r - l) / 2;
        if is_ok(n, k, &a, m) {
            l = m;
        } else {
            r = m;
        }
    }
    if is_ok(n, k, &a, 0) {
        let ans = l + 1;
        println!("{}", ans);
    } else {
        println!("{}", 0);
    }
}


Measured memory_bytes: 26568
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main () {
  long long N;
  cin>>N;
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
  cin >> v.at(i);
}
  sort (all (v));
	double ans = v.at(0);
  int i;
  rep(i, N-1) {
    ans = (ans+v[i+1])/2;
  }
cout<<ans<<endl; 
 return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;

const int INF = 1001001001;
const ll MOD = 1e9 + 7;

using namespace std;
using P = pair<int,int>;

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

int main() {
  ll r, g, b, n;
  cin >> r >> g >> b >> n;

  ll sum = 0; ll count = 0;
  rep(i, 3001) {
      rep(j, 3001) {
          ll rem = r*i + g*j;
          if (n >= rem && (n-rem)%b == 0) count++;
            //   cout << i << " " << j << " " << n-i-j << " " << endl;
      }
  }

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256