akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
ll minn(ll x, ll y){
    if(x<y)
        return x;
    return y;
}
ll maxx(ll x, ll y){
    if(x>y)
        return x;
    return y;
}
double p[3009],a[3009][3009],ans=0.0; 
int main() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>p[i];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=i;j++){
            if(i==0)
                a[i][j] = 1;
            else if(j==0){
                a[i][j] = a[i-1][j] * (1 - p[i]);
            }
            else{
                a[i][j] = (a[i-1][j] * (1 - p[i])) + (a[i-1][j-1] * p[i]);
            }
            // cout<<a[i][j]<<" ";
        }
        // cout<<endl;
    }
    for(int i=(n+1)/2;i<=n;i++)
        ans+=a[n][i];
    printf("%.10lf",ans);
}


Measured memory_bytes: 69120
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
typedef pair<int,int>P;
#define F first
#define S second
int n,m,a1,a2,a3;
int par[10001];
int rak[10001];
void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    rak[i]=1;
  }
}
int find(int x){
  if(par[x]==x){
    return x;
  }else{
    return par[x]=find(par[x]);
  }
}
void unit(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y)return;
  if(rak[x]<rak[y]){
    par[x]=y;
  }else{
    par[y]=x;
    if(rak[x]==rak[y])rak[x]++;
  }
}
bool same(int x,int y){
  return find(x)==find(y);
}
struct edge{int u,v,cost;};
bool comp(const edge& e1,const edge& e2){
  return e1.cost<e2.cost;
}
edge es[100001],e;
int ans;
vector<edge>v;
int V,E;
int kruskal(){
  sort(es,es+E,comp);
  init(V);
  int res=0;
  for(int i=0;i<E;i++){
    edge e=es[i];
    if(!same(e.u,e.v)){
      unit(e.u,e.v);
      v.push_back(e);
      res+=e.cost;
    }
  }
  ans=res;
  return res;
}
int kruskal2(edge now){
  sort(es,es+E,comp);
  init(V);
  int res=0,res1=0;
  for(int i=0;i<E;i++){
    edge e=es[i];
    if(e.v==now.v&&e.u==now.u&&e.cost==now.cost)continue;
    if(!same(e.u,e.v)){
      unit(e.u,e.v);
      res++;
      res1+=e.cost;
    }
  }
  return res!=n-1||ans!=res1;
}
int main(){
  int ans1=0,ans2=0;
  cin>>n>>m;
  r(i,m){
    cin>>a1>>a2>>a3;
    e.u=a1,e.v=a2,e.cost=a3;
    es[i]=e;
  }
  E=m;V=n+1;
  kruskal();
  r(i,v.size()){
    if(kruskal2(v[i])){
      //cout<<v[i].u<<endl;
      ans1++;
      ans2+=v[i].cost;
    }
  }
  cout<<ans1<<' '<<ans2<<endl;
}

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

using namespace std;

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

  vector<long long> a(n);
  for(int i=0; i<n; i++) cin >> a[i];

  long long money = 1000;
  for(int i=1; i<n; i++){
    long long stock = 0;
    if(a[i] > a[i-1]) stock = money / (a[i-1]);
    money += stock * (a[i] - a[i-1]);
  }

  cout << money << '\n';

  return 0;
}


Measured memory_bytes: 3192
#include <iostream>

using namespace std;
long long gcd(long long a,long long b)
{
    return b==0?a:gcd(b,a%b);
}
int main()
{
    long long a,b;
    cin>>a>>b;
    cout<<a*b/gcd(a,b)<<endl;;
    return 0;
}


Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll n,q;
  cin >> n >> q;

  string s;
  cin >> s;

  vector<ll> a(n+1,0);

  for(int i = 1;i<n;i++)
  {
    if(s[i-1] == 'A' && s[i] == 'C')
    {
      a[i+1] = a[i] + 1;
    }
    else
    {
      a[i+1] = a[i];
    }
    
  }

  rep(i,q)
  {
    ll l,r;
    cin >> l >> r;
    cout << a[r] - a[l] << endl;
  }

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 1792
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

splitCount n [] = []
splitCount n xs = let (x,y) = splitAt n xs in x : splitCount n y

f t s = or [any (isInfixOf t) (transpose $ splitCount i s) | i <- [1 .. length s]]

main = do
    n <- getInt
    s <- getLine
    replicateM n getLine >>= print . length . filter (f s)

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

int main(){
  long long n,a,b;
  cin >> n >> a >> b;
  
  long long ans = 0;
  
  ans += ( n/(a+b) ) * a;
  n %= a+b;
  
  ans += min(a, n);
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int N;
    string S;
    cin >> N >> S;

    int left = 0,right = 0;

    for(int i=0;i<N;i++){
        if(S[i] == 'W'){
            left++;
        }
        else{
            right++;
        }
    }

    ll ans = 4000000;
    int tmp;    
    int n_l = 0;

    for(int i=0;i<N;i++){
        if (S[i] == 'E')
        {
            right--;
        }

        tmp = n_l + right;

        if (ans > tmp)
            ans = tmp;

        if(S[i] == 'W'){
            n_l++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 900
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 10 11:20:10 2020

@author: liang
"""

N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

ans = 0
for i in range(N):
    ans += min(B[i], A[i]+A[i+1])
    if B[i] > A[i]:
        A[i+1] -= B[i] - A[i]
    if A[i+1] < 0:
        A[i+1] = 0
print(ans)

Measured memory_bytes: 24084
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner stdIn = new Scanner(System.in);

        for (int i = 1;; i++) {
            int x = stdIn.nextInt();
            if (x == 0) {
                break;
            }
            System.out.printf("Case %d: %d\n", i, x);
        }
    }
}


Measured memory_bytes: 66088
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		Team[] teams = new Team[n];
		for (int i = 0; i < n; i++)
			teams[i] = new Team(i, 0);
		for (int i = 0; i < n * (n - 1) / 2; i++) {
			int a = scanner.nextInt() - 1;
			int b = scanner.nextInt() - 1;
			int c = scanner.nextInt();
			int d = scanner.nextInt();
			if (c > d)
				teams[a].ten += 3;
			else if (c < d)
				teams[b].ten += 3;
			else {
				teams[a].ten++;
				teams[b].ten++;
			}
		}
		Arrays.sort(teams);
		int[] rank = new int[n];
		rank[teams[0].name] = 1;
		int r = 0;
		for (int i = 1; i < n; i++) {
			if (teams[i].ten == teams[i - 1].ten)
				r++;
			else
				r = 0;
			rank[teams[i].name] = i - r + 1;
		}
		for (int ans : rank)
			System.out.println(ans);
	}

	class Team implements Comparable<Team> {
		int name, ten;

		public Team(int name, int ten) {
			super();
			this.name = name;
			this.ten = ten;
		}

		@Override
		public int compareTo(Team o) {
			return o.ten - ten;
		}

	}
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) {
    cin >> s.at(i);
  }
  int ab = 0;
  int firstB = 0;
  int lastA = 0;
  int bothAb = 0;
  for (string ss : s) {
    bool f = (ss.front() == 'B');
    bool l = (ss.back() == 'A');
    if (f) {
      firstB++;
    }
    if (l) {
      lastA++;
    }
    if (f && l) {
      bothAb++;
    }
    for (int i = 0; i < ss.size() - 1; i++) {
      if (ss.substr(i, 2) == "AB") {
        ab++;
      }
    }
  }

  int edge = min(firstB, lastA);
  if (firstB > 0 && firstB == lastA && firstB == bothAb) {
    edge--;
  }
  int res = ab + edge;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int32_t main()
{
	IOS;
	int a, b;
	cin >> a >> b;
	for(int i = 1; i <= 1e5; i++)
	{
		if((i * 8) / 100 == a && (i * 10) / 100 == b)
		{
			cout << i;
			return 0;
		}
	}
	cout << -1;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
	#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	#define lli long long int
	#define ulli unsigned long long int
	#define ff first
	#define ss second
	#define mp make_pair
	#define pb push_back
	#define pf pop_front()
	#define lb lower_bound
	#define ub upper_bound
	#define bs binary_search
	#define loop(i,a,b) for(lli i=a;i<b;i++)
	#define loopi(i,a,b) for(int i=a;i<b;i++)
	#define all(v) v.begin(), v.end()
	#define mod 1000000007
	#define inf 100000000000000000
	#define lld long double
	#define pll pair<long long int,long long int>
	#define pii pair<int,int>
	#define vll vector<lli>
	#define vii vector<int>
	#define endl '\n'
	#define setp(k, x) fixed << setprecision(k) << (x)
	#define deb(x) cerr << #x << ": " << x << " " << endl;
	#define debug(x) cout << "m here-" <<#x<<" ..."<<"\n";
	#define printa(a,n) for(lli i=0;i<n;i++) cout<<a[i]<<" "; cout<<"\n";
  #define printv(a) for(lli i=0;i<a.size();i++) cout<<a[i]<<" "; cout<<"\n";
	bool sortcol( const vector<lli>& v1, const vector<lli>& v2 ) //sort on basis of column //use- sort(vect.begin(), vect.end(),sortcol);
      { return v1[1] < v2[1]; }//[] o based indexing in column
	bool sortpair(const pair<lli, lli> &a, const pair<lli, lli> &b)
			{return a.second < b.second;}
	struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

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


int main ()
{
	// fastio
 	// lli  t;
 	// cin>>t;
 	// while(t--)
 	{
		lli n,i,d,a,b,c=0,j,k;
    cin>>k;
    cin>>a>>b;
    for(i=a;i<=b;i++)
      {
        if(i%k==0)
          {
            c=1;
            break;
          }
      }
      if(c==1)
        cout<<"OK\n";

    else
      cout<<"NG\n";



 	}
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

signed main(){
  int n;
  cin >> n;
  vector<int> v1(n/2),v2(n/2);
  set<int> s1,s2;
  FOR(i,0,n){
    if(i%2){
      cin >> v1[i/2];
      s1.insert(v1[i/2]);
    }
    else{
      cin >> v2[i/2];
      s2.insert(v2[i/2]);
    }
  }
  sort(ALL(v1));
  sort(ALL(v2));
  vector<int> num1,num2;
  for(auto x:s1)num1.pb(COUNT(v1,x));
  for(auto x:s2)num2.pb(COUNT(v2,x));
  sort(ALL(num1),greater<int>());
  sort(ALL(num2),greater<int>());
  num1.pb(0);
  num2.pb(0);
  ll MAX1,MAX2;
  for(auto x:s1)if(COUNT(v1,x) == num1[0])MAX1=x;
  for(auto x:s2)if(COUNT(v2,x) == num2[0])MAX2=x;
  debug(MAX1);
  debug(MAX2);
  if(MAX1==MAX2){
    cout << n-(max(num1[0]+num2[1],num1[1]+num2[0])) << endl;
    return 0;
  }
  else{
    cout << n-(num1[0]+num2[0]) << endl;
  }
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//is_prime
bool is_prime(long long n){
    for(int i = 2; i * i <= n; i++)
        if(n % i == 0) return false;
    return true;
}

//Prime_Factorization
vector<pair<long long, ll> > prime_fact(long long n){
    vector<pair<long long, ll> > p;
    long long m = n;
    for(long long i = 2; i * i <= n; i++){
        if(m % i !=0) continue;
        int c = 0;
        while(m % i == 0) c++, m /= i;
        p.push_back(make_pair(i, c));
    }
    if(m > 1) p.push_back(make_pair(m, 1));
    return p;
}
//Power
long long powmod(long long px, long long py, long long pmod){
	if(py == 0) return 1;
	if(py % 2 == 0) return powmod((px * px) % pmod, py / 2, pmod);
	else return (px * powmod(px, py - 1, pmod)) % pmod;
} 
//Extended_GCD
long long extgcd(long long a, long long b, long long &x, long long &y){
	long long gcd_ = a;
	if (b != 0){
		gcd_ = extgcd(b, a % b, y ,x);
		y -= (a/b) * x;
	} else {
   		x = 1;
   		y = 0;
   	}
   	return gcd_;
}
//Inverse
long long inv(long long a, long long b){
   	long long x, y;
   	extgcd(a, b, x, y);
   	if(x >= 0) return x % b;
   	else return (b - (-x) % b) % b;
}
int main() {
    // your code goes here
    ll n,a[10005],i,j,mod=1e9+7,m,x,y=0,ans=1;
    ll pf[1000005]={0};
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
        if(a[i]==1) continue;
        vector<pair<ll,ll>> pfm=prime_fact(a[i]);
        for(j=0;j<pfm.size();j++){
            m=pfm[j].first; x=pfm[j].second;
            pf[m]=max(pf[m],x);
        }
    }
    for(i=2;i<1000000;i++){
        if(pf[i]==0) continue;
        ans=(ans*powmod(i,pf[i],mod))%mod;
    }
    for(i=0;i<n;i++){
        x=inv(a[i],mod);
        y=(y+x)%mod;
    }
    ans=(ans*y)%mod;
    cout << ans << endl;
    return 0;
}

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

int main(){

	char c[4];

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

	if((c[0] == c[1] && c[1] == c[2]) || (c[1] == c[2] && c[2] == c[3]))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;

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

	int x, y;
	cin >> x >> y;

	int ans = max(4 - x, 0) * 100000 + max(4 - y, 0) * 100000 ;
	if(x == 1 && y == 1) ans += 400000;

	cout << ans << endl;	
}


Measured memory_bytes: 256
package main

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

// Scane Standard Input
var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {

	for {
		s := nextLine()
		// 0だったら処理しない
		if s == "0" {
			break
		}

		// 1文字ずつに分解
		result := 0
		for _, ss := range s {
			i, _ := strconv.Atoi(string(ss))
			result = result + i
		}

		fmt.Println(strconv.Itoa(result))
	}
}



Measured memory_bytes: 1088
n = gets.to_i
ary = []
n.times { ary << gets.chomp }

result = {}
ary.each do |a|
  result[a] = 0 if result[a].nil?
  result[a] += 1
end

group = result.group_by{|k,v| v}

group.max[1].to_h.keys.sort.each do |v|
  puts v
end


Measured memory_bytes: 61432
#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 ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin >> a >> b >> c;
  if (a+b+c<=21){
    cout << "win" << endl;
  }else{
    cout << "bust" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    int n, m;
    cin >> n >> m;
    char s[100010];
    cin >> s;

    int r = 0, idx = 0;
    while (idx < n) {
        for (int i = m; i >= 0; i--) {
            if (i == 0) {
                cout << -1 << endl;
                return 0;
            }
            if (idx + i <= n && s[idx + i] == '0') {
                idx += i;
                r++;
                break;
            }
        }
    }

    int ans[100010] = {};
    int r2 = 0;
    idx = n;
    while (idx > 0) {
        for (int i = m; i >= 0; i--) {
            if (idx - i >= 0 && s[idx - i] == '0') {
                idx -= i;
                ans[r2++] = i;
                break;
            }
        }
    }
    for (int i = r2 - 1; i >= 0; i--) {
        if (i != r2 - 1) cout << " ";
        cout << ans[i];
    }
    cout << endl;


}


Measured memory_bytes: 896
fun main(args: Array<String>) {
    // Your code here!
    var (n,d) = readLine()!!.split(" ").map{it.toInt()}
    var list:List<List<Int>> = (1..n).map{readLine()!!.split(" ").map{it.toInt()}}
    var list2:MutableList<Double> = mutableListOf() 
    var cnt = 0
    
    for(i in 0..n-1){
        for(k in i+1..n-1){
            var preans = 0
            for(j in 0..d-1){
                preans += (list[i][j] - list[k][j]) * (list[i][j] - list[k][j])
            }
            list2.add(Math.sqrt(preans.toDouble()))
        }
    }
    
    for(l in 0..list2.size-1){
        var intNum:Int = list2[l].toInt()
        var doubleNum:Double = list2[l] - intNum.toDouble()
        
        if(doubleNum == 0.0){
            cnt += 1
        }
    }
    println(cnt)
}


Measured memory_bytes: 37900
#include <iostream>
#include <cstdio>
using namespace std;
int h, w, a, s, c[15][15];
int main() {
	int i, j, k;
	scanf("%d%d", &h, &w);
	for(i=0; i<10; i++) for(j=0; j<10; j++) scanf("%d", &c[i][j]);
	for(k=0; k<10; k++) for(i=0; i<10; i++) for(j=0; j<10; j++) {
		c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
	}
	for(i=0; i<h; i++) for(j=0; j<w; j++) {
		scanf("%d", &a);
		if(a==-1) continue;
		s += c[a][1];
	}
	printf("%d", s);
	return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
    int h,a;
    scanf("%d %d",&h,&a);
    int ans = 1;
    while(h-a > 0) {
        h -= a;
        ans++;
    }
    printf("%d\n",ans);
}

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

int main(){

	char s[1002];

	cin >> s;

	for(int i = 0;i < strlen(s);i++){
		if(s[i] <= 67){
			printf("%c",s[i]+26-3);
		}else{
			printf("%c",s[i]-3);
		}
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 1132
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)
#define clz(n)				__builtin_clzll(n))

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int n;
	cin>>n;
	vi a(n);
	for(int& i: a) cin>>i;
	for(int i=0;i<n;i++) {
			if(a[i] != i+1) {
					for(int j=i+1;j<n;j++) {
							if(a[j] == i+1) {
									int tmp = a[i];
									a[i] = a[j];
									a[j] = tmp;
									goto f;
							}
					}
			}
	}
f:
	for(int i=0;i<n-1;i++) {
			if(a[i] > a[i+1]) {
					cout<<"NO";
					return 0;
			}
	}
	cout<<"YES";
	return 0;
}





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

int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    int r,d,x2000;
    cin>>r>>d>>x2000;
    for(int i = 1;i <= 10;i++) {
        cout<<r*x2000-d<<endl;
        x2000 = r*x2000-d;
    }
}

Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)
var wr *bufio.Writer = bufio.NewWriter(os.Stdout)

func nextInt() int {
	sc.Scan()
	val, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return val
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func main() {
	sc.Split(bufio.ScanWords)
    S := nextInt()
    x1, y1 := 0, 0
    x2, y2 := int(math.Pow10(9)), 1
    x3 := (x2-S%x2)%x2
    y3 := (S+x3)/x2
    fmt.Fprintf(wr, "%d %d %d %d %d %d\n", x1, y1, x2, y2, x3, y3)
	wr.Flush()
}


Measured memory_bytes: 1776
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
using namespace std;
int main(){

	int N;
	cin >> N;
	if(N/10==9||N%10==9)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 190, LG = 20;

char a[N][N];
int rt_rec[N][N][N], dn_rec[N][N][N];
int bak_rt[N][N][N], bak_dn[N][N][N];
int mx_rt[N][N], mx_dn[N][N];

int main() {
	int h, w;
	cin >> h >> w;
	for (int i = 1; i <= h; ++i) {
		cin >> (a[i] + 1);
	}
	for (int i = 1; i <= h; ++i) {
		mx_rt[i][w] = w;
		for (int j = w - 1; j >= 1; --j) {
			mx_rt[i][j] = j;
			if (a[i][j] == a[i][j + 1]) {
				mx_rt[i][j] = mx_rt[i][j + 1];
			}
		}
	}
	for (int j = 1; j <= w; ++j) {
		mx_dn[h][j] = h;
		for (int i = h - 1; i >= 1; --i) {
			mx_dn[i][j] = i;
			if (a[i][j] == a[i + 1][j]) {
				mx_dn[i][j] = mx_dn[i + 1][j];
			}
		}
	}
	for (int j = 1; j <= w; ++j) {
		for (int i1 = 1; i1 <= h; ++i1) {
			int cur = w + 1;
			for (int i2 = i1; i2 <= h; ++i2) {
				if (mx_dn[i1][j] < i2) {
					break;
				}
				cur = min(cur, mx_rt[i2][j]);
				rt_rec[j][i1][i2] = cur;
			}
		}
	}
	for (int i = 1; i <= h; ++i) {
		for (int j1 = 1; j1 <= w; ++j1) {
			int cur = h + 1;
			for (int j2 = j1; j2 <= w; ++j2) {
				if (mx_rt[i][j1] < j2) {
					break;
				}
				cur = min(cur, mx_dn[i][j2]);
				dn_rec[i][j1][j2] = cur;
			}
		}
	}
	for (int c = 0; c < LG; ++c) {
		for (int j = 1; j <= w; ++j) {
			for (int len = h; len >= 1; --len) {
				for (int i1 = 1; i1 <= h; ++i1) {
					int i2 = i1 + len - 1;
					if (i2 > h) {
						break;
					}
					int temp = max(rt_rec[j][i1][i2 + 1], rt_rec[j][i1 - 1][i2]);
					rt_rec[j][i1][i2] = max(rt_rec[j][i1][i2], temp);
					bak_rt[j][i1][i2] = rt_rec[j][i1][i2];
				}
			}
		}
		for (int i = 1; i <= h; ++i) {
			for (int len = w; len >= 1; --len) {
				for (int j1 = 1; j1 <= w; ++j1) {
					int j2 = j1 + len - 1;
					if (j2 > w) {
						break;
					}
					int temp = max(dn_rec[i][j1][j2 + 1], dn_rec[i][j1 - 1][j2]);
					dn_rec[i][j1][j2] = max(dn_rec[i][j1][j2], temp);
					bak_dn[i][j1][j2] = dn_rec[i][j1][j2];
				}
			}
		}
		if (rt_rec[1][1][h] >= w) {
			cout << c << endl;
			return 0;
		}
		for (int j = 1; j <= w; ++j) {
			for (int i1 = 1; i1 <= h; ++i1) {
				for (int i2 = i1; i2 <= h; ++i2) {
					int temp = bak_rt[j][i1][i2];
					temp = bak_rt[temp + 1][i1][i2];
					rt_rec[j][i1][i2] = max(rt_rec[j][i1][i2], temp);
					dn_rec[i1][j][temp] = max(dn_rec[i1][j][temp], i2);
				}
			}
		}
		for (int i = 1; i <= h; ++i) {
			for (int j1 = 1; j1 <= w; ++j1) {
				for (int j2 = j1; j2 <= w; ++j2) {
					int temp = bak_dn[i][j1][j2];
					temp = bak_dn[temp + 1][j1][j2];
					dn_rec[i][j1][j2] = max(dn_rec[i][j1][j2], temp);
					rt_rec[j1][i][temp] = max(rt_rec[j1][i][temp], j2);
				}
			}
		}
	}
}

Measured memory_bytes: 107008
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String S, T;
		char a[] = new char[13];
		S = sc.next();
		T = sc.next();



		String B = T.substring(0, S.length());

		if(S.equals(B)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}


	}

}


Measured memory_bytes: 35720
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;

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

  std::cout << "ABC" << N << std::endl;

  return 0;
}

Measured memory_bytes: 256
'use strict'
function main(inp) {
  inp = inp.trim()*1;
  let ans = 0;
  for(let i = 0; i <= inp; i++){
    if(i%3 !== 0 && i%5 !== 0){
      ans+= i;
    }
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 35180
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int k;
	int negative_output = -1;
	int digit_count = 0;
	int divide_round_timer = 0;
	int divide_number;
	cin >> k;
	int digit_count_temp = k;
	while(digit_count_temp > 0){
		digit_count_temp = digit_count_temp / 10;
		digit_count++;
	}
	long int sequence_number = 0;
	for(int i = 0; i < digit_count; i++)
		sequence_number = sequence_number * 10 + 7;
	while(divide_round_timer < k){
		divide_number = sequence_number % k;
		if(divide_number == 0){
			printf("%d", digit_count);
			break;
		}
		digit_count++;
		divide_round_timer++;
		sequence_number = divide_number * 10 + 7;
	}
	if(divide_round_timer >= k)
		printf("%d", negative_output);
	return 0;
}

Measured memory_bytes: 3688
#![allow(non_snake_case)]

#[allow(unused_macros)]
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input!{
        n: usize,
        a: [usize;n],
    }

    let mean: f64 = a.iter().fold(0, |sum, i| sum + i) as f64 / a.len() as f64;
    let mut ans = 0;
    let mut min_v = (1 << 29) as f64;
    let mut val;
    for (i, v) in a.iter().enumerate() {
        val = (*v as f64 - mean).abs();
        if val < min_v {
            min_v = val;
            ans = i;
        }
    }
    println!("{}", ans);
}

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

const int maxn = 100;
char s[maxn];

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm

    cin >> (s+1);

    if( s[3] == s[4] && s[5] == s[6] )
        cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int c,a,n,ans=0;
        cin>>c>>a>>n;
        while(1){
            if(c>0 && a>0 && n>0){
                c-=1;
                a-=1;
                n-=1;
                ans++;
            }
            else if(c>1 && a>0){
                c-=2;
                a-=1;
                ans++;
            }
            else if(c>2){
                c-=3;
                ans++;
            }
            else break;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int N;
	cin >> N;
	int p[20000];
	for(int i=0; i<N; i++){
		int tmp;
		cin >> tmp;
		tmp--;
		p[tmp] = i+1;
	}

	for(int i=0; i<N; i++) cout << (i!=0?" ":"") << 30000*(i+1) << endl;
	for(int i=0; i<N; i++) cout << (i!=0?" ":"") << 30000*(N-i)+p[i] << endl;


	return 0;
}


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

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

    cnt = 0;
    for (int i=1; i<=N; i++) {
        if (to_string(i).length() % 2 == 1) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

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

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;


int main(){
	int n;
	cin>>n;
	map<string, int>mp;
	rep(i,n){
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		mp[s]++;
	}
	ll ans=0;
	for (auto& p:mp){
		int s=p.second;
		ans+=(ll)s*(s-1)/2;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef pair<int, bool> ib;

#define FOR(a, b, c) for(int a = b; a < c; ++a)
#define RFOR(a, b, c) for(int a = b; a >= c; --a)
#define mp(a, b) make_pair(a, b)
#define all(v) v.begin(), v.end()

#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define vb vector<bool>
#define fst first
#define snd second
#define MAXN 310
#define MAXM 44100
#define LOGMAXN 20
#define INF 1000000007
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007LL

struct shop
{
	ll a;
	int mask;
};

int n, m;
ll memo[(1 << 13)+7][1010];
shop s[1010];

ll solve(int mask, int pos)
{
	if(pos >= m) return (mask == ((1 << n) - 1)) ? 0LL : INFLL;
	if(memo[mask][pos] == -1LL)
	{
		ll ans = solve(mask, pos+1);
		ll tmp = solve(mask | s[pos].mask, pos+1);
		if(tmp < INFLL && ans > s[pos].a + tmp) ans = s[pos].a + tmp;
		memo[mask][pos] = ans;
	}
	return memo[mask][pos];
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	while(cin >> n >> m)
	{
		int x, sz;
		FOR(i, 0, (1 << 13)+7)
		{
			FOR(j, 0, 1010)
			{
				memo[i][j] = -1LL;
			}
		}
		FOR(i, 0, m)
		{
			cin >> s[i].a >> sz;
			s[i].mask = 0;
			FOR(j, 0, sz)
			{
				cin >> x;
				x--;
				s[i].mask |= (1 << x);
			}
		}
		ll ans = solve(0, 0);
		ans = ((ans == INFLL) ? -1LL : ans);
		printf("%lld\n", ans);
	}
	return 0;
}


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

int main() {
  int n,k;
  cin >> n >> k;
  dsu d(n);
  for(int i = 0; i < k; i++) {
    int a,b;
    cin >> a >> b;
    a--;b--;
    d.merge(a,b);
  }
  int ans = d.groups().size();
  cout << ans -1 << endl;
}

Measured memory_bytes: 8964
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define lb(a) lower_bound(a)
#define is(a) insert(a)
#define ps(a) push(a)
const int N=5e5+10;
const int inf=0x3f3f3f3f;
int in[N],loc[N],p[N],ans[N],tot,n,k;
std::priority_queue <int,std::vector<int>,std::greater<int> > q;
int head[N],to[N<<1],Next[N<<1],cnt;
void add(int u,int v)
{
    to[++cnt]=v,Next[cnt]=head[u],head[u]=cnt;
}
#define ls id<<1
#define rs id<<1|1
int min(int x,int y){return x<y?x:y;}
int max(int x,int y){return x>y?x:y;}
int mi[N<<2];
void change(int id,int l,int r,int p,int d)
{
    if(l==r) {mi[id]=d;return;}
    int mid=l+r>>1;
    if(p<=mid) change(ls,l,mid,p,d);
    else change(rs,mid+1,r,p,d);
    mi[id]=min(mi[ls],mi[rs]);
}
int query(int id,int L,int R,int l,int r)
{
    if(mi[id]==inf) return inf;
    if(l==L&&r==R) return mi[id];
    int Mid=L+R>>1;
    if(r<=Mid) return query(ls,L,Mid,l,r);
    else if(l>Mid) return query(rs,Mid+1,R,l,r);
    else return min(query(ls,L,Mid,l,Mid),query(rs,Mid+1,R,Mid+1,r));
}
int main()
{
    scanf("%d%d",&n,&k);
    rep(i,1,n) scanf("%d",p),p[p[0]]=i;
    memset(mi,0x3f,sizeof(mi));
    dep(i,n,1)
    {
        int loc=query(1,1,n,p[i],min(n,p[i]+k-1));
        if(loc!=inf) add(p[i],p[loc]),++in[p[loc]];
        loc=query(1,1,n,max(1,p[i]-k+1),p[i]);
        if(loc!=inf) add(p[i],p[loc]),++in[p[loc]];
        change(1,1,n,p[i],i);
    }
    rep(i,1,n) if(!in[i]) q.ps(i);
    while(!q.empty())
    {
        int now=q.top();
        ans[now]=++tot;
        q.pop();
        for(int i=head[now];i;i=Next[i])
        {
            int v=to[i];
            --in[v];
            if(!in[v]) q.ps(v);
        }
    }
    rep(i,1,n) printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 29684
N=int(input())
X=N*(1+N)//2
a=N//3
S3=a*(3+3*a)//2
b=N//5
S5=b*(5+5*b)//2
c=N//15
S15=c*(15+15*c)//2
print(X-S3-S5+S15)

Measured memory_bytes: 9184
#include<bits/stdc++.h>
#include<atcoder/all>

using namespace std;
using namespace atcoder;

int main(){
    int N,Q;
    cin>>N>>Q;
    fenwick_tree<long long> fw(N);

    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        fw.add(i,a);
    }

    for(int i=0;i<Q;i++){
        int a,b,c;
        cin>>a>>b>>c;
        if(a==0){
            fw.add(b,c);
        }
        else{
            cout<<fw.sum(b,c)<<endl;
        }
    }
}


Measured memory_bytes: 8236
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <map>
using namespace std;
typedef long long ll;

int c[] = {
	1000, 500, 100
};

int main(){
	int a, b;
	while(cin >> a >> b && (a || b)){
		int cost = b - a;
		int a[3];
		for(int i = 0; i < 3; i++){
			a[i] = cost / c[i];
			cost %= c[i];
		}
		for(int i = 2; i >= 0; i--){
			if(i != 2) cout << " " ;
			cout << a[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2002");
            WillReturn.Add("2017");
            //2032
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4500");
            WillReturn.Add("0");
            //-4500
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int R = int.Parse(InputList[0]);
        int G = int.Parse(InputList[1]);

        Console.WriteLine(2 * G - R);
    }
}


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

int main() {
long long q,h,s,d,n;
cin >> q >> h >> s >> d >> n;
if(n==1){
    cout << min({q*4,h*2,s}) << endl;
    return 0;
}
else{
long long find=min({q*8,h*4,s*2,d});
long long ans = find*(n/2);
if(!(n%2==0))ans += min({q*4,h*2,s});
cout << ans << endl;
}
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;
li a[200200][66];
li k;

int main() {
    cin >> n >> k;
    rin{
        cin >> a[i][0];
        a[i][0]--;
    }

    repp(j, 1, 62) {
        rin{
            a[i][j] = a[a[i][j - 1]][j - 1];
        }
    }

    bitset<62> bs(k);
    li pos = 0;
    rep(i, 62) {
        if (bs[i]) {
            pos = a[pos][i];
        }
    }
    cout << pos + 1 << endl;


    return 0;
}

Measured memory_bytes: 106684
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:1024000000,1024000000")

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

#define pb push_back
#define F first
#define S second

#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 1e5+5, LG = 17, MOD = 1e9+7;
const int SQ = 320;
const long double EPS = 1e-7;
int a[N];
int F[N<<1], iF[N<<1];
int n;
int fast(int b, int e){
  int res = 1;
  for(;e;b=1ll*b*b%MOD,e>>=1)
    if(e&1)res = 1ll * res * b % MOD;
  return res;
}
void init(){
  F[0] = iF[0] = 1;
  f(i,1,N<<1){
    F[i] = 1ll * i * F[i-1] % MOD;
    iF[i] = fast(F[i], MOD - 2);
  }
}
int get(int x1, int y1, int x2, int y2){
  int cntX = x2 - x1;
  int cntY = y2 - y1;
  return 1ll *F[cntX+cntY] * iF[cntX] % MOD * iF[cntY] % MOD;
}
int32_t main(){
#ifdef ONLINE_JUDGE
  ios_base::sync_with_stdio(0);
  cin.tie(0);
#endif // ONLINE_JUDGE
  init();
  int H,W,A,B;
  cin>>H>>W>>A>>B;
  int ans = 0;
  f(i,1,H-A+1){
    int x = get(1,1,i,B+1);
    if(i>1)x-=get(1,1,i-1,B+1);
    if(x<0)x+=MOD;
    ans += 1ll * x *get(i,B+1,H,W) % MOD;
    if(ans>=MOD)ans-=MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h> /*4C*/
using namespace std;

int main(){

int a,b;
char c;
cin >> a >> c >> b;

while( c != '?' ){
    if ( c == '+' )
    cout << a+b <<endl;
    
        else if (c == '-')
        cout << a-b << endl;
        
            else if (c == '*' )
            cout << a*b << endl;
            
                else if (c == '/')
                cout << a/b << endl;
    cin >> a >> c >> b;
}
}


Measured memory_bytes: 3088
using System;
using System.Linq; 

namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str=Console.ReadLine().Split(' ');
      int N=int.Parse(str[0]);
      int M=int.Parse(str[1]);
      int[] count=new int[N];
      int[][] arr=new int[M][];
      for(int i=0;i<M;i++){
        arr[i]=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
      }
      for(int j=0;j<M;j++){
       count[arr[j][0]-1]++; 
        count[arr[j][1]-1]++;
      }
      for(int k=0;k<N;k++){
        Console.WriteLine(count[k]);
      }
    }
    
  }

}

Measured memory_bytes: 28020