akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, M, ans;

int main()
{
	in >> N >> M;
	std::vector<LL>a(M), b(M);
	std::vector<std::vector<LL>>list(N + 1);
	rep(i, M)
	{
		in >> a[i] >> b[i];
		list[a[i]].push_back(b[i]);
	}
	std::set<LL>queue;
	for (LL i = 1; i <= N; ++i)
	{
		if (queue.size() > 0)
		{
			if (*queue.begin() == i)
			{
				++ans;
				queue.clear();
			}
		}
		for (auto j : list[i]) queue.insert(j);
	}
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
int a[159];
int main(){
	int n,d,x;
	cin>>n>>d>>x;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++){
		if(d%a[i]!=0){
		x+=d/a[i]+1;
	}
	else x+=d/a[i];
}
		cout<<x<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int a,b,c;

int main(){
  cin >> a >> b >> c;
  if(b-a==c-b) cout << "YES" << endl;
  else cout << "NO" << endl;

  
  return 0;
}



Measured memory_bytes: 256
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;


int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int t = 0;
	if (a >= b && a >= c) {
		t = a * 10 + b + c;
	}
	else if (b >= c) {
		t = b * 10 + a + c;
	}
	else {
		t = c * 10 + a + b;

	}
	cout << t << endl;
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=205;
int col[N],d[N],q[N],n,l,r,ans;
char s[N];
vi e[N];

void dfs(int u){
	for(auto v:e[u]){
		if(col[u]==col[v]){
			puts("-1");
			exit(0);
		}
		if(col[v]==-1){
			col[v]=col[u]^1;
			dfs(v);
		}
	}
}

int main(){
	read(n);
	rep(i,1,n){
		scanf("%s",s+1);
		rep(j,1,n){
			if(s[j]=='1') e[i].pb(j);
		}
	}
	memset(col,-1,sizeof col);
	col[1]=0,dfs(1);
	rep(s,1,n){
		memset(d,-1,sizeof d);
		l=r=0,d[s]=0,q[r++]=s;
		int mx=0;
		while(l<r){
			int u=q[l++];
			mx=max(mx,d[u]);
			for(auto v:e[u]){
				if(d[v]>=0) continue;
				d[v]=d[u]+1,q[r++]=v;
			}
		}
		ans=max(ans,mx+1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3948
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

vector<int> res;
int n, m, a, b;
vector<int> edge[216000];
bool used[216000];

void dfs(int x){
  res.push_back(x);
  used[x] = true;
  for(auto v:edge[x]){
    if(used[v])continue;
    dfs(v);
    return;
  }
}

int main(){
  cin >> n >> m;
  for(int i = 0;i < m;i++){
    cin >> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }

  int s = 1, g = edge[s][0];
  used[g] = true;
  dfs(s);
  for(int i = 0;i < res.size();i++){
    int k = res.size() - i - 1;
    if(i < k)swap(res[i], res[k]);
  }
  dfs(g);

  cout << res.size() << endl;
  for(auto v:res)cout << v << " ";cout << endl;
    
  return 0;
}

Measured memory_bytes: 12536
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int H1,M1,H2,M2,K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int m1 = H1*60 + M1;
    int m2 = H2*60 + M2;
    if(m2-m1>=0){
        cout << m2-m1-K << endl;
    }else{
        cout << m2+1440-m1-K << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b, c;
  cin >> a >> b >> c;
  int min1 = min(a+b,b+c);
  if (a + c > min1) {
  	cout << min1 << "\n";
  }else {
  	cout << a + c << "\n";
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int F[45][2];

int fib(int n){
  if(n == 0 || n == 1){
    F[n][0]=1;
    return F[n][1]=1;
  }
  if(F[n][0] == 1) return F[n][1];

  F[n][0]=1;
  return F[n][1] = fib(n-1) + fib(n-2);
}

int main(){
  int i,n;
  scanf("%d",&n);

  for(i=0;i<n;i++) F[i][0]=0;

  printf("%d\n", fib(n));

  return 0;
}



Measured memory_bytes: 2128
#include <iostream>
#include <vector>
#include <algorithm>

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

bool solve(int& iYukichi, int& iIchiyo, int& iHideyo, int N, int Y);

int main() {
  int N = 0;
  int Y = 0;
  std::cin >> N >> Y;
  int iYukichi = 0;
  int iIchiyo = 0;
  int iHideyo = 0;
  if(solve(iYukichi, iIchiyo, iHideyo, N, Y) == false) {
    std::cout << "-1 -1 -1" << std::endl;
  } else {
    std::cout << iYukichi << " " << iIchiyo << " " << iHideyo << std::endl;
  }
  return 0;
}

bool solve(int& iYukichi, int& iIchiyo, int& iHideyo, int N, int Y) {
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if((10000 * (N - i) + 5000 * (i - j) + 1000 * j) == Y) {
        iYukichi = N-i;
        iIchiyo = i - j;
        iHideyo = j;
        return true;
      }
    }
  }
  return false;
}

Measured memory_bytes: 256
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n int
	var s string
	fmt.Sscan(getNextLine(scanner), &n)
	fmt.Sscan(getNextLine(scanner), &s)
	min := n
	sums := make([]int, n+1)
	for i := 0; i < n; i++ {
		sums[i+1] = sums[i]
		if s[i] == '#' {
			sums[i+1]++
		}
	}
	for i := 0; i <= n; i++ {
		sum := sums[i] + (n - i) - (sums[n] - sums[i])
		if sum < min {
			min = sum
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 7552
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    if (v[n / 2 - 1] == v[n / 2])
    {
        cout << 0 << endl;
        return 0;
    }
    else
    {
        int cnt = v[n / 2] - v[n / 2 - 1];     
        cout << cnt << endl;
        return 0;  
    }

}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <set>
#include <numeric>
#include <algorithm>
#include <cstdlib>
#include <vector>

using namespace std;
int main() {
    string s;
    cin >> s;
    if(s.length() == 3){
        cout << s[2] << s[1] << s[0] << endl;
    }
    else cout << s << endl;

}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [A, B] = string_to_int(inputs[0])
    s = 0
    if A == 1:
        s += 300000
    elif A == 2:
        s += 200000
    elif A == 3:
        s += 100000

    if B == 1:
        s += 300000
    elif B == 2:
        s += 200000
    elif B == 3:
        s += 100000

    if A == 1 and B == 1:
        s += 400000
    return s


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


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

using namespace std;
typedef long long ll;

vector<ll>a(5005);
vector<ll>b(5005);
vector<ll>track;
bool vis[5005];

void dfs(int u, long long total_cycle)
{
    if(vis[u])
        return ;
    vis[u]=true;
    total_cycle+=b[u];
    track.push_back(total_cycle);
    dfs(a[u],total_cycle);
}

void solve()
{
    int n,k;
    cin>>n>>k;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        a[i]--;
    }
    for(int i=0; i<n; i++)
        cin>>b[i];
    ll ans=-(1e18);
    for(int i=0; i<n; i++)
    {
        memset(vis,false,sizeof(vis));
        dfs(i,0);
        if(track.back()>0 && k>=(int)(track.size()))
        {
            int m = (int) track.size();
            ll cycles= k/m;
            ll left= k%m;
            ll maxi=-1e18;
            for(int x=0; x<m; x++)
                maxi=max(maxi,track[x]);
            ans=max(ans,(cycles-1LL)*(track.back())+maxi);
            maxi=-1e18;
            for(int x=0; x<left; x++)
                maxi=max(maxi,track[x]);
            ans=max(ans,(cycles*track.back()) + maxi);
        }
        else
        {
            for(int j=0; j<(min((int)track.size(),k)); j++)
            {
                ans=max(ans,track[j]);
            }
        }
        track.clear();
    }
    cout<<ans;
    return;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
   
    return 0;
}


Measured memory_bytes: 3972
import java.util.Scanner;

public class Main{
 public static void main(String[] args){
     Scanner sc =new Scanner(System.in);
     while(true){
         String line =sc.next();
         int n=line.length();
         int sum=0;
         if(line.equals("0"))break;
         
         for(int i=0; i<n; i++){
             char a =line.charAt(i);
             int b = a-'0';
             sum+=b;
         }
         System.out.println(sum);
         
         
         
         
     }
 }
}


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

using namespace std;

int main(){
	int H,W,N,M;
	cin>>W>>H>>N>>M;
	vector<int>ret;
	while(W){
		vector<vector<int>>v(H,vector<int>(W,1));
		for(int i=0;i<N;i++){
			int a,b;
			cin>>a>>b;
			vector<vector<int>>w(H,vector<int>(W));
			if(a==1){
				for(int j=0;j<H;j++){
					for(int k=0;k<W;k++){
						if(k<b){
							w[j][b-k-1]+=v[j][k];
						}
						else{
							w[j][k-b]+=v[j][k];
						}
					}
				}
			}
			else{
				for(int j=0;j<H;j++){
					for(int k=0;k<W;k++){
						if(j<b){
							w[b-j-1][k]+=v[j][k];
						}
						else{
							w[j-b][k]+=v[j][k];
						}
					}
				}
			}
			v=w;
		}
		for(int i=0;i<M;i++){
			int a,b;
			cin>>a>>b;
			ret.push_back(v[b][a]);
		}
		cin>>W>>H>>N>>M;
	}
	for(auto i:ret)cout<<i<<endl;
}


Measured memory_bytes: 3160
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-') w=-1;
		c=getchar();
	}
	while(c<='9'&&c>='0')
	{
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return w==1?x:-x;
}

int n,m,vis[maxn],p;
vector <int> mp[maxn];
int ans1=0;
int ans2=0;
int ans3=0;

inline void dfs(int u,int fa)
{
	ans2=ans1=ans3=0;
	p++;ans2=ans1=ans3=0;
	vis[u]=1;ans2=ans1=ans3=0;
	for(int i=0; i<mp[u].size(); i++)
	{ans2=ans1=ans3=0;
		int v=mp[u][i];ans2=ans1=ans3=0;
		if(vis[v]||v==fa) continue;
		dfs(v,u);ans2=ans1=ans3=0;
	}
}

int main()
{
	n=read();ans2=ans1=ans3=0;
	m=read();ans2=ans1=ans3=0;
	rep(i,1,m)
	{ans2=ans1=ans3=0;
		int u=read(),v=read();
		mp[u].pb(v);ans2=ans1=ans3=0;
		mp[v].pb(u);ans2=ans1=ans3=0;
	}
	int tmp=0;ans2=ans1=ans3=0;
	rep(i,1,n) if(!vis[i]) p=0,dfs(i,0),tmp=max(tmp,p);
	ans2=ans1=ans3=0;
	cout<<tmp+ans1+ans2+ans3<<endl;
	return 0;
}


Measured memory_bytes: 43392
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

typedef struct piar{ll l,r;}I;

int hikaku(const void*p,const void*q){
	I pp=*(I*)p,qq=*(I*)q;
	if(pp.l<qq.l)return -1;
	if(pp.l>qq.l)return 1;
	return 0;
}

I a[200010];
ll rm[200010],rM[200010];
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n){
		int x,y;
		scanf("%d%d",&x,&y);
		if(x>y){ll t=x;x=y;y=t;}
		a[i].l=x;
		a[i].r=y;
	}
	
	qsort(a,n,sizeof(I),hikaku);
	
	rm[0]=INF,rM[0]=0;
	rep(i,0,n){
		rm[i+1]=min(rm[i],a[i].r);
		rM[i+1]=max(rM[i],a[i].r);
	}
	ll ans=(a[n-1].l-a[0].l)*(rM[n]-rm[n]);

	rep(i,0,n)ans=min(ans,(max(a[n-1].l,rM[i])-min(a[i].l,rm[i]))*(rM[n]-a[0].l));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 7548
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
#define MOD (ll)(1e9+7)
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

signed main(){
    ll n;
    cin >> n;
    string s,t;
    cin >> s >> t;

    ll ans = 1;
    t = "";
    rep(i,0,s.size()){
        if(i < (ll)s.size()-1 && s[i] == s[i+1]){
            t += '2';
            i++;
        }
        else{
            t += '1';
        }
    }

    rep(i,0,t.size()){
        if(i == 0){
            if(t[i] == '2') ans = 6;
            else ans = 3;
        }
        else if(t[i] == t[i-1]){
            if(t[i] == '1') ans *= 2;
            else ans *= 3;
        }
        else{
            if(t[i-1] == '1') ans *= 2;
        }
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long int ll;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct X_magic_ { X_magic_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } X_magic__;
constexpr ll INF = ((1LL << 61) + (1 << 29));

int main() {
	ll N, K;
	vector<ll> A;
	cin >> N >> K;
	A.resize(N);
	loop(i, N) cin >> A[i];
	for (ll i = K; i < N; ++i)
		std::cout << (A[i - K] < A[i] ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 4364
#include <stdio.h>
#define N 100000
int n, S[N];
int count(int );

int main()
{
	int i, a=0, q, T[N];

	scanf("%d", &n);

	for( i=0; i<n; i++){
		scanf("%d", &S[i]);
	}

	scanf("%d", &q);

	for( i=0; i<q; i++){
		scanf("%d", &T[i]);
	}

	for( i=0; i<q; i++){
		if( count(T[i]) == 1 ) a++;
	}

	printf("%d\n", a);

	return 0;
}

int count(int num)
{
	int i;

	for( i=0; i<n; i++){
		if( S[i] == num )return 1;
	}

	return 0;
}

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

const int N = 1e5 + 5;

int n, m, a[N];
int cnt[N];
vector<int> vec[N];
int res;

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		++cnt[a[i]];
	}
	for (int val = 1; val <= 1e5; ++val) {
		for (int i = 1; i <= cnt[val] - cnt[val] % 2; ++i) {
			vec[val % m].push_back(val);
		}
		cnt[val] %= 2;
	}
	for (int val = 1; val <= 1e5; ++val) if (cnt[val]) {
		vec[val % m].push_back(val);
	}

	for (int i = 0; i < m; ++i) {
		int j = (m - i) % m;
		if (i == j) {
			res += vec[i].size() / 2;
			vec[i].clear();
			continue;
		}
		while(vec[i].size() && vec[j].size()) {
			++res;
			vec[i].pop_back();
			vec[j].pop_back();
		}
	}

	for (int i = 0; i < m; ++i) {
		int ptr = 0;
		while(ptr < (int)vec[i].size() - 1) {
			if (vec[i][ptr] == vec[i][ptr + 1]) {
				ptr += 2;
				++res;
			} else {
				++ptr;
			}
		}
	}

	printf("%d\n", res);
}

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

int main(){
int num;
cin >> num;
//cout << num << "\n";
 vector<string> v(num);

for(int i =0; i<num; i ++)
{
    cin >> v[i];
}
size_t AC_count = count(v.begin(), v.end(), "AC" );
size_t WA_count = count(v.begin(), v.end(), "WA" );
size_t TLE_count = count(v.begin(), v.end(), "TLE" );
size_t RE_count = count(v.begin(), v.end(), "RE" );
//AC, WA, TLE, RE 

cout << "AC x " <<  AC_count  <<"\n"; 
cout << "WA x " <<  WA_count  <<"\n"; 
cout << "TLE x " <<  TLE_count  <<"\n"; 
cout << "RE x " <<  RE_count  <<"\n"; 


    return 0;
}




Measured memory_bytes: 6400
n, a = map(int, input().split())
x = list(map(lambda q: int(q) - a, input().split()))
X = max(max(x), a)
N = 2 * n * X
dp = [[0] * (N + 1) for i in range(n + 1)]
dp[0][n * X] = 1
for i in range(1, n + 1):
    for j in range(N + 1):
        if j - x[i - 1] < 0 or j - x[i - 1] > N:
            dp[i][j] = dp[i - 1][j]
        elif j - x[i - 1] <= N:
            dp[i][j] = dp[i - 1][j] + dp[i - 1][j - x[i - 1]]

print(dp[n][n * X] - 1)

Measured memory_bytes: 5236
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
string s;
int n,i;
int f()
{
	i++;
	vector<int>a;
	while(s[i]=='[')a.push_back(f()),i++;
	if(s[i]>='0'&&s[i]<='9')
	{
		int now=0;
		while(s[i]>='0'&&s[i]<='9')now=now*10+s[i]-'0',i++;
		now=now/2+1;
		a.push_back(now);
	}
	int ans=0;
	sort(a.begin(),a.end());
	for(int j=0;j<=(a.size()-1)/2;j++)ans+=a[j];
	return ans;
}
main()
{
	cin>>n;
	while(n--)
	{
		cin>>s;
		i=0;
		cout<<f()<<endl;
	}
}



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

int main(){
  int n,count=1,ans=1;
  cin >> n;
  vector<int> v(n,0);
  r(0,i,n)cin >> v.at(i);
  sort(v.begin(),v.end());
  r(0,i,n)ans*=3;
  r(0,i,n){
    if(v.at(i)%2==0)count*=2;
    else count*=1;
  }
  cout << ans-count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
  string S;
  cin >> S;
  int price = 700;
  for(int i; i < S.length(); ++i){
    if(S[i] == 'o'){
      price += 100;
    }
  }
  cout << price << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{

	public static void main(String[] args){
		
		Scanner sc =new Scanner(System.in);
	    
		Double x1=sc.nextDouble();
		Double y1=sc.nextDouble();
		Double x2=sc.nextDouble();
		Double y2=sc.nextDouble();
		
		System.out.printf("%f",distance(x1,y1,x2,y2));
		
	}
	private static double distance(double x1,double y1,double x2,double y2) {
		return Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
	}

		
		
}


Measured memory_bytes: 28220
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    d = int(ipt())
    c = [int(i) for i in ipt().split()]
    s = [[int(i) for i in ipt().split()] for _ in range(d)]
    for i in s:
        print(i.index(max(i))+1)
    
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 70392
x, y = map(int, input().split())

bfs = [[x, 0, '']]

ans = (abs(y) + abs(x)) * 2

while len(bfs) > 0:
    tmp = []
    for e in bfs:
        v, c, b = e
        if v == y:
            ans = min(ans, c)
            continue
        if b != 'B':
            tmp.append([-v, c + 1, 'B'])
        if v < y:
            ans = min(ans, c + y - v)
        if v < -y:
            tmp.append([-y, c + (-y - v), 'A']) 
    bfs = tmp

print(ans)

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class Main{
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args){
        int N, L;
        {int[] a = in.ii(); N = a[0]; L = a[1];}
        String[] S = new String[N];
        for(int i = 0; i < N; i++)
            S[i] = in.s();
        Arrays.sort(S);
        for(int i = 0; i < N; i++)
            out.print(S[i]);
        out.flush();
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include<set>
#define ll long long 
#include <string>
using namespace std;


int main()
{
	int n;
	cin>>n;
	if (n%2==0)
	cout<<n/2<<endl;
	else
	cout<<n/2+1<<endl;
}
	
 


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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}

ll pow(ll x, ll y) {
	if(y == 0)
	return 1;
	ll temp = pow(x, y/2);
	temp = (temp*temp);
	if(y%2 == 1)
		temp *= x;
	return temp;
}

#define int ll

int32_t main() {
	int k;
	cin >> k;
	queue<int> q;
	for(int i = 1; i <= 9; i++)
		q.push(i);
	while(k > 1) {
		k--;
		int x = q.front();
		q.pop();
		if(x%10 != 0)
			q.push(10*x + x%10 - 1);
		q.push(10*x + x%10);
		if(x%10 != 9)
			q.push(10*x + x%10 + 1);
	}
	cout << q.front();
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
int main(){
	ll a,b,c;
	ll total=0,temp;
	cin>>a>>b>>c;
	if(a<=b)cout<<a;
	else if(a<=b+c)cout<<b;
	else {
		temp=a%(b+c);
		if(temp<=b){
			total=a/(b+c)*b;
			cout<<temp+total;
		}
		else cout<<b+(a/(b+c)*b);
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include <stack>
using namespace std;
int main()
{
    int  n;
   scanf("%d",&n);
        stack<int>stk;
        int a;
        if(n==0)
            printf("0\n");
        else
        {
            while(n!=0)
            {
                a=abs(n%(-2));
                stk.push(a);
                n=(n-a)/(-2);
            }
        }
        while(!stk.empty())
        {
            printf("%d",stk.top());
            stk.pop();
        }
       printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

#include <stdio.h>

using namespace std;

int main(){

  char str[16];
  char ans[4];
  for(int i = 0; i < 3; i++){
    scanf("%s",str);
    ans[i] = str[i];
  }

  ans[3] = '\0';

  printf("%s\n",ans);

  return 0;
}


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

using namespace std;

//#define FILE_IO

int N, K, lowerThanK;
int v[5005];
bitset <5005> pfx[5005], sfx[5005];

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d", &N, &K);
    for(int i = 1; i <= N; i++)
        scanf("%d", &v[i]);

    pfx[0][0] = 1;
    for(int i = 1; i <= N; i++)
    {
        for(int j = 0; j < v[i] && j <= K; j++)
            pfx[i][j] = pfx[i - 1][j];
        for(int j = v[i]; j <= K; j++)
            pfx[i][j] = pfx[i - 1][j] | pfx[i - 1][j - v[i]];
    }

    sfx[N + 1][0] = 1;
    for(int i = N; i >= 1; i--)
    {
        for(int j = 0; j < v[i] && j <= K; j++)
            sfx[i][j] = sfx[i + 1][j];
        for(int j = v[i]; j <= K; j++)
            sfx[i][j] = sfx[i + 1][j] | sfx[i + 1][j - v[i]];
    }

    int ans = 0;
    for(int i = 1; i <= N; i++)
    {
        if(v[i] >= K)
            continue;

        int ok = 1;

        for(int j = K - 1; j >= K - v[i]; j--)
            for(int k = 0; k <= j; k++)
                if(pfx[i - 1][k] && sfx[i + 1][j - k])
                {
                    ok = 0;
                    break;
                }
        ans += ok;
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 6400
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<int> P(N), Q(N);
  rep(i,N) std::cin >> P[i];
  rep(i,N) std::cin >> Q[i];

  std::vector<int> A = P;
  std::sort( all(A) );

  int a, b;
  int cnt = 0;
  do {
    bool flagP = true;
    bool flagQ = true;
    rep(i,N) {
      if ( A[i] != P[i] ) flagP = false;
      if ( A[i] != Q[i] ) flagQ = false;
    }
    if ( flagP ) a = cnt;
    if ( flagQ ) b = cnt;
    cnt++;
  } while (std::next_permutation(all(A)));

  std::cout << std::abs(a-b) << std::endl;
  return 0;
}


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

int func(int a, int n) {
  int res = 0;
  while (n > 0) {
    res += n % a;
    n /= a;
  }
  return res;
}

int main() {
  int n, ans = INFINITY;
  cin >> n;
  for (int i = 0; i <= n; i++) ans = min(ans, func(6, i) + func(9, n - i));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            

            List<List<int>> Input = new List<List<int>>();


            int Item1;
            int Item2;
            int temp;

            for(int i = 0; i < 3001; i++)
            {
                var result1D = Console.ReadLine().Split(' ');

                Item1 = int.Parse(result1D[0]);

                Item2 = int.Parse(result1D[1]);


                if(Item1 > Item2)
                {
                    temp = Item2;
                    Item2 = Item1;
                    Item1 = temp;
                }


                List<int> localList = new List<int>();

                if (Item1 == 0 && Item2 == 0) break;

                localList.Add(Item1);
                localList.Add(Item2);

                Input.Add(localList);
            }

            foreach(var result in Input)
            {
                Console.WriteLine("{0} {1}", result[0], result[1]);
            }

        }



    }

}

Measured memory_bytes: 9584
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;


int main() {
	int n, m; cin >> n >> m;
	vector<int> d = { 0,2,5,5,4,5,6,3,7,6 };
	bool avl[13] = {};
	for (int i = 0; i < m; i++) {
		int a; cin >> a;
		avl[a] = true;
	}
	vector<int> ord = { 1, 7, 4, 5, 3, 2, 9, 6, 8 };
	vector<vector<int>> dp(n + 2, vector<int>(13, -1));
	auto cmp = [](const vector<int> &a, const vector<int> &b) {
		int cnta = 0, cntb = 0;
		for (int i = 1; i < 10; i++) cnta += a[i];
		for (int i = 1; i < 10; i++) cntb += b[i];
		if (cnta != cntb) return cnta < cntb;
		for (int i = 9; i >= 1; i--) {
			if (a[i] != b[i]) return a[i] < b[i];
		}
		return false;
	};
	for (int i = 0; i < 10; i++) dp[0][i] = 0;
	for (int c : ord) {
		if (!avl[c]) continue;
		for (int i = 0; i <= n; i++) {
			if (dp[i][0] == -1) continue;
			if (i + d[c] > n) continue;
			auto v = dp[i];
			v[c]++;
			if (!cmp(dp[i + d[c]], v)) continue;
			for (int j = 0; j < 10; j++) dp[i + d[c]][j] = dp[i][j];
			dp[i + d[c]][c]++;
		}
	}
	for (int i = 9; i >= 1; i--) {
		if (!avl[i]) continue;
		for (int j = 0; j < dp[n][i]; j++) cout << i;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<int,int> P;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};
//UnionFind Uni(N);
//Uni.connect;

int main(){
  int n,m;
  cin >> n >> m;
  UnionFind Uni(n);
  rep(i,m){
    int x,y,z;
    cin >> x >> y >> z;
    x--,y--;
    Uni.connect(x,y);
  }
  map<int,int> a;
  rep(i,n){
    a[Uni.root(i)]++;
  }
  cout << a.size() << endl;
}


Measured memory_bytes: 5376
#import <stdio.h>
#import <math.h>

#if !defined(MAX)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif

#if !defined(MIN)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif

int main(){
        int N,K;
        scanf("%d %d", &N,&K);
        double result = MAX(((double)N-(double)K+1.0)/((double)N), 0);
        for (int a=1;a<=MIN(K-1,N);a++){
            double n = ceil(log2((double)K/(double)a));
            result += 1.0/N * pow(0.5,n);
        }
        printf("%.16f", result);
    return 0;
}



Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int mod = 2019;
//const int mod = 998244353;

struct mint {
    int64_t x;
    mint(int64_t x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int64_t t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

};

istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();

    vector<ll> mu(2019);
    mu[0]++;
    reverse(all(s));
    mint now;
    mint x = 1;
    rep(i, n) {
        now += x*(s[i]-'0');
        mu[now.x] += 1;
        x *= 10;
    }

    ll ans = 0;
    rep(i, 2019) {
        ans += (mu[i] * (mu[i]-1)) >> 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
//debug
#ifdef grief
#define debug(...) do{\
	fprintf(stderr , "%s - %d : (%s) = " , __PRETTY_FUNCTION__ , __LINE__ , #__VA_ARGS__ );\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){
	cerr<<x<<endl;
}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){
	cerr<<x<<" , ";
	_DO(tail...);
}
#else
#define debug(...)
#endif
//type
typedef long long ll;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef priority_queue<pll,vector<pll>,greater<pll> > heap;
//macro
#define SZ(x) ((ll)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REP1(i,a,b) for(ll i=(a);i<=(b);i++)
#define mkp make_pair
#define pb push_back
const ll INF=1e18;
const ll MA=1e6+5;
const ll MOD=1e9+7;
//}}}
ll cnt[100100];
vector<pii> box;
int cc;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll n,x;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		cnt[x]++;
	}
	int ans=0;
	for(int i=1;i<=100000;i++){
		if(cnt[i]){
			//box.pb({i,cnt[i]});
			ans+=cnt[i]-1;
		}
	}
	ans++; ans/=2; ans*=2;
	cout<<n-ans<< '\n';
	//int l=0,r=SZ(box)-1;
	
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

void quick(int *,int,int);

int main(){

int N;
scanf("%d",&N);
int member = 3*N;
int a[member];

for (int i = 0; i < member; i++){
    scanf("%d",&a[i]);
}

quick(a,0,member-1);

long long ans=0;
for (int i = member-2; i >= N; i-=2)
{
  ans += a[i];
}

printf("%lld",ans);

return 0;

}
void quick(int a[],int left,int right)
{
    int s,t,i,j;

    if (left<right){
        s=a[left];
        i=left; j=right+1;
        while (1){         
            while (a[++i]<s);
            while (a[--j]>s);
            if (i>=j) break;
            t=a[i]; a[i]=a[j]; a[j]=t;
        }
        a[left]=a[j]; a[j]=s;

        quick(a,left,j-1);
        quick(a,j+1,right);
    }
}

Measured memory_bytes: 2848
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  string s;
  while(cin>>s,s!="0"){
    int sum=0;
    rep(i,s.size())sum+=s[i]-'0';
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod= 1e9+7;

int main(){
  ll A[3];
  cin>>A[0]>>A[1]>>A[2];
  sort(A,A+3);
  if (A[0]%2==1&&A[1]%2==1&&A[2]%2==1){
    cout << A[0]*A[1]*(A[2]/2+1) - A[0]*A[1]*(A[2]/2)<<endl;
  }else {
    cout << 0 << endl;
  }
  return 0;
}


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

    int n;
    vector<int> height;

    int dp[H_MAX];
        
        
    //top down approach
    int minimumCost(int stone){
        //base case
        if(stone==n-1){
            return dp[stone] = 0;
        }
     
        // memory lookup
        if(dp[stone]!=INT_MAX){
            return dp[stone];
        }
        
        // recursion logic
        int oneStep = minimumCost(stone+1) + abs(height[stone]-height[stone+1]);
        
        int twoStep = INT_MAX;
        
        if(stone+2<n) twoStep = minimumCost(stone+2) + abs(height[stone]-height[stone+2]);
        
        return dp[stone] = min(oneStep, twoStep);
    }
        
    int main(){
        cin >> n;
        
        for(int i=0; i<n; i++){
            int x;
            cin >> x;
            height.push_back(x);
        }

        for(int i=0; i<H_MAX; i++){
            dp[i] = INT_MAX;
        }
        
        cout << minimumCost(0) << endl;
        
        return 0;
    }

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

using namespace std;
typedef long long ll;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n));

void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}
const int MAX = 1e5 + 9;
ll arr[MAX], dp[MAX];
int k,n;
int main() {
    fast();
    cin >> n>>k;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    clr(dp,10000);
    dp[0]=0;
    dp[1]=abs(arr[0]-arr[1]);
    for (int j = 2; j < n; ++j) {
        for (int i = 1; i <= min(k,j); ++i) {
            dp[j]=min(dp[j-i]+abs(arr[j]-arr[j-i]),dp[j]);
        }
     //   cout<<dp[j]<<" ";
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
#include<cstdio>
long long a,b,x,o,k;
int main()
{
    scanf("%lld%lld%lld",&a,&b,&x);
    if(a%x)
        o=a/x+1;
    else
        o=a/x;
    k=b/x;
    printf("%lld\n",k-o+1);
    return 0;
}

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

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fst first
#define snd second
typedef long long ll;
inline void Fail(){printf("0");exit(0);}

const int maxn=5005;
const int maxm=205;
int n,m;
int a[maxn],b[maxn][maxm];
ll ans,dis[maxn],sum[maxn][maxn];

class segtree{
public:
	int id,sz;
	pii t[maxn*4];
	void build(){
		for(sz=1;sz<=n;sz<<=1);
		rep(i,sz<<1)t[i]=mp(-1,-1);
		rep(i,n)t[sz+i]=mp(b[i][id],i);
		for(int i=sz-1;i>=0;i--)t[i]=max(t[i<<1],t[i<<1|1]);
	}
	pii query(int l,int r){
		pii res=mp(-1,-1);
		for(l+=sz,r+=sz;l<=r;l>>=1,r>>=1){
			if(l&1)res=max(res,t[l]),l++;
			if((r+1)&1)res=max(res,t[r]),r--;
		}
		return res;
	}
}T;

void add(int l,int r){
	if(l>r)return;
	pii cur=T.query(l,r);
	int pos=cur.snd,val=cur.fst;
//	cout<<l<<" "<<r<<" "<<pos<<" "<<val<<endl;
	sum[l][r]+=val;
	if(pos)sum[l][pos-1]-=val;
	sum[pos+1][r]-=val;
	if(pos)sum[pos+1][pos-1]+=val;
	add(l,pos-1);
	add(pos+1,r);
}

int main(){
	scanf("%d%d",&n,&m);
	a[0]=1;
	REP(i,n-1)scanf("%d",&a[i]),dis[i]=dis[i-1]+a[i];
	rep(i,n)rep(j,m)scanf("%d",&b[i][j]);
	rep(i,m)T.id=i,T.build(),add(0,n-1);
	REP(i,n-1)rep(j,n)sum[i][j]+=sum[i-1][j];
	rep(i,n)for(int j=n-2;j>=0;j--)sum[i][j]+=sum[i][j+1];
	rep(i,n)for(int j=i;j<n;j++)//cout<<i<<" "<<j<<" "<<sum[i][j]<<endl,
	ans=max(ans,sum[i][j]-(dis[j]-dis[i]));
	printf("%lld",ans);
	return 0;
}

/*
Input:
-----------------
Output:
*/

Measured memory_bytes: 200192
#include <bits/stdc++.h>
#define JN ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define mod 1000000007

#define pb push_back
#define mp make_pair

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



double dp[3005];


int main()
{
    JN;

    int n;
    cin >> n;

    double p[n+1];

    dp[0] = 1.0;

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

    for(int i=1; i<=n; i++)
    {
        for(int j=i; j>=0; j--)
        {
            dp[j] = (i==0 ? 0: p[i] * dp[j-1])+ (1-p[i]) * dp[j];
        }
    }

    double ans=0;
    for(int heads=0; heads<=n; heads++)
    {
        int tails = n-heads;
        if(heads>tails)
        {
            ans += dp[heads];
        }
    }

    printf("%.10lf\n", ans);
    
    return 0;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define lld  double
#define pb push_back
#define mp make_pair
#define Maxn 1007
#define ff first
#define ss second
#define inf 100000000
using namespace std;
vector <pair<pair<ll,ll>,ll> > vi;
int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a*c<=b){
        cout<<c;
    }
    else{
        cout<<b/a;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define time cerr << (0.1 * clock()) / CLOCKS_PER_SEC << endl;
#define mod 1000000007
typedef long long ll;
typedef pair<ll, ll> pl;
#define forn(n) for (ll i = 0; i < ll(n); i++)

void solve() {
    ll n, w;
    cin >> n >> w;
    vector<pl> v(n);
    forn(n) {
        cin >> v[i].ff >> v[i].ss;
    }
    vector<ll> prev(1e5 + 5, -1);
    for (int i = 0; i < n; ++i) {
        vector<ll> temp(1e5 + 5, -1);
        for (int j = 0; j < 1e5 + 5; ++j) {
            if (prev[j] != -1) {
                temp[v[i].ss + j] = prev[j] + v[i].ff;
            }
        }
        temp[v[i].ss] = v[i].ff;
        for (int j = 0; j < 1e5 + 5; ++j) {
            if (temp[j] != -1) {
                if (prev[j] == -1) {
                    prev[j] = temp[j];
                } else {
                    prev[j] = min(temp[j], prev[j]);
                }
            }
        }
    }
    for (int i = 1e5 + 4; i >= 0; --i) {
        if (prev[i] != -1 and prev[i] <= w) {
            cout << i << '\n';
            return;
        }
    }
    cout << 0 << '\n';
}

int main() {
    quick;
    solve();
    // ll t;
    // cin >> t;
    // while (t--) {
    //     solve();
    // }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll a,b,c;
ll ans=1000000000000000;
int main(void){
    cin>>a>>b>>c;
    ans=min({abs(b*c*(a/2)-b*c*(a-a/2)),abs(c*a*(b/2)-c*a*(b-b/2)),abs(a*b*(c/2)-a*b*(c-c/2))});
    cout<<ans<<endl;

}



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

#define endl '\n'
#define ll long long
#define LSB __builtin_ctzll
#define sc(a) scanf("%d",&a)
#define MSB 63-__builtin_clzll
#define scl(a) scanf("%lld",&a)
#define BITS __builtin_popcountll
#define mem(a , v)  memset(a , v , sizeof(a))
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9+7;
const int MAX = 1e5+55;
const int INF = 1e9+77;
const ll INFINF = 1e18+1e17;
const double PI = acos(-1.0);
vector<int> months = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y&1)
         s*=x;
         return s;
}


int n;
vector<int> adj[MAX];
vector<int> adj1[MAX];
bool vis[MAX];
ll dp[MAX][2];


void DFS(int u){
    vis[u]=1;
    for(auto &v:adj1[u]){
        if(!vis[v]){
            adj[u].push_back(v);
            DFS(v);
        }
    }
}

ll solve(int u,int col){//col==1 means that the last vertex colored white..
        if(adj[u].size()==0){
            if(col){
                return 2;
            }
            return 1;
        }

        ll &res=dp[u][col];
        if(res!=-1){
            return res;
        }

        res=1;
        if(col){
            for(auto &v:adj[u]){
                res*=(solve(v,0)%MOD);
                res%=MOD;
            }
            ll cur=1;
            for(auto &v:adj[u]){
                cur*=(solve(v,1)%MOD);
                cur%=MOD;
            }
            res+=cur;
        }
        else{
            for(auto &v:adj[u]){
                res*=solve(v,1)%MOD;
                res%=MOD;
            }
        }

        return res%MOD;
}





int main(){

ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//freopen("input.txt" , "r" , stdin);
//freopen("output.txt" , "w" , stdout);




    cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        adj1[a].push_back(b);
        adj1[b].push_back(a);
    }

    DFS(1);
    mem(dp,-1);

    ll ans=solve(1,1)%MOD;


    cout<<ans;







     return 0;

}


Measured memory_bytes: 19840
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	string s;
	cin>>s;
	int l=s.length(),c=15-l;
	FOR(i,0,15){
		if(s[i]=='o')c++;
	}
	if(c>=8)cout<<"YES"<<endl;
	else cout<<"NO";
	return 0;
}


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

#define N 10101
string dp[N];
int a[10];
int cost[10] = {0,2,5,5,4,5,6,3,7,6};
int feed[10];
int cmp1(int p,int q) {
  if (cost[p] != cost[q]) {
    return cost[p] < cost[q];
  } else {
    return p > q;
  }
}
string maxstr(string u,string v) {
  int ul = u.length(), vl = v.length();
  if(ul > vl) { return u; }
  else if (ul < vl) { return v; }
  else { return max(u,v); }
}
int main(void) {
  int n,m; cin >> n >> m;
  for(int i=0; i<m; i++) {
    int j; cin >> j;
    a[i] = j;
  }
  sort(a,a+m,cmp1);
  for(int i=0; i<m; i++) {
    int feed = cost[a[i]];
    string s = "";
    s += '0' + a[i];
    if(maxstr(dp[feed],s) == s) {
      dp[feed] = s;
      for(int j=feed; j<=n; j++) {
        if(dp[j-feed]!="") {
          string cand = dp[j-feed] + s;
          sort(cand.rbegin(),cand.rend());
          dp[j] = maxstr(dp[j],cand);
        }
      }
    }
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 25344