akhauriyash/Code-Regression huggingface dataset:
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
 
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
#define setpr(x) cout << setprecision((x))
#define PI atan(1)*4
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define in insert
#define er erase
#define mk(a , b) { min((a) , (b)) , max((a) , (b)) }
#define flush cout.flush()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endc "\n"
#define MOD 998244353
#define mod(x) (x) %= MOD
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

// #define int ll
 
ll gcd(ll a, ll b){
    while(true){
        if(a>b)
            swap(a,b);
        if (a == 0) 
            return b; 
        ll p = b % a  , q = a;
        a = p;
        b = q;
    }
}
 
ll powerMod(ll x,ll y){
    ll res = 1;
    x %= MOD;
    while(y > 0){
        if(y & 1)res = (res*x)%MOD;
        y = y >> 1;
        x = (x * x)%MOD;
    }
    return res%MOD;
}
 
string binary(ll s) {
    string res = "";
    while(s != 0) {
        res += (char)('0' + s % 2);
        s /= 2;
    }
    reverse(res.begin() , res.end());
    return res;
}


//  =========     /\       /|    |====/|
//      |        /  \       |    |   / |
//      |       /____\      |    |  /  |
//      |      /      \     |    | /   |
//  ========= /        \  =====  |/====|  
//  code

int32_t main(){
    init;
    int n,m,i,j,k,l,p,x;
    cin >> n >> m >> x;
    vector<int> price(n);
    vector< vector<int> >a(n , vector<int>(m));

    for(i = 0; i < n; i++){
        cin >> price[i];
        for(j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }

    int ans = INT_MAX;
    for(i = 0; i < 1 << n; i++){
        int pr = 0;
        vector<int> pp(m , 0);
        for(j = 0; j < 32; j++){
            if(i & (1 << j)){
                // cout << i << " " << (1 << j) << endc;
                pr += price[j];
                for(k = 0; k < m; k++){
                    pp[k] += a[j][k];
                }
            }
        }

        for(auto i : pp){
            if(i < x)goto end;
        }
        ans = min(ans , pr);
        end:;
    }

    if(ans == INT_MAX)cout << -1 << endc;
    else cout << ans << endc;
    return 0;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  set<string> S;
  REP(i, N) {
    string s;
    cin >> s;
    S.insert(s);
  }
  cout << S.size() << endl;

  return 0;
}


Measured memory_bytes: 19196
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;	
	int d = abs(a - b);
	if(v <= w) {
		if(d != 0) cout << "NO" << endl;
		else cout << "YES" << endl;
	} else {
		v -= w;
		if(d <= v * t) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

}





Measured memory_bytes: 3652
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=57;
LL d[N][N*N],lazy[N][N*N],n,a,c;
int main(){
    scanf("%lld%lld",&n,&a);
    memset(d,0,sizeof(d));
    memset(lazy,0,sizeof(lazy));
    for(int i=1;i<=n;i++){
        scanf("%lld",&c);
        for(int j=1;j<i;j++)
        for(int k=1;k<N*N;k++)
        if(d[j][k]){
            lazy[j+1][k+c]+=d[j][k];
        }
        for(int j=1;j<=i;j++)
        for(int k=1;k<N*N;k++)
        if(lazy[j][k]){
            d[j][k]+=lazy[j][k];
            lazy[j][k]=0;
        }
        d[1][c]++;
    }
    LL ans=0;
    for(int i=1;i<=n;i++)
        ans+=d[i][i*a];
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3200
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

template < class BidirectionalIterator >
bool next_combination(BidirectionalIterator first1,
	BidirectionalIterator last1,
	BidirectionalIterator first2,
	BidirectionalIterator last2)
{
	if ((first1 == last1) || (first2 == last2)) {
		return false;
	}
	BidirectionalIterator m1 = last1;
	BidirectionalIterator m2 = last2; --m2;
	while (--m1 != first1 && !(*m1 < *m2)) {
	}
	bool result = (m1 == first1) && !(*first1 < *m2);
	if (!result) {
		// ???
		while (first2 != m2 && !(*m1 < *first2)) {
			++first2;
		}
		first1 = m1;
		std::iter_swap(first1, first2);
		++first1;
		++first2;
	}
	if ((first1 != last1) && (first2 != last2)) {
		// ???
		m1 = last1; m2 = first2;
		while ((m1 != first1) && (m2 != last2)) {
			std::iter_swap(--m1, m2);
			++m2;
		}
		// ??¢
		std::reverse(first1, m1);
		std::reverse(first1, last1);
		std::reverse(m2, last2);
		std::reverse(first2, last2);
	}
	return !result;
}

template < class BidirectionalIterator >
bool next_combination(BidirectionalIterator first,
	BidirectionalIterator middle,
	BidirectionalIterator last)
{
	return next_combination(first, middle, middle, last);
}

int main() {
	while (1) {
		int N; cin >> N; int K; cin >> K;
		if (!N)break;
		vector<string>sts;
		for (int i = 0; i < N; ++i) {
			string st; cin >> st;
			sts.emplace_back(st);
		}
		vector<int>nums(N);
		iota(nums.begin(), nums.end(), 0);
		set<string>anss;
		do {
			vector<int>anums(K);
			iota(anums.begin(), anums.end(), 0);
			do {
				string ans;
				for (int i = 0; i < K; ++i) {
					ans += sts[nums[anums[i]]];
				}
				anss.emplace(ans);
			} while (next_permutation(anums.begin(), anums.end()));
		} while (next_combination(nums.begin(),nums.begin()+K, nums.end()));
		cout << anss.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 3272
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>

#define rep(i, e) for(int i = 0; i < e; i++)
#define repp(i, s, e) for(int i = s; i < e; i++)
#define N_Max 100
#define Card_Max 36
#define p(a) printf("%d\n", a);
#define ll long long
#define MAX 100005
#define NIL -1

using namespace std;

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

const long long INF = 1LL << 60;

int main() {
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if(a1 + a2 + a3 >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define N 10000000
ll primes[N];

//int seive()
//{
//	ll i,j,t=0,sq;
//	bool flag[N];
//	for(i=2;i<=N;i++) flag[i]=1;
//	sq=sqrt(N)+1;
//	for(i=2;i<sq;i++)
//		if(flag[i])
//			for(j=i;j*i<=N;j++)
//				flag[i*j]=0;
//	for(i=2;i<=N;i++)
//		if(flag[i])
//			primes[t++]=i;
//	return t;
//}

//     for(i=0;i<n;i++)
//     for(j=0;j<n;j++)

//int GCD(ll a, ll b)
//{
//    if(a==0)return b;
//    if(b==0)return a;
//    else return GCD(b,a%b);
//}




int main()
{
    ll i,j,k,m,n,q,t,c=0;
    cin>>n;
    ll a[n],b[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    for(i=0;i<n;i++)
    {
        if(a[i]!=b[i])c++;
    }
    if(c<=2)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}


Measured memory_bytes: 256
s = input()
s = s[::-1]
while s:
    if s[:5]=='maerd':
        s = s[5:]
    elif s[:7] =='remaerd':
        s = s[7:]
    elif s[:5] =='esare':
        s = s[5:]
    elif s[:6] =='resare':
        s = s[6:]
    else:
        print('NO');exit()
print('YES')

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

int main() {
  int n, cn;
  cin >> n >> cn;
  int tmp;
  vector<vector<int> > d(cn, vector<int>(cn));

  for (int i = 0; i < cn; i++) {
    for (int j = 0; j < cn; j++) {
      cin >> tmp;
      d[i][j] = tmp;
    }
  }

  vector<vector<int> > c(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int tmp;
      cin >> tmp;
      c[i][j] = tmp;
    }
  }
  vector<int> dis0s;
  vector<int> dis1s;
  vector<int> dis2s;

  for (int k = 0; k < cn; k++) {
    int dis0 = 0;
    int dis1 = 0;
    int dis2 = 0;

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        int c_be = c[i][j] - 1;  //変わる前の色

        if ((i + 1 + j + 1) % 3 == 0) {
          dis0 += d[c_be][k];
        } else if ((i + 1 + j + 1) % 3 == 1) {
          dis1 += d[c_be][k];
        } else {
          dis2 += d[c_be][k];
        }
      }
    }

    dis0s.push_back(dis0);
    dis1s.push_back(dis1);
    dis2s.push_back(dis2);
  }
  int ans = INF;
  for (int i = 0; i < cn; i++) {
    for (int j = 0; j < cn; j++) {
      for (int k = 0; k < cn; k++) {
        if (i != j && j != k && i != k) {
          ans = min(dis0s[i] + dis1s[j] + dis2s[k], ans);
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
    string str;
    bool flag=true;
    cin >> str;
    for(int i=0;i<3;i++){
        if(str.at(i+1)==str.at(i)){
            flag=false;
            break;
        }
    }
    if(flag) cout << "Good";
    else cout << "Bad";

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        
        if (x-r < 0 || y-r < 0 || x+r > W || y+r > H) {
            System.out.println("No");
        } else {
            System.out.println ("Yes");
        }
    }
}


Measured memory_bytes: 26148
#include<iostream>

using namespace std;

int calcNumOfCombination(int n, int r){
    int num = 1;
    for(int i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}


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

    int sum = 0;

    sum += calcNumOfCombination(N, 2);
    sum += calcNumOfCombination(M, 2);
    
    cout << sum << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

void merge(int A[], int n, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++)
    {
        L[i] = A[left + i];
    }
    for (int i = 0; i < n2; i++)
    {
        R[i] = A[mid + i];
    }
    L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; k++)
    {
        cnt++;
        if (L[i] <= R[j])
        {
            A[k] = L[i++];
        }
        else
        {
            A[k] = R[j++];
        }
    }
}

void mergeSort(int A[], int n, int left, int right)
{
    if (left + 1 < right)
    {
        int mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int main()
{
    int A[MAX], n, i;
    cnt = 0;

    cin >> n;
    for (i = 0; i < n; i++)
    {
        cin >> A[i];
    }

    mergeSort(A, n, 0, n);

    for (i = 0; i < n; i++)
    {
        if (i)
        {
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 6900
#include <cstdio>
using namespace std;
int main(void)
{
  int n, y;
  scanf("%d %d", &n, &y);
  
  for(int i=0; i<=n; i++)
  {
    for(int j=0; j<=n-i; j++)
    {
      for(int k=0; k<=n-i-j; k++)
      {
        if(i*10000 + j*5000 + k*1000 == y && i+j+k == n)
        {
          printf("%d %d %d\n", i, j, k);
          return 0;
        }
      }
    }
  }
  
  printf("-1 -1 -1\n");
  
  return 0;
}

Measured memory_bytes: 128
import collections


def bfs(u, n):
    global level, network
    level = [-1] * n
    deq = collections.deque()
    level[u] = 0
    deq.append(u)
    while deq:
        v = deq.popleft()
        for w, c, l in network[v]:
            if c > 0 and level[w] < 0:
                level[w] = level[v] + 1
                deq.append(w)


def dfs(u, t, f):
    global it, level, network
    if u == t:
        return f
    for i in range(it[u], len(network[u])):
        v, c, l = network[u][i]
        if c <= 0 or level[u] >= level[v]:
            continue
        d = dfs(v, t, min(f, c))
        if d <= 0:
            continue
        network[u][i][1] -= d
        network[v][l][1] += d
        it[u] = i
        return d
    it[u] = len(network[u])
    return 0


def max_flow(s, t, n):
    global it, level
    flow = 0
    while True:
        bfs(s, n)
        if level[t] < 0:
            return flow
        it = [0] * n
        while True:
            f = dfs(s, t, 1e10)
            if f > 0:
                flow += f
            else:
                break
    return flow


n, m = map(int, input().split())

network = [[] for _ in range(n)]
for _ in range(m):
    u, v, c = map(int, input().split())
    network[u].append([v, c, len(network[v])])
    network[v].append([u, 0, len(network[u]) - 1])

level = [-1] * n
it = [0] * n

print(max_flow(0, n - 1, n))



Measured memory_bytes: 6256
/* ex6_2
   tamayama */

#include<stdio.h>
#define SIZE 101

int main(void){
    char str1[SIZE];    /*文字列の配列を用意*/
    int i;
    int count=0;
    char first;
    char final;

    for(i=0;i<SIZE;i++){    /*ヌル文字を挿入*/
        str1[i] = '\0';
    }

    scanf("%s",str1);    /*入力された文字数をカウントする*/
    for(i=0;i<SIZE;i++){
        if(str1[i] != '\0'){
            count++;
        }
    }
    first = str1[0];    /*最初の文字*/
    final = str1[count-1];    /*最後の文字*/
    printf("%c%d%c\n",first,count-2,final);    /*真ん中の文字数は、（全体の文字数）-2*/
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <queue>
using namespace std;
deque<int>q;
int main()
{
	int n;
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		int x;
		cin>>x;
		if(i%2!=n%2) q.push_back(x);
		else q.push_front(x);
	}
	while(!q.empty())
	{
		cout<<q.front()<<' ';
		q.pop_front();
	} 
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <type_traits>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int k, x; cin >> k >> x;

    vector<int> v(5);
    for(int i = x - k + 1; i <= x + k - 1; i++) {
        cout << i << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100100
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
inline void read(int &a){
	int f=a=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=1;ch=getchar();}
	while(ch<='9'&&ch>='0') a=a*10+ch-'0',ch=getchar();
	if(f) a=-a;
}
int n,m;
int main(){
	LL u1=0,u0=1;
	int n,p;
	scanf("%d%d",&n,&p);
	for(int i=0,a;i<n;i++){
		scanf("%d",&a);
		if(a&1){
			LL t=u0;
			u0+=u1;
			u1+=t;
		}
		else u0*=2,u1*=2;
	}
	if(p==0) printf("%lld\n",u0);
	else printf("%lld\n",u1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    cout << atcoder::floor_sum(n, m, a, b) << endl;
  }
  return 0; 
}

Measured memory_bytes: 3596
import sys
import math
input = sys.stdin.readline

N = int(input())
arr=[]
ans=[]
for i in range(N):
	arr.append(list(map(int,input().split())))
	ans.append([0,0,0])

ans[-1]=arr[-1]

for i in range(N-2,-1,-1):
	ans[i][0] = arr[i][0] + max(ans[i+1][1],ans[i+1][2])
	ans[i][1] = arr[i][1] + max(ans[i+1][0],ans[i+1][2])
	ans[i][2] = arr[i][2] + max(ans[i+1][0],ans[i+1][1])

print(max(ans[0]))

Measured memory_bytes: 73180
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    XL = []
    for i in range(N):
        x, l = map(int, input().split())
        XL.append((x, l))
    XL.sort(key=lambda p: p[1] + p[0])

    ans = 0
    prev = -10**10
    for i in range(N):
        x, l = XL[i]
        if x - l >= prev:
            ans += 1
            prev = x + l
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 53084
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

X = int(sys.stdin.buffer.readline())
l = 0
h = 0
while l <= X:
    l += 100
    h += 105
    if l <= X <= h:
        print(1)
        exit()
print(0)


Measured memory_bytes: 13616
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
const int MAX_V = 3000;
vector<vector<int>> G(MAX_V);
int N, X, Y;

vector<int> dijkstra(int s) {
    vector<int> d(N, 1e9);
    priority_queue<P> que;
    d[s] = 0;
    que.push(P(s, 0));
    while (!que.empty()) {
        int v = que.top().first, c = que.top().second;
        que.pop();
        if (d[v] < c) continue;
        for (int to : G[v]) {
            if (d[to] > d[v] + 1) {
                d[to] = d[v] + 1;
                que.push(P(to, d[to]));
            }
        }
    }
    return d;
}
int main()
{
    cin >> N >> X >> Y;

    rep(i, N - 1) {
        G[i].emplace_back(i + 1);
        G[i + 1].emplace_back(i);
    }

    G[X - 1].emplace_back(Y - 1);
    G[Y - 1].emplace_back(X - 1);

    vector<int> ans(N);
    rep(i, N - 1) {
        vector<int> res = dijkstra(i);
        repd(j, i + 1, N) {
            ans[res[j]]++;
        }
    }

    rep(i, N - 1) {
        cout << ans[i + 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 3764
from sys import stdin

rooms = [[[0] * 10 for _ in range(3)] for _ in range(4)]
stdin.readline().rstrip()
while True:
    try:
        b, f, r, v = [int(x) for x in stdin.readline().rstrip().split()]
        rooms[b-1][f-1][r-1] += v
    except:
        break

for b in range(4):
    for f in range(3):
        print(" ", end = "")
        print(*rooms[b][f])
    else:
        if b != 3:
            print("#"*20)


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

using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FOR(i, a) for (int i = 0; i < (a); i++)

const int N = int(1e8) + 7;

void init(){

}

void solve(){
    int a, p;
    scanf("%d %d", &a, &p);
    p += a*3;
    printf("%d\n", p/2);
}

const bool mtc = false;

int main(){
    int t;
    if(mtc){
        scanf("%d", &t);
        while(t--) solve();
    }
    else solve();
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
double area3(double x1, double y1, double x2, double y2, double x3, double y3)
{
    double a, b, c, x;
 
    a = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    b = sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
    c = sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
    x = (a+b+c)/2;
    return sqrt(x*(x-a)*(x-b)*(x-c));
}
 
int main()
{
    double x0, y0, x1, y1, x2, y2;
    double s=0;
 
    scanf("%lf,%lf", &x0, &y0);
    scanf("%lf,%lf", &x1, &y1);
    
    while (scanf("%lf,%lf", &x2,&y2)==2) {
        s+=area3(x0, y0, x1, y1, x2, y2);
        x1=x2;
        y1=y2;
    }
    printf("%lf\n", s);
    return 0;
}


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

using namespace std;
#define ll long long
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1e9 + 7;

int main (){
    
    int a,b,c;
    cin >> a >> b >> c;
    bool fumiya = false;
  	int d = 1;
    for(int i = 1; d != 0;){
        d = a*i % b;
        if(d == c){
            fumiya = true;
            break;
        }
        i++;
    }

    if(fumiya) cout << "YES" <<endl;
    else cout << "NO" << endl;


    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }


void solve() {
    int n, m;
    cin >> n >> m;
    using pis = pair<int, string>;
    const int maxn = 100005;
    vector<int> table(maxn);
    vector<int> wa(maxn);
    set<int> st;
    int sum = 0;
    rep(i, m) {
        int p;
        string s;
        cin >> p >> s;
        if (s == "AC") {
            st.insert(p);
            table[p] = 1;
        } else {
            if (table[p] == 0) wa[p]++;
        }
    }
    
    rep(i, n) {
        if (st.find(i + 1) == st.end()) continue;
        sum += wa[i + 1];
    }
    cout << sz(st) << " " << sum << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}






Measured memory_bytes: 5760
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;


int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    std::string S;
    in >> S;
    std::string tmp = "hi";
    for (size_t i = 0; i < 10; i++)
    {
        if (S == tmp) {
            out << "Yes" << endl;
            return 0;
        }
        tmp += "hi";
    }out << "No" << endl;

    return 0;
}
#endif


Measured memory_bytes: 760
import sys
from collections import deque
readline = sys.stdin.readline
n, q = map(int, input().split())
f = lambda a, b: (a, int(b))
dq = deque(f(*readline().split()) for _ in range(n))
cnt = 0
ans = []
while dq:
    s, t = dq.popleft()
    if t <= q:
        cnt += t
        ans.append(s + " " + str(cnt))
    else:
        cnt += q
        dq.append((s, t - q))
print(*ans, sep="\n")



Measured memory_bytes: 13384
n = int(input())
p = list(map(int,input().split()))

cnt = 0
tmp = -1
for i in range(n):
  if p[i] == i+1:
    if i+1 == tmp+1:
      cnt+=0
      tmp = -1     
    else:
      cnt+=1
      tmp = i+1
print(cnt)

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

struct position{
    int y, x;
};

int main(){
    int H, W, D;
    cin >> H >> W >> D;
    position number_position[H * W];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            int num;
            cin >> num;
            number_position[num - 1] = {i, j};
        }
    }
    int need_magic_cost[H * W];
    for(int i = 0; i < D; i++){
        need_magic_cost[((H * W - i) / D) * D + i] = 0;
        for(int j =((H * W - i) / D) * D + i - D; j >= 0; j -= D){
            need_magic_cost[j] = need_magic_cost[j + D] + abs(number_position[j].y - number_position[j + D].y) + abs(number_position[j].x - number_position[j + D].x);;
        }
    }
    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int left, right;
        cin >> left >> right;
        cout << need_magic_cost[left - 1] - need_magic_cost[right - 1] << endl;
    }
}


Measured memory_bytes: 2176
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define SREP(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;
int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	int k;
	scanf("%d", &k);
	if (b < c)Swap(&b, &c);
	if (a < b)Swap(&a, &b);
	REP(i, k)a *= 2;
	PRINTD(a+b+c);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    
    int N,cnt=0;
    cin >>N;
    vector<int> A(N+2);
    vector<int> B(N+2);
    for(int i=1;i<=N;i++){
        cin >>A[i];
    }
    A[0]=0;
    A[N+1]=0;
    for(int i=1;i<=N;i++){
        B[i]=abs(A[i+1]-A[i])+abs(A[i]-A[i-1])-abs(A[i+1]-A[i-1]);
    }
    for(int i=0;i<=N;i++){
        cnt+=abs(A[i+1]-A[i]);
    }
    for(int i=1;i<=N;i++){
        cout <<(cnt-B[i])<<endl;
    }

    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <string>
using namespace std;
#pragma warning (disable: 4996)

long long mod = 1000000007;
string S; int N, A[300009];

int main() {
	cin >> N >> S;
	if (S[0] == 'W' || S[S.size() - 1] == 'W') {
		cout << "0" << endl;
		return 0;
	}
	for (int i = 0; i < S.size(); i++) {
		if (i == 0) A[i] = 1;
		else if (S[i - 1] != S[i]) {
			if (A[i - 1] == 1) A[i] = 1;
			else A[i] = 0;
		}
		else {
			if (A[i - 1] == 1) A[i] = 0;
			else A[i] = 1;
		}
	}
	long long dep = 0, ans = 1;
	for (int i = 0; i < S.size(); i++) {
		if (A[i] == 1) dep++;
		else { ans *= dep; ans %= mod; dep--; }
		if (dep < 0) {
			cout << "0" << endl;
			return 0;
		}
	}
	if (dep != 0) {
		cout << "0" << endl;
		return 0;
	}
	for (long long i = 1; i <= N; i++) { ans *= i; ans %= mod; }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1412
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace lineAralgebra
{

	public class MaxHeap
	{
		public long[] pq;
		int n = 0;
		public MaxHeap(long n)
		{
			pq = new long[n + 1];
		}

		private void Sink(int k)
		{
			while (2 * k <= n)
			{
				int j = 2 * k;
				if (j < n && pq[j] <= pq[j + 1]) j++;
				if (pq[k] >= pq[j]) break;
				Exch(k, j);
				k = j;
			}
		}

		public void insert(long x)
		{
			// add x, and percolate it up to maintain heap invariant
			pq[++n] = x;
			Swim(n);
		}

		private void Swim(long k)
		{
			while (k > 1 && pq[k / 2] < pq[k])
			{
				Exch(k, k / 2);
				k = k / 2;
			}
		}

		public void Exch(long i, long j)
		{
			long swap = pq[i];
			pq[i] = pq[j];
			pq[j] = swap;
		}

		public long DelMax()
		{
			long max = pq[1];
			Exch(1, n--);
			Sink(1);
			pq[n + 1] = 0;

			return max;
		}
	}

	class Program
	{
		static void Main(string[] args)
		{
			var input = Console.ReadLine().Split(' ');
			var n = long.Parse(input[0]);
			var m = long.Parse(input[1]);

			input = Console.ReadLine().Split(' ');

			var a = new int[n];

			var pq = new MaxHeap(n);
			for (var i = 0; i < n; i++)
			{
				a[i] = int.Parse(input[i]);
				pq.insert(a[i]);
			}

			for (var i = 0; i < m; i++)
			{
				var max = pq.DelMax();
				max /= 2;
				pq.insert(max);
			}

			System.Console.WriteLine(pq.pq.Sum());

		}

		/** test cases:
		 * null ==> null
		 * 1 ==> 1
		 * 1->2 ==> 2->1
		 * 1->2->3 ==> 2->1->3
		 * 1->2->3->4 ==> 2->1->4->3
		 */
	}
}

Measured memory_bytes: 25948
#include<stdio.h>

int main(void)
{
    int i,n,m,num,max=0;

    scanf("%d%d",&n,&m);
    max=m;

    for(i=0;i<n;i++){
        scanf("%d",&num);
        m+=num;
        scanf("%d",&num);
        m-=num;
        if(m<0){
            max=0;
            break;
        }
        if(max<m){
            max=m;
        }
    }
    printf("%d\n",max);
    return 0;
}

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

using namespace std;

const int NUM_DICES = 2;
const int NUM_FACES = 6;
const int NUM_SWAPS = 3;
const int NUM_DIRS = 2;

int swap_i[NUM_DIRS][NUM_SWAPS][2] = {
	{{0, 1}, {1, 5}, {4, 5}},
	{{1, 3}, {2, 3}, {3, 4}}
};

void rotate(vector<int> &die, int dir) {
	for (int i = 0; i < NUM_SWAPS; ++i) {
		swap(die[swap_i[dir][i][0]], die[swap_i[dir][i][1]]);
	}	
}

int main() {
	vector<int> dice[NUM_DICES];

	for (int i = 0; i < NUM_DICES; ++i) {
		dice[i].resize(NUM_FACES);
		for (int j = 0; j < NUM_FACES; ++j) {
			cin >> dice[i][j];
		}
	}

	bool answer = false;
	for (int i = 0; i < 10000; ++i) {
		rotate(dice[1], rand() % NUM_DIRS);
		if (dice[0] == dice[1]) {
			answer = true;
			break;
		}
	}

	if (answer) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	cout << endl;
}


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


int main (){
    int N;
    cin>>N;
    vector<long double> A(N);
    long double sumrev=0;
    for(int i=0; i<N; i++){
        cin>>A.at(i);
        sumrev +=1/A.at(i);
    }
    long double sum=1/sumrev;
    cout<<sum<<endl;
}
    

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>
#include<cmath>
#include<iomanip>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int n;
vector<vector<double>> d;
bool v[8] = {};
int cnt;

double dfs(int p, double sum){
    v[p] = true;
    double res = 0;
    for(int i = 0; i < n; i++){
        if(!v[i]){
            res +=  dfs(i, sum + d[p][i]);
        }
    }
    bool f = true;
    for(int i = 0; i < n; i++){
        f &= v[i];
    }
    v[p] = false;
    return (f? sum : res);
}

int main(){
    cin >> n;
    vector<double> x(n), y(n);
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
    }
    int m = 1;
    for(int i = 1; i <= n; i++){
        m *= i;
    }
    d = vector<vector<double>>(n, vector<double>(n));
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            double dx = abs(x[i] - x[j]);
            double dy = abs(y[i] - y[j]);
            d[i][j] = d[j][i] = sqrt(dx * dx + dy * dy);
        }
    }
    double ans = 0;
    for(int i = 0; i < n; i++){
        ans += dfs(i, 0) / m;
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <stdexcept>
#include <utility>
// #include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,n,h) for(int i = n; i < h; ++i)
#define rep3(l,n,h) for(int l = n; l <= h; ++l)
using namespace std;


int main() {
    typedef pair<int,int> int_pair;
    int n,m,sum = 0;
    cin >> n;
    vector<int> t(n);
    rep(i,n) {
        cin >> t.at(i);
        sum += t.at(i);
    }
    cin >> m;
    vector<int> ans(m);
    rep(i,m) {
        int p,x;
        cin >> p >> x, p--;
        ans[i] = sum - t.at(p) + x;
    }
    for(auto& e: ans) cout << e << endl;
     return 0;
    }


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(string s) {
    long ans = 0;
    int w = 0;
    for (int i = cast(int) s.length - 1; i >= 0; i--) {
        if (s[i] == 'W') w++;
        else if (s[i] == 'B') {
            ans += w;
        }
    }
    return ans;
}

void main() {
    string s = read!string;
    writeln(calc(s));
}


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

int main()
{
    cin.tie(0);
    string input;
    cin >> input;
    if(input[2] == input[3] && input[4] == input[5])
    {
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
min_x = 100
a.each do |v|
  x = 0
  while v & 1 == 0 do
    v >>= 1
    x += 1
  end
  min_x = x if min_x > x
end
puts min_x


Measured memory_bytes: 1788
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,m] <- getIntList
    let ans | n == 1 && m == 1 = 1
            | n == 1 = m - 2
            | m == 1 = n - 2
            | otherwise = (n - 2) * (m - 2)
    print ans

Measured memory_bytes: 380
#include<stdio.h>

int main(){
	long long int N,A,B;
	scanf("%lld %lld %lld",&N,&A,&B);

	long long int C=N%(A+B);
	if(C<=A){
		printf("%lld",N/(A+B)*A+C);
	}else{
		printf("%lld",N/(A+B)*A+A);
	}

	return 0;
}

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

int N,W;

int v[110], w[110];
int dp[110][10010];

int main() {
  cin >> N >> W;
  for (int i = 1; i <= N; i++) {
    cin >> v[i] >> w[i];
  }

  memset(dp,0,sizeof(dp));

  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= W; j++) {
      if(j - w[i] >= 0) {
        dp[i][j] = max(dp[i][j] , dp[i - 1][j - w[i]] + v[i]);
      }
      dp[i][j] = max(dp[i][j], dp[i - 1][j]);
    }
  }

  cout << dp[N][W] << '\n';
}


Measured memory_bytes: 7412
n = int(input())
h = list(map(int, input().split()))
h[0] -= 1
             
if n == 1:
      print("Yes")
else:
      for i in range(n-1):
            if h[i] < h[i+1]:
                  h[i+1] -= 1
      for i in range(n-1):
            if h[i+1] < h[i]:
                  print("No")
                  break
      else:
            print("Yes")
                  

Measured memory_bytes: 14396
#include<iostream>

using namespace std;

int main(){
    int H,W;
    while(H!=0||W!=0){
        cin>>H>>W;
        if(H==0&&W==0)break;
        for(int i=0;i<H;i++){
            if(i%2==0)for(int v=0;v<W;v++){
                if(v%2==0)cout<<"#";
                if(v%2==1)cout<<".";
                if(v==W-1)cout<<endl;
            };
            if(i%2==1)for(int v=0;v<W;v++){
                if(v%2==0)cout<<".";
                if(v%2==1)cout<<"#";
                if(v==W-1)cout<<endl;
            };
        }
        cout<<endl;
    }
}



Measured memory_bytes: 3080
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int L, R, D;
	cin >> L >> R >> D;

	int ans = 0;
	rep(i, L, R + 1)
	{
		if (i%D == 0)
		{
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3644
S1=input()
S2=input()
dp=[[0 for i in range(len(S1) + 1)]for j in range(len(S2)+1)]
for i in range(len(S1)+1):
    dp[0][i]=i
for j in range(len(S2)+1):
    dp[j][0]=j
for i in range(1,len(S1)+1):
    for j in range(1,len(S2)+1):
        if S1[i-1]==S2[j-1]:
            dp[j][i]=dp[j-1][i-1]
        else:
            dp[j][i]=min(dp[j-1][i],dp[j][i-1],dp[j-1][i-1])+1
print(dp[len(S2)][len(S1)])



Measured memory_bytes: 42892
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int l = sc.nextInt();
			int result = 0;
			int minus = Integer.MAX_VALUE;

			for (int i = 0; i < n; i++) {
				result += l + i;
				if (Math.abs(l + i) < Math.abs(minus)) {
					minus = l + i;
				}
			}

			System.out.println(result - minus);
		}
	}
}


Measured memory_bytes: 22612
// D - Classified
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			int l = 0, k = (i ^ j) & -(i ^ j);
			for ( ; k; k >>= 1) l++;
			cout << l << ' ';
		}
		cout << endl;
	}

	return 0;
}


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

int main() {
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if(s == u) {
        a = a - 1;
    } else if (t == u) {
        b = b - 1;

    }

    cout << a << ' ' << b << '\n';

    return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

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

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;




int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	ll n;
	cin>>n;
	ll ans=1,c1=0,c2=0,c4=0;
	while(1){
		if(n==4) c4++;
		if(n==2) c2++;
		if(n==1) c1++;
		if(c1==2 || c4==2 || c2==2) break;
		if(n%2==0)
			n/=2;
		else 
			n=3*n+1;
		ans++;
	}
	cout<<ans<<"\n";

		

}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
using namespace std;
int S(int A,int B){
	return A*B;}

int main() {
 int x;
 
 
 cin >>x;
 
 if (x<1200){
 	cout << "ABC"<< endl;
 }
 else {
 	cout << "ARC" <<endl;
 }
 
 	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int[] input_num = new int[3];
            for (int i = 0; i < 3; i++)
            {
                input_num[i] = int.Parse(input[i]);
            }
            int min = input_num.Min();
            int max = input_num.Max();
            int temp = 0;
            int remove_cnt = 0;
            for (int i = 0; i < 3; i++)
            {
                temp += input_num[i];
                if (input_num[i] == max && remove_cnt == 0)
                {
                    temp -= max;
                    remove_cnt++;
                }
            }
            Console.WriteLine(temp.ToString());
        }
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#define vector std::vector
#define string std::string
typedef long long ll;
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define min(a, b) std::min(a, b)
#define max(a, b) std::max(a, b)

template <class T = int>
T in() { T x; std::cin >> x; return x; }
#define output(e) std::cout << e << '\n'

#ifdef LOCAL
#define db std::cout << "L" << __LINE__ <<
#define de << "\n"
#define dv(x) << " " << #x << "->" << x
#else
#define db
#define de
#define dv(x)
#endif

//
// Implementation
//

int main() {
  int X = in();
  int ans = 1;
  for (int i=2; i<=X; i++) {
    for (int j=i*i; j<=X; j*=i) {
      ans = max(ans, j);
    }
  }
  output(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lp3(i,a,b) for(int i=a;i<b;i++)
#define lp2(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
int main(){
	string j="NO";
	int a,seven=0,five=0;
	lp2(i,3){
		cin>>a;
		if(a==5)five++;
		else if(a==7)seven++;
	}
	if(five==2 && seven == 1)j="YES";
	cout<<j<<endl;
	return 0;
}


Measured memory_bytes: 256
io = STDIN
n=io.gets.to_i
def calc(x)
  cnt=0
  while(x.even?)
    x/=2
    cnt+=1
  end
  cnt
end
max=0
ar=(1..n).to_a.map do |x|
  [x,calc(x)]
end.to_a.max_by{|x,c|c}
puts ar[0]

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

int main()
{
	int n,k,x,y;
	
	cin>>n>>k>>x>>y;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(i<=k)
			ans+=x;
		else
			ans+=y;
	}
	cout<<ans;
	return 0;
	
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  string s;
  cin >> s;
  int Q;
  cin >> Q;

  int flip = 0;
  string ls(""), rs(s);
  rep(i, Q) {
    int t;
    cin >> t;
    if (t == 1) {
      flip++;
    } else {
      int f;
      char c;
      cin >> f >> c;
      if ((f + flip) % 2 == 1) {
        ls.push_back(c);
      } else {
        rs.push_back(c);
      }
    }
  }

  if (flip % 2 == 0) {
    reverse(ls.begin(), ls.end());
    cout << ls + rs << endl;
  } else {
    reverse(rs.begin(), rs.end());
    cout << rs + ls << endl;
  }

  return 0;
}

Measured memory_bytes: 1500
#include <cstdio>
#include <cstring>
#include <cassert>

#include <algorithm>
#include <deque>
#include <string>

using namespace std;

#define DEBUG(x) cerr << #x << " = " << x << endl

int main() {
  int n; scanf("%d", &n);
  deque<int> l;
  while(n--) {
    char s[80];
    scanf("%s", s);
    if(strcmp(s, "insert") == 0) {
      int x;
      scanf("%d", &x);
      l.push_front(x);
    }
    else if(strcmp(s, "delete") == 0) {
      int x;
      scanf("%d", &x);
      auto it = find(l.begin(), l.end(), x);
      if(it != l.end()) {
        l.erase(it);
      }
    }
    else if(strcmp(s, "deleteFirst") == 0) {
      l.pop_front();
    }
    else if(strcmp(s, "deleteLast") == 0) {
      l.pop_back();
    }
    else {
      assert(false);
    }
  }

  int k = 0;
  for(int item : l) {
    printf("%d%c", item, " \n"[k++ == l.size() - 1]);
  }
}

Measured memory_bytes: 5100