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

int que[100000];
int head = 0;
int tail = 0;
void enq(int a){
    que[tail] = a;
    tail = (tail+1)%100000;
}

int deq(){
    int h = head;
    head = (head+1)%100000;
    return que[h];
}

bool empty(){
    return head == tail;
}

int main() {
    int n, q;
    char name[100000][11];
    int time[100000];
    int clock = 0;

    scanf("%d%d", &n, &q);
    for(int i=0; i<n; i++){
        scanf("%s%d", name[i], &time[i]);
        enq(i);
    }

    while(!empty()){
        int i=deq();
        if(time[i] <= q){
            clock += time[i];
            time[i] = 0;
            printf("%s %d\n", name[i], clock);
        }else{
            clock += q;
            time[i] -= q;
            enq(i);
        }
    }
}

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

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

    vector<int> cnt_arrival(N);
    vector<int> arrival_order(N);
    cnt_arrival[0] = 1;
    int next = 0;
    int order = 1;
    bool flag = false;
    while (!flag) {
        next = A[next];
        cnt_arrival[next]++;
        arrival_order[next] = order;
        if (cnt_arrival[next] == 2) flag = true;
        if (order == K) {
            cout << next + 1 << endl;
            return 0;
        }
        order++;
    }
    int start_roop = A[next];
    int roop_size = arrival_order[next] - arrival_order[start_roop] + 1;

    int dist_from_start = (K - arrival_order[start_roop]) % roop_size;
    int move = 0;
    int nxt = start_roop; 
    while (move != dist_from_start) {
        nxt = A[nxt];
        move++;
    }
    if (move == 0) cout << start_roop + 1 << endl;
    else cout << nxt + 1 << endl;
}


Measured memory_bytes: 6052
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

#define PI 3.141592653589793238
#define INF 1050000000

using namespace std;



//cout << fixed << setprecision(15) << << endl;
//cout << << endl;

int main() {

	int x;

	cin >> x;

	if (x < 1200) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ARC" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
digit_count = N.to_s.size
candidate_list = [['3'], ['5'], ['7']]
current_digit_candidate_list = candidate_list
(digit_count - 1).times do
  current_digit_candidate_list =
    current_digit_candidate_list.flat_map do |candidate|
      ['3', '5', '7'].map { |c| [c] + candidate }
    end
  candidate_list = candidate_list + current_digit_candidate_list
end
answer = candidate_list
  .select { |ca| ca.uniq.size === 3 }
  .map { |ca| ca.join('').to_i }
  .count { |n| n <= N }
puts answer


Measured memory_bytes: 10748
var i,k,n:longint;
begin
read(n);
k:=round(sqrt(2*n));
while k*(k+1)<n*2 do inc(k);
while k*(k-1)>=2*N do dec(k);
dec(n,k*(k+1)div 2);
for i:=1 to k do if i<>-n then writeln(i);
end.

Measured memory_bytes: 128
def parent(n):
    return (n+1)/2-1

def left(n):
    return (n+1)*2-1

def right(n):
    return (n+1)*2

def max_heapify(A, i):
    l = left(i)
    r = right(i)
    largest = i
    if l < len(A) and A[largest] < A[l]:
        largest = l
    if r < len(A) and A[largest] < A[r]:
        largest = r

    if largest != i:
        A[largest],A[i] = A[i],A[largest]
        max_heapify(A,largest)

def build_max_heap(A):
    for i in reversed(range((len(A)-1)/2+1)):
        max_heapify(A,i)

H = int(raw_input())
A = map(int, raw_input().strip().split(' '))
build_max_heap(A)
print "",
print " ".join(map(str,A))

Measured memory_bytes: 61100
#include<iostream>
using namespace std;
int main()
{
	int n,m,i,a[100],j,v,r,t;
	cin>>n>>m;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(i=1;i<=m;i++)
	{
		for(j=0;j<n-1;j++)
		{
			if(j<=n)
			{
				v=a[j]%i;
				r=a[j+1]%i;
				if(v>r)
				{
					t=a[j];
					a[j]=a[j+1];
					a[j+1]=t;
				}
			}
		}
	}
	for(i=0;i<n;i++)
	{
		cout<<a[i]<<endl;
	}
				
				
				
	return 0;
}

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
int i, j, n[10], max, temp;

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

for(i=0; i < 10; i++){
max = i;
for(j = i + 1; j < 10; j++){
if(n[max] <n[j]) max = j;
}
temp = n[max];
n[max] = n[i];
n[i] = temp;

while(i==0){
cout<<temp<<endl;
break;
}
while(i==1){
cout<<temp<<endl;
break;
}
while(i==2){
cout<<temp<<endl;
break;
}

}
}


Measured memory_bytes: 3084
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>

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

    std::vector<int> A(n);
    for (int i = 0; i < n; i++) {
        std::cin >> A[i];
    }

    int q;
    std::cin >> q;
    for (int i = 0; i < q; i++) {
        int b, m, e;
        std::cin >> b >> m >> e;
        std::rotate(A.begin() + b, A.begin() + m, A.begin() + e);
    }

    for (int i = 0; i < A.size(); i++) {
        std::cout << A[i];
        if (i < A.size() - 1) {
            std::cout << " ";
        }
    }
    std::cout << std::endl;
}



Measured memory_bytes: 3164
N, M = map(int, input().split())
submits = [tuple(input().split()) for _ in range(M)]
accepted = {i: 0 for i in range(1, N+1)}
ACs = 0
WAs = 0
for p, S in submits:
    p = int(p)
    if accepted[p] < 0: continue
    if S == 'AC':
        ACs += 1
        WAs += accepted[p]
        accepted[p] = -1
    else:
        accepted[p] += 1
print(ACs, WAs)

Measured memory_bytes: 33272
#include<iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include<string>
#include<utility>
#include<iterator>
#include<regex>
#include<math.h>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(lli i=0;i<j;i++)
#define rep1(i,j) for(lli i=1;i<=j;i++)
#define rep0d(i,j) for(lli i=j-1;i>=0;i--)
#define MAX 1000000007
typedef struct tree Tree;

using namespace std;

bool cmpf(pair<lli, lli> left, pair<lli, lli> right) {
	return left.first < right.first;
}


int main() {
	lli a, b;
	cin >> a >> b;
	if (b == 1) {
		cout << 0; return 0;
	}
	lli tmp = a;
	while (tmp < b)tmp += a - 1;
	cout << 1 + (tmp - a) / (a - 1);
}


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

int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b&&a!=c)printf("Yes");
	else if(a==c&&a!=b)printf("Yes");
	else if(b==c&&a!=b)printf("Yes");
	else printf("No");
}


Measured memory_bytes: 256
a, b = (int(i) for i in input().split()) 
if a == 0 or b > 10**9 or b == 0 or a == b:
  print('IMPOSSIBLE')
  
elif (a + b) % 2 != 0:
  print('IMPOSSIBLE')
else:
  x = (a + b) / 2
  print(int(x))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int gcd(int a,int b)
{
   	if(a<b)swap(a,b);
   	if(b==0)return a;
   	else if(a%b)return(gcd(b,a%b));
	else return(b);
}

int main()	
{
	int n,l[100005],r[100005],ans=-1;
	cin>>n;
	vector<int>v(n+2);
	l[0]=0,r[n+1]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>v[i];
		l[i]=gcd(l[i-1],v[i]);
	}
	for(int i=n;i>=1;i--)r[i]=gcd(r[i+1],v[i]);
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,gcd(l[i-1],r[i+1]));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
#define MP make_pair
#define PB push_back
#define ll long long
#define int long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define ld long double
#define mod 1000000007


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int wi=15;
	string s;
	cin>>s;
	for(char i: s)
	{
		if(i=='x')
			wi--;
	}
	if(wi>=8)
	{
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<PI> a(n);
  REP(i, 0, n) {
    int v;
    cin >> v;
    a[i] = PI(v, i);
  }
  sort(a.begin(), a.end());
  VI ans(n);
  REP(i, 0, n) {
    int idx = a[i].second;
    if (i < n / 2) {
      ans[idx] = a[n / 2].first;
    } else {
      ans[idx] = a[n / 2 - 1].first;
    }
  }
  REP(i, 0, n) {
    cout << ans[i] << endl;
  }
}


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

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define MAX 1000000


ll  fastpower(ll a, ll n)
{
	ll res = 1;
	while(n > 0)
	{
		if(n % 2 != 0)
		{
			res = (res * a) % MOD;
		}
		n /= 2;
		a=(a * a) % MOD;
	}
	return res;
}

void getprime(vector<bool>&prime)
{
	prime[0] = false;
	prime[1] = false;
	
	for(ll i = 2;i <= MAX; i++)
	{
		if(prime[i])
		{
			for(ll j = i*i; j <= MAX; j += i)
				prime[j] = false;
		}
	}
}

void getfact(vector<ll> &fact, vector<ll> &ifact)
{
	fact[0] = 1;
	ifact[0] = 1;
	
	for(ll i = 1; i <= MAX; i++)
	{
		fact[i] = (fact[i-1] * i)%MOD;
		ifact[i] = (ifact[i-1] * fastpower(i, MOD -2) )%MOD;
	}
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,k;
  string s;
  cin>>n>>m;
  vector<bool>done(n, false);
  vector<ll>penalty(n, 0);
  
  ll pen=0;
  for(ll i=0;i<m;i++)
  {
    cin>>k>>s;
    if(s == "WA")
    {
      if(!done[k-1])
	      penalty[k-1]++;
    }
    else
      done[k-1]=true;
  }
  ll corr=0;
  for(ll i=0;i<n;i++)
    if(done[i])
    {
      pen+=penalty[i];
      corr++;
    }
  cout<<corr<<" "<<pen;
  
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c)%mod;
    if (b&1) return (c*a)%mod;
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)3e5+5;
const int Q = 301;

void solve() {
	int n,m;
  cin>>n>>m;
  if (n==m) cout<<"Yes";
  else cout<<"No";
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        //cout<<"\n";
    }
}


Measured memory_bytes: 256
object Main extends App {
  def reverse(nums: List[Int]): Int = {
    def accumlator(acc: Int, nums: List[Int]): Int = {
      nums.forall(_ % 2 == 0) match {
        case true => accumlator(acc + 1, nums.map(_ / 2))
        case false => acc
      }
    }
    accumlator(0, nums)
  }
  val sc = new java.util.Scanner(System.in)
  val _ = sc.nextLine()
  val nums = sc.nextLine().split(" ").map(_.toInt).toList
  val ret = reverse(nums)
  println(ret)
  ret
}


Measured memory_bytes: 25508
import java.io.*;
import java.util.*;
import java.math.*;
public class Main{

    static long M=(long)1e9+7;
    
    public static void main(String[] args) {
        FastReader fs=new FastReader();
        long n=fs.nextLong();
        long k=fs.nextLong();
        long[]arr=new long[(int)n];
        for(int i=0;i<n;i++){
        	arr[i]=fs.nextLong();
        }
        long[] dp=new long[(int)n];
        for(int i=0;i<n;i++){
        	dp[i]=Integer.MAX_VALUE;
        }
        dp[0]=0;
        for(int i=1;i<n;i++){
        	for(int j=1;j<=k;j++){
        		if((i-j)>=0){
        			dp[i]=Math.min(dp[i],dp[i-j]+Math.abs(arr[i]-arr[i-j]));
        		}
        	}
        }
        System.out.println(dp[(int)n-1]);
    }
        
    public static void p(long[]dp){
    		for(int j=0;j<dp.length;j++){
    			System.out.print(dp[j]+"  ");
    		}
    		System.out.println();
    	
    }
    
    public static long inv(long a, long mod){
        return pow(a, mod-2,mod);
    }
    public static long mul(long a,long b,long mod){
        long res=0;
        while(b!=0){
            if ((b & 1) == 1){ res = (res + a) % mod;}
            a = (a + a) % mod;
            b >>= 1;
        }
        return res;
    }
    
    public static long pow(long a, long n, long mod){
        long res=1;
        while(n != 0){
            if ((n & 1) == 1) res = mul(res, a, mod)%mod;
            a = mul(a , a, mod)%mod;
            n >>= 1;
        }
        return res;
    }
    
    public static long gcd(long a, long b){
        if(a == 0) return b;
        return b == 0 ? a: gcd(b, a % b);
    }

    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
}

Measured memory_bytes: 33504
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) (a<<b)
#define Rshift(a,b) (a>>b)
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = max(a, b) - 1;
    ans = min(ans, max(n - a, n - b));
    if (b < a) {
        swap(a, b);
    }
    if (abs(a - b) % 2 == 0) {
        ans = min(ans, abs(a - b) / 2);
    } else {
        ans = min(ans, a + (b - a) / 2);
        ans = min(ans, n - b + 1 + (b - a) / 2);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
s = gets.chomp

min = 100
# 最大26回
s.split("").uniq.each do |c|
  count = 0
  str = s.dup
  # cに全部変える操作を行う(ループは100回以下)
  while true do
    break if str.split("").uniq.length <= 1
    count += 1
    0.upto(s.length-2) do |i| # (ループは100回以下)
      if str[i] == c || str[i+1] == c
        str[i] = c
      end
    end
    str.chop! # 末尾削除
  end
  min = count if count < min
end
puts min


Measured memory_bytes: 14336
import java.util.*;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int[] x = new int[N];
        int[] y = new int[M];
        for(int i = 0; i < N; i++){
            x[i] = sc.nextInt();
        }
        for(int i = 0; i < M; i++){
            y[i] = sc.nextInt();
        }
        String ans = "War";
        Arrays.sort(x);
        Arrays.sort(y);
        if(x[N-1] < y[0]){
            for(int i = x[N-1]+1; i <= y[0]; i++){
                if(i > X && i <= Y){
                    ans = "No War";
                }
            }
        }
        System.out.println(ans);
    }
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
const int INF = 1e9;

ll cost[1 << 16], dp[1 << 16];
int main() {
  ll n;
  cin >> n;
  ll a[n][n];

  rep(i, n) rep(j, n) cin >> a[i][j];

  rep(i, 1 << n) rep(j, n) for (int k = j + 1; k < n;
                                ++k) if (i & (1 << j) && i & (1 << k))
      cost[i] += a[j][k];

  rep(i, 1 << n) for (int j = i; j > 0; j = (j - 1) & i) dp[i] =
      max(dp[i], dp[i - j] + cost[j]);

  cout << dp[(1 << n) - 1] << endl;
  return 0;
}

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

int main()
{
    long long x,cc=0;
    cin>>x;


    while(x>500||x==500){
    int w=x/500;
      x=x-(w*500);
      cc+=(1000*w);
    }

         while(x<500&&(x>100||x==100)){
    int w=x/100;
      x=x-(w*100);
      cc+=(100*w);


         }

         while(x<100&&(x>50||x==50)){
    int w=x/50;
      x=x-(w*50);
      cc+=(50*w);


         }
             while(x<50&&(x>10||x==10)){

 int w=x/10;
      x=x-(w*10);
      cc+=(10*w);

         }

         while(x<10&&(x>5||x==5)){

   int w=x/5;
      x=x-(w*5);
      cc+=(5*w);

         }






    cout<<cc<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

// 整数スキャン（複数）
/*
int x;
scanf("%d",&x);
int y;
scanf("%d",&y);
int z;
scanf("%d",&y);

// n個の整数のスキャン
/*
ll a[n] = {};
rep(i,n){
    scanf("%lld",&a[i]);
}
*/

// 文字列スキャン
/*
string s;
cin >> s;
*/


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




    int ans = 0;

    ans = 1110 - n;

    cout << ans << endl;
   
    return 0;
}
 
 


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

/**
 * HowManyIslands
 */
public class Main {

    public static void main(String[] args) {
        int tate[] = { -1, -1, -1, 0 };
        int yoko[] = { -1, 0, 1, -1 };

        Scanner sc = new Scanner(System.in);
        while (true) {
            int w = sc.nextInt();
            int h = sc.nextInt();

            int list[][] = new int[h][w];

            if (w == 0 && h == 0)
                return;

            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    list[i][j] = sc.nextInt();
                }
            }

            // ここでUnionFind
            int parent[] = new int[w * h]; // 親の番号(親なら全体の大きさをマイナスで)格納
            for (int i = 0; i < w * h; i++) {
                if (list[i / w][i % w] == 0) {
                    parent[i] = 0;
                } else {
                    parent[i] = -1;
                }
            }

            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    // 1マスずつ見る
                    if (list[i][j] == 1) {
                        for (int k = 0; k < 4; k++) {
                            try {
                                if (list[i + tate[k]][j + yoko[k]] == 1) {
                                    connect(i * w + j, (i + tate[k]) * w + j + yoko[k], parent);
                                }
                            } catch (Exception e) {

                            }
                        }
                    }
                }
            }

            int ans = 0;
            for (int i = 0; i < w * h; i++) {
                if (parent[i] < 0) {
                    ans++;
                }
            }

            System.out.println(ans);

        }

    }

    // 親の番号を返す
    private static int root(int n, int[] parent) {
        if (parent[n] < 0) {
            return n;
        } else {
            return root(parent[n], parent);
        }
    }

    private static int size(int n, int[] parent) {
        return -parent[root(n, parent)];
    }

    private static boolean connect(int a, int b, int[] parent) {
        a = root(a, parent);
        b = root(b, parent);

        if (a == b) // 元々同じ仲間なら
            return false;

        if (size(a, parent) < size(b, parent)) {
            int tmp = a;
            a = b;
            b = tmp;
        }

        parent[a] += parent[b];
        parent[b] = a;

        return true;
    }
}


Measured memory_bytes: 45888
N,Y=map(int,input().split())
A=[]
for i in range(Y//10000+1):
    for j in range((Y-i*10000)//5000+1):
        c1=(Y-10000*i-5000*j)/1000
        c2=N-i-j
        if c1==c2:
            A=[i,j,c1]
            break
        if c1!=c2:
            continue
if len(A)==0:
    print("-1 -1 -1")
else:
    A[2]=int(A[2])
    print(str(A[0])+" "+str(A[1])+" "+str(A[2]))


Measured memory_bytes: 3064
s = input()
t = input()

start = [-1]*26
goal = [-1]*26
for i in range(len(s)):
	a = ord(s[i]) - ord('a')
	b = ord(t[i]) - ord('a')
	if start[a] != -1 or goal[b] != -1:
		if start[a] != b or goal[b] != a:
			print('No')
			exit()
	start[a] = b
	goal[b] = a
print('Yes')

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;


template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    string S, T;
    cin >> S >> T;
    int ans = 0;
    for(int i = 0; i < S.size(); ++i){
        if(S[i] != T[i]){
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3792
S = input()
s = []
for i in S:
    s.append(int(i))

a = 0
if s[0] == 0:
    a = 0
else:
    a = 1

c = 0


for i in range(len(s)):
    if i % 2 == 0:
        if a != s[i]:
            c += 1
        else:
            continue
    else:
        if a == s[i]:
            c += 1

print(c)

Measured memory_bytes: 45148
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-9;


int main() {
    
    ll n,m;
    cin>>n>>m;
    ll ans=0;
    vpll v(n);
    rep(i,n)cin>>v[i].fi>>v[i].se;
    Sort(v);
    for(int i=0;i<n;i++){
        // cout<<i<<ans<<endl;
        if(m==0)break;
        if(v[i].se>=m){
            ans+=m*v[i].fi;
            m=0;
        } else{
            m-=v[i].se;
            ans+=v[i].fi*v[i].se;
        }
    }
    fin(ans);

}








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

int main() {
  int a,b;
  cin >> a >> b;
  if(a<=b)
  {
    for(int i=0;i<b;i++)
    {cout << a;
    }}
    else if(a>b)
    {
    for(int i=0;i<a;i++)
    {cout << b;
    }}
    }

Measured memory_bytes: 256
n = int(input())
s = input()
work = s[1:].count("E")
temp = [work]
leader = s[0]
for c in s[1:]:
    if leader == "W":
        work += 1
    if c == "E":
        work -= 1
    temp.append(work)
    leader = c
print(min(temp))

Measured memory_bytes: 15820
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main(void)
{
	int N, K;
	cin >> N >> K;

	vector<long long> a(N);
	for(int i=0; i<N; i++)
		cin >> a[i];

	vector<long long> imos(N+1, 0);
	for(int i=0; i<N; i++)
		imos[i+1] = imos[i] + a[i];

	vector<long long> v;
	for(int i=0; i<N; i++)
		for(int j=i+1; j<N+1; j++)
			v.push_back(imos[j] - imos[i]);
	
	sort(v.begin(), v.end());

	long long ans = 0;
	for(int i=50; i>=0; i--){
		long long bit = ans + (1LL << i);
		auto it = lower_bound(v.begin(), v.end(), bit);
		int cnt = 0;
		for(; it!=v.end(); it++){
			if((*it & bit) == bit)
				cnt++;
		}

		if(cnt >= K)
			ans = bit;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6260
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;


int main(){
    ll n;
    cin>>n;
    if(n%2==1){
        cout<<0<<endl;
    }else{
        ll ans=0;
        for(ll m=10;m<=n;m*=5){
            ans+=n/m;
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;

int main(){
    int n;cin>>n;
    int a=n%10;
    if(a==3){
        cout <<"bon"<<endl;
    }
    else if(a==7){
        cout<<"hon"<<endl;
    }
    else if(a==2){
        cout<<"hon"<<endl;
    }
    else if(a==4){
        cout<<"hon"<<endl;
    }
    else if(a==5){
        cout<<"hon"<<endl;
    }
    else if(a==9){
        cout<<"hon"<<endl;
    }
    else{
        cout<<"pon"<<endl;
    }
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	string s;
	cin >> s;
	if (s == "AAA" || s == "BBB") {
		cout << "No\n";
	} else {
		cout << "Yes\n";
	}
 	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    double total = 0;
    const double btc_to_jpy = 380000;
    cin >> N;
    FOR(i, 0, N) {
        double val;
        string type;
        cin >> val >> type;
        if (type == "JPY")
            total += val;
        else
            total += val * btc_to_jpy;
    }

    cout << fixed << setprecision(6) << total << endl;
    return 0;
};


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

// author:Swastik Banerjee

using namespace std;

typedef long long ll;
#define MOD 1000000007

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



  ll N;
  cin >> N;

  ll x = N / 500;
  x *= 1000;

  ll rem = N % 500;
  ll y = rem / 5;
  y *= 5;

  cout << x + y;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int mod = 1000000000+7;

int main() {
    int h, w;
    cin>>h>>w;
    
    vector<vector<char>> a;
    for (int i=0; i<h; i++){
        vector<char> temp;
        for (int j=0; j<w; j++){
            char c;
            cin>>c;
            temp.push_back(c);
        }
        a.push_back(temp);
    }
    int dp[h][w] = {};
    dp[0][0] = 1;
    for (int i=0; i<h; i++){
        for (int j=0; j<w; j++){
            if (a[i][j]=='.'){
                if (i-1>=0){
                    if (a[i-1][j]=='.') {dp[i][j] = (dp[i][j]+dp[i-1][j])%mod;}
                } 
                if (j-1>=0){
                    if (a[i][j-1]=='.') {dp[i][j] = (dp[i][j]+dp[i][j-1])%mod;}
                }
            }
        }
    }
    
    cout<<dp[h-1][w-1]%mod;
}




Measured memory_bytes: 5120
#include <iostream>
#include <time.h>
//#include <conio.h>
#include <algorithm>
using namespace std;

int min(int a, int b)
{
	if (a >= b)
		return b;
	return a;
}
int max(int a, int b)
{
	if (a >= b)
		return a;
	return b;
}
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (min(b, d) - max(a, c) < 0)
		cout << 0;
	else
	cout << min(b, d) - max(a, c);
	//_getch();
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace PaizaTest
{
    class Program
    {
        static int N;
        static int[] A = new int[20];
        //static Tuple<int, int>[] X = new Tuple<int, int>[20];
        //static Tuple<int, int>[] Y = new Tuple<int, int>[20];
        static int[][] X = new int[20][];
        static int[][] Y = new int[20][];

        static void Main(string[] args)
        {
            Solve();
        }

        static void Solve()
        {
            N = int.Parse(Console.ReadLine());
            for (int i = 1; i <= N; i++)
            {
                X[i] = new int[20];
                Y[i] = new int[20];
                var line = Console.ReadLine();
                A[i] = int.Parse(line);
                for (int j = 1; j <= A[i]; j++)
                {
                    var val = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
                    X[i][j] = val[0];
                    Y[i][j] = val[1];
                }
            }

            int ans = 0;
            for (int bits = 0; bits < (1 << N); bits++)
            {
                bool ok = true;
                for (int i = 1; i <= N; i++)
                {
                    if (((bits & (1 << (i - 1))) == 0)) continue;
                    for (int j = 1; j <= A[i]; j++)
                    {
                        if ((((bits >> (X[i][j] - 1)) & 1) ^ Y[i][j]) != 0)
                        {
                            ok = false;
                        }
                    }
                }
                if (ok)
                {
                    ans = Math.Max(ans, Counter(bits));
                }

            }
            Console.WriteLine(ans);
        }

        static int Counter(int x)
        {
            if (x == 0) return 0;
            return Counter(x >> 1) + (x & 1);
        }
    }
}



Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long N = 1e5+200,OO=1e15;
int n,arr[N],k;
int dp[N];
ll solve(int i){
    if(i==n-1)return 0;
    if(i>=n) return OO;

    if(~dp[i])return dp[i];
    ll ret =OO;
    for(int j=1;j<=k;j++){
        ll ch1=abs(arr[i]-arr[i+j])+solve(i+j);
        ret =min(ch1,ret);
    }

    return dp[i]=ret;
}
int main()
{
    memset(dp,-1,sizeof dp);
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)scanf("%d",arr+i);
    cout<<solve(0)<<endl;
}


Measured memory_bytes: 5760
using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		String s;
		while(!String.IsNullOrEmpty(s=rs())){
			if(s=="END OF INPUT")break;
			var ss=s.Split(' ');
			for(int j=0;j<ss.Length;j++){
				Console.Write("{0}",ss[j].Length);
			}
			Console.WriteLine("");
		}
	}

	public Sol(){
	}




	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}

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

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i = 0; i < n; i++){
    s[i].resize(n);
    for(int j = 0; j < n; j++){
      cin >> s[i][j];
    }
  }

  int ans = 0;

  vector<string> t(n);
  for(int a = 0; a < n; a++){
    bool flag = true;
    for(int i = 0; i < n; i++){
      t[i].resize(n);
    }
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
        t[i][j] = s[(i+a)%n][j];
      }
    }
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
        if(t[i][j] != t[j][i]) flag = false;
      }
    }

    if(flag) ans += n;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

long long cnt[100001] = {};

int main() {
  long long N, K, a, b;

  scanf("%lld %lld", &N, &K);

  for (int i = 0; i < N; i++) {
    scanf("%lld %lld", &a, &b);
    cnt[a] += b;
  }

  long long ans = 0;
  for (int i = 1; i <= 100000; i++) {
    ans += cnt[i];
    if (ans >= K) {
      printf("%d\n", i);
      break;
    }
  }
}


Measured memory_bytes: 896
import java.util.*;

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

        int r = sc.nextInt();
        int D = sc.nextInt();
        int[] x = new int[15];
        x[0] = sc.nextInt();

        for (int i = 0; i < 10; i++) {
            x[i + 1] = r * x[i] - D;
            System.out.println(x[i + 1]);
        }

    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  ll x;
  cin>>x;
  for (ll i=0;i<=1000;i++)
  {
    for (ll j=0;j<i;j++)
    {
      if(powl(i,5)-powl(j, 5)==x)
      {
        cout<<i<<" "<<j<<endl;
        return 0;
      }
      else if(powl(i, 5)+powl(j, 5)==x)
      {
        cout <<i<<" "<<-j<<endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3684
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;

int main() {
    int a, b;
    cin >> a >> b;
    int len = (b - a) * (b - a + 1) / 2;
    ll ans = len - b;
    cout << ans << endl;
}


Measured memory_bytes: 256
global H, N, M
N, M = map(int, input().split())
H = list(map(int, input().split()))

dicts = {i:True for i in range(N)}
for i in range(M):
    a, b = map(lambda x:int(x) - 1, input().split())
    if H[a] < H[b]:
        dicts[a] = False
    elif H[a] == H[b]:
        dicts[a] = False
        dicts[b] = False
    else:
        dicts[b] = False

ans = 0
for i in range(N):
    if dicts[i]:
        ans += 1

print(ans)
    


Measured memory_bytes: 24440
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main(){
    int h,w; cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }
    ll ans = 0;
    for (int i = 1; i <= h; i++)
    {
        if (i % 2 == 1) ans += (w+2-1)/2;
        if (i % 2 == 0) ans += w/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
x=list(map(int,input().split()))
x.sort()

l,r=x[0],x[-1]
mi=sum([(x[i]-l)**2 for i in range(len(x))])
for i in range(l+1,r+1):
    tmp=sum([(x[k]-i)**2 for k in range(len(x))])
    if tmp<mi: mi=tmp
print(mi)

Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
void swap(int & x, int & y){
    int t=x;
    x=y;
    y=t;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

char s[10];

int main(){
	cin >> s;
	
	REP(i,5){
		if (s[i] == 'A' && s[i+1] == 'C'){
			cout << "Yes" << endl;
			return 0;
		}
	}
	
	cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10000)

N, Q = tuple(map(int, input().split()))

tree = [[-1, 1]  for _ in range(N)] # [next, rank]

def find(i):
    if tree[i][0] == -1:
        group = i
    else:
        group = find(tree[i][0])    
    return group

def unite(x, y):
    px = find(x)
    py = find(y)
    
    if tree[px][1] == tree[py][1]: # rank is same
        tree[py][0] = px
        tree[px][1] += 1
    else:
        if tree[px][1] < tree[py][1]:
            px, py = py, px
        tree[py][0] = px

for _ in range(Q):
    com, x, y = tuple(map(int, input().split()))
    if com: # same
        print(int(find(x) == find(y)))
    else: # unite
        if not int(find(x) == find(y)):
            unite(x, y)

Measured memory_bytes: 8824
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  a=(a+11)%13;
  b=(b+11)%13;
  if(a==b){
    cout<<"Draw"<<endl;
  }else if(a<b){
    cout<<"Bob"<<endl;
  }else{
    cout<<"Alice"<<endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}


void solve()
{

 string s,t;
 cin >> s >> t;
 
 int an = 0;
 for(int i=0;i<sz(s);i++)
 {
   if(s[i]!=t[i]) an++;
 }

 cout<<an<<endl;

}


int32_t main()
{
  //pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char> > a(H+2, vector<char>(W+2, '#'));
	vector<vector<ll> > dp(H+2, vector<ll>(W+2, 0));
	for (int i = 1; i <= H; i++)for (int j = 1; j <= W; j++)cin >> a[i][j];
	dp[1][1] = 1;
	for (int i = 1; i <= H; i++)for (int j = 1; j <= W; j++) {
		if (a[i][j] == '#')continue;
		dp[i][j] %= MOD;
		if (a[i + 1][j] == '.') {
			dp[i + 1][j] += dp[i][j];
		}
		if (a[i][j+1] == '.') {
			dp[i][j+1] += dp[i][j];
		}
	}
	cout << dp[H][W] % MOD << endl;
	return 0;
}

Measured memory_bytes: 9216