akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;

#define MODULE 1000000007
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<class T, class U>
inline void chmin(T &t, U f) { if (t > f)t = f; }

template<class T, class U>
inline void chmax(T &t, U f) { if (t < f)t = f; }

typedef pair<int, int> P;
typedef long long LL;
const LL INF = LLONG_MAX / 2;    //int_max->2*e+9 LLの時はLLONG_MAX
const int MAXN = 100001;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

/*struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};*/

//-----Template---------
int h, w;
vector<string> color(301);
vector<vector<LL>> cost(301,vector<LL>(301));
vector<vector<LL>> dp(301,vector<LL>(301,INF));
LL sum = 0;
int main() {
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        cin >> color[i];
    }
    for (int i = 0; i < w - 1; ++i) {     //2列毎の最小コストを求める
        for (int j = 0; j <= h; ++j)
            for (int k = 0; k <= h; ++k){
                if (j == 0 || k == 0) {
                    LL tmp = 0;
                    for (int l = 0; l < h; ++l) {//0 .. h-1まで回して，変なとこを飛ばす
                        if (l - j >= 0 && l - k >= 0 && color[l - j][i] == color[l - k][i + 1])
                            tmp++;
                    }
                    cost[j][k] = tmp;
                } else {
                    cost[j][k] = cost[j - 1][k - 1] - (color[h - j][i] == color[h - k][i + 1] ? 1 : 0);
                }
            }
        for (int j = 0; j < 301; ++j) {
            fill(dp[j].begin(),dp[j].end(),INF);
        }
        dp[0][0] = 0;
        for (int j = 0; j <= h; ++j) {
            for (int k = 0; k <= h; ++k) {
                LL tmpA = j > 0 ? dp[j - 1][k] + cost[j - 1][k] : INF;
                LL tmpB = k > 0 ? dp[j][k - 1] + cost[j][k - 1] : INF;
                chmin(dp[j][k], min(tmpA, tmpB));
            }
        }
        sum += dp[h][h];
    }
    cout << sum << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define mod  1000000007
using namespace std;
 
 
void testcase()
{
	string s,p;
	cin>>s;
	if(s[s.length()-1] == 's')
		p = s + "es";
	else
		p = s + "s";
	cout<<p<<"\n";
}
 
 
int main()
{
    ll t,test;
    //cin>>test;
    //for(t=0;t<test;t++)
        testcase();
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define	foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define	mp make_pair
#define	pb push_back
#define sz(a) int((a).size())
#define all(a)  a.begin(), a.end()
#define	debug(ccc)	cout << #ccc << " = " << ccc << endl;
#define present(c,x) ((c).find(x) != (c).end())
const double eps = 1e-8;
#define EQ(a,b) (fabs((a)-(b))<eps)
inline int max(int a,int b){return a<b?b:a;}
inline int min(int a,int b){return a>b?b:a;}
inline ll max(ll a,ll b){return a<b?b:a;}
inline ll min(ll a,ll b){return a>b?b:a;}
const int mod = 1e9+7;
const int N = 1e6+10;
const ll inf = 1e18;

ll power(ll a,ll n){
	if(n==0){
		return 1;
	}
	ll b = power(a,n/2);
	b = b*b%mod;
	if(n%2) b= b*a%mod;
	return b;
}

int add(int a,int b){ return (a+b)%mod;}
int mul(int a,int b){ return (ll)a*b%mod;}

int A[N];
int B[N];

int main(){
 // 	freopen("nice.in","r",stdin);
 // freopen("nice.out","w",stdout);
	int n,m;scanf("%d %d",&n,&m);
	A[1]=1.0;
	REP(i,n+1) B[i]++;
	REP(i,m){
		int x,y;scanf("%d %d",&x,&y);
		A[y] = A[y]|(A[x]==1);
		// A[x] = A[x]*(B[x]-1)/B[x];
		if(B[x]==1)	A[x]=0;
		B[x]--;
		B[y]++;

	}
	int ans = 0;
	REP(i,n+1)	ans+=(A[i]>0);
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 1024
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())

n=N()
l=L()
ans=0
for i in range(n-1):
    if l[i]>l[i+1]:
        ans+=l[i]-l[i+1]
        l[i+1]=l[i]
print(ans)



Measured memory_bytes: 94148
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 105;
const int MAX_W = 10005;

int v[MAX_N];
int w[MAX_N];
int dp[MAX_W];

int main()
{
	int n,W;
	cin >> n >> W;
	rep(i,n){
		cin >> v[i] >> w[i];
	}
	rep(i,n){
		for(int j=W;j>=w[i];j--){
			dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
		}
	}
	cout << dp[W] << "\n";
	return 0;
}

Measured memory_bytes: 3124
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        int len = s.length();
        String r = "";
        r += s.charAt(0);
        r += (len-2);
        r += s.charAt(len-1);
        System.out.println(r);
    }
}

Measured memory_bytes: 20564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	if(n%2==1){
		cout<<0<<endl;
		return 0;
	}
	ll ans=0;
	ll now=n;
	ll num=5;
	ll cnt=0;
	while(now/num){
		ans+=(now/num)/2;
		string s=to_string(num);
		if(s.size()>=18){
			break;
		}
		num*=5;
		cnt++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

// belik's shit
ll const mod = 1e9 + 7;
namespace {
	ll mult(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) {
			val += mod;
		}
		if (val >= mod) {
			val -= mod;
		}
		return val;
	}
	ll poww(ll a, ll b)
	{
		ll val = 1;
		a %= mod;
		while (b > 0){
			if (b % 2) val = mult(a, val);
			a = mult(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 2e5 + 5;

ll ans[maxn];
signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll a, b, c; cin >> a >> b >> c;
	ll kek = a - b;
	c = max(0LL, c - kek);
	cout << c << endl;
	return 0;

}
/*

*/

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;

const int NMAX=3000;
int r,g,b,n;
ll ans=0;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	
	cin >> r >> g >> b >> n;
	
	for(int premier=0;premier<=(n/r);premier++){
		for(int second=0;second<=(n/g);second++){
			int reste=n-premier*r-second*g;
			
			if(reste>=0 && reste%b==0) ans++;
		}
	}
	
	cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    n=1000-n;
    int ans=0;
    while(n>=500){
      ans++;
      n-=500;
    }
    while(n>=100){
      ans++;
      n-=100;
    }
    while(n>=50){
      ans++;
      n-=50;
    }
    while(n>=10){
      ans++;
      n-=10;
    }
    while(n>=5){
      ans++;
      n-=5;
    }
    while(n){
      ans++;
      n--;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3072
#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() {
  int s, w;
  cin >> s >> w;
  string ans = s > w ? "safe" : "unsafe";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 10000000000000000
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
#define SIZE 1000000

int main(){
	int t;
	cin>>t;
	int n,d;
	for(int i=0;i<t;i++){
		cin>>n>>d;
		int temp=d;
		if(n%2==0)temp=127-temp;
		temp=temp+127*(n-1);
		cout<<temp<<endl;
	
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a)      cout<<a<<" "
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll minize(ll& a,ll b){return a=(a>b?b:a);}
inline ll maxize(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];
bool check(string s,ll p1,ll p2){
	while(p1<p2){
		if(p1+1<=p2 and s[p1+1]=='.')p1++;
		else if(p1+2<=p2 and s[p1+2]=='.')p1+=2;
		else re 0;
	}
	re (p1==p2);
}
bool check2(string s,ll p1,ll p2){
	ll flag=0;
	while(p1<p2){
		if(p1-1>=1 and s[p1-1]=='.' and s[p1+1]=='.')flag=1;
		if(p1+1<=p2 and s[p1+1]=='.')p1++;
		else if(p1+2<=p2 and s[p1+2]=='.')p1+=2;
		else re 0;
		if(p1<=p2 and p1-1>=1 and s[p1-1]=='.' and s[p1+1]=='.')flag=1;
	}
	re (p1==p2 and flag);
}
ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	cin>>n;
	fu(i,1,4)sc(A[i]);
	
	string s;
	sc(s);
	s="&"+s;
	
	if(A[3]>A[4]){
		if(check(s,A[1],A[3]) and check(s,A[2],A[4])){
			if(check2(s,A[2],A[4]))re pr("Yes"),0;
			else re pr("No"),0;
		}
		else re pr("No"),0;
	}
	else{
		if(check(s,A[1],A[3]) and check(s,A[2],A[4]))re pr("Yes"),0;
		else re pr("No"),0;
	}

	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	}
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

Measured memory_bytes: 792
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <map>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;

int main()
{
	int l[11] = {0};
	while(1){
		if(scanf("%d,", &l[1]) == EOF)
			break;
		reep(i, 2, 11){
			scanf("%d,", &l[i]);
			l[i] += l[i-1];
		}

		int v1, v2;
		scanf("%d,%d", &v1, &v2);
		printf("%d\n", distance(l, lower_bound(l, l+11, l[10]/double(v1+v2)*v1)));
	}
	return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

map<PI, li> memo;

li rec(li lim_xor, li lim_sum) {
    if (lim_sum == 0) {
        return 1;
    }
    if (memo.count({lim_xor, lim_sum}) > 0) {
        return memo[ {lim_xor, lim_sum}];
    }
    li res = 0;
    // 00
    res = (res + rec(lim_xor / 2, lim_sum / 2)) % MOD;
    if (lim_sum > 0 && lim_xor > 0) {
        // 10
        res = (res + rec((lim_xor - 1) / 2, (lim_sum - 1) / 2)) % MOD;
    }
    if (lim_sum > 1) {
        // 11
        res = (res + rec(lim_xor / 2, (lim_sum - 2) / 2)) % MOD;
    }
    return (memo[ {lim_xor, lim_sum}] = res);
}

int main() {
    li n;
    cin >> n;

    cout << rec(n, n) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

template<class T> map<T, int> factor(T n) {
  map<T, int> res;
  for (T i = 2; i * i <= n; i++) while (n % i == 0) res[i]++, n /= i;
  if (n != 1) res[n]++;
  return res;
}

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  lint n; cin >> n;
  auto mp = factor(n);
  for (auto&& i : mp) n = n * (i.first - 1) / i.first;
  cout << n << '\n';
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const int INF = 1e9;
const int MOD = 1000000007;

int main() {
  ll n, m;
  cin >> n >> m ;
  vector<ll>yakusu;
  yakusu.push_back(m);
  for(int i=1;i*i<=m;i++){
    if(m%i==0){
      yakusu.push_back(i);
      yakusu.push_back(m/i);
    }
  }
  sort(yakusu.begin(),yakusu.end(),greater<ll>());
  
  rep(i,yakusu.size()){
    if(m%yakusu[i]==0){
      int x=m/yakusu[i];
      if(x>=n){
        cout << yakusu[i] << endl;
        return 0;
      }
    }
  }
  
}

Measured memory_bytes: 256
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

lo n,m,cev,b,a[li],k,cev1;
string s;
vector<int> v;

int main(void){
	cin>>n;
	cev+=n%10;n/=10;
	cev+=10*(n%10);n/=10;
	cev1+=n%10;n/=10;
	cev1+=10*(n%10);n/=10;
	if(cev==0 && cev1==0){cout<<"NA\n";return 0;}
	if((cev>12 && cev1>12) || (cev>12 && cev1==0) || (cev1>12 && cev==0)){cout<<"NA\n";return 0;}
	if((cev<=12 && cev1<=12 && cev>0 && cev1>0) ){cout<<"AMBIGUOUS\n";return 0;}
	if(cev==0){
		cout<<"MMYY\n";
		return 0;
	}
	if(cev1==0){
		cout<<"YYMM\n";
		return 0;
	}
	if(cev1<=12){
		//~ cout<<cev<<endl;
		cout<<"MMYY\n";return 0;
	}
	else cout<<"YYMM\n";
	return 0;
}


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

vector<int> s[2];
vector<ull> u[2];

const int N = 500;
int n;
int val[2][N];
int d[N][N];

void flip() {
  rep(i,n)rep(j,i) {
    swap(d[i][j], d[j][i]);
  }
}
bool solve() {
  rep(i,n)rep(j,n) d[i][j] = -1;
  rep(k,2) {
    rep(i,n) {
      int x = val[k][i];
      if (s[k][i] != x) {
        rep(j,n) {
          if (d[i][j] == !x) return false;
          d[i][j] = x;
        }
      }
    }
    flip();
  }
  rep(_,2) {
    rep(k,2) {
      rep(i,n) {
        int x = val[k][i];
        if (s[k][i] == x) {
          vector<int> p;
          bool ok = false;
          rep(j,n) {
            if (d[i][j] == -1) p.push_back(j);
            if (d[i][j] == x) ok = true;
          }
          if (ok) continue;
          if (p.size() == 0) return false;
          if (p.size() == 1) {
            d[i][p[0]] = x;
          }
        }
      }
      flip();
    }
  }

  vector<int> is, js;
  rep(i,n) {
    bool filled = true;
    rep(j,n) if (d[i][j] == -1) filled = false;
    if (!filled) is.push_back(i);
  }
  rep(j,n) {
    bool filled = true;
    rep(i,n) if (d[i][j] == -1) filled = false;
    if (!filled) js.push_back(j);
  }
  rep(i,is.size())rep(j,js.size()) {
    d[is[i]][js[j]] = (i+j)%2;
  }
  return true;
}

ull ans[N][N];

int main() {
  cin >> n;
  rep(i,2) {
    s[i] = vector<int>(n);
    rep(j,n) cin >> s[i][j];
  }
  rep(i,2) {
    u[i] = vector<ull>(n);
    rep(j,n) cin >> u[i][j];
  }

  rep(b,64) {
    rep(i,2)rep(j,n) val[i][j] = u[i][j]>>b&1;
    if (!solve()) {
      cout << "-1" << endl;
      return 0;
    }
    rep(i,n)rep(j,n) ans[i][j] |= ull(d[i][j])<<b;
  }
  rep(i,n) {
    rep(j,n) {
      cout<<ans[i][j]<<(j==n-1?'\n':' ');
    }
  }
  return 0;
}

Measured memory_bytes: 8440
import java.util.Scanner;

public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int b, count = 0;
		for(int i = 0; i < n; i++)
		{
			if( isPrime( input.nextInt() ) )
				count++;
		}
		
		System.out.println(count);
	}

	private static boolean isPrime(int num)
	{
		if (num == 2 ) return true;
        if (num % 2 == 0) return false;
        for (int i = 3; i * i <= num; i += 2)
            if (num % i == 0) return false;
    	return true;
	}
}

Measured memory_bytes: 43492
#include <iostream>
#include <map>
using namespace std;
int main()
{
	int n,x=0,t,A,ans=0;
	map<int,int> a;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>t;
		if(t>100000)ans++;else a[t]=a[t]+1;
	}
	map<int,int>::iterator iter;  
	for(iter = a.begin(); iter != a.end(); iter++)  
		if(iter->first<=iter->second)ans+=iter->second-iter->first;
			else ans+=iter->second;
	cout<<ans<<endl;
}  

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

P project(P a,P b,P c){
  b-=a,c-=a;
  return a+b*real(c/b);
}

P reflect(P a,P b,P c){
  return -c+project(a,b,c)*2.0;
}

int main(){
  int n;
  double ax,ay,bx,by,cx,cy;
  scanf("%lf %lf %lf %lf %d",&ax,&ay,&bx,&by,&n);
  while(n--){
    scanf("%lf %lf",&cx,&cy);
    P p=reflect(P(ax,ay),P(bx,by),P(cx,cy));    
    printf("%.8f %.8f\n",p.real(),p.imag());
  }
  return 0;
}

Measured memory_bytes: 1256
#include <stdio.h>

int main()
{
    char a[100000];

    int n;

    scanf("%d", &n);

    char c = getchar();

    scanf("%s", a);

    for(int i = 0;a[i]!='\0';i++)
    {
        a[i]+=n;
        if(a[i]>'Z')
            a[i]-=26;
    }

    puts(a);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	fast_io();
	int d;
	cin >> d;
	d = 25 - d;
	cout << "Christmas";
	while(d--){
		cout << " Eve";	
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
typedef vector <int> ivector;
typedef set <int> iset;

int main(void){
	int n,q,tmp;
	iset S, T;

	cin >> n;
	for (int i=0; i<n; i++){
		cin >> tmp;
		S.insert(tmp);
	}

	cin >> q;
	for (int i=0; i<q; i++){
		cin >> tmp;
		T.insert(tmp);
	}

	ivector X(min(S.size(), T.size()));
	ivector::iterator it = set_intersection(S.begin(), S.end(), T.begin(), T.end(), X.begin());
	cout << it - X.begin() << endl;

	return 0;
}

Measured memory_bytes: 5568
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int ans = 0;
        for(int i = 0; i < n; i++){
            ans += Integer.parseInt(sc.next()) -1;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 26316
#include <bits/stdc++.h> 
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 998244353;
const int maxn = 3e5+10;
const int N = 1e5+10;
const int E = 2e5+10;  
ll n;

int main(){
	cin>>n;
	ll sum=0;
	F(i,1,n){
		F(j,1,n){
			F(k,1,n){
				sum+=__gcd(__gcd(i,j),k);
			}
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h> 
#define int long long
using namespace std;
int n,m,ans,fa[100001];
int find(int x)
{
	return fa[x]==x?x:fa[x]=find(fa[x]); 
}
signed main()
{
	scanf("%lld %lld",&n,&m);
	ans=n;
	for(int i=1;i<=n;i++)
		fa[i]=i;
	while(m--)
	{
		int x,y;
		scanf("%lld %lld",&x,&y);
		if(find(x)!=find(y))
		{
			ans--;
			fa[find(x)]=find(y);	
		}	
	} 
	cout<<ans-1;
	return 0;
}

Measured memory_bytes: 4536
//(・ω・)
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
using namespace std;

int main(){
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if(s==u){
      cout << a-1 << " "  << b << endl;
  }
  else{
      cout << a << " " << b-1 << endl;
  }
}

Measured memory_bytes: 256
D = int(input())
c = [int(i) for i in input().split()]
s = []
for _ in range(D):
    s.append([int(i) for i in input().split()])
score = 0
days = [[0]*26 for i in range(D+1)]
T = []
for k in range(D):
    t = int(input())-1
    T.append(t)
    for i in range(26):
        if i == t:
            days[k+1][i] = 0
        else:
            days[k+1][i] = days[k][i]+1
    score += s[k][t]
    for i in range(26):
        score -= days[k+1][i]*c[i]
M = int(input())
for _ in range(M):
    d,q = [int(i)-1 for i in input().split()]
    diff = s[d][q] - s[d][T[d]]
    i = d+1
    for k in range(d+1,D):
        if T[k] == q:
            i = k
            break
    else:
        i = D
    j = d+1
    for k in range(d+1,D):
        if T[k] == T[d]:
            j = k
            break
    else:
        j = D
    diff -= c[T[d]]*(days[d][T[d]]+1)*(j-d) - c[q]*days[d+1][q]*(i-d)
    score += diff
    L = days[d+1][q]
    for k in range(d+1,i+1):
        days[k][q]  -= L
    L = days[d][T[d]]+1
    for k in range(d+1,j+1):
        days[k][T[d]] += L
    T[d] = q
    print(score)

Measured memory_bytes: 71460
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
	char name[100];
	int t;
}P;

P Q[LEN+1];
int head,tail,n;

void enqueue(P x){
	Q[tail] = x;
	tail++;
	if(tail > LEN){
		tail = 0;
	}
}

P dequeue(){
	P a;
	a = Q[head];
	head ++;
	if(head > LEN){
		head = 0;
	}
	return a;
}

int main(){
	int total_time = 0;
	int i,q;
	P u;

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

	head = 1;
	tail = n + 1;

	for(i = 1;i <= n;i++){
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].t);
	}

	while(head != tail){
		u = dequeue();
		if(u.t > q){
			total_time += q;
			u.t -= q;
			enqueue(u);
		}else if(u.t <= q){
			total_time += u.t;
			printf("%s %d\n", u.name, total_time);
		}
	}

	return 0;
}

Measured memory_bytes: 10756
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int vec[1000000];
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        vec[t]++;
    }
    int ans=1;
    for(int i=0;i<n;i++){
        if(vec[i]>2){
            ans=0;
            break;
        }else if(i!=0&&vec[i]==1){
            ans=0;
            break;
        }else if(vec[i]==0){
            continue;
        }else{
            ans*=vec[i];
            ans%=MOD;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int a[200007],tot[200007];
int main()
{
	int n,i,x,k;
	cin>>n>>k;
	
	int s=0;
	
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(tot[a[i]]==0) s++;
		tot[a[i]]++;
	}	
	
	sort(tot+1,tot+n+1);
	int j=1;
	while(tot[j]==0)
		j++;
		
	int ans=0;
	while(s>k)
	{
		ans+=tot[j];
		j++;
		s--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n,m=map(int,input().split())      
uf=UnionFind(n)
for i in range(m):
    a,b=map(int,input().split())
    uf.union(a-1,b-1)
print(-min(uf.parents))    

Measured memory_bytes: 75052
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define r(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;

int main(void){
  int b, r;
  cin >> b;
  string s[110];
  string t[110];

  r(i,b){
    cin >> s[i];
  }

  cin >> r;
  r(i,r){
    cin >> t[i];
  }

  int ans=0;
  int cnt=0;
    for(int i=0; i<b; i++){
      cnt=0;
      for(int j=i; j<b; j++){
        if(s[i]==s[j])cnt++;
      }
      for(int j=0; j<r; j++){
        if(s[i]==t[j])cnt--;
      }
      ans=max(ans, cnt);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int k,s;
	int ans=0;
	cin >>k>>s;
	for(int a=0;a<=k;a++){
		for(int b=0;b<=k;b++){
			if(s-a-b >=0 and s-a-b <=k){ans++;}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
typedef unsigned long long ll;
ll a[maxn],sum[maxn];
const int mod = 1e9 + 7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin >> n;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
        sum[i] %= mod;
    }
    ll ans = 0;
    for(int i = 2;i <= n;i++){
        ans = (ans + a[i] * sum[i-1]) % mod;
    }
    cout << ans % mod<< endl;
    return 0;
}

Measured memory_bytes: 6712
n=gets.to_i
a,b=gets.split.map(&:to_i)
q=gets.split.map(&:to_i)
aa,bb,cc=0,0,0
n.times do |i|
  if q[i]<=a
    aa+=1
  elsif q[i]<=b
    bb+=1
  else
    cc+=1
  end
end
p [aa,bb,cc].min


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long N; cin >> N;
	vector<long long>A(2 * N);
	for (int i = 0; i < 2 * N; i++) {
		cin >> A.at(i);
	}
	sort(A.begin(), A.end());
	long long ans = 0;
	for(int i = 0; i < 2 * N; i += 2) {
		ans += A.at(i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def str_to_int(lista):
    for num, i in enumerate(lista):
        lista[num]=int(i)
        
def main():
    N_M=input().split()
    N=int(N_M[0])
    M=int(N_M[1])
    lst_H = input().split()
    str_to_int(lst_H)
    lst_Hcheck=[0]*N
    for i in range(M):
        temp = input().split()
        str_to_int(temp)
        temp[0] = temp[0]-1
        temp[1] = temp[1]-1
        if lst_H[temp[0]] > lst_H[temp[1]]:
        	lst_Hcheck[temp[1]] = 1
        elif lst_H[temp[0]] < lst_H[temp[1]]:
        	lst_Hcheck[temp[0]] = 1
        elif lst_H[temp[0]] == lst_H[temp[1]]:
            lst_Hcheck[temp[0]] = 1
            lst_Hcheck[temp[1]] = 1
    print(lst_Hcheck.count(0))
main()   

Measured memory_bytes: 82716
#  import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
#  sys.setrecursionlimit(10**7)
#  inf = 10 ** 20
#  eps = 1.0 / 10**10
#  mod = 10**9+7
#  dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
#  ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
#  def LI(): return [int(x) for x in sys.stdin.readline().split()]
#  def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
#  def LF(): return [float(x) for x in sys.stdin.readline().split()]
#  def LS(): return sys.stdin.readline().split()
#  def I(): return int(sys.stdin.readline())
#  def F(): return float(sys.stdin.readline())
#  def S(): return input()
#  def pf(s): return print(s, flush=True)

#  N, K = LI()
#  A = LI()

#  if N == K:
#      print(1)
#      exit()
#  N -= K
#  result = N / (K-1) + 1
#  if result % 1 != 0:
#      result //= 1
#      result += 1

#  print(int(result))



import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

N, K = LI()
A = LI()

if N == K:
    print(1)
    exit()
result = 0
N -= K
result += 1
result += N / (K-1)
if N % (K-1) != 0:
    result = int(result) + 1

print(int(result))

Measured memory_bytes: 16272
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
#define fout cout << fixed << setprecision(20)
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll LINF = 1e18;
// const ll MOD = 1e9 + 7;
const ll MOD = 1234567;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = INF;
    for (int y = 0; y < n; y++) {
        vector<int> v;
        for (int i = 0; i < n;) {
            vector<int> now;
            int j = i;
            while (j < n && a[j] >= a[y]) {
                now.push_back(a[j]);
                j++;
            }
            i = j + 1;
            sort(all(now));
            rep(l, sz(now) - k + 1) v.push_back(now[l]);
        }
        sort(all(v));
        if (sz(v) < q) continue;
        int x = v[q - 1];
        chmin(ans, x - a[y]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
if __name__ == "__main__":
    n = int(input())
    S = list(map(int, input().split()))
    q = int(input())
    T = list(map(int, input().split()))

    result = 0
    for t in T:
        l = 0
        r = n - 1
        while l <= r:

            # print('t {} l {} r {}'.format(t, l, r))
            c = (l + r) // 2
            if t < S[c]:
                r = c - 1
                continue
            elif t == S[c]:
                result += 1
                break
            elif S[c] < t:
                l = c + 1
                continue
            raise Exception

    print(result)



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

int main() {
	int a, b;
	char op;
	cin >> a >> op >> b;
	int ans;
	if (op == '+') {
		ans = a + b;
	} else if (op == '-') {
		ans = a - b;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
const int MAX_N=1e5;
int N,Q;
ll A[MAX_N],psm[MAX_N+1],psm2[MAX_N+1];	
bool C(ll x,ll r){
	int cnt=upper_bound(A,A+N,x+r-1)-lower_bound(A,A+N,x-r+1);
	int ub=upper_bound(A,A+N,x+r-1)-A;
	return N-ub>=cnt;
}
int main(){
	cin>>N>>Q;
	REP(i,N)cin>>A[i];
	REP(i,N)psm[i+1]=psm[i]+A[i];
	psm2[1]=A[0];
	REP(i,N-1){
		psm2[i+2]=psm2[i]+A[i+1];
	}
	REP(q,Q){
		ll X;
		cin>>X;
		ll ans=0;
		int tn,alb,aub;
		{
			int lb=0,ub=1e9+1;
			while(ub-lb>1){
				int mid=(lb+ub)>>1;
				if (C(X,mid)){
					lb=mid;
				}else{
					ub=mid;
				}
			}
			ll r=lb;
			if (r!=0){
				alb=upper_bound(A,A+N,X-r)-A;
				aub=lower_bound(A,A+N,X+r)-A;
			}else{
				alb=aub=lower_bound(A,A+N,X)-A;
			}
			int cnt=aub-alb;
			ans+=psm[N]-psm[N-cnt];
			tn=N-cnt-1;
		}
		while(tn>=aub){
			ans+=A[tn];
			tn--;
			bool f1=false,f2=false;
			if (alb>0){
				f1=true;
			}
			if (tn>=aub){
				f2=true;
			}
			if (f1==false && f2==false){
				break;
			}
			if (f1 && (!f2 || X-A[alb-1]<=A[aub]-X)){
				alb--;
			}else{
				aub++;
			}
		}
		ans+=psm2[alb];
		cout<<ans<<endl;
	}
	return 0;
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int W=in();
    int H=in();
    int top=H;
    int bottom=0;
    int left=0;
    int right=W;
    int N=in();
    int x,y,a;
    REP(i,N){
        cin>>x>>y>>a;
        if(a==1){
            left=max(left,x);
        }else if(a==2){
            right=min(right,x);
        }else if(a==3){
            bottom=max(bottom,y);
        }else{
            top=min(top,y);
        }
    }
    int ans;
    ans=max(top-bottom,0)*max(right-left,0);
    print(ans);
    return 0;
}


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

int main(){
	string S;
	cin>>S;
	if(S[1]=='R'){
		if(S[0]=='R' and S[2]=='R')cout<<3<<endl;
		else if(S[0]=='R' or S[2]=='R')cout<<2<<endl;
		else cout<<1<<endl;
	}else{
		if(S[0]=='R' or S[2]=='R')cout<<1<<endl;
		else cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   998244353 ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
void solve(){
   int n , x , y ;
   cin >> n >> x >> y ;
   vector < int > ans(n,0);
    for( int i = 1 ; i <= n ; i++){
        for( int j = i+1 ; j <= n ; j++){
            if(j<=x || i >= y){
                ans[j-i]++;
            }
            else if(i<=x && j>=y){
                ans[x-i + 1 + j-y]++;
            }
            else if (i<=x && j<y){
                int d = x-i + min(1+y-j,j-x) ;
                ans[d]++;
            }
            else if (j>=y && i>x){
                int d = j-y + min(i-x+1,y-i) ;
                ans[d]++;
            }
            else{
                int d = min(j-i,i-x+y-j+1);
                ans[d]++;
            }
        }
    }
    for( int i = 1 ; i < n ; i++) cout << ans[i] << "\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t ;
    t = 1 ;
    //cin >> t ;
    while(t--){
        solve( );
    }
}
// number of subset having xor in 2ki ow


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
int main() {
	int n;
	cin >> n;
	int mx1 = -1e9, mx2 = -1e9;
	int mn1 = 2e9, mn2 = 2e9;
	while (n--) {
		int x, y;
		cin >> x >> y;
		mx1 = max(mx1, x + y);
		mx2 = max(mx2, x - y);
		mn1 = min(mn1, x + y);
		mn2 = min(mn2, x - y);
	}
	cout << max(mx1 - mn1, mx2 - mn2) << endl;
}

Measured memory_bytes: 3596
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;



int main(){
    
    int N;
    cin >> N;
    int a;
    a=0;
    while(a*7<=N){
        if((N-7*a)%4 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a++;
    }
    cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
from fractions import gcd
from itertools import accumulate
N = int(input())
A = list(map(int, input().split()))
B = list(accumulate(A, gcd))
C = list(accumulate(A[::-1], gcd))[::-1]
C = C[2:] + C[:2]
B[-1] = C[-1]
C[-2] = B[-2]
print(max(map(gcd, B, C)))

Measured memory_bytes: 16612
def main():
    A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())

    counter = 0

    for Ai in range(A + 1):
        for Bi in range(B + 1):
            for Ci in range(C + 1):
                total = 500*Ai + 100*Bi + 50*Ci
                if total == X:
                    counter += 1

    print(counter)

main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
typedef long long ll;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	int n;
	cin >> n;
	ll ans = 1LL*n*(n-1)/2;
	cout << ans << endl;

	return 0;
}


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

int main(){
  int n,S[10001],q,T[501],i,j,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
    if(S[i]<0 || S[i]>1000000000){
      exit(1);
      }
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
    if(T[i]<0 || T[i]>1000000000){
      exit(8);
      }
  }
  
  for(i=0;i<q;i++){
    for(j=0;j<n-1;j++){
      if(T[i]==S[j]){
	count++;
	break;
      }
    }
  }
  
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 640