akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <array>
#include <vector>
using namespace std;

int main(void){
  	//input
	string S;
  	cin >> S;
  	//compute
  	int ans;
  	int len = S.size();
  	int count = 0;
  	for(int i=0; i<len; i++){
    	if(S[i] == '0'){
        	count++;
        }
    }
  	ans = count < len - count ? 2*count : 2*(len - count);
  	//output
  	cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e9;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k,t;
    cin >> k >> t;
    vector<ll> a(t);
    cins(all(a));
    vector<vector<bool>> dp(t+1,vector<bool>(k+1,0));
    dp[0][0] = 1;
    rep(i,t){
        rep(j,k+1){
            if (dp[i][j]){
                dp[i+1][j+a[i]] = dp[i+1][j] = 1;
            }
        }
    }
    ll l = 0;
    rep(i,k/2+1){
        if (dp[t][i]){
            chmax(l,i);
        }
    }
    ll r = k-l;
    if (r-l <= 1) PRINT(0);
    else PRINT(r-l-1);
}


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

int getketa(int num) {
    int keta = 0;
    while(num) {
        keta += 1;
        num /= 10;
    }
    return keta;
}

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    rep(i, n) {
        if(getketa(i + 1) % 2 == 1) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3596
S = int(input())
G = 500
GG = 5

g_count = 0
gg_count= 0

while S >= G:
  S = S - G
  g_count += 1
while S >= GG:
  S = S - GG
  gg_count += 1
print(g_count*1000 + gg_count*5)


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

int main(){
    char s;
    cin >> s;
    if((s >= 'a') && (s <= 'z')){
        cout << "a" << endl;
    }else if((s >= 'A') && (s <= 'Z')){
        cout << "A" << endl;
    }
    return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[3005];
ll B[3005];
ll C[3005];

int main()
{
    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    REP(i, X)
    {
        cin >> A[i];
    }
    REP(i, Y)
    {
        cin >> B[i];
    }
    REP(i, Z)
    {
        cin >> C[i];
    }
    sort(A, A + X, [](ll a, ll b) { return a > b; });
    sort(B, B + Y, [](ll a, ll b) { return a > b; });
    sort(C, C + Z, [](ll a, ll b) { return a > b; });
    vector<ll> v;
    REP(a, X)
    {
        REP(b, Y)
        {
            v.push_back(A[a] + B[b]);
        }
    }
    sort(v.begin(), v.end(), [](ll a, ll b) { return a > b; });
    vector<int> zi(Z, 0);
    REP(i, K)
    {
        int mi = Z - 1;
        REP(z, Z)
        {
            if (zi[z] >= v.size())
                continue;
            if (C[z] + v[zi[z]] > C[mi] + v[zi[mi]])
                mi = z;
        }
        cout << C[mi] + v[zi[mi]] << endl;
        zi[mi]++;
    }
    return 0;
}

Measured memory_bytes: 10348
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=200005;
vector<int> nxt[MAXN];
void ins(int x,int y){nxt[x].emplace_back(y);}
int otA[MAXN],otB[MAXN],vis[MAXN],n,m;
char ch[MAXN];
queue<int> li;
int main()
{
	n=read();m=read();
	scanf("%s",ch+1);
	for(int i=1;i<=m;i++)
	{
		int x=read(),y=read();
		ins(x,y);ins(y,x);
		if(ch[x]=='A')otA[y]++;else otB[y]++;
		if(ch[y]=='A')otA[x]++;else otB[x]++;
	}
	for(int i=1;i<=n;i++)if(!otA[i]||!otB[i])vis[i]=1,li.push(i);
	while(!li.empty())
	{
		int x=li.front();li.pop();vis[x]=1;
		for(auto y:nxt[x])if(!vis[y])
		{
			if(ch[x]=='A')--otA[y];else --otB[y];
			if(!otA[y]||!otB[y])vis[y]=1,li.push(y);
		}
	}bool flag=false;
	for(int i=1;i<=n;i++)flag|=(!vis[i]);
	puts(flag?"Yes":"No");
	return 0;
}



Measured memory_bytes: 13184
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main()
{
    int N,W;
    cin >> N >> W;
    ll w[N],v[N];
    for(int i = 0;i < N;i++)
    {
        cin >> w[i] >> v[i];
    }
    ll dp[N + 1][W + 1] = {};
    for(int i = 0;i < N;i++)
    {
        for(int j = 0;j <= W;j++)
        {
            if(j < w[i])
            {
                dp[i + 1][j] = dp[i][j];
            }
            else
            {
                dp[i + 1][j] = max(dp[i][j],dp[i][j - w[i]] + v[i]);
            }
        }
    }
    cout << dp[N][W] << "\n";

    return 0;
}

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

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

using ll = long long;

int log(ll x) {
  int cnt = 0;
  ll y = x;
  while(y > 0){
    y /= 10;
    cnt++;
  }
  return cnt;
}

int F(ll x, ll y){
  return max(log(x), log(y));
}

int main() {
  ll N;
  cin >> N;
  ll i = 1LL;
  ll a;
  while(i*i<=N) {
    if(N % i==0)a=i;
    i++;
  }
  int ans=F(a,N/a);
  cout << ans << endl;
}
  

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if(A<C&&C<B){
        printf("Yes");
    }else if(B<C&&C<A){
        printf("Yes");
    }else{
        printf("No");
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 1000000000
#define MAX_V 10000
#define MAX_E 100000
using namespace std;
typedef pair<int, int> P;
struct edge { int u, v, cost; };

bool comp(const edge& e1, const edge& e2){
	return e1.cost < e2.cost;
}

int V, E;
edge es[MAX_E];

class UnionFind {
	vector<int> data;
	int root(int a) {
		return data[a] < 0 ? a : data[a] = root(data[a]);
	}
public:
	UnionFind(int n) : data(n, -1) {}
	bool Find(int a, int b) {
		return root(a) == root(b);
	}
	void Union(int a, int b) {
		int ra = root(a), rb = root(b);
		if (ra == rb) return;
		if (data[ra] < data[rb]) {
			data[ra] += data[rb];
			data[rb] = a;
		}
		else {
			data[rb] += data[ra];
			data[ra] = b;
		}
	}
};

int Kruskal() {
	int res = 0;
	UnionFind uf(V);
	sort(es, es + E, comp);
	for (int i = 0; i < E; i++) {
		edge e = es[i];
		if (!uf.Find(e.u, e.v)) {
			uf.Union(e.u, e.v);
			res += e.cost;
		}
	}
	return res;
}

int main()
{
	cin >> V >> E;
	for (int i = 0; i < E; i++) {
		cin >> es[i].u >> es[i].v >> es[i].cost;
	}
	cout << Kruskal() << endl;
	return 0;
}

Measured memory_bytes: 4288
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C4N solver = new C4N();
        solver.solve(1, in, out);
        out.close();
    }

    static class C4N {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            long n = in.nextLong();
            for (int i = 1; i <= 3500; i++) {
                for (int j = 1; j <= 3500; j++) {
                    long x = n * i * j;
                    long y = 4 * i * j - n * (i + j);
                    if (x > y && y > 0) {
                        if (x % y == 0 && x / y > 0) {
                            out.println(i + " " + j + " " + x / y);
                            return;
                        }
                    }

                }
            }

        }

    }
}



Measured memory_bytes: 23764
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
typedef long long ll;
using namespace std;


int main(){
    int n,m;cin>>n>>m;
    printf("%d",(int)(1800*m+100*n)*(int)pow(2,m));
    
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//数値
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int ba = b-a;
		int B = 0;
		for(int i = ba; i > 0; i--){
            	B += i;
            }
		 System.out.println(B-b);
     }
}

Measured memory_bytes: 35632
//テンプレ
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)

int main() {
  int X,Y;
  int ans=0;
  cin>>X>>Y;
  rep(i,X+1){
    int asi=i*2+(X-i)*4;
    if(asi==Y){
      ans=1;
    }
  }
  if(ans==1){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

int main () {
  std::vector<int> ABC(3);
  std::cin >> ABC[0] >> ABC[1] >> ABC[2];
  std::sort(ABC.begin(),ABC.end());

  // minとsecond_minについて
  if ((ABC[0] % 2) == (ABC[1] % 2 )) {
    int answer = (ABC[1] - ABC[0]) / 2 + (ABC[2] - ABC[1]); 
    std::cout << answer << std::endl; 
  }
  else {
    if ((ABC[0] % 2) == (ABC[2] % 2)) {
      int answer = (ABC[2] - ABC[0]) /2 + (ABC[2] + 1 - ABC[1]) / 2 + 1;
      std::cout << answer << std::endl;    
    } 
    else {
      int answer = (ABC[2] - ABC[1]) /2 + (ABC[2] + 1 - ABC[0]) /2 + 1;
      std::cout << answer << std::endl;
    } 
  }
}

Measured memory_bytes: 256
_ = input()
N = list(map(int, input().split()))
pren = N[0]
preud = 0 # up = 1, down = -1
cnt = 0
for n in N:
  # 初めに方向の評価
  if pren < n:
    ud = 1
  elif pren > n:
    ud = -1
  else:
    ud = 0
  # 逆方向
  if preud * ud == - 1:
    cnt += 1
    preud = 0
  else:
    if ud != 0:
      preud = ud
  pren = n
#  print(ud, preud)
print(cnt+1)

Measured memory_bytes: 16048
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
const int MAX =110000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
signed main() {
  COMinit();
  int n,m;
  cin>>n>>m;
  vector<int> k;
  int t=2,s,m0=m;
  for(int i=2;i*i<=m0;i++){
    s=0;
    while(m%i==0){
      s++;
      m/=i;
    }
    if(s!=0)k.push_back(s);
  
  }
  if(m!=1)k.push_back(1LL);

  int ans=1;
  for(int i=0;i<k.size();i++){
    ans=(ans*COM(n-1+k[i],k[i]))%MOD;
  }
  cout<<ans;

  return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

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

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);
//const int INF=(1<<29);

int main(){
  string s;
  cin >>s;
  REP(i,s.size()){
    if(s[i]=='?')cout << "D";
    else cout << s[i];
  }
  cout << endl;
}



Measured memory_bytes: 3756
T = input()
T_list = list(T)
i = 0
for s in T_list:
  if i == len(T_list):
    break
  if i == 0:
    if T_list[i] == "?":
      if 1 < len(T_list):
        if T_list[i+1] == "D":
          T_list[i] = "P"
        elif T_list[i+1] == "?":
          T_list[i] = "P"
          T_list[i+1] = "D"
          i = i + 2
          continue
        else:
          T_list[i] = "D"
      else:
        T_list[i] = "D"
  else:
    if T_list[i] == "?":
      if T_list[i-1] == "P":
        T_list[i] = "D"
      elif i+1 < len(T_list):
        if T_list[i+1] == "D":
          T_list[i] = "P"
        elif T_list[i+1] == "?":
          T_list[i] = "P"
          T_list[i+1] = "D"
          i = i + 2
          continue
        else:
          T_list[i] = "D"
      else:
        T_list[i] = "D"
  i = i + 1
T = "".join(T_list)
print(T)

Measured memory_bytes: 10892
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main() {
    cin>>N;
    set<ll> c;
    ll non = 0;
    rep(i,N){
        cin>>A;
        reps(j,1,9){
            if(A < j*400){
                c.insert(j);
                break;
            }
            if(j == 8) ++non;
        }
    }
    cout<<max(1LL,ll(c.size()))<<' '<<c.size() + non<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a,b;
int main() {
	// your code goes here
	cin>>a>>b;
	if(a==b)cout<<"Draw"<<endl;
	else if((a>=2&&a<b)||b==1)cout<<"Bob"<<endl;
	else if((b>=2&&a>b)||a==1)cout<<"Alice"<<endl;

	return 0;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const ll LINF = 1e11;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

    int n, k;
    cin >> n >> k;

    double ans = 0;
    for (int i = 1; i <= n; ++i) {
        double tmp = 1.0 / n;
        int now = i;
        while (now < k) {
            now *= 2;
            tmp /= 2;
        }
        ans += tmp;
    }
    cout << setprecision(12) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, M, C int
	fmt.Scan(&N, &M, &C)

	Blist := make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Scan(&Blist[i])
	}

	clearnum := 0
	for i := 0; i < N; i++ {
		tmp := 0
		Alist := make([]int, M)

		for k := 0; k < M; k++ {
			fmt.Scan(&Alist[k])
			tmp = tmp + Alist[k]*Blist[k]
		}
		tmp = tmp + C
		if tmp > 0 {
			clearnum++
		}
	}

	fmt.Println(clearnum)

}


Measured memory_bytes: 512
t,_,s=open(0).read().partition('\n')
h,w=map(int,t.split())
d={}
d[4]=a=h//2*(w//2)
d[1]=b=h%2and w%2
d[2]=(h*w-a*4-b)//2
for i in map(s.count,set(s)-{'\n'}):
  for j in(4,2,1):
    while d[j]and i>=j:
      i-=j
      d[j]-=1
print('YNeos'[any(t for t in d.values())::2])

Measured memory_bytes: 3064
package main

import (
        "fmt"
)

func solution(x, n int, p []int) int {
        if len(p) == 0 {
                return x
        }

        var memo [103]int
        for i := range p {
                memo[p[i]]--
        }

        lo := 1 << 31
        for i := 0; i <= 102; i++ {
                if memo[i] == 0 {
                        memo[i] = abs(x - i)
                        lo = min(lo, memo[i])
                }
        }

        out := 0
        for i := 0; i <= 102; i++ {
                if memo[i] != -1 && lo == memo[i] {
                        out = i
                        break
                }
        }
        return out
}

func min(x, y int) int {
        if x < y {
                return x
        }
        return y
}

func abs(x int) int {
        if x < 0 {
                return -x
        }
        return x
}

func main() {
        var x, n int
        fmt.Scan(&x, &n)
        p := make([]int, n)
        for i := range p {
                fmt.Scan(&p[i])
        }
        fmt.Println(solution(x, n, p))
}

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

int N;
string s;

int main(){
	cin >> N;
	cin >> s;
	int res = 0;
	for(int i = 0; i < N; i++){
		string t;
		cin >> t;
		bool flag = false;
		for(int j = 0; j < t.size(); j++){
			if(t[j] == s[0]){
				for(int k = 1; k < t.size(); k++){
					bool flag_ = true;
					for(int l = 1; l < s.size(); l++){
						if(j + k * l >= t.size() || s[l] != t[j + k * l]) flag_ = false;
					}
					if(flag_) flag = true;
				}
			}
		}
		if(flag) res++;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <cstring>
using namespace std;
long long a[401000],stack[401000],l[401000],r[401000],s[401000];
int main()
{
	long long n;
	cin>>n;
	for(long long i=1; i<=n; i++)
	{
		cin>>a[i];
		s[i]=s[i-1]+a[i];
	}
	
	long long top=0;
	for(long long i=1; i<=n; i++)
	{
		while(top&&a[i]<=a[stack[top]])
		{
			top--;
		}
		l[i]=stack[top]+1;
		top++;
		stack[top]=i;
	}
	memset(stack,0,sizeof(stack));
	top=0;
	for(long long i=n; i>=1; i--)
	{
		while(top&&a[i]<=a[stack[top]])
		{
			top--;
		}
		r[i]=stack[top]-1;
		top++;
		stack[top]=i;
	}
	long long ans=0;
	for(long long i=1; i<=n; i++)
	{
		long long left=l[i],right=r[i];
		if(right==-1) right=n;
		ans+=(i-left+1)*a[i]*(right-i+1);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 14080
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

int n; 
bool isSumbit(int x[],int y){

    for(int bit=0 ; bit < (1 << n) ; bit++){
        int sum = 0;

        for(int i = 0 ;i < n ; i++){
            if(bit & (1 << i)){
                sum += x[i];
            }
            
        }
        if(sum == y){
            return true;
        }
    }
    return false;
}

bool isSumdfs(int x[],int index, int sum){
    if(sum == 0){
        return true;
    }
    if(index >= n){
        return false;
    }

    return (isSumdfs(x,index+1,sum) || isSumdfs(x,index+1,sum-x[index]));
}

int main(){
    cin >> n;
    int a[n];
    rep(i,n) scanf("%d",&a[i]);

    int m; cin >> m;

    
    rep(i,m){
        int b; scanf("%d" , &b);
        bool ans = isSumdfs(a,0,b);
        if(ans) {
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }
}


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

constexpr long mod = 1000000007;

long powpow(long x, long y) {
    long r = 1;
    while(y) {
        if(y&1) r *= x, r %= mod;
        x *= x, x %= mod;
        y >>= 1;
    }
    return r;
}

int main(void) {
    string s;
    cin >> s;
    int l = s.size();

    vector<vector<long>> dp(3, vector<long>(4));

    long q = 0;
    for(size_t i=0; i<l; i++)
        q += s[i] == '?';

    for(size_t i=0; i<l; i++) {
        for(int j: {2,1,0})
            for(int k: {2,1,0}) {
                dp[j][k] += (j>0 ? dp[j-1][k] : k==0) * (s[i] == 'A'+j), dp[j][k] %= mod;
                dp[j][k+1] += (j>0 ? dp[j-1][k] : k==0) * (s[i] == '?'), dp[j][k+1] %= mod;

            }
    }

    long r = 0;
    for(int i: {0,1,2,3})
        if(q-i >= 0)
            r += dp[2][i] * powpow(3, q-i), r %= mod;

    cout << r << endl;
}


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

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

typedef long long ll;

int main ()
{
	int n;
  	cin >> n;
  	ll dp[100010][3];
  	ll a [100010][3];
  	for(int i = 0; i < n; i++)
    {
    	for(int j = 0; j < 3; j++)
        {
       		cin >> a[i][j];
        }
    }
  	for(int i = 0; i < 100010; i++)
    {
    	for(int j = 0; j < 3; j++)
        {
        	dp[i][j] = 0;
        }
    }
  	for(int i = 0; i < n; i++)
    {
    	for(int j = 0; j < 3; j++)
        {
        	for(int k = 0; k < 3; k++)
            {
            	if(j == k)
                {
                	continue;
                }
              	chmax(dp[i+1][k], dp[i][j] + a[i][k]);
            }
        }
    }
  	ll res = 0;
  	for(int i = 0; i < 3; i++)
    {
  		chmax(res,dp[n][i]);
    }
  	cout << res << endl;
}


Measured memory_bytes: 4992
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

n = ni()
a = nl()

sa = set(a)
l = len(sa)

if l == 1:
    if a[0] == 0:
        print('Yes')
    else:
        print('No')
elif len(a) % 3 == 0:
    if l == 2:
        if a.count(0) == n // 3:
            print('Yes')
        else:
            print('No')
    elif l == 3:
        if all([a.count(ele) == n // 3 for ele in sa]):
            li = list(sa)
            if li[0] ^ li[1] ^ li[2] == 0:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 14100
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T, typename U, typename V>
ostream &operator<<(ostream &os, const tuple<T, U, V> &t){
  os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef tuple<int, int, int> TT;
typedef pair<int, TT> PT;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);




signed main(){
  int n;cin >> n;
  vector<P> vec(n);
  rep(i,n){
    int x, y;cin >> x >> y;
    vec[i] = P(y, x);
  }
  sort(all(vec));
  int t = 0;
  rep(i,n){
    t += vec[i].se;
    if(t > vec[i].fi){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}






Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100000
#define INF 10000000

int N, M, S, T, dist[MAXN + 3][3];
vector<int> adj[MAXN + 3];

int main() {
    cin >> N >> M;
    for (int i = 1; i <= M; i++) {
        int u, v;
        cin >> u >> v;

        adj[u].push_back(v);
    }
    cin >> S >> T;

    for (int i = 1; i <= MAXN; i++) {
        dist[i][0] = dist[i][1] = dist[i][2] = INF;
    }

    queue<pair<int, int> > Q;

    dist[S][0] = 0;
    Q.push({S, 0});

    while (!Q.empty()) {
        auto front = Q.front(); Q.pop();
        int u = front.first;
        int mod = front.second;

        for (auto v: adj[u]) {
            int nextMod = (mod + 1)%3;
            if (dist[v][nextMod] == INF) {
                dist[v][nextMod] = dist[u][mod] + 1;
                Q.push({v, nextMod});
            }
        }
    }

    if (dist[T][0] < INF && dist[T][0]%3 == 0)
        cout << dist[T][0]/3 << endl;
    else
        cout << -1 << endl;
}


Measured memory_bytes: 6912
#include <iostream>
#include <map>
#include <bits/stdc++.h>
#include <cstdlib>
#include <math.h> 
using namespace std;
typedef pair<int, int> pi; 
#define ll long long int
#define inf 1e6
int main(){
	int n;
	cin>>n;
    ll x,y,curx,cury;
	cin>>x>>y;
	curx=x,cury=y;
	n--;
	while(n--)
	{
		cin>>x>>y;
	    ll m=max(curx/x,cury/y);
	    ll a=x*m,b=y*m;
	    if(a<curx||b<cury)
	    {a+=x,b+=y;}
	    curx=a,cury=b;
	}
	cout<<curx+cury;
}

Measured memory_bytes: 256
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if a+b <= a+c and a+b <= b+c:
    print(a+b)
elif a+c <= a+b and a+c <= b+c:
    print(a+c)
else:
    print(b+c)

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

using ll = long long;

template <class INT_T> INT_T powi(INT_T x, INT_T y) {
    if (y == 0) return 1;
    if (y == 1) return x;
    if (y & 1) return powi(x*x, y/2) * x;
    return powi(x*x, y/2);
}

inline ll layer(ll lv) { return 4 * powi((ll)2, lv) - 3; }
inline ll patty(ll lv) { return powi((ll)2, lv+1) - 1; }

ll solve(ll lv, ll x)
{
    if (lv <= 0) {
        return x > 0 ? 1 : 0;
    }
    if (x <= 1) {
        return 0;
    } else if (x <= 1 + layer(lv-1)) {
        return solve(lv-1, x-1);
    } else if (x == 1 + layer(lv-1) + 1) {
        return 1 + patty(lv-1);
    } else {
        return patty(lv-1) + 1 + solve(lv-1, min(layer(lv-1), x-1-layer(lv-1)-1));
    }
}

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

    ll n, x;
    cin >> n >> x;

    cout << solve(n, x) << endl;
}


Measured memory_bytes: 256
//This code was made by Chinese_zjc_
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int n; 
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>n;
	cout<<n*n*n;
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

S = '-' + input().rstrip()
N = len(S) - 1

def solve(S):
    if S[1] == '0':
        return None
    if S[N] == '1':
        return None
    prev = 1
    graph = []
    for n in range(1,N//2 + 1):
        if S[n] != S[N-n]:
            return None
        if S[n] == '0':
            continue
        for i in range(prev,n):
            graph.append('{} {}'.format(i,n))
        prev = n
    for i in range(prev,N):
        graph.append('{} {}'.format(i,N))
    return graph

graph = solve(S)

if graph is None:
    print(-1)
else:
    print('\n'.join(graph))


Measured memory_bytes: 14232
# include <iostream>
# include <iomanip>


using namespace std;


int main() {
    long long w, h, x, y; cin >> w >> h >> x >> y;

    cout << setprecision(9);
    cout << double(w) * double(h) / 2 << " ";
    cout << ((w == 2*x) and (h == 2*y)) << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
int i,x=0;
char ch[100],ln;
scanf("%s",ch);
ln=strlen(ch);
for(i=0;i<ln;i++)
{
if(ch[i+1]>='a'&&ch[i]<='z')
 {
    x++;
 }
}
printf("%c%d%c",ch[0],x-1,ch[ln-1]);
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, A;
    cin >> N >> A;

    cout << N*N - A << endl;
    return 0;
}

Measured memory_bytes: 3612
function Main(input) {
    input = input.split("\n");
    var a = parseInt(input[0]);
    var nums = input[1].split(' ').map(Number);
    var tmp = 0.0;
    for(var i=0; i<a; i++){
        tmp += 1/nums[i];
    }
    console.log(1/tmp);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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


vector<int> graph[100001];
int dp[100001];

// void d_m_c()
// {
// 	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
// }



int solve(int src)
{
	if (dp[src] != -1)
		return dp[src];
	int leaf = 1;

	int bestChild = 0;
	for (int nbr : graph[src])
	{
		leaf = 0;
		bestChild = max(bestChild, solve(nbr));
	}

	if (leaf)
		return dp[src] = 0;
	else
		return dp[src] = 1 + bestChild;
}

int32_t main()
{
	//d_m_c();

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

	for (int i = 0; i < m; i++)
	{
		int x, y;
		cin >> x >> y;

		graph[x].push_back(y);
	}

	memset(dp, -1, sizeof dp);

	int best = 0;
	for (int i = 1; i <= n; i++)
	{
		best = max(best, solve(i));
	}

	cout << best;

	return 0;
}

Measured memory_bytes: 8192
char a[500][501];m[500][500];
main(i,j,k,x,y,r,M){
	for(;scanf("%d%d",&y,&x),x;printf("%d\n",r)){
		for(j=0;j<y;j++)scanf("%s",a[j]);
		for(j=0;j<y;j++)for(r=i=0;i<x;m[j][i]=r,i++)if(a[j][i]=='.')r++;else r=0;
		for(r=i=0;i<x;i++)for(j=0;j<y;j++)for(M=99999,k=j;k<y;k++){
			if(M>m[k][i])M=m[k][i];
			if(r<M*(k-j+1))r=M*(k-j+1);
		}
	}
exit(0);}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  
  vector<int> A(n);
  for (auto& item : A) {
    cin >> item;
  }

  bool flag;
  int cnt = 0;
  do {
    flag = false;
    for (int i = n - 1; 0 < i; --i) {
      if (A[i - 1] > A[i]) {
        swap(A[i - 1], A[i]);
        flag = true;
        ++cnt;
      }
    }
  } while (flag);

  const char* sep = "";
  for (auto& item : A) {
    cout << sep << item;
    sep = " ";
  }
  cout << endl;
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 3080
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int q = Integer.parseInt(sc.next());
		
		String s = sc.next();
		
		int[] i = new int[n];
		
		int account = 0;
		
		for(int j = 1; j < s.length(); j++) {
			if(s.charAt(j-1) == 'A') {
				if(s.charAt(j) == 'C') {
					account++;
				}
			}
			i[j] = account;
		}
		
		List<Integer> res = new ArrayList<Integer>();
		
		for(int j = 0; j < q; j++) {
			int start = Integer.parseInt(sc.next());
			int end = Integer.parseInt(sc.next());

			res.add(i[end-1] - i[start-1]);
		}
		
		for(int j : res) {
			System.out.println(j);
		}
		
	}
}

Measured memory_bytes: 63904
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#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 endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#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; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n;
  cin >> n;
  vector<int> a(1 << n);
  cin >> a;
  sort(all(a));

  multiset<int> s; // どれを子にするかlogで
  rep(i, (1 << n) - 1) s.insert(a[i]); // (1 << n)
  // for (auto e : s) cerr << e << " "; cerr << endl;
  vector<int> x;
  x.eb(a.back());
  a.pop_back();

  rep(i, n) { // days
    rep(j, pow_(2, i)) {
      auto it = s.lower_bound(x[j]);
      if (it == s.begin()) {
        cout << "No" << endl;
        return;
      }
      --it;
      x.eb(*it);
      s.erase(it);
      // cerr << x << endl;
      // for (auto e : s) cerr << e << " "; cerr << endl;
    }
  }
  cout << "Yes" << endl;
}

/*
3
1 1 4 5 8 8 8 9
Yes

9

9
8

9 8
8
5

  8
  9 8 4
1 8
  5
  1
*/


Measured memory_bytes: 16652
"""
                            pppppppppppppppppppp
                         ppppp  ppppppppppppppppppp
                      ppppppp    ppppppppppppppppppppp
                      pppppppp  pppppppppppppppppppppp
                      pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
       ppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppp
      pppppppppppppppppppppppppppppppppppppppppppppppp  ppppppppppppppppppppp
     ppppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppppp
    ppppppppppppppppppppppppppppppppppppppppppppppp    pppppppppppppppppppppppp
   pppppppppppppppppppppppppppppppppppppppppppppp     pppppppppppppppppppppppppp
  ppppppppppppppppppppppppppppppppppppppppppppp      pppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppppppp               pppppppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppp     pppppppppppppppppppppppppppppppppppppppppppppp
  ppppppppppppppppppppppppppp    pppppppppppppppppppppppppppppppppppppppppppppppp
    pppppppppppppppppppppppp  pppppppppppppppppppppppppppppppppppppppppppppppppp
     ppppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppppp
      pppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppp
       ppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
                              pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppp  pppppppp
                              ppppppppppppppppppppp    ppppppp
                                 ppppppppppppppppppp  ppppp
                                    pppppppppppppppppppp
"""


import sys
from functools import lru_cache, cmp_to_key
from collections import defaultdict as dd, deque, Counter as C
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(var, end="\n"): sys.stdout.write(str(var)+end)
def outa(*var, end="\n"): sys.stdout.write(' '.join(map(str, var)) + end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


l, r, d = sp()
answer = 0
for i in range(l, r + 1):
    if i % d == 0:
        answer += 1
out(answer)


Measured memory_bytes: 68592
#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 min(a, b) (a > b ? b : a)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll nck(int n, int k) { ll ret = 1; rep(i, k) {ret *= n - i; ret /= i + 1; } return ret; } // n <= 60
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int n;
vector<int> b;

int solve() {
    
    if (b[0] != 1) return 0;
    
    vector<int> ans;
    rep(i, n) {
        // outa(b, n - i);
        
        int flg = 0;
        for (int j = n - 1 - i; j >= 1; --j) {
            if (b[j] == j + 1) {
                ans.eb(j + 1);
                b.erase(b.begin() + j);
                flg = 1;
                break;
            }
        }
        if (flg) continue;
        
        if (SZ(b) > 1 && b[0] == 1 && b[1] == 1) {
            b.erase(b.begin());
            ans.eb(1);
            
        }
    }
    
    ans.eb(1);
    if (SZ(ans) != n) return 0;
    
    reverse(all(ans));
    rep(i, n) out(ans[i]);
    return 1;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    cin >> n;
    b.resize(n);
    rep(i, n) cin >> b[i];
    
    if (solve() == 0) out(-1);
    
}


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

ll dp[100005],n,h[100005],k;

void boost()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

ll solve(ll currh)
{
	int i;
	if(currh==n)
		return 0;
	if(dp[currh]!=-1)
		return dp[currh];
	ll res=1000000007;
	for(i=1;i<=k;i++)
	{
		if(currh+i<=n)
			res=min(res,abs(h[currh]-h[currh+i])+solve(currh+i));
	}
	return dp[currh]=res;
}

int main()
{
	int i;
	boost();
	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	for(i=1;i<=n;i++)
		cin>>h[i];
	cout<<solve(1)<<endl;
	return 0;
}

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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c;
	d = (a * 100) + (b * 10) + c;
		if (d % 4 == 0)
		{
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
}

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

using namespace std;

int main(){
  map<int, int> mp;
  int n;
  cin >> n;
  for(int x=1;x*x<=n;x++){
    for(int y=1;y*y<=n;y++){
      for(int z=1;z*z<=n;z++){
        mp[x*x+y*y+z*z+x*y+y*z+z*x]++;
      }
    }
  }
  for(int i=1;i<=n;i++){
    cout << mp[i] << endl;
  }
}



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

int main() {
	ll A; double B;
	cin >> A >> B;

	ll ib = B * 100 + 0.5;
	A *= ib;
	A /= 100;

	cout << A << endl;

	return 0;
}


Measured memory_bytes: 3696
use std::cmp::min;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let l:usize = read();
    let r:usize = read();
    if r - l > 3000 {
        println!("0");
    } else {
        let mut ans = 2018;
        for i in l..r {
            for j in i+1..=r {
                ans = min(ans, (i*j)%2019);
            }
        }
        println!("{}", ans);
    }
}

Measured memory_bytes: 2120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		long n = Integer.parseInt(str);

		System.out.println(math(n));
	}
	static long math(long n){
		for(long i = n ; 1 < i ; i--) {

			if (i == 0){
				break;
			}

			n *= (i-1);
		}
		return n;
	}
}

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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
// #define INF 1e9
const ll INF = 1LL << 60;


int main(){
  vector<int> cnt(100008, 0), prime(100008, 0);
  FOR(n, 2, 100001){
    bool isPrime = true;
    for(int j = 2; j * j <= n; j++){
      if(n%j==0){
        isPrime = false;
      }
    }
    if(isPrime){
      prime[n] = 1;
    }
    if(isPrime && (n+1)%2==0 && prime[(n+1)/2]){
      cnt[n]++;
    }
  }
  REP(i, 100001){
    cnt[i+1] += cnt[i];
  }
  int Q;
  cin >> Q;
  REP(i, Q){
    int l, r;
    cin >> l >> r;
    cout << cnt[r] - cnt[l-1] << endl;
  }
  return 0;
}



Measured memory_bytes: 1408
#include <algorithm>
#include<cfenv>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include<numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
using namespace std;
typedef long long llong;
vector<llong> AllDivisors(llong N) {
	vector<llong> ANS;
	for (llong i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ANS.push_back(i);
			if (N / i != i)ANS.push_back(N / i);
		}
	}
	sort(ANS.begin(), ANS.end());
	return ANS;
}
bool IsPrime(llong N) {
	for (llong i = 2; i * i <= N; i++) {
		if (N % i == 0) return false;
	}
	return true;
}
//ここまで共通
int N, M;
int A = 0;
int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a;
		cin >> a;
		A += a;
	}
	if (A <= N) {
		cout << N - A;
	}
	else {
		cout << -1;
	}


}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int inf = 1001001001;
int main() {
    int n, k; cin >> n >> k;
    int a; rep(i, n) cin >> a;
    for(int g=1;g<=n;g++) {
        if(n <= k + (k-1)*(g-1)) {
            cout << g;
            return 0;
        }
    }
}


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

int main()
{
    int t,flag=0;
    cin>>t;
    for(int i=3;i>0;i--)
	{
		if(t%10==7)
		flag=1;
		t=t/10;
	 } 
	 if(flag)cout<<"Yes";
	else cout<<"No";
    return 0;
}

Measured memory_bytes: 3636
/*
======================
[     ___T_          ]
[    | 6=6 | =>HI :-)]
[    |__o__|         ]
[ >===]__o[===<      ]
[     [o__]          ]
[      .".           ]
[      |_|           ]
[                    ]
======================
 */

#include<bits/stdc++.h>
using namespace std;
using lli = int64_t;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int T = 1;
    for(int t = 1; t <= T; t++){
        string s,p;
        cin >> s >> p;
        int min_value = INT_MAX;
        if((int) s.size() == (int) p.size()){
            min_value = 0;
            for(int i = 0; i < (int) s.size(); i++){
                if(s[i] != p[i]){
                    min_value += 1;
                }
            }
            cout << min_value << "\n";
            return 0;
        }
        for(int i = 0; i < (int) s.size() - (int) p.size(); i++){
            int count = 0;
            for(int j = 0; j < (int) p.size(); j++){
                if(s[i + j] != p[j]){
                    count += 1;
                }
            }
            min_value = min(min_value,count);
        }
        cout << min_value << "\n";
    }
}


Measured memory_bytes: 3644