akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <limits>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
constexpr lnt INF = 2e18;
/*-*/

template <typename T = lnt>
struct Dinic
{
	struct Edge
	{
		int a,b;
		T c,f;
		Edge(int a, int b, T c) : a(a),b(b),c(c),f(0) {}
	};
	const T INF;
	int n,m=0;
	std::vector<std::vector<int> > G,Gf;
	std::vector<Edge> E;
	Dinic(int n) : n(n),INF(std::numeric_limits<T>::max()),G(n),Gf(n) {}
	void add_edge(int i, int j, int c) {
		E.emplace_back(i,j,c);
		E.emplace_back(j,i,0);
		G[i].emplace_back(m);
		G[j].emplace_back(m|1);
		m+=2;
	}
	bool bfs(int s, int t) {
		Gf.assign(n,std::vector<int>());
		std::queue<int> que; que.emplace(s);
		std::vector<int> dist(n,INF);
		dist[s]=0;
		while(!que.empty()) {
			int i=que.front(); que.pop();
			for(int to:G[i]) {
				if(dist[E[to].b]!=INF || E[to].c==E[to].f) continue;
				dist[E[to].b]=dist[E[to].a]+1;
				que.emplace(E[to].b);
			}
		}
		if(dist[t]==INF) return true;
		for(int i=0;i<m;i++) {
			if(dist[E[i].a]+1!=dist[E[i].b] || E[i].c==E[i].f) continue;
			Gf[E[i].a].emplace_back(i);
		}
		return false;
	}
	T dfs(int i, T max_flow, const int& t) {
		if(i==t || max_flow==0) {
			return max_flow;
		}
		T v_flow=0;
		for(int to:Gf[i]) {
			if(max_flow==0) break;
			T f=dfs(E[to].b,std::min(max_flow,E[to].c-E[to].f),t);
			if(f>0) {
				E[to].f+=f;
				E[to^1].f-=f;
				v_flow+=f;
				max_flow-=f;
			}
		}
		return v_flow;
	}
	T flow(int s, int t) {
		T max_flow=0;
		while(true) {
			if(bfs(s,t)) break;
			T f = dfs(s,INF,t);
			if(f==0) break;
			max_flow+=f;
		}
		return max_flow;
	}
};

int main() {
	int h,w;
	std::cin >> h >> w;
	std::vector<std::string> g(h);
	rep(i,h) std::cin >> g[i];
	std::vector<std::vector<int> > X(h),Y(w);
	int sx,sy,tx,ty;
	rep(i,h) {
		rep(j,w) {
			if(g[i][j]=='o'||g[i][j]=='S'||g[i][j]=='T') {
				if(g[i][j]=='S') {
					sx=i; sy=j;
				}
				if(g[i][j]=='T') {
					tx=i; ty=j;
				}
				X[i].emplace_back(j);
				Y[j].emplace_back(i);
			}
		}
	}
	if(sx==tx||sy==ty) {
		print(-1);
		return 0;
	}
	auto enc = [&] (int i, int j) {
		return i*w+j;
	};
	debug(sx,sy,tx,ty);
	Dinic<int> flow(2*h*w);
	rep(i,h) {
		for(auto y1:X[i]) for(auto y2:X[i]) {
			if(y1==y2) continue;
			flow.add_edge(enc(i,y1),h*w+enc(i,y2),1);
		}
	}
	rep(i,w) {
		for(auto x1:Y[i]) for(auto x2:Y[i]) {
			if(x1==x2) continue;
			flow.add_edge(enc(x1,i),h*w+enc(x2,i),1);
		}
	}
	rep(i,h) rep(j,w) flow.add_edge(enc(i,j)+h*w,enc(i,j),1);
	print(flow.flow(enc(sx,sy),enc(tx,ty)+h*w));
}


Measured memory_bytes: 84700
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int main()
{
	int i,n,k;
	cin>>n>>k;
	for(i=0;i<=n;i++){
		if(2*(n-i)+4*i==k){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl; 
	return 0;
}


Measured memory_bytes: 3628
// in the name of God
// vaght hast vali kam ast 
#include <bits/stdc++.h>

using namespace std ;

const int MAXN = 1e6 + 100 ; 

int32_t main(){
	ios_base::sync_with_stdio(0) ; 
	cin . tie(0) ; cout . tie(0) ;

	int n ; cin >> n ; 
	int s = 0 , t = 0 ;  
	for(int i = 0 ; i < n ; i ++){
		int x ; cin >> x ;
		if(x == i + 1)
			t ++ ; 
		if(x != i + 1 || i == n - 1){ 
			s += (t + 1) / 2 ;  
			t = 0 ; 
		}
	}

	
	cout << s << '\n' ;
}

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())

A_B = A * X + B * Y
all_C = max(X, Y) * 2 * C
part_C = min(X, Y) * 2 * C + (X < Y) * (Y - X) * B + (Y < X) * (X - Y) * A

print(min(A_B, all_C, part_C))


Measured memory_bytes: 3060
//--- pE ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	public Solution () {
		reader = new Reader();
		while (reader.hasNext()) {
			run_case();
		}
	}
	private void run_case() {
		int N = reader.ni();
		String str = reader.ns();

		List<BIT> list_st = new ArrayList<>();
		for (int i=0; i<26; i++) list_st.add(new BIT(N+1));
		// SegmentTreeRSQ st = new SegmentTreeRSQ(1, N);
		for (int i=0; i<str.length(); i++) {
			int idx = str.charAt(i) - 'a';
			// int t = (int)list_st.get(idx).query(i + 1, i + 1);
			list_st.get(idx).addVal(i, 1);
		}

		int Q = reader.ni();
		StringBuilder str_sb = new StringBuilder(str);
		for (;Q-->0;) {
			// int[] arr = strToIntArray(scanner.nextLine());
			// String[] vals = scanner.nextLine().split("\\s+");

			int q = reader.ni();

			if (q == 1) {
				int i = reader.ni();
				char c = reader.ns().charAt(0);
				int n = str_sb.charAt(i-1) - 'a';
				int m = c - 'a';

				// int t = (int)list_st.get(n).query(i, i);
				list_st.get(n).addVal(i-1, -1);

				str_sb.setCharAt(i-1, c);

				// t = (int)list_st.get(m).query(i, i);
				list_st.get(m).addVal(i-1, 1);
			} else {
				int l = reader.ni()-1;
				int r = reader.ni()-1;
				int cnt = 0;
				for (int i=0; i<26; i++) {
					if (list_st.get(i).getSum(l, r) > 0) cnt ++;
				}
				System.out.println(cnt);
			}
		}
		return;
	}
}

class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public String ns() {return this.next();}
}

class BIT {
	public long[] arr;
	public BIT(int n) {
		arr = new long[n];
	}
	public long getSum(int i) {
		long sum = 0;
		for(i++;i > 0;i -= i&-i)sum += arr[i];
		return sum;
	}
	public long getSum(int l, int r) {
		return getSum(r) - getSum(l-1);
	}
	public void addVal(int i, long v) {
		if(v == 0)return;
		int n = arr.length;
		for(i++;i < n;i += i&-i)arr[i] += v;
	}
}


Measured memory_bytes: 161564
#include <bits/stdc++.h>
using namespace std;
const int limit = 100;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int h, w;
int res = 0;
char a[limit][limit];

void dfs(int x, int y){
    //現在地を探索済みにする、またシンボルを保存
    char simbol = a[x][y];
    a[x][y] = '.';
    //4近傍を探索
    for(int i=0; i < 4; i++){
            int nx = x + dx[i], ny = y + dy[i];
            if(0 <= nx and nx < h and 0 <= ny and ny < w and a[nx][ny] == simbol)
                dfs(nx, ny);
        }
    return;
}

int main(){
    while (1) {
    //結果の初期化
    res = 0;
    cin >> h >> w;
    //停止条件
    if(h == 0 and w == 0) break;
    //mapを格納
    for(int i=0; i < h; i++) for(int j=0; j < w; j++) cin >> a[i][j];


    //search
    for(int i=0; i < h; i++){
        for(int j=0; j < w; j++){
            if(a[i][j] != '.'){
                dfs(i, j);
                res += 1;
            }
        }
    }

    cout << res << endl;
}
    return 0;
}



Measured memory_bytes: 3540
//#define _USE_MATH_DEFINES
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));


bool check(const string& s) {
    vector<bool> go(500);
    go['G'] = go['C'] = go['A'] = go['T'] = true;
    return all_of(begin(s), end(s), [&go](const char c){return go[c];});
}

int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("out.txt", "w", stdout);
//    cin.tie(0);
//    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(0);


    string s;
    cin >> s;
    int best = 0;
    int n = s.length();
    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j <= n; ++j)
            if (check(s.substr(i, j - i)))
                best = max(best, j - i);
    cout << best << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=998244353;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
struct BIT{
    int n,beki=1;
    vector<int>bit;
    BIT(int x){
        bit.resize(x+1,0);
        n=x;
        while(beki*2<=n)beki*=2;
    }
    int sum(int i){
        int res=0;
        while(i>0){
            res+=bit[i];
            res%=mod;
            i-=i&-i;
        }
        return res;
    }
    void add(int i,int x){
        while(i<=n){
            bit[i]+=x;
            bit[i]%=mod;
            i+=i&-i;
        }
    }
    int lowerbound(int w){
        if(w<=0)return 0;
        int x=0;
        for(int k=beki;k>0;k>>=1){
            if(x+k<=n&&bit[x+k]<w){
                w-=bit[x+k];
                x+=k;
            }
        }
        return x+1;
    }
};
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,k,l[15],r[15];
    cin>>n>>k;
    rep(i,k){
        cin>>l[i]>>r[i];
    }
    BIT bit(n);
    bit.add(1,1);
    bit.add(2,mod-1);
    for(int i=1;i<n;i++){
        int x=bit.sum(i);
        rep(j,k){
            if(i+l[j]<=n){
                if(i+r[j]+1<=n)bit.add(i+r[j]+1,(mod-x)%mod);
                bit.add(i+l[j],x);
            }
        }
    }
    cout<<bit.sum(n)%mod<<endl;
    return 0;
}


Measured memory_bytes: 4784
#-------最強ライブラリMath(Python)------
#バグなんてありえないｗｗｗｗｗｗｗｗ
#安心してお使いくださいｗｗｗｗｗｗｗｗｗ

import math
# 累乗(mod)
# O(log n)
def pow_mod(x, n, m):
  # pythonはもともとサポートしている
  return pow(x, n, m)

# 逆元
# O(log m)
def inv_mod(x, m):
  # フェルマーの小定理を利用
  return pow(x, m - 2, m)

# 中国剰余定理
# mod取った値とmodのリストから元の値を復元する
# O(n log lcm(m[i]))
def crt(r, m):
  n = len(r)
  r0, m0 = 0, 1
  for i in range(n):
    r1 = safe_mod(r[i], m[i])
    m1 = m[i]
    if m0 < m1:
      r0, r1 = r1, r0
      m0, m1 = m1, m0
    if m0 % m1 == 0:
      # 解が存在しない場合は0,0
      if r0 % m1 != r1: return (0, 0)
      continue
    g, im = inv_gcd(m0, m1)
    u1 = m1 // g
    # 解が存在しない場合は0,0
    if ((r1 - r0) % g): return (0, 0)
    x = (r1 - r0) // g % u1 * im % u1
    r0 += x * m0
    m0 *= u1
    if r0 < 0: r0 += m0
  return (r0, m0)

# (a * i + b)/m (0 <= i <= n-1) の和
# O(log(n + m + a + b))
def floor_sum(n, m, a, b):
  ans = 0
  if a >= m:
    ans += (n - 1) * n * (a // m) // 2
    a %= m
  if b >= m:
    ans += n * (b // m)
    b %= m
  y_max = (a * n + b) // m
  x_max = y_max * m - b
  if y_max == 0: return ans
  ans += (n - (x_max + a - 1) // a) * y_max
  ans += floor_sum(y_max, a, m, (a - x_max % a) % a)
  return ans

# 負の数を考慮したmod
def safe_mod(x, m):
  x %= m
  if x < 0: x += m
  return x

# gcdと逆元
def inv_gcd(a, b):
  a = safe_mod(a, b)
  if a == 0: return (b, 0)
  s, t = b, a
  m0, m1 = 0, 1
  while t:
    u = s // t
    s -= t * u
    m0 -= m1 * u
    s, t = t, s
    m0, m1 = m1, m0
  if m0 < 0: m0 += b // s
  return (s, m0)

#-------最強ライブラリここまで------

def main():
  T = int(input())
  NMAB = [list(map(int, input().split())) for _ in range(T)]

  for n, m, a, b in NMAB:
    print(floor_sum(n, m, a, b))

main()

Measured memory_bytes: 27220
#include<bits/stdc++.h>
const int N=19,S=65539,mo=1e9+7;
int n,m,i,j,k,mm,f[N][S],a[N],fac[S],inv[S],vf[S],lm,ans,x,xs[S];
inline int C(int n,int m){return 1ll*vf[m]*vf[n-m]%mo*fac[n]%mo;}
int main(){
	for(int i=*vf=*fac=1;i<S;++i)inv[i]=i==1?1:1ll*(mo-mo/i)*inv[mo%i]%mo,
		vf[i]=1ll*vf[i-1]*inv[i]%mo,fac[i]=1ll*fac[i-1]*i%mo;
	scanf("%d%d",&n,&m);for(i=1;i<=m;++i)scanf("%d",a+i);f[m+1][0]=1;
	for(i=m;i;--i)for(j=0,lm=(1<<n)-a[i]+1;j<=lm;++j)for(f[i][j]=(f[i][j]+f[i+1][j])%mo,k=0;k<n && (j|(1<<k))<=lm;++k)
		if(!(j>>k&1))f[i][j|(1<<k)]=(f[i][j|(1<<k)]+1ll*(mo-f[i+1][j])*C(lm-j-1,(1<<k)-1))%mo;
	for(i=*xs=1;i<S;++i)xs[i]=1ll*vf[i&-i]*xs[i^(i&-i)]%mo;
	for(i=0;i<1<<n;++i)ans=(ans+1ll*fac[i]*xs[i]%mo*f[1][(1<<n)-1-i])%mo;
	ans=1ll*(1<<n)*ans%mo;for(i=0;i<n;++i)ans=1ll*fac[1<<i]*ans%mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define LL long long
using namespace std;
const LL Maxn = 1e7+10;
const LL Mod = 1e9+7;
LL n, m, K;
LL jc[Maxn<<1], inv[Maxn<<1];
LL C(LL x, LL y) { return jc[x]*inv[y]%Mod*inv[x-y]%Mod; }
int main() {
	LL i, j, k;
	scanf("%lld%lld%lld", &n, &m, &K);
	jc[0] = 1;
	for(i = 1; i <= n+m; i++) jc[i] = jc[i-1]*i%Mod;
	inv[0] = inv[1] = 1;
	for(i = 2; i <= n+m; i++) inv[i] = inv[Mod%i]*(Mod-Mod/i)%Mod;
	for(i = 2; i <= n+m; i++) inv[i] = inv[i-1]*inv[i]%Mod;
	LL ans = 0;
	if(K >= 2){
		LL res = 0;
		for(i = 2; i <= K; i++){
			res = (res+i*(i-1))%Mod;
		}
		ans = (ans+res*C(n+m-2,K-2)%Mod*jc[K-2]%Mod*n%Mod*m)%Mod;
	}
	LL res = K*(K+1)/2%Mod;
	ans = (ans+res*C(n+m-1,K-1)%Mod*jc[K-1]%Mod*(n+m))%Mod;
	ans = (ans+K*C(n+m,K)%Mod*jc[K])%Mod;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 312704
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//----------------------------------------------------------------------


int main(void) {
  ll a, b, x;

  cin >> x >> a >> b;

  x -= a;

  x = x - (x / b) * b;

  cout << x << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define INF 1007654321
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }

const int MOD = 1e9 + 7;
const int MAXV = 1e5;

int main() {
    FAST_IO();
    int N; cin >> N;
    string S; cin >> S;
    vector<int> LW(N), RE(N);
    rep(i, N) {
        if(i == 0) LW[i] = (S[i] == 'W');
        else LW[i] = LW[i-1] + (S[i] == 'W');
    }
    for(int i = N-1; i >= 0; --i) {
        if(i == N-1) RE[i] = (S[i] == 'E');
        else RE[i] = RE[i+1] + (S[i] == 'E');
    }
    int ans = N;
    rep(i, N) {
        if(i == 0) ans = min(ans, RE[i+1]);
        else if(i == N-1) ans = min(ans, LW[i-1]);
        else ans = min(ans, LW[i-1] + RE[i+1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2964
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const LL MOD = 1000000007LL;
int main() {
	LL A, B, C;
	cin >> A >> B >> C;
	if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
		cout << 0 << endl;
	}
	else {
		cout << min(A*B, min(B*C, C*A)) << endl;
	}
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();
constexpr ll I_MAX = numeric_limits<int>::max();
constexpr ull UI_MAX = numeric_limits<unsigned int>::max();

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)



int main() {

	int n,w;
	cin >> n >> w;


	vector<pair<ll, ll>> wv(n+1);
	vector<ll> empty(w + 1, 0);
	vector<vector<ll>> dp(n+1, empty);

	rep(i, 1, n + 1) {
		ll tw, tv;
		cin >> tw >> tv;
		wv[i] = make_pair(tw, tv);
	}

	rep(i, 1, n + 1) {
		rep(j, 0, w + 1) {
			if (j - wv[i].first >= 0) {
				dp[i][j] = max(dp[i - 1][j - wv[i].first] + wv[i].second, dp[i-1][j]);
			}
			else {
				dp[i][j] = dp[i - 1][j];
			}
		}
	}

	cout << dp[n][w] << endl;

	return 0;
}

Measured memory_bytes: 80256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	S := next()
	if S == "Sunny" {
		fmt.Fprintln(out, "Cloudy")
	} else if S == "Cloudy" {
		fmt.Fprintln(out, "Rainy")
	} else {
		fmt.Fprintln(out, "Sunny")
	}
}

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// Genericsがないので筋肉で...
// interfaceでの取扱がようわからんし
func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// mapからkeysとvaluesを返す感じのやつ
// なんかしらんけどmap[interface{}]interface{}しか受け付けない。なんのためのinterface{}やねん
// なので呼ぶときのmapはmap[int]stringとかじゃダメ
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
	return
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

vector<int> c;
vector<vector<int>> E;

bool dfs(int now){
	for(int i=0;i<E[now].size();i++){
		int to  =E[now][i];
		if(c[now]>c[to]){
			if(!dfs(to))return true;
		}
	}
	
	return false;
}

int main(){
	
	int N;
	cin>>N;
	
	c.resize(N,0);
	E.resize(N,vector<int>());
	
	for(int i=0;i<N;i++)cin>>c[i];
	
	for(int i=0;i<N-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	vector<int> ans;
	for(int i=0;i<N;i++){
		if(dfs(i))ans.push_back(1+i);
	}
	
	for(int i=0;i<ans.size();i++){
		if(i!=0)cout<<' ';
		cout<<ans[i];
	}
	cout<<endl;

	return 0;
}


Measured memory_bytes: 3836
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	set<string>s;
	rep(i,n){
		string tmp;
		cin>>tmp;
		s.insert(tmp);
	}
	cout<<SZ(s)<<endl;
}

Measured memory_bytes: 19136
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#define inRange(x,a,b) (a <= x && x < b)
int di[8] = {0,0,1,-1,1,1,-1,-1};
int dj[8] = {1,-1,0,0,1,-1,1,-1};

int main(){
    int h, w;
    cin >> h >> w;
    char mat[h][w];
    queue<pair<pair<int,int>,int>> q;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> mat[i][j];
            if(mat[i][j] == '#')    q.push({{i,j},0});
        }
    }
    vector<vector<int>> d(h, vector<int>(w, 1<<30));
    int ans = 0;
    while(!q.empty()){
        auto p = q.front(); q.pop();
        int i = p.first.first, j = p.first.second, c = p.second;
        if(d[i][j] <= c)    continue;
        d[i][j] = c;
        ans = max(ans, c);
        for(int k = 0; k < 4; k++){
            int ni = i+di[k], nj = j+dj[k];
            if(inRange(ni,0,h) && inRange(nj,0,w) && mat[ni][nj]=='.' && c+1 < d[ni][nj]){
                q.push({{ni,nj},c+1});
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

ans=N

for i in range(-5,5):
    x=int(N**.5)+i
    if x>0:
        test=x+A+(N-1)//x+1
        ans=min(ans,test)

for n in range(2,41):
    for i in range(n,0,-1):
        for x in range(2,int(N**(1/n))+1000):
            test=x*i+(x+1)*(n-i)
            last=pow(x,i)*pow(x+1,n-i)
            test+=(N-1)//last+1+n*A
            ans=min(ans,test)

print(ans)

Measured memory_bytes: 75108
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

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

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  string S, T;
  cin >> S >> T;
  int S_l = S.length();
  int T_l = T.length();
  int ans = T_l;
  for (int i = 0; i < S_l - T_l + 1; i++) {
    int tmp = 0;
    for (int j = 0; j < T_l; j++) {
      if (T[j] != S[i + j]) {
        tmp++;
      }
      if (tmp > ans) {
        break;
      }
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3636
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];puts("");}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
// #define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

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

	char c;
	cin>>c;
	if(c=='A')cout<<'T'<<endl;
	if(c=='T')cout<<'A'<<endl;
	if(c=='C')cout<<'G'<<endl;
	if(c=='G')cout<<'C'<<endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i] = a[i] % k

if k == 1:
    print(0)
    exit()

ruiseki = [0]
for i in range(n):
    ruiseki.append((a[i]+ruiseki[-1])%k)

mini = 0
dic = {}
ans = 0
for j in range(1, n+1):
    if j-k+1 > mini:
        dic[(ruiseki[mini]-mini)%k] -= 1
        mini += 1
    if (ruiseki[j-1]-(j-1))%k in dic:
        dic[(ruiseki[j-1]-(j-1))%k] += 1
    else:
        dic[(ruiseki[j-1]-(j-1))%k] = 1
    if (ruiseki[j]-j)%k in dic:
        ans += dic[(ruiseki[j]-j)%k]
print(ans)

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

int main()
{
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  
  int ans;
  if (N <= K)
  {
    ans = X * N;
  }
  else
  {
    ans = X * K + Y * (N - K);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc084/tasks/abc084_c
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main()
{
    int N;
    cin >> N;
    vector<int> C(N - 1), S(N - 1), F(N - 1);
    for (int i = 0; i < N - 1; ++i) cin >> C[i] >> S[i] >> F[i];
    if (N == 1)
    {
        cout << S[0] + C[0] << endl;
        return 0;
    }
    vector<int> res(N, 0);
    res[N-1] = 0;
    
    res[N-2] = S[N-2] + C[N-2];
    for (int i = 0; i < N - 2; ++i)
    {
        int t = S[i] + C[i];
        for (int in = i + 1; in < N - 1; ++in)
        {
            if (t > 0 && t <= S[in])
            {
                t = S[in] + C[in];
                continue;
            }
            int m = 1;
            while(true)
            {
                if (t > S[in] + F[in] * (m - 1) && t <= S[in] + F[in] * m)
                {
                    t = S[in] + F[in] * m + C[in];
                    break;
                }
                else ++m;
            }
        }
        res[i] = t;
    }

    for (int i = 0; i < N; ++i)
    {
        cout << res[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const ll mod = 998244353;
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
int main() {
	ll N, M = 0, t;
	cin >> N;
	vector<int> K(N);
	cin >> t;
	if (t == 0) {
		rep(i, 1, N)cin >> t, K[t]++, M = max(M, t);
		if (K[0] == 0) {
			t = K[0] = 1;
			rep(i, 1, M + 1) {
				t *= (ll)mpower(K[i - 1], K[i]);
				t %= mod;
			}
			printf("%lld\n", t);
			return 0;
		}
	}
	puts("0");
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1000000007, INF = 1e18;
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;}



signed main(){
	int A,B,C;
	cin>>A>>B>>C;
	cout<<max(0ll,B-(A-C))<<endl;
}

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

s = list(input())

a = [0] * (n+1)

for i in range(1, n):
    if s[i-1] == "A" and s[i] == "C":
        a[i+1] = a[i] + 1
    else:
        a[i+1] = a[i]

for j in range(q):
    l, r = list(map(int, input().split()))
    print(a[r] - a[l])



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

#define int long long

int d[10001000];

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

	int n,res=0;
	cin>>n;
	for (int i=1; i<=n; i++)
		for (int j=1; i*j<=n; j++){
			d[i*j]++;
		}
			
	for (int i=1; i<=n; i++) res+=d[i]*i;
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 81760
#include<bits/stdc++.h>
using namespace std;
inline int nxt(){int aaa;scanf("%d",&aaa);return aaa;}
vector<int > v[200005];
void solve()
{
    int n=nxt();
    for(int i=0;i<n;i++){
        int in=nxt();
        v[in].push_back(i);
    }
    if(v[1].size()==0){
        cout<<-1<<endl;
        return;
    }
    int x=v[1][0];
    int i=1;
    for(i=2;i<200002;i++){
        if(v[i].size()==0) break;
        int index=upper_bound(v[i].begin(),v[i].end(),x)-v[i].begin();
        //cout<<index<<" "<<v[i].size()<<" "<<v[i][index]<<endl;
        if(index>=v[i].size()) break;
        if(v[i][index]<=x) break;
        x=v[i][index];
    }
    cout<<n-i+1<<endl;

}
int main()
{
    int tc=1;
    while(tc--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 11136
import fractions

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a,b = map(int,input().split())
n = fractions.gcd(a,b)

li = prime_factorize(n)

print(len(set(li))+1)


Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, q; cin >> n >> q;
    string s; cin >> s;
    vector<int> v(n, 0), sum(n+1, 0);
    for (int i = 0; i < n-1; i++) {
        if (s[i] == 'A' && s[i+1] == 'C') {
            v[i+1]++;
        }
    }
    for (int i = 0; i < n; i++) {
        sum[i+1] = sum[i] + v[i];
    }
    for (int qi = 0; qi < q; qi++) {
        int l, r; cin >> l >> r;
        int c = sum[r] - sum[l-1];
        if (v[l-1] == 1) c--;
        cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
typedef long long ll;
#define M 1000000007
int n,x[205];
ll dp[2][205];
int main(void){
    cin>>n;
    for(int i=0;i<n;){
        char c;
        cin>>c;
        if(c=='U')x[i++]=1;
        else if(c=='D')i++;
        else n--;
    }
    dp[0][0]=1;
    for(int i=0,u=1;i<n;i++,u++){
        for(ll j=0;j<=n;j++){
            if(x[i]==1){
                if(j>0)dp[u%2][j]=(dp[i%2][j]*j+dp[i%2][j-1])%M;
                else dp[u%2][j]=dp[i%2][j]*j%M;
            }else{
                dp[u%2][j]=(dp[i%2][j+1]*(j+1)*(j+1)+dp[i%2][j]*j)%M;
            }
        }
    }
    cout<<dp[n%2][0]<<endl;
}


Measured memory_bytes: 3096
import sys

def main():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())

    out = 'NO'

    if V==W:
        if B==A:
            out = 'YES'
            print(out)
            sys.exit()
        else:
            print(out)
            sys.exit()

    if B < A:
        t = (B - A) / (W - V)
    else:
        t = (B - A) / (V - W)
        
    if t >= 0:
        if t<=T:
            out = 'YES'
    
    print(out)
main()

Measured memory_bytes: 9204
#include <cstdio>
#include <algorithm>

using namespace std;

long long get(long long x, int a) {
    if (x < a) {
        return x;
    } else {
        return x + 1;
    }
}

bool check(int a, int b, long long m) {
    long long l = 1, r = m, m1, m2, i;
    
    while (r - l > 10) {
        m1 = l + (r - l) / 3;
        m2 = r - (r - l) / 3;
        
        if ((__int128)get(m1, a) * get(m + 1 - m1, b) > (__int128)get(m2, a) * get(m + 1 - m2, b)) {
            r = m2;
        } else {
            l = m1;
        }
    }
    
    for (i = l; i <= r; i++) {
        if ((__int128)get(i, a) * get(m + 1 - i, b) >= (__int128)a * b) return false;
    }
    
    return true;
}

int main() {
    int q, i;
    
    scanf("%d", &q);
    
    for (i = 0; i < q; i++) {
        int a, b;
        long long l, r, m;
        
        scanf("%d %d", &a, &b);
        
        if (a > b) swap(a, b);
        
        l = 0, r = (long long)a * b, m = (l + r) / 2;
        
        while (r - l > 1) {
            if (check(a, b, m)) {
                l = m;
                m = (l + r) / 2;
            } else {
                r = m;
                m = (l + r) / 2;
            }
        }
        
        printf("%lld\n", l);
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 0; i < 1000; ++i) {
		ostringstream os;
		os << setfill('0') << setw(3) << i;
		string str = os.str();
		int pos = 0;
		for (int j = 0; j < n; ++j) {
			if (str[pos] == s[j]) pos++;
			if (pos == 3) {
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3692
#include <cstdio>
#include <cctype>

int main() {
  char s1[16], s2[16], s3[16];
  scanf("%s %s %s", s1, s2, s3);

  printf("%c%c%c\n", toupper(s1[0]), toupper(s2[0]), toupper(s3[0]));
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

int main(void){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> g(n+1);
    rep(i,0,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<bool> visited(n);
    vector<int> cnt(n,-1);
    // dijkstra
    queue<int> q;
    q.push(0);
    cnt[0]=0;
    while(!q.empty()){
        int id=q.front();q.pop();
        visited[id]=true;
        for(int i=0;i<g[id].size();i++){
            int idx=g[id][i];
            if(visited[idx])continue;
            q.push(idx);
            visited[idx]=true;
            cnt[idx]=id;
        }
    }
    rep(i,0,n){
        if(cnt[i]==-1){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    rep(i,1,n)cout<<cnt[i]+1<<endl;
    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int a, b;cin >> a >> b;
    string s;cin >> s;
    if(s[a] != '-'){
        cout << "No" << endl;
        return 0;
    }
    s[a] = '0';
    for(auto c : s){
        if(c < '0' || '9' < c){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int L,R,d;
	cin>>L>>R>>d;
	int ret=0;
	for(int i=L; i<=R; i++){
		if(i%d==0){
			ret++;
		}
	}
	cout<<ret<<endl;
	return 0;
}

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

int main(){
  char s[200006];
  char t[200006];
  scanf("%s %s", s, t);
  int cnt = 0;
  int n;
  n = strlen(s);
  int i;
  for(i = 0;i < n;i++){
    if(s[i] != t[i]) cnt++;
  }

  printf("%d\n",cnt);
  return 0;
}


Measured memory_bytes: 4188
#include <bits/stdc++.h>
using namespace std;
const int max_v = 1000;
int v,E,n,m;
int d[max_v][max_v];
int s[max_v], c[max_v];
pair<int , int> p[max_v];
const int INF = 1e9;
vector<int> ls;

void solve(){

    for(int i=0 ; i+1<m ; i++){
        if((p[i].first == p[i+1].first && p[i].second != p[i+1].second) || (p[i].first == 1&& p[i].second == 0)){
            puts("-1"); return;
        }
    }
    if(p[m-1].first == 1 && p[m-1].second == 0){
        if(n!=1){puts("-1"); return;}
    }
    int sum = 0;

        int i = 0;
        if(p[i].first == 1 ){
        sum += p[i].second *  pow(10 ,n-1);
        }
        while(p[i].first == 1){
        i++;
        }
        if(p[i].first == 2 && n-2 >=0){
           sum += p[i].second * pow(10 , n-2);
        }
        while(p[i].first == 2)i++;
        if(p[i].first == 3 && n-3 >= 0){
           sum += p[i].second * pow(10, n-3);
        }
        if(n == 3 && sum<100)    sum += 100;
        if(n == 2 && sum<10)    sum += 10;
        
    cout << sum << endl;
}
int main(){
    cin >> n >> m;
    for(int i=0 ; i<m ; i++){
        cin >> p[i].first >> p[i].second;
    }
    sort(p, p+m);
    solve();
    return 0;
}

Measured memory_bytes: 256
package main

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

type Count [][]int

func (c Count) Len() int {
	return len(c)
}
func (c Count) Less(i, j int) bool {
	return c[i][0] >= c[j][0]
}
func (c Count) Swap(i, j int) {
	c[i], c[j] = c[j], c[i]
}

func main() {
	var n int
	fmt.Scan(&n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	countMap := make(map[int]int)
	for i := 0; i < n; i++ {
		scanner.Scan()
		a, _ := strconv.Atoi(scanner.Text())
		countMap[a]++
	}

	var count Count
	for k, v := range countMap {
		count = append(count, []int{v, k})
	}
	sort.Sort(count)

	if len(count) == 1 {
		if count[0][1] == 0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
		return
	}

	if n%3 != 0 {
		fmt.Println("No")
		return
	}

	u := n / 3
	if len(count) == 2 {
		if count[0][0] == 2*u && count[1][0] == u {
			if count[1][1] == 0 {
				fmt.Println("Yes")
				return
			}
		}
		fmt.Println("No")
		return
	}

	if len(count) == 3 {
		if count[0][0] == u && count[1][0] == u && count[2][0] == u && count[0][1]^count[1][1] == count[2][1] {
			fmt.Println("Yes")
			return
		}
	}

	fmt.Println("No")
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

const int MOD = int(1e9) + 7;

int n;
int d[1000005];

int main() {
    cin >> n;
    d[0] = 1;
    int sum = 1;
    for (int i = 1; i <= n - 1; ++i) {
        d[i] = sum;
        if (i >= 2) {
            d[i] -= d[i - 2];
            if (d[i] < 0) {
                d[i] += MOD;
            }
        }
        sum += d[i];
        if (sum >= MOD) {
            sum -= MOD;
        }
    }
    int ans = (sum - d[n - 1]) * (LL)(n - 1) % MOD * (n - 1) % MOD;
    ans = (ans + (LL)d[n - 1] * n) % MOD;
    forn(i, n - 1) {
        int cnt = i + 2;
        if (i + 2 >= n) {
            --cnt;
        }
        ans = (ans + (LL)cnt * d[i]) % MOD;
    }
    if (ans < 0) {
        ans += MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using lond = long double;

int main(){
	int n;
	cin >> n;
	int de = n % 10;
	if (de ==3)
		cout << "bon" << endl;
	else if (de == 0 || de == 1 || de == 6 || de == 8)
		cout << "pon" << endl;
	else
		cout << "hon" << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <numeric>
#include <list> 
#include <cmath>
#include <stdio.h>

using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()
#define INF (1e9)

typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> P;

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

int main() {
	int N, H, W;
	cin >> N;
    cin >> H; 
    cin >> W;
    printf("%d", (N - H + 1) * (N - W + 1));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
const int max_n = 1e5;
const ll mod = 1e9+7;
void send(int a,int b,int c,int d){
  printf("%d %d %d %d\n",a,b,c,d);
}
struct edge{
  int to;
  ll cost;
};
vector<ll> v[200000];
ll ans[200000];
void dfs(int u, int pre){//根uでカウントk
  for(int next : v[u]){
    if(next!=pre){
       ans[next] += ans[u];
       dfs(next, u);
    }
  }
}
int main(){
  int n,q;  cin >> n >> q;

  rep(i,0,n-1){
    int x,y;  cin >> x >> y;  --x;  --y;
    v[y].pb(x);
    v[x].pb(y);
  }
  ll sum = 0;
  rep(i,0,q){
    int x; ll y;  cin >> x >> y;
    --x;
    ans[x] += y;
  }
  dfs(0,-1);
  rep(i,0,n){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 24320
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define forn(i,n)for(ll i=0;i<(n);i++)
#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)
#define for1n(i,n) for(ll i=1;i<=(n);i++)
#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)
#define MOD 1000000007
#define MAXN 100000

using namespace std;


void bfs(vector<vector<char>> &arr,ll &l,ll r,ll N,ll M){

    queue<pair<ll,ll>> q;
    q.push({l,r});
    while(!q.empty()){
        pair<ll,ll> a=q.front();

        q.pop();
        if(arr[a.first][a.second]=='.') arr[a.first][a.second]='B';
        char ch=arr[a.first][a.second];
        if(a.second>0 && arr[a.first][a.second-1]=='.') {
                q.push({a.first,a.second-1});
                if(ch=='B') arr[a.first][a.second-1]='W';
                else arr[a.first][a.second-1]='B';
        }
        if(a.second<M-1 && arr[a.first][a.second+1]=='.') {
                q.push({a.first,a.second+1});
                if(ch=='B') arr[a.first][a.second+1]='W';
                else arr[a.first][a.second+1]='B';
        }
        if(a.first>0 && arr[a.first-1][a.second]=='.') {
                q.push({a.first-1,a.second});
                if(ch=='B') arr[a.first-1][a.second]='W';
                else arr[a.first-1][a.second]='B';
        }
        if(a.first<N-1 && arr[a.first+1][a.second]=='.') {
                q.push({a.first+1,a.second});
                if(ch=='B') arr[a.first+1][a.second]='W';
                else arr[a.first+1][a.second]='B';
        }

    }

}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    ll T=1;
    //cin>>T;
    while(T--)
    {
        ll N;
        cin>>N;
        ll ans=0;
        ll g;
        for1n(i,N){
            if(i%3==0 || i%5==0 || i%15==0){
                g=1;
            }
            else ans+=i;
        }
        cout<<ans;


    }





    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
using namespace std;
int main()
{
	int n,tmp=0;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	do{
		bool f=false;
		for(int i=1;i<=n;i++)
		{
			if(a[i]%2!=0)
			{
				f=true;
				break;
			}
		}
		if(f) break;
		for(int i=1;i<=n;i++)
		{
			a[i]=a[i]/2;
		}
		tmp++;
	}while(1);
	cout<<tmp<<endl;
	return 0;
}

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

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
#define mp make_pair
const long long mod = 1000000007;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);
    ll n;
    cin >> n;
    string A,B,C;
    cin >>A >> B >> C;
    ll cnt = 0;
    for(ll i =0;i<n;i++)
        if(A[i]==B[i])
        {
            if(B[i]!=C[i])
                cnt++;
        }
        else if(A[i]==C[i])
        {
            if(B[i]!=C[i])
                cnt++;
        }
        else if(B[i]==C[i])
        {
            if(A[i]!=B[i])
                cnt++;
        }
        else cnt += 2;
    cout << cnt ;
    return 0;
}

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



int main(void) {
  int n;
  int *dist;
  list<pair<int,int>> *lst;
  queue<int> q;
  
  cin >> n;
  dist = new int[n+1];
  lst = new list<pair<int,int>>[n+1];
  
  for (int i = 0; i < n - 1; i++) {
    pair<int,int> p;
    int u, v, w;
    cin >> u >> v >> w;
    p = {v,w};
    lst[u].push_front(p);
    p = {u,w};
    lst[v].push_front(p);
  }
  
  for (int i = 1; i < n + 1; i++) {
    dist[i] = -1;
  }
  
  dist[1] = 0;
  q.push(1);
  while( !q.empty() ) {
    int c = q.front();
    
    q.pop();
    for (list<pair<int,int>>::iterator itr = lst[c].begin(); itr != lst[c].end(); itr++) {
      if (dist[itr->first] == -1) {
        dist[itr->first] = dist[c] + itr->second;
        q.push(itr->first);
      }
    }
  }
    
  for (int i = 1; i <= n; i++) {
    cout << (dist[i] % 2 == 0 ? '0' : '1') << endl;
  }
  
  return 0;
}
  

Measured memory_bytes: 8704