akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define id(i,j) ((i) * 3000 + (j))
using namespace std;
typedef long long LL;
typedef pair<LL, int> PLI;
const int INF = 0x3f3f3f3f;
const LL LINF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 2e5 + 10;
int N, M, S;
struct edge
{
    int v, c;
};
vector<edge> g[maxn];
bool vis[maxn];
LL dist[maxn];
void Dijkstra(int s)
{
    memset(dist, 0x3f, sizeof(dist));
    priority_queue<PLI, vector<PLI>, greater<PLI> > q;
    dist[s] = 0;
    q.push(make_pair(dist[s], s));
    while(!q.empty())
    {
        int u = q.top().second;
        q.pop();
        if(vis[u])
            continue;
        else
            vis[u] = true;
        for(auto e : g[u])
        {
            int v = e.v, c = e.c;
            if(!vis[v] && dist[u] + c < dist[v])
            {
                dist[v] = dist[u] + c;
                q.push(make_pair(dist[v], v));
            }
        }
    }
}
int main()
{
    scanf("%d %d %d", &N, &M, &S);
    for(int i = 1; i <= M; i++)
    {
        int A, B, U, V;
        scanf("%d %d %d %d", &U, &V, &A, &B);
        for(int j = A; j <= 2500; j++)
        {
            g[id(U, j)].push_back(edge{id(V, j - A), B});
            g[id(V, j)].push_back(edge{id(U, j - A), B});
        }
    }
    for(int i = 1; i <= N; i++)
    {
        int C, D;
        scanf("%d %d", &C, &D);
        for(int j = 0; j < C; j++)
            for(int k = j + C; k <= 2500; k += C)
                g[id(i, k - C)].push_back(edge{id(i, k), D});
    }
    Dijkstra(id(1, min(S, 2500)));
    for(int i = 2; i <= N; i++)
    {
        LL ans = LINF;
        for(int j = 0; j <= 2500; j++)
            ans = min(ans, dist[id(i, j)]);
        printf("%lld\n", ans);
    }
    return 0;
}


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

long long func(long long n){
    return ((n==1)? n:n*func(n-1));
}

int main(){
    long long N;
    cin >> N;
    //vector<vector<int>> P(N,vector<int>(func(N)+1));
    //vector<vector<int>> Q(N,vector<int>(func(N)+1));
    vector<long long> P(N);
    vector<long long> Q(N);
    rep(i,N){
        cin >> P[i];
    }
    rep(i,N){
        cin >> Q[i];
    }
    long long cntP = 0, cntQ = 0;
    
    rep(i,N){
        if(P[i] == 1){
            rep(j,N){
                P[j] -= 1;
            }
            continue;
        }else{
            cntP += (P[i]-1)*func(N-i-1);
            rep(j,N){
                if(P[i] < P[j]){
                    P[j] -= 1;
                }
            }
        }
    }
    rep(i,N){
        if(Q[i] == 1){
            rep(j,N){
                Q[j] -= 1;
            }
            continue;
        }else{
            cntQ += (Q[i]-1)*func(N-i-1);
            rep(j,N){
                if(Q[i] < Q[j]){
                    Q[j] -= 1;
                }
            }
        }
    }
    //cout << cntP << endl;
    //cout << cntQ << endl;
    cout << abs(cntP-cntQ)<< endl;
}



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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    int N,K;
    cin >> N >> K;
    set<int> D;
    REP(_,K) {
        int d;
        cin >> d;
        D.insert(d);
    }

    FOR(val,N,100000) {
        string s = to_string(val);
        bool ok = true;
        for(const auto &it: s) if(D.count(((int)it-'0'))) ok = false;
        if(!ok) continue;
        cout << val << endl;
        return;
    }
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3672
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }


signed main()
{
	int a, b;
	cin >> a >> b;

	int ans = a - 1;
	if (b >= a) ans++;

	cout << ans << endl;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int l, r, c = 2018;
  cin >> l >> r;
  
  
  if( (r - l) > 2018) c = 0;
  l = l % 2019; r = r % 2019;
  
  for(int i = l; i < r ; i++){
    for(int j = i + 1; j < r + 1; j++){
      c = min(c, i * j % 2019);
    }
  }
  cout << c  << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define x first
#define y second
#define loop(i, start, end) for(int i=start; i<=end; ++i)
#define loopr(i, end, start) for(int i=end; i>=start; --i)
#define pb push_back
#define MOD 1000000007
#define mod(a) (a%MOD + MOD)%MOD
using namespace std;

template <typename T>
void inputArray(T *a, int start, int end) {
    loop(i, start, end) cin >> a[i];
}

template <typename T>
void printArray(T *a, int start, int end) {
    loop(i, start, end) cout << *(a+i) << ' ';
}

void ruffleSort(int *a, int n) {
    unsigned seed=0;
    shuffle(a, a+n, default_random_engine(seed));
    sort(a, a+n);
}

int main() {   
    IOS;
	int n;
    cin >> n;
    int d1[n], d2[n];
    loop(i, 0, n-1) {
        cin >> d1[i];
        cin >> d2[i];
    }
    int cnt=0;
    loop(i, 0, n-1) {
        if(d1[i]==d2[i]) ++cnt;
        else cnt=0;
        if(cnt>=3) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    //cerr << " Execution : " << (1.0*clock())/CLOCKS_PER_SEC << "s" << endl;
    return 0;
}

Measured memory_bytes: 3652
import re
S=input()
m=re.findall('(R+L+)',S)
A=[]
for s in m:
    r=len(s.split('L')[0])
    A.append((r,len(s)-r))
res=[]
for l,r in A:
    L=(l+1)//2+r//2
    R=l//2+(r+1)//2
    res+=[0]*(l-1)+[L,R]+[0]*(r-1)
print(*res)

Measured memory_bytes: 92764
/**
        	C++14 (GCC 5.4.1)
**/
#include <iostream>
using namespace std;

int main(){
    long long H, W, A, B;

    cin >> H >> W >> A >> B;

    for(long long i = 0 ; i < H ; i++){
        for(long long j = 0 ; j < W ; j++){
            if((i < B && j < A )||(i >= B && j >= A) ){
                cout << 1 ;
            }
            else {
                cout << 0 ;
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
n,m=map(int,input().split())
mod=10**9+7
a=[0]*(n+1)
dp=[0]*(n+1)
dp[0]=1
for i in range(m):
    a[int(input())]=1
    
if a[1]==1:
    dp[1]=0
else:
    dp[1]=1
    
for j in range(2,n+1):
    if a[j]==0:
        dp[j]=dp[j-1]+dp[j-2] 
                  
print(dp[n]%mod)            

    
    


Measured memory_bytes: 460788
import math
n = int(input())

ans = float('inf')
#nの公約数を求める。そのルートに近しいものが答え
for i in range(1,math.floor(n**0.5)+1):
    if n%i==0:
        tmp = i+n//i-2
        if tmp<ans:
            ans=tmp
print(ans)

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

int main(){
    ll a,b;
    cin >> a >> b;
    vector<ll> a_prime;
    a_prime.push_back(1);
    ll c=a;
    for(ll i=2; i*i<=a; i++){
        if(c%i == 0){
            a_prime.push_back(i);
            while(c%i==0){
                c  /= i;
            }
        }
    }
    if(c != 1){
        a_prime.push_back(c);
    }
    int count=0;
    for(int i=0; i<a_prime.size(); i++){
        ll k=a_prime.at(i);
        if(b%k==0) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3532
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
if a1*t1+a2*t2>=b1*t1+b2*t2:
    a1,a2,b1,b2 = b1,b2,a1,a2
d = b1*t1+b2*t2 - (a1*t1+a2*t2)
if d == 0:
    print('infinity')

elif a1*t1<b1*t1:
    print(0)
else:
    if (a1*t1 - b1*t1)*2%d ==0:
        print(((a1*t1 - b1*t1)*2+d-1)//d)
    else:
        print((a1*t1 - b1*t1)//d*2+1)


Measured memory_bytes: 3064
# 解説を見た
# よく理解していない

def main():
    n = int(input())
    s = input()
    q = int(input())
    *ks, = map(int, input().split())

    for k in ks:
        cnt = 0
        d, m, dm = 0, 0, 0
        for i in range(k):
            char = s[i]
            if char == 'D':
                d += 1
            elif char == 'M':
                m += 1
                dm += d
            elif char == 'C':
                cnt += dm

        for i in range(k, n):
            p_char = s[i - k]
            char = s[i]
            if p_char == 'D':
                dm -= m
                d -= 1
            elif p_char == 'M':
                m -= 1

            if char == 'D':
                d += 1
            elif char == 'M':
                m += 1
                dm += d
            elif char == 'C':
                cnt += dm

        print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 55564
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int N, M;
  scanf("%d",&N);
  scanf("%d",&M);
  std::vector<int > L(M), R(M);
  for (int i=0; i<M; i++){
    scanf("%d",&L[i]);
    scanf("%d",&R[i]);
  }
  int start = 1;
  int end = N;
  for (int i=0; i<M; i++){
    start = std::max(start,L[i]);
    end = std::min(end, R[i]);
  }
  int ans = std::max(end-start+1,0);
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 1024
#[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 ( 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 ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: u64, d: u64
    }

    let x = d * 2 + 1;
    println!("{}", ceil_div(n, x));
}

#[allow(dead_code)]
fn ceil_div(x: u64, y: u64) -> u64 {
    (x + y - 1) / y
}

Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
"""
Sugoroku and Pieces
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0653

"""
import sys


class Piece:
    def __init__(self, pos):
        self.pos = pos


def main(args):
    _ = input()                 #  N
    board = [None] * 2020
    pieces = [Piece(0)]
    for p in map(int, input().split()):
        x = Piece(p)
        board[p] = x
        pieces.append(x)
    _ = input()                 #  M
    for p in map(int, input().split()):
        if pieces[p].pos == 2019 or board[pieces[p].pos + 1] != None:
            continue
        pos = pieces[p].pos
        pieces[p].pos += 1
        board[pos] = None
        board[pos + 1] = pieces[p]
    for p in pieces[1:]:
        print(p.pos)


if __name__ == '__main__':
    main(sys.argv[1:])



Measured memory_bytes: 5632
#include <iostream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

void visit_dfs(vector<int> *c, vector<bool> &visit, int start = 0) {
  visit[start] = 0;
  stack<int> s;
  s.push(start);
  visit[start] = true;
  while (!s.empty()) {
    int current = s.top();
    s.pop();
    for (const auto &e : c[current])
      if (!visit[e]) {
        s.push(e);
        visit[e] = true;
      }
  }
}

int main(int argc, char const *argv[]) {
  int n, m;
  int ans = 0;
  cin >> n >> m;
  vector<int> *c = new vector<int>[n];
  vector<bool> visit(n, false);

  for (int i = 0; i < m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    c[x].push_back(y);
    c[y].push_back(x);
  }

  for (int i = 0; i < n; i++) {
    if (!visit[i]) {
      ans++;
      visit_dfs(c, visit, i);
    }
  }
  
  cout << ans << endl;

  return 0;
}


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

const int SIZE=30000;
int main(){
    vector<int> v2,v3,v6;
    for(int i=1;i<=SIZE;i++){
        if(i%2==0 && i%3==0){
            v6.push_back(i);
        }
        else if(i%2==0){
            v2.push_back(i);
        }else if(i%3==0){
            v3.push_back(i);
        }
    }
    int n;
    cin>>n;
    if(n==3){
        cout<<"2 5 63"<<endl;
        return 0;
    }
    vector<int> ans;
    for(int i=0;i<v2.size()/2 && n>3;i++){
        ans.push_back(v2[i*2]);
        ans.push_back(v2[i*2+1]);
        n-=2;
    }
    for(int i=0;i<v3.size()/2 && n>1;i++){
        ans.push_back(v3[i*2]);
        ans.push_back(v3[i*2+1]);
        n-=2;
    }
    for(int i=0;i<v6.size() && n>0;i++){
        ans.push_back(v6[i]);
        n--;
    }
    for(int i=0;i<ans.size();i++) cout<<ans[i]<<(i==ans.size()-1 ? '\n' : ' ');
    return 0;
}

Measured memory_bytes: 640
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    string S;
    cin >> S;
    if(N%2==1) cout << "No" << endl;
    else{
        ll half = N /2;
        if(S.substr(0,half)==S.substr(half,half)){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }




    }

}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define ll long long
#define N 100010
using namespace std;
int n,a[N],k,ans;
int dfn[N],size[N],tot,fk[N],sonk[N],f[N],dep[N];
int s[N],cnt;
int t[N<<2];
struct member
{
	int x;
};
bool operator <(const member &x,const member &y)
{
	return dep[x.x]<dep[y.x];
}
priority_queue<member> qx;
struct node
{
	int num,next;
}mp[N];
void init(int x,int y)
{
	mp[++cnt].next=s[x];
	mp[cnt].num=y;
	s[x]=cnt;
}
void dfs(int x,int fa,int d)
{
	f[x]=fa;
	size[x]=1;
	dep[x]=d;
	dfn[x]=++tot;
	if(d==k)fk[x]=sonk[1];
	if(d>k)fk[x]=sonk[fk[fa]];
	int tx=0;
	for(int i=s[x];i;i=mp[i].next)
	{
		tx=1;
		int y=mp[i].num;
		sonk[x]=y;
		dfs(y,x,d+1);
		size[x]+=size[y];
	}
	if(!tx&&d>k)
	{
		member z;
		z.x=x;
		qx.push(z);
	}
}
void change(int x,int lx,int rx,int l,int r)
{
	if(l<=lx&&rx<=r)
	{
		t[x]=1;
		return;
	}
	int mid=(lx+rx)>>1;
	if(l<=mid)change(x<<1,lx,mid,l,r);
	if(mid<r)change(x<<1|1,mid+1,rx,l,r);
}
int ask(int x,int lx,int rx,int p)
{
	if(t[x]||lx==rx)return t[x];
	int mid=(lx+rx)>>1;
	if(p<=mid)return ask(x<<1,lx,mid,p);
	else return ask(x<<1|1,mid+1,rx,p);
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(i>1)init(a[i],i);
	}
	if(a[1]!=1)++ans,a[1]=1;
	dfs(1,1,0);
	while(qx.size())
	{
		member z=qx.top();
		qx.pop();
		int x=z.x;
		if(!ask(1,1,n,dfn[x]))
		{
			x=fk[x];
			++ans;
			change(1,1,n,dfn[x],dfn[x]+size[x]-1);
			x=f[x];
			if(dep[x]>k)
			{
				z.x=x;
				qx.push(z);
			}
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
vll Zalgo(const string &s){
   ll n=s.size();;
   vll ret(n,0);
   ret[0]=n;
   ll cmpbeg=1;
   ll same=0;
   while(cmpbeg<n){
       while(same+cmpbeg<n&&s[same]==s[same+cmpbeg])same++;
       ret[cmpbeg]=same;
       if(same==0){
           cmpbeg++;
           continue;
       }
       ll cpyfrom=1;
       while(cpyfrom+cmpbeg<n&&ret[cpyfrom]+cpyfrom<same){
           ret[cmpbeg+cpyfrom]=ret[cpyfrom];
           cpyfrom++;
       }
       cmpbeg+=cpyfrom;
       same-=cpyfrom;
   }
   return ret;
}
int main( ){
    int n;
    cin>>n;
    string s;
    cin>>s;
    ll res=0;
    rep(i,0,n){
        string t=s.substr(i);
        vll lcp=Zalgo(t);
        rep(j,0,t.size()){
            chmax(res,min(j,lcp[j]));
        }
    }
    cout<<res<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define MAX 100
vector<int> p;
vector<bool> p_table(MAX+1,true);
void prime(){
  p_table.at(0)=false,p_table.at(1)=false;
  for(int i=2;i<=MAX;i++){
    if(p_table.at(i)){
      p.push_back(i);
      for(int j=2;i*j<=MAX;j++){
        p_table.at(i*j)=false;
      }
    }
  }
}

int main(){
  int N;
  cin>>N;
  prime();
  int n=p.size();
  vector<int> p_count(n,0);
  for(int i=2;i<=N;i++){
    int k=0;
    int j=i;
    while(j>1){
      if(j%p.at(k)==0){
        p_count.at(k)++;
        j/=p.at(k);
      }else{
        k++;
      }
    }
  }
  sort(p_count.begin(),p_count.end());
  int k74=lower_bound(p_count.begin(),p_count.end(),74)-p_count.begin();
  int k24=lower_bound(p_count.begin(),p_count.end(),24)-p_count.begin();
  int k2=lower_bound(p_count.begin(),p_count.end(),2)-p_count.begin();
  int k14=lower_bound(p_count.begin(),p_count.end(),14)-p_count.begin();
  int k4=lower_bound(p_count.begin(),p_count.end(),4)-p_count.begin();

  int ans=0;
  ans+=n-k74;
  ans+=(n-k24)*(n-k2-1);
  ans+=(n-k14)*(n-k4-1);
  ans+=(n-k4)*(n-k4-1)/2*(n-k2-2);
  cout<<ans<<endl;
}


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

int main()
{	int W,H,x,y,r;
	cin >> W;
	cin >> H;
	cin >> x;
	cin >> y;
	cin >> r;

	if(y-r>=0&&y+r<=H&&x-r>=0&&x+r<=W){
	cout<<"Yes"<<endl;
}
	else
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
const int maxn=1e5+7;
int main()
{
    int A,B,m,x,y,c;
    cin>>A>>B>>m;
    int b[maxn],a[maxn],p1[maxn],p2[maxn];
    int ans;
    for(int i=1;i<=A;i++)
    {
        cin>>a[i];
        p1[i]=a[i];
    }
    for(int i=1;i<=B;i++){
        cin>>b[i];
        p2[i]=b[i];
    }
    sort(p1+1,p1+A+1);
    sort(p2+1,p2+B+1);
    ans=p1[1]+p2[1];
    for(int i=0;i<m;i++){
        cin>>x>>y>>c;
        ans=min(ans,a[x]+b[y]-c);
    }
   cout<<ans;
    return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int cnt[MAXN];

void solve(){
	REP(i, 0, 4) {
		int a;
		cin >> a;
		cnt[a]++;
	}
	if (cnt[1] == 1 && cnt[4] == 1 && cnt[9] == 1 && cnt[7] == 1) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

int main(){
	int i,n,a,b,p[101],c1=0,c2=0,c3=0;
  	cin>>n>>a>>b;
  	for(i=0;i<n;i++){
	cin>>p[i];
      if(p[i]<=a){
		c1++;
      }else if(p[i]>b){
		c3++;
      }else{
		c2++;
      }
    }
  
  	cout << min({c1,c2,c3}) << endl;
}
  	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;
    cin >> n;
    vector<ll> b(n);
    for (ll i = 0; i < n; i++) cin >> b[i];
    stack<ll> ans;
    for (ll t = 0; t < n;t++) {
        ll k = b.size();
        for (ll i = k - 1; i >= 0; i--) {
            if (b[i] == i+1) {
                ans.push(b[i]);
                b.erase(b.begin() + i);
                break;
            }
        }
    }
    if(ans.size()!=n){
        cout << -1 << endl;
    }
    else{
        while(!ans.empty()){
            cout << ans.top() << endl;
            ans.pop();
        }
    }
}

Measured memory_bytes: 3560
N = int(input())
A = list(map(int, input().split()))

I = [i+a for i,a in enumerate(A, start=1)]
J = [i-a for i,a in enumerate(A, start=1)]
#print(I, J)

dic = {}
ans = 0

for i in range(N):
    if I[i] in dic:
        dic[I[i]] += 1
    else:
        dic[I[i]] = 1
    if J[i] in dic:
        ans += dic[J[i]]


#print(dic)
print(ans)


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

const int LEF=0;
const int RIG=1;
const int UNTOUCH=1e8;
struct State{
  pair<int,int> lef;
  pair<int,int> rig;
  int next;
};

bool operator<(State lhs,State rhs){
  if(lhs.lef!=rhs.lef) return lhs.lef>rhs.lef;
  if(lhs.rig!=rhs.rig) return lhs.rig>rhs.rig;
  return lhs.next>rhs.next;
}


int main(){
  int w,h;
  while(cin>>w>>h,w){
    vector<vector<char>> buf(h,vector<char>(w));
    vector<vector<int>> clif(h,vector<int>(w));
    vector<int> s;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin>>buf[i][j];
	if(buf[i][j]=='X'){
	  clif[i][j]=UNTOUCH;
	}
	else if(buf[i][j]=='S' || buf[i][j]=='T'){
	  clif[i][j]=0;
	  if(buf[i][j]=='S'){
	    s.push_back(j);
	  }
	}
	else{
	  clif[i][j]=buf[i][j]-'0';
	}
      }
    }
    map<State,int> dp;
    priority_queue<pair<int,State>,vector<pair<int,State>>,greater<pair<int,State>>> que;
    for(int i=0;i<s.size();i++){
      State st;
      st.lef=make_pair(h-1,s[i]);
      st.rig=make_pair(h-1,s[i]);
      st.next=LEF;
      dp[st]=0;
      que.push(make_pair(0,st));
      st.next=RIG;
      dp[st]=0;
      que.push(make_pair(0,st));
    }
    const int REACH=3;
    vector<int> dh={2,1,0};
    auto isrange=[&h,&w](int i,int j){return 0<=i && i<h && 0<=j && j<w;};
    bool touchable=false;
    while(!que.empty()){
      auto val=que.top();
      que.pop();
      if(val.first>dp[val.second]) continue;
      State st=val.second;
      if(buf[st.lef.first][st.lef.second]=='T' || buf[st.rig.first][st.rig.second]=='T'){
	touchable=true;
	cout<<val.first<<endl;
	break;
      }
      pair<int,int> pivot=(st.next==LEF ? st.rig :st.lef);
      for(int i=1;i<=REACH;i++){
	for(int j=-dh[i-1];j<=dh[i-1];j++){
	  int toh=j+pivot.first;
	  int tow=i*(st.next==LEF ? -1 : 1)+pivot.second;
	  if(isrange(toh,tow) && clif[toh][tow]!=UNTOUCH){
	    State tos=st;
	    int cost=dp[st]+clif[toh][tow];
	    if(st.next==LEF){
	      tos.lef=make_pair(toh,tow);
	      tos.next=RIG;
	    }
	    else{
	      tos.rig=make_pair(toh,tow);
	      tos.next=LEF;
	    }
	    if(dp.count(tos)){
	      if(dp[tos]>cost){
		dp[tos]=cost;
		que.push(make_pair(cost,tos));
	      }
	    }
	    else{
	      dp[tos]=cost;
	      que.push(make_pair(cost,tos));
	    }
	  }
	}
      }

      
    }
    if(!touchable) cout<<-1<<endl;
    
  }

}

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

using namespace std;


int main(void) {
	int x,res,rest,T,D,L;
	while (cin >> T >> D >> L,T,D,L) {
		res = rest = 0;
		for (int i = 0; i < T; ++i) {
			cin >> x;
			if (i < T-1) {
				if (x >= L) {
					rest = D;
				}
				else {
					--rest;
				}
				if (rest > 0) {
					++res;
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}



Measured memory_bytes: 3084
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    s = input()
    MOD = 10 ** 9 + 7
    
    dp = [[0] * N for _ in range(N)]
    acc = [i for i in range(1, N + 1)]
    
    for i in range(1, N):
        for j in range(N - i + 1):
            if s[i - 1] == '<':
                dp[i][j] = (acc[N - i] - acc[j]) % MOD
            else:
                dp[i][j] = acc[j]
        acc[0] = dp[i][0]
        for j in range(1, N):
            acc[j] = (acc[j - 1] + dp[i][j]) % MOD
    print(dp[-1][0])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 111964
#include "iostream"
#include "cmath"
#include "iomanip"
using namespace std;

int main(int argc, char const *argv[])
{
	int n=0;
	double m=0;
	double ans=0;
	while(true)
	{
		m=0;
		ans=0;
		cin >> n;
		if (n == 0)
		{
			break;
		}
		int s[n];
		for(int i=0; i<n; i++)
		{
			cin >> s[i];
			m += s[i];
		}
		m /= n;

		for(int i=0; i<n; i++)
		{
			ans += pow(s[i]-m, 2);
		}
		ans /= n;
		ans = sqrt(ans);
		cout << fixed <<setprecision(10) << ans << endl;
	}

	return 0;
}


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

typedef long long ll;

int n,a[85];
ll dp[85];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    dp[1]=1000;
    for(int i=1;i<n;i++){
        dp[i+1]=max(dp[i],dp[i]/a[i]*a[i+1]+dp[i]%a[i]);
    }
    cout<<dp[n]<<endl;

    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()) {
			int n = scan.nextInt();
			// 入力が0以下なら終了する。
			if(n < 1) break;

			// 入力がいくつ来るか事前にわかっているので、配列を用意して入れる。
			int[] a = new int[n];
			for(int i = 0; i < n; i++) {
				a[i] = scan.nextInt();
			}

			// i番目の要素までの合計値をsum[i]に入れる。
			int[] sum = new int[n];
			sum[0] = a[0];
			for(int i = 1; i < n; i++) {
				sum[i] = a[i] + sum[i - 1];
			}

			// 問題で求める最大値をmaxに入れるために、Integer.MIN_VALUE（intで格納できる値で一番小さい値）で初期化する。
			int max = Integer.MIN_VALUE;

			// j番目からi番目までの合計はsum[i] - sum[j]で求まるので、これとmaxを比較してmaxのほうが小さいならば更新する。
			for(int i = 0; i < n; i++) {
				max = max > sum[i] ? max : sum[i];
				for(int j = 0; j < i; j++) {
					max = max > sum[i] - sum[j] ? max : sum[i] - sum[j];
				}
			}
			System.out.println(max);
		}

		scan.close();
	}

}



Measured memory_bytes: 36136
#include <stdio.h>

int main(void)
{
	long long int a, b;
	scanf("%lld %lld", &a, &b);
	if(a * b < 0 || a * b == 0){
		printf("Zero\n");
		return 0;
	}else if((a < 0 && b < 0) && (b - a) % 2 == 0){
		printf("Negative\n");
		return 0;
	}
	printf("Positive\n");
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 998244353;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}



int main(void) {

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

  if (x > y) {
    int tmp = x;
    x = y;
    y = tmp;
  }

  for (int k = 1; k <= n - 1; k++) {
    int ans;
    if (y - x + 1 - k > k) ans = y - x + 1;
    else if (y - x + 1 - k == k) ans = k;
    else ans = 0;
    for (int t = 1; t <= x - 1; t++) {
      if (k - t <= 0) ans += 1;
      if (k - t > 0 && y - x + 1 - (k - t) > k - t) ans += 2;
      if (k - t > 0 && y - x + 1 - (k - t) == k - t) ans += 1;
      //if (1 <= k - t && k - t <= (y - x)/2) ans += 2;
      if (k - t > 0 && y - x + 1 - (k - t) < k - t) ans += 0;

      if (k - t <= 1) ans += 0;
      if (2 <= k - t && k - t - 1 <= n - y) ans += 1;
    }
    for (int t = 1; t <= n - y; t++) {
      if (k - t <= 0) ans += 1;
      if (k - t > 0 && y - x + 1 - (k - t) > k - t) ans += 2;
      if (k - t > 0 && y - x + 1 - (k - t) == k - t) ans += 1;
      //if (1 <= k - t && k - t <= (y - x)/2) ans += 2;
      if (k - t > 0 && y - x + 1 - (k - t) < k - t) ans += 0;

      //if (k - t <= 1) ans += 0;
      //if (2 <= k - t && k - t - 1 <= n - y) ans += 1;
    }
    
    printf("%d\n", ans);
  }
}


Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	int N;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		long H =  nextLong();

		if(H == 1) {
			out.println(1);
			return;
		}

		long cnt = 1;
		long num = H/2;
		while(num > 1) {
			num /= 2;
			cnt *= 2;
			cnt ++;
		}
		if(num == 1) {
			cnt *= 2;
			cnt ++;
			num = 0;
		}
		out.println(cnt);
	}

	static long modpow(long a, long n, long mod) {
	    long res = 1;
	    while (n > 0) {
	        if ((n & 1) != 0) res = res * a % mod;
	        a = a * a % mod;
	        n >>= 1;
	    }
	    return res;
	}
	static long modinv(long a, long mod) {
	    return modpow(a, mod - 2, mod);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}

	long lcm(long m, long n) {
	        return m * n / gcd(m, n);
	}

	private final int[] sizeTable = {
	        9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, Integer.MAX_VALUE
	};

	public int stringSize(int x) {
	    for (int i = 0;; i++)
	        if (x <= sizeTable[i])
	            return i + 1;
	}
}

Measured memory_bytes: 23252
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;

int x[2010],y[2010],pow[2010],sum[2010],n;
int main()
{
    scanf("%d",&n);int i,j;
    for (i=1;i<=n;i++) 
    {
        scanf("%d%d",&x[i],&y[i]);
        sum[i]=abs(x[i]+y[i]);
    }
    for (i=1;i<n;i++)
        if (sum[i]%2!=sum[i+1]%2) {printf("%d",-1);return 0;}
    int maxd=0,cnt=0;
    for (i=1;i<=n;i++) maxd=max(maxd,sum[i]);
    if  (!(sum[1]%2)) {pow[++cnt]=1;maxd--;} 
    int tmp=1;
    while (tmp-1<=maxd) {pow[++cnt]=tmp;tmp*=2;}
    printf("%d\n",cnt);
    for (i=1;i<=cnt;i++) printf("%d ",pow[cnt-i+1]);printf("\n");
    for (i=1;i<=n;i++)
    {
        int fx=x[i],fy=y[i],nx=0,ny=0;
        for (j=cnt;j>=1;j--)
        {
            int chax=fx-nx,chay=fy-ny;
            if (abs(chax)>abs(chay))
            {
                if (chax>0) {printf("R");nx+=pow[j];}
                else {printf("L");nx-=pow[j];}
            }
            else 
            {
                if (chay>0) {printf("U");ny+=pow[j];}
                else {printf("D");ny-=pow[j];}
            }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int inf = 1e9+7;
const int N = 1e6+9;

int main() {
    ios_base::sync_with_stdio(0);
    int a,b,n;
    cin>>n>>a>>b;
    int ok=0;
    if(a%n==0) ok=1;
    else if(b%n==0) ok=1;
    else {
        int p = a/n;
        if((p+1)*n<=b) ok=1;
    }
    if(ok) cout<<"OK\n";
    else cout<<"NG\n";
    return 0;
}

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

int main() {
	ll a, b, c;
	ll k;
	cin >> a >> b >> c >> k;
	if (k <= a)cout << k << endl;
	else if (k <= a + b)cout << a << endl;
	else cout << a - (k - (a + b)) << endl;
}


Measured memory_bytes: 3636
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int x = sc.nextInt();
        _out.println((x < 1200 ? "ABC" : "ARC"));
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 21844
void main(){
	int a, b;
	scanf("%d %d", &a, &b);
	double ans = (a+b)/2.to!double;
	ans.round().writeln();
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


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

signed main(void)
{
	int n, k;
	cin >> n >> k;
	if (n >= k * 2 - 1)
	cout << "YES" << endl;
	else
	cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k == x:
                cnt += 1
print(cnt)

Measured memory_bytes: 3060
n, m = map(int, input().split())
ac = [0] * n
wa = [0] * n

for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC':
        ac[p] += 1
    elif s == 'WA':
        if ac[p] == 0:
            wa[p] += 1

for i in range(n):
    if ac[i] == 0:
        wa[i] = 0

ac = sum([item>0 for item in ac])
wa = sum(wa)
print(ac, wa)

Measured memory_bytes: 5528
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int inf=1<<29;
const ll Maxn=1e6;
const double pi=3.1415926536;

string t=" abcdefghijklmnopqrstuvwxyz";
char s[Maxn];

int main(){
	ll k;
	int m;
	scanf("%s",s);
	scanf("%lld",&k);
	int len=strlen(s);
	int j=len-1;
	for(int i=0;i<len-1;i++){
		if(s[i]=='a') m=0;
		else m='z'-s[i]+1;
		k-=m;
		if(k>=0) s[i]='a';
		else k+=m;
	}
	k%=26;
	if(k>'z'-s[j]) s[j]=t[k-('z'-s[j])];
	else s[j]=t[s[j]-'a'+k+1];
	printf("%s\n",s);
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var raw = ReadLine().Split().Select(int.Parse).ToArray();
            var N = raw[0];
            var M = raw[1];

            var K = new int[N];
            var A = new int[N][];
            for (int i = 0; i < N; i++)
            {
                raw = ReadLine().Split().Select(int.Parse).ToArray();
                K[i] = raw[0];
                A[i] = new int[K[i]];
                A[i] = raw.Skip(1).ToArray();
            }

            var like = new int[M];
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < M; j++)
                {
                    if (A[i].Contains(j + 1)) like[j]++;
                }
            }

            var ans = 0;
            for (int i = 0; i < M; i++)
            {
                if (like[i] == N) ans++; 
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13524
import sys
input = sys.stdin.readline
O = list(input().rstrip())
E = list(input().rstrip())
if len(O) == len(E):
    ans = []
    for i, j in zip(O, E):
        ans.append(i)
        ans.append(j)
else:
    ans = [O.pop(0)]
    for i, j in zip(O, E):
        ans.append(j)
        ans.append(i)
print("".join(ans))


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
	string s,str;
	cin>>s;
	for(int i=0;i<s.size();++i){
		char tmp=s[i]-3;
		str+=(char)((tmp>='A')?tmp:tmp+26);
	}
	cout<<str<<endl;
	return 0;
}

Measured memory_bytes: 1180
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define swap(p,q) r=(p);(p)=(q);(q)=r
#define INF 1000000000000//10^12
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007

using namespace std;


//void型なので返り値は無し　d[]に結果が格納されるので欲しいものをansに
int main(void)
{
	//変数の宣言
	int n;
	int x[1010];
	int y[1010];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;
	int ok,ng;



	//データの読み込み


	scanf("%d",&n);
//	scanf_s("%d",&n);


	for(i=0;i<n;i++){
		scanf("%d %d",&x[i],&y[i]);
//		scanf_s("%d %d",&x[i],&y[i]);
	}

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	for(i=0;i<n;i++){
		if(i==0){
			flag=(x[0]+y[0])%2;
		}else{
			if((flag+x[i]+y[i])%2!=0){
				printf("-1");
				return 0;
			}
		}
	}
	
	max=1;
	for(i=0;i<30;i++){
		max=max*2;
	}

	if(flag==0){
		printf("32\n");
		temp=max;
		for(i=0;i<32;i++){
			printf("%d",temp);
			if(i!=31) printf(" ");
			if(temp!=1)temp=temp/2;
		}
		printf("\n");

		for(i=0;i<n;i++){
			temp=max;
			temp1=x[i];
			temp2=y[i];
			for(j=0;j<32;j++){
				if(abs(temp1)>=abs(temp2)){
					if(temp1>0){
						printf("R");
						temp1=temp1-temp;
					}else{
						printf("L");
						temp1=temp1+temp;
					}
				}else{
					if(temp2>0){
						printf("U");
						temp2=temp2-temp;
					}else{
						printf("D");
						temp2=temp2+temp;
					}
				}
				if(temp!=1)temp=temp/2;
			}
			printf("\n");
		}
	}else{
		printf("33\n");
		temp=max;
		for(i=0;i<33;i++){
			printf("%d",temp);
			if(i!=32) printf(" ");
			if(temp!=1)temp=temp/2;
		}
		printf("\n");

		for(i=0;i<n;i++){
			temp=max;
			temp1=x[i];
			temp2=y[i];
			for(j=0;j<33;j++){
				if(abs(temp1)>=abs(temp2)){
					if(temp1>0){
						printf("R");
						temp1=temp1-temp;
					}else{
						printf("L");
						temp1=temp1+temp;
					}
				}else{
					if(temp2>0){
						printf("U");
						temp2=temp2-temp;
					}else{
						printf("D");
						temp2=temp2+temp;
					}
				}
				if(temp!=1)temp=temp/2;
			}
			printf("\n");
		}
	}


	//	printf("計算部分終了\n");

	//出力
	
	//printf("%lld",dp[n]);

	//	printf("結果の出力終了\n");


	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n+1]={0};
  int x;
  for(int i=1;i<n;i++){
    cin>>x;
    a[x]++;
  }
  for(int i=1;i<=n;i++)
    cout<<a[i]<<" ";
}

Measured memory_bytes: 4348
S = input()

if S[0]=='R':
    if S[1]=='R':
        if S[2]=='R':
            print(3)
            exit()
if S[0]=='R':
    if S[1]=='R':
        if S[2]!='R':
            print(2)
            exit()
if S[0]!='R':
    if S[1]=='R':
        if S[2]=='R':
            print(2)
            exit()
if 'R' in S:
    print(1)
else:
    print(0)
    


Measured memory_bytes: 8964
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

void func(){
    int n=in();
    ll ans=0;
    vector<priority_queue<pii>> que(2);
    rep(i,n){
        int k=in()-1,l=in(),r=in();
        if(l > r){
            ans += r;
            l -= r;
            que[0].push(mp(-k,l));
        }else{
            ans += l;
            r -= l;
            que[1].push(mp(-(n-k-2),r));
        }
    }
    rep(x,2){
        rep(i,n){
            while(!que[x].empty() && -que[x].top().first < i){
              //  cout<<"##"<<i<<" "<<-que[x].top().first<<" "<<que[x].top().second<<endl;
                que[x].pop();
            }
            if(!que[x].empty()){
                ans += que[x].top().second;
               // cout<<i<<" "<<-que[x].top().first<<" "<<que[x].top().second<<endl;
                que[x].pop();
            }
        }
    }
    cout<<ans<<endl;
}

/*int main(){
    int N=in();
    for(int n=1;n<=N;n++){
        int ans=0;
        for(int a=2;a*a<n*2;a++){
            for(int b=a;b*b<n*2;b++){
                int x = sqrt(n*2 - a*a - b*b);
                if(x >= b && a + b > x && x*x + a*a + b*b == 2*n && (a+b+x)%2==0){
                    if(a==b){
                        if(b==x)ans++;
                        else ans+=3;
                    }
                    else if(b==x)ans += 3;
                    else ans += 6;
                }
            }
        }
        cout<<ans<<endl;
    }
}*/
int main(){
    int l=in()-1,r=in(),d=in();
    cout<<r/d-l/d<<endl;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e3 + 5);
const int MAX_H = (int)(1e4 + 5);

int h, n;

int a[MAX_N], b[MAX_N];

ll dp[MAX_H];

int main(void) {
  // Here your code !
  scanf("%d %d", &h, &n);

  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &(a[i]), &(b[i]));
  }

  for (int j = 0; j <= h; ++j) {
    dp[j] = INF;
  }

  dp[0] = 0LL;

  for (int j = 0; j <= h; ++j) {
    for (int i = 0; i < n; ++i) {
      int target_index = j + a[i];
      target_index = target_index >= h ? h : target_index;

      dp[target_index] = min(dp[target_index], dp[j] + b[i]);
    }
  }

  ll ans = dp[h];

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

  return 0;
}


Measured memory_bytes: 384