akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//  MST2ND
//
//  Created by Dong Truong on 7/13/19.
//  Copyright © 2019 Dong Truong. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
#define long long long

const long maxn = 1e6+2 , cm=1e9+7 , ba=31;
struct elem
{
    long id,gt;
};

string s,t;
vector <long> a[maxn];

long bs(long o,long id)
{
    //long o=t[i]-'a'+1;
    long l=0,r=a[o].size()-1;
    while (l<=r)
    {
        long mid=(l+r)/2;
        if (a[o][mid]>id && (mid==0 || a[o][mid-1]<=id))
            return mid;
        if (a[o][mid]>id) r=mid-1;
        else l=mid+1;
    }
    return -1;
}
void nhap()
{
    cin>>s>>t;
    for (int i=0;i<s.length();++i)
        a[s[i]-'a'+1].push_back(i);
    long round=1,id=-1;
    for (int i=0;i<t.length();++i)
    {
        long o=bs(t[i]-'a'+1,id);
        if (o==-1)
        {
            ++round;
            if (a[t[i]-'a'+1].empty())
            {
                cout<<-1;return ;
            }
            id=a[t[i]-'a'+1][0];
        }
        else
            id=a[t[i]-'a'+1][o];
    }
    cout<<(round-1)*s.length()+id+1;
}
int main(int argc, const char * argv[]) {
   // freopen("a.inp","r",stdin);
    nhap();
    return 0;
}


Measured memory_bytes: 25148
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ii> P;
typedef unsigned long long int ull;
const int MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e9;

int main(){
    int h,n;cin>>h>>n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++) cin>>a[i]>>b[i];
    int dp[n+1][20001];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=20000;j++){
            dp[i][j]=INF;
        }
    }
    dp[0][0]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<=20000;j++){
            dp[i+1][j]=dp[i][j];
            if(j>=a[i]) dp[i+1][j]=min(dp[i+1][j],dp[i+1][j-a[i]]+b[i]);
        }
    }
    int ans=INF;
    for(int j=h;j<=20000;j++){
        ans=min(ans,dp[n][j]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 81692
N=int(input())
S=list(map(str,input().split()))

print(" ".join(S).rstrip())

for i in range(1,len(S)):
    
    for j in range(i):
        if int(S[j])>=int(S[i]):
            S.insert(j,S[i])
            del S[i+1]
    
        else:
            
            pass
    print(" ".join(S).rstrip())


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

typedef long long LL;

const int N=100;

LL mod;
int n,m,sk;

void into(){
  scanf("%d%d%d%lld",&n,&m,&sk,&mod);
}

LL inv[N+9],fac[N+9],ifac[N+9];

void Get_inv(){
  inv[1]=1;
  fac[0]=fac[1]=1;
  ifac[0]=ifac[1]=1;
  for (int i=2,lim=max(n,m);i<=lim;++i){
	inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	fac[i]=fac[i-1]*i%mod;
	ifac[i]=ifac[i-1]*inv[i]%mod;
  }
}

LL pw[N+9][N*N+9];

void Get_pw(){
  for (int i=0;i<=sk;++i){
	pw[i][0]=1;
	for (int j=1;j<=n*m;++j) pw[i][j]=pw[i][j-1]*i%mod;
  }
}

LL dp[2][N+9][N+9];
int now,old;
LL tmp[N+9][N+9];

void Get_now(){
  now^=1;old^=1;
  for (int i=0;i<=n;++i)
	for (int j=0;j<=m;++j) dp[now][i][j]=0;
}

void Get_dp(){
  LL mod2=mod*mod;
  now=0;old=1;
  dp[now][0][0]=1;
  for (int i=1;i<=sk;++i){
	Get_now();
    for (int j=0;j<=n;++j)
	  for (int k=0;k<=m;++k) tmp[j][k]=ifac[j]*pw[i][j*(m-k)]%mod*pw[sk-i+1][j*k]%mod;
    for (int j=0;j<=n;++j)
      for (int k=0;k<=m;++k){
		for (int t=0;t<=j;++t){
		  dp[now][j][k]+=dp[old][j-t][k]*tmp[t][k];
		  if (dp[now][j][k]>=mod2) dp[now][j][k]-=mod2;
		}
		dp[now][j][k]%=mod;
	  }
	Get_now();
	for (int j=0;j<=m;++j)
	  for (int k=0;k<=n;++k) tmp[j][k]=ifac[j]*pw[i][j*(n-k)]%mod*pw[sk-i+1][j*k]%mod;
    for (int j=0;j<=n;++j)
	  for (int k=0;k<=m;++k){
		for (int t=0;t<=k;++t){
		  dp[now][j][k]+=dp[old][j][k-t]*tmp[t][j];
		  if (dp[now][j][k]>=mod2) dp[now][j][k]-=mod2;
		}
	    dp[now][j][k]%=mod;
	  }
	Get_now();
    for (int j=0;j<=n;++j)
	  for (int k=0;k<=m;++k){
		tmp[j][k]=ifac[j]*pw[i][j*(m-k)]%mod*pw[sk-i][j*k]%mod;
		if (j&1&&tmp[j][k]) tmp[j][k]=mod-tmp[j][k];
	  }
    for (int j=0;j<=n;++j)
      for (int k=0;k<=m;++k){
		for (int t=0;t<=j;++t){
		  dp[now][j][k]+=dp[old][j-t][k]*tmp[t][k];
		  if (dp[now][j][k]>=mod2) dp[now][j][k]-=mod2;
		}
		dp[now][j][k]%=mod;
	  }
	Get_now();
	for (int j=0;j<=m;++j)
	  for (int k=0;k<=n;++k){
		tmp[j][k]=ifac[j]*pw[i][j*(n-k)]%mod*pw[sk-i][j*k]%mod;
		if (j&1&&tmp[j][k]) tmp[j][k]=mod-tmp[j][k];
	  }
    for (int j=0;j<=n;++j)
	  for (int k=0;k<=m;++k){
		for (int t=0;t<=k;++t){
		  dp[now][j][k]+=dp[old][j][k-t]*tmp[t][j];
		  if (dp[now][j][k]>=mod2) dp[now][j][k]-=mod2;
		}
	    dp[now][j][k]%=mod;
	  }
  }
}

void work(){
  Get_inv();
  Get_pw();
  Get_dp();
}

void outo(){
  printf("%lld\n",dp[now][n][m]*fac[n]%mod*fac[m]%mod);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 11788
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
      int n,k;
      cin >> n >> k;
      ll mod = 1e9+7;
      ll dp[n],a[n];
      for(int i=0;i<n;i++)
            cin >> a[i];
      if(n==1)
      {
            cout << 0 << endl;
      }
      else
      {
            dp[0] = 0;
            dp[1] = abs(a[1]-a[0]);
            for(int i=2;i<n;i++)
            {
                  dp[i] = mod;
                  for(int j=i-1;j>=i-k;j--)
                  {
                        if(j<0)
                              break;
                        dp[i] = min( dp[i],dp[j]+abs(a[i]-a[j]) );
                  }
            }
            cout << dp[n-1] << endl;
      }
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
string a,b,c;
cin>>a>>b>>c;
cout<<a.at(0)<<b.at(1)<<c.at(2)<<endl;
}









Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100000
#define ff first
#define ss second
#define ll long long
#define mod 1000000007
#define pii pair<ll,ll>
#define vi vector<ll>
#define mii map<ll,ll>
#define pb push_back
#define mp make_pair
#define ps(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define w(x) ll x; cin>>x; while(x--)
#define endl '\n'
void kehsihba(){
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {
	//kehsihba();
	ll n;
	cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++){
		if(i%3==0 || i%5==0){
			continue;
		}
		else{
			ans+=i;
		}
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 3588
while True:
    N, M, P, A, B = map(int, input().split())
    if not (N | M | P | A | B):
        break
    A, B = A - 1, B - 1
    T = [int(x) for x in input().split()]
    INF = 1000
    dp = [[INF] * M for _ in range(1 << N)]
    dp[0][A] = 0
    edges = []
    for _ in range(P):
        s, t, c = map(int, input().split())
        s, t = s - 1, t - 1
        edges.append((s, t, c))
        edges.append((t, s, c))
    ans = INF
    for state in range(1 << N):
        for s, t, c in edges:
            for k in range(N):
                if state >> k & 1 and dp[state][t] > dp[state & ~(1 << k)][s] + c / T[k]:
                    dp[state][t] = dp[state & ~(1 << k)][s] + c / T[k]
    ans = min(dp[state][B] for state in range(1 << N))
    print("Impossible" if ans == INF else "{:.05f}".format(ans))

Measured memory_bytes: 7932
#include<iostream>
#include<vector>
#define P pair<int, int>

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<P> v;
  for(int i=1;i<=n;i++){
  	for(int j=i+1;j<=n;j++){
    	if(i+j!=n/2*2+1)v.push_back(P(i,j));
    }
  }
  cout << v.size() << endl;
  for(int i=0;i<v.size();i++){
  	cout << v[i].first << ' ' << v[i].second << endl;
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,M;cin >> N >> M;
  vector<int> v(N,0);
  rep(i,M){
    int x,y;cin >> x >> y;
    --x;--y;
    ++v[x];
    ++v[y];
  }
  bool issat = true;
  rep(i,N) if(v[i]&1) issat=false;
  YESNO(issat);
  return 0;
}


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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for(int a = 0;a <= A;++a) {
    for(int b = 0;b <= B;++b) {
      for(int c = 0;c <= C;++c) {
        int total = 500*a + 100*b + 50*c;
        if(total == X) {
          ++res;
        }
      }
    }
  }
  cout << res << endl;
}


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

int main(){
    string s;
    int m,h;
   
    while(cin >> s&&s!="-"){
        cin >> m;
        for(int i=0;i<m;i++){
            cin >> h;
            s=s.substr(h)+s.substr(0,h);
        }
    cout << s <<endl;
    }
}


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

int main() {
  string s;
  vector<long> a(13);
  vector<long> b(13);
  vector<long> c={1,10,9,12,3,4};
  cin >> s;
  long x=0;
  for(long i=s.size()-1;i>=0;i--) if(s[i]!='?') x=(x+(s[i]-'0')*c[(s.size()-i-1)%6])%13;
  a[x]=1;
  for(long i=s.size()-1;i>=0;i--) {
    if(s[i]=='?') {
      b=a;
      for(long i2=0;i2<13;i2++) {
        for(long i3=1;i3<10;i3++) {
          a[(i2+i3*c[(s.size()-i-1)%6])%13]+=b[i2];
          a[(i2+i3*c[(s.size()-i-1)%6])%13]=a[(i2+i3*c[(s.size()-i-1)%6])%13]%1000000007;
        }
      }
    }
  }
  cout << a[5] << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define int long long
#define P pair<int,int>
#define S stack<int>
#define Q queue<int>
#define V vector<int>
using namespace std;
pair<int,P> p[110];
bool b[110];
signed main(){
	int n;
	cin>>n;
	f(i,n) cin>>p[i].first>>p[i].second.first>>p[i].second.second;
	f(j,101){
		f(k,101){
			int x=0,y=0;
			f(i,n){
				if(i==0||y!=1){
					if(p[i].second.second){
						if(y==0){
							x=abs(p[i].first-j)+abs(p[i].second.first-k)+p[i].second.second;
							y=1;
						}
						else if(x<abs(p[i].first-j)+abs(p[i].second.first-k)+p[i].second.second) goto mutu;
						else {
							x=abs(p[i].first-j)+abs(p[i].second.first-k)+p[i].second.second;
							y=1;
						}
					}
					else if(y==0){
						x=abs(p[i].first-j)+abs(p[i].second.first-k)+p[i].second.second;
						y=2;
					}
					else x=min(x,abs(p[i].first-j)+abs(p[i].second.first-k)+p[i].second.second);
				}
				else{
					if(p[i].second.second==0){
						if(x>abs(p[i].first-j)+abs(p[i].second.first-k)+p[i].second.second) goto mutu;
					}
					else if(x!=abs(p[i].first-j)+abs(p[i].second.first-k)+p[i].second.second) goto mutu;
				}
			}
			cout<<j<<" "<<k<<" "<<x<<endl;
			return 0;
			mutu:;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
using namespace std;

int main() {
	IOS;
	int r;
	cin >> r;
	int low = 1, high = 1000000;
	while(low <= high) {
		int mid = low + (high - low) / 2;
		float x1 = (float)mid * 1.08;
		int x = x1;
		if(x == r) {
			cout << mid;
			return 0;
		}
		if(x < r) {
			low = mid + 1;
		}
		else high = mid - 1;
	}
	cout << ":(";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o set

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,a,b; cin >> n >> a >> b;
    string s; cin >> s;
    int cnt=0;
    int cnt2=0;
    rep(i,s.size()){
        if(s[i]=='a'){
            if(cnt<a+b){
                cout << "Yes" << endl;
                cnt++;
            }else{
                cout << "No" << endl;
            }
        }else if(s[i]=='b'){
            if(cnt<a+b&&cnt2<b){
                cnt++;
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
            cnt2++;
        }else{
            cout << "No" << endl;
        }
    }
}


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

class Main{


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int[] l = new int[n];
		
		for(int i = 0;i < n;i++){
			l[i] = sc.nextInt();
		}
		Arrays.sort(l);
		int max = l[n-1];
		for(int i = 0;i < n-1;i++){
			max -= l[i];
		}
		if(max<0){
			System.out.println("Yes");
		}else{
			System.out.println("No");

		}
		

		

	}


	static int lowerbond(long k, long[] data){		//kより小さい最小の値をdataの中から探し、返す二分探索
		int min = 0;
		int max = data.length-1;

		while(max-min >= 0){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid-1;
			}else{
				min = mid+1;
			}
		}
		return min;
	}









	class UnionFind{
		int[] parent;
		public UnionFind(int N){
			this.parent = new int[N];
			for(int i = 0; i < N;i++){
				parent[i] = i;
			}
		}
		public int root(int x){			//根要素を取得
			if(parent[x] == x){			//初期状態
				return x;
			}else{
				return parent[x] = root(parent[x]);    	//再帰によって根を取得
			}
		}
		public void unite(int x,int y){ 	//統合メソッド
			if(same(x,y)){					//同じ根なら終了
				return;
			}
			int xroot = root(x);
			int yroot = root(y);
			parent[xroot] = yroot;			//統合
			return;

		}

		public boolean same(int x,int y){			//根が同じか（同じグループに属しているか）を判定
			return(root(x) == root(y));
		}
	}

}

class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



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

bool mx(int a,int b){
    if(a>b) return 1;
    else 0;
}
int main(){
    string a,b;
    int sx,sy;
    cin>>a>>b;
    sx = a.size();
    sy = b.size();
    int chk[sx+1][sy+1]={0};
    string ans="";
    int as=0;
    for(int i=0;i<=sx;i++) chk[i][0]=0;
    for(int j=0;j<=sy;j++) chk[0][j]=0;
    for(int i=1;i<sx+1;i++){
        for(int j=1;j<sy+1;j++){
            if(a[i-1]==b[j-1]){ 
                chk[i][j]=chk[i-1][j-1]+1;
            }
            else{
                chk[i][j]=max(chk[i-1][j],chk[i][j-1]);
            }
        }
    }
    ans="";
    int i=sx;
    int j=sy;
    while(i>0 && j>0){
        if(chk[i][j]==chk[i-1][j]){
            i--;
        }
        else if(chk[i][j]==chk[i][j-1]){
            j--;
        }
        else{
            ans = a[i-1]+ans;
            i--;
            j--;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 38740
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll aa , bb;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->aa - ((fr*)q)->aa;}
/*nCk*/
ll nckused[1000][1000];
ll nckreached[1000][1000];
ll comb(ll n,ll k){
    if(n>1000) return (k==0 || k==n)?1:comb(n-1,k-1)+comb(n-1,k);
    if(nckreached[n][k]==1) return nckused[n][k];
    nckreached[n][k] = 1;
    nckused[n][k] = (n==1 || (k==0 || k==n) )?1:comb(n-1,k-1)+comb(n-1,k);
    return (n==1 || (k==0 || k==n) )?1:comb(n-1,k-1)+comb(n-1,k);
}

int main(void){
    // char ;
    ll n;
    scanf("%lld",&n);
    // ll [n];
    printf("%lld\n",comb(n,2)-n/2);

    if(n%2){
        rep(i,0,n-1){
            rep(j,i+1,n){
                if(j==n-2-i) continue;
                printf("%lld %lld\n",i+1,j+1);
            }
        }

    }else{
        rep(i,0,n-1){
            rep(j,i+1,n){
                if(j==n-1-i) continue;
                printf("%lld %lld\n",i+1,j+1);
            }
        }
    }

    // printf("\n");
    return 0;
}


Measured memory_bytes: 4736
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int[] Stu = new int[30];
		
		for(int i = 0; i < 30; i++){
			Stu[i] = i + 1;
		}
		
		for(int i = 0; i < 28; i++){
			int a = s.nextInt();
			Stu[a - 1] = 0;
		}
		
		for(int i = 0; i < 30; i++){
			if(Stu[i] != 0){
				System.out.println(Stu[i]);
			}
		}
	}
}

Measured memory_bytes: 17184
xlist = []

while(1):
    x = int(input())

    if x == 0:
        break

    xlist.append(x)

for x in xlist:
    ans = 0
    while(1):
        n = x % 10
        ans += n
        x //= 10
        if x == 0:
            print(ans)
            break



Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1e5;
typedef long long ll;
int k[N] = {0};


int main(){
	int n;
	cin >> n;
	int s = sqrt(n)+1, ans = 0;
	for(int x = 1; x <= s; x++){
		for(int y = 1; y <= s; y++){
			for(int z = 1; z <= s; z++){
				k[x*x+y*y+z*z+x*y+y*z+x*z]++;
			}
		}
	}
	for(int i = 1; i <= n; i++){
		printf("%d\n",k[i]);
	}
	return 0;
}



Measured memory_bytes: 3820
/*
 * @Author: Kaizyn
 * @Date: 2020-04-12 20:18:14
 * @LastEditTime: 2020-04-12 20:22:46
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const int N = 4e3+7;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;

int n;
char s[N];

inline void solve()
{
    cin >> n >> (s+1);
    int r = 0, g = 0, b = 0;
    for (int i = 1; i <= n; ++i) {
        if (s[i] == 'R') ++r;
        if (s[i] == 'G') ++g;
        if (s[i] == 'B') ++b;
    }
    long long res = 1ll*r*g*b;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; i+j+j <= n; ++j) {
            if (s[i] != s[i+j] && s[i] != s[i+j+j] && s[i+j] != s[i+j+j]) --res;
        }
    }
    cout << res << endl;
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int testcase = 1;
    // cin >> testcase;
    for (int i = 1; i <= testcase; ++i) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>
int main(void)
{
  long long n,a,x,mn,mx,s;
  s=0;
  mn=1000000;
  mx=-1000000;
  scanf("%lld",&n);
  for(x=0;x<n;x++){
    scanf("%lld",&a);
    s=s+a;
    if(mn>a){mn=a;}
    if(mx<a){mx=a;}
  }
  printf("%lld %lld %lld\n",mn,mx,s);

  return 0;
}


Measured memory_bytes: 2088
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<set>
#include<stdlib.h>
#include<vector>
using namespace std;
typedef long long ll;


int main(void) {
	string s;
	int count = 0,x=0;
	cin >> s;
	if (s[0] != 'A') {
		cout << "WA" << endl;
		return 0;
	}
	x = s[1] - '\0';
	if (s[1] == 'C' || ((65 <= x) && (x <= 90))) {
		cout << "WA" << endl;
		return 0;
	}
	x = s[s.length()-1] - '\0';
	if (s[s.length()-1] == 'C' || ((65 <= x) && (x <= 90))) {
		cout << "WA" << endl;
		return 0;
	}
	for (int i = 2;i < s.length() - 1;i++) {
		int r = s[i] - '\0';
		if ((65 <= r) && (r <= 90)) {
			if (s[i] == 'C')count++;
			else {
				cout << "WA" << endl;
				return 0;
			}
		}
	}
	if (count == 1)cout << "AC" << endl;
	else cout << "WA" << endl;	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    String S = scanner.next();
		    String T = scanner.next();
		    
		   if( S.equals(T) ) 
		   {
				System.out.println("H");   
		   }
		   else
		   {
			   System.out.println("D");
		   }
		    scanner.close(); }
		  }

Measured memory_bytes: 21332
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long a[200020];
int main() {
	long long n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n - k; i++) {
		if (a[i] < a[i + k]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 5188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse -> greater<long long>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back

ll solve(string S){
   string T="";
   for(auto c:S)if(c!='x')T+=c;
   string T2=T;
   reverse(ALL(T2));
   if(T!=T2)return -1;
   int N=sz(T);
   VI nums(N+1,0);
   int iter=0;
   for(int i=0;i<sz(S);){
      int j=i;
      while(j<sz(S) && S[j]=='x')++j;
      nums[iter++]=j-i;
      i=j+1;
   }
   ll res=0;
   for(int i=0;i*2<sz(nums);++i){
      res+=max(nums[i],nums[sz(nums)-1-i])-min(nums[i],nums[sz(nums)-1-i]);
   }
   return res;
}

int main(){
   string S;
   cin>>S;
   cout<<solve(S)<<endl;
}

Measured memory_bytes: 4584
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int MAX = 200010;
ll inv[MAX],fact[MAX],fi[MAX],mod = 1000000007;
void inverse(){
	int i;
	inv[1] = 1;
	for(i=2;i<MAX;i++){
		inv[i] = mod - (mod/i)*inv[mod%i]%mod;
	}
	fact[0] = fi[0] = 1;
	for(i=1;i<MAX;i++){
		fact[i] = fact[i-1]*i%mod;
		fi[i] = (fi[i-1]*inv[i])%mod;
	}
}

vector<int> G[200010],H[200010];
int dp[200010];
int dfs(int s, int p,int n){
	int ret = 1;
	for(int v:G[s]){
		if(v==p) continue;
		dfs(v,s,n);
		H[s].push_back(dp[v]);
		ret += dp[v];
	}
	dp[s] = ret;
	H[s].push_back(n - ret);
	return ret;
}

ll pw(ll a, ll x){
	ll ret = 1;
	while(x){
		while(!(x&1)){
			(a *= a) %= mod;
			x /= 2;
		}
		x--;
		(ret *= a) %= mod;
	}
	return ret;
}
ll ans = 0;
int main(){
	int i,j,n;
	cin >> n;
	for(i=0;i<n - 1;i++){
		int a,b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(0,-1,n);
	inverse();
	for(i=0;i<n;i++){
		ll x = inv[2];
		ll y = (1 - pw(inv[2],n - 1) + mod)%mod;
		for(j=0;j<H[i].size();j++){
			ll z = (1 - pw(inv[2],H[i][j]) + mod)%mod;
			(z *= pw(inv[2],n - H[i][j] - 1)) %= mod;
			y -= z;
			y = (y + mod)%mod;
		}
		(ans += x*y%mod) %= mod;
	}
	cout << ans << endl;
}
	

Measured memory_bytes: 43136
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<utility>
using namespace std;
#define MS(m,z) memset(m,z,sizeof(m))
typedef unsigned U; typedef pair<int,int > P; typedef long long ll;
void inp();
int main(){
#ifdef XS
	//freopen(".in","r",stdin);
#endif
	//int n;scanf("%d",&n);for(int i=1;i<=n;i++)
	inp();
	return 0;
}
ll gcd(ll a,ll b){
	return a==0?b:gcd(b%a,a);
}
const int N = 1000;
ll A[N];
void inp(){
	int n;scanf("%d",&n);
	ll a=1,tmp=1;
	for(int i = 0;i<n;i++){
		scanf("%lld",&A[i]);
	}
	sort(A,A+n);
	for(int i =0;i<n;i++){
		tmp=A[i];
		if(a>tmp)swap(a,tmp);
		if(tmp%a==0)a=tmp;
		else a= tmp/gcd(a,tmp)*a;
	}
	printf("%lld\n",a);
}
//C.cc by xsthunder at Sat Aug 12 20:08:20 2017


Measured memory_bytes: 128
package main

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

var (
	N, M int
	d    [5]string
)

func main() {
	readVariables()
	//N=1 , 0 attention!
	answer := 0
	for i := 0; i < M; i++ {
		s, c := nextInt(), nextStr()
		if d[s-1] != "" && d[s-1] != c {
			answer = -1
			break
		} else {
			d[s-1] = c
		}
	}
	if (N > 1 && d[0] == "0") || answer == -1 {
		answer = -1
	} else {
		for i := 0; i < N; i++ {
			if d[i] == "" {
				if i != 0 || N == 1 {
					d[i] = "0"
				} else {
					d[i] = "1"
				}
			}
		}
		answer, _ = strconv.Atoi(strings.Join(d[0:N], ""))
	}
	fmt.Println(answer)
}

func readVariables() {
	N, M = nextInt(), nextInt()
	for i := 0; i < 5; i++ {
		d[i] = ""
	}
}

/* Template */

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt returns minimum argument
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt returns maximum argument
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt returns |x| for x
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow calculates integer power with modulo operation
//if modulo <= 1, it powers w/o module operation
//if base < 0, return value might be negative too.
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=1000005;
int n,m,k,a[N<<1],b[N<<1];
char s[N],t[N];
void pr(int *a){
	int len=N*2-1;
	while(!a[len])len--;
	Rep(i,len,0)putchar(a[i]+'0'); puts("");
}
int main(){
	scanf("%d%d%d",&n,&m,&k);
	scanf("%s%s",s,t);
	For(i,0,n-1)a[n-i-1]=s[i]-'0';
	For(i,0,m-1)b[m-i-1]=t[i]-'0';
	n=max(n,m);
	stack<int> st;
	st.push(N*100);
	Rep(i,n,0)if(a[i]+b[i]){
		stack<int> zs;
		if(a[i]+b[i]==1)st.push(i);
		else{
			int x=1,y=1,dq=i+1,lft=k-1;
			a[i]=b[i]=0;
			while(x+y){//cout<<x<<" "<<y<<" "<<dq<<" "<<st.top()<<endl;
				if(x+y==1){
					if(st.top()>dq){a[dq]=x; b[dq]=y; st.push(dq); break;}
					else{
						if(x==a[dq]&&y==b[dq]){
							st.pop(); a[dq]=b[dq]=0; 
						}else{
							st.pop(); a[dq]=b[dq]=0; x=y=1; lft--; if(lft<0){a[dq]=b[dq]=1; break;}
						}
					}
				}else{
					if(st.top()>dq+lft){a[dq+lft]=b[dq+lft]=1; break;}
					else{
						lft-=st.top()-dq; dq=st.top(); st.pop(); zs.push(dq);
						x=a[dq]; y=b[dq]; swap(a[dq],b[dq]); 
					}
				}
				dq++;
			}
		}
		while(zs.size()){st.push(zs.top()); zs.pop();}
	}
	pr(a); pr(b);
}

Measured memory_bytes: 19584
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<tuple>
#include<ctime>
#include<functional>
#include<cmath>
#include<cassert>
#include<string.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p; 
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
 int N,K,p[1001],sum=0;
 cin>>N>>K;
 rep(i,N) cin>>p[i];
 sort(p,p+N);
rep(i,K) sum+=p[i];
p(sum);
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int n; cin >> n;
	vector<int>a(n);
	int x = 0;
	rep(i, 0, n) {
		cin >> a[i];
		chmax(x, a[i]);
	}
	int y = 0;
	rep(i, 0, n) {
		int z = (x + 1) / 2;
		if (abs(y - z) > abs(z - a[i]))y = a[i];
	}
	cout << x << ' ' << y << "\n";

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
long long int jdz(long long int x)
{
    if(x<0) return -x;
    else return x;
}
int main()
{
    int n,i,x;
    long long int a[200005],mini;
    scanf("%d",&n);
    scanf("%lld",&a[0]);
    for(i=1;i<n;i++){
        scanf("%lld",&a[i]);
        a[i]=a[i-1]+a[i];
    }
    mini=jdz(a[n-1]-2*a[0]);
    for(i=1;i<n-1;i++){
        if(jdz(a[n-1]-2*a[i])<mini){
        mini =jdz(a[n-1]-2*a[i]);
        }
    }
    printf("%lld",mini);
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define ll long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 1e18
    
const int N=2e5+5;
const int M=1e9+7;

void solve()
{
	int l,r,d;
	cin>>l>>r>>d;
	int ans=r/d;
	ans-=((l-1)/d);
	cout<<ans<<endl;
}

signed main()
{
	int t=1;
	// cin>>t;
	for(int tc=1;tc<=t;tc++)
	{
		solve();
	}
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll a, b; cin >> a >> b;
  if (b % a == 0)
    fin(a + b) else fin(b - a)
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
using System;

namespace ITP1_8_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] counter = new int[26];

            while (true)
            {
                string str1 = Console.ReadLine();
                if (str1 == null)
                    break;
                if (1200 <= str1.Length)
                    Environment.Exit(0);
                string str = str1.ToLower();

                for (int i = 0; i < str.Length; i++)
                {
                    if (str[i] - 'a' > 25 || str[i] - 'a' < 0)
                        continue;
                    counter[str[i] - 'a']++;
                }
            }

            for (int i = 0; i < 'z' - 'a' + 1; i++)
            {
                Console.WriteLine("{0} : {1}", Convert.ToChar('a' + i), counter[i]);
            }
        }
    }
}



Measured memory_bytes: 7868
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		// cin.ignore(); must be there when using getline(cin, s)
		string s;
		cin>>s;
		s='0'+s;
		int ans1=0,ans2=0;
		for (int i = 1; i < s.size(); ++i)
		{
			if(s[i]!=(i%2?'1':'0'))
				ans1++;	
			if(s[i]!=(i%2?'0':'1'))
				ans2++;	
			//cout<<ans1<<" "<<ans2<<endl;
		}
		cout<<min(ans1,ans2);
	}

Measured memory_bytes: 512
x = int(input())

mx = 1
for b in range(2, x + 1):
    if b ** 2 > x:
        mx = max(mx, (b - 1) ** 2)
        break
    for p in range(2,x + 1):
        if b ** p > x:
            mx = max(mx, b ** (p - 1))
            break

print(mx)

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

int main(){
  string S;
  cin >> S;
  ll N = S.length();
  ll ten = 1;
  ll cur = 0;
  vector<ll> v(2020,0);
  
  REP(i,N) {
    cur = (cur + (S[N-1-i]-'0') * ten ) % 2019;
    ten = (ten * 10) % 2019;
    v[cur]++;
//    cout << S[N-1-i] << " " << cur << endl;
  }
  v[0]++;
  ll ans = 0;
  REP(i,2019) {
    ans += v[i] * (v[i]-1) / 2;
  }
  cout << ans << endl;
}


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

typedef long long ll;


int main() {
  int N,M,X,Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N),y(M);
  int Max=-1000,miy=1000;
  for(int i=0; i<N; i++){
    cin >> x[i];
    Max = max(Max,x[i]);
  }
  for(int i=0; i<M; i++){
    cin >> y[i];
    miy = min(miy,y[i]);
  }

  if(Max<miy && X<miy && Y>Max && X<Y) cout << "No War" << endl;
  else cout << "War" << endl;
  
}

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

const int mod=1e9+7;

int main()
{
	int n,k;
	long long ans=0;
	scanf("%d%d",&n,&k);
	for(int i=k;i<=n+1;++i) {
		ans+=1ll*(n+1-i)*i+1;
		ans%=mod;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 3828
#include"bits/stdc++.h"
using namespace std;

int main() {
	int X, A, B;
	cin >> X >> A >> B;
	string judge = "safe";
	if (A >= B) {
		judge = "delicious";
	}
	else if (A + X < B) {
		judge = "dangerous";
	}
	cout << judge << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int t,max=0;
  string ss;
  map<string,int>vote;
  set<string> words;
  cin>>t;
  for(int i=0;i<t;i++)
  {cin>>ss;
  	++vote[ss];
  	words.insert(ss);
  	if(max<vote[ss])
  	max=vote[ss];} 
  for(set<string>::iterator it=words.begin();it!=words.end();++it)
  {if(vote[*it]==max)
  	cout<<*it<<"\n";}
  return 0;
} 

Measured memory_bytes: 34560
#include <iostream>
using namespace std;
int main(){
    int A,B;
    cin >> A >> B;
    A = ( A + 11 ) % 13;
    B = ( B + 11 ) % 13;
    if (A>B) cout << "Alice" <<endl;
    if (A<B) cout << "Bob" <<endl;
    if (A==B) cout << "Draw" <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define CINVEC(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    string A, B, C;
    cin >> A >> B >> C;
    YESNO(A[A.size() - 1] == B[0] && B[B.length() - 1] == C[0], "YES", "NO");
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
  public static void main(String... args) {
    BufferedReader br = new BufferedReader(
      new InputStreamReader(System.in));

    try {
      char[] s = br.readLine().toCharArray();
      for(int i = 0; i < s.length; i++) {
        if(s[i] != 'U' && s[i] != 'D') {
          if((i % 2 == 0 && s[i] == 'L')
          || (i % 2 != 0 && s[i] == 'R')) {
            System.out.println("No");
            return;
          }
        }
      }
      System.out.println("Yes");
      br.close();
    } catch(IOException e) {
      e.printStackTrace();
    }
  }
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    double a, b, C;
    double S, L, h;
    cin>>a>>b>>C;
    
    S = a * b * sin(C * PI / 180) / 2;
    L = a + b + sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(C * PI / 180));
    h = b * sin(C * PI / 180);
    printf("%.10f\n%.10f\n%.10f\n", S, L, h);
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N;
    vec a(N), ord(N);
    ll num = 0;
    rep(i,N) cin>>a[i], ord[i] = i;
    sort(ALL(ord), [&](int x, int y){
        return a[x] < a[y];
    });
    rep(i,N) num += ord[i]%2 != i%2;
    cout<<num / 2<<endl;
}

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

int main() {
  string s;
  cin >> s;
  if(s == "a" || s=="i" || s == "u"|| s == "e" || s =="o")
    cout << "vowel" << endl;
  
  else
    cout << "consonant" << endl;
}


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

static const int N = 100;

int main(void){
    int n,p[N+1],m[N+1][N+1];
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> p[i-1] >> p[i];
    }
    
    for(int i=1;i<=n;i++) m[i][i]=0;
    for(int l=2;l<=n;l++){
        for(int i=1;i<=n-l+1;i++){
            int j=i+l-1;
            m[i][j]=(1<<21);
            for(int k=i;k<=j-1;k++){
                m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
            }
        }
    }
    cout << m[1][n] << endl;
    
    return 0;
}











Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll N;
  cin >> N;
  vll T(N), A(N);
  ll TT = 1, AA = 1;
  for(int i = 0; i < N; i++){
    cin >> T.at(i) >> A.at(i);
    ll x = max((TT + T.at(i) - 1)/T.at(i), (AA + A.at(i) - 1)/A.at(i));
    TT = T.at(i) * x;
    AA = A.at(i) * x;
  }
  cout << TT + AA << endl; 
}

Measured memory_bytes: 256