akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
using namespace std;

struct Sq
{
	unsigned long xmax;
	unsigned long li;
};

int main()
{
	string st;
	long a = 0, hmax = 0;
	vector<long> h = { 0 };
	vector<Sq> S = { Sq{0, 0} };

	cin >> st;

	for (unsigned long i = 0; i < st.size(); i++) {

		switch (st[i]) {
			case '/':
				if (h[i] == hmax)
					hmax++;
				else {
					for (unsigned long j = 0; j < i + 1; j++) {
						if (h[h.size() - j - 1] == h[i] + 1) {
							if (S.back().xmax !=0 && (S.back().xmax < i - j + 1))
								S.push_back(Sq{ i , j});
							else if (S.size() > 1 && (S[S.size() - 2].xmax > i - j + 1)) {
								S.back().li += j;
								while (S.size() > 1 && (S[S.size() - 2].xmax > i - j + 1)) {
									S[S.size() - 2].li += S.back().li;
									S.pop_back();
								}
							}
							else{
								S.back().li += j;
								S.back().xmax = i;
							}
							break;
						}
					}
				}
				h.push_back(h[i] + 1);
				break;
			case '\\':
				h.push_back(h[i] - 1);
				break;
			case '_':
				h.push_back(h[i]);
				break;
		}
	}

	for (unsigned long i = 0; i < S.size(); i++)
		a += S[i].li;

	cout << a << endl;

	if (a > 0) {
		cout << S.size();
		for (unsigned long i = 0; i < S.size(); i++)
			cout << " " << S[i].li;
	}
	else
		cout << "0";

	cout << endl;

	return 0;
}

Measured memory_bytes: 3424
import java.util.Arrays;
import java.util.Scanner;

public class Main 
{

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(); //pieces
		int m = sc.nextInt(); //coordinates
		int[] dif = new int[m-1];
		int[] coor = new int[m];
		
		for(int i = 0; i < m; i++)
		{
			coor[i] = sc.nextInt();
		}
		Arrays.sort(coor);
		for(int i = 0; i < m-1; i++)
		{
			dif[i] = coor[i+1] - coor[i];
		}
		Arrays.sort(dif);
//		System.out.println(Arrays.toString(dif));
		
		int r = 0;
		for(int i = m-1-(n); i >= 0; i--)
		{
			r += dif[i];
		}
		System.out.println(r);
	}

}


Measured memory_bytes: 61000
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i = 0; i < n; i++)
int m;
ll l, a, b, maxs;
struct mat{
    ll d[3][3] = {};
    mat operator*(const mat &a){
        mat res;
        rep(i,3) rep(j,3) rep(k,3) (res.d[i][j] += d[i][k] * a.d[k][j]) %= m;
        return res;
    }
} ans = {{{1,0,0},{0,1,0},{0,0,1}}};
int main(){
    scanf("%lld%lld%lld%d", &l, &a, &b, &m);
    maxs = a + b*(l-1);
    for(ll t = 10;1; t *= 10){
        if(t <= a) continue;
        ll sz = (min(maxs, t-1) - a) / b - (max(t/10, a) - 1 - a + b) / b + 1;
        for(mat c={{{t%m,0,0},{1,1,0},{0,b%m,1}}}; sz; sz/=2, c=c*c)if(sz&1)ans=ans*c;
        if(maxs < t) break;
    }
    printf("%lld\n", (a%m*ans.d[1][0] + ans.d[2][0])%m);
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(){
    int n,k,h,ans=0;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&h);
        if(h>=k){
            ans++;
        }
    }
    printf("%d\n",ans);
}

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

using namespace std;

int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	s1[0] = toupper(s1[0]);
	s2[0] = toupper(s2[0]);
	s3[0] = toupper(s3[0]);
	cout << s1[0] << s2[0] << s3[0];
	return 0;
}

Measured memory_bytes: 256
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: x,y,a,b


    read*, x,y

    do a=0,x
        b = x-a
        if (2*a+4*b == y) then
            print'(a)', 'Yes'
            stop
        end if
    end do
    print'(a)', 'No'

end program main

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int N;
    cin >> N;
    vector<vector<ld>> dp(N + 1, vector<ld>(N + 1, 0));
    dp[0][0] = 1;
    for (int i = 1; i <= N; i++)
    {
        ld p;
        cin >> p;
        dp[i][0] = dp[i - 1][0] * (1.0 - p);
        for (int j = 1; j <= i; j++)
        {
            dp[i][j] += dp[i - 1][j - 1] * p;
            dp[i][j] += dp[i - 1][j] * (1.0 - p);
        }
    }
    ld res = 0;
    for (int i = 0; i <= N; i++)
    {
        if (i <= N - i)
            continue;
        res += dp[N][i];
    }
    cout << fixed << setprecision(10) << res << endl;
}


Measured memory_bytes: 141056
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	M := sc.NextInt()
	check := func(c int) bool {
		v := M - 2*c
		if v < 0 {
			return false
		}

		k := c - N
		if k <= 0 {
			return true
		}
		if v/2 >= k {
			return true
		}
		return false
	}
	r := N + M
	l := 0
	for r-l > 1 {
		c := (l + r) / 2
		if check(c) {
			l = c
		} else {
			r = c
		}
	}
	fmt.Println(l)
}

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

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

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

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

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

	return mp
}

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


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,d,x;

int main(){
    cin >> n >> d >> x;
    ll ans = x;
    rep(i,n){
        ll a; cin >> a;
        ans += ((d-1)/a + 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#define INF 1e9
using namespace std;
char s[200005];
int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",s+1);
	int cnt=0;
	for(int i=1;i<=strlen(s+1);i++){
		if(s[i]=='R')cnt++;	
	}
	int ans=0;
	for(int i=1;i<=cnt;i++){
		if(s[i]=='W')ans++;
	}
	printf("%d",ans);
	return 0;
}


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

using namespace std;
const int N = 1e5+7;

int w[N],v[N];
long long dp[N];

int main()
{
	int n,W;
	cin>>n>>W;
	for(int i=1;i<=n;i++) cin>>w[i]>>v[i];
	
	for(int i=1;i<=n;i++){
		for(int j = W;j >= w[i];j --){  //选 
			dp[j] = max(dp[j-w[i]]+v[i],dp[j]);
		}
	}
	cout<<dp[W];
	return 0;
} 

Measured memory_bytes: 4360
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n string
	fmt.Scan(&n)
	if strings.HasSuffix(n, "2") ||
		strings.HasSuffix(n, "4") ||
		strings.HasSuffix(n, "5") ||
		strings.HasSuffix(n, "7") ||
		strings.HasSuffix(n, "9") {
		fmt.Println("hon")
	} else if strings.HasSuffix(n, "0") ||
		strings.HasSuffix(n, "1") ||
		strings.HasSuffix(n, "6") ||
		strings.HasSuffix(n, "8") {
		fmt.Println("pon")
	} else {
		fmt.Println("bon")
	}
}


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

#define fr first
#define sc second
#define mk make_pair

using namespace std;

int n;

int main()
{
    cin >> n;
    int ans = n;
    for(int i = 1; i <= n; i++)
    {
        if(i * 1ll * (i + 1) / 2 >= n)
        {
            ans = i;
            break;
        }
    }

    vector<int> vec;

    for(int i = ans; i > 0; i--)
    {
        if(n >= i)
            n -= i, vec.push_back(i);
    }

    for(int i = vec.size() - 1; i >= 0; i--)
    {
        cout << vec[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 384
A, B, AB, O = 0, 0, 0, 0
while True:
    try: n = input().split(',')
    except: break
    
    if n[-1] == 'A':
        A += 1
    elif n[-1] == 'B':
        B += 1
    elif n[-1] == 'AB':
        AB += 1
    elif n[-1] == 'O':
        O += 1

print('{}\n{}\n{}\n{}'.format(A, B, AB, O))
    



Measured memory_bytes: 5568
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] x=new int[n];
		int[] y=new int[n];
		long[] h=new long[n];
		int t=0;
		for(int i=0; i<n; i++){
			x[i]=sc.nextInt();
			y[i]=sc.nextInt();
			h[i]=sc.nextLong();
			if(h[i]!=0){
				t=i;
			}
		}
		for(int i=0; i<=100; i++){
			for(int j=0; j<=100; j++){
				long H=h[t]+Math.abs(x[t]-i)+Math.abs(y[t]-j);
				boolean ch=true;
				for(int k=0; k<n; k++){
					if(h[k]!=Math.max(H-Math.abs(x[k]-i)-Math.abs(y[k]-j),0)){
						ch=false;
						break;
					}
				}
				if(ch){
					System.out.println(i+" "+j+" "+H);
					return;
				}
			}
		}
	}
}


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

int main() {
  int N, M, L; cin >> N >> M;
  
  for(int i=0; i<M; i++) {
    cin >> L;
    N = __gcd(L, N);
  }
  
  if(N == 1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
  return 0;
}

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

int main(){
    int n,k;
    cin >> n>>k;
    int ans=1;
    for(int i=0;i<n;i++){
        if(ans<k)
        ans*=2;
        else
        ans+=k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    string S;
    int N, cnt = 0;
    cin >> N >> S;
    for (int i = 0; i < 1000; i++) {
        int c[3] = {i / 100, (i / 10) % 10, i % 10};
        int f = 0;
        for (int j = 0; j < N; j++) {
            if (S[j] == ('0' + c[f])) f++;
            if (f == 3) break;
        }
        if (f == 3) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = map(int, input().split())
c = Counter(a)
q,r = divmod(n, 2)
if r:
    b = [c[0] == 1]
    for i in range(1,q+1):
        b.append(c[i*2] == 2)
    if all(b):
        print(2**q%(10**9+7))
    else:
        print(0)
else:
    b = []
    for i in range(q):
        b.append(c[i*2+1] == 2)
    if all(b):
        print(2**q%(10**9+7))
    else:
        print(0)

Measured memory_bytes: 16624
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  vt<int> m(5);
  int num = 0, k = 9;
  rep(i,5) {
    std::cin >> m[i];
    if(k > m[i]%10 && m[i]%10 != 0){
      k = m[i]%10;
      num = i;
    }
  }

  int ans = 0;
  rep(i,5) {
    if(i == num)
      continue;
    else if(m[i]%10 != 0)
      m[i] += 10 - (m[i]%10);
    ans += m[i];
  }

  std::cout << ans + m[num] << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
#define SET(a,c) memset(a,c,sizeof(a))

#define DEBUG(x) cout<< #x <<": "<<x<<endl

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll INF = INT_MAX/3;
const ll MOD = 1000000007;
const double EPS = 1e-14;
const int dx[] = {1,0,-1,0} , dy[] = {0,1,0,-1};

int search(int x,int y,vector< pair<int,int> > &xs){
    int dxy[] = {-1,0,1};
    int s = 0;
    REP(i,3)REP(j,3){
        int nx = x + dxy[i];
        int ny = y + dxy[j];
        auto p = lower_bound(ALL(xs),MP(nx,ny));
        if( *p == MP(nx,ny) ){
            s++;
        }
    }
    return s;

}

int main(){
    ll H,W,N;
    cin >> H >> W >> N;
    vector<pair<int,int> > ab(N);
    vi a(N),b(N);
    REP(i,N){
        scanf("%d %d",&ab[i].second,&ab[i].first);
        ab[i].first--;
        ab[i].second--;
        a[i] = ab[i].second;
        b[i] = ab[i].first;
    }
    ab.PB(MP(-2,-2));
    ab.PB(MP(INF,INF));
    sort(ALL(ab));

    vl ans(10);
    REP(i,10) ans[i] = 0;
    int dxy[] = {-1,0,1};
    set< pair<int,int> > used;
    REP(i,N){
        REP(j,3)REP(k,3){
            int nx = b[i] + dxy[j];
            int ny = a[i] + dxy[k];
            if( nx < 1 || ny < 1 || nx+1>=W||ny+1>=H){
                continue;
            }else if( used.find(MP(nx,ny))!=used.end() ){
                continue;
            }else{
                int ret = search(nx,ny,ab);
                ans[ret]++;
                used.insert(MP(nx,ny));
            }
        }
    }
    ans[0] = (H-2)*(W-2) - ll(used.size());

    REP(i,10){
        cout << ans[i] << endl;
    }
    return 0;
}




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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)


typedef long long ll;
typedef unsigned long long int llt;

const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

string ans ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ans += to_string(x);
     return;
}

llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}



int main()
{
  set<int> ss;
  rep(i, 0, 3) {
    int a;
    cin>>a;
    ss.insert(a);
  }
  cout<<ss.size()<<endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int ans = 1, flag = 0;
  for (int i = 1; i < N; i++) {
    if (flag == 0 && A[i-1] < A[i]) {
      flag = 1;
    } else if (flag == 0 && A[i-1] > A[i]) {
      flag = -1;
    } else if (flag == 1 && A[i-1] > A[i]) {
      flag = 0;
      ans++;
    } else if (flag == -1 && A[i-1] < A[i]) {
      flag = 0;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
from math import sqrt
n, d = map(int, input().split())
lst = []
cnt = 0
for i in range(n):
    a = tuple(map(int, input().split()))
    lst.append(a)
for i in range(n-1):
    for j in range(i+1, n):
        x = 0
        for k in range(d):
            x += (lst[i][k]-lst[j][k])**2
        length = sqrt(x)
        if length%1 == 0:
            if length != 0:
                cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int main(){
	int k,i;
	string s;
	cin>>s;
	k=0;
	for(i=0;i<s.size();i++){
		if(s[i]=='+')
			k++;
		else k--;
	}
	cout<<k;
	return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int N, K;
  cin >> N >> K;
  Vl H(N);
  REP(i, N) cin >> H.at(i);
  sort(H.begin(), H.end(), greater<ll>());
  REP(j, min(K, N)) H.at(j) = 0;
  ll ans = 0;
  for (auto a : H) ans += a;
  cout << ans << endl;
}

Measured memory_bytes: 1792
main = do
  [n, a, b] <- (map (read :: String -> Int) . words) <$> getLine
  print $ solve n a b

solve n a b
  | n <= a = n
  | n <= a+b = a
  | otherwise = let (p, q) = n `divMod` (a+b) in p*a + solve q a b

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  int64_t x;
  cin >> x;
  int64_t t=100;
  int ans=0;
  while(t<x){
    t=t+t/100;
    ans ++;
  }
  cout << ans << endl; 
}

Measured memory_bytes: 3632
#include <iostream>
#include<string>
using namespace std;
int piza(int n){
    int sum=0;
    while(n>0){
        sum=sum+n%10;
        n=n/10;
    }
    return sum;
}

int main(){
    int N,A,B;
    cin>>N>>A>>B;
    int total=0;
    for(int i=1; i<=N; i++){
        int sum = piza(i);
        if(sum>=A&&sum<=B){
            total=total+i;
        }
        
    }
    cout<<total<<endl;
}

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

using namespace std;

#define ll long long
#define endl '\n'

const double pi = std::acos(-1);

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double deg = abs(h * 30 + m / 2 - 6 * m);
    double c = sqrt(a * a + b * b - 2 * a * b * cos(deg * pi / 180));

    cout << fixed << setprecision(20) << c << endl;

    return 0;
}


Measured memory_bytes: 4240
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import numpy as np


n = int(input())
U = 3500
for x in range(1, U+1):
    y = np.arange(1, U+1, dtype=np.int64)
    den = 4 * x * y - n * x - n * y
    num = n * x * y
    y = y[(num % den == 0) & (den > 0)]
    if len(y) > 0:
        y = y[0]
        z = (n * x * y) // (4 * x * y - n * x - n * y)
        break
print(x, y, z)


Measured memory_bytes: 27504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 100500;
ll n,k,q,point[N];

int main() {
   scanf("%lld%lld%lld" , &n , &k , &q);
   for (ll i = 1 ; i <= n ; i++) point[i] = k;
   for (ll i = 0 ; i < q ; i++) {
      ll x; scanf("%lld" , &x);
      ++point[x];
   }
   for (ll i = 1 ; i <= n ; i++) {
      if (point[i] - q <= 0) {
         printf("No\n");
      } else {
         printf("Yes\n");
      }
   }
}


Measured memory_bytes: 1408
n=int(input())
l=list(map(int,input().split()))
sumlmin=[0]*n
sumlmin[1]=abs(l[1]-l[0])
for i in range(n-2):
    sumlmin[i+2]=min((sumlmin[i]+abs(l[i+2]-l[i])),(sumlmin[i+1]+abs(l[i+2]-l[i+1])))


print(sumlmin[n-1])

Measured memory_bytes: 52208
// D - Negative Cycle
#include <bits/stdc++.h>

using namespace std;

#define	INF	1e16

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);

	int n;
	cin >> n;
	vector<vector<long long> > a(n, vector<long long>(n));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (i != j) cin >> a[i][j];

	vector<vector<long long> > dp(n + 1, vector<long long>(n + 1, INF));
	dp[0][0] = 0;

	for (int i = 1; i <= n; i++) {
		vector<long long> x(i), y(i);
		for (int j = 1; j < i; j++) {
			for (int k = i + 1; k <= n; k++) x[j] += a[k - 1][j - 1];
			x[j] += x[j - 1];
		}
		for (int j = i - 1; j >= 0; j--) {
			for (int k = j + 1; k < i + 1; k++) y[j] += a[j][k - 1];
			if (j + 1 < i - 1) y[j] += y[j + 1];
		}
		for (int j = 0; j < i; j++)
			for (int k = 0; k < j + 1; k++)
				dp[i][j] = min(dp[i][j], dp[j][k] + x[j] - x[k] + y[j]);
	}

	cout << *min_element(dp[n].begin(),dp[n].end()) << endl;

	return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< int, int >   cp2;
typedef pair< int, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789


 

///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////



priority_queue< cp3, vector<cp3>, greater<cp3> >p;
cp3 now;

int g[112];

int find( int key ){
	//cout<<key<<" "<<g[key]<<endl;
	if( g[key] < 0 ) return key;
	return g[key] = find( g[key] );
}

void unite( int x, int y ){
	x = find( x );
	y = find( y );
	if( x == y ) return;
	
	if( g[x] < g[y] ) swap( x, y );
	if( g[x] == g[y] ) g[y]--;//??±??????x???????????????
	//g[y] += g[x];		 //????????°???x??????????°???????
	g[x] = y;
}

int a[112][112];
int N;
int ans = 0;

int main(){
	
	cin>>N;
	
	fill( g, g+112, -1 );
	
	
	REP( i, N ){
		REP( j, N ){
			scanf("%d",&a[i][j]);
			if( a[i][j] != -1 ){
				p.push( cp3( a[i][j], cp2(i, j) ) );
				//printf("%d %d %d\n",p[idx].fi, p[idx].sec, p[idx].thr);
				
			}
		}
	}
	
	while( !p.empty() ){
		now = p.top();
		p.pop();
		
		if( find(now.sec) != find(now.thr) ){
			unite( now.sec, now.thr );
			ans += now.fi;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;

}

Measured memory_bytes: 3272
#include<stdio.h>
int main()
{
   int h,w,n,i,a;
   scanf("%d%d%d",&h,&w,&n);
   if(h>=w)i=h;else i=w;
   if(n%i==0)a=n/i;
   else a=n/i+1;
   printf("%d",a);
   return 0;
}
   


Measured memory_bytes: 128
//パソコン甲子園2010 問題番号01 水道料金を節約しよう
#include<stdio.h>

int main(void){

	int w, sum, lm;

	scanf("%d",&w);

	while(w != -1){

		lm = 4280;
		sum = 1150;

		while(w > 10){

			if(w >= 31){
				sum += (w - 30) * 160;
				w -= (w - 30);
			}
			else if(w >= 21){
				sum += (w - 20) * 140;
				w -= (w - 20);
			}
			else if(w >= 11){
				sum += (w - 10) * 125;
				w -= (w - 10);
			}

		}

		lm -= sum;
		printf("%d\n",lm);
		scanf("%d",&w);

	}
	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  for(int i = 0; i < n; i++)
  {
    char a;
    cin >> a;
    if(a == 'Y')
    {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline


def make_prime_numbers(n):
    """n以下の素数を列挙したリストを出力する
    計算量: O(NloglogN)
    入出力例: 30 -> [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
    """
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(2 * i, n + 1, i):
            is_prime[j] = False
    prime_numbers = [i for i in range(n + 1) if is_prime[i]]
    return prime_numbers


n = int(input())
s = [int(input()) for i in range(n)]


primes = make_prime_numbers(int((10 ** 10) ** (1 / 3) + 20))
pow2 = set([i ** 2 for i in range(10 ** 5 + 10)])
to_anti = {}

# s[i] が立方数で割り切れるときは割る
for i in range(n):
    anti = 1
    tmp_s = s[i]
    for div in primes:
        cnt = 0
        while tmp_s % div == 0:
            tmp_s //= div
            cnt += 1
        mod_cnt = cnt % 3
        cnt = cnt - mod_cnt
        s[i] //= (div ** cnt)
        anti *= div ** ((3 - mod_cnt) % 3)
    if tmp_s in pow2:
        to_anti[s[i]] = anti * int(tmp_s ** 0.5)
    else:
        to_anti[s[i]] = anti * (tmp_s ** 2)

# key: s[i], val: 個数
cnts = {}
for key in s:
    if key not in cnts:
        cnts[key] = 0
    cnts[key] += 1

# 例えば、key = (2 ** 2) * (5 ** 1) と key = (2 ** 1) * (5 ** 2) は
# 片方しか選べないので、 cnts[key]が大きい方を選ぶと得する
ans = 0
used = set([])
for key in cnts:
    if key == 1:
        ans += 1
        continue
    if key in used:
        continue
    anti_key = to_anti[key]
    used.add(anti_key)
    if anti_key in cnts:
        ans += max(cnts[anti_key], cnts[key])
    else:
        ans += cnts[key]

print(ans)

Measured memory_bytes: 148116
package main

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

func main() {
	s := readString()
	t := readString()
	n := len(s)

	mapST := make(map[string]string)
	mapS := make(map[string]int)
	mapT := make(map[string]int)
	for i := 0; i < n; i++ {
		mapS[string(s[i])] = mapS[string(s[i])] + 1
		mapT[string(t[i])] = mapT[string(t[i])] + 1
		firstS, ok := mapST[string(s[i])]
		if !ok {
			mapST[string(s[i])] = string(t[i])
		} else {
			if firstS != string(t[i]) {
				fmt.Println("No")
				return
			}
		}
	}

	if len(mapS) != len(mapT) {
		fmt.Println("No")
		return
	}

	// for key := range mapS {
	// 	_, ok := mapT[key]
	// 	if !ok {
	// 		continue
	// 	}
	// 	if mapS[key] != mapT[key] {
	// 		fmt.Println("No")
	// 		return
	// 	}
	// }

	fmt.Println("Yes")
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

// 最大公約数
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

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

func comb(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7

	COMB_MAX = 510000
)

var (
	readString func() string
)

var (
	fac  = [COMB_MAX]int{}
	finv = [COMB_MAX]int{}
	inv  = [COMB_MAX]int{}
)

func init() {
	readString = newReadString(os.Stdin)
}

func combInit() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < COMB_MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


Measured memory_bytes: 3200
using System;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    public void Solve()
    {
        var sc = new Scanner();
        int N = sc.NextInt();
        int D = sc.NextInt();

        int l = D * 2 + 1;
        Console.WriteLine((N + l - 1) / l);
    }
}


class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private readonly StreamReader _stream;
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}


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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; ++i) {
    ans += to_string(i).size() % 2;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	int M;
	if(N == 3){
		M = 2;
	}else if(N % 2 == 0){
		M = N*(N-2)/2;
	}else{
		M = (N-1)*(N-3)/2 + (N-1);
	}
	cout << M << endl;
	
	if(N == 3){
		cout << "1 3" << endl;
		cout << "2 3" << endl;
		return 0;
	}
	
	if(N % 2 == 0){
		for(int i = 1; i <= N; i++){
			for(int j = i+1; j <= N; j++){
				if(i+j != N+1){
					cout << i << " " << j << endl;
				}
			}
		}
	}else{
		for(int i = 1; i <= N; i++){
			for(int j = i+1; j <= N; j++){
				if(i == N || j == N){
					cout << i << " " << j << endl;
				}
				else if(i+j != N){
					cout << i << " " << j << endl;
				}
			}
		}
	}
	
	return 0;
}

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

typedef unsigned long long ll;

int main()
{
    int n;
    int i,j,k;
    cin >> n;
    vector<int> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    ll ans = 1e8;
    ll tmp = 0;
    for(i = -100;i <= 100;++i){
        tmp = 0;
        for(j = 0;j < n;++j){
            tmp += (a.at(j)-i)*(a.at(j)-i);
        }
        if(tmp < ans){
            ans = tmp;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    a,b=map(int,input().split())
    if a==0 and b==0:break
    f=[[0 for i in range(b)]for j in range(a)]
    for i in range(a):
        for j in range(b):
            if i==0 or i==a-1 or j==0 or j==b-1:
                f[i][j]=1
    for i in range(a):
        for j in range(b):
            if f[i][j]==1:
                print('#',end='')
            else :
                print('.',end='')
        print()
    print()

Measured memory_bytes: 9400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll c[10002];
ll glid[101][101];
int main() {
	ll h,w,C;
	cin>>h>>w>>C;
	for(int i=0;i<C;i++){
		cin>>c[i];
	}
	ll k=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(c[k]==0){
				k++;
			}
			c[k]--;
			glid[i][j]=k+1;
		}
	}
	bool turn=false;
	for(int i=0;i<h;i++){
		if(turn==false){
			for(int j=0;j<w;j++){
				cout << glid[i][j]<< " ";
			}
		}
		else{
			for(int j=w-1;j>=0;j--){
				cout << glid[i][j]<<" ";
			}
		}
		cout << endl;
		if(turn){
			turn=false;
		}
		else{
			turn=true;
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> void mmax(T &m, const T q) { if (m < q) m = q; }
template<typename T> void mmin(T &m, const T q) { if (m > q) m = q; }
template<typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

const string YES = "Yes";
const string NO = "No";

int main()
{
    lint N;
    cin >> N;
    vector<lint> L(N);
    REP(i, N){ cin >> L[i]; }
    sort(L.begin(), L.end());
    if (accumulate(L.begin(), L.begin() + N - 1, 0LL) > L[N - 1]) cout << YES << endl;
    else cout << NO << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> V(N);
    rep(i,0,N)cin >> V[i];
    int cnt = 0;
    rep(i,0,N){
        if(V[i] != i+1)cnt++;
    }
    if(cnt > 2)cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

signed main(){
	int N;
	cin>>N;
	cout<<N*N*N<<endl;
	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if(d<a || b<c) cout << 0 << endl;
  else cout << min(min(min(abs(d-a),abs(b-a)),abs(d-c)),abs(b-c)) << endl;
  
  
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline #for input speed
sys.setrecursionlimit(10**7)


N, Q = map(int, input().split())
G = [[] for _ in range(N)]
P = [0 for _ in range(N)]

for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

for _ in range(Q):
    p, x = map(int, input().split())
    p -= 1
    P[p] += x


def dfs(current, parent):
    for child in G[current]:
        if child == parent:
            continue
        P[child] += P[current]
        dfs(child, current)


dfs(0, -1)

print(' '.join([str(p) for p in P]))


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    vector<int> c = {0};
    int pre = -1;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (a == pre)
            continue;
        c.push_back(a);
        pre = a;
    }
    n = c.size() - 1;
    vector<ll> ret(n + 1, 0);
    map<ll, ll> cnt;
    ret[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        ret[i] = (ret[i - 1] + cnt[c[i]]) % MOD;
        cnt[c[i]] = (cnt[c[i]] + ret[i - 1]) % MOD;
    }
    cout << ret[n] << endl;
}


Measured memory_bytes: 15092
use proconio::input;


fn solve(n: i64, mut x: i64, a: Vec::<i64>) -> i64 {
    let mut ans = 0;
    for i in 0..n as usize {
        x -= a[i];
        ans += 1;

        if x <= 0 {
            break;
        }
    }

    if x != 0 {
        ans -= 1;
    }

    return ans;
}


fn main() {
    input!{
        n: i64,
        mut x: i64,
        mut a: [i64; n],
    }

    a.sort();
    let ans = solve(n, x, a);

    // let mut ans = 0;
    // for i in 0..n as usize {
    //     x -= a[i];
    //     ans += 1;

    //     if x <= 0 {
    //         break;
    //     }
    // }

    // if x != 0 {
    //     ans -= 1;
    // }

    println!("{}", ans);
}


Measured memory_bytes: 2080
#include<iostream>
#include<vector>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    //int h[n];
    rep(i,n) cin >> h[i];
    int ans = 0;
    rep (i,n){
        if(h[i] >= k) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

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

    string Ans = "Yes";

    for(int i = 0; i < S.size(); i += 2){
        if(S.at(i) == 'L'){
            Ans = "No";
            break;
        }
    }
        for(int i = 1; i < S.size(); i += 2){
        if(S.at(i) == 'R'){
            Ans = "No";
            break;
        }
    }

    cout << Ans << endl;
}

Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b[ohara], c[ohara], d, tmp, m, h, w, x, y, sum, k, q;
V g[ohara];
map<P, ll> mp;
ll vi[ohara], dep[ohara];

void dfs(ll now, ll depp) {
  if (vi[now]) return;
  vi[now] = 1;
  dep[now] = depp;
  rep(i, Size(g[now])) {
    ll to = g[now][i];
    dfs(to, depp + mp[{now, to}]);
  }
}

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

  cin >> n;
  rep(i, n - 1) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    g[a[i]].p_b(b[i]);
    g[b[i]].p_b(a[i]);
    mp[{a[i], b[i]}] = c[i];
    mp[{b[i], a[i]}] = c[i];
  }
  cin >> q >> k;
  dfs(k - 1, 0LL);
  rep(i, q) {
    cin >> x >> y;
    x--;
    y--;
    Cout(dep[x] + dep[y]);
  }
  return 0;
}

Measured memory_bytes: 68096
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  for (int i = 0; i < M; ++i) {
    cin >> A[i];
  }
  int sum = 0;
  for (int i = 0; i < M; ++i) {
    sum += A[i];
  }
  if (sum > N) {
    cout << -1 << endl;
  } else {
    cout << N - sum << endl;
  }
  return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const double eps = 1e-9;

double f(double a, double b, double theta){
  if(theta > M_PI/2) return 0;
  if(b>=a*tan(theta)){
    return a*a*b - a*a*a*tan(theta)/2.0;
  }else return a*b*b*tan(M_PI/2-theta)/2.0;
  return 0;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  double a,b,x;cin >> a >> b >> x;
  double s = 0, e = M_PI/2+eps;
  while(e-s>eps){
    double m = (s+e)/2.0;
    if(f(a,b,m) > x) s = m;
    else e = m;
  }
  cout << 180*s/M_PI << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
inline int abs(int x) { return x < 0 ? -x : x; }
int arr[100005], seq[100005];
inline ll work(int n)
{
	int cur = 0;
	std::sort(arr, arr + n);
	for (int i = (n >> 1) - 1; i >= 0; i--) {
		seq[cur] = arr[i];
		cur += 2;
	}
	if (n & 1) {
		seq[cur] = arr[n >> 1];
	}
	cur = 1;
	for (int i = n - 1; i >= n + 1 >> 1; i--) {
		seq[cur] = arr[i];
		cur += 2;
	}
	ll ans = 0;
	for (int i = 0; i + 1 < n; i++) {
		ans += abs(seq[i] - seq[i + 1]);
	}
	return ans;
}
int main()
{
	// freopen("TPC2018-C.in", "r", stdin);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", arr + i);
	}
	ll ans = work(n);
	for (int i = 0; i < n; i++) {
		arr[i] *= -1;
	}
	printf("%lld\n", std::max(ans, work(n)));
	return 0;
}

Measured memory_bytes: 1024
r=range(int(input()))
u=[]
v=[]

for i in r:
  a,b=map(int,input().split())
  u+=[a+b]
  v+=[a-b]
  if u[0] % 2 != u[i] % 2:
    print(-1)
    exit()
    
d =[2**i for i in range(31)][::-1]
d+=[] if u[0] % 2 else [1]
print(len(d))
print(*d)

for i in r:
  x=""
  for j in d:
    fu = abs(u[i] + j) < abs(u[i] - j)
    fv = abs(v[i] + j) < abs(v[i] - j)
    u[i]+=[-j,j][fu]
    v[i]+=[-j,j][fv]
    x+='RUDL'[fu * 2 + fv]
  print(x)

Measured memory_bytes: 3188
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);
	string s; cin >> s;
	ll k; cin >> k;
	k--;
	for (int i = 0; i < (int)s.length(); i++)
	{
		if (s[i] == '1')
		{
			if (k == (ll)i)
			{
				cout << s[i] << endl;
				return 0;
			}
		}
		else
		{
			cout << s[i] << endl;
			return 0;
		}
	}
}

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

using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    if (N == 1) {
        cout << "Hello World" << endl;
    }
    else {
        int A, B;
        cin >> A >> B;
        cout << A + B << endl;
    }


    return 0;
}

Measured memory_bytes: 256