akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> destinations(M);
    for (int i = 0; i < M; ++i)
    {
        cin >> destinations[i];
    }
    sort(destinations.begin(), destinations.end());
    if (M == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    vector<int> distances(M - 1);
    for (int i = 0; i < M - 1; ++i)
    {
        distances[i] = destinations[i + 1] - destinations[i];
    }
    int sum = accumulate(distances.begin(), distances.end(), 0);
    sort(distances.rbegin(), distances.rend());
    for (int i = 0; i < min(N - 1, M - 1); ++i)
    {
        sum -= distances[i];
    }
    cout << sum << endl;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    int N; cin >> N;
    VI A(N), B(N); REP(i,N) cin >> A[i] >> B[i];

    SORT(A); SORT(B);
    int mx, mn;
    if(N&1){
        mn = A[N/2]; mx = B[N/2];
    }
    else{
        mn = A[N/2-1]+A[N/2]; mx = B[N/2-1]+B[N/2];
    }

    int ans = mx-mn+1;
    
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t){
        Main();
    }
    return 0;
}

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

int main(){
    ll x;
    cin>>x;
    ll ans=0;
	ans+=x/500*1000;
    ll qx=x%500;
    ans+=qx-qx%5;
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
static const int INFTY = (1<<21);

int n, M[MAX][MAX];

void dijkstra(){
  int minv, i=0, u, v=0;
  int d[MAX], color[MAX];

  for(i=0; i<n; i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;
  while(1){
    minv = INFTY;
    u = -1;
    for(i=0; i<n; i++){
      if(minv>d[i] && color[i] != BLACK){
        u = i;
        minv = d[i];
      }
    }

    if(u == -1) break;
    color[u] = BLACK;
    for(v=0; v<n; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
        if(d[v] > d[u] + M[u][v]){
          d[v] = d[u] + M[u][v];
          color[v] = GRAY;
        }
      }
    }
  }

  for(i=0; i<n; i++){
    printf("%d %d\n",i,(d[i]==INFTY ? -1 : d[i]));
  }
}

int main(){

  int i=0,j=0;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      M[i][j] = INFTY;
    }
  }

  int k, c, u, v;
  for(i=0; i<n; i++){
    scanf("%d%d",&u,&k);
    for(j=0; j<k; j++){
      scanf("%d%d",&v,&c);
      M[u][v] = c;
    }
  }

  dijkstra();

  return 0;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

int N;
vec<int> A;

int calc(int b) {
	int sum = 0;
	rep (i, N) {
		sum += abs(A[i] - b);
	}
	return sum;
}

signed main() {
	cin >> N;
	A.resize(N);
	rep (i, N) {
		cin >> A[i];
		A[i] -= (i + 1);
	}

	print1(all(A));

	sort(all(A));

	int num = A[N/2];

	cout << calc(num) << endl;

	return 0;
}

Measured memory_bytes: 1792
def resolve():
    ans = [input() for _ in range(5)]
    an = 0
    count = []
    for i in range(5):
        if ans[i][-1]=="0":
            an += int(ans[i])
        else:
            an += int(ans[i])+10-int(ans[i][-1])
            count.append(int(ans[i][-1]))
    print(an-10+min(count) if len(count) != 0 else an)
resolve()

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define ll long long
#define el '\n'

using namespace std;

ll pc[41];

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

    for (int i=0;i<41;i++) pc[i]=(1 << i);

    ll a,b;
    cin >> a >> b;

    ll xa=a%4;
    if (xa==0) xa=a;
    else if (xa==2) xa=a+1;
    else if (xa==1) xa=1;
    else xa=0;
    ll xb=b%4;
    if (xb==0) xb=b;
    else if (xb==2) xb=b+1;
    else if (xb==1) xb=1;
    else xb=0;

    xa=(xa^a);

    cout << (xb^xa) << el;

    return 0;
}

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

int main(void) {

    char s[1000];

    scanf("%s", s);

    int len = strlen(s);

    if (s[len - 1] == 's') {
        printf("%ses\n", s);
    } else {
        printf("%ss\n", s);
    }
    
    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

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

    vector<P> ans;
    if (n % 2){
        FOR(i,1,n){
            FOR(j,i+1,n){
                if (i + j != n) ans.push_back(P(i, j));
            }
        }
    }else{
        FOR(i,1,n){
            FOR(j,i+1,n){
                if (i + j != n + 1) ans.push_back(P(i, j));
            }
        }
    }
    cout << ans.size() << endl;
    for (P p : ans) cout << p.first << " " << p.second << endl;

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        // input
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        if (A > C && C > B) System.out.println("Yes");
        else if (B > C && C > A) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 21844
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b + 1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef deque<ll> dqll;

const ll mod = 1000000007;

vector<ll> cst;
vector<vector<P>> lst;

int main() {
  ll H, W, N;
  cin >> H >> W >> N;

  vll lst(N);
  vll tmp(W);

  for (ll i = 0; i < N; i++) {
    cin >> lst[i];
  }

  ll use = 0;
  ll col = 0;
  for (ll i = 0; i < H; i++) {
    for (ll j = 0; j < W; j++) {
      ll tmp_idx = (i % 2 == 0) ? j : W - 1 - j;
      tmp[tmp_idx] = col+1;
      use++;
      if (use >= lst[col]) {
        col += 1;
        use = 0;
      }
    }
    for (ll j = 0; j < W; j++) {
      cout << tmp[j] << " ";
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    long L = sc.nextLong();
    long R = sc.nextLong();

    sc.close();

    long r = Math.min(R, L+4038);

    long min = 2018;
    
    for (long i = L; i <= r; i++){
      for (long j = i + 1; j <= r; j++){
        long m = i*j%2019;
        min = Math.min(min, m);
      }
    }

    System.out.println(min);
    
  }

}

Measured memory_bytes: 21844
n,m=map(int,input().split())
h=list(map(int,input().split()))
aa=[[] for i in range(n)]
for i in range(m):
    ai,bi=list(map(int,input().split()))
    aa[ai-1].append(bi-1)
    aa[bi-1].append(ai-1)

icnt=0
for i in range(n):
    yn=""
    for bii in aa[i]:
        if h[bii]>=h[i]:
            yn="NO"
            break
    if yn!="NO":
        icnt+=1

print(icnt)
    

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

using namespace std;

int main(void){

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

    int ans = 0;

    for(int i = 0;i < n;i++){
        for(int j = 0;j < d;j++){
            if(j*a[i]+1 > d)break;
            ans++;
        }
    }

    cout << ans+x << endl;

    return 0;
}

Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
A = iil()
ans = 0
for i in range(1,n):
    if A[i-1] == A[i]:
        ans += 1
        A[i] = -1
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);

    int N,M,C,s,o,sum,cnt;
    int[][] A;
    int[] B;

    N=sc.nextInt();
    M=sc.nextInt();
    C=sc.nextInt();

    A=new int[N][M];
    B=new int[M];

    for(s=0;s<M;s++){
      B[s]=sc.nextInt();
    }

    for(s=0;s<N;s++){
      for(o=0;o<M;o++){
        A[s][o]=sc.nextInt();
      }
    }

    for(cnt=0,s=0;s<N;s++){
      for(sum=0,o=0;o<M;o++){
        sum+=A[s][o]*B[o];
      }
      if(sum+C>0){
        cnt++;
      }
    }

    System.out.println(cnt);

  }
}


Measured memory_bytes: 23764
A, B, M = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

minimum = min(a) + min(b)

for _ in range(M):
  x, y, c = map(int, input().split())
  tmp = a[x-1] + b[y-1] - c
  if tmp < minimum:
    minimum = tmp
    
print(minimum)

Measured memory_bytes: 18736
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

priority_queue<pii,vector<pii>,greater<pii> > pq;
string str[105];
ll mrk[105][105],dist[105][105];

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

	ll h,w,i,j,u,v,d,wt;

	cin >> h >> w;

	for(i=0;i<h;++i)
		cin >> str[i];

	for(i=0;i<h;++i)
	{
		for(j=0;j<w;++j)
		{
			dist[i][j] = 1e9;
		}
	}

	if(str[0][0] == '#')
	{
		pq.push(pii(1,pi(0,0)));
		dist[0][0] = 1;
	}
	else
	{
		pq.push(pii(0,pi(0,0)));
		dist[0][0] = 0;
	}
	
	while(!pq.empty())
	{
		pii ed = pq.top();
		pq.pop();
		d = ed.ff;
		u = ed.ss.ff;
		v = ed.ss.ss;

		if(mrk[u][v])
			continue;

		mrk[u][v] = 1;

		if(u+1<h && v<w)
		{
			if(str[u+1][v] == '#')
				wt = 1;
			else
				wt = 0;
			if(str[u][v] == '#')
				wt = 0;
			if(dist[u+1][v] > dist[u][v]+wt)
			{
				dist[u+1][v] = dist[u][v] + wt;
				pq.push(pii(dist[u+1][v],pi(u+1,v)));
			}
		}
		if(u<h && v+1<w)
		{
			if(str[u][v+1] == '#')
				wt = 1;
			else
				wt = 0;
			if(str[u][v] == '#')
				wt = 0;
			if(dist[u][v+1] > dist[u][v]+wt)
			{
				dist[u][v+1] = dist[u][v] + wt;
				pq.push(pii(dist[u][v+1],pi(u,v+1)));
			}
		}
	}

	cout << min(h+w-1,dist[h-1][w-1]) << "\n";
	return 0;
}
	

Measured memory_bytes: 512
#include <iostream>
#include <vector>

using std::cin;
using std::cout;
using std::vector;

class BIT {
  vector<int> tree;

 public:
  BIT(int n) : tree(n, 0) {}
  void add(int i, int x) {
    while (i <= tree.size()) {
      tree[i] += x;
      i += i & -i;
    }
  }

  int sum(int s) {
    int ans = 0;
    while (s > 0) {
      ans += tree[s];
      s -= s & -s;
    }

    return ans;
  }
};

int main(int argc, const char *argv[]) {
  int n, q;
  cin >> n >> q;
  BIT bit(n + 1);
  for (int i = 0; i < q; i++) {
    int c, x, y;
    cin >> c >> x >> y;
    if (c == 0) {
      bit.add(x, y);
    } else {
      cout << bit.sum(y) - bit.sum(x - 1) << '\n';
    }
  }

  return 0;
}


Measured memory_bytes: 3132
import java.util.Scanner;

public class Main {
    static Scanner input = new Scanner(System.in);

    public static void main(String[] prgs) {
        int[] before = new int[51];
        int[] temp = new int[51];
        while(input.hasNext()) {
            int n = input.nextInt(), r = input.nextInt();
            if(n == 0 && r == 0)
                break;
            for(int i = n, j = 1; i >= 1 && j <= n; i--, j++) {      //Initialize
                before[j] = i;
            }
            for(int i = 1; i <= r; i++) {
                int p = input.nextInt(), c = input.nextInt();
                for(int j = 1; j <= p - 1; j++) {
                    temp[j] = before[j];
                }
                for(int k = p; k <= p + c - 1; k++) {
                    before[k - p + 1] = before[k];
                }
                for(int j = c + 1, k = 1; j <= p + c - 1 && k <= p - 1; j++, k++) {
                    before[j] = temp[k];
                }
            }
            System.out.println(before[1]);
        }
    }
}



Measured memory_bytes: 36220
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
using P=pair<int,int>;
int main() {
    rep(i,5){
        int x;
        cin>>x;
        if(x==0){
            cout<<i+1<<endl;
        }
    }

}

Measured memory_bytes: 3584
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    cout<<(n/2)+n%2;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> PI;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second


signed main(){
	
	ll n,cnt = 0,cnt2 = 0,memo = 0;
	
	bool is_exist[8] = {false};
	
	cin >> n;
	
	rep(i,0,n){
		cin >> memo;
		
		if(memo >= 3200) cnt++;
		else{
			is_exist[memo / 400] = true;
		}
	}
	
	
	
	
	rep(i,0,8){
		if(is_exist[i]) cnt2++;
	}
	
	if(cnt2 != 0)cout << cnt2 << " " << cnt+cnt2 << endl;
	else cout << 1 << " " << cnt+cnt2 << endl;
	
	
	return 0;

}

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

using namespace std;
#define int long long
#undef int
int main(){
	#define int long long
	int a,b,c,d,n;cin>>a>>b>>c>>d>>n;
	n*=4;
	if(b>a*2)b=a*2;
	if(c>b*2)c=b*2;
	if(d>c*2)d=c*2;
	int ans=0;
	ans+=(n/8)*d;n%=8;
	ans+=(n/4)*c;n%=4;
	ans+=(n/2)*b;n%=2;
	ans+=(n)*a;
	cout<<ans<<endl;
	return 0;
}

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

signed main(){
  
  int N, D;
  cin >> N >> D;
  
  D = D * D;
  
  int ans = 0;
  
  for(int i=0;i<N;i++){

    int X, Y;
    cin >> X >> Y;
      
    int d = X * X + Y * Y;
    
    if( d <= D ) ans++;
    
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>

#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1<<29
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back
#define _DEBUG(x) cout<<#x<<": "<<x<<endl
#define _DDEBUG(x,y) cout<<#x<<": "<<x<<", "<<#y<<": "<<y<<endl
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

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

	int a, b;
	cin >> a >> b;

	if(a <= 0 && 0 <= b) {
		cout << "Zero" << endl;
	} else if (0 <= a && 0 <= b) {
		cout << "Positive" << endl;
	} else {
		cout << (((a - b) * -1) % 2 ? "Positive" : "Negative") << endl;
	}
#if DEBUG
	cout << "** RESULT **" << endl; // debug
#endif

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] dom = new long[n];
		long[] mt = new long[n];
		for(int i = 0; i < n; i++) {
			dom[i] = sc.nextLong();
		}
		for(long i = dom[0]; i > -1; i--) {
			boolean suc = true;
			mt[0] = i * 2;
			for(int j = 0; j < n; j++) {
				long tmp = 2 * dom[j] - mt[j];
				if(tmp >= 0) {
					if(j != n - 1) {
						mt[j + 1] = tmp;
					} else if(tmp != mt[0]) {
						i += (tmp - mt[0] + 4) / 4;
						suc = false;
						break;
					}
				} else {
					i += (tmp + 2) / 2;
					suc = false;
					break;
				}
			}
			if(suc) {
				for(int j = 0; j < n; j++) {
					System.out.print(mt[j] + " ");
				}
				System.out.println();
				break;
			}
		}

	}

}


Measured memory_bytes: 64804
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#include <cstdint>

using namespace std;

int main() {
    int64_t x;
    scanf("%lld", &x);

    int64_t res=x/11*2;
    if (x % 11 > 6) {
        res += 2;
    } else if (x % 11 > 0) {
        ++res;
    }

    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    string ans = "Impossible";
    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
        ans = "Possible";
    cout << ans << endl;
}


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;
  stack<int> s;
  queue<int> q;
  bool a[10000];
  rep(i,10000){
    a[i]=true;
    int tmp=i;
    while(tmp){
      s.push(tmp%10);
      q.push(tmp%10);
      tmp/=10;
    }
    while(s.size()){
      if(s.top()!=q.front())a[i]=false;
      s.pop();
      q.pop();
    }
  }

  cin>>n;
  rep(i,20000)
    if(a[n-i]){
      cout<<n-i<<endl;
      break;
    }else if(a[n+i]){
      cout<<n+i<<endl;
      break;
    }

}

Measured memory_bytes: 3168
#include <stdio.h>
#include <string.h>

int MakeEqual3Figures(int x, int y, int z)
{
    int countone = 0;
    int counttwo = 0;
    int resultone = 0;

    while (x != z)
    {
        x += 2;
        countone++;
    }

    while (y != z)
    {
        y += 2;
        counttwo++;
    }

    resultone = countone + counttwo;
    return resultone;
}

void OddEvenCheck(int p, int q, int r)
{
    int OddorEvenOne = (q - p) % 2;
    int OddorEvenTwo = (r - q) % 2;

    if (OddorEvenOne == 0 && OddorEvenTwo == 0)
    {
        printf("%d", MakeEqual3Figures(p, q, r));
    }

    else if (OddorEvenOne != 0 && OddorEvenTwo != 0)
    {
        p = p + 1;
        r = r + 1;
        printf("%d", MakeEqual3Figures(p, q, r) + 1);
    }

    else if (OddorEvenOne == 0 && OddorEvenTwo != 0)
    {
        p = p + 1;
        q = q + 1;
        printf("%d", MakeEqual3Figures(p, q, r) + 1);
    }

    else if (OddorEvenOne != 0 && OddorEvenTwo == 0)
    {
        q = q + 1;
        r = r + 1;
        printf("%d", MakeEqual3Figures(p, q, r) + 1);
    }
}

void Compare3Figures(int a, int b, int c)
{
    if (b < a && a < c)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }

    else if (b < a && c < b)
    {
        int tmptwo = a;
        a = c;
        c = tmptwo;
    }

    else if (a < b && c < b && a < c)
    {
        int tmpthree = b;
        b = c;
        c = tmpthree;
    }

    else if (a <= b && c <= a)
    {
        int tmpfour = a;
        a = c;
        c = b;
        b = tmpfour;
    }

    else if (b <= a && b <= c && c <= a)
    {
        int tmpfive = a;
        a = b;
        b = c;
        c = tmpfive;
    }

    else if (a == c && a < b)
    {
        int tmpsix = b;
        b = c;
        c = tmpsix;
    }

    OddEvenCheck(a, b, c);
}

int main(int argc, char *argv[])
{

    int A = 0;
    int B = 0;
    int C = 0;

    do
    {
        scanf("%d", &A);
    } while (A < 0 || 50 < A);

    do
    {
        scanf("%d", &B);
    } while (B < 0 || 50 < B);

    do
    {
        scanf("%d", &C);
    } while (C < 0 || 50 < C);

    Compare3Figures(A, B, C);

    printf("\n");
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)

int main(){
    ll n;
    cin>>n;
    ll ans = 1e12;
    for(ll i=1;i*i<=n;i++){
        if(n % i == 0){
            ans = min(ans, i + n/i - 2);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
from collections import Counter
def main():
    K = int(input())
    S = [7] * K
    T = [0] * len(S)

    if K == 7 or K == 1:
        print(1)
        return
    
    if K % 2 == 0 or K % 5 == 0:
        print(-1)
        return
    
    P = K
    T[0] = S[0] % P
    power = 1

    ans = -1
    for i in range(1, len(S)):
        power *= 10
        power %= P
        T[i] = T[i-1] + power * S[i]
        T[i] %= P

        if T[i] == 0:
            ans = i + 1
            break

    # print(T)
    # counter = Counter(T)
    # ans = sum(x * (x - 1) // 2 for x in counter.values()) + counter[0]
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 56540
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <math.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <map>
//#include <unordered_map>
using namespace std;
const int Size=1024;
const int mod2=998244353;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
//std::ios::sync_with_stdio(false);
#define LINF 0x3f3f3f3f3f3f3f3f
typedef long long ll;
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lson  p<<1
#define rson  p<<1|1
#define pb  push_back
#define pii pair<int,int>
#define pII pair<int,pii>
#define pll pair<ll,ll>
#define se second
#define fi first
/*    */

const int maxn=1e6+15;
const int base=307;

map<string,int>mp;
string a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    int ans=0;
    for(int i=1;n>=i;i++){
        cin>>a[i];
        mp[a[i]]++;
        ans=max(ans,mp[a[i]]);
    }
    sort(a+1,a+n+1);
    for(int i=1;n>=i;i++){
        if(mp[a[i]]==ans){
            cout<<a[i]<<endl;
            mp[a[i]]=-1;
        }
    }
    return 0;
}



Measured memory_bytes: 34560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double a,b;
    long x=1000000,i=1,flag=0;
    cin>>a>>b;
    while(x--)
    {
        double m=floor(i*0.08);
        double n=floor(i*0.1);
        if(m==a&&n==b)
            {flag=1;break;}
            i++;
    }
    if(flag==0)
        cout<<"-1"<<endl;
    else
        cout<<i<<endl;
}


Measured memory_bytes: 256
N = int(input())
button = [int(input()) for _ in range(N)]

cnt = 0
now = 0
while 1:
    n = button[now]
    cnt += 1
    if n==2:
        break
    if cnt>N+2:
        cnt = -1
        break
    now = n-1
print(cnt)
    
    

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

typedef long long ll;
const int mod = 1e9 + 7;

ll H, A;

int main() {
    cin >> H >> A;

    cout << ceil((double)H / A) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    char S[4]={};
    char value;
    scanf("%s",S);
    
    value=S[0];
    for (int i=1; i<4; i++) {
        if (value==S[i]) {
            printf("Bad");
            return 0;
        }else{
            value=S[i];
        }
    }

    printf("Good");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    if(c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }    
  }
  int top() {
    return s[0];
  }
  int right(){
    return s[2];
  }
  int left(){
    return s[3];
  }
  int front(){
    return s[1];
  }
};
bool same(Dice a,Dice b){
  for(int i=0;i<6;i++) if(a.s[i]!=b.s[i]) return false;
  return true;
}
int main(){
  Dice d[2];
  for(int j=0;j<2;j++) 
    for(int i=0;i<6;i++)
      cin >> d[j].s[i];
  bool f=false;
  
  
  for(int i=0;i<4;i++){
    d[1].roll('R');
    for(int j=0;j<4;j++){
      d[1].roll('N');
      if(same(d[0],d[1])) f=true;
    }
  }
  d[1].roll('E');
  for(int j=0;j<4;j++){
    d[1].roll('N');
    if(same(d[0],d[1])) f=true;
  }

  d[1].roll('W');
  d[1].roll('W');
  for(int j=0;j<4;j++){
    d[1].roll('N');
    if(same(d[0],d[1])) f=true;
  }
  
  cout << (f?"Yes":"No") << endl;
  return 0;
}



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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N, K;
	
	cin >> N >> K;
	
	vector<int> h(N);
	
	rep(i, N)
		cin >> h[i];
		
	sort(h.begin(), h.end());
	
	int ans = 1000000000;
	
	for(int i = 0; i <= N - K; i++)
		ans = min(h[i + K - 1] - h[i], ans);
	
	cout << ans << endl;
	
	return 0;
}

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

int n;
int T[1024];
int E[1024];

int main() {
  for(;;) {
    scanf("%d", &n);
    if( n == 0 ) break;
    for(int i = 0; i < n; ++i) {
      scanf("%d", &E[i]);
    }
    double bH = 1e10;
    int bS, bA, bC; 
    for(int S = 0; S < 16; ++S) {
      for(int A = 0; A < 16; ++A) {
        for(int C = 0; C < 16; ++C) {
          for(int i = 0; i < 256; ++i) T[i] = 0;
          int R = S;
          double H = 0.0;
          for(int k = 0; k < n; ++k) {
            R = (A * R + C) % 256;
            int t = (E[k] + R) % 256;
            T[t] += 1;
          }
          for(int k = 0; k < 256; ++k) {
            if( T[k] == 0 ) continue;
            double t = (double)T[k] / n;
            H -= t * log(t);
          }
          if( bH - H > 0.00000000001 ) {
            bH = H;
            bS = S;
            bA = A;
            bC = C;
          }
        }
      }
    }
    printf("%d %d %d\n", bS, bA, bC);
  }            
  
  return 0;
}

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

typedef long long ll;
typedef pair<int,int> p;

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

string S;
int main(){
    ios::sync_with_stdio(false);
    cin >> S;
    int n = S.size();
    ll TS = n;
    REP(i, n-1) {
        if (S[i] != S[i+1])
            TS = min(TS, max(i+1, n - (i+1)));
    }
    cout << TS << endl;
    return 0;
}


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

using namespace std;

constexpr int64_t mod = INT64_C(1000000007);

int64_t solve(int maxColor, const std::vector<int>& colors) {
  int const n = (int const)colors.size();
  if (n <= 1) {
    return 1;
  }
  std::vector<int64_t> dp(n + 1, 0);
  std::vector<int64_t> colorDp(maxColor + 1, 0);
  dp[0] = 1;
  for (int i = 0; i < n; ++i) {
    int const color = colors[i];
    dp[i + 1] += dp[i];
    dp[i + 1] %= mod;
    dp[i + 1] += colorDp[color];
    dp[i + 1] %= mod;
    colorDp[color] = dp[i + 1];
  }
  return dp[n];
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n;
  std::cin >> n;
  std::vector<int> colors;
  colors.reserve(n);
  int maxColor = INT_MIN;
  for (int i = 0; i < n; ++i) {
    int color;
    std::cin >> color;
    color--;
    if (!colors.empty() && color == colors.back()) {
      continue;
    }
    colors.push_back(color);
    maxColor = std::max(color, maxColor);
  }
  std::cout << solve(maxColor, colors) << std::endl;
  return 0;
}


Measured memory_bytes: 4224
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */

    //#pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(int i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(int i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(int i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 200500;

    void solve() {
      ll n;
      cin >> n;
      ll a[n], gcdf[n], gcdb[n];
      rep(i, n) cin >> a[i];
      if(n == 1) {
          cout << a[0] << endl;
          return;
      }
      ll g = 0;
      rep(i, n) g = __gcd(g, a[i]), gcdf[i] = g;
      g = 0;
      repD(i, n-1 , 0) g = __gcd(g, a[i]), gcdb[i] = g;
      ll ans = max(gcdf[n-2], gcdb[1]);
      repA(i, 1, n-2) ans = max(ans, __gcd(gcdf[i-1], gcdb[i+1]));
      cout << ans << endl;
    }

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      //te
      solve();
      return 0;
    }       

Measured memory_bytes: 2560
#include<bits/stdc++.h>
const int N=10;
using namespace std;
char s[N];
int main()
{
	scanf("%s",s);
	int len=strlen(s);
	if(len<=1)
	{
		printf("No\n");
		return 0;
	}
	int flag=0;
	for(int i=0;i<len-1;++i)
	{
		if(s[i]=='A'&&s[i+1]=='C') flag=1;
	}
    if(flag) printf("Yes\n");
    else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
pub mod contest {
    pub mod input {
        use std::io;
        use std::str::FromStr;
        use std::fmt::Debug;

        pub fn read_one<F>() -> F
        where F: FromStr, <F as FromStr>::Err: Debug {
            let mut input = String::new();
            io::stdin().read_line(&mut input).unwrap();
            input.trim().parse().unwrap()
        }

        pub fn read_line() -> String {
            let mut input = String::new();
            io::stdin().read_line(&mut input).unwrap();
            input
        }

        pub fn read_words<F>() -> Vec<F>
        where F: FromStr, <F as FromStr>::Err: Debug {
            let mut input = String::new();
            io::stdin().read_line(&mut input).unwrap();
            input
                .split_whitespace()
                .map(|i| i.parse().unwrap())
                .collect()
        }

        pub fn read_matrix<F>(num_lines: usize) -> Vec<Vec<F>>
        where F: FromStr, <F as FromStr>::Err: Debug {
            (0..num_lines).map(|_| read_words()).collect()
        }

        // 所有権的な問題で SplitWhitespace を直接持てないので妥協
        // まあ、一行のデータの数なんてそんなに多くないだろうし
        pub struct WordsReader {
            words: Vec<String>,
            cur: usize,
        }

        impl WordsReader {
            pub fn new() -> Self {
                let mut input = String::new();
                io::stdin().read_line(&mut input).unwrap();
                WordsReader {
                    words: input.split_whitespace().map(|i| i.to_owned()).collect(),
                    cur: 0,
                }
            }

            pub fn next<F>(&mut self) -> F
            where F: FromStr, <F as FromStr>::Err: Debug {
                let v: F = self.words[self.cur].parse().unwrap();
                self.cur += 1;
                v
            }
        }
    }
}

fn gcd(x: i64, y: i64) -> i64 {
    if x == 0 {
        return y;
    } else {
        return gcd(y % x, x);
    }
}

fn lcm(x: i64, y: i64) -> i64 {
    return (x * y) / gcd(x, y);
}


fn count_multiples(a: i64, b: i64, x: i64) -> i64 {
    let q1 = a / x;
    let r1 = a % x;
    let q2 = b / x;
    if r1 == 0 {
        q2 - q1 + 1
    } else {
        q2 - q1
    }
}

fn multiples_of_two(a: i64, b: i64, c: i64, d: i64) -> i64 {
    let x = count_multiples(a, b, c);
    let y = count_multiples(a, b, d);
    let z = count_multiples(a, b, lcm(c, d));
    // println!("x = {}, y = {}, z = {}, lcm = {}", x, y, z, lcm(c, d));
    x + y - z
}

fn solve(a: i64, b: i64, c: i64, d: i64) -> i64 {
    let cnt = multiples_of_two(a, b, c, d);
    let total = b - a + 1;
    total - cnt
}

fn main() {
    let mut wr = contest::input::WordsReader::new();
    let a: i64 = wr.next();
    let b: i64 = wr.next();
    let c: i64 = wr.next();
    let d: i64 = wr.next();
    println!("{}", solve(a, b, c, d));
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int inf = 1e9+7;
const int N = 1e6+9;

void solve() {
    int a, b, n;
    string s;
    cin>>s;
    char ch=s.back();
    if(ch=='3') cout<<"bon";
    else if(ch=='0' || ch=='1' || ch=='6' || ch=='8') cout<<"pon";
    else cout<<"hon";
}
int main() {
    ios_base::sync_with_stdio(0);
    int T=1 ,cas=0;
    while(T--) {
        solve();
    }
    return 0;
}

// ll, reset, 1, bottom

Measured memory_bytes: 3476
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
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; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<58;
 
int main() {
	ll n, c, k;
	ll ans = 0;
	ll bcount;
	cin >> n >> c >> k;
	vector<ll> A(n);
	rep(i, n) {
		cin >> A[i];
	}
	sort(all(A));
	rep(i, n) {
		bcount = 0;
		ll top = A[i];
		while (A[i + 1] - top <= k) {
			++bcount;
			if (bcount == c) {
				++ans;
				break;
			}
          	++i;
		}
		if (bcount == c) {
			bcount = 0;
			continue;
		}
		++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;

int main() {
	long long X;
	cin >> X;
	for (long long A = 0; A <= 1000; A++)
	{
		for (long long B = 0; B <= 1000; B++)
		{
			if (pow(A, 5) - pow(B, 5) == X)
			{
				cout << A << " " << B << endl;
				return 0;
			}
			else if (pow(A, 5) + pow(B, 5) == X)
			{
				cout << A << " " << (-1)*B << endl;
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 4028
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;


void solve(){
    int n, m;
    cin >> n >> m;
    vector <pii> students(n);
    for(int i = 0; i < n; i++){
        cin >> students[i].first >> students[i].second;
    }
    vector <pii> checkpoint(m);
    for(int i = 0; i < m; i++){
        cin >> checkpoint[i].first >> checkpoint[i].second;
    }
    vi ans;
    for(auto &student : students){
        int ab = 2e9 + 2227;
        int idx = -1;
        int k = 1;
        for(auto &i : checkpoint){
            int tmp = ab;
            ab = min(abs(student.first - i.first) + abs(student.second - i.second), ab);
            if(tmp != ab) idx = k;
            k++;
        }
        ans.push_back(idx);
    }
    for(auto &i : ans) cout << i << endl;
}
int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int t;
    cin >> t;
    rep(i, t) {
        ll first, buy, check, add;
        cin >> first >> buy >> check >> add;
        // cout << first << " " << buy << " " << check << " " << add;
        bool f = true;
        if(min(first, add) < buy) f = false;
        else if(check >= buy) f = true;    // always true
        else {
            ll g = __gcd(buy, add);
            if(buy-g+(first%g) > check) f = false;
        }
        cout << (f?"Yes":"No") << '\n';
    }
    return 0;
}

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

#define rep1(i, a, n) for (int i = a; i < n; i++)
#define rep2(i, a, n) for (int i = n; i >= a; i--)
#define asc(v) sort(v.begin(), v.end())
#define desc(v) sort(v.begin(), v.end(), greater<int>())

using namespace std;

int main() {
  int C[3][3];
  rep1(i, 0, 3) {
    rep1(j, 0, 3) { cin >> C[i][j]; }
  }

  string ans = "Yes";
  if ((C[0][1] - C[0][0]) != (C[1][1] - C[1][0])) ans = "No";
  if ((C[0][2] - C[0][1]) != (C[1][2] - C[1][1])) ans = "No";
  if ((C[1][1] - C[1][0]) != (C[2][1] - C[2][0])) ans = "No";
  if ((C[1][2] - C[1][1]) != (C[2][2] - C[2][1])) ans = "No";
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int N;
    cin>>N;
    cout<<(N+N*N+N*N*N)<<endl;
}

Measured memory_bytes: 3632
n = int(input())
flowers = list(map(int,("0 " + input()).split(' ')))
diff = []
ans = 0
for i in range(1,n + 1):
    diff.append(flowers[i] - flowers[i - 1])
# print(diff)
for d in diff:
    if d > 0:
        ans += d
print(ans)


Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
int a[200005],n,b[200005];
map<int,int>__rank;
int main(){
	//freopen("c.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	for(int i=n;i>=1;--i){
		__rank[b[i]]=i;
	}
	for(int i=1;i<=n;++i){
		printf("%d\n",__rank[a[i]]<=n/2 ? b[n/2+1] : b[n/2]);
	}
	return 0;
}

Measured memory_bytes: 12928
w, h , n = gets.split.map(&:to_i)

to = h
bo = 0
ri = w
le = 0

n.times {
  x, y, a = gets.split.map(&:to_i)
  if a == 1 && le < x
    le = x
  elsif a == 2 && ri > x
    ri = x
  elsif a == 3 && y > bo
    bo = y
  elsif a  == 4 && y < to
    to = y
  end
}

puts [0, (ri-le)].max * [0, (to-bo)].max


Measured memory_bytes: 1788
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std ;

#define fi( a , b , c ) for ( int a = b ; a <= c ; a++ )
#define fo( a , b , c ) for ( int a = b ; a >= c ; a-- )
#define long long long

struct AR{
     long x , y , z ;
};

const int N = 2e3+1 ;
const long oo = 1e18 ;

int n , m ;
long ans ;
int t[3] ;
AR a[N] , b[N] ;

bool Cmp( AR a , AR b ){
     return a.x+a.y+a.z > b.x+b.y+b.z ;
}

void Solve(){
     fi( i , 1 , n ) a[i] = b[i] ;
     if ( t[0] )
          fi( i , 1 , n ) a[i].x = -b[i].x ;
     if ( t[1] )
          fi( i , 1 , n ) a[i].y = -b[i].y ;
     if ( t[2] )
          fi( i , 1 , n ) a[i].z = -b[i].z ;

     sort(a+1,a+1+n,Cmp) ;

     long s = 0 ;
     fi( i , 1 , m )
          s += a[i].x+a[i].y+a[i].z ;

     ans = max( ans , s ) ;
}

void Try( int x ){
     fi( i , 0 , 1 ){
          t[x] = i ;
          if ( x == 2 )
               Solve() ;
          else
               Try(x+1) ;
          t[x] = 0 ;
     }
}

int main(){

     cin >> n >> m ;
     fi( i , 1 , n ){
          cin >> a[i].x >> a[i].y >> a[i].z ;
          b[i] = a[i] ;
     }

     ans = -oo ;
     Try(0) ;

     cout << ans ;

}


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

int main(){
  string s;
  cin >> s;
  int L=s.size();
  int A=0, Z=L;
  for(int i=0; i<L; i++){
    if(s.at(i)=='A'){
      A=i;
      break;
    }
  }
  for(int i=0; i<L; i++){
    if(s.at(L-i-1)=='Z'){
      Z=L-i-1;
      break;
    }
  }
  cout << Z-A+1 << endl;
}


Measured memory_bytes: 640