akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


void solve(long long N, long long D, std::vector<long long> X, std::vector<long long> Y){
  long long k =0;
  double dd =0;
  for(int i=0; i<N;i++) {
      dd = sqrt( X[i]*X[i] + Y[i]*Y[i]);
      if (dd <= D) k++;
  }
  cout<<k<<endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    std::vector<long long> X(N);
    std::vector<long long> Y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&Y[i]);
    }
    solve(N, D, X, Y);
    return 0;
}


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

using namespace std;
int n, ans, h[22], f[22];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> h[i];

	f[1] = 1;
	ans = 1;
	for (int i = 2; i <= n; ++i) {
		f[i] = 1;

		int j = i-1;
		while (j > 0 && h[i] >= h[j]) {
			f[i] += f[j];
			j -= f[j];
		}

		if (f[i] == i)
			++ans;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string str;
 
bool solve(){
  
  while(1){
    if((int)str.size()<=3){
      if(str=="ABC")return true;
      else return false;
    }
 
    bool flag=false;
    string tmp="";
    bool flg[3]={};
    for(int i=0;i<(int)str.size();i++){
      if(i+2<(int)str.size()&&
         str[i]=='A'&&str[i+1]=='B'&&str[i+2]=='C'){
        i+=2;
        tmp.push_back('?');
        flag=true;
      }else{
        tmp.push_back(str[i]);
        flg[ str[i]-'A' ] = true;
      }
    }
    if(flag==false)return false;    
    
    char ch='?';
 
    if(flg[0]&&flg[1]&&!flg[2])ch='C';
    else if(flg[0]&&!flg[1]&&flg[2])ch='B';
    else if(!flg[0]&&flg[1]&&flg[2])ch='A';
    else return false;
 
    for(int i=0;i<(int)tmp.size();i++)
      if(tmp[i]=='?')tmp[i]=ch;
 
    str=tmp;
   
  }
  return true;
}
int main(){
 
  cin>>str;
  if(solve())cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

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

#define M 1000010

int main(){
	IOS;
	ll n,k;cin>>n>>k;
	ll r,s,p;cin>>r>>s>>p;
	string t;cin>>t;
	ll ans=0;
	rep(i,0,k){
		ll j=i;
		while(j<n){
			if(j<n and j+k>=n){
				if(t[j]=='r')ans+=p;
				if(t[j]=='s')ans+=r;
				if(t[j]=='p')ans+=s;
			}
			else if(t[j]!=t[j+k]){
				if(t[j]=='r')ans+=p;
				if(t[j]=='s')ans+=r;
				if(t[j]=='p')ans+=s;
			}
			else if(t[j]==t[j+k]){
				if(t[j]=='r')ans+=p;
				if(t[j]=='s')ans+=r;
				if(t[j]=='p')ans+=s;
				j+=k;
			}
			// telll(i,j,ans);
			j+=k;
		}
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 512
use proconio::input;

fn main() {
    input! {
        n: i64,
        m: i64,
        k: i64,
    }

    for a in 0..=n {
        for b in 0..=m {
            if a * m + b * n - 2 * a * b == k {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}

Measured memory_bytes: 2140
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double c = sc.nextDouble();

		BigDecimal d = sqrt(new BigDecimal(a), 50);
		BigDecimal e = sqrt(new BigDecimal(b), 50);
		BigDecimal f = sqrt(new BigDecimal(c), 50);
		System.out.println(d.add(e).compareTo(f) == -1 ? "Yes" : "No");
	}

	public static BigDecimal sqrt(BigDecimal a, int scale) {

		BigDecimal x = new BigDecimal(Math.sqrt(a.doubleValue()), MathContext.DECIMAL64);
		if (scale < 17) {
			x = x.setScale(scale, BigDecimal.ROUND_HALF_EVEN);
			return x;
		}

		BigDecimal b2 = new BigDecimal(2);
		for (int tempScale = 16; tempScale < scale; tempScale *= 2) {
			x = x.subtract(
					x.multiply(x).subtract(a).divide(
							x.multiply(b2), scale, BigDecimal.ROUND_HALF_EVEN));
		}
		return x;
	}
}

Measured memory_bytes: 23380
#include<stdio.h>
 #include<algorithm>
 using namespace std;
 int main()
 {
 char s[10];
 scanf("%s", s);
 if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3])printf("Yes\n");
 else if(s[0] == s[2] && s[2] != s[1] && s[1] == s[3])printf("Yes\n");
 else if(s[0] == s[3] && s[3] != s[1] && s[1] == s[2])printf("Yes\n");
 else printf("No\n");
 }

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

int main() {
  int N,A=1,B=1;
  cin>>N;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    if(a%2==0){
      B*=2;
    }
    A*=3;
  }
  cout<<A-B<<endl;
}

Measured memory_bytes: 256
N, D = map(int, input().split())
X = [tuple(map(int, input().split())) for _ in range(N)]

A = [i ** 2 for i in range(150)]

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        dist = sum([(X[i][k] - X[j][k]) ** 2 for k in range(D)])
        if dist in A:
            ans += 1

print(ans)


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

int n,q;
long long x[N],s[N],f[2][N],g[N],ans;

void modify(long long f[],int x,long long t){
	if (x>n) return;
	f[x]=min(f[x],t);
	modify(f,x+(x&-x),t);	
}

long long query(long long f[],int x){
	if (!x) return 1ll<<60;
	return min(f[x],query(f,x-(x&-x)));
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();q=read();x[1]=read();x[2]=read();
	for (int i=3;i<=q+2;i++) x[i]=read();
	for (int i=2;i<=q+2;i++) s[i]=s[i-1]+abs(x[i]-x[i-1]);
	fill(f[0]+1,f[0]+n+1,1ll<<60);
	fill(f[1]+1,f[1]+n+1,1ll<<60);
	modify(f[0],x[1],g[2]-s[2]-x[1]);
	modify(f[1],n-x[1]+1,g[2]-s[2]+x[1]);
	ans=g[2]+s[q+2]-s[2];
	for (int i=3;i<=q+2;i++){
		g[i]=min(query(f[0],x[i])+s[i-1]+x[i],query(f[1],n-x[i]+1)+s[i-1]-x[i]);
		modify(f[0],x[i-1],g[i]-s[i]-x[i-1]);
		modify(f[1],n-x[i-1]+1,g[i]-s[i]+x[i-1]);
		ans=min(ans,g[i]+s[q+2]-s[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 18176
#set
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
x = gets.chomp.to_i
counter = 0
surplus_500 = 0
surplus_100 = 0
surplus_50 = 0
chk_500 = 0
chk_100 = 0
chk_50 = 0

#main
if a + b + c == 0 || x / 50 == 0 then
    exit
end

for i in 0 .. a 
    if i == 0 then 
        surplus_500 = x
    else
        # chk_500 = x / ( i * 500 ) 
        # if chk_500 >= 1 then
            surplus_500 = x - ( i * 500 )
        #  else
        #     surplus_500 = x
        # end
    end

    for j in 0 .. b
        if j == 0 then
            surplus_100 = surplus_500
        else
            # chk_100 = surplus_500 / ( j * 100 ) 
            # if chk_100 >= 1 then
                surplus_100 = surplus_500 - ( j * 100 )
            # else
            #     surplus_100 = surplus_500
            # end 
        end

        for k in 0 .. c
            if k == 0 then
                surplus_50 = surplus_100
            else
                # chk_50 = surplus_100 / ( k * 50 )
                # if chk_50 >= 1 then
                    surplus_50 = surplus_100 - ( k * 50 )
                # else
                #     surplus_50 = surplus_100
                # end
            end
            if surplus_50 == 0 then
                counter += 1
            end
            # print ("i=#{i},j=#{j},k=#{k},counter=#{counter} \n")
        end
    end
end

print ("#{counter}\n")

Measured memory_bytes: 1788
from collections import defaultdict
N = int(input())
A = [0]+list(map(int,input().split()))
for i in range(N):
    A[i+1] += A[i]
dic = defaultdict(int)
for i in range(N+1):
    dic[A[i]] += 1
ans = 0
for x in dic.values():
    ans += x*(x-1)//2
print(ans)

Measured memory_bytes: 129392
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1e9+7
using namespace std;
typedef long long ll;
const double pi=acos(-1);

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    string s,t;
    cin >> s >> t;
    int ans=t.size();

    for(int i=0;i<s.size()-(t.size()-1);i++){
        int tmp=0;
        for(int j=0;j<t.size();j++){
            if(s[i+j]!=t[j]) tmp++;
        }
        ans=min(ans,tmp);
    }
    cout << ans << endl;
}

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

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef pair<int, int> pii;

const int MOD = (int) 1e9 + 7;

const int MAXN = (int) 1e5, alpha = 26;

int n;

char s[MAXN + 5];

inline void input()
{
	n = read<int>();
	scanf("%s", s);
}

inline void solve()
{
	static int cnt[alpha];

	for(int i = 0; i < n; ++i) ++cnt[s[i] - 'a'];

	int ans = 1;
	for(int i = 0; i < alpha; ++i) ans = (LL) ans * (cnt[i] + 1) % MOD;
	(--ans) %= MOD;
	printf("%d\n", (ans + MOD) % MOD);
}

int main()
{
#ifndef ONLINE_JUDGE
//	freopen("A.in", "r", stdin);
//	freopen("A.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 384
import java.util.*;

class Main{
	public  static void main(String args[]){
		Scanner s=new Scanner(System.in);
		while(true){
			int a=s.nextInt();
			int b=s.nextInt();
			if(a+b==0)System.exit(0);
			HashMap<String, Boolean> map=new HashMap<String,Boolean>();
			String[] c=new String[a];
			for(int i=0;i<a;i++){
				c[i]=s.next();
			}
			int count=0;
			for(int i=0;i<a;i++){
				for(int j=0;j<a;j++){
					if(b>2){
						for(int k=0;k<a;k++){
							if(b>3){
								for(int l=0;l<a;l++){
									if(i!=j&&i!=k&&i!=l&&j!=k&&j!=l&&k!=l&&!map.containsKey(c[i]+c[j]+c[k]+c[l])){
										count++;
										map.put(c[i]+c[j]+c[k]+c[l],true);
									}
								}
							}else{
								if(i!=j&&i!=k&&j!=k&&!map.containsKey(c[i]+c[j]+c[k])){
									count++;
									map.put(c[i]+c[j]+c[k],true);
								}
							}
						}
					}else{
						if(i!=j&&!map.containsKey(c[i]+c[j])){
							count++;
							map.put(c[i]+c[j],true);
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<utility>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;
long long dp[100];
long long dfs(int n){
  if(n==0)return 2;
  if(n==1)return 1;
  if(dp[n-2]==0)dp[n-2]=dfs(n-2);
  if(dp[n-1]==0)dp[n-1]=dfs(n-1);
  return dp[n-2]+dp[n-1];
}
int main(){
  int n;
  cin>>n;
  cout<<dfs(n)<<endl;
  return 0;
}


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

int n, k;
vu w;
ll ans;
unordered_set<int> visit;

void input() {
    cin >> n >> k;
    w = vu(n);
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        w[--a].insert(--b);
        w[b].insert(a);
    }
}

inline void solve(int x, int v) {
    for (int i : w[x]) {
        if (visit.count(i)) continue;
        visit.insert(i);
        ans = (ans * v) % MOD;
        v--;
        solve(i, k-2);
    }
}

int main() {
    input();
    ans = k;
    visit.insert(0);
    solve(0, k-1);
    cout << ans << endl;
}


Measured memory_bytes: 22436
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
	}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	int n,cnt=0;
    bool b=true;
    cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    while(true){
        rep(i,n){
            if(a[i]%2!=0) b=false;
        }
        if(b) {
            rep(i,n) a[i]/=2;
            cnt++;
        }
        else break;
    }
    cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define repl(k,n) for(k=0;k<n;++k)

int main() {
	int N;
	cin >> N;
	int i;
	int x;
	int y;
	int z;
	int count=0;
	int stop = 0;
	double a;
	int limit;
	for (i = 1; i < N + 1;i++) {
		count = 0;
		a = sqrt(i);
		limit = a;
		for (x = 1; x < limit; x++) {
			for (y = x; y < limit; y++) {
				for (z = y; z < limit; z++) {
					if (x * x + x * y + x * z + y * y + z * z + y * z == i) {
						if (x == y && y == z)count = count + 1;
						else if (x == y || y == z || z == x)count = count + 3;
						else count = count + 6;
						stop = stop + 1;
					}
					if (stop == 2) z = i / 6 + 2;
				}
			}
		}
		cout << count<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3640
y, x = gets.chomp.split(" ").map(&:to_i)
y_vec = []
x_vec = []
y.times do |n|
  y_vec << gets.chomp.split(" ").map(&:to_i)
end
x.times do |n|
  x_vec << gets.chomp.to_i
end
y.times do |i|
  num = 0
  x.times do |j|
    num += y_vec[i][j] * x_vec[j]
  end
  puts num.to_s
end

Measured memory_bytes: 9028
#include<bits/stdc++.h>
using namespace std;
int a,n,x;
int main()
{
	cin>>a>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		a-=x;
	}
	if(a<=0)cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef double          D;
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define pb              push_back
#define GCD(a, b)       __gcd(a, b)
#define PI              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define Rep(i,a,b)      for(int i = a; i <= b; i++)
#define rep(i,a,b)      for(int i = a; i >= b; i--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)

#define si(x)           scanf("%d",&x)
#define pi(x)           printf("%d",x)
#define ss(str)         scanf("%s",str)
#define pl(x)           printf("%lld",x)
#define sl(x)           scanf("%lld",&x)
#define sii(x,y)        scanf("%d %d",&x,&y)
#define sll(x,y)        scanf("%lld %lld",&x,&y)
#define siii(x,y,z)     scanf("%d %d %d",&x,&y,&z)
#define slll(x,y,z)     scanf("%lld %lld %lld",&x,&y,&z)
using namespace std;



/*
int bs(int l,int r)
{
    int mid,res=inf;

    while(l<=r)
    {
        mid=l+(r-l)/2;

        if(check(mid,0)|| check(mid,1))
        {
            res=min(res,mid);
            r=mid-1;
        }
        else
            l=mid+1;

    }


    return res;
}*/
int NOD[10000002];

void NumberOfDivisors(int n)
{
    for(int i=1; i<=n;i++)
    {
        for(int j=i ;j<=n ;j+=i)
            NOD[j]++;
    }
}


int main()
{
    int n;
    si(n);

    NumberOfDivisors(n);

    LL res=0;

    Rep(i,1,n)
    {
        res+=((LL)i*(LL)NOD[i]);
    }


    printf("%lld\n",res);


    return 0;

}
/*
LL n,m,k,x;
    slll(n,m,k);

    LL first[n+5];
    LL second[m+5];
    first[0]=0;
    second[0]=0;

    Rep(i,1,n)
    {
        sl(first[i]);
        first[i]+=first[i-1];
    }

    Rep(i,1,m)
    {
        sl(second[i]);
        second[i]+=second[i-1];
    }


    LL i=n,j=m;

    while(true)
    {

    }
*/


Measured memory_bytes: 42828
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned int;
using vi  = vector<int>; using vb  = vector<bool>; using vd  = vector<double>; using vl  = vector<ll>;
using vvi = vector<vi>;  using vvb = vector<vb>;   using vvd = vector<vd>;     using vvl = vector<vl>;
 
#define REP(i,n) for(ll i=0; i<(n); ++i)
#define FOR(i,b,n) for(ll i=(b); i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define TEN(x) ((ll)1e##x)
 
template<typename T> inline string join(const vector<T>& vec, string sep = " ") { stringstream ss; REP(i, vec.size()) ss << vec[i] << ( i+1 == vec.size() ? "" : sep ); return ss.str(); }
 
 
///////////////
 
#define EPS (1e-10)
#define NEXT(x, i) (x[(i + 1) % x.size()])
 
template<class T> using CR = const T &;
using P = complex<ld>;
using G = vector<P>;
 
int sgn(ld a, ld b = 0) {
    if (a > b + EPS) return 1;
    if (a < b - EPS) return -1;
    return 0;
}
 
ld dot(P a, P b) { return real(conj(a)*b); }
ld cross(P a, P b) { return imag(conj(a)*b); }
 
int ccw(P a, P b, P c) {
    b -= a;
    c -= a;
    if (sgn(cross(b, c))) return sgn(cross(b, c)); // clockwise or counter clockwise
    if (sgn(dot(b, c)) == -1) return 2;            // c--a--b
    if (sgn(norm(b), norm(c)) == -1) return -2;    // a--b--c
    return 0;                                      // a--c--b
}
 
struct L : public vector<P> {
    L(P a, P b) { push_back(a); push_back(b); }
};

bool iLL(CR<L> l, CR<L> m, bool strict = false) {
	if (sgn(cross(l[1] - l[0], m[1] - m[0]))) return true;   // not-parallel
	return !strict && !sgn(cross(l[1] - l[0], m[0] - l[0])); // same line
}
bool iLS(CR<L> l, CR<L> s, bool strict = false) {
	int c = sgn(cross(l[1] - l[0], s[0] - l[0])) * sgn(cross(l[1] - l[0], s[1] - l[0]));
	return c <= 0 && (!strict || c == -1);
}
bool iSS(CR<L> s, CR<L> t, bool strict = false) {
	int ccwa = ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]);
	int ccwb = ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]);
	return ccwa <= 0 && (!strict || ccwa == -1)
		&& ccwb <= 0 && (!strict || ccwb == -1);
}
ld dLP(CR<L> l, P p) { return abs(cross((l[1] - l[0]), p - l[0]) / (l[1] - l[0])); }
ld dSP(L s, P p) {
	if (dot(s[1] - s[0], p - s[0]) < 0) return abs(p - s[0]);
	if (dot(s[1] - s[0], p - s[1]) > 0) return abs(p - s[1]);
	return dLP(s, p);
}
ld dLL(CR<L> a, CR<L> b) { return iLL(a, b) ? 0 : dLP(a, b[0]); }
ld dLS(CR<L> a, CR<L> b) { return iLS(a, b) ? 0 : min(dLP(a, b[0]), dLP(a, b[1])); }
ld dSS(CR<L> a, CR<L> b) { return iSS(a, b) ? 0 : min(min(dSP(a, b[0]), dSP(a, b[1])), min(dSP(b, a[0]), dSP(b, a[1]))); }

//////////////
 
int main() {
#ifdef INPUT_FROM_FILE
    ifstream cin("sample.in");
    ofstream cout("sample.out");
#endif
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(30);
	ll n; cin >> n;
	REP(i, n) {
		ld x0, y0, x1, y1, x2, y2, x3, y3;
		cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		cout << dSS({ { x0, y0 }, { x1, y1 } }, { { x2, y2 }, { x3, y3 } }) << endl;
	}
    return 0;
}

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

using ll=long long;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,k;
  cin>>n>>k;
  ll sum=0;
  int h[n];
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  sort(h,h+n);
  for(int i=0;i<n-k;i++){
    sum+=h[i];
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
#include <cassert>
#include <complex>
using namespace std;
//#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<int,P> Q;

int main() {
    int n,k;
    cin>>n>>k;
    vector<P>p(n);
    vector<ll>X,Y;
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        p[i]=P(x,y);
        X.push_back(x);
        Y.push_back(y);
    }
    sort(X.begin(),X.end());
    sort(Y.begin(),Y.end());
    ll ans = 1LL*(X[X.size()-1]-X[0])*(Y[Y.size()-1]-Y[0]);
    for(int x1=0;x1<n;x1++){
        for(int x2=x1+1;x2<n;x2++){
            for(int y1=0;y1<n;y1++){
                for(int y2=y1+1;y2<n;y2++){
                    int num = 0;
                    ll lx = X[x1],rx = X[x2];
                    ll by = Y[y1],uy = Y[y2];
                    for(int i=0;i<n;i++){
                        if(lx<=p[i].first&&p[i].first<=rx&&by<=p[i].second&&p[i].second<=uy){
                            num++;
                        }
                    }
                    if(num>=k){
                        ans = min(ans,1LL*(rx-lx)*(uy-by));
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll n,a[300010],s[2][300010]={},mx=-1e17;
  cin>>n;
  Fr(i,3*n) cin>>a[i];
  priority_queue<ll,vector<ll>,greater<ll>> pq;
  Fr(i,n){
    s[0][i]=s[0][i-1]+a[i];
    pq.push(a[i]);
  }
  Fr(j,n){
    ll i=n+j;
    pq.push(a[i]);
    s[0][i]=s[0][i-1]+a[i]-pq.top();
    pq.pop();
  }
  priority_queue<ll> PQ;
  fr(j,n){
    ll i=3*n-j;
    s[1][i]=s[1][i+1]+a[i];
    PQ.push(a[i]);
  }
  fr(j,n){
    ll i=2*n-j;
    PQ.push(a[i]);
    s[1][i]=s[1][i+1]+a[i]-PQ.top();
    PQ.pop();
  }
  fr(j,n+1) mx=max(mx,s[0][n+j]-s[1][n+j+1]);
  cout<<mx<<endl;
}

Measured memory_bytes: 9588
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << " : " << x << endl

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No") {
		if (judge_exp) {
			cout << ok << endl;
		}
		else {
			cout << ng << endl;
		}
	}

	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000007;
	const int tenfive = 100000;
}

using namespace atcoder;

int main() {
	int n, h, w;
	cin >> n >> h >> w;
	int ans = 0, hi, wi;
	for (int i = 0; i < n; i++) {
		cin >> hi >> wi;
		if (hi >= h && wi >= w) {
			ans++;
		}
		
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,ii> iii;
typedef pair<int, iii> iiii;
typedef pair<double, ii> dii;
typedef long long ll;
typedef pair<ll, ii> lii;
const int INF = 1000000000;
const double EPS = 1e-9;
#define LSOne(S) (S & (-S))
int mods(int a, int b) { return (b + (a%b)) % b; }
 
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    
    int n, ans = 0, tmp[3], a[25];

    cin >> n;

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

    for (int i = 1; i < n-1; i++) {
        tmp[0] = a[i-1];
        tmp[1] = a[i];
        tmp[2] = a[i+1];
        sort(tmp, tmp+3);
        if (tmp[1] == a[i]) ans++;
    }

    cout << ans << '\n';
 
    return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

int main(){
    string S, T;
    getline(cin, S);
    getline(cin, T);
    int s, t;
    s = S.size();
    t = T.size();

    int minC = 1000;
    for(int i = 0; i < s; i++){
        int cnt = 0;
        for(int j = 0; j < t; j++){
            if(i + j >= s){
                cout << minC << endl;
                return 0;
            };
            if(T.at(j) != S.at(i + j)) cnt++;
        }
        minC = min(minC, cnt);
    }
    cout << minC << endl;
}

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

int main(){
   int n,m;
   
   cin>>n;
   vector<string> plus(n);
   for(int i=0;i<n;i++){
       cin>>plus.at(i);
   }
   
   cin>>m;
   vector<string> minus(m);
   for(int i=0;i<m;i++){
       cin>>minus.at(i);
   }
   
   int counter1,counter2;
   int result=0;
   
   for(int i=0;i<n;i++){
       counter1=counter2=0;
       for(int k=0;k<n;k++){
           if(plus[i]==plus[k]) counter1++;
       }
       for(int j=0;j<m;j++){
           if(plus[i]==minus[j]) counter2++;
       }
       if(result<(counter1-counter2)) result=counter1-counter2;
   }
   cout<<result<<endl;
   return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N;
int ans[20000];

signed main()
{
	cin >> N;

	if (N == 3)
	{
		cout << "2 5 63" << endl;
		return 0;
	}

	if (N <= 15002)
	{
		int max = 0;
		int sum = 0;
		for (int i = 0; i < N - 3; i++)
		{
			ans[i] = (i + 1) * 2;
			max = MAX(ans[i], max);
			sum += ans[i];
		}
		for (int i = max + 2; i <= 30000; i += 2)
		{
			if(((sum + i) % 3) == 0)
			{
				ans[N - 3] = i;
				ans[N - 2] = 3;
				ans[N - 1] = 9;
				break;
			}
		}
	}
	else
	{
		int max = 0;
		int sum = 0;

		int m = 15000;
		if (N % 2 != 0)
		{
			m = 14999;
		}
		for (int i = 0; i < m; i++)
		{
			ans[i] = (i + 1) * 2;
			max = MAX(ans[i], max);
			sum += ans[i];
		}
		for (int i = 0; i < N - m; i++)
		{
			ans[i + m] = 3 * (i * 2 + 1);
		}
	}

	REP(i, N)
	{
		cout << (i ? " " : "") << ans[i];
	}
	cout << endl;
}







Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define maxn 200010
#define LL long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef pair<int,LL> pii;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int tot=1<<15;

int n;
LL a[maxn],sum,ans=0x3f3f3f3f3f3f3f3f,tmp;

int main(){
	//freopen("test.txt","r",stdin);
	
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",a+i),sum+=a[i];
	for(int i=1;i<=n;i++){
		tmp+=a[i];
		ans=min(ans,abs(sum-2*tmp));
	}
	cout<<ans<<endl;
	
	return 0;
} 

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
int main() {
	int n;
	string s;
	cin >> n >> s;
	int m;
	m = s.size();
	rep(i, m) {
		s[i] = (s[i] - 'A' + n)%26+'A';
	}
	cout << s << endl;

}







Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second

ll x, y, z;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> x >> y >> z;
	x = abs(x);
	
	ll d = min(x / z, y);
	x -= d * z, y -= d;
	
	if(y & 1) x = z - x * (!!x);
	
	cout << x << endl;

	return 0;
}

Measured memory_bytes: 3648
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	l := make([]int, n)
	for i := 0; i < n; i++ {
		l[i] = nextInt()
	}

	sort.Ints(l)
	max := l[n-1]
	others := 0
	for i := 0; i < n-1; i++ {
		others += l[i]
	}
	if max < others {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 640
/*-------------------------------"ANJAN AGARWALA"-----------------------------

         _/_/_/_/    _/_/    _/   _/_/_/_/   _/_/_/_/    _/_/    _/   
        _/    _/    _/ _/   _/         _/   _/    _/    _/ _/   _/        
       _/_/_/_/    _/   _/ _/         _/   _/_/_/_/    _/  _/  _/         
      _/    _/    _/    _/_/   _/    _/   _/    _/    _/    _/_/  
     _/    _/    _/      _/   _/_/_/_/   _/    _/    _/      _/   

-------------------------------------@anjn98---------------------------------*/

//#define opti
#ifdef opti
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long long int LL;
typedef unsigned long long int ull;
ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;*/

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int csrand(int l=0, int r=1e9){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define PR(a)           cout<<"("<<a<<")";
#define ED              cout<<'\n';
#define endl            '\n'
#define loop(j,a,n)     for(int j=a;j<=n;j++)
#define loop1(j,a,n)    for(int j=a;j>=n;j--)
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define trav(x,s)       for(auto x:s)
#define SC(n)           scanf("%d",&n)
#define PB              push_back
#define MP              make_pair
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first
#define S               second 
#define binf            2000000000000000001
#define mod             1000000007


const int N=21;

int n;
int dp[N][1<<N],tab[N][N];

int solve(int i,int mask)
{
    if(i==n)
        return (mask+1) == (1<<n) ;

    if(dp[i][mask]!=-1) return dp[i][mask];

    int ans=0;
    for(int w=0;w<n;w++)
    {
        if(tab[i][w]==0) continue;
        if(mask&(1<<w)) continue;
        ans=(ans+ solve(i+1, mask|(1<<w)))%mod;
    }
    return dp[i][mask]=ans;
}

int main() 
{
    IO

    memset(dp,-1,sizeof(dp));
    
    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++) 
            cin>>tab[i][j];
    
    int ans=solve(0,0);
    cout<<ans<<endl;
}




 

Measured memory_bytes: 172288
#include <cstdio>

int main()
{
    int a,b,c,sum;
    scanf("%d/%d/%d",&a,&b,&c);
    
    sum = a + 1;
    
    if(b < 10)
    {
        printf("%d/0%d",sum,b);
    }
    else
    {
        printf("%d/%d",sum,b);
    }
    
    
    if(c < 10)
    {
        printf("/0%d",c);
    }
    else 
    {
        printf("/%d",c);
    }
    
    
    

}



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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)


int main() {
	string s, t;
	cin >> s >> t;
	int lim = SZ(s)-1;
	int res = 0;
	FOR(i, 0, lim) {
		if (s[i] != t[i]) {
			res++;
		}
	}
	pv(res);
	return 0;
}

Measured memory_bytes: 3864
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)



int main(){
	int n;
	cin >> n;
	vector<tuple<string, int, int>> p(n);
	int input;
	REP(i,n){
		cin >> get<0>(p[i]) >> input;
		get<1>(p[i]) = input * -1;
		get<2>(p[i]) = i+1;
	}
	sort(p.begin(), p.end());
	
	REP(i,n){
		cout << get<2>(p[i]) << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void){
    long long x,k,d,ans;
    scanf("%lld %lld %lld", &x,&k,&d);

    x = llabs(x);
    if(x/d>=k-1){
        printf("%lld\n", llabs(x - k*d));
        return 0;
    }else{
        if((k - x/d)%2 == 0){
            ans = x%d;
        }else{
            ans = d - x%d;
        }
    }

    printf("%lld\n", llabs(ans));
}


Measured memory_bytes: 1736
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);


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

	int A, B, C, K;
	cin >> A >> B >> C >> K;

	const int ans = (A - B)*(K % 2 ? -1 : 1);
	cout << ans << endl;

	return 0;
}

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

string s;
int k;
set<string> se;

int main() {    
    cin >> s >> k;
    for (int i = 0; i < s.size(); i++) {
        for (int j = 1; j <= k; j++) {
            if (i + j > s.size()) break;
            se.insert(s.substr(i, j));
        }
    }
    for (int i = 1; i < k; i++) se.erase(se.begin());
    cout << *se.begin() << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cstdlib>
#include <typeinfo>

using namespace std;

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


int i,j;

int main(void){
    
    int n,m;
    cin >> n >> m;
    int a[m],b[m];
    FOR(i,m)cin>>a[i]>>b[i];
    
    int ans[n];
    FOR(i,n)ans[i]=0;
    
    FOR(i,m){
        ans[ a[i]-1 ]++;
        ans[ b[i]-1 ]++;
    }
    FOR(i,n)cout<<ans[i]<<endl;
    
    return 0;
    
}


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

int N, Q;
int const INF = INT_MAX;

struct SegmentTree {
private:
    int n;
    vector<int> node;

public:
    SegmentTree(vector<int> v) {
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, INF);
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }

    void update(int x, int val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = min(node[2*x+1], node[2*x+2]);
        }
    }

    int getmin(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return INF;
        if(a <= l && r <= b) return node[k];

        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};

int main() {
    cin >> N >> Q;
    SegmentTree seg( vector<int>(N, INF) );
    for(int i=0; i<Q; i++) {
        int c, x, y; cin >> c >> x >> y;
        if(c == 0) seg.update(x, y);
        else cout << seg.getmin(x, y+1) << endl;
    }    
}

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

static const int INF = 1e9+7;

int main(){
    int N;
    cin>>N;
    vector<int> H(N);
    vector<int> dp(100000,INF);
    for(int i=0; i<N; i++){
        cin>>H[i];
    }

    dp[0] = 0;

    for(int i=0; i<N; i++){
        dp[i+1] = min(dp[i]+abs(H[i]-H[i+1]),dp[i+1]);
        dp[i+2] = min(dp[i]+abs(H[i]-H[i+2]),dp[i+2]);
    }

    cout<<dp[N-1]<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map
#include<cmath>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 10000007

typedef  long long ll;

using namespace std;

ll gcd(ll a,ll b){
    if (b==0)return a;
    return gcd(b,a%b);
}

ll deg(int i){
  ll ret = 1;
  while(i != 0){
    if(i/10 == 0){
      break;
    }
    i/=10;
  }
  
  return i;
}
bool judge(string s){
  bool ret = false;
  string t = s;
  reverse(t.begin(), t.end());
  if(s == t){
    ret = true;
  }
  return ret;
}

// //map<ll,ll> m;
vector<ll> v;
ll k;

void rec(ll cur, ll deg){
  if(deg == 10) return; //k個数出てきたら終わり.
  
  //最初のケース
  if(cur == 0){
    deg++;
    v.push_back(1);rec(1, deg);
    v.push_back(2);rec(2, deg);
    v.push_back(3);rec(3, deg);
    v.push_back(4);rec(4, deg);
    v.push_back(5);rec(5, deg);
    v.push_back(6);rec(6, deg);
    v.push_back(7);rec(7, deg);
    v.push_back(8);rec(8, deg);
    v.push_back(9);rec(9, deg);
  }else{
    //最下位の数を考える
    ll a = cur%10; //同じ数
    ll b = min(9LL,cur%10+1LL); //1だけ大きい数
    ll c = max(cur%10-1LL,0LL); //1だけ小さい数
    deg++;
    if(a != b && b != c){
      v.push_back(cur*10+a);rec(cur*10+a, deg);
      v.push_back(cur*10+b);rec(cur*10+b, deg);
      v.push_back(cur*10+c);rec(cur*10+c, deg);
    }
    if(a == b){
      v.push_back(cur*10+b);rec(cur*10+b, deg);
      v.push_back(cur*10+c);rec(cur*10+c, deg);
    }else if(a == c){
      v.push_back(cur*10+a);rec(cur*10+a, deg);
      v.push_back(cur*10+b);rec(cur*10+b, deg);
    }
  }
}


void solve(){
  cin >> k;
  rec(0LL,0LL);
  ll  ans = 0;
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(), v.end()) ,v.end());
  
  cout << v[k-1] << endl;
  
}


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


Measured memory_bytes: 6596
/*"You can do anything you set your mind to,man" - Eminem*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define llpow(a,b) (ll)(pow(a,b)+0.5)
#define l_b(a,val) min((int)a.size()-1, (int)(lower_bound(a.begin(),a.end(),val)-a.begin()))
#define f first
#define s second
#define INF 9223372036854775807
const  int mod = 1000000007;
void add(ll& a, ll b){a+=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
void mul(ll& a, ll b){a*=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
ll binexpomodulo(ll x, ll y){ll res =1;x%=mod;if(!x)return 0;while(y){if(y&1){mul(res, x);}mul(x,x);y>>=1;}return res;}
ll nCrInOr(ll n, ll r){ll res = 1;if(r>n-r)r = n-r;ll rin = 1;for(ll i = 1; i <=r ; i++)rin = (rin*i)%mod;rin = binexpomodulo(rin,mod-2);for(ll i = 1; i <= r; i++)res = (res*(n-i+1))%mod;res = (res*rin)%mod;return res;}
int msb(ll n){int ans;for(int i = 0 ; i < 64;  i++)if(n&(1LL<<i))ans = i+1;return ans;}
void strrev(string& s){int n = (s.size());for(int i = 0 ; i < n/2; i++)swap(s[i],s[n-1-i]);}
int main()
{
	int n,k; cin>>n>>k;
	ll a[n];
	for(int i = 0 ; i < n ;i++){
		cin>>a[i];
	}
	vector<ll> dp(n,INF);
	dp[0] = 0LL;
	for(int i = 1 ; i < n ; i++)
		for(int j = 1; (j<=k)&&((i-j)>=0) ;j++)
				dp[i] = min(dp[i],abs(a[i]- a[i-j]) + dp[i-j]);
			cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
typedef struct {
	long long yen, stock;
}Store;
bool cmp(Store a, Store b) {
	return a.yen < b.yen;
}
int main()
{
	long long N, M, L, ans = 0;;
	Store s[100000];
	std::cin >> N >> M;
	for (int i = 0; i < N; i++)
		std::cin >> s[i].yen >> s[i].stock;
	std::sort(s, s + N, cmp);
	L = M;
	for (int i = 0; i < N; i++) {
		if (L <= s[i].stock) {
			ans += L * s[i].yen;
			break;
		}
		else {
			L -= s[i].stock;
			ans += s[i].stock * s[i].yen;
		}
	}
	std::cout << ans << "\n";
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

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

struct Dinic {
	struct edge {
		int to;
		ll cap;
		int rev;
		bool isrev;
		int idx;
		edge(int _to, ll _cap, int _rev, bool _isrev, int _idx) :to(_to), cap(_cap), rev(_rev), isrev(_isrev), idx(_idx) {}
	};
	vector<vector<edge>> g;
	vector<int> min_cost, iter;
	Dinic(int n) :g(n) {}

	void add_edge(int from, int to, ll cap, int idx = -1) {
		g[from].emplace_back(to, cap, (int)g[to].size(), false, idx);
		g[to].emplace_back(from, 0, (int)g[from].size() - 1, true, idx);
	}

	bool bfs(int s, int t) {
		min_cost.assign(g.size(), -1);
		queue<int> q;
		q.emplace(s);
		min_cost[s] = 0;
		while (!q.empty() && min_cost[t] == -1) {
			int cur = q.front();
			q.pop();
			for (auto& e : g[cur]) {
				if (e.cap > 0 && min_cost[e.to] == -1) {
					min_cost[e.to] = min_cost[cur] + 1;
					q.push(e.to);
				}
			}
		}
		return min_cost[t] != -1;
	}

	ll dfs(int idx, const int t, ll flow) {
		if (idx == t) return flow;
		for (int& i = iter[idx]; i < g[idx].size(); i++) {
			edge& e = g[idx][i];
			if (e.cap > 0 && min_cost[idx] < min_cost[e.to]) {
				ll d = dfs(e.to, t, min(flow, e.cap));
				if (d > 0) {
					e.cap -= d;
					g[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	ll max_flow(int s, int t) {
		ll flow = 0;
		while (bfs(s, t)) {
			iter.assign(g.size(), 0);
			ll f = 0;
			if ((f = dfs(s, t, INF)) > 0) flow += f;
		}
		return flow;
	}
};
int H, W;
int cnv(int i, int j) {
	return i * W + j + 1;
}
int dh[] = { 1,-1,0,0 };
int dw[] = { 0,0,1,-1 };
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	ll X, Y, E; scanf("%lld %lld %lld", &X, &Y, &E);
	Dinic g(X + Y + 2);
	for (int i = 1; i <= X; i++) {
		g.add_edge(0, i, 1);
	}
	for (int i = 1; i <= Y; i++) {
		g.add_edge(i + X, X + Y + 1, 1);
	}
	for (int i = 0; i < E; i++) {
		int x, y; scanf("%d %d", &x, &y);
		x++; y++;
		y += X;
		g.add_edge(x, y, 1);
	}
	cout << g.max_flow(0, X + Y + 1) << endl;
	return 0;
	/*
		おまじないを使ったらscanfとprintf関連注意！！！！！！！！！！！！
	*/
}



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

int main() {
    int n, m; 
    array<int, 100000> ts;
    array<int, 100> ps;
    array<int, 100000> xs;

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

    cin >> m;
    for (int i = 0; i < m; i++) {
        cin >> ps[i];
        cin >> xs[i];
    }

    for (int i = 0; i < m; i++) {
        int sum = 0;
        for (int j = 0; j < n; j++) {
            if (ps[i] == (j + 1)) {
                sum += xs[i];
            } else {
                sum += ts[j];
            }
        }
        std::cout << sum << '\n';
    }
}

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

int main() {
  int A, B, C;
  scanf("%d%d%d", &A, &B, &C);

  vector<int> s{A, B, C};
  sort(s.begin(), s.end());

  if (s.at(0) == 5 && s.at(1) == 5 && s.at(2) == 7) {
    printf("YES");
  } else {
    printf("NO");
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


i64 a,b;

int main(){
	cin >> a >> b;
	
	if(b-a >= 2018 || (a <= 2019 && b >= 2019)){
		cout << 0 << endl;
		return 0;
	}
	a %= 2019; b %= 2019;
	int ans = INF;
	for(int i = a; i < b; i++){
		for(int j = i+1; j <= b; j++){
			ans = min(ans, i*j % 2019);
		}
	}
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

int main()
{
  int N, K; cin >> N >> K;
  char D[11];
  for(int i = 0; i < K; i++) cin >> D[i];
  for(int i = N; ; i++) {
    string t = to_string(i);
    bool flag = true;
    for(int j = 0; j < K; j++) {
      if(t.find(D[j]) != string::npos) flag = false;
    }
    if(flag) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


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

const int inf = 1012345678;

int main()
{
	int n = 0;
	cin >> n;
	string ans = "No";
	for (int i =0; i <= n/4; i++)
	{
		for (int j = 0; j <= n/7; j++)
		{
			if (4 * i + 7 * j == n)
			{
				ans = "Yes";
			}
		}
	}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256