akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,ans=0,sum=0;
	string s;
	cin>>n>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='W') ans++;
	}
	for(int i=n-1;i>=n-ans;i--){
		if(s[i]=='R') sum++;
	}
	cout<<sum;
	return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    REP(i,0,H) cin >> S[i];

    ll cnt = 1;
    mat C(H, vec(W));
    vector<bool> F(H);
    REP(i,0,H) {
        bool f = false;
        REP(j,0,W) {
            if((!f) && S[i][j] == '#') f = true;
            else if(f && S[i][j] == '#') ++cnt;
            C[i][j] = cnt;
        }
        if(f) ++cnt;
        F[i] = f;
    }

    ll k = 0;
    while(!F[k]) ++k;
    for(ll i=k-1; i>=0; --i) {
        REP(j,0,W) C[i][j] = C[k][j];
    }
    REP(i,1,H) {
        if(!F[i]) {
            REP(j,0,W) C[i][j] = C[i-1][j];
        }
    }

    REP(i,0,H) {
        REP(j,0,W) PS(C[i][j]);
        PR("");
    }


    return 0;
}

/*



*/

Measured memory_bytes: 4484
S = input() + 'E'
for w in list('ACGT'):
    S = S.replace(w, ' ')
count = 0
max_count = 0
for w in S:
    if w == ' ':
        count += 1
    elif count > max_count:
        max_count = count
        count = 0
print(max_count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll d,n;
    cin>>d>>n;
    ll temp=1;
    for(int i=0;i<d;i++)
    {
        temp=temp*100;
    }
    if(n==100 && d==0)
    {
        cout<<101<<endl;
    }
    else if(n==100 && d==1)
    {
        cout<<10100<<endl;

    }
    else if(n==100 && d==2)
    {
        cout<<1010000<<endl;
    }
    else
    {
        cout<<temp*n<<endl;
    }
}


Measured memory_bytes: 256
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int dp[103][303];
int w[103], v[103];

int main()
{
	int n, W;
	scanf("%d %d", &n, &W);
	for (int i = 0; i <= n; i++) for (int j = 0; j <= 300; j++) dp[i][j] = -100;

	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d %d", &w[i], &v[i]);

		for (int k = i; k >= 0; k--) {
			for (int j = 300; j >= 0; j--) {
				if (dp[k][j] < 0) continue;
				if (j + w[i] - w[0] > 300) continue;
				dp[k + 1][j + w[i] - w[0]] = MAX(dp[k + 1][j + w[i] - w[0]], v[i] + dp[k][j]);
			}
		}
	}

	LL ans = 0;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= 300; j++) {
			if (dp[i][j] < 0) continue;
			if (1LL * i * w[0] + j > W) continue;
			LL now = dp[i][j];
			ans = MAX(ans, now);
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 384
import bisect
n,k=map(int,input().split())
a=list(map(int,input().split()))
N=[];Z=[];P=[]
for i in range(n):
  if a[i]<0:
    N.append(a[i])
  elif a[i]==0:
    Z.append(a[i])
  else:
    P.append(a[i])

if k<=len(N)*len(P):
  for i in range(len(N)):
    N[i]*=-1
  N.sort()
  P.sort()
  Nr=list(reversed(N))
  L=0;R=10**18+1
  while R-L>1:
    x=(L+R)//2
    ct=0
    ct2=0
    for j in range(len(Nr)):
      if ct2!=len(P):
        while Nr[j]*P[ct2]<x:
          ct2+=1
          if ct2==len(P):
            break
      ct+=len(P)-ct2
    if ct<k:
      R=x
    else:
      L=x
  print(-L)

elif k<=len(N)*len(P)+(len(Z)*(len(Z)-1))//2+len(Z)*(len(N)+len(P)):
  print(0)

else:
  y=len(N)*len(P)+(len(Z)*(len(Z)-1))//2+len(Z)*(len(N)+len(P))
  for i in range(len(N)):
    N[i]*=-1
  N.sort()
  P.sort()
  L=0;R=10**18+1
  Nr=list(reversed(N))
  Pr=list(reversed(P))
  while R-L>1:
    x=(L+R)//2
    ct=0
    ct2=0
    for j in range(len(Nr)):
      if ct2!=len(N):
        while Nr[j]*N[ct2]<=x:
          ct2+=1
          if ct2==len(N):
            break
      ct+=min(ct2,len(N)-1-j)
    ct3=0
    for j in range(len(Pr)):
      if ct3!=len(P):
        while Pr[j]*P[ct3]<=x:
          ct3+=1
          if ct3==len(P):
            break
      ct+=min(ct3,len(P)-1-j)
    if ct<k-y:
      L=x
    else:
      R=x
  print(R)

Measured memory_bytes: 99588
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
const ld eps = 1e-9;
const db PI = atan(1) * 4;

template<typename T, typename S>inline bool upmin(T&a, const S&b) { return a > b ? a = b, 1 : 0; }
template<typename T, typename S>inline bool upmax(T&a, const S&b) { return a < b ? a = b, 1 : 0; }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }
namespace SOLVE {
	VLL weights;
	VLL values;
	vector<VLL> memo;

	ll value(ll w, ll i) {
		
		if (i == -1) {
			return 0;
		}
		if (memo[w][i] != 0) {
			return memo[w][i];
		}

		ll option1 = 0;
		if (w >= weights[i]) {
			option1 = value(w - weights[i], i - 1) + values[i];
		} 

		ll option2 = value(w, i - 1);
		memo[w][i] = max(option1, option2);
		// cout << w << ' ' << i << ' ' << memo[w][i] << endl;
		return max(option1, option2);

	}

	void main() {
		ll n, w, a, b;
		cin >> n >> w;
		values.resize(n);
		weights.resize(n);
		memo.clear();
		memo.resize(w + 5, VLL(n + 5));
		
		REP(i, 0, n) {
			cin >> a >> b;
			weights[i] = a;
			values[i] = b;
		}

		ll this_v;
		RREP(i, w, 0) {
			this_v = value(i, n - 1);
			if (this_v != 0) {
				cout << this_v;
				return;
			}
		}
	}
}


signed main() {

	int t;
	//    in(t);
	t = 1;
	while (t--) {
		SOLVE::main();

	}

	return 0;
}


Measured memory_bytes: 85376
n, m = map(int, input().split())
h = list(map(int, input().split()))

kouho = [True]*(n+1)
for i in range(m):
  a, b = map(int, input().split())
  if h[a-1] < h[b-1]:
    kouho[a] = False
  elif h[a-1] > h[b-1]:
    kouho[b] = False
  else:
    kouho[b] = False
    kouho[a] = False
print(kouho.count(True)-1)

Measured memory_bytes: 20040
Nstr,Kstr=input().split()
S=input()
N=int(Nstr)
K=int(Kstr)-1
#print(X)
ans=""
i=0
for v in S:
	if(K==i):
		if (S[K]=="A"):
			ans=ans+"a"
		if (S[K]=="B"):
			ans=ans+"b"
		if (S[K]=="C"):
			ans=ans+"c"
	else:
		ans=ans+v
	i=i+1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
using namespace std;
int main()
{
	int n; 
	string in;
	getline(cin,in);
	n=atoi(in.c_str());
	while(n--)
	{
		getline(cin,in);
		int dig[26];
		string ans="";
		bool flag=false;
		for(int i = 1;;i+=2)
		{
			if(i%13==0) continue;
			for(int j = 0; j < 26; ++j)
			{
				for(int k = 0; k < 26; ++k)
				{
					dig[k]=(i*k+j)%26;
				}
				ans="";	
				for(int k = 0; k < in.size(); ++k)
				{
					if(in[k]==' ') ans+=' ';
					else 
					{
						char tmp='a'+dig[in[k]-'a'];
						ans+=tmp;
					}
				}
				//cout<<ans<<endl;
				if(ans.find("that")!=-1||ans.find("this")!=-1)
				{
					cout<<ans<<endl;
					flag=true;
				}
				if(flag) break;
			}
			if(flag) break;
		}

	}
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  vi a(n);
  int s = 0;
  for (int i = 0; i < a.size(); ++i) {
    cin >> a[i];
    s += a[i];
  }
  int best = 0, mi = 1e9;
  for (int i = 0; i < a.size(); ++i) {
    int cand = abs(s - a[i] * n);
    if (cand < mi) {
      mi = cand;
      best = i;
    }
  }
  cout << best << endl;
  return 0;
}

Measured memory_bytes: 256
set = int(input())
 
lis = list(map(int, input().split()))
 
v = 0
lis.sort()

for i in range(set-1):
    if lis[i] == lis[i + 1]:
        v =1
            
if v == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 26808
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
    int n, x;
    cin>>n>>x;
    vi v(n);
    for(int i = 0; i < n; i++)cin>>v[i];
    int l = v[0], s = max(0ll, l-x);
    l-=s;
    for(int i = 1; i < n; i++){
        s+=max(0ll, l+v[i]-x);
        l=v[i]-max(0ll, l+v[i]-x);
    }   
    cout<<s;
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int l,r,d,i,cnt=0;
	cin >> l >> r >> d;
	for(i=l;i<=r;i++)
	{
		if(i>=l && i<=r && i%d==0) 
		{
			cnt++;
		}
	}
	cout << cnt << endl;

	
	return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
int main(){
  char a[11], b, i;
  scanf("%s", a);
  i=0;
  scanf("%c",&b);
  while(1){
    if(a[i]=='\0') break;
    scanf("%c",&b);
    if(a[i]!=b){
      printf("No");
      return 0;
    }
    i++;
  }
  printf("Yes");
}

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

void check_num(int, int);
void end_check_num(int, int);
void include3(int, int, int);

int main(){
    int n;
    cin >> n;
    int i = 1;
    check_num(i, n);
    cout << endl;
}

void check_num(int i, int n){
    int x = i;
    if ( x % 3 == 0 ){
        cout << " " << i;
        end_check_num(i, n);
    } else {
        include3(i, n, x);
    }
}

void include3(int i, int n, int x){
    if ( x % 10 == 3 ){
        cout << " " << i;
        end_check_num(i, n);
    } else {
        x /= 10;
        if ( x ) {
            include3(i, n, x);
        }
        else{
            end_check_num(i, n);
        }
    }
}

void end_check_num(int i, int n){
    if ( ++i <= n ){
        check_num(i, n);
    }
}


    

Measured memory_bytes: 1164
package main

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

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
    buf := make([]byte, 0, 1000000)
    for {
        l, p, e := rdr.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}

var sc = bufio.NewScanner(os.Stdin)

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

func main(){
	var N, A, B,res int
	fmt.Scan(&N)
	fmt.Scan(&A)
	fmt.Scan(&B)
	res=0
	if ((B-A)%2==0) {
		res=(B-A)/2
	}else{
		if (N-B>A-1){
			res=(B-(A-1+1))/2+(A-1+1)
		}else{
			res=((N-A)-(N-B+1))/2+(N-B+1)
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>

#define fir first
#define sec second
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define All(s) (c).begin(), (c).end()
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long int ll;

int N;

void input() {
    cin >> N ;
}

void solve(){
    input();
    int a = N*N;
    cout << a << endl;
    return ;
}

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

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

int main(){
for(int x,y,i=0;  ; i++){
cin >> x >> y;
if(x==0 && y==0)break;
if(x>y) cout << y  << " " << x <<endl;
else cout << x << " " << y <<endl;
}

return 0;

}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

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

  if(b - a >= 2019) {
    cout << 0 << endl;
    return 0;
  }
 
  int mi = 2020;
  for(int i = a; i <= b; i++) {
    for(int j = i+1; j <= b; j++) {
      mi = min(mi, (i%2019) * (j%2019) % 2019);
    }
  }
  cout << mi << endl; 
}


Measured memory_bytes: 3612
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main _ =
    let [|a;b|] = reada int
    let f = if (a * b) % 2 = 0 then "Even" else "Odd"
    printfn "%s" f
    0


Measured memory_bytes: 14044
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("A");}else{puts("a");}
#define MAX_N 200005

int main() {
    char c;
    cin >> c;
    if(c <= 'Z')yn;
    return 0;
}




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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))

int main(int argc, char *argv[])
{
  int a,b;
  scanf("%d %d", &a, &b);

  if(b%a==0){
    printf("%d\n", a+b);
  }else{
    printf("%d\n", b-a);
  }
  return 0;
}


Measured memory_bytes: 128
<?php
fscanf(STDIN, "%d", $num);

for($i=-6208;$i<6209;$i++){
    $array[$i] = (int)pow($i,5);
}


foreach($array as $key=>$value){
    $target = binarySearch($value, $num, -6208, 6208);
    if($target !== false){
        echo $key." ". $target;
        exit;
    }
}



function binarySearch( $n, $target, $min, $max)
{
    global $array;
    $pivot = $min + intdiv($max - $min, 2);
//    echo $min."-".$max."-".$pivot.PHP_EOL;
    if ($n - $array[$pivot] < $target) {
        if($pivot == $min){
            return false;
        }
        if($n - $array[$pivot -1 ]  > $target){
            return false;
        }elseif($n - $array[$pivot -1 ]  == $target) {
            return $pivot - 1;
        }else{
            if($pivot - 1 ==$min){
                return false;
            }
                return (binarySearch($n, $target, $min, $pivot));
        }

    } elseif ($n - $array[$pivot] > $target) {
        if($pivot == $max){
            return false;
        }
        if($n - $array[$pivot + 1] < $target ){
            return false;
        }elseif($n - $array[$pivot + 1] == $target) {
            return $pivot + 1;
        }else {
            if($pivot + 1 == $max){
                return false;
            }
            return (binarySearch($n, $target, $pivot, $max));
        }
    }else{
        return $pivot;
    }
}

function array_last(array $array)
{
    return end($array);
}

Measured memory_bytes: 17304
//IOI 2021

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

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 2 * 1000 + 17, inf = 2e9 + 17;

int n, a[2 * MAXN], b[MAXN], w[MAXN], dp[MAXN][MAXN], TB[MAXN], TW[MAXN], PB[MAXN][MAXN], PW[MAXN][MAXN];
char col[2 * MAXN];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= 2 * n; i++) {
		cin >> col[i] >> a[i];
		if (col[i] == 'W')
			w[a[i]] = i;
		else
			b[a[i]] = i;
	}
	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++)
			TW[i] += (w[j] < w[i]), TB[i] += (b[j] < b[i]);
	for (int i = 1; i <= n; i++)
		for (int j = n - 1; j >= 0; j--)
			PW[i][j] = PW[i][j + 1] + (b[j + 1] < w[i]), PB[i][j] = PB[i][j + 1] + (w[j + 1] < b[i]);

	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= n; j++)
			dp[i][j] = inf;
	dp[n][n] = 0;
	for (int i = n; i >= 0; i--)
		for (int j = n; j >= 0; j--) {
			if (i != n)
				dp[i][j] = min(dp[i][j], dp[i + 1][j] + TW[i + 1] + PW[i + 1][j]);
			if (j != n)
				dp[i][j] = min(dp[i][j], dp[i][j + 1] + TB[j + 1] + PB[j + 1][i]);
		}
	cout << dp[0][0] << endl;
//	cerr << "# "  << dp[1][0] << endl;
	return 0;
}



Measured memory_bytes: 47872
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define fix(n) cout<<fixed<<setprecision(n);
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  while(1){
    int a,b; cin>>a>>b;
    if(a==0 && b==0) break;
    rep(i,0,a){
      rep(j,0,b){
        if((i+j)%2==0) cout<<"#";
        else cout<<".";
      }
      co("");
    }
    co("");
  }
    
  return 0;
}


Measured memory_bytes: 3084
N = int(input())
A=list(map(int, input().strip().split()))
B=list(map(int, input().strip().split()))

count=0

for i in range(N):
    #for j in range(N):
    if A[i]-B[i]>0:
        count+=B[i]
    else:
        count+=A[i]
        B[i]=B[i]-A[i]
        if A[i+1]-B[i]>0:
            count+=B[i]
            A[i+1]=A[i+1]-B[i]
        else:
            count+=A[i+1]
            A[i+1]=0

print(count)


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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int H, W;
	
	cin>>H>>W;
	
	if(H == 1 || W == 1) cout<<1<<endl;
	else if(H*W%2 == 0) cout<<H*W/2<<endl;
	else {
		cout<<((H+1)/2) * ((W+1)/2) + ((H)/2) * ((W)/2)<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

print(" ".join(map(str, A)))
for i in range(1, n):
    v = A[i]
    j = i-1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(" ".join(map(str, A)))


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

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

  ll n,m;
  string s;
  cin >> n >> m >> s;
  vll d(n+1,inf); // distance between i-th and N-th 
  vll most(n+1,inf); // most left position whose distance to N-th is i

  d[n]=0;
  most[0]=n;
  ll left=n-1,right=n;
  
  rep(t,1,n+1){
    ll next=right;
    while(left>=right-m&&left>=0){
     if(s[left]=='0') {
       d[left]=t;
       next=left;
     }
      left--; 
    }
    if(next==right) {
      cout << -1 << endl;
      return 0;
    }
    
   right=next;
   most[t]=right;
    if(left<0) break;
  }
  
   vll ans;
   ll now=0;
  repr(t,d[0]-1,0){
    ans.push_back(most[t]-now); //Step size
    now=most[t];
  }
  
  rep(i,0,ans.size()-1) cout << ans[i] << " ";
    cout << ans[ans.size()-1] << endl;
}


Measured memory_bytes: 3144
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
  int n,k;
  cin >> n >> k;
  int l[k],r[k];
  rep(i,k)cin >> l[i] >> r[i];
  vector<mint> a(n,0);
  a[0]=1;
  vector<mint> s(n+1,0);
  s[1]=s[1]+a[0];
  rep(i,n){
    if(i==0)continue;
    rep(j,k){
      if(i-l[j]>=0)a[i]+=s[i-l[j]+1]-s[max(i-r[j],0)];
    }
    s[i+1]=s[i]+a[i];
  }
  //rep(i,n)cout << a[i] << endl;
  cout << a[n-1] << endl;
}

Measured memory_bytes: 6440
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

    int n;
    cin >> n;

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

    int ans = 0;
    while (true) {
        sort(a, a+n);

        int g = a[1];
        for (int i = 1; i < n; i++) g = gcd(g, a[i]);

        ans = max(ans, g);
        if (a[0] == a[n-1]) break;
        
        for (int i = 0; i < n; i++) a[i] = gcd(a[0], a[i]);
    }

    cout << ans << "\n";
    return 0;
}

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

typedef long long ll;
typedef long double ld;

#define n1		      "\n"
#define B                     begin()
#define E                     end()
#define F                     first
#define S                     second
#define pb                    push_back
#define pf                    push_front
#define popb                  pop_back()
#define popf                  pop_front()

const int BIG=1e5+55;
const int BIGG=1e9+7;
const ll BIGGE=1e12+55;
const double SML=(1e-7);

using namespace std;

    string s;
    
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL);
    cout.tie(NULL);
    cin >>s;
    for (auto i:s) {
        if (i == '7') {
            cout <<"Yes";
            return 0;
        }
    }
    cout <<"No";
    
    
    
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

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

	ll sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	ll dx = tx - sx;
	ll dy = ty - sy;

	string ans;

	ans += string(dy, 'U');
	ans += string(dx, 'R');
	ans += string(dy, 'D');
	ans += string(dx+1, 'L');
	ans += string(dy + 1, 'U');
	ans += string(dx + 1, 'R');
	ans += "DR";
	ans += string(dy + 1, 'D');
	ans += string(dx + 1, 'L');
	ans += "U";

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
//length of the longest path in a directed acyclic graph
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e9+5;

int32_t main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin>>a[i];
    int dp[n][n];
    memset(dp,0,sizeof(dp));
    for(int i = n-1; i >= 0; i--){
        for(int j = i; j < n; j++){
            if(j == i) dp[i][j] = a[i];
            else dp[i][j] = max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
        }
    }
    cout<<dp[0][n-1];
}

Measured memory_bytes: 70656
#include<cstdio>
#include<algorithm>
using namespace std;
struct kk
{
	long long num;
	int id,im;
}s[200010];
#define lowbit(x) x&(-x)
bool cmp1(kk A,kk B)
{
	return A.num<B.num||(A.num==B.num&&A.id<B.id);
}
bool cmp2(kk A,kk B)
{
	return A.id<B.id;
}
int c[200010],n;
long long k,ans,x;
void modify(int s,int x)
{	
    for (;s<=n+1;s+=lowbit(s))	   
	   c[s]+=x;
}
int sum(int s)
{	
    int ans=0;	
	for (int i=s;i;i-=lowbit(i))	   
	  ans+=c[i];	
	return ans;
}
int main()
{
	scanf("%d%lld",&n,&k);
	s[0].num=0;s[0].id=0;
	int i;
	for (i=1;i<=n;i++)
	{
		scanf("%d",&x);
		s[i].num=s[i-1].num+x-k;
		s[i].id=i;
	}
	sort(s,s+n+1,cmp1);
	for (i=0;i<=n;i++) s[i].im=i+1;
	sort(s,s+n+1,cmp2);
	long long ans=0;
	for (i=0;i<=n;i++)
	{
		ans+=sum(s[i].im);
		modify(s[i].im,1);
	}
	printf("%lld\n",ans);
}
//BIT:binary indexed tree

Measured memory_bytes: 4096
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        PriorityQueue<Long> pq = new PriorityQueue<>(Collections.reverseOrder());
        for (int i = 0; i < n; i++) {
            long a = Long.parseLong(sc.next());
            pq.add(a);
            pq.add(a);
        }
        sc.close();

        // 主処理
        pq.poll();
        long result = 0;
        for (int i = 0; i < n - 1; i++) {
            result += pq.poll();
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 70920
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;

int main() {
  int N;
  string S, T;
  cin >> N >> S >> T;
  string ans = "";
  REP(i, N) {
    ans.push_back(S[i]);
    ans.push_back(T[i]);
  }
  cout << ans << endl;
}


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

//#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int N;
int A[100000];

signed main(){
    cin>>N;
    rep(i,N)cin>>A[i];

    vint vec;
    rep(i,N){
        if(i>0&&A[i-1]!=A[i])continue;
        int c=i+1;
        while(c<N&&A[c-1]!=A[c])c++;
        vec.pb(c-i);
    }

    if(vec.size()<=2){
        cout<<accumulate(all(vec),0ll)<<endl;
        return 0;
    }
    int ma=0;
    rep(i,vec.size()-2){
        chmax(ma,vec[i]+vec[i+1]+vec[i+2]);
    }
    cout<<ma<<endl;
    return 0;
}

Measured memory_bytes: 1800
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int N, K; cin >> N >> K;
  string s; cin >> s;
  int a = s[K-1];
  s[K-1] = a + 32;
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int num;
  char str[16];
  
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&num);
  
  if(num%2 == 0)
  {
    printf("%d\n",num);
  }else
  {
    printf("%d\n",2*num);
  }
  
  return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    ans = A[0][0] in b and A[1][0] in b and A[2][0] in b
    ans = ans or A[0][1] in b and A[1][1] in b and A[2][1] in b
    ans = ans or A[0][2] in b and A[1][2] in b and A[2][2] in b

    ans = ans or A[0][0] in b and A[0][1] in b and A[0][2] in b
    ans = ans or A[1][0] in b and A[1][1] in b and A[1][2] in b
    ans = ans or A[2][0] in b and A[2][1] in b and A[2][2] in b

    ans = ans or A[0][0] in b and A[1][1] in b and A[2][2] in b
    ans = ans or A[2][0] in b and A[1][1] in b and A[0][2] in b

    if ans:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)]
         for _ in range(3)]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(A, N, b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+10;
typedef long long ll;
//注意有些int类型要改成long long类型 
//vector<int> ve[N]; 
int main(){
//	freopen("input.txt","r",stdin); 
	int n,m;
	cin>>n>>m;
	int a,b;
	vector<int> ve[N]; 
	priority_queue<int> q;
	ll earn=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",&a,&b);
		if(a>m) continue;
		ve[m-a+1].push_back(b);
	}
	for(int i=m;i>=1;i--)
	{
		for(int v:ve[i]) q.push(v);
		while(!q.empty())
		{
			earn+=q.top();
			q.pop();
			break;			
		}
	}
	cout<<earn<<endl;
	return 0;
}








Measured memory_bytes: 26752
#include <iostream>
#include <string>   
using namespace std;
 
int main(){
int rank[3],a[10],i = 0,ii = 0,b,c;
rank[0] = 0;
rank[1] = 0;
rank[2] = 0;
while(i <= 9){
	cin >> a[i];
	while(ii <= 2){
		if(rank[ii] < a[i]){
			b = 2 - ii;
			c = ii;
			if(ii == 2){
				rank[2] = a[i];
			}
			if(ii == 1){
				rank[2] = rank[1];
				rank[1] = a[i];
			}
			if(ii == 0){
				rank[2] = rank[1];
				rank[1] = rank[0];
				rank[0] = a[i];
			}		


			break;	
		}
		ii++;
	}
i++;
ii = 0;

}
cout<<rank[0]<<endl<<rank[1]<<endl<<rank[2]<<endl;




}

Measured memory_bytes: 1160
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, K, Q;
    cin >> N >> K >> Q;
    vector<ll> A(N);
    set<ll> st;
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        st.insert(A[i]);
    }

    auto isOK = [&](ll a) {
        //最小値をYとして決め打つ
        for (ll Y : st) {
            //Aの各要素を
            //  1)Y未満
            //  2)Y以上かつY + a以下
            //  3)Y + a超過
            //のどれかという情報へ変換する
            vector<ll> B;
            B.push_back(1);
            for (ll i = 0; i < N; i++) {
                B.push_back(
                    (A[i] < Y ? 1: (A[i] > Y + a ? 3 : 2))
                );
            }
            B.push_back(1);

            ll num_b = 0, num_2 = 0, cnt = 0;
            for (ll i : B) {
                if (i == 1) {
                    ll n = max(num_b - K + 1, (ll)0);
                    cnt += min(n, num_2);
                    num_b = num_2 = 0;
                } else if (i == 2) {
                    num_b++;
                    num_2++;
                } else {
                    num_b++;
                }
            }
            if (cnt >= Q) {
                return true;
            }
        }
        return false;
    };

    ll ng = -1, ok = INT_MAX;
    while (ng + 1 != ok) {
        ll mid = (ng + ok) / 2;
        (isOK(mid) ? ok = mid : ng = mid);
    }

    cout << ok << endl;
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define fo(i, n) for(int i = 1; i <= n; ++i)

typedef long long ll;
typedef pair<int, int> pii;

const int N = 200200;
ll cnt[N][26];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	string s;
	cin >> s;
	int n = s.length();
	s = '#' + s;
	ll ans = 1;
	for(int i = 1; i <= n; ++i)
	{
		cnt[i][s[i] - 'a']++;
		for(int j = 0; j < 26; ++j)
			cnt[i][j] += cnt[i - 1][j];
		ans += (i - cnt[i][s[i] - 'a']);
	}
	cout << ans;
	return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : (x))
#define all(x) x.begin(), x.end() // sort(all(x))
#define sz(x) (int)(x).size()
#define mp(x, y) make_pair((x), (y))

typedef long long ll;

typedef double T;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tiii;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<T> vt;
typedef vector<vt> vvt;
typedef vector<pii> vpi;
typedef vector<pii> vpl;
typedef vector<vpi> graph;
typedef complex<T> Pt;
typedef pair<Pt, Pt> Line;

const ll MOD = 1e9 + 7; // 998244353;
const T EPS = 1e-10;
const int INF = 1e9 + 1;

/* Mod Library */

struct Mod {
    ll x;
    Mod (ll x = 0) : x(x) {}
    Mod operator+(Mod b) { return Mod((x + b.x)%MOD); }
    Mod operator-(Mod b) { return Mod((x - b.x + MOD)%MOD); }
    Mod operator*(Mod b) { return Mod((x * b.x)%MOD); }
    Mod operator/(Mod b) { return *this * inverse(b); }
    Mod operator%(Mod b) { return Mod(x % b.x); }

    static ll euclid(ll a, ll b, ll &x, ll &y) {
        if (b) {
            ll d = euclid(b, a%b, y, x);
            y -= a/b*x;
            return d;
        }
        x = 1; 
        y = 0;
        return a;
    }
    
    Mod inverse(Mod a) {
        ll x, y, g = euclid(a.x, MOD, x, y);
        assert(g == 1);
        return Mod((x + MOD)%MOD);
    }

    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this^(e/2);
        r = r*r;
        return e&1 ? *this*r : r;
    }
};

/* Input Library */
template <typename A, typename B>
istream& operator>>(istream &in, pair<A, B> &p) {
    in >> p.first >> p.second;
    return in;
}

template <typename A, typename B>
ostream& operator<<(ostream &out, pair<A, B> &p) {
    out << p.first << " " << p.second;
    return out;
}

template <typename I>
istream& operator>>(istream &in, vector<I> &a) {
    trav(i, a) in >> i;
    return in;
}

template <typename I>
ostream& operator<<(ostream &out, vector<I> &a) {
    rep(i, 0, sz(a)) {
        if (i) out << " ";
        out << a[i];
    }
    return out;
}

void fast_io() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    //cout.tie(0);
    cin.exceptions(cin.failbit);
} 

void solve_test() {
  int l, r , d;
  cin >> l >> r >> d;


  int ans = 0;
  for (int i = d; i <= r; i += d) {
    if (i >= l) {
      ++ans;
    }
  }

  cout << ans << endl;

}

void setup() {
}

int main() {
    setup();
    srand(time(0));
    fast_io();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve_test();
    }
}


Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
	public static Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		//A
		/*
		int s = sc.nextInt();
		if(s < 1000)
			System.out.println("ABC");
		else
			System.out.println("ABD");
			*/
		int a = sc.nextInt();
		int b = sc.nextInt();
		int sa = b-a;
		int ans = 0;
		for(int i = 0 ; i <= sa ; i++){
			ans+=i;
		}
		System.out.println(ans - b);
	}
}


Measured memory_bytes: 20692
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N, M = in.nextInt
  val sc = (1 to M).map(_ => (in.nextInt, in.nextInt)).distinct.groupBy(_._1).mapValues(_.map(_._2))

  def proc(pos: Int, num: Int): Int = {
    if (pos > N) num
    else {
      sc.get(pos) match {
        case None => proc(pos + 1, num * 10 + (if (N > 1 && pos == 1) 1 else 0))
        case Some(l) =>
          if (l.size > 1 || (N > 1 && l.head == 0 && pos == 1)) -1
          else proc(pos + 1, num * 10 + l.head)
      }
    }
  }

  println(proc(1, 0))
}

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

int main(){
  int N;cin>>N;
  ll L[N];
  rep(i,N) cin>>L[i];
  int ans=0;
  
  for(int i=0;i<N-2;i++){
    for(int j=i+1;j<N-1;j++){
      for(int k=j+1;k<N;k++){
        int a=L[i];
        int b=L[j];
        int c=L[k];
        if(a+b>c && b+c>a && c+a>b && a!=b && b!=c && c!= a){
          ans++;
        }
      }
    }
  }
  cout<<ans<<endl;
}      

Measured memory_bytes: 3528
# import itertools
# import math
import sys
sys.setrecursionlimit(500*500)
# import numpy as np
from collections import deque

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
N, M = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# A_B = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# edges = [list(map(int,input().split())) for _ in range(M)]
# tree = [[] for _ in range(N + 1)]

# for edge in edges:
#     tree[edge[0]].append([edge[1], edge[2]])
#     tree[edge[1]].append([edge[0], edge[2]])

# depth = [-1] * (N + 1)
# depth[1] = 0

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr

tree = [[] for _ in range(N + 1)]
edges = [list(map(int,input().split())) for _ in range(M)]

for edge in edges:
    tree[edge[0]].append(edge[1])
    tree[edge[1]].append(edge[0])

depth = [-1] * (N + 1)
depth[1] = 0

d = deque()
d.append(1)

ans = [0] * (N + 1)
while d:
 v = d.popleft()
 for i in tree[v]:
   if depth[i] != -1:
     continue
   depth[i] = depth[v] + 1
   ans[i] = v
   d.append(i)

# ans = depth[2:]
print('Yes')
print(*ans[2:], sep="\n")

Measured memory_bytes: 60024
local tgt = 1
local strs = {}
local pos = {1, 1, 1}
local tmp = ""
for i = 1, 3 do strs[i] = io.read() end
while pos[tgt] <= #(strs[tgt]) do
  tmp = strs[tgt]:sub(pos[tgt], pos[tgt])
  pos[tgt] = pos[tgt] + 1
  tgt = string.byte(tmp) - 96
end
print(string.char(tgt + 64))


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              3.14159265358979323844
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    string s;
    cin>>s;
    rep(i,0,sz(s)/2){
    	if (s[i]!=s[sz(s)-1-i]){
    		cout<<"No"<<endl;
    		return;
    	}
    }
    rep(i,0,sz(s)/4){
    	if (s[i]!=s[sz(s)/2-1-i]){
    		cout<<"No"<<endl;
    		return;
    	}
    }
    rep(i,(sz(s)/2)+1,(3*sz(s))/4){
    	if (s[i]!=s[sz(s)-1-i]){
    		cout<<"No"<<endl;
    		return;
    	}
    }
    cout<<"Yes"<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> nums(n);
    for(int i=0;i<n;i++)
    {
        cin>>nums[i];
    }
    vector<int> dp(n,INT_MAX);
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        for(int j=i-1;j>=(max(0,i-k));j--)
        {
            dp[i]=min(dp[i],dp[j]+abs(nums[i]-nums[j]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024