jiahuimbzuai/CoQuIR huggingface dataset:
//  [java]
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        //Compute c1 = new Compute();//calc
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();
        //input
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        String s =sc.next();
        String ss[]=new String[n];
        for (int i=0;i<n;++i) ss[i]=s.substring(i,i+1);

        String ans = "";
        for (int i=0;i<n-1;++i)
        {
            if (!ss[i].equals(ss[i+1]))
            {
                ans+=ss[i];
            }
        }

        System.out.println(ans.length()+1);
        sc.close();
    }
}
//  [java]
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    // スライムの数
    int slimesCnt = scanner.nextInt();
    // スライムの並び
    String slimes = scanner.next();
    // 出力用
    String output = String.valueOf(slimes.charAt(0));
    
    for (int i = 0; i < slimesCnt - 1; i++){
      if (output.charAt(output.length() - 1) != (slimes.charAt(i + 1))){
        output = output.concat(String.valueOf(slimes.charAt(i + 1)));
      }
    }
    
    System.out.println(output.length());
  }

}
//  [cpp]
#include<stdio.h>

int main()
{
  long long int n;
  long long int i,k;
  scanf("%lld",&n);
  char s[n+1];

  long long int del = 0;

  scanf("%s",s);

  s[n]=0;

  for(i=0;i<n-del-1;i++)
  {
    while(s[i]==s[i+1])
    {
      for(k=i+1;k<n-del;k++)
      {
        s[k]=s[k+1];
      }
      del=del+1;
      if(del+1==n)
      {
        break;
      }
    }
  }


  printf("%lld",n-del);

  return 0;
}
//  [cpp]
#include <iostream>
#include <string>
using namespace std;

int main()
{
	int N;
	string s;
	cin >> N;
	cin >> s;
	int i = 1;
	while (i < s.size())
	{

		if (s[i] == s[i - 1]) {

			if (i >= 2) {

				s.erase(i, 1);
			}
			else {
				s = s.substr(i, s.size());

			}
			i = 1;
		}else
		{
			i++;
		}
	}
	cout << s.size() << endl;
	return 0;
}
//  [cpp]
#include <bits/stdc++.h>

using namespace std;

int main()
{
  int N;
  string S;
  bool isSta = false;
                                                                                                                                              
  cin >> N;
  cin >> S;

  while(!isSta){
    isSta = true;
    for(int i=0;i<S.size()-1;i++){
      if(S[i] == S[i+1]){
        S.erase(S.begin() + i);
        isSta = false;
        break;
      }
    }
  }

  cout << S.size() << endl;

  return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>
int main(){
  int n;
  char s[111111];
  scanf("%d%s",&n,s);
  for(int i=1;i<strlen(s);i++){
    n-=(s[i]==s[i-1]);
  }
  printf("%d",n);
}
//  [c]
#include<stdio.h>
#include<string.h>

int main()
{
    int n,a=1;
    scanf("%d",&n);
    char s[n];
    for(int i=0;i<n;i++)
    {scanf("%s",&s[i]);}
    for(int i=0;i<n-1;i++)
    {if(s[i]!=s[i+1])
    {a++;}
    }
    printf("%d",a);
    return 0;
}
//  [c]
#include <stdio.h>

int main(void) {
	int n,a;
	scanf("%d",&n);
  a=n;
	char s[n];
	for(int i=0;i<n;i++){
      scanf("%s",&s[i]);
    }
  for(int i=0;i<n-1;i++){
    if(s[i]==s[i+1]){
      a--;
    }
  }
    printf("%d",a);
    
  
  
	// your code goes here
	return 0;
}
//  [javascript]
function main(arg) {
    var arg2 = arg.split(/\n/g);
	var honbun = arg2[1];
	var alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	for(i=0;i<alphabet.length;i++){
		var iro = alphabet.substr(i,1);
		var regkun = new RegExp(iro+"+", 'g');
		honbun = honbun.replace(regkun,iro);
	}
	console.log(honbun.length);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
		//文字列から10進数に変換するときはparseIntを使います
	var n = parseInt(input[0], 10);
		
	s = input[1].trim().split("");///////  trim  文字
   
	//console.log(s);
	var cnt = 0;
	var i = 0;
    for(i=0;i<n;i++){
     if (s[i] == s[i+1]){//console.log(i);
                      }else{cnt =cnt +1;}
                     // console.log (cnt);
    }
	console.log(cnt);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(arg) {
 
    var N = arg.split("\n")[0]-0;
    var S = arg.split("\n")[1].split("");
 
    var ans = 0;
    var prev = "";

    S.map(function (v) { 

        if (v !== prev) ans ++;
        prev = v;
    });

    console.log(ans)

    return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	fmt.Scan(&n,&s)
	
	ans := ""
	past := ""
	for _,v := range s {
		stv := string(v)
		if past != stv {
			ans += stv
		}
		past = stv
	}
	fmt.Println(len(ans))
}
//  [go]
package main

import "fmt"

func main() {

	var N int
	fmt.Scan(&N)
	var S string
	fmt.Scan(&S)

	var ans string
	for i :=0; i < N; {
		if i < N-1 && S[i] == S[i+1]{
			i++
		}else {
			ans = ans + string(S[i])
			i++
		}
	}
	fmt.Println(len(ans))

}
//  [go]
package main

import "fmt"

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)

	ans := ""
	p := ""
	for _, c := range s {
		t := string(c)
		if p != t {
			ans += t
		}
		p = t
	}

	fmt.Println(len(ans))
}
//  [ruby]
n=gets.to_i
s=gets.chomp.split("")
index = 0
loop do
  break if s.length < index + 1
  if s[index] == s[index+1]
    s.delete_at(index+1) 
  else
    index += 1
  end
end
puts s.length
//  [ruby]
n = gets.chomp.to_i
s = gets.chomp.split('')
if n == 1
    puts 1
    exit
elsif n == 2
    puts s[0] == s[1] ? 1 : 2
    exit
end

comp = false
ans = s.length
i = 0
while true do
    if s[i+1] == s[i]
        s.delete_at(i+1)
    else
        i += 1
    end
    break if s.length == i+2
end
puts s[i] == s[i+1] ? s.length-1 : s.length
//  [ruby]
n = gets.to_i
str = gets.chomp.split("")
i = 0
while i < n - 1 do
  if str[i] == str[i + 1]
    str.delete_at(i + 1)
    n -= 1
  else
    i += 1
  end
end
puts str.length
//  [rust]
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::HashSet;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
      n:i64,
    mut s: Chars,
    }

    s.dedup();

    debug!(s);

     println!("{}", s.len());
}
//  [rust]
use proconio::input;
use proconio::marker::Bytes;

fn main() {
  input! {
    n: usize,
    s: String
  }
  let mut s: Vec<char> = s.chars().collect();
  let mut index = 0;
  
  while index + 1 < s.len() {
    if s[index] == s[index + 1] {
      s.remove(0);
    } else {
      index += 1;
    }
  }
  println!("{}", s.len());
}
//  [typescript]
const fs = require('fs');
const input: string[] = fs.readFileSync('/dev/stdin', 'utf-8').split('\n');
const n: number = parseInt(input[0]);
const S: string = input[1];

let result: string = '';
for (let i = 0; i < n; ++i) {
  if (!result) {
    result += S[i];
  } else if (result.slice(-1) !== S[i]) {
    result += S[i];
  }
} 

console.log(result.length);
//  [typescript]
function isEnd(str) {
    let end = true
    if(str.length < 2) return true
	const arr = str.split("")
	for (let idx in arr) {
		if (idx === 0) {
			end = arr[idx + 1] === arr[idx] ? false : true
			if (end === false) break;

		} else if (idx < arr.length) {
			end = arr[idx] === arr[idx - 1] ? false : true
			if (end === false) break;

		} else {
			end = arr[idx + 1] === arr[idx] || arr[idx] === arr[idx - 1] ? false : true
			if (end === false) break;
		}
	}
	return end
}

const fusion = (str) => {
	const result = str.split("").reduce((acc, cur, idx, arr) => {

		let isFusion = 0

		if(idx === 0){
			isFusion = arr[idx + 1] === cur ? idx + 1  : 0;
		}else if(idx >= arr.length - 1){
			isFusion = arr[idx - 1] ===cur  ?  idx -1 : 0;
		}else{
			 if(arr[idx - 1] === cur){
				isFusion = idx - 1
			 }else if(arr[idx + 1] === cur){
				isFusion = idx + 1
			 }

		}

		if (isFusion) {
			if(idx % 2 !== 0 || idx === 0)return  acc
			return acc + arr[isFusion]

		} else {
			return acc + cur
		}
	}, "")

    if(!isEnd(result)){
       return fusion(result)
    }
	return result
}
function main(input) {
    const args = input.split("\n");
    const str = args[1]
    let result = str
    
    result = fusion(result)
	console.log(result.length)
}

// main("20" + "\n" + "xxzaffeeeeddfkkkkllq")

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
import * as fs from "fs";

function main(lines: string[][]) {
  const slimes = lines[1][0].split("");
  const unique = (data: string[]): string[] => {
    const uniq = [];
    data.forEach((d) => {
      if (uniq[uniq.length - 1] !== d) uniq.push(d);
    });
    return uniq;
  };
  const uniqueData = unique(slimes);
  console.log(uniqueData.length);
}

const lines = fs
  .readFileSync("/dev/stdin", "utf8")
  .split("\n")
  .map((l) => l.split(" "))
  .filter((input) => !(input.length === 1 && input[0] === ""));

main(lines);
//  [python]
import math
x1, y1, x2, y2 = map(int, input().split())
p3 = 0
q3 = 0
p4 = 0
q4 = 0

for x3 in range(-301, 301):
    for y3 in range(-301, 301):
        length1 = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
        length2 = math.sqrt((x3 - x2)**2 + (y3 - y2)**2)
        if x2 != x1 and x3 != x2:
            slope = (y2 - y1)/(x2 - x1)*(y3 - y2)/(x3 - x2)
            if y1 != y2 and length1 == length2 and slope == -1 and\
                x2 > x1 and y3 > (y2 - y1)/(x2 - x1)*x3 +(x2*y1 - y2*x1)/(x2 - x1):
                p3 = x3
                q3 = y3
            elif y1 != y2 and length1 == length2 and slope == -1 and\
                x2 < x1 and y3 < (y2 - y1)/(x2 - x1)*x3 +(x2*y1 - y2*x1)/(x2 - x1):
                p3 = x3
                q3 = y3
        else:
            if x2 == x1 and y2 > y1 and y3 == y2 and x3 == x2 - length1:
                p3 = x3
                q3 = y3
            elif x2 == x1 and y2 < y1 and y3 == y2 and x3 == x2 + length1:
                p3 = x3
                q3 = y3
            elif x2 > x1 and y2 == y1 and x3 == x2 and y3 == y2 + length1:
                p3 = x3
                q3 = y3
            elif x2 < x1 and y2 == y1 and x3 == x2 and y3 == y2 - length1:
                p3 = x3
                q3 = y3

for x4 in range(-301, 301):
    for y4 in range(-301, 301):
        length1 = math.sqrt((p3 - x2)**2 + (q3 - y2)**2)
        length2 = math.sqrt((x4 - p3)**2 + (y4 - q3)**2)
        if x2 != p3 and p3 != x4:
            slope = (q3 - y2)/(p3 - x2)*(y4 - q3)/(x4 - p3)
            if y2 != q3 and length1 == length2 and slope == -1 and\
                p3 > x2 and y4 > (q3 - y2)/(p3 - x2)*x4 +(p3*y2 - q3*x2)/(p3 - x2):
                p4 = x4
                q4 = y4
            elif y2 != q3 and length1 == length2 and slope == -1 and\
                p3 < x2 and y4 < (q3 - y2)/(p3 - x2)*x4 +(p3*y2 - q3*x2)/(p3 - x2):
                p4 = x4
                q4 = y4
        else:
            if p3 == x2 and q3 > y2 and y4 == q3 and x4 == p3 - length1:
                p4 = x4
                q4 = y4
            elif p3 == x2 and q3 < y2 and y4 == q3 and x4 == p3 + length1:
                p4 = x4
                q4 = y4
            elif p3 > x2 and q3 == y2 and x4 == p3 and y4 == q3 + length1:
                p4 = x4
                q4 = y4
            elif p3 < x2 and q3 == y2 and x4 == p3 and y4 == q3 - length1:
                p4 = x4
                q4 = y4

print(p3, q3, p4, q4)
//  [python]
import numpy as np

x1,y1,x2,y2 = list(map(int,input().split()))

mat = np.array([[0,1],[-1,0]])
vec = [x2 - x1, y2 - y1]
rot_vec = -mat.dot(vec)
x4, y4 = rot_vec + np.array([x1,y1])
x3 = x4 + vec[0]
y3 = y4 + vec[1]

print(x3,y3,x4,y4)
//  [python]
import numpy as np


def run(p1, p4):
    v = p4 - p1
    A = np.array([[v[0], v[1]], [v[1], -v[0]]])
    b = np.array([0, np.dot(v, v)])
    x = np.dot(np.linalg.inv(A), b)
    return x + p1


l = list(map(int, input().split()))
p1 = np.array([l[0], l[1]])
p2 = np.array([l[2], l[3]])

p3 = run(p2, p1).astype(np.int64)
p4 = run(p3, p2).astype(np.int64)

print("{} {} {} {}".format(p3[0], p3[1], p4[0], p4[1]))
//  [java]
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int a = sc.nextInt();
  int b = sc.nextInt();
  int c = sc.nextInt();
  int d = sc.nextInt();
  int x = c-a;
  int y = d-b;
  int e = c-y;
  int f = d+x;
  int g = e-x;
  int h = f-y;
  System.out.println(e+" "+f+" "+g+" "+h);
}}
//  [java]
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		int dx = x2 - x1;
		int dy = y1 - y2;
		int x3 = x2 + dy;
		int y3 = y2 + dx;
		int x4 = x1 + dy;
		int y4 = y1 + dx;
		System.out.println(x3 + " " + y3 + " "  + x4 + " " + y4);
	}

}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int x1 = in.nextInt();
			int y1 = in.nextInt();
			int x2 = in.nextInt();
			int y2 = in.nextInt();

			int dx = x2-x1;
			int dy = y2-y1;

			int x3 = x2 - dy;
			int y3 = y2 + dx;
			int x4 = x3 - dx;
			int y4 = y3 - dy;

			out.printf("%d %d %d %d\n", x3, y3, x4, y4);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

	static long max(long... n) {
		long ret = n[0];
		for (int i = 0; i < n.length; i++) {
			ret = Math.max(ret, n[i]);
		}
		return ret;
	}

	static int max(int... n) {
		int ret = n[0];
		for (int i = 0; i < n.length; i++) {
			ret = Math.max(ret, n[i]);
		}
		return ret;
	}

	static long min(long... n) {
		long ret = n[0];
		for (int i = 0; i < n.length; i++) {
			ret = Math.min(ret, n[i]);
		}
		return ret;
	}

	static int min(int... n) {
		int ret = n[0];
		for (int i = 0; i < n.length; i++) {
			ret = Math.min(ret, n[i]);
		}
		return ret;
	}

}
//  [cpp]
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
#define point complex <ld>
#define x real()
#define y imag()
#define dot(a,b) ( (conj(a)*(b)).real() )
#define cross(a,b) ( (conj(a)*(b)).imag() )
#define vec(a,b) ((b)-(a))
#define eps 1e-8

int dcmp(ld a , ld b) {return fabs(a-b)<=eps ? 0: a<b ? -1 : 1;}

ld calc(point p , point p2)
{
    ld ds =  (p.x-p2.x)*(p.x-p2.x) + (p.y-p2.y)*(p.y-p2.y);
    return sqrt(ds);
}

bool check(point p , point p2 ,point p3)
{
    ld pp2 = calc(p,p2) , p2p3=calc(p2,p3);

    if (dcmp(pp2,p2p3) != 0) return 0;

    ld pp3 = calc(p,p3);

    if (dcmp(pp3 , sqrt(2)*pp2) != 0) return 0;
    point aa = vec(p,p2) , bb = vec(p,p3);
    if (cross(aa,bb) > 0) return 1;

    return 0;

}

bool isSq(point p , point p2 , point p3 , point p4)
{
    vector<point> v;
    v.push_back(p) , v.push_back(p2) , v.push_back(p3) , v.push_back(p4);

    map <ll,ll> mp;
    set <ll> st;
    for (int i=0; i<v.size(); i++)
    {
        for (int j=0; j<v.size(); j++)
        {
            if (i!=j)
            {
                mp[ (v[i].x-v[j].x)*(v[i].x-v[j].x) + (v[i].y-v[j].y)*(v[i].y-v[j].y) ]++;
                st.insert((v[i].x-v[j].x)*(v[i].x-v[j].x) + (v[i].y-v[j].y)*(v[i].y-v[j].y));
            }
        }
        if (mp.size()!=2) return 0;
        mp.clear();
    }
    if (st.size()!=2) return 0;
    set<ll> ::iterator it=st.begin();
    ll tmp=*it;
    it++; ll tmp2=*it;
    if (tmp2 != 2*tmp) return 0;

  //  point pp = vec(p,p2) , pp2 = vec(p,p3);
  //  if (cross(pp,pp2) > 0) return 1;
    return 1;
}

void solve(point p , point p2 , point p3)
{
    for(int i=-400; i<=400; i++)
    {
        for(int j=-400; j<=400; j++)
        {
            point p4(i,j);
            if (isSq(p,p2,p3,p4))
            {
                cout << p3.x << ' ' << p3.y << ' ' << p4.x << " " << p4.y << "\n";
                exit(0);
            }
        }
    }
}

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

    ll xx,yy,x2,y2,x3,y3,x4,y4;
    cin >> xx >> yy >> x2 >> y2;

    point p(xx,yy),p2(x2,y2);

    for(int i=-400; i<=400; i++)
    {
        for(int j=-400; j<=400; j++)
        {
            point p3(i,j);
            if (check(p,p2,p3))
            {
                solve(p,p2,p3);
            }
        }
    }
//
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
#define point complex <ld>
#define x real()
#define y imag()
#define dot(a,b) ( (conj(a)*(b)).real() )
#define cross(a,b) ( (conj(a)*(b)).imag() )
#define vec(a,b) ((b)-(a))
#define eps 1e-8

int dcmp(ld a , ld b) {return fabs(a-b)<=eps ? 0: a<b ? -1 : 1;}

ld calc(point p , point p2)
{
    ld ds =  (p.x-p2.x)*(p.x-p2.x) + (p.y-p2.y)*(p.y-p2.y);
    return sqrt(ds);
}

bool check(point p , point p2 ,point p3)
{
    ld pp2 = calc(p,p2) , p2p3=calc(p2,p3);

    if (dcmp(pp2,p2p3) != 0) return 0;

    ld pp3 = calc(p,p3);

    if (dcmp(pp3 , sqrt(2)*pp2) != 0) return 0;
    point aa = vec(p,p2) , bb = vec(p,p3);
    if (cross(aa,bb) > 0) return 1;

    return 0;

}

bool isSq(point p , point p2 , point p3 , point p4)
{
    vector<point> v;
    v.push_back(p) , v.push_back(p2) , v.push_back(p3) , v.push_back(p4);

    map <ll,ll> mp;
    set <ll> st;
    for (int i=0; i<v.size(); i++)
    {
        for (int j=0; j<v.size(); j++)
        {
            if (i!=j)
            {
                mp[ (v[i].x-v[j].x)*(v[i].x-v[j].x) + (v[i].y-v[j].y)*(v[i].y-v[j].y) ]++;
                st.insert((v[i].x-v[j].x)*(v[i].x-v[j].x) + (v[i].y-v[j].y)*(v[i].y-v[j].y));
            }
        }
        if (mp.size()!=2) return 0;
        mp.clear();
    }
    if (st.size()!=2) return 0;
    set<ll> ::iterator it=st.begin();
    ll tmp=*it;
    it++; ll tmp2=*it;
    if (tmp2 != 2*tmp) return 0;

  //  point pp = vec(p,p2) , pp2 = vec(p,p3);
  //  if (cross(pp,pp2) > 0) return 1;
    return 1;
}

void solve(point p , point p2 , point p3)
{
    for(int i=-400; i<=400; i++)
    {
        for(int j=-400; j<=400; j++)
        {
            point p4(i,j);
            if (isSq(p,p2,p3,p4))
            {
                cout << p3.x << ' ' << p3.y << ' ' << p4.x << " " << p4.y << "\n";
                exit(0);
            }
        }
    }
}

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

    ll xx,yy,x2,y2,x3,y3,x4,y4;
    cin >> xx >> yy >> x2 >> y2;

    point p(xx,yy),p2(x2,y2);

    for(int i=-400; i<=400; i++)
    {
        for(int j=-400; j<=400; j++)
        {
            point p3(i,j);
            if (check(p,p2,p3))
            {
                solve(p,p2,p3);
            }
        }
    }

    return 0;
}
//  [c]
#include <stdio.h>
  
int main()
{
  int x1,x2,x3,x4,y1,y2,y3,y4;

  scanf("%d %d %d %d",&x1,&y1,&x2,&y2);

  x3=x2-(y2-y1);
  y3=y2+(x2-x1);
  x4=x3-(y3-y2);
  y4=y3+(x3-x2);

  printf("%d %d %d %d\n",x3,y3,x4,y4);

  return 0;
}
//  [c]
/* ex 7_1 AtCoder Beginner Contest 108 B
   nk777 */

// ↑y
// →x

#include <stdio.h>
// 頂点を返す構造体point
typedef struct point{
    int x_elem;
    int y_elem;
}point;
// ある頂点についてx軸、y軸について移動させた頂点を返す関数
// 求めたい点の2個前の点point_2before, 1個前の点point_1before
point shift_point(point point_2before, point point_1before){
    // 求めたい頂点point_next
    point point_next;
    // 符号付きの差lenX, lenY
    int lenX, lenY;
    lenX = point_1before.x_elem - point_2before.x_elem;
    lenY = point_1before.y_elem - point_2before.y_elem;
    // 1個前の点にxとyの差を入れ替えて足す。ただしyの差は符号を変える
    point_next.x_elem = point_1before.x_elem - lenY;
    point_next.y_elem = point_1before.y_elem + lenX;
    return point_next;
}

int main(void){
    // 点point1(x1,y1), 点point2(x2,y2), 点point3, 点point4
    point point1, point2, point3, point4;
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);

    // 点point1(x1,y1), 点point2(x2,y2)を構造体に入れる
    point1.x_elem = x1;
    point1.y_elem = y1;
    point2.x_elem = x2;
    point2.y_elem = y2;
    // 移動した値を代入
    point3 = shift_point(point1, point2);
    point4 = shift_point(point2, point3);

    // 出力
    printf("%d %d %d %d\n", point3.x_elem, point3.y_elem, point4.x_elem, point4.y_elem);

    return 0;
}
//  [c]
/* ex 7_1
   yy8332 */
#include <stdio.h>

//構造体宣言
typedef struct point{
  int x_elem;
  int y_elem;
}point;

//(+x,+y)移動する関数
point shift_point(point p, int x, int y){
  point q;
  q.x_elem = p.x_elem + x;
  q.y_elem = p.y_elem + y;

  return q;
}

int main(void){
  point p1, p2, p3, p4;
  int x, y;

  //入力読み取り
  scanf("%d %d %d %d", &p1.x_elem, &p1.y_elem, &p2.x_elem, &p2.y_elem);

  x = -p2.y_elem + p1.y_elem;
  y = -p1.x_elem + p2.x_elem;

  p3 = shift_point(p2, x, y);
  p4 = shift_point(p1, x, y);

  //出力
  printf("%d %d %d %d\n", p3.x_elem, p3.y_elem, p4.x_elem, p4.y_elem);

  return 0;
}
//  [javascript]
'use strict'

const main = (input) => {
    input = input.split(' ').map(i => parseInt(i))
    const x1 = input[0]
    const y1 = input[1]
    const x2 = input[2]
    const y2 = input[3]
    const x = x2 - x1
    const y = y2 - y1
    console.log('%d %d %d %d', x2 - y, y2 + x, x1 - y, y1 + x)
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))
//  [javascript]
// parameter "input" gets all data
function Main(input) {
	// the first line is assigned to input[0], the second line is assigned to input[1] similarly.
	var xy = input.split(' ');
	for(var i=0;i<xy.length;i++){
		xy[i] = parseInt(xy[i]);
	}
	var dx = xy[0]-xy[2];
	var dy = xy[1]-xy[3];
	xy.push(xy[2]+dy);
	xy.push(xy[3]-dx);
	xy.push(xy[4]+dx);
	xy.push(xy[5]+dy);
	console.log(xy[4],xy[5],xy[6],xy[7])
}
// Don't edit this line!
//Main(require("fs").readFileSync(__dirname+'/in.txt', "utf8"));
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split(' ');
	var xys = toIntArr(input);
	var p1 = [xys[0],xys[1]];
	var p2 = [xys[2],xys[3]];

	var v = [p2[0]-p1[0],p2[1]-p1[1]];
	var p3 = [p2[0]-v[1],p2[1]+v[0]];
	var p4 = [p1[0]-v[1],p1[1]+v[0]];
	console.log(p3[0],p3[1],p4[0],p4[1]);
}
//  [go]
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func debug(a ...interface{}) {
	if os.Getenv("ONLINE_JUDGE") == "false" {
		fmt.Fprintln(os.Stderr, a...)
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1001), 1001001)

	x1, y1, x2, y2 := scanInt(), scanInt(), scanInt(), scanInt()

	dx := x2 - x1
	dy := y2 - y1
	x3, y3 := x2-dy, y2+dx
	x4, y4 := x3-dx, y3-dy
	fmt.Fprintln(wr, x3, y3, x4, y4)
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var x1, y1, x2, y2 int
	fmt.Scan(&x1, &y1, &x2, &y2)

	dx := x2 - x1
	dy := y2 - y1

	fmt.Println(x2-dy, y2+dx, x1-dy, y1+dx)
}
//  [go]
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	parseProblem()
}

func parseProblem() {
	x1, y1, x2, y2 := scanInt(sc), scanInt(sc), scanInt(sc), scanInt(sc)
	base := vec{x: x1, y: y1}
	dv := vec{x: x2 - x1, y: y2 - y1}
	orDv := orthogonal(dv)
	p3 := add(add(base, dv), orDv)
	p4 := add(base, orDv)
	fmt.Println(p3.x, p3.y, p4.x, p4.y)
}

type vec struct{ x, y int }

func add(v1, v2 vec) vec {
	return vec{x: v1.x + v2.x, y: v1.y + v2.y}
}

func orthogonal(v vec) vec {
	return vec{x: -v.y, y: v.x}
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
//  [ruby]
x1, y1, x2, y2 = gets.split.map(&:to_i)

def dist(x1, y1, x2, y2)
  dy = y2 - y1
  dx = x2 - x1
  Math.sqrt(dy ** 2 + dx ** 2)
end

l = dist(x1, y1, x2, y2)

candA = []
candB = []

(-300..300).each do |y|
  (-300..300).each do |x|
    if (x1 != x || y1 != y) && l == dist(x, y, x2, y2)
      candA << [x, y]
    end

    if (x2 != x || y2 != y) && l == dist(x, y, x1, y1)
      candB << [x, y]
    end
  end
end

candA.each do |a, b|
  next if (a - x2) * (y1 - y2) - (x1 - x2) * (b - y2) < 0

  candB.each do |c, d|
    if l == dist(a, b, c, d) && dist(a, b, x1, y1) == dist(c, d, x2, y2)
      puts [a, b, c, d].join(' ')
      # exit
    end
  end
end
//  [ruby]
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

X1, Y1, X2, Y2 = get_ints

vector = [X2 - X1, Y2 - Y1]

first_vector = [-vector[1], vector[0]]
X3, Y3 = [X2 + first_vector[0], Y2 + first_vector[1]]

second_vector = [X3 - X2, Y3 - Y2]

third_vector = [-second_vector[1], second_vector[0]]
X4, Y4 = [X3 + third_vector[0], Y3 + third_vector[1]]

puts "#{X3} #{Y3} #{X4} #{Y4}"
//  [ruby]
a,b,c,d=gets.split.map &:to_i
e=c-a
f=d-b
ans1=c-f
ans2=d+e
ans3=ans1-e
ans4=ans2-f
puts [ans1,ans2,ans3,ans4]*' '
//  [rust]
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        x1: i16,
        y1: i16,
        x2: i16,
        y2: i16,
    }

    let vx = x2 - x1;
    let vy = y2 - y1;
    println!("{} {} {} {}", x2-vy, y2+vx, x1-vy, y1+vx);
}
//  [rust]
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        x1: i16,
        y1: i16,
        x2: i16,
        y2: i16,
    }

    // let vx = x2 - x1;
    // let vy = y2 - y1;
    // println!("{} {} {} {}", x2-vy, y2+vx, x1-vy, y1+vx);
    println!("{} {} {} {}", y1+x2-y2, -x1+x2+y2, x1+y1-y2, y1-x1+x2);
}
//  [rust]
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    let a: isize = read!();
    let b: isize = read!();
    let c: isize = read!();
    let d: isize = read!();
    println!("{} {} {} {}",c-d+b,d+c-a,a-d+b,b-a+c)
}
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [x1, y1, x2, y2] = input[0].map(Number);

  const diffX = x2 - x1;
  const diffY = y2 - y1;

  return [x2 - diffY, y2 + diffX, x1 - diffY, y1 + diffX].join(" ");
};

console.log(main(read()));
//  [typescript]
function main(input) {
const x1 = parseInt(input.split(/\s|\n/g)[0],10),
	  y1 = parseInt(input.split(/\s|\n/g)[1],10),
	  x2 = parseInt(input.split(/\s|\n/g)[2],10),
	  y2 = parseInt(input.split(/\s|\n/g)[3],10),
      x3 = x2-(y2-y1),
      y3 = y2+(x2-x1);
console.log(`${x3} ${y3} ${x3-(y3-y2)} ${y3+(x3-x2)}`.split(/\n/g)[0])
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [python]
l = list(map(int, input().split()))
a=l[0]
b=l[1]

import numpy as np

east_num = b-a

tmp = np.arange(1,b-a+1)

east_hight = sum(tmp)

snow= east_hight-b

print(snow)
//  [python]
A,B=map(int,input().split())
H=[0]*1000

i=1
while i<=999:
    H[i]=i+H[i-1]
    i+=1

ans=0
while True:
    if (A+ans in H)and(B+ans==H[H.index(A+ans)+1] in H):
        break
    else:
        ans+=1
    
print(ans)
//  [python]
a, b = map(int, input().split())
snowless = []
cnt = 0
ans = 0
for i in range(1, 1000):
    cnt += i
    snowless.append(cnt)

for j in range(snowless[-1]):
    if a + j in snowless and b + j in snowless:
        ans = j

print(ans)
//  [java]
import java.util.*;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int a = scanner.nextInt(), b = scanner.nextInt();
        TreeMap<Integer, Integer> result = new TreeMap<>();

        IntStream.range(0,1000)
                .boxed()
                .reduce(0, (accumulator, val)->{
                    int ac = accumulator+val;
                    result.put(val,ac);
                    return ac;
                });

        OptionalInt answer = result.entrySet().stream()
                .filter(ent -> ent.getValue()-a==result.get(ent.getKey()+1)-b)
                .mapToInt(ent -> ent.getValue()-a)
                .findFirst();

        /*
        int accumulator = 0;
        int ans = 0;
        for (int i = 0; i < 1000; i++) {
            int nextAccumulator = accumulator + i;
            if (accumulator - a == nextAccumulator - b){
                ans = accumulator -a;
                break;
            }
            accumulator = nextAccumulator;
        }
        */
        System.out.println(answer.orElse(0));
        scanner.close();
    }
}
//  [java]
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();

		int tmp = b - a;

		pr.println(tmp * (tmp + 1) / 2 - b);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}
//  [cpp]
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdlib>
#include<cstdio>

using namespace std;
int po(int c)
{
    int i,a;
    for(i=1; i<=999; i++)
    {
        a=i*(i+1)/2;
        if(a==c)
            return i;
    }
    return 0;
}
int main()
{
    int a,b,i,c,d;
    scanf("%d %d",&a,&b);
    for(i=0; ; i++)
    {
        c=a+i;
        d=b+i;
        if(po(c)+1==po(d))
        {
            printf("%d\n",i);
            break;
        }
    }
    return 0;
}
//  [cpp]
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
    int a,b;
    int cnt=0;
    int sum=0;
    // 
    cin >> a >> b;
    //
    for(int i = 1; i < 1000; i++)
    {
        sum +=i;
        for(int j=1;j<1000000; j++)
        {
            if((a+j) == sum && (b+j) == (sum+i+1)) 
            {
                cnt = j;
                break;  
            }
        }
    }
    cout << cnt << endl;
}
//  [cpp]
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#define rep(i, n) for(i = 0; i < n; i++)
//#define int long long
using namespace std;

int a, b;

signed main() {
	cin >> a >> b;
	
	for (int x = 1; x <= 499500; x++) {
		for (int i = 1; i < 999; i++) {
			int left = i * (i + 1) / 2;
			int right = (i + 1) * (i + 2) / 2;
			if (left - x == a && right - x == b) {
				cout << x << endl;
				return 0;
			}
		}
	}
	return 0;
}
//  [c]
#include <stdio.h>
int main(){
  int a,b,i,j,s;
  scanf("%d%d",&a,&b);
  for(i=1;i<499500;i++){
    s=0;
    a++;
    b++;
    for(j=1;j<1000;j++){
      s+=j;
      if(a==s&&b==s+j+1)printf("%d",i);
    }
  }
  return 0;
}
//  [javascript]
"use strict";

/**
 * Resolves problem.
 * @param  {string} input
 * @returns {string}
 */
var main = function(input) {
    const params = input.split(" ").map(x => parseInt(x));
    const a = params[0];
    const b = params[1];

    const difference = b - a;
    let height = 0;
    for (let i = 1; i < 1000; i++) {
        height = height + i;
        if ((i + 1) === difference) {
            return height - a;
        }
    }
};

const output = main(require("fs").readFileSync("/dev/stdin", "utf8"));
console.log(output); // console.log outputs with trailing new line!
//  [javascript]
function equal(a, b) {
    var aP = Object.getOwnPropertyNames(a);
    var bP = Object.getOwnPropertyNames(b);
    if (aP.length != bP.length)
        return false;
    for (var i = 0; i < aP.length; i++)
        if (a[aP[i]] !== b[aP[i]])
            return false;
    return true;
}
function pi(text) {
    return parseInt(text, 10);
}
function main(input) {
    var tmp = input.split(" ").map(_ => pi(_));
    var tmp2 = tmp[1] - tmp[0];
    console.log(tmp2 * (tmp2 + 1) / 2 - tmp[1]);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict'

function Main(input) {
  const a = Number(input.split(' ')[0]);
  const b = Number(input.split(' ')[1]);

  const dif = b - a;
  let lowtower = 0;

  for(let i=dif; i>0; i--) {
    lowtower += i;
  }

  console.log(lowtower - b);

}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [go]
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	f := func(v int) int {
		return ((v + 1) * v) >> 1
	}
	ap := f(1)
c:
	for i := 2; i <= 999; i++ {
		bp := f(i)
		for x := 1; x < 499500; x++ {
			if ap-x == a && bp-x == b {
				fmt.Println(x)
				break c
			}
		}
		ap = bp
	}
}
//  [go]
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	sum := 0
	for i := 1; i <= b-a; i++ {
		sum += i
	}
	fmt.Println(sum - b)
}
//  [ruby]
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A, B = get_ints

c = B - A
puts ( c * (c-1))/2 - A
//  [ruby]
a,b = gets.chomp.split(' ').map(&:to_i)
d = (b - a)
puts d * (d + 1) / 2 - b
//  [ruby]
a = gets.split(' ').map(&:to_i)

p ((a[1] - a[0]) * (a[1] - a[0] + 1) / 2) - a[1]
//  [rust]
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        a: i64,
        b: i64,
    }
    let d = b-a;
    println!("{}", d*(d+1)/2 - b);
}
//  [rust]

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let ab = read_vec::<i32>();
    let (a,b) = (ab[0],ab[1]);
    let dif =  b -a;
    let v :i32= (0..dif+1).fold(0,|x,y| x +y);
    let ans  = v -b;
    println!("{}",ans);
}
//  [rust]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::*;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let a: usize = read!();
    let b: usize = read!();

    let diff = b - a;

    let mut ans = 0;

    for i in 1..diff {
        ans += i;
    }

    println!("{}", ans - a);
}
//  [swift]
import Foundation
let heights = readLine()!.componentsSeparatedByString(" ").map{Int($0)!}
var preciseHeight = 0
for i in 1...(heights[1] - heights[0]) {
  preciseHeight += i
}
print(preciseHeight - heights[1])
//  [swift]
let i=readLine()!.characters.split(" ").map{Int(String($0))!},a=i[0],b=i[1];print((1..<b-a).reduce(0){$0+$1}-a)
//  [swift]
/// Swift5 -> Swift2.2

extension String {
    // split(separator:maxSplits:omittingEmptySubsequences:)
    func split(separator separator: Character) -> [String] {
        return self.characters.split(separator).map(String.init)
    }
}
extension Array {
    // init(repeating:count:)
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
    // lastIndex(where:)
    func lastIndex(where predicate: (Element) -> Bool) -> Int? {
      	for i in stride(from: count - 1, through: 0, by: -1) {
          	if predicate(self[i]) {
              	return i
            }
        }
      	return nil
    }
}
extension Array where Element: Comparable {
    // sorted()
    func sorted() -> [Element] {
        return self.sort( { $0 < $1 } )
    }
    // max()
    func max() -> Element? {
        guard self.count > 0 else { return nil }
        return self.reduce(self.first!) { return Swift.max($0, $1) }
    }
}
extension String {
    // Sequence#enumerated()
  	// public func enumerate<Seq : SequenceType>(base: Seq) -> EnumerateSequence<Seq>
    func enumerated() -> EnumerateSequence<[Character]> {
        return Array(self.characters).enumerate()
    }
}
// stride(from:through:by:)
func stride(from start: Int, through end: Int, by stride: Int) -> StrideThrough<Int> {
    return start.stride(through: end, by: stride)
}
// stride(from:to:by)
func stride(from start: Int, to end: Int, by stride: Int) -> StrideTo<Int> {
    return start.stride(to: end, by: stride)
}

/// end


let input = readLine()!.split(separator: " ").map { Int($0)! }
let a = input[0]
let b = input[1]

let diff = b - a
let lengthOfEast = (diff + 1) * diff / 2

print(lengthOfEast - b)
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [a, b] = input[0].map(Number);

  return ((b - a) * (b - a + 1)) / 2 - b;
};

console.log(main(read()));
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [a, b] = input[0].map(Number);

  let answer = 0;

  for (let i = 1; i < b - a; i++) {
    answer += i;
  }

  return answer - a;
};

console.log(main(read()));
//  [typescript]
import * as fs from 'fs';

const input = (fs.readFileSync('/dev/stdin', 'utf8') as string).split('\n');

const [a, b] = input[0].split(' ').map((x) => +x);

const d = b - a;

console.log((d * (d + 1)) / 2 - b);
//  [python]
import numpy as np
import copy as cp

N = int(input())
MIN = np.sqrt(N) - 1
MAX = np.sqrt(N)

m = int(MAX)
print(m**2)
//  [python]
# coding: utf-8
import numpy
N = int(input())
X = numpy.sqrt(N)

print(int(X)*int(X))
//  [python]
import numpy as np

N = int(input())
print(int(np.sqrt(N)) ** 2)
//  [java]
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Main myself = new Main();
		int answer = myself.execute();

		System.out.print(answer);
	}

	/**
	 * 実処理メソッド
	 */
	public int execute() {

		try (Scanner scanner = new Scanner(System.in)) {

			final int N = scanner.nextInt();

			double sqrt = Math.sqrt(N);

			// iはテスト数
			for (int i = N; 0 < i; i--) {

				for (int j = (int) sqrt + 1; 0 < j; j--) {

					if (j * j == i) {
						return i;
					}
				}
			}

			return 0;
		}

	}

}
//  [java]
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long ans = -100100100100L;
		for(long i = 0 ; i <= n ; i++) {
			if(i * i <= n) {
				ans = Math.max(ans, i * i);
			}
		}
		System.out.println(ans);
	}
}
//  [java]
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long ans = 0;
		for (long i = 1; i <= N; i++) {
			if (i * i <= N) {
				ans = i * i;
			}
		}
		sc.close();
		System.out.println(ans);
	}
}
//  [cpp]
#include <iostream>
using namespace std;

int heihou(int n){
  int count=0;
  for(int i=1;i<32000;i++){
    if(i*i==n){
      count++;
    }
  }
  return count;
}

int main(){
  int n;
  cin >> n;
  for(int i=n;;i--){
    if(heihou(i)==1){
      cout << i << endl;
      break;
    }
  }
}
//  [cpp]
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
long long  n ;
int main(){
	cin>>n;
	bool a = false;
	for(int i = n ; i > 0; i--){
		rep(j,i+1){
			long long k = j*j;
			if(i == k){
				cout<<i<<endl;
				a = true;
				break;
			}
			if(k>i){
				break;
			}
		}
		if(a){
			break;
		}
	}
	
}
//  [cpp]
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int N; cin >> N;
  vi square; for(int i = 40000; i > 0; i--) square.push_back(i*i);
  for (int i = N; i > 0; i--) {
    if (count(all(square),i)) {
      cout << i << endl;
      return 0;
    }
  }
}
//  [c]
#include<stdio.h>
int main(void)
{
    long long int n,i,j,ans=0;
    scanf("%lld",&n);
    for(i=n;i>0;i--){
        j=1;
        while((j*j)<=i){
            if((j*j)==i)
                ans=i;
            j++;
        }
        if(ans!=0)
            break;
    }
    printf("%lld\n",ans);
    return 0;
}
//  [c]
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d",&a);
  for(int i=a; 0<a; i--){
    b=0;
    for(int j=1; j*j<=i; j++){
      if(j*j==i){b=1;}
    }
    if(b){printf("%d",i);break;}
  }
  return 0;}
//  [c]
#include<stdio.h>
int main(){
  long int n,i,ans=0;
  scanf("%ld",&n);
  for(i=1;i<=n;i++){
    if(ans<i*i&&i*i<=n){
      ans=i*i;
    }
  }
  printf("%ld\n",ans);
  return(0);
}
//  [javascript]
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    var n = parseInt(input[0], 10);
    var ans = 1;
    for (var i = 1; i <= n; i++) {
        if (i * i > n) {
            ans = (i - 1) * (i - 1);
            break;
        }
    }

    console.log(ans);

    return 0;
}
//  [javascript]
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0]);
  var ans =Math.pow(Math.floor(Math.sqrt(n)),2);
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
    var sum = 0;
    for(var i=0;Math.pow(i,2)<=input;i++){
    }
    console.log(Math.pow(i-1,2))
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());