akhauriyash/Code-Regression huggingface dataset:
n, k=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)


l, m, r=0, a[0, k].inject(:+), a[k, n-k+1].inject(0){|r, e| r+[0, e].max}
# puts "#{l} #{m} #{r}"
best=[0, l+[0, m].max+r].max
(k...n).each do |i|
  l+=[0, a[i-k]].max
  m+=(a[i]-a[i-k])
  r-=[0, a[i]].max
  best=[best, l+[0, m].max+r].max
end

puts best


Measured memory_bytes: 11276
#include<stdio.h>

int main() {
  int L, R, d;
  scanf("%d%d%d", &L, &R, &d);
  int i, wa = 0;
  
  for(i = 0; i < 101; i++) {
    if(i*d > R) {break;}
    else {
      if(i*d >= L) { wa++; }
    }
  }
  printf("%d", wa);
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

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

    vector<string> a(n);
    vector<string> b(m);
    for(LL i=0; i<n; i++){
        cin >> a[i];
    }
    for(LL i=0; i<m; i++){
        cin >> b[i];
    }

    bool ans=false;
    bool is_ok;
    for(LL i=0; i+m<=n; i++){
        for(LL j=0; j+m<=n; j++){
            is_ok=true;
            for(LL k=0; k<m; k++){
                for(LL l=0; l<m; l++){
                    if(a[i+k][j+l]!=b[k][l]){
                        is_ok=false;
                    }
                }
            }
            if(is_ok==true){
                ans=true;
            }
        }
    }

    if(ans==true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;

int main(){
    int W, H, N;
    cin >> W >> H >> N;
    vector<int> x(N), y(N), a(N);
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i] >> a[i];
    }
    
    int x_left = 0, y_below = 0;
    int x_right = W, y_above = H;
    
    for(int i = 0; i < N; i++){
        if(a[i] == 1){
            x_left = max(x_left, x[i]);
        }
        else if(a[i] == 2){
            x_right = min(x_right, x[i]);
        }
        else if(a[i] == 3){
            y_below = max(y_below, y[i]);
        }
        else{
            y_above = min(y_above, y[i]);
        }
    }
    
    if(x_right - x_left < 0 && y_above - y_below < 0){
        cout << 0 << endl;
        return 0;
    }
    
    int ans = max(0, (x_right - x_left) * (y_above - y_below));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
int main(){
	int a,b;
  std::cin>>a;
  b=a%10;
  if(b==2||b==4||b==5||b==7||b==9){
    std::cout<<"hon"<<std::endl;
  }else if(b==3){
    std::cout<<"bon"<<std::endl;
  }else{
    std::cout<<"pon"<<std::endl;
  }
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define int                 long long
#define FF(i,a,b)           for(int i=a;i<b;i++)
#define BF(i,a,b)           for(int i=a;i>=b;i--)
#define vi                  vector<int>
#define MAP                 map<int,int>
#define pb                  push_back
#define MP                  make_pair
#define F                   first
#define S                   second
#define pi                  pair<int,int>
#define all(v)              v.begin(),v.end()
#define PIE                 3.1415926535897932384626433832795
#define FastIO              ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
//#define ordered_set         tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
/*

    order_of_key (k) : Number of items strictly smaller than k .
    find_by_order(k) : K-th element in a set (counting from zero).

*/
/**************************************************************************************/
                       /*Global Variables*/
const int mod = 1e9+7;
const int N = 2e5+10;
const int inf = 3e18;

/**************************************************************************************/
template <typename A>istream& operator>>(istream& input,vector<A>& x) {for(auto& i:x)input>>i;return input;}
template<typename A>ostream& operator<<(ostream& output,vector<A>& x) {for(auto& i:x)output<<i<<' ';return output;}
int add(int a, int b){return (a%mod + b%mod + mod)%mod;}
int sub(int a, int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b){return ((a%mod)*(b%mod) + mod)%mod;}
int Power(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b&1)res*=a;
        a*=a;
        b>>=1;
    }
    return res;
}
signed main()
{
    FastIO;
    int T=1;
    //cin>>T;
    while(T--)
    {
        int n;
        cin>>n;
        vi a(n);
        cin>>a;
        vi dp(n);
        FF(i,0,n)dp[i]=inf;
        dp[0]=0;
        dp[1]=abs(a[1]-a[0]);
        
        for( int i=2;i<n;i++)
        {
            dp[i]=min(dp[i],dp[i-1]+abs(a[i-1]-a[i]));
            dp[i]=min(dp[i],dp[i-2]+abs(a[i-2]-a[i]));
        }
        cout<<dp[n-1]<<"\n";
    }

}
/*
|| Do what you can with all you have,wherever you are. ||

|| Knowing is not enough, we must apply. Wishing is not enough, we must do. ||

|| A goal is a dream with deadline. ||

|| Whether you think you can or you think you can't, you're right. ||

|| A year from now you may wish you had started today ||
*/



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

const int mod = 998244353;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	int l[k], r[k];
	for(int i = 0; i < k; i++) {
		cin >> l[i] >> r[i];
	}
	long long ans[2 * n + 1] = {0};
	long long add[2 * n + 1] = {0};
	ans[1] = 1;
	for(int i = 1; i <= n; i++) {
		add[i] += add[i - 1];
		add[i] %= mod;
		ans[i] += add[i];
		for(int j = 0; j < k; j++) {
			add[i + l[j]] += ans[i];
			add[i + l[j]] %= mod;
			add[i + r[j] + 1] -= ans[i];
			add[i + r[j] + 1] %= mod;
		}
		ans[i] %= mod;
		ans[i] += mod;
		ans[i] %= mod;
		// cout << ans[i] << ' ';
	}
	cout << ans[n] << endl;
	return 0;
}

Measured memory_bytes: 9852
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

#define int long long

const int N = 200005;

int q;
int t[N];
int a[N], b[N];
int cntfenw[N];
int sumfenw[N];
map <int, int> id, what;
vector <int> vec;

void update(int i, int val1, int val2) {
  for (; i < N; i += i & (-i)) {
    cntfenw[i] += val1;
    sumfenw[i] += val2;
  }
}

int cntsum(int i) {
  int ans = 0;
  for (; i > 0; i -= i & (-i)) {
    ans += cntfenw[i];
  }
  return ans;
}

int cntsum(int i, int j) {
  if (i > j) return 0;
  return cntsum(j) - (i > 1 ? cntsum(i - 1) : 0);
}

int sumsum(int i) {
  int ans = 0;
  for (; i > 0; i -= i & (-i)) {
    ans += sumfenw[i];
  }
  return ans;
}

int sumsum(int i, int j) {
  if (i > j) return 0;
  return sumsum(j) - (i > 1 ? sumsum(i - 1) : 0);
}

int findmid(int x) {
  int l = 1, r = N - 1, ans;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (cntsum(mid) >= x) {
      ans = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  return ans;
}

int go(int el, int pos) {
  int ans = 0;
  ans += el * cntsum(1, pos) - sumsum(1, pos);
  ans += sumsum(pos, N - 1) - el * cntsum(pos, N - 1);
  return ans;
}

int32_t main() {
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> t[i];
    if (t[i] == 1) {
      cin >> a[i] >> b[i];
      vec.push_back(a[i]);
    }
  }
  sort(vec.begin(), vec.end());
  vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
  for (int i = 0; i < vec.size(); i++) {
    id[vec[i]] = i + 1;
    what[i + 1] = vec[i];
  }
  int sumb = 0;
  int mid, len = 0, pos;
  for (int i = 0; i < q; i++) {
    if (t[i] == 1) {
      len++;
      sumb += b[i];
      update(id[a[i]], 1, a[i]);
      if (len & 1) {
        pos = findmid(len / 2 + 1);
      } else {
        pos = findmid(len / 2);
      }
      mid = what[pos];
    } else {
      cout << mid << " " << sumb + go(mid, pos) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 22900
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            //string s = Console.ReadLine();

            // 文字列の入力
            //string t = Console.ReadLine();

            //// 整数の入力
            //long n = long.Parse(Console.ReadLine());

            //// 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            //// 整数配列の入力
            var a = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            //int c = 0;

            long[] b = {a[0]*a[2],a[0]*a[3],a[1]*a[2],a[1]*a[3]};




            Console.WriteLine(b.Max());

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28272
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

#define MAX 5000

int G[51][51];
int h,w;


void dfs(int x, int y){
    /*for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            cout <<G[i][j]<<" ";
        }
        cout << endl;
    }
    cout << endl;*/
    if(x<0||x>=h||y<0||y>=w) return;
    for (int i=-1; i<=1 ; i++) {
        if(x+i>=h or x+i<0) continue;
        for (int j=-1; j<=1; j++) {
            if(y+j>=w or y+j < 0) continue;
            if (G[x+i][y+j]==1) {
                G[x+i][y+j]=0;
                dfs(x+i,y+j);
            }
        }
    }
}


int main(){
    for(;;){
        cin >> w >> h;
        if(w==0 and h == 0) break;
        int ans=0;
        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                G[i][j]=0;
            }
        }
        for (int i = 0; i<h;i++) {
            for (int j=0; j < w; j++) {
                cin >> G[i][j];
            }
        }
        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                if (G[i][j]==1) {
                    G[i][j]=0;
                    ans++;
                    dfs(i,j);
                }
            }
        }
        cout << ans <<endl;
    }
    return 0;
}

Measured memory_bytes: 1348
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int h, w, c;
int ans, a, counta;
vector<vector<int>> p;

vector<vector<int>> check(vector<vector<int>> tmp, int i, int j, int color, int nowcolor){
    tmp[i][j] = color;
    counta++;
    if(i != 0){
        if(tmp[i - 1][j] == nowcolor){
            tmp = check(tmp, i - 1, j, color, nowcolor);
        }
    }

    if(i != h - 1){
        if(tmp[i + 1][j] == nowcolor){
            tmp = check(tmp, i + 1, j, color, nowcolor);
        }
    }

    if(j != 0){
        if(tmp[i][j - 1] == nowcolor){
            tmp = check(tmp, i, j - 1, color, nowcolor);
        }
    }

    if(j != w - 1){
        if(tmp[i][j + 1] == nowcolor){
            tmp = check(tmp, i, j + 1, color, nowcolor);
        }
    }

    return tmp;
}

void dfs(vector<vector<int>> tmp, int times){
    vector<vector<int>> tmp2;
    if(times < 4){
        for(int i = 1; i <= 6; i++){
            if(i != tmp[0][0]){
                tmp2 = check(tmp, 0, 0, i, tmp[0][0]);
                dfs(tmp2, times + 1);
            }
        }
    }else{
        if(tmp[0][0] != c){
            tmp2 = check(tmp, 0, 0, c, tmp[0][0]);
            counta = 0;
            check(tmp2, 0, 0, 0, tmp2[0][0]);
            ans = max(ans, counta);
        }
    }
}

int main(){
    vector<int> tmp;
    while(true){
        p.clear();
        cin >> h >> w >> c;
        if((h | w | c) == 0) break;
        for(int i = 0; i < h; i++){
            tmp.clear();
            for(int j = 0; j < w; j++){cin >> a; tmp.push_back(a);}
            p.push_back(tmp);
        }

        ans = 1;
        counta = 0;
        dfs(p, 0);
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3200
import java.io.IOException;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) throws IOException {
		/*
		 * ?????? ???.length < 10 ?????? ??´.length < 1000
		 *
		 * T.contains " " or Enter Ti
		 *
		 * All Ti -> T.contains cnt?
		 *
		 * Example) input- W : computer
		 *
		 * T1: Nurtures computer scientists and highly-skilled computerengineers
		 * T2: who will create and exploit "knowledge" for the newera.
		 * T3: Provides an outstanding computer environment.
		 * T4: END_OF_TEXT if(t4.equl("END_OF_TEXT"))break;
		 *
		 * output- 3
		 */

		Scanner sc = new Scanner(System.in);

		// sample input
		final String infoW = sc.next();
		// Count variable declear
		int cnt = 0;
		// while section

		while (true) {
			final String  strT = sc.next();
			// break condition
			if ("END_OF_TEXT".equals(strT)) {
				break;
				// equlas() ?°?????????¨??§??????????????\
				// equalsignorecase() ?°?????????¨??§??????????????\?????????
				// ????????????????????????????????????
			} else if (infoW.equalsIgnoreCase(strT)) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 26324
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	N := readInt()
	M := readInt()
	Q := readInt()

	f := make([][]int, 510)
	for i := range f {
		f[i] = make([]int, 510)
	}
	for i := 0; i < M; i++ {
		l := readInt()
		r := readInt()
		f[l][r]++
	}

	for i := 1; i <= N; i++ {
		for j := 1; j <= N; j++ {
			f[i][j] += f[i][j-1]
		}
	}
	for i := N; i > 0; i-- {
		for j := 1; j <= N; j++ {
			f[i][j] += f[i+1][j]
		}
	}

	for i := 0; i < Q; i++ {
		l := readInt()
		r := readInt()
		println(f[l][r])
	}

}


Measured memory_bytes: 6016
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int n;
  cin >> n;

  int dp[n + 1];
  fill(dp, dp + n + 1, 0);

  for(int i = 1; i <= n; i++){
    dp[i] = dp[i - 1] + 1;
    int base = 6;
    while(i - base >= 0){
      dp[i] = min(dp[i], dp[i - base] + 1);
      base *= 6;
    }
    base = 9;
    while(i - base >= 0){
      dp[i] = min(dp[i], dp[i - base] + 1);
      base *= 9;
    }
  }

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{
    int h,a;
    cin>>h>>a;
    if(h%a==0)
        cout<<h/a<<e;
    else
        cout<<h/a+1<<e;


}



Measured memory_bytes: 256
k = int(input())
s = input()
n = len(s)

N = n + k - 1

mod = 1000000007
fact = [1] * (N + 1)
ifact = [1] * (N + 1)

for i in range(N):
    fact[i + 1] = fact[i] * (i + 1) % mod
    ifact[i + 1] = pow(fact[i + 1], mod - 2, mod)


def comb(x, y):
    if y < 0 or y > x:
        return 0
    return (fact[x] * ifact[x - y] * ifact[y]) % mod


m25 = [1]
for i in range(k):
    m25.append(m25[i] * 25 % mod)
m26 = [1]
for i in range(k):
    m26.append(m26[i] * 26 % mod)

ans = 0
for i in range(k + 1):
    p = m25[k - i] * m26[i] % mod
    p *= comb(n + k - i - 1, n - 1)
    p %= mod
    ans += p
    ans %= mod
print(ans)


Measured memory_bytes: 215384
import numpy as np

N, M = map(int, input().split())  # 複数数値入力

A = [[0, 0]] * N
for i in range(N):
    A[i] = list(map(int, input().split()))  # 複数数値入力

A = np.array(A, dtype=np.float64)
A = A[np.argsort(A[:, 0])]

ans = 0
for i in range(N):
    if M >= A[i][1]:
        M -= A[i][1]
        ans += A[i][0] * A[i][1]
    else:
        ans += A[i][0] * M
        break

print(int(ans))


Measured memory_bytes: 37900
from bisect import bisect_left

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

ans = 0

for i in range(q):
    x = bisect_left(S, T[i])
    if x < n:
        if S[x]==T[i]:
            ans += 1
print(ans)


Measured memory_bytes: 16740
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
using M = Mint<int>;
const int MAX = 1010;
int dp[MAX][MAX];
M sm[MAX][MAX]={};

signed main(){
  int h,w;
  cin>>h>>w;
  h++;w++;

  for(int i=0;i<MAX;i++)
    dp[0][i]=dp[i][0]=i;

  for(int i=1;i<MAX;i++)
    for(int j=1;j<MAX;j++)
      dp[i][j]=dp[min(i,j)][min(i%j,j%i)];

  for(int i=1;i<MAX;i++)
    for(int j=1;j<MAX;j++)
      sm[i][j]=sm[i][j-1]+M(dp[i][j]-1);

  for(int i=1;i<MAX;i++)
    for(int j=1;j<MAX;j++)
      sm[i][j]+=sm[i-1][j];

  int num=h*w;
  M ans=M(num)*M(num-1)*M(num-2)/M(6);
  //cout<<ans<<endl;

  for(int i=1;i<h;i++)
    for(int j=1;j<w;j++)
      ans-=M(2)*sm[i][j];
  //cout<<ans<<endl;

  ans-=M(h)*M(h-1)*M(h-2)/M(6)*M(w);
  ans-=M(w)*M(w-1)*M(w-2)/M(6)*M(h);
  //cout<<ans<<endl;

  ans*=M(2).pow(num-3);
  cout<<ans<<endl;
  return 0;
}



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

using namespace std;

int main()
{
    int N = 0, D =0;
    double XY [2] [199999];
    int i =0, count = 0;
  	double sum =0;


    cin >> N >> D;

    for (i = 0; i < N ; i++){
        cin >> XY[0][i] >> XY[1][i];

        sum = sqrt(pow(XY[0][i],2) + pow(XY[1][i],2));

        if (sum <= D){
            count+=1;
        }
    }

    cout << count;

}



Measured memory_bytes: 6964
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

int main(void){
  ll n, k;
  cin >> n >> k;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  for (int i = k; i < n; i++){
    if (a[i] - a[i-k] > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
      
  }

  return 0;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define mod (1000000007)
 
// vector<long long int> temp(40002);//long int vis[1000002] = {0};
  // vector<long int> g[1000002];

int main() {
 
  long long int t = 1;
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
 
 //cin >> t;
  while(t--){
 
    int n,m,x = 0,y = 0,start = 0,end = 0,index = 0,z;

    string a,b;
    cin >> a >> b;

    n = a.size();
    m = b.size();

    int arr[n+1][m+1];
    for(int i = 0;i<=n;i++)
    {
      for(int j = 0;j<=m;j++)
      {
          if(i == 0 || j == 0)
           arr[i][j] = 0;
          
          else if(a[i-1] == b[j-1])
           {
             arr[i][j] = arr[i-1][j-1]+1;
           }
           else
           {
             arr[i][j] = max(arr[i-1][j],arr[i][j-1]);
           }
           
      }
    }
    string ans = "";
    int i = n,j = m;

    while(i>0 && j>0)
    {
      if(a[i-1] == b[j-1])
      {
        ans+=a[i-1];
        i--;j--;
        continue;
      }
      if(arr[i-1][j] > arr[i][j-1])
       i--;
       else
       {
         j--;
       }
       

    }


    reverse(ans.begin(),ans.end());
    cout << ans << '\n';
      
  } 
}


Measured memory_bytes: 38832
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void solve(){
 int n,a,b;
 cin>>n>>a>>b;
 cout<<min(b,n*a);   
}

int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

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

int main(){

    long int N;
    long int sum = 0;
    int i;

    scanf("%ld",&N);

    for(i = 1; i <= N; i++){
        if((i%3 != 0)&&(i%5 != 0)){
            sum += i; 
        }
    }
    
    printf("%ld",sum);

    return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
int N, ANS;
char S, T;
int main(void)
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> S;
		if (S != T)
		{
			ANS++;
		}
		T = S;
	}
	cout << ANS << endl;
	return 0;
}

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

int main()
{
  int n,ans;
  ans=0;
  cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++)
  {
    cin>>p.at(i);
  }
  sort(p.begin(),p.end());
  for(int i=0;i<n;i++)
  {
    if(i==n-1)
      p.at(i)/=2;
    ans+=p.at(i);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3476
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 998244353

N, M, K = map(int, input().split())

ans = [0] * (K + 1)
ans[0] = M

class Factorial:
    def __init__(self, n, mod):
        self.f = [1]
        self.mod = mod
        for j in range(1, n + 1):
            self.f.append(self.f[-1] * j % mod)
        self.i = [pow(self.f[-1], mod - 2, mod)]
        for j in range(n, 0, -1):
            self.i.append(self.i[-1] * j % mod)
        self.i.reverse()
    def factorial(self, j):
        return self.f[j]
    def ifactorial(self, j):
        return self.i[j]
    def comb(self, n, k):
        return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0

C = Factorial(N + 1, MOD).comb

ans = 0
m = M - 1
for i in range(K + 1):
    tmp = C(N - 1, i)
    tmp = (tmp * pow(m, N - 1 - i, MOD)) % MOD
    ans += tmp
    ans %= MOD

ans *= M
ans %= MOD

print (ans)



Measured memory_bytes: 26252
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775808;

ll combi(ll x, ll y) {
    ll num = 1;
    for (int i = 1; i <= y; i++) {
        num = num * (x - i + 1) / i;
    }
    return num;
}

int main() {
    string A;
    cin >> A;
    int len = A.length();
    char x[len];
    for (int i = 0; i < len; i++) {
        x[i] = A[i];
    }
    sort(x, x + len);
    ll d = 0;
    char ch = x[0];
    ll num = 1;
    for (int i = 1; i < len; i++) {
        if (x[i] == ch) {
            num++;
        } else {
            if (num >= 2) {
                d += combi(num, 2);
            }
            ch = x[i];
            num = 1;
        }
    }
    if (num >= 2) {
        d += combi(num, 2);
    }
    ll ans = combi(len, 2) + 1;
    ans -= d;
    cout << ans << endl;
}


Measured memory_bytes: 772
#include<bits/stdc++.h>
using namespace std;
#define ll  long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD = 1000000007;
ll cnt =0,ans=0;
const int MAX = 510000;

int main(){
   int n , m;
   cin >> n >> m;
   int a,b;
   vector<int>to[100010];
   for(int i=0;i<m;i++){
       cin >> a >> b;
       a--; b--;
       to[a].push_back(b);
       to[b].push_back(a);
   }
   
   queue<int>q;
   vector<int>dist(n,INF);

   vector<int>pre(n,-1);
   dist[0] = 0;
   q.push(0);

   while(!q.empty()){
       int v = q.front();q.pop();
       for(int u : to[v]){
           if(dist[u]!=INF)continue;
           dist[u] = dist[v] +1;
           pre[u] = v;
           q.push(u);

       }
       
   }
   cout << "Yes" << endl;
       for(int i=0;i<n;i++){
           if(i == 0)continue;
           ans = pre[i];
           ans++;
           cout << ans << endl;
       }

}
       


Measured memory_bytes: 10460
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	result := 0
	if a > b {
		result += a
		a--
		if a > b {
			result += a
		} else {
			result += b
		}
	} else if a < b {
		result += b
		b--
		if a > b {
			result += a
		} else {
			result += b
		}
	} else {
		result = 2 * a
	}
	fmt.Println(result)

}


Measured memory_bytes: 512
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sca = new Scanner(System.in);
    char[] sa = sca.next().toCharArray();
    char[] sb = sca.next().toCharArray();
    char[] sc = sca.next().toCharArray();
    sca.close();
    int la = sa.length;
    int lb = sb.length;
    int lc = sc.length;
    int na = 0;
    int nb = 0;
    int nc = 0;
    char nex = 'a';
    while(true){
      if (nex =='a'){
        if (na==la){
          System.out.println("A");
          break;
        }
        nex = sa[na++];
      }else if (nex =='b'){
        if (nb==lb){
          System.out.println("B");
          break;
        }
        nex = sb[nb++];
      }else{
        if (nc==lc){
          System.out.println("C");
          break;
        }
        nex = sc[nc++];
      }
    }
  }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  cin>>n;
  vector<string> s(n);
  REP(i, n) cin>>s[i];
  map<string, int> mp;
  REP(i, n) mp[s[i]]++;
  int ans = 0;
  for(auto p: mp) if(p.second > 0) ans++;
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 25088
price=int(input())
while price!=0:
    change=1000-price
    if change//500==1:
        fiveh=1
        change-=500
    else:
        fiveh=0
    if change//100>0:
        hundred=change//100
        change=change%100
    else:
        hundred=0
    if change//50>0:
        fifty=change//50
        change=change%50
    else:
        fifty=0
    if change//10:
        ten=change//10
        change=change%10
    else:
        ten=0
    if change//5:
        five=change//5
        change=change%5
    else:
        five=0
    one=change    
    print(fiveh+hundred+fifty+ten+five+one)  
    price=int(input())
else:
    pass
        



Measured memory_bytes: 5588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
const int MOD = 1e9 + 7;

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

    ll ans = 0, sum = 0;
    rep(i, n) sum += a[i];
    sum %= MOD;

    rep(i, n - 1) {
        sum -= a[i];
        if (sum < 0) sum += MOD;
        ans = (ans + a[i] * sum) % MOD;
    }

    cout << ans << endl;
    return 0;
}


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

struct A
{
  A(
    int a
  )
    : a(a)
    , cnt(1)
  {
  }
  int a;
  int cnt;
};

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  for (auto & A : a)
    cin >> A;
  sort(a.begin(), a.end());
  vector<A> cnt;
  cnt.push_back(A(a[0]));
  for (int i = 1; i < N; ++i)
  {
    if (a[i] == cnt[cnt.size() - 1].a)
      ++cnt[cnt.size() - 1].cnt;
    else
      cnt.push_back(A(a[i]));
  }
  int rem = 0;
  for (int i = 0; i < cnt.size(); ++i)
  {
    if (cnt[i].cnt < cnt[i].a)
      rem += cnt[i].cnt;
    else if (cnt[i].a < cnt[i].cnt)
      rem += cnt[i].cnt - cnt[i].a;
  }
  cout << rem;
  return 0;
}


Measured memory_bytes: 1784
#include <stdio.h>

int main(void)
{
	int i,j,repeat,dataset[10];
	
	scanf("%d",&repeat);
	for(j=0;j<repeat;j++)
	{
		scanf("%d",&dataset[j]);
	}
	
	for(j=0;j<repeat;j++)
	{
		printf("Case %d:\n",j+1);
		
		for(i=0;i<10;i++)
		{
			dataset[j]=(int)((dataset[j]*dataset[j])%1000000)/100;
			
			printf("%d\n",dataset[j]);
		}
	}
}

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

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

    if (N % 10 == 3) cout << "bon" << endl;
    else if(N % 10 == 0 ||N % 10 == 1 || N % 10 == 6 || N % 10 == 8) cout << "pon" << endl;
    else cout << "hon" << endl;

    return 0;
}

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

using namespace std;
 
#define EPS 1e-3
#define equals(a,b) (abs(a-b) < EPS)
typedef vector<double> vec;
typedef vector<vec> mat;

vec gauss_jordan(const mat &A,const vec &b){
  int n = A.size();
  mat B(n,vec(n+1));
  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      B[i][j] = A[i][j];
    }
  }
  for(int i = 0 ; i < n ; i++){
    B[i][n] = b[i];
  }
  for(int i = 0 ; i < n ; i++){
    int pivot = i;
    for(int j = i ; j < n ; j++){
      if(abs(B[j][i]) > abs(B[pivot][i])){
        pivot = j;
      }
    }
    swap(B[i],B[pivot]);
    if(abs(B[i][i]) < EPS){ return vec(); }
    for(int j = i+1 ; j <= n ; j++){
      B[i][j] /= B[i][i];
    }
    for(int j = 0 ; j < n ; j++){
      if(i != j){
        for(int k = i+1 ; k <= n ; k++){
          B[j][k] -= B[j][i]*B[i][k];
        }
      }
    }
  }
  vec x(n);
  for(int i = 0 ; i < n ; i++){
    x[i] = B[i][n];
  }
  return x;
}

int main(){
  int d;
  while(cin >> d,d){
    int N = d+3;
    mat A(N,vec(d+1));
    vec b(N);
    for(int i = 0 ; i < N ; i++){
      cin >> b[i];
      for(int j = 0 ; j <= d ; j++){
        A[i][j] = pow((double)i,j);
      }
    }
    for(int i = 0 ; i < N ; i++){
      int idx = 0;
      mat A2(N-2,vec(d+1));
      vec b2(N-2);
      for(int j = 0 ; idx < N-2 ; j++){
        if(i == j){ continue; }
        A2[idx] = A[j];
        b2[idx++] = b[j];
      }
      vec res = gauss_jordan(A2,b2);
      if(res.size() > 0){
        int x = (i == N-1 ? N-2 : N-1);
        double sum = 0;
        for(int j = 0 ; j < (int)res.size() ; j++){
          sum += res[j]*pow((double)x,j);
        }
        if(equals(sum,b[x])){
          cout << i << endl;
          break;
        }
      }
    }
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int a = N / 1000;
  int b = N % 1000 / 100;
  int c = N % 1000 % 100 / 10;
  int d = N % 1000 % 100 % 10;
  if ((a == b && b == c) || (b == c && c == d))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

char S[20] = {};

int main() {
	cin >> S;
	if (S[0] == 'Y' && S[1] == 'A' && S[2] == 'K' && S[3] == 'I') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
    int n,p,a[50],i,j,f,q;
      while(0<=scanf("%d%d",&n,&p)){
        if(n==0 && p==0)break;
        q=p;
        for(i=0;i<50;i++){
            a[i]=0;
        }
        f=0;
        i=0;
        while(f==0){
            if(p>0){
                a[i%n]++;
                p--;
            }else{
                p=a[i%n];
                a[i%n]=0;
            }
            if(a[i]==q){
                break;
            }
             
            i=(i+1)%n;
        }
         
        printf("%d\n",i);
    }
    return 0;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);

  int n, m, d;
  cin >> n >> m >> d;

  double x = (d == 0) ? n : 2 * (n - d);
  double ans = x * (m - 1) / (1.0 * n * n);
  cout << fixed << setprecision(10) << ans << '\n';

  return 0;
}


Measured memory_bytes: 3748
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  string t;
  cin >> t;
  int x=t.size();

  bool n=false;
  bool w=false;
  bool s=false;
  bool e=false;
  rep(i,x){
    if(t[i]=='N')n=true;
    if(t[i]=='W')w=true;
    if(t[i]=='S')s=true;
    if(t[i]=='E')e=true;    
  }
  
  cout << ((n&&w&&s&&e)||(n&&s&&(!w)&&(!e))||(w&&e&&(!n)&&(!s))?"Yes":"No") << endl;
  
}


Measured memory_bytes: 256
s = input()
len_s = len(s)
ans_array = [0 for x in range(len_s+1)]
for index in range(len_s):
    if s[index] == "<":
        ans_array[index + 1] = ans_array[index]+1
for index in reversed(range(len_s)):
    if s[index] == ">":
        ans_array[index] = max(ans_array[index+1]+1, ans_array[index])
print(sum(ans_array))

Measured memory_bytes: 24092
#include <bits/stdc++.h>
using namespace std;
    #define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
    #define ll long long
    #define int long long 
    #define ull unsigned long long 
    #define ld long double
    #define sb __builtin_popcount
    #define vi vector<int>
    #define vc vector<char>
    #define ii pair<int, int>
    #define pq priority_queue<ii, vector<ii>, greater<ii>>
    #define vii vector<ii>
    #define sz(a) int((a).size())
    #define f(a, b) for (int i = a; i < b; i++)
    #define fr(a, b) for (int i = a - 1; i >= b; i--)
    #define tr(x, m) for (auto x : m)
    #define in(a, b) (b.find(a) != string::npos)
    #define minin(a) *min_element(all(a))
    #define maxin(a) *max_element(all(a))
    #define X first
    #define Y second
    #define fill(a, x) memset(a, x, sizeof(a))
    #define pb push_back
    #define pf push_front
    #define mp make_pair
    #define all(v) v.begin(), v.end()
    #define rall(v) reverse(v.begin(), v.end())
    #define unq(v) v.erase(unique(all(v)), v.end())
    #define el "\n"
    #define mx3(a, b, c) max(max(a, b), c)
    #define mn3(a, b, c) min(min(a, b), c)
    #define S(v) accumulate(all(v), (ll)0)
    #define SP(n) cout.precision(n)
    const ld PI = atan(1.0) * 4.0;
    const ll MOD = 1e9 + 7;
    const ll INF = 1e18;
    const ld EPS = 0.0000001;
    const ll MD = 998244353;
    
    int32_t main() {
        fio;
        int a,b,c,k;
        cin>>a>>b>>c>>k;
        if(a>=k)cout<<k;
        else if((a+b)>=k)cout<<a;
        else if((a+b+c)>=k)cout<<a-(k-a-b);
        return 0;
    }


Measured memory_bytes: 3652
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<cmath>
#include<cstring>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define eps (double)1e-9
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pdbs;
 
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...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
// look for  all edge cases
//search for a pattern


vector<bool> vis(1e6+2 , false);

signed main() {	
	
	ios::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	vector<int> v(n);
	
	map<int,int> freq;
	
	for(int i =0 ; i < n; i++){
		cin >> v[i];
		freq[v[i]] += 1;
		
	}
	
	sort(all(v));
	
	int ans = 0;
	
	
	for(int i =0 ; i < n; i++){
		
		
		
		if(v[i] == 1){
			
			if(freq[v[i]] > 1){
				ans = 0;
			}
			else
				ans = 1;
			
			break;
		}
		
		if(freq[v[i]] > 1){
			vis[v[i]] = true;
		}
		
		if(vis[v[i]] == false){
			ans += 1;
		}
		
		
		for(int j = 2*v[i] ; j < 1e6+2 ; j+= v[i]){
			vis[j] = true;
		}
		
	}
	
	cout<<ans;
	
	return 0;
}


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

struct loc {
    int i, j;
};

int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };

#define ira(a, b, c) (a <= b && b < c)

int main(){
    int h, w;
    cin >> h >> w;
    char arr[h][w];
    queue<loc> q;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> arr[i][j];
            if(arr[i][j] == '#') q.push({ i, j });
        }
    }
    int r = 0;
    while(q.size()){
        int ps = q.size();
        while(ps--){
            int x = q.front().i, y = q.front().j;
            q.pop();
            for(int i = 0; i < 4; i++){
                if(ira(0, x + dx[i], h) && ira(0, y + dy[i], w) && 
                        arr[x+dx[i]][y+dy[i]] != '#'){
                    arr[x+dx[i]][y+dy[i]] = '#';
                    q.push({ x + dx[i], y + dy[i] });
                }
            }
        }
        r++;
    }
    cout << (r-1) << '\n';
}


Measured memory_bytes: 9360
N, M = map(int, input().split())

cs = [0] * N
for _ in range(M):
  L, R = map(int, input().split())
  cs[L - 1] += 1
  if R != N:
    cs[R] -= 1

for i in range(1, N):
  cs[i] += cs[i - 1]

print(sum(1 for i in range(N) if cs[i] == M))

  

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

typedef long long ll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forr(i,m,n) for(ll i=m;i<n;i++)
#define testcase int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define rev(v) v.rbegin(),v.rend()
#define pb push_back
#define endl "\n"
#define print(v) forr(i,0,v.size())cout<<v[i]<<" ";cout<<endl;
#define print_map(m) for(auto it=m.begin(); it!=m.end();it++) cout<<(*it).first<<" "<<(*it).second<<endl;
#define vi vector<int>
#define vp vector< pair<int, int> >

ll maxi(ll a, ll b){
	if(a>b) return a;
	return b;
}

ll mini(ll a, ll b){
	if(a>b) return b;
	return a;
}

bool sorter(pair<int, int> a, pair<int, int> b){
	if(a.second!=b.second) return a.second>b.second;
	return a.first>b.first;
}

int main(){
	fastio
	ll r; cin>>r;
	cout<<3.14159*2*r<<endl;
	return 0;
}

Measured memory_bytes: 3804
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	ld N; cin >> N;
    cout << setprecision(20) << (N*N*N)/27 << endl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int Sx,Sy,Tx,Ty;
    cin >> Sx >> Sy >> Tx >> Ty;
    int dx = Tx - Sx;
    int dy = Ty - Sy;
    cout << string(dy,'U') << string(dx,'R');
    cout << string(dy,'D') << string(dx,'L');
    cout << 'L' << string(dy+1,'U') << string(dx+1,'R') << 'D';
    cout << 'R' << string(dy+1,'D') << string(dx+1,'L') << 'U';
 
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            int K = int.Parse (Console.ReadLine ());
            string S = Console.ReadLine ();

            if (S.Length <= K)
            {
                Console.WriteLine (S);
            }
            else
            {
                string m = "";
                for (int i = 0; i < K; i++)
                {
                    m += S[i].ToString ();
                }

                Console.WriteLine (m + "...");

            }

        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 27484
#include <bits/stdc++.h>
#define sz(a) (int)a.size()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;
const ll MOD = 2019;

ll modexp(ll a,ll b,ll m) {
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

int main() {
	string s;
	cin >> s;
	int curr = 0;
	map<int, int> cnt;
	cnt[0] = 1;
	ll ans = 0;
	for(int i = s.length() - 1; i >= 0; --i) {
		curr += (s[i] - '0') * modexp(10, s.length() - i - 1, MOD) % MOD;
		curr %= MOD;
		// cout << curr << " ";
		ans += cnt[curr]++;
	}
	cout << ans;
}



Measured memory_bytes: 3724
use proconio::input;
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
const M: usize = 1_000_000_000 + 10;
fn main() {
    input!(N: usize, K: i64);
    input!(mut A: [i64; N]);
    let mut high = M;
    let mut low = 1;
    while high != low {
        let mut cnt: i64 = 0;
        let mid = (high + low) / 2;
        cnt += A.iter().fold(0, |acc, &x| acc + (x - 1) / (mid as i64));
        if cnt <= K {
            high = mid;
        } else {
            low = mid + 1;
        }
    }

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


Measured memory_bytes: 5396