akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

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

    vector<int> r;
    map<int, int> to;
    for(int i = 1; i * i <= n; i++){
        r.push_back(i);
        if(i != n / i){
            r.push_back(n / i);
        }
    }
    sort(ALL(r));

    int nr = SZ(r);
    vector<int> cr(nr);
    rep(i, nr){
        cr[i] = r[i];
        if(i > 0){
            cr[i] -= r[i-1];
        }
    }

    vector<int> dp(ALL(cr));
    vector<int> sum(nr);
    rep(i, nr){
        if(i > 0){
            sum[i] += sum[i-1];
        }
        sum[i] += dp[i];
    }

    rep(i, k - 1){
        rep(j, nr){
            dp[j] = sum[nr-1-j] * cr[j] % MOD;
        }
        rep(j, nr){
            sum[j] = 0;
            if(j > 0){
                sum[j] += sum[j-1];
            }
            sum[j] += dp[j];
            sum[j] %= MOD;
        }
    }

    cout << sum.back() << endl;

    return 0;
}


Measured memory_bytes: 2928
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fir first
#define sec second
#define pb push_back
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 int INF = 1<<30;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

int main(){
	int n;
	cin >> n;
	vector<P> T(n);
	rep(i,n){
		int a, b;
		cin >> a >> b;
		T[i] = make_pair(b, a);
	}
	sort(all(T));
	ll t = 0;
	rep(i,n){
		int a = T[i].sec, b = T[i].fir;
		t += a;
		if(t > b){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<vector<int>> a(2, vector<int>(n));
  for (auto&& e : a[0]) cin >> e;
  for (auto&& e : a[1]) cin >> e;
  for (int i = 1; i < n; i++) {
    a[0][i] += a[0][i - 1];
  }
  a[1][0] += a[0][0];
  for (int i = 1; i < n; i++) {
    a[1][i] += max(a[0][i], a[1][i - 1]);
  }
  cout << a[1][n - 1] << endl;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n = read::<usize>();
    let mut seq = vec![0; n];
    for i in 0..n {
        seq[i] = read::<usize>();
    }
    let mut h = 0;
    for i in 0..n {
        if seq[i] < h {
            println!("No");
            return;
        }
        h = std::cmp::max(h, seq[i] - 1);
    }
    println!("Yes");
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

#define loop(i, n) for (int i = 0; i < (int)n; i++)

int main() {
    string s; cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) { cout << "Yes" << endl; return 0; }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,k,i;
	int m,n;
	scanf("%d%d%d",&a,&b,&k);
	m=min(b,a+k-1);
	n=max(b-k+1,a+k);
	for(i=a;i<=m;i++)
		printf("%d\n",i);
	for(i=n;i<=b;i++)
		printf("%d\n",i);
	return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    cout << (((n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3])) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3612
import java.util.Scanner
import java.util.Arrays
object Main extends App {
  val sc = new Scanner(System.in)
  val x, y, z, k = sc.nextInt
  val as = Array.fill(x)(sc.nextLong)
  val bs = Array.fill(y)(sc.nextLong)
  val cs = Array.fill(z)(sc.nextLong)

  def merge(la: Array[Long], ra: Array[Long]): Array[Long] = {
    val arr = for {
      l <- la
      r <- ra
    } yield l + r
    Arrays.sort(arr)
    arr
  }

  val result = merge(merge(as, bs).takeRight(3000), cs)
  println(result.takeRight(k).reverse.mkString("\n"))
}

Measured memory_bytes: 158796
#include<bits/stdc++.h>
using namespace std;
template <typename T> inline void read(T &x)
{
	x=0;int f=1;char c=getchar();
	for(;c>'9'||c<'0';c=getchar())if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=f;
}
template <typename T> inline void print(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) print(x/10);
	putchar(x%10+48);
}
long long s1[10101010];
bool s2[10101010];
long long n,m,x,y,z,cnt,sum;
int main()
{
	read(n);
	for(register int i=1;i<=n;i++)
		read(s1[i]);
	for(register int i=1;i<=n;i++)
	{
		if(s1[1]<s1[i])
		{
			y=1;
			break;
		}
		if(s1[1]>s1[i])
		{
			y=2;
			break;
		}
	}
	if(y==0)
	{
		cout<<1;
		return 0;
	}
	for(register int i=2;i<=n;i++)
	{
		if(y==1)
		{
			if(s1[i]>s1[i-1])
				y=1;
			if(s1[i]<s1[i-1]&&s2[i-1]==false)
			{
				for(register int j=i;j<=n;j++)
				{
					if(s1[i]<s1[j])
					{
						y=1;
						break;
					}
					if(s1[i]>s1[j])
					{
						y=2;
						break;
					}
				}
				sum++,s2[i-1]=true;
			}
		}
		else if(y==2)
		{
			if(s1[i]>s1[i-1]&&s2[i-1]==false)
			{
				for(register int j=i;j<=n;j++)
				{
					if(s1[i]<s1[j])
					{
						y=1;
						break;
					}
					if(s1[i]>s1[j])
					{
						y=2;
						break;
					}
				}
				sum++,s2[i-1]=true;
			}
			if(s1[i]<s1[i-1])
				y=2;
		}
	}
	print(sum+1);
	return 0;
}

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

int main() {
  int N,M;
  int Fx = 0;
  cin >> N;
  M = N;
  
  while(N != 0){
    Fx += N % 10;
    N /= 10;
  }
  
  if(M % Fx == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

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

	double T, A;
	cin >> T >> A;

	int ans = 0;
	double diff = 100100100;
	for (int ii = 0; ii < N; ++ii){
		double H;
		cin >> H;

		double tmp = T - H * 0.006;
		double tDiff = abs(A - tmp);
		if (tDiff < diff){
			ans = ii;
			diff = tDiff;
		}
	}

	cout << ans + 1 << "\n";

	return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){

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

	int n;cin>>n;
	vector<int> v(n,0);
	for(int i=0;i<n;i++)
		cin>>v[i];

	vector<vector<ll> > dp(n,vector<ll> (n,LLONG_MAX));
	vector<vector<ll> > s(n,vector<ll> (n,LLONG_MAX));
	for(int i=0;i<n;i++){
		dp[i][i]=0;
		s[i][i]=0;
	}

	for(int j=1;j<n;j++){
		for(int i=j-1;i>=0;i--){
			for(int k=i;k<j;k++){
				ll tmp=dp[i][k]+dp[k+1][j];
				if(k==i)
					tmp+=v[i];
				if(k+1==j)
					tmp+=v[j];
				ll t=tmp+s[i][k]+s[k+1][j];

				if(t<s[i][j]){
					dp[i][j]=tmp;
					s[i][j]=t;
				}
			}
		}
	}
	
	// for(int i=0;i<n;i++){
	// 	for(int j=0;j<n;j++){
	// 		if(i<=j)
	// 			cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }

	cout<<s[0][n-1]<<endl;

	return 0;
}

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

int main(){
  int x;
  while(cin>>x){
  int ans=0;
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      for(int k=0;k<10;k++){
        for(int l=0;l<10;l++){
          if(i+j+k+l==x)ans++;
        }
      }
    }
  }
  cout<<ans<<endl;
}
}



Measured memory_bytes: 2976
#include <cstdio>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(){
    map<string, int> data;
    string mxlen, mst, str;
    while(cin >> str){
        data[str]++;
        if(data[str] > data[mst]){
            mst = str;
        }
        if(str.size() > mxlen.size()){
            mxlen = str;
        }
    }
    cout << mst << ' ' << mxlen << endl;
    return 0;
}

Measured memory_bytes: 1192
#include <iostream> 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define MAX 1000001
ll prime[MAX];
#define FAST           ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define gcd __gcd
// ll rec(vector<vector<ll> >& dp,vector<ll>& arr,int n,int i,int k,int w)
// {
//   ll ans=0;
//   if(i>=n)
//     return 0;

//   if(dp[i][k]!=-1)
//     return dp[i][k];


//   if(k!=0)
//   ans=max(rec(dp,arr,n,i+1,w,w),arr[i]+rec(dp,arr,n,i+1,k-1,w));
//   else
//   ans=max(rec(dp,arr,n,i+1,k,w),rec(dp,arr,n,i+1,w,w));

//   return dp[i][k]=ans;

// }

//ll t[400008];
// void build(vector<ll>& a, int v, int tl, int tr) {
//     if (tl == tr) {
//         t[v] = a[tl];
//     } else {
//         int tm = (tl + tr) / 2;
//         build(a, v*2, tl, tm);
//         build(a, v*2+1, tm+1, tr);
//         t[v] = max(t[v*2] ,t[v*2+1]);
//     }
// }

// ll maxi(int v, int tl, int tr, int l, int r) {
//     if (l > r) 
//         return 0;
//     if (l == tl && r == tr) {
//         return t[v];
//     }
//     int tm = (tl + tr) / 2;
//     return max(maxi(v*2, tl, tm, l, min(r, tm)) ,maxi(v*2+1, tm+1, tr, max(l, tm+1), r));
// }



// void update(int v, int tl, int tr, int pos, ll new_val) {
//     if (tl == tr) {
//         t[v] = new_val;
//     } else {
//         int tm = (tl + tr) / 2;
//         if (pos <= tm)
//             update(v*2, tl, tm, pos, new_val);
//         else
//             update(v*2+1, tm+1, tr, pos, new_val);
//         t[v] = max(t[v*2] ,t[v*2+1]);
//     }
// }


struct hash_pair {
   template <class T1, class T2>
   size_t operator()(const pair<T1, T2>& p) const{
      auto hash1 = hash<T1>{}(p.first);
      auto hash2 = hash<T2>{}(p.second);
      return hash1 ^ hash2;
   }
};


int temp[1000002]={0};

void sieve()
{
  temp[1]=1;
  for(int i=2;i<1000002;i++)
  {
    if(temp[i]==0)
    { temp[i]=i;
      for(int j=i*2;j<1000002;j+=i)
      { 
        if(temp[j]==0)
        temp[j]=i;
      }
    }
  }

}

int dfs(int i,vector<vector<int> > &g,vector<int>& p,vector<int>& c)
{
  int sub=1;
  for(auto x:g[i])
  {
    if(p[i]!=x)
    {
      p[x]=i;
      sub+=dfs(x,g,p,c);
    }
  }

  return c[i]=sub;
}


int main() { 

int x;
cin>>x;

if(x)
  cout<<0<<"\n";
else
  cout<<1<<"\n";

return 0;
}
/*
1
4
1 2
2 3
3 4
*/


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

long long int gcd(long long int a, long long int b) {
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    
    if (b == 0) return a;
    else return gcd(b, a % b);
}

int main(){
    long long int n, X;
    cin >> n >> X;

    vector<long long int> x(n+1);
    x[0] = X;
    for(int i=1; i<n+1; i++){
        cin >> x[i];
    }
    sort(x.begin(),x.end());

    long long int ans = 0;
    for(int i=0; i<n; i++){
        ans = gcd(ans, x[i+1] - x[i]);
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long int Long;
typedef long double Double;
const int MAXN = 1e5 + 3;
const int MOD = 1e9 + 7;


int main() {
	int a, n;
	
	scanf("%d%d", &n, &a);
	printf("%d\n", n*n - a);
	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <assert.h>
#include <algorithm>
//#include <cmath>
#include <stack>
#include <string>

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

    std::string S;
    std::cin >> S;
    std::stack<char> left_stack;

    int32_t idx = 0;
    int32_t res = 0;
    char prev = 'x';
    for(idx = 0; idx < (int32_t) S.size(); idx++){
        if(!left_stack.empty()){
            prev = left_stack.top();
            if(S[idx] != prev){
                res += 2;
                left_stack.pop();
            }
            else{
                left_stack.push(S[idx]);
            }
        }
        else{
            left_stack.push(S[idx]);
        }
    }


    std::cout << res;
    return 0;
}


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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T>
vector<vector<T> > make_v(size_t a,size_t b){
  return vector<vector<T> >(a,make_v<T>(b));
}
template<typename T>
vector<vector<vector<T> > > make_v(size_t a,size_t b,size_t c){
  return vector<vector<vector<T> > > (a,make_v<T>(b,c));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//INSERT ABOVE HERE
signed main(){
  Int n;
  string s;
  cin>>n>>s;
  auto dp=make_v<Int>(8,n+1);
  dp[1][0]=1;
  const Int MOD = 10007;
  for(Int i=0;i<n;i++){
    for(Int b=0;b<8;b++){
      for(Int c=0;c<8;c++){
	if(s[i]=='J'&&(c&1)==0) continue;
	if(s[i]=='O'&&(c&2)==0) continue;
	if(s[i]=='I'&&(c&4)==0) continue;
	if((b&c)==0) continue;
	dp[c][i+1]+=dp[b][i];
	dp[c][i+1]%=MOD;
      }
    }
  }
  Int ans=0;
  for(Int i=0;i<8;i++) ans+=dp[i][n];
  ans%=MOD;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
#define N 200010
using namespace std;
ll n,dp[N],f[N][32],ans[N],num[N],wei[N];
vector<pair<ll,pair<ll,ll> > > vt[N];
vector<pair<pair<ll,ll>,pair<ll,ll> > > ds[N];
void dfs(ll x,ll lst,ll d)
{
	ll i;
	dp[x]=d;
	for(i=0;i<30;i++)
	{
		f[x][i+1]=f[f[x][i]][i];
	}
	for(i=0;i<vt[x].size();i++)
	{
		if(vt[x][i].F!=lst)
		{
			f[vt[x][i].F][0]=x;
			dfs(vt[x][i].F,x,d+1);
		}
	}
	return;
}
ll glca(ll x,ll y)
{
	ll i;
	if(dp[x]<dp[y])
	{
		swap(x,y);
	}
	for(i=30;i>=0;i--)
	{
		if(dp[f[x][i]]>=dp[y])
		{
			x=f[x][i];
		}
		if(x==y)
		{
			return x;
		}
	}
    for(i=30;i>=0;i--)
    {
        if(f[x][i]!=f[y][i])
        {
            x=f[x][i];
            y=f[y][i];
        }
    }
    return f[x][0];
}
void dfs2(ll x,ll lst,ll sow)
{
	ll i,y;
	pair<pair<ll,ll>,pair<ll,ll> > p;
	pair<ll,pair<ll,ll> > p2;
	for(i=0;i<ds[x].size();i++)
	{
		p=ds[x][i];
		if(p.S.S==0)
		{
			ans[p.S.F]+=sow*p.F.S;
		}
		else if(p.S.S==1)
		{
			ans[p.S.F]+=wei[p.F.F]*p.F.S;
		}
		else
		{
			ans[p.S.F]+=num[p.F.F]*p.F.S;
		}
	}
	for(i=0;i<vt[x].size();i++)
	{
		p2=vt[x][i];
		if(p2.F==lst)
		{
			continue;
		}
		num[p2.S.F]++;
		wei[p2.S.F]+=p2.S.S;
		dfs2(p2.F,x,sow+p2.S.S);
		wei[p2.S.F]-=p2.S.S;
		num[p2.S.F]--;
	}
	return;
}
int main(){
	ll i,x,y,q,col,w,a;
	scanf("%lld%lld",&n,&q);
	for(i=1;i<n;i++)
	{
		scanf("%lld%lld%lld%lld",&x,&y,&col,&w);
		x--;
		y--;
		vt[x].push_back(make_pair(y,make_pair(col,w)));
		vt[y].push_back(make_pair(x,make_pair(col,w)));
	}
	dfs(0,-1,0);
	for(i=0;i<q;i++)
	{
		scanf("%lld%lld%lld%lld",&col,&w,&x,&y);
		x--;
		y--;
		a=glca(x,y);
		ds[x].push_back(make_pair(make_pair(0,1),make_pair(i,0)));
		ds[x].push_back(make_pair(make_pair(col,-1),make_pair(i,1)));
		ds[x].push_back(make_pair(make_pair(col,w),make_pair(i,2)));
		ds[y].push_back(make_pair(make_pair(0,1),make_pair(i,0)));
		ds[y].push_back(make_pair(make_pair(col,-1),make_pair(i,1)));
		ds[y].push_back(make_pair(make_pair(col,w),make_pair(i,2)));
		ds[a].push_back(make_pair(make_pair(0,-2),make_pair(i,0)));
		ds[a].push_back(make_pair(make_pair(col,2),make_pair(i,1)));
		ds[a].push_back(make_pair(make_pair(col,-w*2),make_pair(i,2)));
	}
	dfs2(0,-1,0);
	for(i=0;i<q;i++)
	{
		printf("%lld\n",ans[i]);
	}
	return 0;
}

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

int main(void){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; i++){
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());
    int ans = 0;
    for(int i=0; i<n; i++){
        if(i == n-1){
            ans += v.at(i)/2;
        }else{
            ans += v.at(i);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n; cin >> n;
  vector<string> blue(n);
  for(int i = 0; i < n; i++){
    cin >> blue[i];
  }
  int m; cin >> m;
  vector<string> red(m);
  for(int i = 0; i < m; i++){
    cin >> red[i];
  }
  
  auto calc = [&](string s) {
    int buf = 0;
    for(string t: blue) {
      if(t == s) buf++;
    }
    for(string t: red) {
      if(t == s) buf--;
    }
    return buf;
  };
  
  int ans = 0;
  for(string t: blue){
    ans = max(ans, calc(t));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,r,x;
	scanf("%d %d",&n,&r);
	if(n>10||n==10)
	{
		x = r;
		printf("%d",x);
	}
	else
	{
		x = 100*(10-n);
		printf("%d",x+r);
	}
	return 0;
 } 

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

typedef long long ll;
typedef long double ld;

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

int main(){

    ll N;

    cin >> N;

    cout << N * 800 - N / 15 * 200 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    const int mod = 1e9+7;
    cin >> N;
    long long a = 1;
    for(int i=1; i<=N; ++i)
    {
        a = a*i%mod;
    }
    cout << a << endl;
}

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


using namespace std;



#define For(i,x,n)  for(long long i=x;i<n;i++)
#define rFor(i,x,n) for(long long i=x;i>=n;i--)
#define itFor(it,st)   for(auto it=st.begin() ; it!=st.end() ; it++)
#define MOD 1000000007
#define PI 3.141592653589793
#define INF 999999999999999999
#define N 1000005
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sp " "
#define cont continue
#define brk break

#define deb1(x)                cout<<#x<<": "<<x<<endl
#define deb2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define deb3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define deb4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

using namespace std;

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed;
    cout<<setprecision(3);
    srand(time(NULL));

    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll> a(n),b(m);
    For(i,0,n)
        cin>>a[i];
    For(i,0,m)
        cin>>b[i];
    ll sm = 0,idx=0;
    while(idx < n and sm+a[idx]<=k)
        sm += a[idx++];
    ll ans = idx;
    ll idx2 = 0;
    while(idx2 < m and idx>=0){
        sm += b[idx2];
        idx2++;
        while(sm>k and idx>0)
            sm -= a[--idx];
        if(sm<=k and ans < idx+idx2)
            ans = idx+idx2;
    }
    cout<<ans;
    //cout<<"\nTime used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case
    return 0;
}

//s1.substr(1,3) - return 3 characters starting from position 1 as substring of string sz1. eg sz1="shreynumh" sz1.substr(2,5)="reyan"
//num = atoi(s.c_str()); //convert string s to integer num
//n.erase(i,std::string::npos); //erase i th position in string n , decreasing string size
//s.find(b)!= std::string::npos - finds string b in string a - true if found
//cout<<"Time used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case                


Measured memory_bytes: 6360
#include<bits/stdc++.h>
#define U [1<<17]={}
#define G(a)((c=A[a]+A[P[a]]+C[a])%k?c:0)
typedef long long L;using namespace std;
map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p;char s U;
L D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)
	d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;}
L M(L i){return i?B[i]+M(i^i&-i):0;}
L S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;}
L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]));}
main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
	for(D(b=p=0);p<*Z;p++)if(!p|H[P[a=p]]-p)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=p;
	for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));}

Measured memory_bytes: 33476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n;
	cin >> n;
	ll p[n];
	zep(i, 0, n){
		cin >> p[i];
	}
	
	ll ans = 0;
	ll m = INF;
	zep(i, 0, n){
		if(p[i] < m){
			ans++;
		}
		m = min(p[i], m);
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    a = s.count("-")
    b = s.count("+")
    print(b-a)
    return

#B
def B():
    n = S()
    num = sum(map(int, n))
    n = int("".join(n))
    print(["Yes", "No"][n % num > 0])
    return

#C
def C():
    n, k = LI()
    LI()
    print((n - k) // (k - 1) + 1 + bool((n - k) % (k - 1)))
    return

#D
def D():
    return


#Solve
if __name__ == '__main__':
    C()

Measured memory_bytes: 52696
# -*- coding: utf-8 -*-
n = int(input())
x = [int(i) for i in input().split()]

ans = 100 * 100 * 100
tmp = 0
for i in range(-1000, 1001): #iは集会を開く場所
    for j in range(n):
        tmp += pow(x[j] - i, 2)
    if ans > tmp:
        ans = tmp
    tmp = 0
print(ans)


Measured memory_bytes: 2940
import heapq
import math
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
logof2=[0]*N
mi=0
buf=0
#print(A)
for i in range(N):
    A[i]=-A[i]  #heapqは実装上最初値しか取り出さないので、数列を-1倍し、最小値が最大に当たるようにする
heapq.heapify(A)#priority_que化
for i in range(M):
    buf=heapq.heappop(A)    #最大値を取り出すことに相当
    buf=-(-buf)/2            #切り捨て(floor)の挙動は負数の時おかしくなるので一旦正値に変換して計算し
    #buf=-buf                #負数に戻す
    heapq.heappush(A,buf)   #
    #print(A)
for i in range(N):
    mi=mi+math.floor(-1*A[i])  #残った要素ごとの足し算に相当する

print(mi)


Measured memory_bytes: 14532
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
typedef long long ll;
int main()
{
    char word[1000];
    int  i,flag,count[100];
    scanf("%s",word);
    int len=strlen(word);
    memset(count,0,sizeof(count));
    for(i=0;i<len;i++)
    {
        count[word[i]]++;
    }
    flag=1;
    for(i=0;i<len;i++)
    {
        if(count[word[i]]!=2)
        {
            flag=0;
        }
    }
    if(flag)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

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

int main(){
  ll N,H;
  cin >> N >> H;
  priority_queue<ll> a, b;

  for(int i = 0; i < N; i++){
    ll tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    a.push(tmp1);
    b.push(tmp2);
  }

  ll cnt = 0;
  while(H > 0){
    if(!b.empty()){
      if(a.top() <= b.top()){
	H -= b.top();
	b.pop();
	cnt++;
      }else{
	H -= a.top();
	cnt++;
      }
    }else{
      H -= a.top();
      cnt++;
    }
  }

  cout << cnt << endl;
  
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

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

    map<ll, ll> m;
    ll prev = 0;
    m[prev]++;
    REP(i, 0, N) {
        prev += A[i];
        m[prev]++;
    }

    ll ans = 0;
    for (auto elm : m) ans += elm.second * (elm.second - 1) / 2;
    cout << ans << endl;

    return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e18)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    bool ng = false;
    ll ans = 1;
    rep(i, n) {
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
        if (ng || __int128(ans) * a[i] > (ll)(INF)) ng = true;
        ans *= a[i];
    }
    if (ng) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4052
#include "bits/stdc++.h"

using namespace std;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < 100; i++) {
        int foo = n - 4 * i;
        if (foo >= 0 && foo % 7 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#define maxn 110
using namespace std;
int n,d[maxn];
int cnt[10],ans;
int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&d[i]);
	for (int i=1;i<=9;i++)
		cnt[i]=0;
	for (int i=1;i<=n;i++) {
		if (d[i]<400)
			cnt[1]++;
		else if (d[i]<800)
			cnt[2]++;
		else if (d[i]<1200)
			cnt[3]++;
		else if (d[i]<1600)
			cnt[4]++;
		else if (d[i]<2000)
			cnt[5]++;
		else if (d[i]<2400)
			cnt[6]++;
		else if (d[i]<2800)
			cnt[7]++;
		else if (d[i]<3200)
			cnt[8]++;
		else cnt[9]++;
	}
	ans=0;
	for (int i=1;i<=8;i++)
		if (cnt[i]>0)
			ans++;
	if (ans==0)
		printf("1 %d\n",cnt[9]);
	else printf("%d %d\n",ans,ans+cnt[9]);
	return 0;
}

Measured memory_bytes: 128
#include "iostream"
#include "string.h"
using namespace std;
 
int main(){
 
  string T;
  
  cin >> T;
  
  for(int i=0; i<= T.size(); i++){
   
    if(T[i]=='?') T[i]='D';
    
  }
  
  cout << T;
    
  return 0;
  
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b && a!=c) || (a==c && a!=b) || (c==b && b!=a)){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}


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

const int inf=1<<25;
int N,M,H,K,s,t;

struct node{int to,cost,hour,num;};
vector<node> graph[110];

typedef tuple<int,int,int> state;

int dijkstra(int mask){
	int dist[100][25];
	rep(i,N)rep(j,H+1) dist[i][j]=inf;
	dist[s][0]=0;
	priority_queue<state,vector<state>,greater<state>> q;
	q.push(state(0,s,0));
	while(!q.empty()){
		int c,v,t;
		tie(c,v,t)=q.top();q.pop();
		for(auto &e:graph[v]){
			int nc=c; if(~mask&(1<<e.num)) nc+=e.cost;
			int nv=e.to;
			int nt=t+e.hour; if(nt>H) continue;
			if(dist[nv][nt]>nc){
				dist[nv][nt]=nc;
				q.push(state(nc,nv,nt));
			}
		}
	}
	int res=inf;
	rep(i,H+1) res=min(res,dist[t][i]);
	return res;
}

int main(void){
	while(cin >> N >> M >> H >> K,N){
		rep(i,N) graph[i].clear();
		rep(i,M){
			int a,b,c,h,r;
			cin >> a >> b >> c >> h >> r;
			a--,b--,r--;
			graph[a].push_back({b,c,h,r});
			graph[b].push_back({a,c,h,r});
		}
		cin >> s >> t; s--,t--;
		int P; cin >> P;
		int dp[1<<8];
		rep(i,1<<K) dp[i]=inf;
		dp[0]=0;
		rep(i,P){
			int l,d;
			cin >> l >> d;
			int mask=0;
			rep(j,l){
				int k; cin >> k; k--;
				mask|=(1<<k);
			}
			dp[mask]=d;
		}
		rep(i,1<<K)rep(j,1<<K) dp[i|j]=min(dp[i|j],dp[i]+dp[j]);
		int ans=inf;
		rep(i,1<<K) ans=min(ans,dp[i]+dijkstra(i));
		cout << ((ans==inf)?-1:ans) << endl;
	}
	return 0;
}

Measured memory_bytes: 1396
#include "bits/stdc++.h"
using namespace std;
using lint = long long;
const int INF = 1e9;

signed main(){
  int N; cin >> N;
  string s; cin >> s;
  int Q; cin >> Q;
  vector<set<int> > alp(26, set<int> {INF});
  for(int i = 0; i < N; i++) alp[s[i] - 'a'].insert(i);
  
  for(int i = 0; i < Q; i++){
    int t; cin >> t;
    if(t == 1){
      int ind; char nc; cin >> ind >> nc; --ind;
      auto pc = s[ind];
      s[ind] = nc;
      alp[pc - 'a'].erase(ind);
      alp[nc - 'a'].insert(ind);
    }
    if(t == 2){
      int ans = 0;
      int l, r; cin >> l >> r; --l;
      for(int c = 0; c < 26; c++){
        if(alp[c].empty()) continue;
        if(*alp[c].lower_bound(l) < *alp[c].lower_bound(r)) ans++;
      }
      cout << ans << endl;
    }
  }
}


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

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> Ls(M), Rs(M);
    for(int i = 0; i < M; ++i){
        cin >> Ls[i] >> Rs[i];
    }

    int Lmax = *max_element(Ls.begin(), Ls.end());
    int Rmin = *min_element(Rs.begin(), Rs.end());
    int ans = Rmin - Lmax + 1;
    ans = max(ans, 0);
    cout << ans << endl;

    



    return 0;
}

Measured memory_bytes: 1024
// 三井住友信託銀行プログラミングコンテスト2019-A
// 2019.12.1 bal4u

#include <stdio.h>

int main()
{
	int M1, D1, M2, D2;
	
	scanf("%d%d%d%d", &M1, &D1, &M2, &D2);
	puts(M1 != M2? "1": "0"); 
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long int *value;bool *ready;

long long int dp(long int n, int *h){
    if(ready[n])return value[n];
    if(n==0)return 0;
    if(n==1)return abs(h[1]-h[0]);
    
    value[n]=min(abs(h[n]-h[n-1])+dp(n-1,h),abs(h[n]-h[n-2])+dp(n-2,h));
    ready[n]=true;
    return value[n];
}


void run_case(){
    long int n;
    cin>>n;
    int *h;
    value = new long long int[n];ready=new bool[n];
    h=new int[n];

    for(long int i=0;i<n;i++){
        cin>>h[i];
        ready[i]=false;
    }
    cout<<dp(n-1,h);
    
    

}
int main(){
	ios_base::sync_with_stdio(false),cin.tie(nullptr);
    int t=1;
    while(t--){
        run_case();

    }
}



Measured memory_bytes: 7232
#include <stdio.h>

int main(void){
  int Mon[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
  int month,day;

  for(;;){

    scanf("%d%d" ,&month ,&day);
    if( month == 0 && day == 0 ) break;

    while( month != 1 ) day += Mon[--month];

    switch(day%7){
    case 0:
      printf("Wednesday\n");
      break;
    case 1:
      printf("Thursday\n");
      break;
    case 2:
      printf("Friday\n");
      break;
    case 3:
      printf("Saturday\n");
      break;
    case 4:
      printf("Sunday\n");
      break;
    case 5:
      printf("Monday\n");
      break;
    case 6:
      printf("Tuesday\n");
      break;
    }

  }

  return 0;
}

Measured memory_bytes: 584
N = int(input())
arr = list(map(int, input().split()))
cnt = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            if arr[i] == arr[j] or arr[j] == arr[k] or arr[i] == arr[k]:
                continue
            if not ((arr[i] + arr[j]) > arr[k] and (arr[j] + arr[k]) > arr[i] and (arr[i] + arr[k]) > arr[j]):
                continue
            cnt += 1
print(cnt)

Measured memory_bytes: 9244
n, m = map(int,input().split())
l = [0 for i in range(m)]
for i in range(n):
  s = list(map(int, input().split()))
  for j in range(1, s[0]+1):
    l[s[j]-1] += 1
l = list(map(lambda x: x//n, l))
print(sum(l))
  

Measured memory_bytes: 38256
#include <iostream>
#include <cmath>

using namespace std;

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

  long sq = sqrt(n);
  do {
    if (n % sq == 0) {
      break;
    }
  } while(sq--);

  cout << sq + n / sq - 2 << endl;
  return 0;
}


Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int ans;
void solve(string &S, string &T, int pos, int k,int cnt) {
	if (pos == k) {
		ans = min(ans, cnt);
		return;
	}
	int d = (T[pos] - S[pos] + 10) % 10;
	if (d == 0) {
		solve(S, T, pos + 1, k, cnt);
		return;
	}
	for (int i = pos; i < k; i++) {
		(S[i] += d) %= 10;
		solve(S, T, pos + 1, k, cnt + 1);
	}
	for (int i = pos; i < k; i++) (S[i] += 10 - d) %= 10;
}
int main() {
	int k;
	while (cin >> k, k) {
		string S, T;
		cin >> S >> T;
		for (int i = 0; i < k; i++) S[i] -= '0', T[i] -= '0';
		ans = 1 << 30;
		solve(S, T, 0, k, 0);
		cout << ans << endl;
	}
}


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

int main()
{
  int cnt = 0;
  string S;
  cin >> S;
  for (int i = 0; i < S.size(); i++)
  {
    if (S.at(i) == 'o')
      cnt++;
  }
  cout << ((cnt + (15 - S.size()) >= 8) ? "YES" : "NO") << endl;
}


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

#define ll long long


int main(void)
{
	int k = 0; cin >> k;
	string s; cin >> s;
	string ans = "";
	if(k < s.size()) {
		for(int i = 0; i < k; i++) {
			ans += s[i];
		}
		ans += "...";
		cout << ans << endl;
	} else {
		cout << s << endl;
	}
	
}


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

using namespace std;

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

const int INF = 1000000000; //
const ll LINF = (ll) 4000000000000000000; //
const ll MOD = (ll) 1000000007; //
const double PI = 3.1415926535898; //

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define NP(v) next_permutation(v.begin(),v.end())

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

int main() {
    string s;
    cin >> s;
    stack<char> stk;

    int len = (int) s.length();
    stk.push(s[0]);

    REP(i, 1, s.length()) {
        if (!stk.empty() && stk.top() == 'S' && s[i] == 'T') {
            stk.pop();
            len -= 2; //s[i]は入れない
        } else {
            stk.push(s[i]);
        }
    }
    
    cout << len << endl;

    return 0;
}


Measured memory_bytes: 644
#include <iostream>
#define add(coinvalue) changecoins+=(int)change/coinvalue;change%=coinvalue;
using namespace std;

int main() {
	// your code goes here
	for(;;){
		int fee;
		cin >> fee;
		if(fee==0)
			break;
		int change=1000-fee;
		int changecoins=0;
		add(500)
		add(100)
		add(50)
		add(10)
		add(5)
		add(1)
		cout << changecoins << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#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

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

int main() {
	int A, B;
	cin >> A >> B;
	cout << max(0, A - B * 2) << endl;
}

Measured memory_bytes: 256
//This is getting accepted!
#include<bits/stdc++.h>
#define ll long long
#define oo 1000000009
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define INARR(a,n) for (int i = 1; i <= (n); ++i) cin >> a[i];
#define ITE(x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define isset(x, i) (((x)>>(i))&1)
#define setbit(x, i) ((x)^(1ll<<(i)))
#define clearbit(x, i) ((x)&(~(1ll<<(i))))
#define twoexp(i) (1ll<<(i))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define FI first
#define SE second
#define son1 (id*2)
#define son2 (id*2+1)

using namespace std;

const int MOD = 1000000007;
const double EPS = 1e-8;
const double PI = 2 * acos(0);
const int MAXN = 1e6 + 6;

int n;
string s[MAXN];

void input() {
	int u, v, w, x, y, qtype;
	
	cin >> n;
	FOR(i, 1, n) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}
	
}


void preprocess() {
	
	sort(s+1, s+n+1);
	
}

void process(int itest) {
	int u, v, w, x, y, qtype;
	
	ll res = 0;
	
	int i = 1, j = i;
	while(i <= n && j <= n) {
		while(j < n && s[i] == s[j+1])
			j++;
		
		res += 1ll * (j-i+1) * (j-i) / 2;
		
		i = j+1; j = i;
	}
	
	cout << res << endl;
	
}

void oneTest() {
	
	input();
	preprocess();
	process(0);
	
}

void multiTest() {
	
	int t;
	cin >> t;
	
	for (int it = 1; it <= t; ++it) {
		input();
		preprocess();
		process(it);
	}
}

int main(){
    #ifndef ONLINE_JUDGE
//    freopen("../out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	oneTest();
//	multiTest();

    return 0;

}


Measured memory_bytes: 12800
#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);
	ll d,t,s;
	cin>>d>>t>>s;
	double sp = (d*1.0)/(t*1.0);
	if(sp<=(s*1.0))	cout<<"Yes"<<endl;
	else	cout<<"No"<<endl;
	// // float tm = t*1.0;
	// // float tp = (float)(d/s);
	// if(d/s<=t)	cout<<"Yes"<<endl;
	// // else if(abs(tp-tm) < 1e-9)	cout<<"Yes"<<endl;
	// else	cout<<"No"<<endl;
}


Measured memory_bytes: 3640
while True:
    H, W = map(int,input().split())
    if H == 0 and W == 0:break
    for j in range(H):
        for i in range(W):
            if (i + j) % 2 == 0:
                print('#',end='')
            else:
                print('.',end='')
        print()
    print()


Measured memory_bytes: 7004
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;

namespace atcoder
{
    class Solver
    {
        //Solve
        public void Solve()
        {
            cin = new Scanner();
            int n = cin.nextint;
            int[] b = cin.scanint;

            int max = b[0] + b[n - 2];

            for (int i = 0; i < n - 2; i++)
            {
                // Console.WriteLine(Math.Min(b[i], b[i + 1]));
                max += Math.Min(b[i], b[i + 1]);
            }

            Console.WriteLine(max);
        }


        //Main
        public Solver() { }
        Scanner cin;
        public static int Main()
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Solver().Solve();
            Console.Out.Flush();
            return 0;
        }

        //Util
        static bool IsOdd(long num) { return (num & 1) == 1; }
        static bool IsEven(long num) { return (num & 1) == 0; }
        static long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
    }

    class Scanner
    {
        string[] s; int i;
        readonly char[] cs = new char[] { ' ' };
        public Scanner() { s = new string[0]; i = 0; }
        public string[] scan => Console.ReadLine().Split();
        public int[] scanint => Array.ConvertAll(scan, int.Parse);
        public long[] scanlong => Array.ConvertAll(scan, long.Parse);
        public double[] scandouble => Array.ConvertAll(scan, double.Parse);
        public string next
        {
            get
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next;
            }
        }
        public int nextint => int.Parse(next);
        public long nextlong => long.Parse(next);
        public double nextdouble => double.Parse(next);
    }

    class Node<T>
    {
        private int m_height;
        private Node<T> m_parent;
        public T Item { get; private set; }
        public Node(T item)
        {
            m_height = 0;
            m_parent = this;
            Item = item;
        }
        public Node<T> Find()
        {
            if (m_parent == this) { return this; }

            Node<T> parent = m_parent.Find();
            m_parent = parent;
            return parent;
        }
        public static void Unite(Node<T> a, Node<T> b)
        {
            Node<T> p = a.Find();
            Node<T> q = b.Find();
            if (p.m_height < q.m_height)
            {
                p.m_parent = q;
                q.m_height = Math.Max(p.m_height + 1, q.m_height);
            }
            else
            {
                q.m_parent = p;
                p.m_height = Math.Max(q.m_height + 1, p.m_height);
            }
        }
    }
}

Measured memory_bytes: 13268
from collections import deque 
h,w=map(int,input().split())
S=[input() for _ in range(h)]
def long(S,start):
    tbl=[[-1]*w for _ in range(h)]
    tbl[start[0]][start[1]]=0
    todo=deque([start])
    while todo:
        a,b=todo.popleft()
        c=tbl[a][b]
        if a!=0 and S[a-1][b]=="." and tbl[a-1][b]==-1:
            tbl[a-1][b]=c+1
            todo.append([a-1,b])
        if a!=h-1 and S[a+1][b]=="." and tbl[a+1][b]==-1:
            tbl[a+1][b]=c+1
            todo.append([a+1,b])
        if b!=0 and S[a][b-1]=="." and tbl[a][b-1]==-1:
            tbl[a][b-1]=c+1
            todo.append([a,b-1])
        if b!=w-1 and S[a][b+1]=="." and tbl[a][b+1]==-1:
            tbl[a][b+1]=c+1
            todo.append([a,b+1])
    m=0
    for i in range(h):
        for j in range(w):
            m=max(m,tbl[i][j])
    return m
ans=0
for x in range(h):
    for y in range(w):
        if S[x][y]==".":
            ans=max(ans,long(S,[x,y]))
print(ans)

Measured memory_bytes: 3316
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b;
    cin >> a >> b;
    cout << (a-1) * (b-1);
    
    cout << endl;
}


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

using namespace std;

#define all(v) (v).begin(), (v).end()

using li = long long;
using ld = long double;

void solve(bool);

int main() {
#ifdef YA
    auto s = clock();
    assert(freopen("input.txt", "r", stdin));
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif

    cout << fixed << setprecision(20);

    solve(true);

#ifdef YA1
    while (true) solve(false);
#endif

#ifdef YA
    cout << endl << endl << "time = " << (clock() - s) / (double)CLOCKS_PER_SEC << endl;
#endif

    return 0;
}

int n, m;
bool a[1111][1111];

void solve(bool __attribute__((unused)) read) {
    cin >> n >> m;
    vector <pair <int, int> > q;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < m; ++j) {
            a[i][j] = (s[j] == '#');
            if (a[i][j]) {
                q.push_back({i, j});
            }
        }
    }
    int cnt = 0;
    int l = 0;
    int gr = q.size();
    while (l < (int)q.size()) {
        int x, y;
        tie(x, y) = q[l++];
        // cout << x << " " << y << endl;
        for (int dx = -1; dx <= 1; ++dx) {
            for (int dy = -1; dy <= 1; ++dy) {
                if (abs(dx) + abs(dy) != 1 || x + dx < 0 || x + dx >= n || y + dy < 0 || y + dy >= m || a[x + dx][y + dy])
                    continue;
                a[x + dx][y + dy] = 1;
                q.push_back({x + dx, y + dy});
            }
        }
        if (l == gr) {
            gr = q.size();
            ++cnt;
            // cout << endl;
            // cout << gr << endl << endl;
        }
    }
    cout << cnt - 1 << "\n";
}

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

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

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

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

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

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

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

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

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

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

    map<ll,ll> M;

    M[A]++;
    M[B]++;
    M[C]++;

    if(M[5] == 2 && M[7] == 1){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3544
#!/usr/bin/python3

import sys

def min2nd(ls):
    return sorted(ls)[1]

def solve(input):
    count = 0
    for i in range(0, len(input) - 2):
        slice_ = input[i:i+3]
        if slice_[1] == min2nd(slice_):
            count += 1
    return count

def main():
    sys.stdin.readline()
    inputs = [int(s) for s in sys.stdin.readline().rstrip().split(" ")]
    print(solve(inputs))

main()

Measured memory_bytes: 3060