akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}
template <class T>
bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
        return c - '0';
    return 0;
}
using namespace std;

int main()
{
    ll n, t, ans = 0;
    cin >> n;
    if (n % 2 != 1)
    {
        t = 1;
        while (t <= 1e18)
        {
            t *= 5;
            ans += n / (t * 2);
        }
    }

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

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

using namespace std;

#define FOR(i,a,b) for(int i=a;i<=b;i++)

const int N=1e3;

int main()
{
	int n,a[N],lmin=INT_MAX,lmax=INT_MIN,ans=INT_MAX;
	cin >> n;
	FOR(i,1,n) {
		cin >> a[i];
		lmin=min(lmin,a[i]);
		lmax=max(lmax,a[i]);
	}
	sort(a+1,a+1+n);
	FOR(i,lmin,lmax) {
		int sum=0;
		FOR(j,1,n) sum+=(a[j]-i)*(a[j]-i);
		ans=min(ans,sum);
	}
	cout << ans;
}

Measured memory_bytes: 256
import java.math.BigDecimal

fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val W = sc.nextInt()
    val H = sc.nextInt()
    val x = sc.nextInt()
    val y = sc.nextInt()

    val m = if (x * 2 == W && y * 2 == H) 1 else 0

    val r = BigDecimal.valueOf(W.toLong()).multiply(BigDecimal.valueOf(H.toLong())).divide(BigDecimal.valueOf(2L))
    println("$r $m")
}


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

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

const long long inf = 1LL << 60;

long long a[100010][3];

long long dp[100010][3];

int main(){
  int n,i,k,j;
  cin >> n;

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


  for(i=0;i<10010;++i){
    for(k=0;k<3;++k){
    dp[i][k]=0;
  }
  }

  for(i=0;i<n;++i){
    for(k=0;k<3;++k){
      for(j=0;j<3;++j){
        if(k==j) continue;
        chmax(dp[i+1][j],dp[i][k]+a[i][j]);
      }
    }
  }

  long long ans=0;

  for(i=0;i<3;++i){
    chmax(ans,dp[n][i]);
  }

  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 4992
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
    int N;
    cin >> N;
    long A[N+1], B[N];
    for(int i=0;i<N+1;i++) cin >> A[i];

    for(int i=0;i<N;i++) cin >> B[i];

    long ans = 0;
    for(int i=0;i<N;i++){
      ans += min(B[i], A[i]+A[i+1]);
      A[i+1] -= max(B[i]-A[i], long(0));
      A[i+1] = max(A[i+1], long(0));
    }
  	

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



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


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

    vector<int> dp(100110,1e9),h(100110);
    int n,k;
    cin >> n>>k;
    rep(i, n) cin >> h[i + 1];
    dp[1] = 0;

    forx(i,1,n){
        forx(j,1,k+1){
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    cout << dp[n] << endl;

    return 0;
    }


Measured memory_bytes: 1024
n,k = map(int,input().split())
s = list(map(int,input().split()))
# print(s)
now_city = 1
s_l_city = 1
t = [0] #何回そこを通ったか
f = [0] #何回目にそこを通ったか
a=0
b = 0#サイクルありなし
f_l=0#ループの最初
for i in range(n):
    t.append(0)
    f.append(-1)
# print(s)
sycle = 0
for i in range(1,n+10):
    now_city = s[now_city-1]
    
    if t[now_city-1]==1:
        #  print(i,f[j])
         sycle=i-f[now_city-1]
         f_l=f[now_city-1]
        #  f_l=i
        #  a = 1
         b = i
        #  s_l_city=now_city
        #  print("ループの最初の数字",now_city,"最初は"+str(f_l)+"回目","周期は",sycle)
         break
    t[now_city-1]+=1
    f[now_city-1]=i
# print(t)
# print(f_l)
# print(f_l,sycle,s_l_city)

if k>b:
    # now_city=s_l_city
    for _ in range((k-f_l)%sycle):
        
        now_city = s[now_city-1]
    # print((k-f_l)%sycle)
    print(now_city)
else:
    # print("ループなし")
    now_city=1
    for _ in range(k):
        now_city=s[now_city-1]
    print(now_city)



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

int main(){

int N;
cin >> N;

int ans = 0, ma = 0;
      for(int i = 0; i < N; i++){ 
             int p;
             cin >> p;
             ma = max(ma, p);
             ans += p; 
      }

ans = ans - (ma / 2);

cout << ans << endl; 

}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    
    int n;
    int a;
    int x=0,y=0,z=0;
    scanf("%d",&n);
    for(;~scanf("%d",&a);){
        if(a%4==0){
            z++;
        }else if(a%2==0){
            y++;
        }else{
            x++;
        }
    }
    
    if(y && x<=z){
        printf("Yes");
    }else if(!y && x<=z+1){
        printf("Yes");
    }else{
        printf("No");
    }
    
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vll = vector<vl>;
using vii = vector<vi>;
using pii = pair<int, int>;

using vc = vector<char>;
using vcc = vector<vc>;
using vb = vector<bool>;
using vbb = vector<vb>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using vd = vector<double>;
using vdd = vector<vd>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


const int MOD = 1e9 + 7;

vector<pii> prime_factorization(int n){ // 素因数分解をしたvector<素数, 指数>を返す
  vector<pii> res;
  int tmp, root_n = floor(sqrt(n));
  if(n % 2 == 0){
    tmp = 1;
    n /= 2;
    while(n % 2 == 0){
      n /= 2;
      tmp++;
    }
    res.push_back(make_pair(2, tmp));
  }
  ll i = 3;
  while(i <= root_n && i <= n){
    if(n % i == 0){
      tmp = 1;
      n /= i;
      while(n % i == 0){
        n /= i;
        tmp++;
      }
      res.push_back(make_pair(i, tmp));
    }
    i += 2;
  }
  if(n != 1) res.push_back(make_pair(n, 1));
  return res;
}
vector<pli> prime_factorization(ll n){ // 素因数分解をしたvector<素数, 指数>を返す
  vector<pli> res;
  int tmp, root_n = floor(sqrt(n));
  if(n % 2 == 0){
    tmp = 1;
    n /= 2;
    while(n % 2 == 0){
      n /= 2;
      tmp++;
    }
    res.push_back(make_pair(2, tmp));
  }
  ll i = 3;
  while(i <= root_n && i <= n){
    if(n % i == 0){
      tmp = 1;
      n /= i;
      while(n % i == 0){
        n /= i;
        tmp++;
      }
      res.push_back(make_pair(i, tmp));
    }
    i += 2;
  }
  if(n != 1) res.push_back(make_pair(n, 1));
  return res;
}

// n は 2以上の素数表を返す
vb Primes(int n){
  vector<bool> res(n + 1, true);
  res.at(0) = false; res.at(1) = false;
  for(int i = 2; i <= sqrt(n); i++){
    if(res.at(i)){
      for(int j = 2 * i; j <= n; j += i){
        res.at(j) = false;
      }
    }
  }
  return res;
}
// ===================================================

string fetch(string *s, int p, int q, int n){
  int i;
  string res = "";
  for(i = 0; i < p; i++) res = res + (*s).at(i);
  for(i = q; i < n; i++) res = res + (*s).at(i);
  return res;
}

using vs = vector<string>;
using vss = vector<vs>;

int main(){
  string s; cin >> s;
  int n = s.size();
  for(int i = 0; i < n; i++){
    for(int j = i; j < n; j++){
      if(fetch(&s, i, j, n) == "keyence"){
        cout << "YES\n";
        return 0;
      }
    }
  }
  cout << "NO\n";
  return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


int main(){

    int n;
    cin>>n;
    Vec vec(n);
    for(int i=0;i<n;i++){
        cin>>vec[i];
    }   
    sort(vec.begin(),vec.end());

    int a=0,b=0;

    for(int i=n-1;0<=i;i--){

        if(i%2==0){
            b+=vec[i];
        }
        else{
            a+=vec[i];
        }
        
    }
    cout<<abs(a-b)<<endl;


}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int a[SIZE],p[SIZE],d[SIZE],an[SIZE];
set<int>D,U,H;
VI e[SIZE];
int main(){
 DRII(N,K);
 REPP(i,1,N+1){RI(a[i]);p[a[i]]=i;}
 int rr=1;
 U.insert(N+1);U.insert(0);
 D.insert(N+1);D.insert(0);
 REPP(i,1,N+1){
   for(;rr<min(N+1,i+K);rr++)U.insert(a[i]);
  U.erase(a[i]);
  if(i-K>0)D.erase(a[i-K]);
  set<int>::iterator it=U.lower_bound(a[i]);
  if(*it!=N+1)d[i]++,e[p[*it]].PB(i);
  it--;
if(*it!=0)d[p[*it]]++,e[i].PB(p[*it]);
it=D.lower_bound(a[i]);
  if(*it!=N+1)d[i]++,e[p[*it]].PB(i);
  it--;
if(*it!=0)d[p[*it]]++,e[i].PB(p[*it]);
  D.insert(a[i]);
 }
 REPP(i,1,N+1)
  if(d[i]==0)H.insert(i);
 REP(kk,N){
  int x=*H.rbegin();H.erase(x);
  an[x]=N-kk;
  REP(i,SZ(e[x])){
   d[e[x][i]]--;
   if(!d[e[x][i]])H.insert(e[x][i]);
  }
 }
 for(int i=1;i<=N;i++)printf("%d%c",an[i],i<N?' ':'\n');
 return 0;
}

Measured memory_bytes: 74368
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	string a,b;
	int tem=0;
	cin>>a>>b;
	int n1=a.size();
	int n2=b.size();
	int p=n1;
	if(n1!=n2)
	{
		cout<<"No";return 0;
	}
	else
	{
		while(p--)
		{
			int g=0;
			//cout<<a[0]<<endl;
			int cnt=a[n1-1];
			int cnt1=a[0];
			for(int i=1;i<n1;i++)
			{
				int cnt2=a[i];
				a[i]=cnt1;
				cnt1=cnt2;
			}
			a[0]=cnt;
			for(int i=0;i<n1;i++)
			{
				if(a[i]!=b[i])
				{
					g=1;break;
				}
			}
			if(g==0)
			{
				cout<<"Yes";tem=1;
				return 0;
			}
		}	
		if(tem==0)cout<<"No"<<endl;
	}
	return 0;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;
using Int = long long;
#define REP(i, n) for (int i = 0; i < n; i++)
int main()
{
    int n; cin >> n;
    Int c1 = 0, c2 = 0, s1 = 0, s2 = 0;
    REP(i, n) {
        int a; cin >> a;
        s1 += a;
        s2 += a;
        if (i % 2 == 0) {
            if (s1 <= 0) c1 += 1 - s1, s1 = 1;
            if (s2 >= 0) c2 += s2 - (-1), s2 = -1;
        } else {
            if (s1 >= 0) c1 += s1 - (-1), s1 = -1;
            if (s2 <= 0) c2 += 1 - s2, s2 = 1;
        }
    }
    cout << min(c1, c2) << endl;
    return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

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

    int A, B;
    cin >> A >> B;
    vector<int> an(A), blu(B);

    REP(i, A)
    {
        cin >> an[i];
    }

    REP(i, B)
    {
        cin >> blu[i];
    }

    int ans = 0;

    REP(i, B)
    {
        int locB = i, locA = 0, tmp = 0;

        while(locB < B && locA < A)
        {
            if(blu[locB] == an[locA])
            {
                tmp++;
                
                ans = max(ans, tmp);
                locB++;
            }

            locA++;
        } 
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
 
const int mxN = 2e5 + 10;
int n, m;
ll k, a[mxN], b[mxN];
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
 
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i) {
    cin >> a[i + 1];
    a[i + 1] += a[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> b[i + 1];
    b[i + 1] += b[i];
  }
  int ans = 0;
  for (int i = 0; i <= n; ++i) {
    if (a[i] > k)
      break;
    // int j = m;
    // while (a[i] + b[j] > k) 
    //   j--;
    int j = upper_bound(b, b + m + 1, k - a[i]) - b;
    ans = max(i + j - 1, ans);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 6768
package main

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

var in = newIo(bufio.NewScanner(os.Stdin))

func main() {
	n := in.nextInt()
	print(solve(n))
}
func maxInt(a int, b int) int {
	if a < b {
		return b
	}
	return a
}

func solve(n int) string {
	m := int(n / 100)
	if m < (n/10)%10 || m < n%10 {
		m++
	}
	return strings.Repeat(strconv.Itoa(m), 3)
}

func print(result ...interface{}) {
	for _, r := range result {
		kind := reflect.TypeOf(r).Kind()
		if kind == reflect.Array || kind == reflect.Slice {
			rv := reflect.ValueOf(r)
			cnv := make([]interface{}, rv.Len())
			for i := 0; i < rv.Len(); i++ {
				cnv[i] = rv.Index(i).Interface()
			}
			print(cnv...)
		} else {
			fmt.Println(r)
		}
	}
}

type io struct {
	sc *bufio.Scanner
}

func newIo(sc *bufio.Scanner) *io {
	i := new(io)
	i.sc = sc
	i.sc.Split(bufio.ScanWords)
	return i
}

func (i *io) setSplit(f bufio.SplitFunc) {
	i.sc.Split(f)
}

func (i *io) nextIntSlice(y int, delim string) [][]int {
	result := make([][]int, y)
	for j := 0; j < y; j++ {
		line := i.next()
		result[j] = perseIntSlice(strings.Split(line, delim))
	}
	return result
}

func (i *io) next() string {
	i.sc.Scan()
	return i.sc.Text()
}

func (i *io) nextInt() int {
	return perseInt(i.next())
}

func (i *io) nextLong() int64 {
	return perseLong(i.next())
}

func perseInt(s string) int {
	in, _ := strconv.Atoi(s)
	return in
}

func perseLong(s string) int64 {
	in, _ := strconv.ParseInt(s, 10, 64)
	return in
}

func perseIntSlice(s []string) []int {
	var r = make([]int, len(s))
	for i := 0; i < len(s); i++ {
		r[i] = perseInt(s[i])
	}
	return r
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int maxn = 2009;
const int MOD = 1000000007;
int f[maxn][maxn];
int N, K, ans;

int main(){
	scanf("%d%d", &N, &K);
	f[0][N+1] = 1;
	for (int i=1; i<=K; i++){
		f[i][N-i+1] = (f[i-1][N-i+2] + f[i-1][N-i+1]) % MOD;
		for (int j=N-i; j>=1; j--)
			f[i][j] = (f[i-1][j] + f[i][j+1]) % MOD;
	}
	ans = (f[K][1] - f[K-1][1] + MOD) % MOD;
	for (int i=1; i<=N-K-1; i++) ans = ans*2 % MOD;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 15232
fun main(args: Array<String>) {
    /*readLine()で一行分の入力をString型として受け取り（"!!"でnull非許容に）
    split()で空白区切りにパースし
    map{}でInt型に変換して各変数に代入する
    */
    val (a, b, c) = readLine()!!.split(" ").map{ it.toInt() }
    var count = 0
    
    for (i in a..b) {
        if (i % c == 0) {
            count += 1            
        }
    }
    println(count)
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

/* Some Libraries */

const int H_MAX = 400;
int H,W;
vector<string> f;
bool seen[H_MAX][H_MAX];

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

pi dfs(int y, int x)
{
    int sz=1;
    int cnt=(f[y][x]=='#');
    seen[y][x] = true;
    rep(i,4){
        int ny = y+dy[i];
        int nx = x+dx[i];
        if (!(0<=ny&&ny<H&&0<=nx&&nx<W)) continue;
        if (seen[ny][nx]) continue;
        if (f[y][x]==f[ny][nx]) continue;
        auto [a,b]=dfs(ny,nx);
        sz+=a; cnt+=b;
    }
    return pi(sz,cnt);
}

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>H>>W;
    f.resize(H);
    rep(i,H) cin>>f[i];

    ll ans=0;

    rep(i,H)rep(j,W){
        if (!seen[i][j]){
            auto [sz,b]=dfs(i,j);
            ans+=(ll)(sz-b)*b;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 18848
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>
#include <iomanip>

using namespace std;

int n, m, x, y;

int main() {

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

	cin >> n >> m >> x >> y;

	double ans = 1.0 * n * m / 2;

	cout<<fixed<<setprecision(10) << ans << " ";

	if (x+x == n && y+y == m)
		cout << 1 << endl;
	else
		cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<string>
#include<vector>
#include<iostream>
 
using namespace std;
 
int main()
{
    int n, r;
    while(cin >> n >> r){
        if(n==0 && r==0) break;
        vector<int> huda;
        for(int i=0;i<n;i++){
            huda.push_back(n-i);
        }
        /*
		for(int i=0;i<n;i++){
            cout<<huda[i]<<endl;
        }
        cout<<endl;
		*/
        for(int i=0;i<r;i++){
            int p, c;
            cin >> p >> c;
            vector<int> temp;
            for(int j=0;j<c;j++){
				temp.push_back(huda[p-1+j]);
            }
            /*
			cout<<"temp"<<endl;
            for(int i=0;i<temp.size();i++){
                cout<<temp[i]<<endl;
            }
            cout<<endl;
            */
            for(int j=c-1;(p-1+j-c)>=0;j--){
				//cout << p-1+j << " " << p-1+j-c <<endl;
				huda[p-1+j]=huda[p-1+j-c];
			}
            //cout <<endl;
            for(int j=0;j<c;j++){
                huda[j]=temp[j];
            }
            /*
			for(int i=0;i<n;i++){
				cout<<huda[i]<<endl;
			}
	        cout <<endl;
			*/
        }
        /*
        for(int i=0;i<n;i++){
            cout<<huda[i]<<endl;
        }
        cout <<endl;
        */
        cout << huda[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    int n, m, c[200100] = {};
    bool ans = false;

    cin >> n >> m;
    REP(i, m)
    {
        int a, b;
        cin >> a >> b;

        if (a == 1 || a == n)
        {
            if (c[b] == 1)
            {
                ans = true;
                break;
            }

            c[b]++;
        }
        if (b == 1 || b == n)
        {
            if (c[a] == 1)
            {
                ans = true;
                break;
            }

            c[a]++;
        }
    }

    cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;

    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

int N, M;
int a[1050], b[1050], c[1050][20];

void input() {
    cin >> N >> M;
    for(int i = 1; i <= M; i++) {
        cin >> a[i] >> b[i];
        for(int j = 1; j <= b[i]; j++) cin >> c[i][j];
    }
}

void solve() {
    input();
    const int INF = 1e9;
    vector<int> dp(5000, INF);
    dp[0] = 0;
    for(int item = 1; item <= M; item++) {
        int now = 0;
        for(int j = 1; j <= b[item]; j++) {
            now |= (1 << (c[item][j] - 1));
        }
        for(int bits = 0; bits < (1 << N); bits++) {
            chmin(dp[bits | now], dp[bits] + a[item]);
        }
    }
    if(dp[(1 << N) - 1] == INF) dp[(1 << N) - 1] = -1;
    cout << dp[(1 << N) - 1] << endl;
    return;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) begin(x), end(x)
#define SZ(x) (int)(x).size()
#define cps(x) sort(all(x)), (x).erase(unique(all(x)), end(x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int n0 = 2e5 + 123;
ll n, a[n0];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	ll mx = 0, ans = 0;
	for (int i = 1; i <= n; i++) {
		mx = max(mx, a[i]);
		ans += mx - a[i];
	}
	cout << ans;
}


Measured memory_bytes: 5180
N, M = list(map(int, input().rstrip().split()))

# students
st = []
for i in range(N):
    a, b = list(map(int, input().rstrip().split()))
    st.append((a, b))


# checpoints
ct = []
for i in range(M):
    c, d = list(map(int, input().rstrip().split()))
    ct.append((c, d))

for i in range(N):
    cp = 0
    dist = -1
    for j in range(len(ct) - 1, -1, -1):
        tmp = abs(st[i][0] - ct[j][0]) + abs(st[i][1] - ct[j][1])
        if dist < 0:
            cp = j + 1
            dist = tmp
        else:
            if tmp <= dist:
                cp = j + 1
                dist = tmp


    print(cp)



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

int main() {
	ll x,y;
  	cin>>x>>y;
  	ll count=0;
  	if(x>=0 && y>=0){
     	 if(x<=y) count=y-x;
      	 else if(y!=0) count=x-y+2;
      	 else count=x-y+1;
    }else if(x<0 && y<0){
    	if(x<=y) count=y-x; 
        else count=x-y+2;
    }else{
     	count=abs(x+y)+(x&&y);  
      	if(x==0 && y<0) count++;
    }
  	cout<<count<<endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 1000000007 
int p[100001];
int32_t main()
{
    fast;
    int n,m;
    cin>>n;
    int x;
    cin>>x;
    int ans=x;
    int mi=1;
    for(int i=1;i<n;i++)
    {
    	cin>>x;
    	if(x<=ans)
    	{
    		mi++;
    		ans=x;
    	}
    }

    cout<<mi;

}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

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

int getDistance(const vector<int>& x, const vector<int>& y, const int X, const int Y) {
    int distance = INT_MAX;
    for (const int v : x) distance = min(distance, abs(v - X));
    for (const int v : y) distance = min(distance, abs(v - Y));
    return distance;
}

void dfs(const ll N, const int i, vector<int>& x, vector<int>& y, unordered_set<int>& z,
        const std::vector<long long>& X,
        const std::vector<long long>& Y,
        const std::vector<long long>& P,
       vector<ll>& answer) {
    if (i >= N) {
        ll s = 0;
        for (const int k : z) {
            s += P[k] * getDistance(x, y, X[k], Y[k]);
        }
        answer[x.size() + y.size() - 2] = min(answer[x.size() + y.size() - 2], s);
        return;
    }
    x.push_back(X[i]);
    z.erase(i);
    dfs(N, i+1, x, y, z, X, Y, P, answer);
    z.insert(i);
    x.pop_back();

    y.push_back(Y[i]);
    z.erase(i);
    dfs(N, i+1, x, y, z, X, Y, P, answer);
    z.insert(i);
    y.pop_back();

    dfs(N, i+1, x, y, z, X, Y, P, answer);
}

void solve(long long N, std::vector<long long> X, std::vector<long long> Y, std::vector<long long> P){
//    N = 15;
//    X = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
//    Y = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
//    P = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};

    vector<int> x = {0}, y = {0};
    unordered_set<int> z;
    rep(i, 0, N) z.insert(i);
    vector<ll> answer(N+1, LLONG_MAX);
    dfs(N, 0, x, y, z, X, Y, P, answer);
    ll minS = LLONG_MAX;
    rep(i,0,N+1) {
        minS = min(minS, answer[i]);
        cout << minS << endl;
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    std::vector<long long> Y(N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&Y[i]);
        scanf("%lld",&P[i]);
    }
    solve(N, std::move(X), std::move(Y), std::move(P));
    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

//ユークリッドの互除法
unsigned gcd(unsigned a, unsigned b)
{
    if (a < b)
    {
        gcd(b, a);
    }

    unsigned r;

    while ((r = a % b))
    {
        a = b;
        b = r;
    }

    return b;
}

int r[100001], l[100001], a[100001];

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

    //li 1~iまでの最大公約数
    l[1] = a[1];
    for (int i = 2; i <= n; i++)
    {
        l[i] = gcd(l[i - 1], a[i]);
    }

    //ri n~iまでの最大公約数
    r[n] = a[n];
    for (int i = n - 1; i > 0; i--)
    {
        r[i] = gcd(r[i + 1], a[i]);
    }

    //番兵
    l[0] = 0;
    r[n + 1] = 0;

    int res = 0;
    for (int i = 1; i <= n; i++)
    {
        int tmp;
        if (l[i - 1] == 0 || r[i + 1] == 0)
        {
            tmp = l[i - 1] + r[i + 1];
        }
        else
        {
            tmp = gcd(l[i - 1], r[i + 1]);
        }
        res = max(res, tmp);
    }
    cout << res;
}

Measured memory_bytes: 1408
import sys
from collections import defaultdict


def reverse_search(n, parents):
    q = [n - 1]
    visited = set()
    while q:
        v = q.pop()
        if v in visited:
            continue
        visited.add(v)
        q.extend(u for u in parents[v] if u not in visited)
    return visited


n, m, p = list(map(int, input().split()))
INF = 10 ** 12
links = [set() for _ in range(n)]
parents = [set() for _ in range(n)]
costs = [defaultdict(lambda: INF) for _ in range(n)]
for line in sys.stdin:
    a, b, c = map(int, line.split())
    a -= 1
    b -= 1
    links[a].add(b)
    parents[b].add(a)
    costs[a][b] = min(costs[a][b], p - c)
reachable = reverse_search(n, parents)

dist = [INF] * n
dist[0] = 0
for _ in range(len(reachable)):
    updated = False
    for v in reachable:
        d = dist[v]
        if d == INF:
            continue
        cv = costs[v]
        for u in links[v]:
            if dist[u] > d + cv[u]:
                dist[u] = d + cv[u]
                updated = True
    if not updated:
        break
else:
    print(-1)
    exit()

print(max(0, -dist[n - 1]))


Measured memory_bytes: 54020
n = int(input())
l = [list(map(int, input().split())) for i in range(n)]
#print(l[0][0])
#print(l[0][1])
ans = n-2
ans1 = 0

for m in range(ans):
  if l[m][0]  == l[m][1] and l[m+1][0] == l[m+1][1] and l[m+2][0] == l[m+2][1]:
    ans1 += 1
 
    
    
if ans1 >= 1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 8980
import java.util.Calendar;
import java.util.Locale;
import java.util.Scanner;

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

            Calendar calendar = Calendar.getInstance();
            calendar.set(2017, Calendar.SEPTEMBER, X);
            System.out.println(calendar.getDisplayName(
                Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.ENGLISH).toLowerCase());
        }
    }
}



Measured memory_bytes: 27412
#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;
using ll = long long;
using P = pair<int,int>;


int main() {
  int n;
  cin >> n;
  map<string, int> mp;
  REP(i,n){
    string s;
    cin >> s;
    mp[s]++;
  }

  int mx = 0; //ｍｘ：　最大の投票数
  for(auto p : mp) mx = max(mx, p.second);
  for(auto p : mp) {
    if(p.second != mx) continue;
    cout << p.first << endl;
  }

  return 0;

}

Measured memory_bytes: 19112
from heapq import *

N=int(input())
A=[int(input()) for i in range(N)]
h=[]
for i in A:
    heappush(h, -i)
maxh = -heappop(h)
secondh = -heappop(h)
for i in A:
    print(maxh if i != maxh else secondh)


Measured memory_bytes: 73432
#include<stdio.h>
int main(void)
{
	int a,b,c;

	scanf("%d %d %d", &a, &b, &c);

	if (a < b&&b < c)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
#define FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ull unsigned long long
#define ll long long
#define ld long double
#define PSET(x,y) fixed<<setprecision(y)<<x
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define lop(i,a,b) for(ll i=a;i<b;i++)
#define lopr(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define ff first		
#define ss second
#define pi pair<int,int>
#define pll pair<ll, ll>
#define ti tuple<int,int>
#define tll tuple<ll, ll>
#define si set<int>
#define sll set<ll>
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll>,greater<ll>>
#define state tuple<int,int,int>
#define graph map<ll,list<ll>>

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ld PI = asin(1) * 2;
inline int sbt(int x){return __builtin_popcount(x);} //returns number of set bits

using namespace std;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1<<" | ";
        __f(comma+1, args...);
    }
#else
#define deb(...)
#endif

const ll SIZE = 0;

int main(){
    // clock_t tStart = clock();
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    
    FastIO
    
    int a,b,t;
    cin>>a>>b>>t;

    cout<<floor(t/a)*b;

    // printf("Time taken: %.6fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = [0]
    for i in a:
        if i == b[-1]+1:
            b.append(i)
    c = len(a)-len(b[1:])
    print(-1 if c == len(a) else c)
        
if __name__ == '__main__':
    main()

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

int main()
{
  string s, t;
  cin >> s >> t;
  int i, j;
  bool ac = true;
  for(i = 0; i < s.length(); i++)
  {
    ac = true;
    for(j = 0; j < s.length(); j++)
    {
      if(s.at((j+i)%s.length()) != t.at(j))
      {
        ac = false;
        break;
      }
    }
    if(ac == true) break;
  }
  if(ac == true) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
  
  int N, K, X;
  cin >> N >> K;
  X = 1;
//  cout << "N:" << N << endl;
//  cout << "K:" << K << endl;
//  cout << "X:" << X << endl;
    
  for(int i = 0; i < N; i++) {
    if(X < K) {
      X *= 2;
    }
    else {
      X += K;
    }
  }
  cout << X << endl; 
}

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

int main(){
    string s;

    cin >> s;

    int c = 0;

    for(int i = 0; i < s.size() / 2; ++i){
        if(s[i] != s[s.size() - 1 - i]) c++;
    }

    cout << c << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n),b(n),c(n);
  rep(i,n){ cin>>a[i]; } sort(a.begin(),a.end());
  rep(i,n){ cin>>b[i]; } sort(b.begin(),b.end());
  rep(i,n){ cin>>c[i]; } sort(c.begin(),c.end());
  ll ans=0;
  rep(i,n){
    ll ita = lower_bound(a.begin(),a.end(),b[i]) -a.begin();
    ll itc = c.end()-upper_bound(c.begin(),c.end(),b[i]);
    ans += ita*itc;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2688
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll h, w, H, W;
  scanf("%lld%lld%lld%lld", &h, &w, &H, &W);
  printf("%lld\n", h * w - ((H * w + W * h) - H * W));
  return 0;
}


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

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

int dmin = 10000;
for (int i = 0; i < N; i++)
{
  int d = 0;
  while (A[i] % 2 == 0)
{
  A[i]/= 2;
  d++;
}
  if (dmin > d)
  {
    dmin = d;
  }
  
}

cout << dmin << endl;
 
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define F first
#define s second
#define int long long
int z[1919][1919];		
signed main(){
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	rep(0,i,h){
		rep(0,j,w){
			if(i<b&&j<a)z[i][j]=1;
			else if(i>=b&&j>=a)z[i][j]=1;
		}
	}
	rep(0,i,h){
		rep(0,j,w){
			cout<<z[i][j];
		}
		cout<<endl;
	}				
}						

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

#define REP(i,n) for(long long i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(long long i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

ll dp[102][200003];

int main(){
  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  REP(i, N){
    cin >> w[i] >> v[i];
  }

  REP(i, N){
    REP(j, W){
      dp[i+1][j] = dp[i][j];
    }
    REP(j, W){
      dp[i+1][j+w[i]] = max(dp[i+1][j+w[i]], dp[i][j]+v[i]);
    }
  }
  ll ans = 0;
  REP(i, W+1){
    ans = max(ans, dp[N][i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 156416
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

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

    vl v0(n), v1(n);
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        v0[i] = x - y;
        v1[i] = x + y; 
    }

    sort(all(v0));
    sort(all(v1));
    
    out(max(v0[n-1] - v0[0], v1[n-1] - v1[0]));
    re0;
}

Measured memory_bytes: 6328
S = gets.chomp.chars

def count(list, first_color)
  color = first_color
  count = 0
  S.each do |c|
    count += 1 if c != color
    color = color == '0' ? '1' : '0'
  end
  count
end

ans = [count(S, '0'), count(S, '1')].min
puts ans


Measured memory_bytes: 9468
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define N 2050
#define mo 924844033
#define ll long long
using namespace std;
int n,m,bz[N+N],a[N][N],tot=0;
ll f[N+N][N][2],jc[N],g[N],ans;
int main()
{
	scanf("%d%d",&n,&m);
	jc[0]=1;
	fo(i,1,n) jc[i]=(jc[i-1]*(ll)i)%mo;
	fo(i,1,n)
	{
		fo(j,0,1)
		if(a[i][j]==0)
		{
			int ed=0;
			for(int x=i,y=j;x<=n;x+=m,y^=1) a[x][y]=1,ed++;
			bz[tot+=ed]=1;
		}
	}
	f[1][0][0]=1;
	fo(i,1,tot)
	{
		fo(j,0,n)
		{
			f[i+1][j][0]=(f[i][j][1]+f[i][j][0])%mo;
			if(!bz[i]) f[i+1][j+1][1]=f[i][j][0]; 
		}
	}
	fo(i,0,n) g[i]=(f[tot][i][0]+f[tot][i][1])%mo;
	ans=jc[n];
	ll j=-1;
	fo(i,1,n)
	{
		ans=(ans+g[i]*jc[n-i]*j%mo+mo)%mo;
		j=-j;
	}
	printf("%lld\n",ans);
}

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

int main()
{
  int64_t N, cnt = 0;
  cin >> N;
  vector<int64_t> A(N), S(N + 1, 0);
  map<int64_t, int64_t> nums;
  for (int i = 0; i < N; i++)
    cin >> A.at(i);
  for (int i = 0; i < N; i++)
    S.at(i + 1) = S.at(i) + A.at(i);
  for (int i = 0; i <= N; i++)
    nums[S.at(i)]++;
  for (auto num : nums)
  {
    int64_t n = num.second;
    cnt += n * (n - 1) / 2;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    ll y = min(a, k);
    ans += y;
    k -= y;
    y = min(b, k);
    k -= y;
    cout << ans - k << endl;

    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long a,b,c,x,tot=0;
cin>>a>>b>>c>>x;
for(long long i=0;i<=a;i++){
	for(long long j=0;j<=b;j++){
		for(long long k=0;k<=c;k++){
			long long qq=i*500+j*100+k*50;
			if(qq==x){
				tot++;
			}
			if(qq>x)
			{
			break;	
			}
		}
	}
}
cout<<tot<<endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
	
const ll siz = 1e5 + 10;
const ll mod = 1e9 + 7;
const ll MAXX = 1e18; 

ll n;
map<ll, bool> check;

//input
vector<ll> hold;
vector<ll> alternate;
vector<ll> dis;

//tree
ll tree[4 * siz];

void update(ll pos) {
	for (ll i = pos; i <= 2 * siz; i += i & -i) {
		//cerr << pos << '\n';
		tree[i]++;
	}
}

ll get(ll pos) {
	ll ans = 0;
	for (ll i = pos; i; i -= i & -i) {
		ans += tree[i];
	}
	return ans;
}

void setAlte(ll num) {
	for (ll i = 1; i <= n; i++) {
		if (hold[i] < num) {
			alternate[i] = 0;
		}
		else {
			alternate[i] = 1;
		}
	}
	for (ll i = 1; i <= n; i++) {
		alternate[i] += alternate[i - 1];
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("INP.txt", "r", stdin);
	//freopen("OUT.txt", "w", stdout);
	cin >> n;
	hold.resize(n + 1);
	alternate.resize(n + 1);
	for (ll i = 1; i <= n; i++) {
		cin >> hold[i];
		if (!check[hold[i]]) {
			check[hold[i]] = true;
			dis.push_back(hold[i]);
		}
	}
	ll tar = n * (n + 1) / 2;
	tar /= 2;
	dis.push_back(0);
	sort(dis.begin(), dis.end());
	ll le = 1, ri = dis.size() - 1;
	ll ans = 0;
	while (le <= ri) {
		//cerr << le << ' ' << ri << '\n';
		ll mid = (le + ri) / 2;
		ll num = dis[mid];
		setAlte(num);
		update(siz);
		ll cnt = 0;
		for (ll i = 1; i <= n; i++) {
			cnt += get(2 * alternate[i] - i + siz);
			update(2 * alternate[i] - i + siz);	
		}
		if (cnt >= tar) {
			ans = max(ans, num);
			le = mid + 1;
		}
		else {
			ri = mid - 1;
		}
		memset(tree, 0, sizeof(tree));
	}
	cout << ans << '\n';
	return 0; 	
} 	

Measured memory_bytes: 12020
package main

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

func main() {
	sc := NewScanner()

	k := sc.ReadInt()

	q := make([]int64, 9)
	for i := range q {
		q[i] = int64(i + 1)
	}

	cur := 0
	for {
		n := q[cur]
		cur++
		if cur >= k {
			fmt.Println(n)
			return
		}

		base := n * 10
		mostRight := n % 10
		if mostRight > 0 {
			q = append(q, base+mostRight-1)
		}
		q = append(q, base+mostRight)
		if mostRight < 9 {
			q = append(q, base+mostRight+1)
		}
	}
}

// util
// *   math(int)

func AbsInt(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func MinInt(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func MaxInt(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func PowInt(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   math(int)

func AbsInt64(x int64) int64 {
	if x >= 0 {
		return x
	}
	return -x
}

func MinInt64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func MaxInt64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func PowInt64(base int64, exponent uint) int64 {
	answer := int64(1)
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// * io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 10624
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define VECCIN(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int N, K;
    cin >> N >> K;
    int ans = INF;
    REP(i, N + 1) {
        int cur = 1;
        int cnt = 0;
        while (cnt < i) {
            cnt++;
            cur *= 2;
        }
        cur += K * (N - cnt);
        ans = min(ans, cur);
    }

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

Measured memory_bytes: 256
n,k = map(int,input().split())
mod = 10**9+7
s = ((n*(n+1)//2+1)*(n-k+1))%mod
for i in range(k,n+1):
  s = (s - (n-i)*(n-i+1)//2)%mod
  s = (s - i*(i-1)//2)%mod
print((s+1)%mod)

Measured memory_bytes: 63424