akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1e18;

P x[100001], y[100001];

typedef struct edge_ {
		int from, to, cost;
		edge_(int f, int t, int c): from(f), to(t), cost(c){};
} edge;

bool comp(const edge &ed1, const edge &ed2){
		return ed1.cost < ed2.cost;
}

int par[100001];
int r[100001];
int n;

void init(){
		for(int i = 0; i < n; i++){
				par[i] = i;
		}
}

int find(int x){
		if(par[x] == x)return x;
		else return par[x] = find(par[x]);
}

void unite(int x, int y){
		int xp = find(x);
		int yp = find(y);
		if(xp == yp)return;
		if(r[xp] > r[yp]){
				par[yp] = xp;
		}else{
				par[xp] = yp;
				if(r[xp] == r[yp])r[yp]++;
		}
}

int main(int argc, char const* argv[])
{
	cin >> n;
	for(int i = 0; i < n; i++){
			int xx, yy;
			cin >> xx >> yy;
			x[i] = mk(xx, i);
			y[i] = mk(yy, i);
	}
	sort(x, x + n);
	sort(y, y + n);
	vector<edge> vec;
	for(int i = 0; i < n - 1; i++){
			vec.pb(edge(x[i].second, x[i+1].second, x[i+1].first - x[i].first));
			vec.pb(edge(y[i].second, y[i+1].second, y[i+1].first - y[i].first));
	}
	sort(vec.begin(), vec.end(), comp);
	init();
	ll res = 0;
	for(auto itr = vec.begin(); itr != vec.end(); ++itr){
			int from = (*itr).from;
			int to = (*itr).to;
			int cost = (*itr).cost;
			if(find(from) == find(to))continue;
			res += cost;
			unite(from, to);
	}
	cout << res << endl;
	return 0;
}


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

ll f(ll a, ll b) {
  if (a == b) return a;
  if (a > b) swap(a, b);
  if (b % a == 0) return 2 * ((b - 1) / a) * a + f(a, a);
  return 2 * (b / a) * a + f(a, b % a);
}

int main() {
  ll N, X; cin >> N >> X;
  cout << N + f(N - X, X) << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range (n):
    if(a[i]>=b[i]):
        ans+=b[i]
    elif(a[i+1]<b[i]-a[i]):
        ans+=a[i]+a[i+1]
        a[i+1]=0
    else:
        ans+=b[i]
        a[i+1]-=b[i]-a[i]
print(ans)


Measured memory_bytes: 18476
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        if (b <= c || d <= a) {
            System.out.println(0);
        } else if (a <= c && b <= d) {
            System.out.println(b - c);
        } else if (a <= c && b > d) {
            System.out.println(d - c);
        } else if (a > c && b <= d) {
            System.out.println(b - a);
        } else {
            System.out.println(d - a);
        }
    }
}


Measured memory_bytes: 22996
using System;
public class Hello{
    public static void Main(){
        int N = int.Parse(Console.ReadLine());
        int[] A = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
        int[] B = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
        int sum = 0;
        int ans = 0;
        for(int x = 0;x < N;x++){
            for(int a = 0;a <= x;a++){
                sum += A[a];
            }
            for(int b = x;b < N;b++){
                sum += B[b];
            }
            if(sum > ans){
                ans = sum;
            }
            sum = 0;
        }
        Console.WriteLine(ans);
        
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y;
cin >> x >> y;
int n = y+x-1;
for(int i=y-x+1;i<=n;i++){

    cout << i ;
    if(i!=n)
        cout << " ";
}
cout << endl;


return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			double a = 0;
			double x = sc.nextInt();
			double h = sc.nextInt();
			if(x == 0 && h == 0)break;
			double t=x/2;
			double b=Math.sqrt(h*h+t*t);
			a = (x*x)+(b*x*2);
			System.out.printf("%6f\n",a);
	}
}
}

Measured memory_bytes: 17200
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <string>

using namespace std;
typedef long long ll;

int solve();

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

//	sday日目とeday日目だけの取引でeday日目の所持金を最大化する
//	pは株価の配列、dはsday日目の所持金の最大値
int knap(const vector<vector<int>> &p,
	const int d,
	const int sday,
	const int eday) 

{
	const int n = p[sday].size();

	vector< int > v(n), w(p[sday]);
	for (int i = 0; i < n; i++)
		v[i] = p[eday][i] - p[sday][i];

	//　i番目までの株を使って利益を最大化する
	// 漸化式
	// Q[j + m * w[i]] = max( Q[i][j + m * w[0] ], Q[i][j] + m * v[0] )

	const int dmax = d + 1;
	vector<int> Q(dmax, 0);

	for (int i = 0; i < n; i++) {
		if (v[i] <= 0) { continue; }
		for (int j = 0; j < dmax; j++) {
			if (j + w[i] < dmax)
				Q[j + w[i]] = max(Q[j + w[i]], Q[j] + v[i]);
		}
	}

	int m = *max_element(Q.begin(), Q.end());

	return m + d;
	
}


int solve() {

	int n, d, x;

	cin >> n >> d >> x;
	vector<vector<int>> p(d, vector<int>(n));

	for (int i = 0; i < d; i++)
		for (int j = 0; j < n; j++)
			cin >> p[i][j];

	vector<int> xmax(d, x);

	for (int i = 0; i < d; i++) {
		for (int j = i + 1; j < d; j++) {
			xmax[j] = max(xmax[j], knap(p, xmax[i], i, j));
		}
	}

	cout << xmax[d - 1] << endl;

	return 0;
}


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

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

  int i;
  int a, b;
  vector<int> city(N,0);
  for (i=0;i<M;i++){
    cin >> a >> b;
    city.at(a-1)++;
    city.at(b-1)++;
  }

  for (i=0;i<N;i++){
    cout << city.at(i) << endl;
  }
}

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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    
    int tot = 0;
    
    for (int i = 0; i < m; ++i) {
        int x;
        cin >> x;
        tot += x;
    }
    
    int ans = n - tot;
    
    cout << (ans >= 0 ? ans : -1) << endl;
    
    return 0;
}


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

using namespace std;
using ll = long long;

#define INF (1LL << 60)

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i,0,N) cin >> A[i];

    ll S = 0;
    REP(i,0,N) S += A[i];

    ll T = 0;
    for(ll i=1; i<=N-2; i+=2) T += A[i];
    ll x = S - T * 2;
    _PS(x);
    REP(i,1,N) {
        x = 2 * A[i-1] - x;
        _PS(x);
    }


    return 0;
}

/*



*/

Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstring>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()
#define pb push_back

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

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

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

	string s;
	cin >> s;

	ll cnt = 0;

	// 両方の数の個数を数えて引く

	ll zeroNum = 0;
	ll oneNum = 0;

	rep(i, s.size()) {
		if (s[i] == '0') {
			zeroNum++;
		}
		else {
			oneNum++;
		}
	}

	if (zeroNum >= oneNum) cnt = oneNum * 2;
	else cnt = zeroNum * 2;

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int interest (int i){
	return (int)(i * 1.05 + 0.999);
}

int main(void) {
	int n, debt = 100;
	scanf ("%d", &n);
	while (n > 0){
		debt = interest (debt);
		n--;
	}
	printf ("%d\n", debt * 1000);
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define lbound lower_bound
#define ubound upper_bound
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define heap_min priority_queue<int,vector<int>,greater<int>>
#define heap_max priority_queue<int>
#define precision(x) cout << setprecision(x) << fixed;
#define printv(v) for(auto p : v) cout << p << " ";
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout << a[i] << " "; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int32_t main()
{
   fast;
   #ifndef ONLINE_JUDGE
   freopen("goodluckin.txt","r",stdin);
   freopen("goodluckout.txt","w",stdout);
   #endif
   int n,k;
   cin >> n >> k;
   int a[n];
   for(int i = 0 ; i < n ; i++){
      cin >> a[i];
   }
   for(int i = k ; i < n ; i++){
    if(a[i] > a[i-k]){
      cout << "Yes\n";
    }
    else{
      cout << "No\n";
    }
   }
   
}


Measured memory_bytes: 5212
#include <iostream>

int main(){
   int A, B, C, X;
   std::cin >> A >> B >> C >> X;
   int cnt = 0;
   for (int i=0; i<=A; ++i){
      for (int j=0; j<=B; ++j){
         for (int k=0; k <=C; ++k){
            if (500*i + 100*j +50*k == X){
               cnt++;
            }
         }
      }
   }
   std::cout << cnt << std::endl;

}



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
M = 10**6 + 5
cnt = [0 for _ in range(M)]

for i in A:
    if cnt[i] != 0:
        cnt[i] = 2
        continue
    
    j = i
    while j < M:
        cnt[j] += 1
        j += i
ans = 0
for i in A:
    if cnt[i] == 1:
        ans += 1
print(ans)

Measured memory_bytes: 195384
/* به نام یزدان */
#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 100 * 1000 + 10;
vector<int> adj[MAX_N], rev[MAX_N], topol;
int n, m, dp[MAX_N];
bool mark[MAX_N];

void read_input() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
		rev[v].push_back(u);
	}
}

void dfs(int v) {
	mark[v] = true;
	for (int u: adj[v])
		if (!mark[u])
			dfs(u);
	topol.push_back(v);
}

void solve() {
	for (int v = 0; v < n; v++)
		if (!mark[v])
			dfs(v);
	reverse(topol.begin(), topol.end());
	for (int v: topol)
		for (int u: rev[v])
			dp[v] = max(dp[v], dp[u] + 1);
}

void print_output() {
	int ans = 0;
	for (int i = 0; i < n; i++)
		ans = max(ans, dp[i]);
	cout << ans;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	read_input();
	solve();
	print_output();
}


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < int(s.size()) - 1; ++i) {
    if (s.substr(i, 2) == "AC") {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}



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

int main(){
    int n;
    cin>>n;
    vector<int>v;
    while(n!=0){
        v.push_back(n%10);
        n/=10;
    }
    for(int i=v.size()-1;i>=0;i--){
        if(v[i]==9)cout<<1;
        else cout<<9;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
long long gcd (long long a,long long b)
{
	if(b==0) return a;
	return gcd (b,a%b);
}
int main()
{
	int n,i;
	long long s,t,b[5000];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%lld",&b[i]);
	t=b[0];
	for(i=1;i<n;i++)
		t=b[i]/gcd(t,b[i])*t;
	printf("%lld\n",t);
	return 0;
}

Measured memory_bytes: 128
n,k=map(int, input().split())
a=list(map(int, input().split()))
dp=[0]*n
for i in range(1,n):
    m=10**9
    for j in range(max(0,i-k),i):
        m=min(m,dp[j]+abs(a[j]-a[i]))
    dp[i]=m
print(dp[-1])

Measured memory_bytes: 52448
var
    s:string;
	c,f,i:integer;
begin
    readln(s);
	c:=0;
	f:=0;
	for i:=1 to length(s) do
	begin
	    if s[i]='C' then c:=i;
		if s[i]='F' then f:=i;
        if c=0 then f:=0;
	end;
    if (c<>0)and(f<>0) then writeln('Yes')
	else writeln('No');
end.

Measured memory_bytes: 128
// Problem : E - Rem of Sum is Num
// Contest : AtCoder - AtCoder Beginner Contest 146
// URL : https://atcoder.jp/contests/abc146/tasks/abc146_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 200005

//Solution

int n,k;
int a[N];
mi m;

int get(int a, int b){
    //return (a-b+k)%k;
    int x = a-b;
    while(x < 0) x += k;
    return x%k;
}

void solve(){
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i], a[i] += a[i-1];
    m[0]++;
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(i >= k) m[get(a[i-k],i-k)]--;
        ans += m[get(a[i],i)];
        m[get(a[i],i)]++;
    }
    cout<<ans<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

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

using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> inline void sort_uniq(T& c) { sort(all(c)); c.erase(unique(all(c)), c.end()); }
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    ll H, W; cin >>H>>W;
    if (H%3==0 || W%3==0) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = LLONG_MAX;

    for (int i = 0; i < 2; i++) {
        for (ll h = 1; h < H; h++) {
            ll a, b, c, d;
            a = h * W;
            b = (H-h)/2 * W;
            c = (H - h - (H-h)/2) * W;
            d = max({a,b,c}) - min({a,b,c});
            chmin(ans, d);
            b = (H-h) * (W/2);
            c = (H-h) * (W-(W/2));
            d = max({a,b,c}) - min({a,b,c});
            chmin(ans, d);
        }
        swap(H, W);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
def dist(list_x,list_y,p):
    sum = 0
    for i in range(len(list_x)):
        sum += abs(list_x[i]-list_y[i])**p
    return print(sum**(1/p))


def infi(list_x,list_y):
    sum=[]
    for i in range(len(list_x)):
        sum.append(abs(list_x[i]-list_y[i]))
    return print(max(sum))

#%%
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

dist(x,y,p=1)
dist(x,y,p=2)
dist(x,y,p=3)
infi(x,y)



Measured memory_bytes: 5644
#include<bits/stdc++.h>
#define rint register int 
#define ll long long 
using namespace std;
const int mod = 1e9+7;
const int Max = 2020;
inline int add(int x,int y){x+=y;if(x>=mod) x-=mod;return x;}
inline ll ksm(ll x,ll y){
	ll res=1;while(y){
		if(y&1) res=res*x%mod;
		x=x*x%mod;y>>=1;
	}
	return res;
}
int f[5555][5555],n,A[401010],B[401000],fac[100010],Ifac[101000];
inline int C(int x,int y){
	return 1ll*fac[x]*Ifac[y]%mod*Ifac[x-y]%mod;
}
int main() {
	cin>>n;
	for(rint i=1;i<=n;++i) cin>>A[i]>>B[i],f[Max-A[i]][Max-B[i]]++;
	for(rint i=1;i<=Max*2;++i) {
		for(rint j=1;j<=Max*2;++j) {
			f[i][j]=add(f[i][j],f[i][j-1]);
			f[i][j]=add(f[i-1][j],f[i][j]);
		}
	}fac[0]=Ifac[0]=1;
	for(rint i=1;i<=Max*4;++i) fac[i]=1ll*fac[i-1]*i%mod;
	Ifac[Max*4]=ksm(fac[Max*4],mod-2);
	for(rint i=Max*4-1;i;--i) Ifac[i]=1ll*(i+1)*Ifac[i+1]%mod;
	int ans=0;
	//cout<<C(4,2)<<endl; 
	for(rint i=1;i<=n;++i) ans=add(ans,f[Max+A[i]][Max+B[i]]),ans=add(ans,mod-C((A[i]+B[i])*2,A[i]*2));
	cout<<1ll*ans*ksm(2,mod-2)%mod;
	return 0;	
} 

Measured memory_bytes: 85144
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
void swap(int* a, int* b){
	int tmp;
	tmp = *a; *a = *b; *b = tmp;
}
int main(void) {
	int a,b;
	while (1){
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0) break;
		if (b < a) swap(&a, &b);
		printf("%d %d\n", a, b);
	}
	return 0;
}

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

x1 = A * X + B * Y
if X > Y:
  x2 = Y * 2 * C + (X - Y) * A
else:
  x2 = X * 2 * C + (Y - X) * B
x3 = max(X, Y) * 2 * C

print(min(x1, x2, x3))

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    map<int, long long> m;
    for (int i = 0; i < n; i++) m[a[i]]++;
    long long all = 0;
    for (auto &iter: m) {
        all += (iter.second-1) * iter.second / 2;
    } 
    for (int i = 0; i < n; i++) {
        cout << all - (m[a[i]]-1) << "\n";
    }
    return 0;
}

Measured memory_bytes: 10368
S = input()
Q = int(input())

is_reversed = False
head = ""

for i in range(Q):
    tmp_Q = input().split()

    if len(tmp_Q) == 1:
        is_reversed = not is_reversed
        
    else:
        if tmp_Q[1] == "1":
            if is_reversed:
                S = S + tmp_Q[2]
            else:
                head = head + tmp_Q[2]
        else:
            if is_reversed:
                head = head + tmp_Q[2]
            else:
                S = S + tmp_Q[2]

if is_reversed:
    print(S[::-1] + head)
else:
    print(head[::-1] + S)

Measured memory_bytes: 4476
// #define MODULAR_ARITHMETIC
// #define INDEXED_SET
#ifndef LOCAL_DEBUG
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#endif

#include <stdarg.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <chrono>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <set>
#define pb push_back
#define mp make_pair
#define f(i, a, b) for (int i = a; i < b; i++)
#define revf(i, b, a) for (int i = b; i >= a; i--)
#define srt(v) sort(v.begin(), v.end())
#define rev_srt(v) sort(v.rbegin(), v.rend())
using namespace std;

#ifdef MODULAR_ARITHMETIC
template <typename T>
T add(T a, T b, T c)
{
	T res = a + b;
	return (res >= c ? res - c : res);
}
template <typename T>
T mod_neg(T a, T b, T c)
{
	T res;
	if (abs(a - b) < c)
		res = a - b;
	else
		res = (a - b) % c;
	return (res < 0 ? res + c : res);
}
template <typename T>
T mul(T a, T b, T c)
{
	ll res = (ll)a * b;
	return (res >= c ? res % c : res);
}
ll mulmod(ll a, ll b, ll m)
{
	ll q = (ll)(((LD)a * (LD)b) / (LD)m);
	ll r = a * b - q * m;
	if (r > m)
		r %= m;
	if (r < 0)
		r += m;
	return r;
}
template <typename T>
T expo(T e, T n)
{
	T x = 1, p = e;
	while (n)
	{
		if (n & 1)
			x = x * p;
		p = p * p;
		n >>= 1;
	}
	return x;
}
template <typename T>
T power(T e, T n, T m)
{
	T x = 1, p = e;
	while (n)
	{
		if (n & 1)
			x = mul(x, p, m);
		p = mul(p, p, m);
		n >>= 1;
	}
	return x;
}
template <typename T>
T extended_euclid(T a, T b, T &x, T &y)
{
	T xx = 0, yy = 1;
	y = 0;
	x = 1;
	while (b)
	{
		T q = a / b, t = b;
		b = a % b;
		a = t;
		t = xx;
		xx = x - q * xx;
		x = t;
		t = yy;
		yy = y - q * yy;
		y = t;
	}
	return a;
}
template <typename T>
T mod_inverse(T a, T n)
{
	T x, y, z = 0;
	T d = extended_euclid(a, n, x, y);
	return (d > 1 ? -1 : mod_neg(x, z, n));
}
#endif

#ifdef INDEXED_SET
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#endif

#define endl '\n'
#define precision(x) cout << fixed << setprecision(x);
#define fio                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

ll mod = 1e9 + 7;
const int max_n = 5.0 * 1e5 + 5;

void solvetestcase()
{
	int n;
	cin >> n;
    vi a(n+1);
    f(i,0,n){
        int num;
        cin>>num;
        a[num] = i+1;
    }
    f(i,0,n) cout<<a[i+1]<<" ";
}

int main()
{
	fio;
	int t = 1;

	// UNCOMMENT FOR TESTCASES	\
	cin >> t;

	f(T, 1, t + 1)
	{
		// UNCOMMENT FOR CODEJAM,HACKERCUP	\
		cout << "Case #" << T << ": ";
		solvetestcase();
	}
};

/*
    AUTHOR:     KUNAL TAWATIA
    EDUCATION:  INDIAN INSTITUTE OF TECHNOLOGY, JODHPUR
*/

Measured memory_bytes: 1280
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

/*

*/

struct Factorial{
	long long N,mod;
	vector<long long> fact,inv;
	long long mod_pow(long long x,long long n){
		long long res=1;
		while(n){
			if(n&1) (res*=x)%=mod;
			(x*=x)%=mod;
			n>>=1;
		}
		return res;
	}
	long long Inverse(long long n){
		return mod_pow(n,mod-2);
	}
	Factorial(){}
	Factorial(long long sn,long long smod){
		N=sn; mod=smod;
		fact.reserve(sn+1); inv.reserve(sn+1);
		//初期化
		fact[0]=1;
		for(int i=1;i<=sn;i++){
			fact[i]=(fact[i-1]*i) % mod;
		}
		inv[sn]=Inverse(fact[sn]);
		for(int i=sn;i>0;i--){
			inv[i-1]=(inv[i]*i) % mod;
		}
	}
	long long Fact(long long n){
		if(n<0)return 0;
		return fact[n];
	}
	long long Inv(long long n){
		if(n<0)return 0;
		return inv[n];
	}
	long long Combination(long long n,long long r){
		if(n<r)return 0;
		if(r<0)return 0;
		if(r==0)return 1;
		long long ans=1;
		ans = (ans*Fact(n)) % mod;
		ans = (ans*Inv(r)) % mod;
		ans = (ans*Inv(n-r)) % mod;
		return ans;
	}
	long long plus(long long a,long long b){
		a%=mod;
		b%=mod;
		return (a+b)%mod;
	}
	long long minus(long long a,long long b){
		a%=mod;
		b%=mod;
		return (a+mod-b)%mod;
	}
	long long mul(long long a,long long b){
		a%=mod;
		b%=mod;
		return (a*b)%mod;
	}
	long long div(long long a,long long b){
		a%=mod;
		b%=mod;
		return (a*Inverse(b))%mod;
	}
};

int main(void){
	ll n,a[100010],visit[100010]={},l,r,c,mod=1e9+7;
	Factorial f(100010,mod);
	cin>>n;
	reg(i,1,n+1){
		cin>>a[i];
		if(visit[a[i]]==0){
			visit[a[i]]=i;
		}else{
			l=visit[a[i]]-1;
			r=n+1-i;
		}
	}
	reg(k,1,n+1){
		cout<<(f.Combination(n+1,k)-f.Combination(l+r,k-1)+mod)%mod<<endl;
	}
	return 0;
}

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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    string s; cin >> s;
    int n = s.size();
    cout << s[0] << n-2 << s[s.size()-1] << endl;
    return 0;
}

Measured memory_bytes: 3608
N, T = map(int, input().split())
t = [int(e) for e in input().split()]

prev_t = t[0]
ans = T
for _t in t[1:]:
    delta_t = _t - prev_t
    if delta_t <= T:
        ans += delta_t
    else:
        ans += T
    prev_t = _t
print(ans)

Measured memory_bytes: 25196
import java.util.Scanner;
import java.util.Arrays;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()){
            boolean first=true;
            int n = sc.nextInt();
            String dec = Integer.toBinaryString(n);
            for(int i=dec.length()-1; i>=0; i--){

                if(Integer.parseInt(dec.substring(i,i+1))==1){
                    //System.out.println("substring;"+dec.substring(i,i+1));               
                    if(first){
                        first=false;
                        System.out.print((int)Math.pow(2,dec.length()-1-i));
                    }else{
                        System.out.print(" "+(int)Math.pow(2,dec.length()-1-i));
                    }
                }
            }
             System.out.println();
        }
    }
}




Measured memory_bytes: 26252
N = int(input())
A = list(map(int ,input().split()))
MOD = 10**9+7

sum = 0
for i in range (N):
    sum += A[i] % MOD

ans = 0
for i in range(N):
    sum -= A[i]
    ans += (A[i] * sum) % MOD

ans = ans % MOD
print(ans)

Measured memory_bytes: 31436
#include <stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if((a==5 || a==7) && (b==5 || b==7) && (c==5 || c==7)){
    if(a+b+c == 17){ printf("YES\n"); return 0; }
  }
  printf("NO\n");
  return 0;
}

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

int main(){
  string S,T,U;
  cin>>S>>T;
  int A,B;
  cin>>A>>B>>U;
  if(U==S){
    A--;
  }
  else{
    B--;
  }
  cout<<A<<" "<<B<<endl;
}

Measured memory_bytes: 3560
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(double);
		void decrement(void);
		void decrement(double);
		double getResult(void);
	private:
		double result;
	};
	void Ans::showResult(void) {
		printf("%.0lf\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(double value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(double value) {
		this->result -= value;
	}
	double AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void input(Str* str) {
		str->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				str->push_back(row);
				row = "";
			} else {
				row += buf[i];
			}
		}
		str->push_back(row);
	}
	void input(Num* num) {
		num->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				num->push_back(std::atoi(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		num->push_back(std::atoi(row.c_str()));
	}
	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::Num s;
	AtCoder::input(&s);
	const int n = s[0], k = s[1];

	AtCoder::input(&s);

	AtCoder::Ans* ans = new AtCoder::Ans();

	for (int h : s) {
		if (k <= h) {
			ans->increment();
		}
	}

	ans->showResult();

	delete(ans);

	return 0;
}


Measured memory_bytes: 1404
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
const int N = 1e5 + 5;

int n, m;
vector <pair <ll, int> > s[N];

ll d[N];
priority_queue <pair <ll, int> > pq;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int l, r, c;

    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        cin >> l >> r >> c;
        s[l].pb({c, r});
    }

    for(int i = 1; i <= n; i++)
        sort(s[i].begin(), s[i].end());

    int done_to = 1;
    for(auto t: s[1])
        pq.push({-t.first, t.second});
    d[n] = -1;
    while(!pq.empty())
    {
        pair <ll, int> t = pq.top();
        pq.pop();

        for(; done_to + 1 <= t.second;)
        {
            done_to++;
            d[done_to] = -t.first;
            for(auto p: s[done_to])
                pq.push({t.first - p.first, p.second});
        }
    }

    cout << d[n] << endl;

    return 0;
}


Measured memory_bytes: 7672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

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

int main() {
	int n;
	cin >> n;
		
	vector<int> a(n + 1);
	vector<int> b(n);

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

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

	ll ans = 0;

	for (int i = 0; i < n; i++) {
		int num = min(a[i], b[i]);
		ans += num;
		b[i] -= num;
		a[i] -= num;
		num = min(a[i + 1], b[i]);
		ans += num;
		b[i] -= num;
		a[i + 1] -= num;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, digitDP, treeDP//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vll flag, D; vll path;
//***********//
int main() {
	cin >> N;
	vl A(N), R(N);
	for (i = 0; i < N; i++) {
		cin >> A[i];
		R[A[i]-1] = i;
	}
	set<ll> S, S2;
	S.insert(-1);
	S.insert(N);
	S2.insert(1);
	S2.insert(-N);
	for (i = 0; i < N; i++) {
		S.insert(R[i]);
		S2.insert(-R[i]);
		ll left = 0, right = 0;
		left = -*S2.lower_bound(-R[i] + 1) + 1;
		right = *S.lower_bound(R[i] + 1)-1;
		ans += (i + 1) * (R[i] - left + 1) * (right - R[i] + 1);
	}
	co(ans);
}

Measured memory_bytes: 25144
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>

int main() {

    int n, f = 1, t = 0;
    bool bp = false;
    bool bq = false;
    std::vector<int> a;
    std::vector<int> p;
    int p_pos = 0;
    std::vector<int> q;
    int q_pos = 0;
    int it = 1;

    std::cin >> n;
    for(int i = 0; i < n; i++) {
        f *= n - i;
        std::cin >> t;
        p.push_back(t);
    }
    for(int i = 0; i < n; i++) {
        std::cin >> t;
        q.push_back(t);
    }

    while(std::next_permutation(p.begin(), p.end())) {
        p_pos++;
    }
    p_pos = std::abs(f-p_pos);
    while(std::next_permutation(q.begin(), q.end())) {
        q_pos++;
    }
    q_pos = std::abs(f-q_pos);
    printf("%i", std::abs(q_pos-p_pos));



    return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll n, a, b, c, d;

int main() {
	cin.tie(0)->sync_with_stdio(0);
    cin >> n >> a >> b >> c >> d;
    
    bool pos = false;
    for (ll i = 1; i < n - 1; ++i) {
        ll lb = a + c * i, ub = a + d * i;
        lb -= (d * (n - 1 - i)), ub -= (c * (n - 1 - i));
        if (b >= lb && b <= ub) {
            pos = true;
            break;
        }
    }

    if (pos) cout << "YES";
    else cout << "NO";
}


Measured memory_bytes: 3604
#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 main() {
  ll n;
  cin >> n;
  if((n/100)*5>=n%100) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>

int main() {
	int a,b,c,res;
  
  	std::cin >> a >> b >> c;
  
  	if (a == b && b == c) {
    	res = 1;
    } else if ( a == b || b == c || c == a) {
      	res = 2;
    } else {
    	res = 3;
    }
      
     std::cout << res << std::endl;
}

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

/*** Template Begins ***/
#define int ll
typedef long long                   ll;
typedef pair<int,int>               PII;
typedef pair<ll, pair<int, int> >   PIII;
typedef vector<int>                 vi;
typedef vector<pair<int, int> >     vii;

#define endl         '\n'
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
#define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
#define all(a)       (a).begin(),(a).end()
#define fr(i,a,b)    for(int i=a;i<=b;i++)
#define lp(i,a)      for(int i=0;i< a;i++)

// Debug //

#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;

// Constants //

const int N = 1e5+7;
const int xinc[] = {0, 0, 1, -1};
const int yinc[] = {1, -1, 0, 0};
const long double PI = acos(-1.0);

/*** Template Ends ***/
int n, a[N];
vii ans;
void psh(int a, int b) {
	ans.pb(mp(a, b));
}

void solve() {
    
    cin >> n;
    lp(i,n) cin >> a[i];
    sort(a, a+n);
    reverse(a, a+n);

    int pos = a[0], neg = a[n-1];
    fr(i,1,n-2) {
    	if (a[i] >= 0) {
    		psh(neg, a[i]);
    		neg -= a[i];
    	}
    	else {
   			psh(pos, a[i]); 		
       		pos -= a[i];
    	}
    }
    psh(pos, neg);
    cout << pos - neg << endl;
    for (auto i : ans)	cout << i.F << " " << i.S << endl;
}

signed main() {
    
    ios;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t;
    //cin >> t;
    t = 1;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 4336
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0); }

int main() {
  ull r, d, x2000;
  cin >> r >> d >> x2000;

  vector<ull> res;
  ull rr = r * x2000 - d;
  res.push(rr);
  for (ull i=1; i < 10; i++) {
    rr = rr * r - d;
    res.push(rr);
  }

  for (auto v : res) {
    cout << v << endl;
  }


  return 0;
}


Measured memory_bytes: 256
main :: IO ()
main = do
  s <- getLine
  print $ solve s
  

solve :: String -> Int
solve = length . go . reverse 
  where
    go :: String -> String
    go [] = []
    go [x] = []
    go (x:y:z)
      | check z  = z
      | otherwise = go z
    check :: String -> Bool
    check str =
      let (ls, rs) = splitAt ((length str) `div` 2) str in
        ls == rs
   


Measured memory_bytes: 892
#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d", &n);

    int *A = malloc(sizeof(int) * n);

    int i;
    for (i = 0; i < n; i++) scanf("%d", A + i);

    int q;
    scanf("%d", &q);

    int com, b, e, v, j;
    for (i = 0; i < q; i++) {
        scanf("%d %d %d", &com, &b, &e);
        v = A[b];
        if (com == 0) {
            for (j = b + 1; j < e; j++) {
                if (A[j] < v) v = A[j];
            }
        }
        else {
            for (j = b + 1; j < e; j++) {
                if (A[j] > v) v = A[j];
            }
        }
        printf("%d\n", v);
    }

    return 0;
}


Measured memory_bytes: 2088
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
#include <queue>
#include <cstring>

#define pb push_back
#define p push

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfb(a) printf("%.10lf\n",a);
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.12lf\n",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"

#define SIZE  ( int)(1e9 + 7)
#define MAXN (ll) ((1e6+5))
#define K 25
#define  ALPHABET_SIZE  26
//#define N (int)(1e5+10)
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define INF (ll )1e18
#define int ll
using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int,int>>> vvpi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph ;



signed main ( ) {
 ll n ;
 cin >> n;
 ll k = n , t = 0;
 while ( k > 0){
     t += k % 10;
     k/=10;
 }
 if ( n % t == 0){
     cout << "Yes";
 }else {
     cout<<"No";
 }
    return 0;
}



















Measured memory_bytes: 256
N,W=list(map(int,input().strip().split(" ")))
items=[]
for _ in range(N):
    w,v=list(map(int,input().strip().split(" ")))
    items+=[(w,v)]

MAX_val=N*10**3+1
dp=[[10**9+1]*MAX_val for i in range(N)]
dp[0][items[0][1]]=items[0][0]
for i in range(1,N):
    for val in range(1,MAX_val):
        if val-items[i][1]>0:
            dp[i][val]=min(dp[i-1][val],dp[i-1][val-items[i][1]]+items[i][0])
        elif val==items[i][1]:
            dp[i][val]=min(items[i][0],dp[i-1][val])
        dp[i][val]=min(dp[i][val],dp[i-1][val])

MAX=0
for i in range(len(dp[-1])):
    if dp[-1][i]<=W:
        #print(i)
        MAX=i
print(MAX)
    

Measured memory_bytes: 121844
import java.util.*;

public class Main {
    private static Integer N;
    private static List<List<List<Integer>>> map = new ArrayList<>();

    public static boolean judge(Integer bit) {

        for (int i = 0; i < N; ++i) {
            // i人目が「不親切」だったら、証言は無意味
            if ((bit & (1 << i)) == 0) continue;

            List<List<Integer>> xys = map.get(i);
            // それぞれ確認
            for (List<Integer> xy : xys) {
                int x = xy.get(0);
                int y = xy.get(1);

                if (y == 1 && ((bit & (1 << x)) == 0)) return false;
                if (y == 0 && ((bit & (1 << x)) != 0)) return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        N = Integer.parseInt(scanner.next());

        // ここで初期化
        for (int i = 0; i < N; i++) {
            int A = Integer.parseInt(scanner.next());
            List<List<Integer>> xys = new ArrayList<>();

            for (int j = 0; j < A; ++j) {
                List<Integer> xy = new ArrayList<>();
                xy.add(Integer.parseInt(scanner.next()) - 1);
                xy.add(Integer.parseInt(scanner.next()));
                xys.add(xy);
            }
            map.add(xys);
        }

        int res = 0;
        for (int bit = 0; bit < (1 << N); ++bit) {
            if (judge(bit)) {
                int count = 0;
                for (int i = 0; i < N; ++i) {
                    if ((bit & (1 << i)) != 0) ++count;
                }
                res = Math.max(res, count);
            }
        }

        System.out.println(res);
    }
}


Measured memory_bytes: 24652
namespace ABC_087
{
    class Program
    {
        static void Main(string[] args)
        {
            // Candies
            var width = int.Parse(System.Console.ReadLine());
            var a = System.Console.ReadLine().Split(' ');
            var b = System.Console.ReadLine().Split(' ');
            System.Console.WriteLine(candies(width, a, b));
        }

        static private int candies(int width, string[] a, string[] b)
        {
            var max = 0;
            for (int downAt = 0; downAt < width; downAt++)
            {
                var sum = 0;
                for (int x = 0; x < width; x++)
                {
                    if (x <= downAt) sum += int.Parse(a[x]);
                    if (x >= downAt) sum += int.Parse(b[x]);
                }
                max = System.Math.Max(max, sum);
            }
            return max;
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<iomanip>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
vector<vector<bool>> path(10, vector<bool>(10, false));
//与えられたグラフの隣接行列
//path[a][b]=true<=>a-b間に辺がある
int N, M;
int ans = 0;
int vcount = 0;//いくつの頂点を訪れたかを記録する
vector<bool>visited(10, false);//各頂点に訪れたかを記録する

void dfs(int from) {
	visited[from] = true;
	vcount++;
	if (vcount == N) {
		ans++;
	}
	else {
		for(int i = 1; i <= N; ++i) {
			if (!visited[i] && path[from][i]) {
				dfs(i);
			}
		}
	}
	visited[from] = false;
	vcount--;
	return;
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		path[a][b] = path[b][a] = true;
	}
	dfs(1);
	cout << ans << endl;
    return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)

int main(){
    
    int r;
    cin >> r;
    cout << 3 * pow(r, 2) << endl;
    return 0;
}

Measured memory_bytes: 256
/// Bismillahir Rahmanir Rahim
/* Author: Mohammad Morsalin (aka white_space)
    Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define PI acos(-1)
#define IOS ios::sync_with_stdio(false);
using namespace std;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
int main()
{
    IOS
    int n;
    cin>>n;
    int x = n%10;
    if(x==3)cout << "bon\n";
    else if(x==0 || x==1 || x==6 || x==8)cout << "pon" << endl;
    else cout << "hon"<<endl;
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3664
def examA():
    L, R, D = LI()
    ans = R//D - (L-1)//D
    print(ans)
    return

def examB():

    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(2*10**6)

if __name__ == '__main__':
    examA()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

int main() {
    int N,K; cin >> N >> K;
    vector<int> h(N);
    int ret = 0;

    for (int i = 0; i < N; i++){
        cin >> h.at(i);
    }
    for(int i = 0; i < N; i++){
        if(h.at(i) >= K){
            ret++;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 640