akhauriyash/Code-Regression huggingface dataset:
//専用ライブラリ
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int cmp(P a,P b){
        if(a.fi!=b.fi)
        return a.fi>b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n;
    cin>>n;
    ll res=0;
    ll rmin=INF,lmax=-INF;
    vector<pair<ll,ll>> a;
    ll li,ri;
    for(int i=0;i<n;i++){
        ll l,r;
        cin>>l>>r;
        r++;
        if(rmin>r)
        {
            rmin=r;
            ri=i;
        }
        if(lmax<l)
        {
            lmax=l;
            li=i;
        }
        a.push_back(make_pair(l,r));
    }
    sort(all(a));
        ll x=-1;
        ll y=INF;
    for(ll i=0;i<n;i++){
        chmax(res,mmax(0,rmin-lmax)+a[i].se-a[i].fi);//if ri==li
    }
    y=a[n-1].se;
    for(ll i=n-1;i>=0;i--){
        x=a[i].fi;
        chmax(res,mmax(0,y-lmax)+mmax(0,rmin-x));//if ri!=li
        chmin(y,a[i].se);
    }
    
    cout<<res<<endl;
    
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 2420
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    InputStreamReader is = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(is);
    int num,i;
    int []S = new int[13];
    int []H = new int[13];
    int []C = new int[13];
    int []D = new int[13];

    for(i = 0;i < 13;i++){
      S[i] = 0;
      H[i] = 0;
      C[i] = 0;
      D[i] = 0;
    }
    num = sc.nextInt();
    for(i = 0;i < num;i++){
      char op = sc.next().charAt(0);
      int c = sc.nextInt();
      if(op == 'S'){
        S[c - 1] = 1;
      }
      else if(op == 'H'){
        H[c - 1] = 1;
      }
      else if(op == 'C'){
        C[c - 1] = 1;
      }
      else if(op == 'D'){
        D[c - 1] = 1;
      }
    }

    for(i = 0;i < 13;i++){
      if(S[i] == 0){
         System.out.println("S "+ (i + 1));
      }
    }
    for(i = 0;i < 13;i++){
      if(H[i] == 0){
         System.out.println("H "+ (i + 1));
      }
    }
    for(i = 0;i < 13;i++){
      if(C[i] == 0){
         System.out.println("C "+ (i + 1));
      }
    }
    for(i = 0;i < 13;i++){
      if(D[i] == 0){
         System.out.println("D "+ (i + 1));
      }
    }
  }
}

Measured memory_bytes: 26500
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	fmt.Println(resolve(parseProblem(os.Stdin)))
}

func parseProblem(r io.Reader) int {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines

	return scanInt(sc)
}

func resolve(n int) (int, int) {
	ds := enumDivisors(n)
	max := len(ds) - 1

	cand := map[int]struct{}{}
	for _, d := range ds {
		cand[d] = struct{}{}
	}
	delete(cand, n)
	sort.Sort(sort.Reverse(sort.IntSlice(ds)))
	min := 0
	for _, k := range ds {
		if _, ok := cand[k]; !ok {
			continue
		}
		if len(cand) == 0 {
			break
		}
		for _, kk := range enumDivisors(k) {
			delete(cand, kk)
		}
		min++
	}
	return min, max
}

func pow(n, i int) (res int) {
	res = 1
	for i > 0 {
		if i&1 == 1 {
			res *= n
		}
		i >>= 1
		n *= n
	}
	return res
}

func enumDivisors(n int) (r []int) {
	max := int(math.Sqrt(float64(n))) + 1
	for i := 1; i < max; i++ {
		if n%i == 0 {
			r = append(r, i)
			if n/i != i {
				r = append(r, n/i)
			}
		}
	}
	sort.Sort(sort.IntSlice(r))
	return r
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}



Measured memory_bytes: 1184
import java.util.*;

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

        long result = 0;
        long whiteCount = 0;
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (ch == 'W') {
                result += i - whiteCount;
                whiteCount++;
            }
        }
        System.out.println(result);
    }
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  vector<int> x(3);
  for (int i = 0; i < s.size(); i++) x.at(s.at(i) - 'a')++;
  
  sort(x.begin(), x.end());
  
  if ((x[0] == x[1] && x[1] == x[2]) || (x[0] == x[1] && x[1] == x[2] - 1) || 
      (x[0] == x[1] - 1 && x[1] == x[2])) cout << "YES\n";
  else cout << "NO\n";
}

Measured memory_bytes: 512
/*#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>*/
#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = {1,0,-1,0};
ll dy[4] = {0,1,0,-1};

int main(){
    ll a,b,c,d,e,f;
	cin >>a>>b>>c>>d>>e>>f;
	ll sug,ans;
	a*=100,b*=100;
	ans = a;
	sug = 0;
	rep(i1,101)rep(i2,101)rep(i3,101)rep(i4,101){
		ll allw = i1*a+i2*b;
		ll alls = i3*c+i4*d;
		if(allw + alls 	<= f){
			if(alls*100 <= allw*e){
				if(sug*(allw+alls) <= alls*ans){
					sug = alls;
					ans = alls + allw;
				}
			}
		}
	}
	cout << ans << " " << sug << endl;
	return 0;
}  


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

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

	long long x = 1;

	for (int i = 0; i < d; i++)	x *= 100;
	
	long long ans = x;

	for (int i = 1; i <= n; i++) { 
		
		if ( i % 100 == 0) {
			n++;
			continue;			
		}
		
		ans = i * x; 
	
	}
		
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < v.size();i++)

#define INF 1000000000
#define pb(a) push_back(a)
#define llong long long
#define vi vector<int>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())

int main(){
	int a;
	int buf;
	while(1){
		cin>>a;
		if(a==0)break;
		REP(i,9){
			cin>>buf;
			a-=buf;
		}
		cout<<a<<"\n";
	}
	return 0;
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int a[N] ; 

int main() {
  int n ;
  ll sum = 0LL ;
  scanf("%d", &n) ;

  for(int i =1 ;i<=n ; i++){
    scanf("%d", &a[i]) ;
    sum+=abs(a[i]-a[i-1]) ;
  }
  sum+=abs(a[n]-0) ;

  for(int i = 1 ;i<=n ;i++){
    cout << sum - abs(a[i] - a[i-1]) -abs(a[i+1]-a[i]) + abs(a[i+1]-a[i-1]) << endl ;
  }
	
  return 0 ;
}

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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  ll n;
  cin >> n;
  vll h(n);
  REP(i, n) {
    cin >> h[i];
  }
  ll now_h = h[n - 1];
  FORD(i, n - 2, 0) {
    if (now_h < h[i] - 1) {
      COUT("No");
      return;
    }
    if (now_h >= h[i]) {
      now_h = h[i];
    }
    else {
      if (now_h >= h[i] - 1) {
        now_h = h[i] - 1;
      }      
    }
    
  }
  COUT("Yes");

}



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

/*
5
1 2 1 1 3
*/


Measured memory_bytes: 3936
import sys

n = int(input())
p = list(map(int,input().split()))


sorted_p = sorted(p)

limit = 2

index_L,value_L = [],[]
for val in range(0,n):
    if p[val] != sorted_p[val]:
        index_L.append(val)
        value_L.append(p[val])
        limit -= 1

        if limit <= 0:
            p[index_L[0]] = value_L[1]
            p[index_L[1]] = value_L[0]

            if p == sorted_p:
                print("YES")
            else:
                print("NO")
            
            sys.exit(0)

print("YES")


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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

/* 
  //エラトステネスのふるい
  int maxNum = 100000;
  char isNotPrime[maxNum+1] = {};
  isNotPrime[0]=isNotPrime[1]=1;
  for(int i=2;i<maxNum;i++){
    if(isNotPrime[i]==1) continue;
    int num = i+i;
    while(num<=maxNum){
      isNotPrime[num]=1;
      num += i;
    }
  }
*/
// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

// 降順ソート vector<int> v;
// sort(v.begin(),v.end(),greater<int>());

signed main() {
  ll n,k;
  cin >> n >> k;
  
  vector<pair<int,int>> val(n);
  int a,b;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    val[i] = make_pair(a,b);
  }
  sort(val.begin(),val.end());

  for(int i=0;i<n;i++){
    k -= val[i].second;
    if(k<=0){
      cout << val[i].first << endl;
      return 0;
    }
  }

  
  
  return 0;
}




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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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 dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
struct UnionFind {
 vector<long long> data;
 UnionFind(long long size) : data(size, -1) { }
 bool unionSet(long long x, long long y) {
   x = root(x); y = root(y);
   if (x != y) {
     if (data[y] < data[x]) swap(x, y);
     data[x] += data[y]; data[y] = x;
   }
   return x != y;
 }
 bool findSet(long long x, long long y) {
   return root(x) == root(y);
 }
 long long root(long long x) {
   return data[x] < 0 ? x : data[x] = root(data[x]);
 }
 long long size(long long x) {
   return -data[root(x)];
 }
};

int main(){
  ll n, m; cin >> n >> m;
  UnionFind uf(n);
  REP(i, m){
    ll x, y, z; cin >> x >> y >> z; x--; y--;
    uf.unionSet(x, y);
  }
  ll ans = 0;
  REP(i, n){
    if(uf.root(i) == i) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int a,b;
  
  cin >> a >> b;
 
  if ((a*b)%2)
  {
    cout << "Odd" << endl;
  }
  else
  {
    cout << "Even" << endl;
  }
}


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

int main() {
    int N,K;
    cin >> N >> K;
    vector<int> d(K);
    int a;
    vector<int> A;
    for (int i=0; i<K; i++) {
        cin >> d[i];
        for (int j=0; j<d[i]; j++) {
            cin >> a;
            A.push_back(a);
        }
    }
    int NA = A.size();
    vector<int> sunuke(N);
    for (int i=0; i<NA; i++) {
        if (sunuke[A[i]-1] == 0) {
            sunuke[A[i]-1] = 1;
        }
    }
    int ans = 0;
    for (int i=0; i<N; i++) {
        ans += sunuke[i];
    }
    cout << N-ans << endl;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int n,q,a[N],b[N];
int get(int x,int y,int z){
  for(int i=1;i<=n;i++)b[i]=a[i]%z;
  int l=x/n;
  int r=x%n;
  y%=z;
  int ans1=0,ze=0;
  for(int i=1;i<=n;i++){
    if(!b[i])ze++;
  }
  ans1+=ze*l;
  ze=0;
  for(int i=1;i<=r;i++){
    if(!b[i])ze++;
  }
  ans1+=ze;
  LL tot=0;
  for(int i=1;i<=n;i++){
    tot+=b[i];
  }
  tot=1ll*tot*l;
  for(int i=1;i<=r;i++)tot+=b[i];

  //cout<<tot+y<<endl;
  return x-ans1-(tot+y)/z;
}
int main() {
  ios::sync_with_stdio(false);
   cin>>n>>q;
   for(int i=1;i<=n;i++)cin>>a[i];
   for(int i=1;i<=q;i++){
     int a,b,c;
     cin>>a>>b>>c;
     --a;
     cout<<get(a,b,c)<<'\n';
   }
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

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


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

using namespace std;
int n,f[1202020],siz[202020];
const int mod = 1e9+7;
long long sum = 0;

inline int getf(int x) {
	if (x == f[x])
		return x;
	return f[x] = getf(f[x]);
}
int m,aa,bb;
int main() {
scanf("%d",&n);
for (int i = 1;i <= n; i++) {
	scanf("%d",&aa);
	f[aa]++;
}
int fl = 0;
for (int i = 2;i <= 1000000; i++ ) {
	int sum = 0;
	for (int j = 1;j*i <= 1000000; j++)
		sum += f[i*j];
	if (sum == n) {
		printf("not coprime");
		return 0;
	}
	if (sum > 1) {
		fl = 1;
	}
}
	if (fl) {
		printf("setwise coprime");
	}
	else
		printf("pairwise coprime");
	return 0;
}
/*
5
6 14 15 7 12 16 5 4 11 9 3 10 8 2 13 1
4
1 2 3 4 5 6 7 8
*/

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

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

	bool can = true;

	if (n % 2 != 0) {
		can = false;
	}
	else {
		for (int i = 0; i < n / 2; i++) {
			if (s[i] != s[i + n / 2]) can = false;
		}
	}

	if(can) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

#define PI 3.14159265358979323846

// #define ll long long int
#define ff first
#define ss second
#define int long long int
#define pb push_back

#define N 10000010
#define MOD 1000000007

int bexp(int a, int b)
{
    int res = 1;
    while(b)
    {
        if(b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

    int n, k;
    cin >> n >> k;
    int p[n + 1] = {}, c[n + 1] = {};

    for(int i = 1; i <= n; ++i)
        cin >> p[i];

    for(int i = 1; i <= n; ++i)
        cin >> c[i];
    
    int visi[n + 1] = {};    
    int ans = INT_MIN;
    for (int i = 1; i <= n; ++i)
    {
        int cnt = min(n + 1, k), no = 0, in = i;
        int l = cnt, c1 = 0;
        while(cnt--)
        {
            if (visi[in])
            {
                l = min(n + 1, k) - cnt - 1;
                c1 = in;
                break;
            }

            visi[in] = 1;
            no += c[p[in]];
            in = p[in];
            ans = max(ans, no);
        }

        if (c1)
        {   
            // cout << l << " " << in << endl;
            no = (k / l - 1) * no;
            cnt = k % l + l;
            if (k / l > 1)
                ans = max(ans, no);
            while(cnt--)
            {
                no += c[p[in]];
                in = p[in];
                ans = max(ans, no);
            }
        }

        memset(visi, 0, sizeof(visi));
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3804
import kotlin.math.PI
import kotlin.math.abs
import kotlin.math.cos
import kotlin.math.sqrt

//

fun main() {
    abc168c()
}

fun abc168c() {
    val (a, b, h, m) = readLine()!!.split(" ").map { it.toDouble() }
    val deltaA = 30 * h + m / 2
    val deltaB = 6 * m
    val delta = abs(deltaA - deltaB)
    val rad = delta * PI / 180.0
    val cos = cos(rad)
    val x = sqrt(a * a + b * b - 2 * a * b * cos)
    println(x)
}


Measured memory_bytes: 36596
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()

w = []
seen = []
for i in range(n):
    w.append(input())

for i in range(n-1):
    if w[i] in seen or w[i+1] in seen:
        print('No')
        exit()
    if w[i][-1] != w[i+1][0]:
        print('No')
        exit()
    seen.append(w[i])

print('Yes')


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>

using namespace std;

const int V=100005;

vector<int> to[V*2];

bool visited[V*2];

vector<int> cnt;

void dfs(int v)
{
	if(visited[v])return;
	visited[v]=true;
	cnt[v/V]++;
	for(int i=0;i<to[v].size();i++)
		dfs(to[v][i]);


}

int main()
{
	int n;
	cin >> n;
	for(int i=0;i<n;i++)
	{
		int x,y;
		cin >> x >> y;
		y+=V;
		to[x].push_back(y);
		to[y].push_back(x);
	}

	long long ans=0;

	for(int i=0;i<V*2;i++)
	{
		if(visited[i])continue;
		cnt=vector<int>(2,0);
		dfs(i);
		ans+=(long long)cnt[0]*cnt[1];	
	}
	ans-=n;

	cout << ans << endl;

}

Measured memory_bytes: 10240
n=int(input())
l=[]
lans=[]
for i in range(n):
  x,y=(map(int,input().split()))
  l.append(x+y)
  lans.append(x-y)

l.sort()
lans.sort()
#print(l)
print(max(l[-1]-l[0],lans[-1]-lans[0]))

'''
  ll1=[ll[1],ll[0]]
  lan.append(ll1)

l.sort()
lan.sort()
we=abs(l[0][0]-l[-1][0])+abs(l[0][1]-l[-1][1])
we1=abs(lan[0][0]-lan[-1][0])+abs(lan[0][1]-lan[-1][1])
print(max(we,we1))
'''

Measured memory_bytes: 25908
N = input()

a = 0  # not borrowed
b = 0  # borrowed

t = int(N[-1])
a, b = a + t, a + (10 - t)

for i in range(len(N) - 2, -1, -1):
    t = int(N[i])
    a, b = min(a + t, b + (t + 1)), min(a + (10 - t), b + (10 - (t + 1)))
print(min(a, b + 1))


Measured memory_bytes: 5492
def main():
    N = int(input())
    S1 = list(input())
    S2 = list(input())
    d = 10**9 + 7
    # print(N, S1, S2)

    skip = False
    Map = {("p","v"):3, ("p","h"):6, ("v","h"):2, ("h","v"):1, ("h","h"):3, ("v","v"):2}
    pre = "p"

    possibles = 1
    for n in range(N):
        if skip:
            skip = False
            continue
        pass
        if S1[n] == S2[n]:  # vertical
            # print("v")
            now = "v"
        else:  # horizonal
            # print("h")
            now = "h"
            skip = True
        possibles *= Map[(pre,now)]
        possibles %= d
        # print("possibles", pre, now, possibles)
        pre = now

    print(possibles)

        
if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
<?php

ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_WARNING);
ini_set('display_errors', 'Off');

// define('DEBUG', true);
define('DEBUG', false);

$map = array(array());
fscanf(STDIN, "%d %d", $H, $W);
for ($i = 1; $i <= $H; $i++) {
    fscanf(STDIN, "%s", $S);
    $map[$i] = str_split(" " . $S);
}
// var_dump($map);

for ($i = 1; $i <= $H; $i++) {
    for ($j = 1; $j <= $W; $j++) {
        $x = 0;
        if ($map[$i][$j] == ".") {
            if ($map[$i-1][$j-1] == "#") {
                $x++;
            }
            if ($map[$i-1][$j  ] == "#") {
                $x++;
            }
            if ($map[$i-1][$j+1] == "#") {
                $x++;
            }
            if ($map[$i  ][$j-1] == "#") {
                $x++;
            }
            if ($map[$i  ][$j+1] == "#") {
                $x++;
            }
            if ($map[$i+1][$j-1] == "#") {
                $x++;
            }
            if ($map[$i+1][$j  ] == "#") {
                $x++;
            }
            if ($map[$i+1][$j+1] == "#") {
                $x++;
            }
            echo $x;
        } else {
            echo $map[$i][$j];
        }
    }
    echo PHP_EOL;
}

Measured memory_bytes: 4604
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    string s;
    cin >> s;
    int n = s.length();
    stack<char> st;
    rep(i, n) {
        if ( st.empty() ) {
            st.push(s[i]);
        }
        else if ( st.top() == '0' && s[i] == '1' ) {
            st.pop();
        }
        else if ( st.top() == '1' && s[i] == '0' ) {
            st.pop();
        }
        else {
            st.push(s[i]);
        }
    }
    cout << n - st.size() << endl;
    return 0;
}


Measured memory_bytes: 512
use std::io::*;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let mut v: Vec<i32> = (0..100010).map(|_| 0).collect();
    let n: usize = iter.next().unwrap().parse().unwrap();
    for _i in 0..n {
        let a: usize = iter.next().unwrap().parse().unwrap();
        let b: usize = iter.next().unwrap().parse().unwrap();
        v[a]+=1;
        v[b+1]-=1;
    }
    let mut result = 0;
    let mut member = 1;
    for i in 2..n+2 {
        member += v[i];
        let i = i as i32;
        if i <= member {
            result = i;
        }
    }
    if result > 0 {
        result-=1;
    }
    println!("{}", result);
}



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

namespace MSPC2020
{
    class C
    {
        static void Main(string[] args)
        {
            //var CA = Enumerable.Repeat(0, (int)N).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
            //var LRd = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //var X = int.Parse(Console.ReadLine());
            //var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var NK = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var N = NK[0]; var K = NK[1];
            for (long i = 0; i < N - K; i++)
            {
                var L = A[i];
                var R = A[i + K];

                if (L < R) Console.WriteLine("Yes");
                else Console.WriteLine("No");
            }

        }
    }
}


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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

ll bit_ones(ll n)
{
	ll ret = 0;
	while(n > 0) {
		if(n % 2) ret++;
		n /= 2;
	}
	return ret;
}

ll calc(ll x)
{
	ll ret = 1;
	while(x > 0) {
		ll shitproblem = bit_ones(x);
		x %= shitproblem;
		ret++;
	}
	return ret;
}

int main()
{
    Fast_IO();
    ll n; cin >> n;
    string s; cin >> s;
    ll popcount = 0;
    f(i,0,n-1) if(s[i] == '1') popcount++;
    ll org_p1 = 0, org_m1 = 0;
    ll pow2_p1[n], pow2_m1[n];
    ll p1 = popcount + 1, m1 = popcount - 1;
    pow2_p1[0] = pow2_m1[0] = 1;
    f(i,1,n-1) {
    	if(m1 > 0) pow2_m1[i] = (pow2_m1[i-1] * 2) % m1;
    	pow2_p1[i] = (pow2_p1[i-1] * 2) % p1;
    }
    rf(i,n-1,0) {
    	ll Power = n-1 - i;
    	if(s[i] == '1') {
    		org_p1 = (org_p1 + pow2_p1[Power]) % p1;
    		if(m1 > 0) org_m1 = (org_m1 + pow2_m1[Power]) % m1;
    	}
    }
    f(i,0,n-1) {
    	if(s[i] == '0') {
    		ll xi = org_p1;
    		ll Power = n-1-i;
    		xi = (xi + pow2_p1[Power]) % p1;
    		cout << calc(xi) << endl;
    	}
    	else {
    		if(m1 == 0) {
    			cout << 0 << endl;
    			continue;
    		}
    		ll xi = org_m1;
    		ll Power = n-1-i;
    		xi = (xi - pow2_m1[Power] + m1) % m1;
    		cout << calc(xi) << endl;
    	}
    }
    return 0;
}


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

int main() {
  int M,N;
  cin >> N >> M;
  
  if(M == N){
    cout << "Yes";
  } else {
    cout << "No";
  }
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back


vec fac(210000), finv(210000), inv(210000);

ll modpow(ll a, ll n, ll m)
{
    if(n == 0) return 1;
    ll t = modpow(a, n >> 1, m);
    t = t * t % m;
    if(n & 1) t = t * a % m;
    return t; 
}

void combinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    REP(i,2,210000) {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
 
ll combmod(ll n, ll r)
{
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    ll c = 1;
    REP(i,0,r) c = c * (n-i) % MOD;
    c = c * finv[r] % MOD;
    return c;
}

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;

//    vec inv(200010, 0);
//    inv[1] = 1;
//    REP(i,2,200010) inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;

    combinit();

    ll nCa = 1, nCb = 1, c;
    REP(i,1,a+1) nCa = ((nCa * (n-i+1) % MOD) * inv[i]) % MOD;
    REP(i,1,b+1) nCb = ((nCb * (n-i+1) % MOD) * inv[i]) % MOD;
    c = (modpow(2, n, MOD) - 1- nCa - nCb) % MOD;
    c = (c < 0) ? c + MOD : c;
    PR(c); 

    return 0;
}

/*

nC1 + ... + nCn - nCa - nCb
= 2^n - 1 - nCa - nCb

*/

Measured memory_bytes: 5120
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define ll long long

ll n, m;
int main()
{
	cin >> n >> m;
	
	if (n > 2 && m > 2) cout << (n - 2)*(m - 2) << endl;
	else if (n == 1 && m == 1) cout << 1 << endl;
	else if (n == 1 && m > 2) cout << m - 2 << endl;
	else if (m == 1 && n > 2) cout << n - 2 << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int min(int a, int b){
    if(a<b)return a;
    return b;
}
int main(void){
    int n, m;
    scanf("%d %d", &n, &m);
    int l, r;
    scanf("%d %d", &l, &r);
    for(int i=1; i<m; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        if(l<a)l=a;
        if(b<r)r=b;
    }
    if(r<l)printf("0\n");
    else printf("%d\n", min(n, r-l+1));
    return 0;
}


Measured memory_bytes: 1688
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> m(k,0);
	for(int i=1;i<=n;++i)m[i%k]++;

	ll ans = 0;
	for(int i=0;i<k;i++)
	{
		int b = (k - i)%k;
		int c = (k - i)%k;
		if((c+b)%k==0)
		{
			ans += (1LL)*m[i]*m[b]*m[c];
		}

	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline int ubnd(T&v,ET(T) x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T) x){return lower_bound(begin(v),end(v),x)-begin(v);}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline void inpt(T&v,int n,function<ET(T)()>f=In<ET(T)>){for(v.reserve(n);n--;v.emplace_back(f()));}
TT inline void show(T&v,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),cout<<x;cout<<e;}
#undef TT
#undef ET

inline void fast_io(){ios::sync_with_stdio(0); cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline string instr(){string x;cin>>x;return x;}
inline ll pow_mod(ll a, ll k, ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a, ll p){return pow_mod(a,p-2,p);}

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

bool is_digit(const string& s){
  if (isdigit(s[0])) return true;
  return (s[0] == '+' || s[0] == '-') && isdigit(s[1]);
}

int main()
{
  string line;
  while (getline(cin, line)){
    stringstream ss(line);
    string e;
    stack<ld> st;
    while (ss >> e){
      if (is_digit(e)) st.push(stof(e));
      else {
        ld a, b;
        a = st.top();
        st.pop();
        b = st.top();
        st.pop();
        if (e == "+") st.push(b + a);
        if (e == "-") st.push(b - a);
        if (e == "*") st.push(b * a);
        if (e == "/") st.push(b / a);
      }
    }
    printf("%Lf\n", st.top());
  }
  return (0);
}

// priority_queue queue deque front top push pop map set stringstream max_element min_element insert count find get tie make_tuple

Measured memory_bytes: 1264
import java.util.Scanner;

public class Main {

	static int[] hai;
	static int addHai;
	static boolean ans[];
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(cin.hasNext()){
			String str = cin.next();
			hai = new int[10];
			ans= new boolean[10];
			for(int i=0;i<str.length();i++){
				hai[str.charAt(i)-'0']++;
			}
			for(int i = 1;i<10;i++){
				if(hai[i]<4){
					
					hai[i]++;
					addHai=i;
					bfs(14);
					hai[i]--;
				}
			}
			boolean first = true;
			for(int i = 0;i<10;i++){
				if(ans[i]){
					if(first){
						first=false;
						System.out.print(i);
					}else{
						System.out.print(" "+i);
					}
				}
			}
			if(first){
				System.out.print(0);
			}
			System.out.println();
		}
		
			
	}
	static void bfs(int haiCount){
		//print(hai);
		if(haiCount==2){
			// 頭
			for(int i = 1;i<10;i++){
				if(hai[i]==2){
					ans[addHai]=true;
				}
			}
		}
		// 刻子
		for(int i = 1;i<10;i++){
			if(hai[i]>=3){
				hai[i]=hai[i]-3;
				bfs(haiCount-3);
				hai[i]=hai[i]+3;
			}
		}
		
		for(int i = 1;i<8;i++){
			if(hai[i]>0&&hai[i+1]>0&&hai[i+2]>0){
				hai[i]--;
				hai[i+1]--;
				hai[i+2]--;
				bfs(haiCount-3);
				hai[i]++;
				hai[i+1]++;
				hai[i+2]++;
			}
		}
	}
	static void print(int[] a){
		for(int i = 0;i<a.length;i++){
			System.out.print(a[i]+" ");
		}
		System.out.println();
	}
}

Measured memory_bytes: 12000
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map as Map
import Data.Map (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

ans :: String -> Int
ans ('A':'B':'C':s) = 1 + ans s
ans (_:s) = ans s
ans [] = 0

main :: IO ()
main = do
	n <- readLn
	s <- take n <$> getLine
	print $ ans s


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

signed main(){
    int a,b,k;
    cin>>a>>b>>k;
    if(k>a){
        k=k-a;
        a=0;
    }
    else{
        a=a-k;
        k=0;
    }
    //cout<<a<<" "<<k;
    if(k!=0){
        if(k>b){
            k=k-b;
            b=0;
        }
        else{
            b-=k;
            k=0;
        }
    }
    cout<<a<<" "<<b;
    return 0;
}

Measured memory_bytes: 3592
<?php
fscanf(STDIN, "%d %d", $n, $k);
$p = array_map('intval', explode(' ', trim(fgets(STDIN))));
foreach ($p as $i => $v) {
    $p[$i]++;
}
$max = 0;
$s = 0;
$q = new SplQueue();
for ($i = 0; $i < count($p); ++$i) {
    $s += $p[$i];
    $q->enqueue($p[$i]);
    if ($q->count() > $k) {
        $s -= $q->dequeue();
    }
    if ($q->count() == $k) {
        $max = max($max, $s);
    }
}
printf("%.10f", $max / 2);


Measured memory_bytes: 27120
N=int(input())
d={}
for _ in range(N):
    s=input()
    if s in d:
        d[s]+=1
    else:
        d[s]=1
mv=max(d.values())
l=list()
for k,v in d.items():
    if v==mv:
        l.append(k)
l.sort()
for li in l:
    print(li)

Measured memory_bytes: 32096
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

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

    int n,m;
    cin>>n>>m;
    vs a(n),b(n);
    cin>>a>>b;
    int c=0;
    rep(i,n)rep(j,m)if(a[i][j]-b[i][j])c++;
    cout<<c<<endl;
}



Measured memory_bytes: 11348
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
int f[1000005],a[55],b[55];
int main(){
	memset(f,0x3f3f3f3f,sizeof(f));
    a[1]=6;b[1]=9;f[1]=1;f[0]=0;
    for(int i=2;a[i-1]<100000;i++)a[i]=a[i-1]*6,f[a[i]]=1;
    for(int i=2;b[i-1]<100000;i++)b[i]=b[i-1]*9,f[b[i]]=1;
    for(int i=2;i<=100000;i++){
    	for(int j=1;a[j]<=i;j++){
    		f[i]=min(f[i],f[i-a[j]]+1);
		}
		for(int j=1;b[j]<=i;j++){
			f[i]=min(f[i],f[i-b[j]]+1);
		}
		f[i]=min(f[i],f[i-1]+1);
	}    
	int n;
	cin>>n;
	cout<<f[n];
    return 0;
}


Measured memory_bytes: 4096
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n, k; cin >> n >> k;
    vector<int> p(n);
    vector<ld> ex(n);
    rep(i, n) {
        cin >> p[i];
        ex[i] = (1.0 + (ld)p[i]) / 2.0;
    }
    ld now = 0.0;
    rep(i, k) {
        now += ex[i];
    }
    ld ans = now;
    for(int i = k; i < n; ++i) {
        now += ex[i];
        now -= ex[i - k];
        chmax(ans, now);
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 4352
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
 
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 200005;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
     ll n;
     cin >> n;
     ll a[n];
     for(ll i=0;i<n;i++)   cin >> a[i];      
     map<ll,ll> y;
     ll ans = 0;
     for(ll i=0;i<n;i++)
     {
          ans = ans + y[i-a[i]];
          y[i+a[i]]++;
     }
     cout<<ans;
}

int main()
{
     FAST;
     ll t = 1;
  //   cin >> t;
     while(t--)
     {    
          solve();
     }
}

Measured memory_bytes: 27812
N = int(input()) 
prime = [] 
def isprime(n):
    flag = 0
    for i in range(2,int(n**(1/2))+1):
        if n % i == 0:
            flag = 1
            break
    if n == 2:
        flag = 0
    if flag == 0:
        return True
    else:
        return False 
for i in range(1,55556):
    if isprime(i) and i%5==1:
        prime.append(i) 
ans = str(prime[1] )
for i in range(2,N+1):
    ans += " "+str(prime[i] )
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll n,m;
    cin>>n>>m;
    vector<pair<ll,ll> > ab(n,pair<ll,ll>(0,0));
    rep(i,n){cin>>ab[i].first>>ab[i].second;} 
    sort(ab.begin(), ab.end());
    priority_queue<ll> que;
    ll res = 0;
    ll cnt=0;
    for(ll i=1;i<=m;i++){
        while(cnt<n&&ab[cnt].first<=i){
            que.push(ab[cnt].second);
            cnt++;
        }
        if(!que.empty()){
            res += que.top();
            que.pop();
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 2936