akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BOneClue solver = new BOneClue();
        solver.solve(1, in, out);
        out.close();
    }

    static class BOneClue {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int k = in.scanInt();
            int x = in.scanInt();
            for (int i = Math.max(-1000000, x - k + 1); i <= Math.min(x + k - 1, 1000000); i++) {
                out.print(i + " ");
            }
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



Measured memory_bytes: 23508
using System;
using System.Linq;
 
class Program
{
	static void Main()
    {
		long[] N = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
		long ans = 0;
      	long x = N[2];
      
        if(N[2]>=N[1]){
          	x = N[1]-1;
        }
      
       	ans = N[0]*x/N[1];
      	Console.WriteLine(ans);
    }
}

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

#define ls rt<<1
#define rs rt<<1|1
typedef pair<int,int> pii;
const int maxn = 1e5 + 10;
const int maxm = 1e6 + 10 ;
const int inf=0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
const int st=(1<<20)-1;
const int mod = 1e9+7;
const double eps = 1e-5;
const int vec[2][2]={1,0,0,1};

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}

inline ll sv(ll x) {
    ll ans=1;
    for(int i=1;i<=x;i++) {
        ans*=i;
        ans%=mod;
    }
    return ans;
}
int main() {
#ifdef LOCAL
    freopen("input.txt","r",stdin);
#endif // LOCAL
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    n=read(); m=read();
    ll ans=0;
    if(n==m) {
        ans=sv(n)*sv(m)%mod;
        ans<<=1;
        ans%=mod;
    }
    else if(abs(n-m)==1) {
        ans=sv(n)*sv(m)%mod;
    }
    else ans=0;
    cout<<ans;
    return 0;
}
//校园网真tm卡


Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	sc.NextInt()
	A := sc.NextIntArray()
	mp := map[int]int{}
	for _, v := range A {
		mp[v]++
	}

	total := 0
	for _, v := range mp {
		total += v * (v - 1) / 2
	}
	for _, v := range A {
		k := mp[v]
		fmt.Println(total - (k*(k-1))/2 + ((k - 1) * (k - 2) / 2))
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 17408
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;
#define two(X) (1<<(X))
#define twoL(X) (((int64)(1))<<(X))
#define contain(S,X) (((S)&two(X))!=0)
#define containL(S,X) (((S)&twoL(X))!=0)
const double pi=acos(-1.0);
const double eps=1e-11;
template<class T> inline void ckmin(T &a,T b){if(b<a) a=b;}
template<class T> inline void ckmax(T &a,T b){if(b>a) a=b;}
template<class T> inline T sqr(T x){return x*x;}
typedef pair<int,int> ipair;
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
#define ALL(A) A.begin(),A.end()

int main()
{
#ifdef _MSC_VER
	freopen("input.txt","r",stdin);
#endif
	std::ios::sync_with_stdio(false);
	int64 c4,c2,c1,y;
	cin>>c4>>c2>>c1>>y;
	int64 x=min(c1,min(c2*2,c4*4));
	int64 n;
	cin>>n;
	int64 ret=min(n*x,n/2*y+n%2*x);
	cout<<ret<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, ans = 0;
    double d, x, y;
    cin >> n >> d;
    while(n--) {
        cin >> x >> y;
        if (hypot(x, y) <= d)
            ans += 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
using namespace std;

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    int cnt_min = 0;
    for ( int i = 0 ; i < m ; i++ ){
        int a;
        cin >> a;
        if ( a < x ) cnt_min++;
    }
    int cnt_max = m-cnt_min;
    if ( cnt_min >= cnt_max ) cout << cnt_max << endl;
    else cout << cnt_min << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,p;cin >> n >> m >> p;
    vector<pair<pair<int,int>,int>> g(m);
    vector<vector<int>> h(n);
    for(int i=0;i<m;i++){
        int a,b,c;cin >> a >> b >> c;
        a--,b--,c-=p;
        h[b].push_back(a);
        g[i]={{a,b},-c};
    }
    vector<bool> vis(n);
    vis[n-1]=true;
    stack<int> st;
    st.push(n-1);
    while(!st.empty()){
        int p=st.top();
        st.pop();
        for(int x:h[p]){
            if(!vis[x]){
                vis[x]=true;
                st.push(x);
            }
        }
    }
    vector<ll> d(n,INF);
    d[0]=0;
    for(int t=0;t<2*n;t++){
        for(int i=0;i<m;i++){
            ll u=g[i].first.first,v=g[i].first.second,w=g[i].second;
            if(d[u]==INF){
                continue;
            }
            if(chmin(d[v],d[u]+w)){
                if(t>=n&&vis[v]){
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }
    cout << max(0LL,-d[n-1]) << endl;
}

Measured memory_bytes: 512
import Control.Monad.State
import Data.Char

main = do
  s <- getLine
  k <- readLn :: IO Int


  putStrLn $ (`evalState` k) $ do
    let len = length s
    forM (zip [1..] s) $ \(i,c) -> do
      k' <- get
      if i == len && k' >= 0 then
        return $ chr ((ord c - ord 'a' + k') `mod` 26 + ord 'a')
        else
        if (ord 'z'+1) - ord c <= k' && c /= 'a' then do
          put $ k' - ((ord 'z'+1) - ord c)
          return $ 'a'
        else
          return c


Measured memory_bytes: 7548
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

const int N=200100;
const lint inf=1e18;
const lint MOD=1.0e9+7;

lint powerMod(long x, long exponent) {
  long prod = 1;
  for (int i = 63; i >= 0; --i) {
    prod = (prod * prod) % MOD;
    if ((exponent & 1L << i) != 0) {
      prod = (prod * x) % MOD;
    }
  }
  return prod;
}


lint fact[N];
lint invfact[N];
void initialize() {
  fact[0] = invfact[0] = 1;
  for (int i = 1; i < N; ++i)
    fact[i] = (i * fact[i - 1]) % MOD;
  invfact[N-1]=powerMod(fact[N-1],MOD-2);
  for(int i=N-2;i>=0;--i)
    invfact[i] = invfact[i+1]*(i+1)%MOD;
}

int n;
lint x,y;
int c[N];
lint w[N];
vector<pair<lint, int> > mi[N];
bool inert[N];
lint almi=inf;


int main(){
  initialize();
  cin>>n>>x>>y;
  rep(i,n)cin>>c[i]>>w[i];
  rep(i,n)c[i]--;
  rep(i,n){
    mi[c[i]].push_back(make_pair(w[i],i));
    almi=min(almi,w[i]);
  }
  vector<pii> srt;
  rep(i,n){
    srt.push_back(pii(w[i],i));
  }
  sort(srt.begin(),srt.end());
  lint sec=inf;
  rep(i,n){
    if(srt[i].second==srt[0].second)continue;
    sec=srt[i].first;
    break;
  }
  rep(i,n)sort(mi[i].begin(),mi[i].end());
  rep(i,n){
    int col=c[i];
    if(w[i]>x-mi[col][0].first){
      int miind=mi[col][0].second;
      lint other_min=srt[0].second==miind?
	sec:srt[0].first;
      inert[i]=w[i]>y-other_min;
    }else{
      int miind=mi[col][0].second;
      lint other_min=srt[0].second==miind?
	sec:srt[0].first;
      inert[i]=w[miind]>y-other_min;
    }
  }
  vi cnt(n);
  int total=0;
  rep(i,n){
    if(inert[i])continue;
    cnt[c[i]]++;
    total++;
  }
  lint ans=fact[total];
  rep(i,n)ans=ans*invfact[cnt[i]]%MOD;
  cout<<ans<<endl;
}


Measured memory_bytes: 19188
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll inf = 1e18+5;
ll n, k, ans, fact[100005], inv[100005], ifact[100005];
const ll mod = 1e9+7;
ll add(ll x, ll y){
	return (x%mod + y%mod + mod)%mod;
}
ll mult(ll x, ll y){
	return (x%mod * y%mod + mod)%mod;
}
ll sub(ll x,ll y){
	return (x%mod - y%mod + mod)%mod;
}
ll nck (ll nn, ll kk ){
	if(nn < kk)return 0;
	if (nn <0 || kk< 0)return 0;
	if (nn ==kk)return 1;
	return(fact[nn]*(ifact[nn-kk] *ifact[kk]%mod)%mod);
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n >> k;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++)cin >> a[i];
	sort(a.begin(), a.end());
	k -= 1;
	//~ vector<ll> pre(n);
	//~ for (ll i = 0; i < n; i++)pre[i] = (i == 0? a[i]: pre[i-1]+a[i]);
	fact[0] =1;
	fact[1] =1;
	inv[1] =1;
	for (ll i = 2; i<= n; i++){
		inv[i] = mod-inv[mod%i]*(mod/i)%mod;
		fact[i] = mult(fact[i-1], i);
	}
	ifact[0] =1,ifact[1] =1;
	for (ll i= 2; i<=n;i++){
		ifact[i] = ifact[i-1] *inv[i] %mod;
	}
	//for each guy, we consider it to be max element, we have to find the number of sets that 
	//can be made this way, and the respective mins of those sets
	for (ll i = k; i < n; i++){
		ll numways = nck(i, k);// i choose k-1
		ans = add(ans, mult(numways, a[i]));
		//~ ans -= pre[infront-1];
	}
	for (ll i = 0; i < n-k; i++){ //for each guy we want to consider it being the min
		ll bigg = n-i-1;
		ll numways = nck(bigg, k); //bigg choose k-1
		ans = sub(ans, mult(numways, a[i]));
	}
	cout << ans;
}


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

int main() {
    
    long long int n;
    cin>>n;
     string s;
     cin>>s;
     if(n%2==0)
     {
         int c=0;
     for(int i=0,j=n/2;i<n/2&&j<n;i++,j++)
     {
         if(s[i]!=s[j])
         {c=1;
         break;}
     }
     if(c)
     cout<<"No\n";
     else
     cout<<"Yes\n";
     }
     else
     cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())

ans = 0
for i in range(1,n + 1):
    double = i
    for j in range(1000):
        if double >= k:
            break
        else:
            double = double << 1
    ans += (1 / n) * ((1 / 2)**j)

print(ans)

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

int main(){
    int n;
    cin>>n;
    int k;
    cin>>k;
    int total=0;
    int arr[n];
    for(int i=0; i<n; i++){
        cin>>arr[i];
    }
    
    sort(arr,arr+n);
    
    for(int i=0; i<k; i++){
        total+=arr[i];
    }
    cout<<total<<endl;
    
    return 0;
}

Measured memory_bytes: 3588
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

struct team{
  int ans,id,p[10],pena;
  bool operator<(const team &a)const{
    if(this->ans == a.ans){
      return this->pena < a.pena;
    }else{
      return this->ans > a.ans;
    }
  }
};

int main(){
  int t,p,r;
  while(cin>>t>>p>>r){
    if(t==0)break;
    team T[t];
    memset(T,0,sizeof(T));
    for(int i=0;i<t;i++)T[i].id=i+1;

    int tid,pid,tm;
    string mes;
    for(int i=0;i<r;i++){
      cin>>tid>>pid>>tm>>mes;
      tid--;pid--;
      if(mes=="CORRECT"){
	T[tid].ans++;
	T[tid].pena+=T[tid].p[pid]*1200 + tm;
      }else{
	T[tid].p[pid]++;
      }
    }
    stable_sort(T,T+t);
    for(int i=0;i<t;i++)
      cout << T[i].id << " " << T[i].ans << " " << T[i].pena << endl;
  }
  return 0;
}

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

using namespace std;

const long long MOD = 1000000007;

// べき乗の余り計算
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) {
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) {
        res += m;
    }
    
    return res;
}


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

    cout << mod(modpow(10, N, MOD) - modpow(9, N, MOD) * 2 + modpow(8, N, MOD), MOD) << endl;
    return 0;
}

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

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

    char s[H][W];
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> s[i][j];
        }
    }

    bool ok = true;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            char m =  s[i][j];
            if (m != '#') continue;
            int mx = j - 1;
            int px = j + 1;
            int my = i - 1;
            int py = i + 1;
            if (!((0 <= mx && s[i][mx] == '#') ||
                (px <= W && s[i][px] == '#') ||
                (0 <= my && s[my][j] == '#') ||
                (py <= H && s[py][j] == '#'))) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = Integer.parseInt(sc.next());
		int W = Integer.parseInt(sc.next());
		int h = Integer.parseInt(sc.next());
		int w = Integer.parseInt(sc.next());
		int[][] arr1 = new int[H][W];
		for(int i=0;i<H;i++) {
			for(int j=0; j<W;j++) {
				arr1[i][j] = 0;
			}
		}
		for(int i=0;i<h;i++) {
			for(int j=0;j<W;j++) {
				arr1[i][j] = 1;
			}
		}
		for(int i=0;i<H;i++) {
			for(int j=0;j<w;j++) {
				arr1[i][j] = 1;
			}
		}
		int count = 0;
		for(int i=0;i<H;i++) {
			for(int j=0; j<W;j++) {
				if(arr1[i][j] == 0)count++;
			}
		}
		System.out.println(count);
	}
}



Measured memory_bytes: 26940
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s.at(0)==s.at(1)||s.at(1)==s.at(2)||s.at(2)==s.at(3)){
    cout<<"Bad"<<endl;
  }
  else{
    cout<<"Good"<<endl;
  }
}


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

int main () {
    string s, t;
    cin >> s;
    cin >> t;
    int count = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) != t.at(i)) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int> a(n + 1);
	for(int i = 0; i < n; i++) cin >> a[i + 1];
	long long sum = 0, res = 0;
	vector<int> stk;
	stk.push_back(0);
	for(int i = 1; i <= n; i++){
		while(a[stk.back()] > a[i]){
			int lst = stk.back(); stk.pop_back();
			sum -= 1ll * (lst - stk.back()) * a[lst];
		}
		sum += 1ll * (i - stk.back()) * a[i];
		stk.push_back(i);
		res += sum;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int n; int k;
    cin>>n>>k;
    vi a(n);
    rep(i,n)cin>>a[i];
    if(n<=k)cout<<1<<endl;
    else {
        int tmp=1;
        int p=k;
        while(p<n){
            tmp++;
            p+=k-1;
        }
    cout<<tmp<<endl;
    }
    return 0;
}




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

typedef long long ll;
const int N = 2000006;



int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n,m;
	cin>>n>>m;
	int cnt = 0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		if(x >= m)cnt++;
	}
	cout<<cnt;
	
	return 0;
}


Measured memory_bytes: 3644
from math import sqrt
from array import array

size = 10000000
s = array('i', range(size+1))
s[1] = 0
sqrtn = int(round(size**0.5))
for i in range(2, sqrtn + 1):
    if s[i]:
        s[i*i: size+1 : i] = array('i', [0] * len(range(i*i, size+1, i)))
primes = list(filter(None, s))

while True:
    a, d, n = map(int, input().split())
    if a == 0: break

    ans = 0
    for p in primes:
        if p-a < 0 : continue
        if (p-a) % d == 0:
            ans = p
            n -= 1
        if n == 0:
            break
    print(ans)

Measured memory_bytes: 104620
import sys
sys.setrecursionlimit(10000)
inp=list(map(len,input().split("T")))
inx,iny=list(map(int,input().split()))
memo={}
def tg(g,n,t):
 g.sort()
 g.reverse()
 def tn(g,n,t):
  if (tuple(g),n,t) in memo:
   return memo[(tuple(g),n,t)]
  if g==[]:
   if n==t:
    return True
   else:
    return False
  if n<t:
   z=tn(g[1:],n+g[0],t)
   memo[(tuple(g),n,t)]=z
   return z
  else:
   z=tn(g[1:],n-g[0],t)
   memo[(tuple(g),n,t)]=z
   return z
 return tn(g,n,t)
 
if tg(inp[1::2],0,iny)and tg(inp[2::2],inp[0],inx):
 print("Yes")
else:
 print("No")
 

Measured memory_bytes: 177452
<?php
$str = "abcdefghijklmnopqrstuvwxyz";
$n = trim(fgets(STDIN));

$name = "";
$i = 0;
while ($n > 0) {
    $name = $str[--$n % 26].$name;
    $n = floor($n / 26);
}
echo $name;

Measured memory_bytes: 16188
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int solve(){
    int l,r,d; cin>>l>>r>>d;
    cout<<r/d-(l-1)/d;
    return 0;
}

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

Measured memory_bytes: 3600
def main():
    a, b, c, x, y = map(int, input().split())
    r = float('inf')
    for piza_c in range(0, max(x, y) * 2 + 1, 2):
        piza_a = max(0, x - piza_c // 2)
        piza_b = max(0, y - piza_c // 2)
        r = min(r, piza_c * c + piza_a * a + piza_b * b)
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 66676
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<ll> > vvll;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
int main() {
	string s;
	cin>>s;
	ll i;
	ll aux[123]={0};ll c=1,d=1;
	fr(i,0,s.length()-1)
	{if(s[i]==s[i+1] && s[i]=='R')
	{
		c++;
	}
	if(s[i]==s[i+1] && s[i]=='S')
	{
		d++;
	}
	}
	if(d!=3)
{	cout<<c;}
else
{
	cout<<0;
}
	return 0;
}


Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {
        static Dictionary<Tuple<long, long>, long> dic = new Dictionary<Tuple<long, long>, long>();


        static void Main(string[] args)
        {

            var nn = ReadLongArr();
//            var aa = ReadLongArr();

            var K = nn[0];
            var X = nn[1];


            var res = 0;

            if( 500 * K >= X)
            {

                Console.WriteLine("Yes");
            } else
            {
                Console.WriteLine("No");
            }



        }

        class SortedMap
        {
            public long[][] elm = new long[100000][];
            public int index = 0;

            public SortedMap(long[] aa)
            {
                Array.Sort(aa);

                long tmp = 0;
                for(int i=0; i<aa.Length; i++)
                {
                    if(tmp != aa[i])
                    {
                        tmp = aa[i];
                        elm[index] = new long[2];
                        elm[index][0] = aa[i];
                        elm[index][1] = 1;
                        index++;
                    } else
                    {
                        elm[index][1]++;
                    }

                }

            }
        }


        class BitArr
        {
            public bool[] bitArr = new bool[64];

            public BitArr(long l)
            {
                var ll = l;
                for(int i=0; i<64; i++)
                {
                    bitArr[i] = (ll % 2) == 1;
                    ll = ll / 2;
                }
            }
        }

        public static int Digit(long num)
        {
            // Mathf.Log10(0)はNegativeInfinityを返すため、別途処理する。
            return (num == 0) ? 1 : ((int)Math.Log10(num) + 1);
        }

        public static long nCm(long n, long m, long mod)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            var a = n * nCm(n - 1, m - 1, mod) / m;
            //            return a % mod;
            return a;
            //return a % 1000000007;
        }

        private static string ReadString()
        {
            return Console.ReadLine();
        }
        private static string[] ReadStringArr()
        {
            return Console.ReadLine().Split(' ');
        }
        private static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadLongArr()
        {
            string[] s = ReadStringArr();
            long[] l = new long[s.Length];
            for(int i=0; i<l.Length; i++)
            {
                l[i] = long.Parse(s[i]);
            }

            return l;
        }
    }

}


Measured memory_bytes: 11092
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.nextInt();
            var b = cin.nextInt();

            for (int i = 0; i < 100000; i++)
            {
                var y = 100 * i;
                var aa = (i * 8) /100;
                var bb = (i * 10)/100;
                if(aa == a && bb == b)
                {
                    Console.WriteLine(i);
                    return;
                }
            }

            Console.WriteLine(-1);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13140
program answer
  implicit none
  integer :: A,B,C
  read(*,*) A, B, C
  if(A==B.and.B/=C) then
     write(*,*) 'Yes'
  else if(A==C.and.A/=B) then
     write(*,*) 'Yes'
  else if(B==C.and.A/=B) then
     write(*,*) 'Yes'
  else
     write(*,*) 'No'
  end if

  stop
 end program answer

Measured memory_bytes: 2852
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)










int main(){
    ll n, d;
    cin >> n >> d;
    vector<vector<double>> x(n, vector<double>(d));
    REP(i, n){
        REP(j, d){
            cin >> x[i][j];
        }
    }
    ll ans = 0;
    REP(i, n - 1){
        for(ll j = i + 1; j < n; j++){
            double dist = 0.0;
            REP(k, d){
                dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            dist = sqrt(dist);
            if(floor(dist) == ceil(dist)){
                ans++;
            }
        }
    }
    cout << ans << endl;
}


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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	string s, t;
	cin >> s >> t;

	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());

	bool ok = s.length() < t.length();
	for (int i = 0, j = 0; i < s.length() && j < t.length(); i++, j++) {
		if (s[i] == t[j]) continue;
		if (s[i] < t[j]) {
			ok = true;
			break;
		} else if (s[i] > t[j]) {
			ok = false;
			break;
		}
	}

	// cout << s << " " << t << " \n";

	cout << (ok ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
#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;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define ceil(a,b) (a+b-1)/b
#define endl "\n"
const int N=100005;
const int inf=1e18;
const double eps=1e-9;

#define oa(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define o1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define o2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define o3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define o4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

int pow(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
int pow1(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
            res=res*a;
            res%=mod;
        }
        a=a*a;
        a%+mod;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
    cin>>n;
    int a[n];
    int xo=0;
    for(int x=0;x<n;x++){
        cin>>a[x];
        xo=xo^a[x];
    }
    for(int x=0;x<n;x++){
        cout<<(xo^a[x])<<" ";
    }









	
return 0;
}


Measured memory_bytes: 5168
using System.Linq;
using System;

public class hello
{
    public static void Main()
    {
        //前後の空白を除き、int型で読み込む
        var n = int.Parse(Console.ReadLine().Trim());
        
        //ｎ個の配列arrを作成
        var arr = new long[n];
        
        //前後の空白を除き、空白を区切りとして、文字列lineとして順番に読み込む
        string[] line = Console.ReadLine().Trim().Split(' ');

        //配列arrにint型に変換した配列lineを、一個ずつ代入
        for (int i = 0; i < n; i++) arr[i] = int.Parse(line[i]);

        //最小、最大、合計を出力
        Console.WriteLine("{0} {1} {2}", arr.Min(), arr.Max(), arr.Sum());

    }
}


Measured memory_bytes: 18308
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<double, double >pd;
typedef pair<string, string> sP;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 5e14;
const double eps = 1e-10;
const double PI = acos(-1);
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,-1,-1,0,0,1,1,1 }, ty[8] = { -1,0,1,-1,1,-1,0,1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

ll n, a, b, p[200010];

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

	ll l = -1, r = INF, mid;
	while (r - l > 1) {
		mid = (r + l) / 2;
		ll sum = 0;
		for (int i = 0;i < n;i++) {
			sum += max(0LL, (p[i] - mid * b + a - b - 1) / (a - b));
		}
		if (sum > mid)l = mid;
		else r = mid;
	}
	cout << r << endl;
	return 0;
}


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

typedef long long ll;
const ll MOD = 1e9+7;
const int N = 1e5+5;

int n;
ll a[N],s,p;

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

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

    for(int i=2;i<=n;i+=2){
        p+=2LL*a[i];
    }

    cout<<s-p<<" ";

    ll pr=s-p;
    for(int i=2;i<=n;i++){
        cout<<2LL*a[i-1]-pr<<" ";
        pr=2LL*a[i-1]-pr;
    }

    return 0;
}


Measured memory_bytes: 2176
import itertools
import math
L=0
M=0
N=int(input())
p=[list(map(int,input().split())) for i in range(N)]
for seq in itertools.permutations(range(N),N):
    tmp=0
    for i in range(N-1):
        x1,y1=p[seq[i]]
        x2,y2=p[seq[i+1]]
        tmp+=math.sqrt((x1-x2)**2+(y1-y2)**2)
    L+=tmp
    M+=1
print(L/M)


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

int main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << H * W - h * W - w * H + h * w << endl;

  return 0;  

}

Measured memory_bytes: 256
#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 (1e9)
#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;
    string s;
    cin >> n >> s;
    s.erase(unique(all(s)), s.end());
    cout << s.size() << endl;
    return 0;
}



Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int a,b;
int f(int n){
	int sum=1;
	for(;n;n/=10)sum*=10;
	return sum;
}
int main(){
	cin>>a>>b;
	b+=a*f(b);
	a=((int)sqrt(double(b)));
	puts(a*a==b?"Yes":"No");
	return 0;
}


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

int main() {
    string s;
    cin>>s;
    int add=0;
    if(s[0]=='o')add+=100;
    if(s[1]=='o')add+=100;
    if(s[2]=='o')add+=100;
    cout<<700+add<<endl;
    return 0;
    }

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)


struct Problem {

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

	void Solve() {
		/*
		UL N; cin >> N;
		vector<ULL> A(N); rep(i, N) cin >> A[i];
		ULL G = A[0];
		rep(i, N) G = gcd(G, A[i]);
		rep(i, N) A[i] /= G;
		//vector<ULL> I(G + 1); I[1] = 1;
		//for (UL i = 2; i <= G; i++) I[i] = M - (M / i * I[M % i] % M);
		vector<ULL> Pl(N + 1), Pr(N + 1); Pl[0] = Pr[0] = 1;
		for (UL i = 1; i <= N; i++) {
			Pl[i] = Pl[i - 1] * A[i - 1] % M;
			Pr[i] = Pr[i - 1] * A[N - i] % M;
		}
		ULL Sans = 0;
		rep(i, N) {
			ULL ans = Pl[i] * Pr[N - i - 1] % M;
			//ans = ans * I[G] % M;
			Sans += ans;
		}
		cout << (Sans % M) << endl;
		*/
		UL N; cin >> N;

		vector<vector<pair<UL, UL>>> E(N);
		rep(i, N - 1) {
			UL a, b; cin >> a >> b;
			a--; b--;
			E[a].push_back({ b, i });
			E[b].push_back({ a, i });
		}
		UL M; cin >> M;
		UL mask[50] = {};
		rep(i, M) {
			UL m = 1 << i;
			vector<pair<UL, UL>> parent;
			parent.assign(N, { 100, 100 });
			stack<UL> q;
			UL u, v; cin >> u >> v; u--; v--;
			q.push(u);
			while (q.size()) {
				UL p = q.top(); q.pop();
				for (auto nx : E[p]) {
					if (nx.first == parent[p].first) continue;
					q.push(nx.first);
					parent[nx.first] = { p, nx.second };
				}
			}
			UL p = v;
			while (p != u) {
				auto nx = parent[p];
				mask[nx.second] |= m;
				p = nx.first;
			}
		}
		vector<array<ULL, 50>> dp(1 << M);
		dp[0][0] = 1;
		rep(i, N - 1) {
			rep(j, 1 << M) {
				dp[j][i + 1] += dp[j][i];
				dp[j | mask[i]][i + 1] += dp[j][i];
			}
		}
		cout << dp[(1 << M) - 1][N - 1];
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 409984
import math

if __name__ == "__main__":
	a, b, x = map(float, input().split())
	if x / a >= a * b / 2:
		t = 2.0 * (b - x / (a * a)) / a
	else:
		t = a * b * b / (2 * x)
	ans = math.degrees(math.atan(t))
	print(ans)

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

int main() {
    int N; cin >> N;
    set<int> A;
    REP(i, 0, N) {
        int a; cin >> a;
        A.insert(a);
    }

    cout << (A.size() % 2 != 0 ? A.size() : A.size() - 1) << endl;

    return 0;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d))
    {
        Yes;
    }
    else
        No;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int l=s.size();
    if(s[l-1]=='s')
    {
        cout<<s<<"es"<<endl;
    }
    else
    {
        cout<<s<<"s"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	static long S;
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		long h = sc.nextInt();
		long w = sc.nextInt();
		long s1,s2,s3;
		long ans = Long.MAX_VALUE;
		S = h*w;
		for(int i = 1; i < h; i++) {//一つの長方形のhについて全探索
			s1 = w*i;
			s2 = w*((h-i)/2);
			ans = Math.min(ans, hikaku(s1,s2));
			s2 = (h-i)*(w/2);
			ans = Math.min(ans, hikaku(s1,s2));
		}
		for(int i = 1; i < w; i++) {
			s1 = h*i;
			s2 = h*((w-i)/2);
			ans = Math.min(ans, hikaku(s1,s2));
			s2 = (w-i)*(h/2);
			ans = Math.min(ans, hikaku(s1,s2));
		}
		System.out.println(ans);
	}
	static long hikaku(long a, long b) {
		long c = S-a-b;
		if(c<=0||a<=0||b<=0) return Long.MAX_VALUE;
		return Math.abs(Math.max(a, Math.max(b, c))-Math.min(a, Math.min(b, c)));
	}
}

Measured memory_bytes: 21972
K,S = map(int, input().split())
# debug
# print([(A,B,S-A-B) for A in range(K+1) for B in range(K+1) if 0 <= S-A-B <= K])
print(sum(1 for A in range(K+1) for B in range(K+1) if 0 <= S-A-B <= K))

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var result = n * 800 - (n / 15) * 200;
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27300
from collections import Counter
n = int(input())
A = list(input().split())
q = int(input())
ansList = [0]*q
d = Counter(A)
Sum = sum(map(int,A))

for i in range(q):
    b,c = input().split()
    Sum -= (int(b)-int(c))*d[b]
    if b in d:
        if c in d:
            d[c] += d.pop(b)
        else:
            d[c] = d.pop(b)
    ansList[i]  +=  Sum

[print(ans) for ans in ansList]

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

class P {
public:
	int x, y;

	P operator - (const P& obj)
	{
		P ret;

		ret.x = x - obj.x;
		ret.y = y - obj.y;

		return ret;
	}

	bool operator == (const P& obj) const
	{
		return x == obj.x&&y == obj.y;
	}

	bool operator != (const P& obj) const
	{
		return !(*this == obj);
	}
};

vector<P> p_rotate(vector<P> p, int num)
{
	vector<P> ret = p;
	unsigned int size = p.size();

	switch (num) {
	case 0:
		break;
	case 1:
		for (unsigned int i = 0; i < size; i++) {
			ret[i].x = -p[i].y;
			ret[i].y = p[i].x;
		}
		break;
	case 2:
		for (unsigned int i = 0; i < size; i++) {
			ret[i].x = -p[i].x;
			ret[i].y = -p[i].y;
		}
		break;
	case 3:
		for (unsigned int i = 0; i < size; i++) {
			ret[i].x = p[i].y;
			ret[i].y = -p[i].x;
		}
		break;
	}

	return ret;
}

bool check(vector<P> p1, vector<P> p2)
{
	bool flag = true;
	unsigned int size = p1.size();

	if (size != p2.size()) {
		flag = false;
	}
	else {
		for (unsigned int i = 1; i < size; i++) {
			P dist1 = p1[i] - p1[i - 1];
			P dist2 = p2[i] - p2[i - 1];

			if (dist1 != dist2) {
				flag = false;
				break;
			}
		}
	}

	return flag;
}

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

		if (n == 0) {
			break;
		}

		vector<vector<P>> line(n + 1);

		for (int i = 0; i <= n; i++) {
			int m;
			cin >> m;

			for (int j = 0; j < m; j++) {
				P temp;
				cin >> temp.x >> temp.y;
				line[i].push_back(temp);
			}
		}

		for (int i = 1; i <= n; i++) {
			bool flag = false;

			for (int j = 0; j < 4; j++) {
				flag = check(line[0], p_rotate(line[i], j));
				if (flag == true) {
					goto End;
				}
			}

			reverse(line[i].begin(), line[i].end());

			for (int j = 0; j < 4; j++) {
				flag = check(line[0], p_rotate(line[i], j));
				if (flag == true) {
					goto End;
				}
			}

		End:

			if (flag == true) {
				cout << i << endl;
			}
		}

		cout << "+++++" << endl;
	}

	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int S = s.size();
  
  int f1 = 0;
  int f2 = 0;
  
  for (int i = 0; i < S; i++) {
    if (i % 2 == 0) {
      if (s.at(i) == '1') {f1++;}
      if (s.at(i) == '0') {f2++;}
    }
    if (i % 2 == 1) {
      if (s.at(i) == '0') {f1++;}
      if (s.at(i) == '1') {f2++;}
    }
  }
  
  cout << min(f1, f2) << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll cnt;
int n;
int a[1000001];
int l;
vector<int> g;

void insertionSort(int a[], int n, int g) {
    for (int i = g; i < n; i++) {
        int v = a[i];
        int j = i - g;
        while (j >= 0 && a[j] > v) {
            a[j + g] = a[j];
            j -= g;
            cnt++;
        }
        a[j + g] = v;
    }
}

void shellSort(int a[], int n) {
    for (int h = 1;;) {
        if (h > n) break;
        g.push_back(h);
        h = 3 * h + 1;
    }

    for (int i = g.size() - 1; i >= 0; i--) {
        insertionSort(a, n, g[i]);
    }
}

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

    cnt = 0;
    shellSort(a, n);

    cout << g.size() << endl;
    for (int i = g.size() - 1; i >= 0; i--) {
        cout << g[i];
        if (i) cout << " ";
    }
    cout << endl << cnt << endl;
    for (int i = 0; i < n; i++) {
        cout << a[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 7024