akhauriyash/Code-Regression huggingface dataset:
N, A, B = map(int, input().strip().split())

a, b, c, d, e = 0, 0, 0, 0, 0
ans = 0

for i in range(N+1):
    n = i

    a = n // 10000
    n = n -10000 * a
    
    b = n // 1000
    n = n -1000 * b

    c = n // 100
    n = n -100 * c

    d = n // 10
    n = n -10 * d

    e = n

    sum = a + b + c + d + e
    if sum >= A and sum <= B:
        ans += i

print(ans)

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

int main() {
  
  int N; cin >> N; int ans = 0;
  
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) cin >> vec[i];
  
  for (int i = 0; i < 101; i++) {
    
    int count = 0;
    
    for (int j = 0; j < N; j++) {
      
      if (0 < vec[j]) count++;
      
      else {
        if (0 < count) ans++;
        count = 0;
      }
      
      vec[j]--;
      
    }
    
    if (0 < count) ans++;
    
  }
  
  cout << ans << endl;
  
}

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

int main(void){
    int a,b;
    char op;
    cin >> a >> op >> b;
    while(op != '?'){
        if(op == '+'){
            cout << a+b << endl;
        }
        else if(op == '-'){
            cout << a-b << endl;
        }
        else if(op == '*'){
            cout << a*b << endl;
        }
        else if(op == '/'){
            cout << a/b << endl;
        }
        cin >> a >> op >> b;
    }
}


Measured memory_bytes: 3104
using System;

public class Test
{
	public static void Main( )
	{
		int n = int.Parse( Console.ReadLine() );
		int[] nums = new int[n+1];
		for( var i=0; i<n; i++ ) {
			nums[i] = int.Parse( Console.ReadLine() );
		}
	
		int cnt = n;
		for( var i=0; i<n; i++ ) {
			if( 2 == nums[i] || 3 == nums[i] ) { continue; }
			if( 0 == nums[i]%2 ) {
				cnt--;
				continue;
			}
			var max = Math.Sqrt( nums[i] );
			for( var j=3; j<=max; j+=2 ) {
				if( 0 == nums[i]%j ) {
					cnt--;
					break;
				}
			}
		}
		
		Console.WriteLine( cnt );
	}
}

Measured memory_bytes: 9184
from math import sqrt


def main():
    list1 = []
    for _ in range(int(input())):
        list1.append(int(input()))
    prime_number = [2]
    for i in range(3, int(sqrt(max(list1)))+1, 2):
        prime = True
        for j in prime_number[:]:
            if i % j == 0:
                prime = False
                break
        if prime:
            prime_number.append(i)
    for i in list1[:]:
        if i == 2:
            continue
        else:
            for j in prime_number:
                if i % j == 0:
                    list1.remove(i)
                    break
                elif j**2 >= i:
                    break
    print(len(list1))


if __name__ == "__main__":
    main()



Measured memory_bytes: 6004
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

template <class... Args>
struct tuple_input_impl;
template <std::size_t i, std::size_t... tail>
struct tuple_input_impl<std::index_sequence<i, tail...>>
{
    template <class... Args>
    static void f(std::tuple<Args...>& x)
    {
        std::cin >> std::get<i>(x);
        tuple_input_impl<std::index_sequence<tail...>>::f(x);
    }
};
template <>
struct tuple_input_impl<std::index_sequence<>>
{
    static void f(...) {}
};

template <class... Args>
std::istream& operator>>(std::istream& in, std::tuple<Args...>& x)
{
    tuple_input_impl<std::index_sequence_for<Args...>>::f(x);
    return in;
}

template <class T>
T read()
{
    T res;
    std::cin >> res;
    return res;
}
template <class T>
std::vector<T> read(std::size_t n)
{
    std::vector<T> res(n);
    for (std::size_t i = 0; i < n; ++i) std::cin >> res[i];
    return res;
}

template <class T, class... Args>
void out_impl(T&& v, Args&&... args)
{
    std::cout << std::forward<T>(v) << ' ';
    impl(std::forward<Args>(args)...);
}
template <class T>
void out_impl(T&& v) { std::cout << std::forward<T>(v); }
template <class... Args>
void out(Args&&... args)
{
    out_impl(std::forward<Args>(args)...);
    std::cout << '\n';
}
template <class... Args>
void out_noreturn(Args&&... args) { out_impl(std::forward<Args>(args)...); }

template <class T>
void print(const T& container)
{
    bool first = true;
    for (auto&& x : container) {
        if (!first) std::cout << ' ';
        std::cout << x;
        first = false;
    }
    std::cout << '\n';
}

void prog()
{
    int n, q;
    std::string s;
    std::cin >> n >> q >> s;
    std::vector<int> a(n + 1);
    for (auto i : boost::irange(0, n - 1)) {
        if (s[i] == 'A' && s[i + 1] == 'C') {
            a[i + 1] = a[i] + 1;
        } else {
            a[i + 1] = a[i];
        }
    }
    a[n] = a[n - 1];
    // print(a);
    for (auto i : boost::irange(0, q)) {
        int l, r;
        std::cin >> l >> r;
        out(a[r - 1] - a[l - 1]);
    }
}

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


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

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;
	cout << (n + 1) / 2 << endl;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n-1):
  if a[i]+a[i+1] >= k:
    print("Possible")
    x = i
    break
else:
  print("Impossible")
  exit()
if x == 0:
  print(*list(range(1,n))[::-1],sep="\n")
else:
  ans = list(range(1,n))
  ans[x:] = ans[n-1:x-1:-1]
  print(*ans,sep="\n")

Measured memory_bytes: 14060
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;
typedef pair<string, string> pss;

char field[100][100];
char num[100][100];
int dx[] = {-1,0,1,1,1,0 ,-1,-1 };
int dy[] = { 1,1,1,0,-1,-1,-1,0 };

int main()
{
	int h, w;
	cin >> h >> w;

	rep(i, h)cin >> field[i];

	rep(i, h) {
		rep(j, w) {
			int sum = 0;
			if (field[i][j] == '#') {
				cout << '#';
				continue;
			}
			rep(k, 8) {
				int ddx = dx[k] + j;
				int ddy = dy[k] + i;
				if (ddx >= 0 && ddx < w && ddy >= 0 && ddy < h) {
					if (field[ddy][ddx] == '#')sum++;
				}
			}
			cout << sum;
		}
		cout << endl;
	}
 	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int push(int *s,int x);
int pop(int *s);
static int top=1;
int main(){
  int s[100],a,b,c,st;
  char bash[100];
  
  while(st=(scanf(" %s",bash))!=EOF){

    /* if(bash[0]=='\n')break; */

    if(bash[0]=='+')
      push(s,(pop(s)+pop(s)));
    else if(bash[0]=='-'){
      a=pop(s);
      b=pop(s);
      push(s,b-a);
    }
    else if(bash[0]=='*')
      push(s,(pop(s)*pop(s)));
    else
      
      push(s,atoi(bash));
  }
  printf("%d\n",pop(s));
  return 0;
}
int push(int *s,int x){
  top=top+1;
  s[top]=x;
}
int pop(int *s){
  top=top-1;

  return s[top+1];
}




Measured memory_bytes: 2128
package main

import "fmt"

func main() {
	var a, b, c, d, sum int
	fmt.Scanf("%d", &a)
	fmt.Scanf("%d", &b)
	fmt.Scanf("%d", &c)
	fmt.Scanf("%d", &d)

	sum = a
	if b < a {
		sum = b
	}

	if c < d {
		sum += c
	} else {
		sum += d
	}

	fmt.Println(sum)
}


Measured memory_bytes: 512
n,k = map(int,input().split())
h = list(map(int,input().split())) + [0] * (k)
dp = [float('inf')] * (n*k + 1)
dp[0] = 0
for i in range(n):
    for j in range(1,k+1):
        dp[i+j] = min(dp[i+j],dp[i] + abs(h[i] - h[i+j]))
print(dp[n-1])


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

int main() {

    int n, min, max;
    long sum;
    cin >> n;

    int a[n];

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

    sum = 0;
    min = a[0];
    max = a[0];

    for(int i = 0; i < n; i++) {
        sum = sum + a[i];

        if(min < a[i]) {
            min = a[i];
        }
        if(max > a[i]) {
            max = a[i];
        }
    }

    cout << max << " " << min << " " << sum << endl;

}



Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n;
	cin >> n;
	const int N = 100 * 1000 + 5;
	vector <int> A(n),cnt(N);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		cnt[A[i]]++;
	}
	int mx = cnt[A[0]];
	for (int i = 1; i < N - 1; i++) {
		mx = max(mx, cnt[i] + cnt[i - 1] + cnt[i + 1]);
	}
	cout << mx;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  double _R, _W, C, R;
  while(cin>>_R>>_W>>C>>R,_R+_W+C+R!=0) {
    double C_ = _R/_W;
    if (C_ >= C) {
      cout << 0 << endl;
    } else {
      //X >= (C-C_)*_W/R
      cout << ceil((C-C_)*_W/R) << endl;
    }
  }
}



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

int main()
{
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    vector<vector<ll>> memo(h, vector<ll>(w));
    vector<ll> a(n); //indexが色がa(i)
    rep(i, n)
    {
        cin >> a[i];
    }
    int u = 0;
    rep(i, h)
    { //偶数は左から右、奇数は右から左
        if (i % 2 == 0)
        {
            rep(j, w)
            {
                memo[i][j] = u + 1;
                a[u] -= 1;
                if (a[u] == 0)
                {
                    u++;
                }
            }
        }
        else if (i % 2 == 1)
        {
            for (int j = w - 1; j >= 0; j--)
            {
                memo[i][j] = u + 1;
                a[u] -= 1;
                if (a[u] == 0)
                {
                    u++;
                }
            }
        }
    }
    rep(i, h)
    {
        rep(j, w)
        {
            cout << memo[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 512
using static System.Console;

class Program {
	static void Main() {
		var S = ReadLine();
		WriteLine(Judge(S) ? "AC" : "WA");
	}
	static bool Judge(string S) {
		var i = 0;
		var flg = false;
		foreach (var c in S) {
			if (i == 0) {
				if (S[0] != 'A') {
					return false;
				}
			} else if (2 <= i && i < S.Length - 1) {
				if (S[i].ToString().ToUpper() == S[i] + "") {
					if (flg) {
						return false;
					}
					flg = true;
				}
			} else {
				if (S[i].ToString().ToUpper() == S[i] + "") {
					return false;
				}
			}
			i++;
		}
		return flg ? true : false;
	}
}

Measured memory_bytes: 11092
#include<stdio.h>
int main(void){
        int x,sum,temp;
        scanf("%d",&x);
        temp=x;
        sum=0;
        while(1){
                sum+=temp%10;
                temp=temp/10;
                if(temp<1){
                        break;
                }
        }
        if(x%sum==0){
                printf("Yes\n");
        }else{
                printf("No\n");
        }
        return 0;
}

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

int main(){
  int H, W;
  cin >> H >> W;
  string S[50];
  
  for(int i = 0; i < H; i++){
    cin >> S[i];
  }//Sの配置完了
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(S[i][j] == '.'){
        int x = 0;
        if((0<=i-1)&&(i-1<=H-1)&&(0<=j-1)&&(j-1<=W-1)){
          if(S[i-1][j-1]=='#'){
          x++;
          }
        }
        if((0<=i-1)&&(i-1<=H-1)&&(0<=j)&&(j<=W-1)){
          if(S[i-1][j]=='#'){
          x++;
          }
        }
        if((0<=i-1)&&(i-1<=H-1)&&(0<=j+1)&&(j+1<=W-1)){
          if(S[i-1][j+1]=='#'){
          x++;
          }
        }
        if((0<=i)&&(i<=H-1)&&(0<=j-1)&&(j-1<=W-1)){
          if(S[i][j-1]=='#'){
          x++;
          }
        }
        if((0<=i)&&(i<=H-1)&&(0<=j+1)&&(j+1<=W-1)){
          if(S[i][j+1]=='#'){
          x++;
          }
        }
        if((0<=i+1)&&(i+1<=H-1)&&(0<=j-1)&&(j-1<=W-1)){
          if(S[i+1][j-1]=='#'){
          x++;
          }
        }
          if((0<=i+1)&&(i+1<=H-1)&&(0<=j)&&(j<=W-1)){
            if(S[i+1][j]=='#'){
          x++;
            }
        }
          if((0<=i+1)&&(i+1<=H-1)&&(0<=j+1)&&(j+1<=W-1)){
            if(S[i+1][j+1]=='#'){
          x++;
            }
        }
        S[i][j]='0'+x;
      }
    }
  }
  for(int i = 0;i<H; i++)
  cout << S[i] << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int i,j,ss,sp,cheak=1;
  char s[101],p[101],temp[2];
  scanf("%s",&s);
  scanf("%s",&p);
  ss=strlen(s);
  sp=strlen(p);
  for(i=0;i<ss;i++){
    if(memcmp(s,p,sp)==0){
      cheak=0;break;
    }
    temp[0]=s[0]; 
    s[ss]=temp[0];
    for(j=0;j<ss;j++){
      s[j]=s[j+1];
    }
  }
  if(cheak==0)printf("Yes\n");
  else printf("No\n");
  return(0);
}

Measured memory_bytes: 532
//#if !defined(YCM) && 1
//#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx")
////#pragma GCC optimize ("O3")
////#pragma GCC target ("sse4")
//#include <stdio.h>
//#endif

#include <bits/stdc++.h>
#include <unistd.h>
//#pragma GCC diagnostic ignored "-Wunused-result"
//#pragma GCC diagnostic ignored "-Wunused-function"
using namespace std;
#define ll int64_t
#define ull unsigned long long int
#define clr(a) memset(a,0,sizeof(a))
#define clr_(a) memset(a,-1,sizeof(a))
#define pb(a) push_back(a)
#define pii pair<int,int>

#define eps 1e-9
#define inf INT_MAX
#define pi acos(-1.0)
#define ff first
#define ss second
#define INF (ll)1e18
#define m_p make_pair
#define vsort(v) sort(v.begin(),v.end())
#define all(v) v.begin(),v.end()
int fx[]={0,0,-1,1,-1,1,1,-1};
int fy[]={1,-1,0,0,1,1,-1,-1};
ll lcm(ll a,ll b){return (a/__gcd(a,b))*b;}
ll bigmod(ll a,ll p,ll mod){ll ans=1;while(p){if(p&1)ans=ans*a%mod;a=a*a%mod;p>>=1;}return ans;}
ll power(ll x,ll n){if(n==0)return 1;else if(n%2==0){ll y=power(x,n/2);return y*y;}else return x*power(x,n-1);}

#ifdef shaft
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " is " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cerr.write(names, comma - names) << " is " << arg1 <<endl;
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
const int N=(int)1e6+5;
const int mod=(int)1e9+7;

int main()
{
    ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(100); cout.tie(nullptr); cin.tie(nullptr);
    #ifdef shaft
        //freopen("in.txt","r",stdin);
        //freopen("out.txt","w",stdout);
    #endif ///shaft
    ll a , b;
    cin >> a >> b;
    ll z = a*b;
    if(z%2 == 0)
        cout <<"Even"<<endl;
    else
        cout <<"Odd"<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;cin>>N;
    int han=(N-1)/2;
    vector<int>d(N);
    for(int i=0;i<N;i++){
        cin>>d[i];
    }
    sort(d.begin(),d.end());
    if(d[han]==d[han+1]){
        cout<<0;
        return 0;
    }
    int ans=d[han+1]-d[han];
    cout<<ans;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
  long n,a[100010],souwa = 0;
  cin >>n;
  a[0] = 0;
  a[n+1] =0;
  for(int i=1;i<=n;i++) cin >> a[i];
  for(int i=1;i<=n+1;i++) souwa += abs(a[i]-a[i-1]);
  for(int i=1;i<=n;i++){
    if((a[i-1]-a[i])*(a[i]-a[i+1])>=0) cout << souwa << endl;
    else cout << (souwa-2*min(abs(a[i]-a[i-1]),abs(a[i]-a[i+1]))) << endl;
  }
}

Measured memory_bytes: 2048
#include <iostream>
#include <cmath>
#include <vector>
#include <limits>
#include <algorithm>
using namespace std;

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

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

	vector<int> a(n);
	REP( i, n ) cin >> a[i];

	int count = 0;
	REP( i, n - 1 ) {
		int min = a[i];
		int p = i;
		for( int j = i + 1; j < n; j++ ) {
			if( a[j] < min ) {
				min = a[j];
				p = j;
			}
		}
		if( p != i ) {
			a[p] = a[i];
			a[i] = min;
			count++;
		}
	}

	REP( i, n - 1 ) cout << a[i] << " ";
	cout << a[n - 1] << endl << count << endl; 
}


Measured memory_bytes: 3112
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll x[N], y[N];
  for(int i=0;i<N;++i) cin>>x[i]>>y[i];
  double ans = 10000000;
  ll x1, y1, x2, y2, x3, y3;
  ll a, b, c;
  double a1, b1, c1;
  double r;
  double tmp;
  bool ok;
  if(N==2) {
    cout<<setprecision(20)<<sqrt((x[1]-x[0])*(x[1]-x[0])+(y[1]-y[0])*(y[1]-y[0]))/2<<endl;
    return 0;
  }
  for(int i=0;i<N;++i) {
    for(int j=i+1;j<N;++j) {
      for(int k=j+1;k<N;++k) {
        x1 = x[i];
        y1 = y[i];
        x2 = x[j];
        y2 = y[j];
        x3 = x[k];
        y3 = y[k];
        tmp = (double)((y1-y2)*(x1-x3)-(y1-y3)*(x1-x2));
        if((y1-y2)*(x1-x3)-(y1-y3)*(x1-x2)==0) continue;
        a = ((y1-y3)*((x1*x1-x2*x2)+(y1*y1-y2*y2))-(y1-y2)*((x1*x1-x3*x3)+(y1*y1-y3*y3)));
        b = ((x1-x2)*((x1*x1-x3*x3)+(y1*y1-y3*y3))-(x1-x3)*((x1*x1-x2*x2)+(y1*y1-y2*y2)));
        c = (-x1*x1-y1*y1)*((y1-y2)*(x1-x3)-(y1-y3)*(x1-x2))-a*x1-b*y1;
        ok = true;
        for(int l=0;l<N;++l) {
          if((y1-y2)*(x1-x3)-(y1-y3)*(x1-x2)>0){
            if((x[l]*x[l]+y[l]*y[l])*((y1-y2)*(x1-x3)-(y1-y3)*(x1-x2))+a*x[l]+b*y[l]+c>0) ok = false;
          }
          else {
            if((x[l]*x[l]+y[l]*y[l])*((y1-y2)*(x1-x3)-(y1-y3)*(x1-x2))+a*x[l]+b*y[l]+c<0) ok = false;
          }
        }
        if(!ok) continue;
        a1 = (double)a;
        b1 = (double)b;
        c1 = (double)c;
        a1 /= tmp;
        b1 /= tmp;
        c1 /= tmp;
        r = sqrt((a1*a1+b1*b1)/4-c1);
        if(r<0) continue;
        ans = min(ans, r);
      }
    }
  }
  for(int i=0;i<N;++i) {
    for(int j=i+1;j<N;++j) {
      x1 = x[i];
      y1 = y[i];
      x2 = x[j];
      y2 = y[j];
      a = -(x1+x2);
      b = -(y1+y2);
      c = x1*x2+y1*y2;
      ok = true;
      for(int l=0;l<N;++l) {
        if((x[l]*x[l]+y[l]*y[l])+a*x[l]+b*y[l]+c>0) ok = false;
      }
      if(!ok) continue;
      a1 = (double)a;
      b1 = (double)b;
      c1 = (double)c;
      r = sqrt((a1*a1+b1*b1)/4-c1);
      if(r<0) continue;
      ans = min(ans, r);
    }
  }
  cout<<setprecision(20)<<ans<<endl;
}



Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	int d,n;
	cin>>d>>n;
	vector<int> tmp(d);
	for(int i=0;i<d;i++)cin>>tmp[i];
	vector<vector<int> > cx(d);
	for(int i=0;i<n;i++){
		int a,b,c;
		cin>>a>>b>>c;
		for(int j=0;j<d;j++){
			if(a<=tmp[j] && tmp[j]<=b) cx[j].push_back(c);
		}
	}
	for(int i=0;i<d;i++) sort(cx[i].begin(),cx[i].end());
	/*for(int i=0;i<d;i++){
		cout<<"day "<<i<<endl;
		for(int j=0;j<cx[i].size();j++){
			cout<<cx[i][j]<<' ';
		}
		cout<<endl;
	}*/
	int l=cx[0][0],r=cx[0][cx[0].size()-1];
	int ls=0,rs=0;
	vector<vector<int> > dp(d,vector<int>(2,0) );
	for(int i=1;i<d;i++){
		dp[i][0] = max(dp[i-1][0]+abs(cx[i][0]-cx[i-1][0]),dp[i-1][1]+abs(cx[i][0]-cx[i-1][cx[i-1].size()-1]) ); 
		dp[i][1] = max(dp[i-1][0]+abs(cx[i][cx[i].size()-1]-cx[i-1][0]),dp[i-1][1]+abs(cx[i][cx[i].size()-1]-cx[i-1][cx[i-1].size()-1]) ); 
	}
	//cout<<ls<<' '<<rs<<endl;
	cout<<max(dp[d-1][0],dp[d-1][1])<<endl;


	return 0;
}



Measured memory_bytes: 3208
import sys
from operator import itemgetter
import math
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, d = na()
pl = []
for i in range(n):
    pl.append(na())
#print(pl)
ct = 0
for i in range(n):
    for j in range(i+1, n):
        l = 0
        if i != j:
            #print(i, j)
            for k in range(d):
                l += ((pl[i][k] - pl[j][k]) ** 2)
                #print(l)
            if math.sqrt(l).is_integer():
                ct += 1
print(ct)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
ll pow1(ll a, ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
		{
			ans=ans*a;
		}
		a=a*a;
		b=b>>1;
	}
	return ans;
}
int main()
{
	int n,i,j;
	cin>>n;
	ll sum = 0,x,ma = 0;
	for(i=0;i<n;i++)
	{
		cin>>x;
		ma = max(ma,x);
		sum += x;
	}
	sum -= (ma/2);
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
  ll d;cin >> d;
  vl c(26);rep(i,26)cin >> c[i];
  vvl s(d,vl(26));rep(i,d)rep(j,26)cin >> s[i][j];
  vector<set<ll>> ch(26);rep(i,26)ch[i].ins(-1),ch[i].ins(d);
  vl days(d);
  ll pre=0;
  vl last(26,-1);
  rep(i,d){
    ll t=0;
    ll maxi=-INF;
    rep(j,26){
        ll p=s[i][j];
        rep(k,26){
            if(k==j)continue;
            p-=c[k]*(i-last[k]);
        }
        if(chmax(maxi,p))t=j;
      }
      days[i]=t;
      last[t]=i;
  }
  rep(i,d){
    ll t=days[i];
    pre+=s[i][t];
    ch[t].ins(i);
    days[i]=t;
  }
  ll score=pre; 
  rep(i,26){
      ll mini=0;
      ll pp=-1;
      for(auto a:ch[i]){
        mini+=(a-pp)*(a-pp-1)/2;
        pp=a;
      }
      score-=c[i]*mini;
  }
  //rep(i,d)cout << days[i] <<endl;

  ll q=900000;
  while(q--){
    ll x=rand()%d,y=rand()%26;
    //cout << x <<" " << y <<endl;
    ll old=days[x];
    pre-=s[x][days[x]];
    ch[days[x]].erase(x);
    days[x]=y;
    pre+=s[x][y];
    ch[y].ins(x);
    ll p=0;
    rep(i,26){
      ll mini=0;
      ll pp=-1;
      for(auto a:ch[i]){
        mini+=(a-pp)*(a-pp-1)/2;
        pp=a;
      }
      p+=c[i]*mini;
    }
    //if(q>299990)cout << score <<endl;
    if(pre-p>=score){
      score=pre-p;
    }
    else{
      ch[y].erase(x);
      pre-=s[x][y];
      days[x]=old;
      ch[days[x]].ins(x);
      pre+=s[x][old];
    }
  }
  rep(i,d)cout << days[i]+1 <<endl;
}   


Measured memory_bytes: 3760
#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;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int dp[3000][3000];

int f(int x, int y) {
    if(dp[x][y] != -1) {
        return dp[x][y];
    }
    for(int i = 1; i * 2 <= x; i++) {
        if(f(x - 2 * i, y + i) == 0) {
            return dp[x][y] = 1;
        }
    }
    for(int i = 1; i * 2 <= y; i++) {
        if(f(x + i, y - 2 * i) == 0) {
            return dp[x][y] = 1;
        }
    }
    return dp[x][y] = 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x, y;
    cin >> x >> y;
    cout << (llabs(x - y) <= 1 ? "Brown" : "Alice") << endl;
    // memset(dp, -1, sizeof(dp));
    // for(int i = 0; i < 50; i++) {
    //     for(int j = 0; j < 50; j++) {
    //         cerr << f(i, j) << " ";
    //     }
    //     cerr << endl;
    // }
}

Measured memory_bytes: 3652
n = gets.to_i
point = []
n.times { point << gets.split.map(&:to_i) }
sum = 0.0
cnt = 0
point.permutation do |x|
  dist = 0.0
  i = 1
  while i < x.size
    dist += ((x[i - 1][0] - x[i][0])**2 + (x[i - 1][1] - x[i][1])**2)**0.5
    i += 1
  end
  sum += dist
  cnt += 1
end
puts sum/cnt


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

void solve(long long N, std::vector<std::string> S){
    set<string> s;
    for(int i=0;i<N;i++){
        s.insert(S[i]);
    }
    cout << s.size() << endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 25236
#include <stdio.h>
//#include <stdlib.h>
//#include <limits.h>
//#include <math.h>

int main() {
  char s[101];
  long n;
  scanf("%s %ld", s, &n);
  int i=0;
  while (s[i] == '1' && i<n-1) i++;
  printf("%c\n", s[i]);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

#define N 2000
#define A 101
#define NIL -1

void Prim();

static const int MAX=500;
static const int INFTY=(1<<21);

int M[A][A], p[A], n, s;

main(){
  int i, j, e;
  
  scanf("%d", &n);
  
  for (i=0; i<n; i++ )
    for (j=0; j<n; j++ ){
      scanf("%d", &e);
      M[i][j]=(e==-1)?INFTY:e;
    }
  
  s=0;
  Prim();
  printf("%d\n", s);
  return 0;
}

void Prim(){
  int i, v, u, k[A];

  for(u=0;u<n;u++){
    k[u]=INFTY;
    p[u]=NIL;
  }

  k[0]=0;

  while(1){
    int minv=INFTY;
    u=NIL;

    for(i=0;i<n;i++)
      if(k[i] < minv && p[i]==NIL ){
	u=i;
	minv=k[i];
      }
    
    if(u==NIL) break;
    p[u]=1;
    s+=k[u];
    
    for(v=0;v<n;v++)
      if(M[u][v]<k[v]){
	k[v]=M[u][v];
      }    
  }
}

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

using namespace std;

long d[111111] = { 1 };
int main() {
	int n, k, p = 1e9 + 7;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		partial_sum(d, d + k + 1, d);
		for (int j = k - a; j--;)
			d[j + a + 1] -= d[j];
		for (int j = 0; j < k; j++)
			d[j + 1] %= p;
	}
	cout << d[k] << endl;
	return 0;
}


Measured memory_bytes: 1024
module ABC086A
  sub Main(ByVal args() as String)
    select Console.ReadLine() mod 10
    case 2,4,5,7,9:
        Console.WriteLine("hon")
    case 0,1,6,8:
        Console.WriteLine("pon")
    case else:
        Console.WriteLine("bon")
    end select
  end sub
end module

Measured memory_bytes: 28292
N = list(map(int, list(input())))

def calc(n1, op, n2):
    if op == '+':
        return n1 + n2
    else:
        return n1 - n2

ops = ['+', '-']

for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            if calc(calc(calc(N[0], op1, N[1]), op2, N[2]), op3, N[3]) == 7:
                break
        else:
            continue
        break
    else:
        continue
    break
print('{}{}{}{}{}{}{}=7'.format(N[0], op1, N[1], op2, N[2], op3, N[3]))


Measured memory_bytes: 3064
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
#include <pthread.h>
#include <omp.h>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
#define _USE_MATH_DEFINES
using namespace std;
using namespace std::chrono;


int mod_power(int x, int y, int mod){
  int ans = 1;
  x %= mod;
  while(y){
    if (y & 1)
      ans *= x, ans %= mod;
    y /= 2;
    x = (x * x) % mod;
  }
  return ans;
}

int mod_inverse(int n, int mod){
  return mod_power(n, mod - 2, mod);
}

int mod_ncr(int n, int r, int mod){
  if (r == 0 or r == n)
    return 1;
  int fact = 1;
  for (int i = 1; i <= r; i++)
    fact *= i, fact %= mod;
  int ans = 1;
  for (int i = n; i > n - r; i--)
    ans *= i, ans %= mod;
  ans *= mod_inverse(fact, mod), ans %= mod;
  return ans;
}

unordered_map<int, int> factor(int n){
  int cnt = 0;
  unordered_map<int, int> m;
  int nn = n;
  while (!(nn & 1))
    cnt++, nn /= 2;
  if(cnt)
    m[2] = cnt;
  for (int i = 3; i <= sqrt(n); i++){
    cnt = 0;
    while(nn % i == 0)
      nn /= i, cnt++;
    if (cnt)
      m[i] = cnt;
  }
  if (nn > 2)
    m[nn] = 1;
  
  return m;
}



signed main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);

  int mod = 1e9 + 7;
  int n, a, b;
  cin >> n >> a >> b;
  cout << (mod_power(2, n, mod) - mod_ncr(n, a, mod) - mod_ncr(n, b, mod) + 5 * mod - 1) % mod << endl;
  
}


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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;
using pii=pair<int,int>;using pll=pair<ll,ll>;using pil=pair<int,ll>;using pli=pair<ll,int>;
using vs=vector<string>;using vvs=vector<vs>;using vvvs=vector<vvs>;
using vb=vector<bool>;using vvb=vector<vb>;using vvvb=vector<vvb>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template<class T,class U>istream&operator>>(istream&is,pair<T,U>&P){is>>P.fst;is>>P.snd;return is;}
template<class T>T read(){T t;cin>>t;return t;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<'('<<p.fst<<", "<<p.snd<<')';}
template<class T>ostream&operator<<(ostream&o,const vector<T>&t){o<<"{";rep(i,sz(t))o<<t[i]<<",";o<<"}"<<endl;return o;}
vs s_p_l_i_t(const string&s,char c){vs v;stringstream ss(s);string x;while(getline(ss,x,c))v.emplace_back(x);return move(v);}
void e_r_r(vs::iterator it){cerr<<endl;}
template<class T,class... Args>void e_r_r(vs::iterator it,T a,Args... args){cerr<<it->substr((*it)[0]==' ',it->length())<<" = "<<a<<", ";e_r_r(++it,args...);}
#define out(args...){vs a_r_g_s=s_p_l_i_t(#args,',');e_r_r(a_r_g_s.begin(),args);}

void Main() {
  int n = read<int>();
  int m = read<int>();
  vvi E(n);
  rep(i, m) {
    int u = read<int>() - 1;
    int v = read<int>() - 1;
    E[u].push_back(v);
    E[v].push_back(u);
  }

  int ans = 0;

  function<void(int, int)> dfs = [&](int cur, int vis) {
    vis |= bit(cur);

    if (__builtin_popcount(vis) == n) ans++;

    forr(nex, E[cur]) {
      if ((bit(nex) & vis) == 0) {
        dfs(nex, vis);
      }
    }
  };
  dfs(0, 0);
  cout << ans << endl;
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 256
# coding: utf-8

n, m = [int(x) for x in input().split()]
xx = []
yy = []
zz = []

for _ in range(n):
    x, y, z = [int(x) for x in input().split()]
    xx.append(x)
    yy.append(y)
    zz.append(z)

result_points = []

results = []

for i in range(8):
    results.append([])
    for j in range(n):
        plus_point = 0
        if i % 2 == 1:
            plus_point += xx[j]
        else:
            plus_point -= xx[j]
        if (i // 2) % 2 == 1:
            plus_point += yy[j]
        else:
            plus_point -= yy[j]
        if (i // 4) % 2 == 1:
            plus_point += zz[j]
        else:
            plus_point -= zz[j]
        results[i].append(plus_point)
    results[i].sort()
    results[i].reverse()

result_points = []

for i in range(8):
    result_points.append(sum(results[i][0:m]))

print(max(result_points))


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

using namespace std;

#define endl '\n'

typedef long long ll;
typedef pair<ll, ll> pii;

ll euler_phi(ll n)
{
	if (n == 0)
		return 0;
	ll ans = n;
	for (ll x = 2; x * x <= n; ++x)
		if (n % x == 0)
		{
			ans -= ans / x;
			while (n % x == 0)
				n /= x;
		}
	if (n > 1)
		ans -= ans / n;
	return ans;
}

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

	int n;
	cin >> n;
	cout << euler_phi(n) << endl;

	return 0;
}

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

class Main {


    public static int totalCostIncurred(int[] height, int[] memo) {
        return totalCostHelper(0, height, memo);
    }

    private static int totalCostHelper(int i, int[] height, int[] memo) {
        if(i == height.length - 1) {
            return 0;
        }

        if(memo[i] != -1) {
            return memo[i];
        }

        int cost1 = Math.abs(height[i+1]-height[i]) + totalCostHelper(i+1,height, memo);
        int cost2 = i+2 < height.length ? Math.abs(height[i+2]-height[i]) + totalCostHelper(i+2,height, memo): Integer.MAX_VALUE;
        return memo[i] = Math.min(cost1, cost2);
    }

    private static int totalCostHelperDP(int [] height) {
        int N = height.length;
        int[] dp = new int[N];

        dp[0] = 0;

        for(int i=1; i<N; i++) {
            int possibility1 = (i-1 >= 0) ? dp[i-1] + Math.abs(height[i]-height[i-1]) : Integer.MAX_VALUE;
            int possibility2 = (i-2 >= 0) ? dp[i-2] + Math.abs(height[i]-height[i-2]) : Integer.MAX_VALUE;
            dp[i] = Math.min(possibility1, possibility2);
        }
        return dp[N-1];
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int numberOfStones = scanner.nextInt();
        int[] height = new int[numberOfStones];
        int[] memo = new int[numberOfStones];
        Arrays.fill(memo, -1);

        for(int i=0; i<height.length; i++)
            height[i] = scanner.nextInt();
        System.out.println(totalCostHelperDP(height));
    }
}

Measured memory_bytes: 59912
#include<iostream>
#include<stack>
using namespace std;
string s="";
int n;
int p;
main()
{
	cin>>n;
	int cnt=1;
	stack<int>S;
	for(int i=0;i<n;i++)
	{
		cin>>p;
		if(cnt<=p)
		{
			for(;cnt<=p;cnt++)
			{
				S.push(cnt);
				s+='(';
			}
		}
		if(!S.empty()&&S.top()==p)
		{
			s+=')';
			S.pop();
		}
		else
		{
			cout<<":("<<endl;
			return 0;
		}
	}
	cout<<s<<endl;
}



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

int A, B, C;

void solve(){
  if(A + B + C == 17){
    if((A == 5 and B == 7) or (A == 7 and B == 5) or (A == 5 and B == 5)){
      cout << "YES" << endl;
    }
    else cout << "NO" << endl;
  }
  else cout << "NO" << endl;
  return ;
}


int main(){
  cin >> A >> B >> C;
  solve();
  return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


class RangeAddMin():
    def __init__(self, n):
        i = 1
        while 2**i <= n:
            i += 1
        self.N = 2**i
        self.A = [0] * (self.N*2)
        self.B = [0] * (self.N*2)

    def add(self, a, b, x, k, l, r):
        def ina(k, l, r):
            if b <= l or r <= a:
                pass
            elif a <= l and r <= b:
                self.A[k] += x
            else:
                m = (l+r) // 2
                ina(k*2+1, l, m)
                ina(k*2+2, m, r)
                self.B[k] = min(self.B[k*2+1] + self.A[k*2+1], self.B[k*2+2] + self.A[k*2+2])

        ina(k, l, r)

    def query(self, a, b, k, l, r):
        def inq(k, l, r):
            if b <= l or r <= a:
                return inf

            if a <= l and r <= b:
                return self.A[k] + self.B[k]

            m = (l+r) // 2
            rl = inq(k*2+1, l, m)
            rr = inq(k*2+2, m, r)
            return min(rl, rr) + self.A[k]

        return inq(k, l, r)

def main():
    n,q = LI()
    qa = [LI() for _ in range(q)]

    ram = RangeAddMin(n)
    rr = []
    for qi in qa:
        s = qi[1]
        t = qi[2] + 1
        if qi[0] == 0:
            x = qi[3]
            ram.add(s, t, x, 0, 0, n)
        else:
            rr.append(ram.query(s, t, 0, 0, n))

        # print(qi,ras.A,ras.B)

    return JA(rr, "\n")

# start = time.time()
print(main())
# pe(time.time() - start)






Measured memory_bytes: 43888
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(c - a) <= d || (abs(a - b) <= d && abs(b - c) <= d)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

x,y,z,k = get_nums_l()

aaa = get_nums_l()
bbb = get_nums_l()
ccc = get_nums_l()

aaa.sort(reverse=True)
bbb.sort(reverse=True)
ccc.sort(reverse=True)

def solve(p):
    count = 0
    for a in aaa:
        for b in bbb:
            for c in ccc:
                if a+b+c < center:
                    break
                count += 1
                if count >= k:
                    return True
    return False

left = 0
right = 30000000001

while left+1 < right:
    center = (left + right) // 2

    if solve(center):
        left = center
    else:
        right = center

border = left

ans = []

for a in aaa:
    for b in bbb:
        for c in ccc:
            if a+b+c >= border:
                ans.append(a+b+c)
            else:
                break

ans.sort(reverse=True)
print("\n".join(list(map(str,ans[:k]))))


Measured memory_bytes: 189340
#include <iostream>

using namespace std;

void failure () {
  cout << -1 << endl;
  exit(0);
}

typedef long long ll;

const ll INF = 1e17;
const int MAX_N = 1e5 + 5;

ll leafc [MAX_N], internc [MAX_N];

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

  for (int i = 0; i <= n; i++) {
    cin >> leafc[i];
  }
  if (leafc[n] == 0) failure();
  
  internc[0] = 1;
  for (int i = 0; i < n; i++) {
    internc[i] -= leafc[i];
    if (internc[i] <= 0) failure();
    internc[i + 1] = min(INF, 2 * internc[i]);
  }
  if (internc[n] < leafc[n]) failure();
  internc[n] = 0;

  for (int i = n - 1; i >= 0; i--) {
    internc[i] = min(internc[i], leafc[i + 1] + internc[i + 1]);
  }

  ll ans = 0;
  for (int i = 0; i <= n; i++) {
    ans += internc[i];
    ans += leafc[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 5192
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input().rstrip()
d1 = {'r': ('p', p), 's': ('r', r), 'p': ('s', s)}
d2 = {'r': {'p': 'r', 's': 's', 'r': 's'},
      's': {'r': 's', 'p': 'p', 's': 's'},
      'p': {'r': 'r', 's': 'p', 'p': 'r'}}
ret = 0
me = []
for i, rival in enumerate(t):
    if i - k < 0 or me[i - k] != d1[rival][0]:
        me.append(d1[rival][0])
        ret += d1[rival][1]
    elif i - k >= 0 and me[i - k] == d1[rival][0] and i + k < n:
        me.append(d2[rival][t[i + k]])
print(ret)


Measured memory_bytes: 9988
#include <stdio.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <map>
#include <ctime>
#include <cmath>
#include <string.h>
#define inf 0x7fffffff
using namespace std;
struct I
{
    int x,y;
};


int a,b,k,n,m,i,c,d,e,o[2222],l[332222]={1,1,2,2,2,8},dx[20]={1,0,-1,0},dy[20]={0,1,0,-1},dz[20]={1,-1};

long long x,y,z;
//map <string,int> m;
int j[501060];


//char r[6][50005];
//deque<int> d;
struct P
{
    int x,y;
    bool operator<(const P &a)const
    {

            return x>a.x;

    }
};
stack<P> s;
double u;
//P u[500000];
vector <int> v[411010];
queue<int> q,q1;
string r,r1;
map<int,int > p;
//A==65
//Z==90

//a==97
bool asd(P a,P b)
{
    return a.x<b.x;
}

int g(int w)
{
    for(int j=3;j*j<=w;j+=2)
        if(w%j==0) return 0;
    return 1;
}

int f(int t,int h)
{

}

int main()
{
    for(int t=1;t<=4;t++)
        scanf("%d",&o[t]);
    for(int t=2;t<=4;t++)
    {
        o[t]=min(o[t],2*o[t-1]);
    }
    scanf("%d",&a);
    if(a%2) k+=o[3];
    printf("%lld",k+(long long)a/2*o[4]);
}


Measured memory_bytes: 11264
#include <algorithm>
#include <array>
#include <climits>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <numeric>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#ifdef ENABLE_ASSERT
#include <cassert>
#else
#undef assert
#define assert static_cast<void>(0)
#endif

using namespace std;
using namespace std::literals;

int main() {
  auto r = 0;
  cin >> r;
  cout << r * r;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    vector<long long> dp(13);
    dp[0] = 1;
    char c;
    long long digit = 1;
    for (int i = 1; i<=(int)S.size(); i++) {
        vector<long long> ndp(13);
        c = S[S.size()-i];
        if (c == '?') {
            for (int n = 0; n<10; n++) {
                for (int j = 0; j<13; j++) {
                    ndp[(n*digit+j)%13] += dp[j];
                    ndp[(n*digit+j)%13] %= mod;
                }
            }
        } else {
            int n = c-'0';
            for (int j = 0; j<13; j++) {
                ndp[(n*digit+j)%13] += dp[j];
                ndp[(n*digit+j)%13] %= mod;
            }
        }
        dp = ndp;
        digit *= 10;
        digit %= 13;
    }
    printf("%lld\n", dp[5]);
    return 0;
}

Measured memory_bytes: 512