akhauriyash/Code-Regression huggingface dataset:
###############################################################################

from bisect import bisect_left as binl
from copy import copy, deepcopy

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    n = intin()

    for i in range(n, 1000):
        i2 = i // 100
        i1 = (i // 10) % 10
        i0 = i % 10

        if i0 == i1 and i1 == i2:
            print(i)
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3540
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <iomanip>
#include <cassert>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-9;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9 + 7;
const LL MAX = 1e5 + 47;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	VLL a(3);
	LL k;
	FOR(i, 0, 3)
		cin >> a[i];
	cin >> k;
	sort(ALL(a));
	reverse(ALL(a));

	LL ans = a[1] + a[2] + a[0] * (1LL << k);
	cout << ans << endl;
	cin >> k;
	return 0;
}

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


void solve(long long N, std::vector<long long> x, std::vector<long long> y){
    vector<int> idx(N);
    iota(idx.begin(), idx.end(), 0);
    long double ans = 0;
    long long a = 0;
    do{
        a++;
        for(int i = 0;i < N-1;i++){
            ans += sqrt(pow(x[idx[i]] - x[idx[i+1]], 2) + pow(y[idx[i]] - y[idx[i+1]], 2));
        }
    }while(next_permutation(idx.begin(), idx.end()));
    cout<<setprecision(20)<<ans/a<<endl;
}

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


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int card = sc.nextInt();
		int a[][] = new int[4][13];
		//文字だけを取り除く
		for (int i = 0; i < card; i++) {
		    String b = sc.next();
		    int c = sc.nextInt();
		    if ("S".equals(b))
		        a[0][c - 1] = 1;
		    else if ("H".equals(b))
		        a[1][c - 1] = 1;
		    else if ("C".equals(b))
		        a[2][c - 1] = 1;
		    else
		        a[3][c - 1] = 1;
		}
		
		for (int i = 0; i < 4; i++) {
		    for (int t = 0; t < 13; t++) {
		        if (a[i][t] == 0)
		            if(i == 0)
		                System.out.println("S " + (t + 1));
		            else if (i == 1)
		                System.out.println("H " + (t + 1));
		            else if (i == 2)
		                System.out.println("C " + (t + 1));
		            else if (i == 3)
		                System.out.println("D " + (t + 1));
		    }
		}
    }
}


Measured memory_bytes: 26268
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N, K;
	cin >> N >> K;
	int num;
	double ans = 0;
	rep(i, N)
	{
		num = i + 1;
		double cnt = 1;
		while (num < K)
		{
			num *= 2;
			cnt /= 2;
		}
		ans += cnt / N;
	}
	printf("%.12f", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
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; }

int n,a,b,c,d;
string s;

bool solve(int f,int t){
    int now = f;
    while(now!=t){
        if(s[now+1]!='#')now++;
        else if(s[now+2]!='#')now+=2;
        else return false;
    }
    return true;
}
int main(){
    cin >> n >> a >> b >> c >> d;
    a--;b--;c--;d--;
    cin >> s;
    bool ans = false;
    //追い抜きなしのパターン
    if(solve(b,d)){
        s[d]='#';
        if(solve(a,c))ans=true;
        s[d]='.';
    }
    //追い抜きありのパターン
    if(solve(b,d)){
        bool nx=false;
        for(int i = b-1;i<d-1;i++){
            if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.')nx=true;
        }
        if(nx){
            solve(a,c);
            s[c]='#';
            if(solve(b,d))ans=true;
        }
    }
    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 640
N = int(input())

count = 0
ba = 0
b = 0
a = 0

for _ in range(N):
    s = input()
    if s[0] == "B":
        if s[-1] == "A":
            ba += 1
        else:
            b += 1
    elif s[-1] == "A":
        a += 1

    n = len(s)
    for i in range(n-1):
        if s[i] == "A" and s[i+1] == "B":
            count += 1

# BA
count += max(ba-1, 0)

if ba >= 1:
    if a >= 1 and b >= 1:
        count += 2
        a -= 1
        b -= 1
    elif a > b:
        count += 1
        a -= 1
    elif b > a:
        count += 1
        b -= 1

#if a >= 1 and b >= 1:
count += min(a, b)        

print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cassert>
#include<climits>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define LLINF (LLONG_MAX)
#define MAX 100010

using namespace std;

typedef long long ll;

int N,M,s[MAX],t[MAX],p[MAX],L[MAX],R[MAX];
ll sum[MAX];

int main(){

  cin >> N >> M;
  rep(i,N)cin >> s[i] >> t[i];
  rep(i,M)cin >> p[i];
  sort(p,p+M);
  rep(i,N){
    L[i] = lower_bound(p,p+M,max(s[i],t[i])) - p;
    R[i] = lower_bound(p,p+M,min(s[i],t[i])) - p;
    if(R[i] >= M)R[i]--;
    L[i]--;
    //cout << s[i] << " and " << t[i] << endl;
    //cout << "(" << p[R[i]] << "," << p[L[i]] << ")" << endl;
  }

  //M == 1,2 は別処理
  sum[0] = p[1] - p[0];
  sum[1] = p[2] - p[1];
  rep(i,M-3){
    sum[i+2] = sum[i] + p[i+3] - p[i+2];
  }
  /*
  rep(i,M-1){
    cout << "sum[" << i << "] = " << sum[i] << endl;
    }
  */
  ll ans = 0;
  ll pre = 0;
  rep(i,N){
    //cout << s[i] << " and " << t[i] << endl;
    pre = ans;
    if(p[R[i]] > p[L[i]]){ // 間に０ぽんぬ
      ans += abs(s[i]-t[i]);
      //cout << "0本でち " << ans << " diff " << ans - pre << endl;
      assert(pre <= ans);
      pre = ans;
      continue;
    }
    if(p[R[i]] == p[L[i]]){// 間に１ or 0ぽんね

      if( min(s[i],t[i]) <= p[R[i]] && p[L[i]] <= max(s[i],t[i]) ){

	if(s[i] < t[i]){
	  ans += p[R[i]] - s[i];
	} else {
	  ans += s[i] - p[R[i]];
	}
	//cout << "1本でち " << ans << " diff " << ans - pre << endl;
	assert(pre <= ans);
	pre = ans;

	continue;

      } else {
	ans += abs(s[i]-t[i]);
	//cout << "0x本でち " << ans << " diff " << ans - pre << endl;
	assert(pre <= ans);
	pre = ans;
	continue;
      }
    }

    int theNumber = L[i] - R[i] + 1;
    //cout << "theNumber = " << theNumber << endl;
    if(s[i] > t[i]) {
      if(theNumber & 1){
	ans += (L[i]-2>=0?sum[L[i]-2]:0) - (R[i]-2>=0?sum[R[i]-2]:0);
	ans += s[i] - p[L[i]];
	assert(s[i]-p[L[i]]>=0);
      } else {
	ans += (L[i]-2>=0?sum[L[i]-2]:0) - (R[i]-1>=0?sum[R[i]-1]:0);
	ans += s[i] - p[L[i]] + p[R[i]] - t[i];
	assert(s[i]-p[L[i]]>=0);
	assert(p[R[i]]-t[i]>=0);
      }
    } else {
      if(theNumber & 1){
	ans += (L[i]-1>=0?sum[L[i]-1]:0) - (R[i]-1>=0?sum[R[i]-1]:0);
	ans += p[R[i]] - s[i];
	assert(p[R[i]]-s[i]>=0);
      } else {
	ans += (L[i]-2>=0?sum[L[i]-2]:0) - (R[i]-1>=0?sum[R[i]-1]:0);
	ans += t[i] - p[L[i]] + p[R[i]] - s[i];
	assert(t[i]-p[L[i]] >= 0);
	assert(p[R[i]]-s[i]);
      }
    }
      assert(pre <= ans);
    //cout << "ans = " << ans << " diff " << ans - pre << endl;
    pre = ans;
    //cout << endl << endl;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3908
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
INF =  float("inf")
import bisect

S = input()

if S == "SUN":
    print(7)
elif S == "MON":
    print(6)
elif S == "TUE":
    print(5)
elif S == "WED":
    print(4)
elif S == "THU":
    print(3)
elif S == "FRI":
    print(2)
elif S == "SAT":
    print(1)


Measured memory_bytes: 69044
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int b[n+1],num[n+1];
	string a[n+1];
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
		num[i]=i+1;
	}
	for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(a[i]>a[j])
			{
				swap(a[i],a[j]);
				swap(b[i],b[j]);
				swap(num[i],num[j]);
			}
		}
	}
	for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(a[i]==a[j]&&b[i]<b[j])
			{
				swap(a[i],a[j]);
				swap(b[i],b[j]);
				swap(num[i],num[j]);
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		cout<<num[i]<<endl;
	 } 
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
string f,g,h,i;
int a,b,c,d,e;
 
int main(){
	
	cin>>a>>b>>c>>d;
	if(a+b>c+d){cout<<"Left"<<endl;}
	else if(a+b==c+d){cout<<"Balanced"<<endl;}
            else{cout<<"Right"<<endl;}

return 0;
}



Measured memory_bytes: 256
h, w = map(int, input().split())
grid = [["#"] * (w + 2) for _ in range(h + 2)]

for i in range(h):
    grid[i + 1] = ["#"] + list(map(str, input().rstrip())) + ["#"]

for i in range(h + 2):
    print("".join(grid[i]))

Measured memory_bytes: 9092
// Problem : C - Sentou
// Contest : AtCoder - AtCoder Beginner Contest 060
// URL : https://atcoder.jp/contests/abc060/tasks/arc073_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

double pi=acos(-1.0);
const int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int n,t;cin>>n>>t;
vi v(n);cin>>v;
int total=t;
int tt=v[0]+t;
for(int i=1;i<n;i++)
{
	if(v[i]>=tt)
	{
		tt=v[i]+t;
		total+=t;
	}
	else
	{
		total-=(tt-v[i]);
		total+=t;
		tt=v[i]+t;
	}
}
cout<<total;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


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

int main() {
    constexpr int64_t N = 2;
    vector<int64_t> T(N), A(N), B(N);
    for (int64_t i = 0; i < N; i++) {
        cin >> T[i];
    }
    for (int64_t i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int64_t i = 0; i < N; i++) {
        cin >> B[i];
    }

    if ((A[0] * T[0] + A[1] * T[1]) == (B[0] * T[0] + B[1] * T[1])) {
        cout << "infinity" << endl;
        return 0;
    }

    //Aの方が絶対速くする
    if (A[0] * T[0] + A[1] * T[1] < B[0] * T[0] + B[1] * T[1]) {
        swap(A, B);
    }

    if (A[0] > B[0]) {
        cout << 0 << endl;
        return 0;
    }

    int64_t ok = -1, ng = LLONG_MAX / 2;
    while (ng - ok != 1) {
        int64_t mid = (ok + ng) / 2;

        //mid距離差がある状態から走って交差するか
        //T[0]秒後の位置
        int64_t A_after_T0 = mid + A[0] * T[0];
        int64_t B_after_T0 = B[0] * T[0];
        if (A_after_T0 == B_after_T0) {
            ok = mid;
        } else if (A_after_T0 <= B_after_T0) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    int64_t diff = (A[0] * T[0] + A[1] * T[1] - B[0] * T[0] - B[1] * T[1]);
    int64_t num = ok / diff;
    int64_t last_diff = num * diff;
    int64_t A_after_T0 = last_diff + A[0] * T[0];
    int64_t B_after_T0 = B[0] * T[0];
    bool last = (A_after_T0 == B_after_T0);

    //ok差までは交差する
    cout << 1 + num * 2 - last << endl;
}

Measured memory_bytes: 256
import time as ti


class MyQueue(object):
    """
    My Queue class

    Attributes:
        queue: queue
        head
        tail
    """

    def __init__(self):
        """Constructor
        """
        self.length = 50010
        self.queue = [0] * self.length
        # counter = 0
        # while counter < self.length:
        #     self.queue.append(Process())
        #     counter += 1
        self.head = 0
        self.tail = 0

    # def enqueue(self, name, time):
    def enqueue(self, process):
        """enqueue method

        Args:
            name: enqueued process name
            time: enqueued process time

        Returns:
            None
        """
        self.queue[self.tail] = process
        # self.queue[self.tail].name = name
        # self.queue[self.tail].time = time
        self.tail = (self.tail + 1) % self.length

    def dequeue(self):
        """dequeue method

        Returns:
            None
        """
        # self.queue[self.head].name = ""
        # self.queue[self.head].time = 0
        self.queue[self.head] = 0
        self.head = (self.head + 1) % self.length

    def is_empty(self):
        """check queue is empty or not

        Returns:
            Bool
        """
        if self.head == self.tail:
            return True
        else:
            return False

    def is_full(self):
        """chech whether queue is full or not"""
        if self.tail - self.head >= len(self.queue):
            return True
        else:
            return False


class Process(object):
    """process class
    """

    def __init__(self, name="", time=0):
        """constructor
        Args:
            name: name
            time: time
        """
        self.name = name
        self.time = time

    def forward_time(self, time):
        """time forward method

        Args:
            time: forward time interval

        Returns:
            remain time

        """
        self.time -= time
        return self.time


def time_forward(my_queue, interval, current_time,):
    """

    Args:
        my_queue: queue
        interval: time step interval
        current_time: current time
    """

    value = my_queue.queue[my_queue.head].forward_time(interval)
    if value <= 0:
        current_time += (interval + value)
        print my_queue.queue[my_queue.head].name, current_time
        my_queue.dequeue()

    elif value > 0:
        current_time += interval
        # name, time = my_queue.queue[my_queue.head].name, \
        #              my_queue.queue[my_queue.head].time
        my_queue.enqueue(my_queue.queue[my_queue.head])
        my_queue.dequeue()

    return current_time


my_queue = MyQueue()
n, q = [int(x) for x in raw_input().split()]
counter = 0
while counter < n:
    name, time = raw_input().split()

    my_queue.enqueue(Process(name, int(time)))
    counter += 1

# end_time_list = []
current_time = 0
while not my_queue.is_empty():
    current_time = time_forward(my_queue, q, current_time)

Measured memory_bytes: 26340
n=int(input())
a=list(map(int,input().split()))
a=[0]+a

now=1000
dp_poss=[0 for i in range(n+1)]
dp_stck=[0 for i in range(n+1)]

buy_choice=[False]*(n+1)
tmp=a[1]
for i in range(1,n):
    if tmp==a[i+1]:continue
    if tmp<a[i+1]:
        buy_choice[i]=True
    tmp=a[i+1]
buy_choice[-1]=False


# day 0
dp_poss[0]=1000

#day 1~
for i in range(1,n+1):
    if buy_choice[i]:
        afford=dp_poss[i-1]//a[i]
        dp_poss[i]=dp_poss[i-1]-afford*a[i]
        dp_stck[i]=dp_stck[i-1]+afford
    else:
        dp_poss[i]=dp_poss[i-1]+dp_stck[i-1]*a[i]

print(dp_poss[n])

    

Measured memory_bytes: 9032
operator fun Pair<Int, Int>.minus(pair: Pair<Int, Int>) = Pair(first - pair.first, second - pair.second)
fun Pair<Int, Int>.manhattanTo(pair: Pair<Int, Int>) = (this - pair).manhattanLength()
fun Pair<Int, Int>.manhattanLength() = Math.abs(first) + Math.abs(second)

data class WayPoint(private val t: Int, private val coordinate: Pair<Int, Int>) {
    private fun timeTo(wayPoint: WayPoint) = wayPoint.t - t

    fun canThenReachTo(wayPoint: WayPoint) = coordinate.manhattanTo(wayPoint.coordinate).let { distance ->
        distance <= timeTo(wayPoint) && timeTo(wayPoint) % 2 == distance % 2
    }
}

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val initialPoint = WayPoint(0, Pair(0, 0))
    val wayPoints = listOf(initialPoint) + (0 until n).map {
        val (t, x, y) = readLine()!!.split(" ").map { it.toInt() }
        WayPoint(t, Pair(x, y))
    }

    val travellable = wayPoints.mapIndexedNotNull { index, wayPoint ->
        wayPoints.getOrNull(index + 1)?.let { nextWayPoint ->
            Pair(wayPoint, nextWayPoint)
        }
    }.all { it.first.canThenReachTo(it.second) }

    println(if (travellable) "Yes" else "No")
}

Measured memory_bytes: 75300
#include<iostream>

//*s,*bを入れ替えm番目とz番目m<z
void exchange(int *s, bool *b, int m, int z) {
	int x;
	bool boo;

	x = *(s + m);
	boo = *(b + m);

	*(s + m) = *(s + z);
	*(b + m) = *(b + z);

	*(s + z) = x;
	*(b + z) = boo;
}

//s:並び替え,n:データ数,p:閾値
void sortx(int *s, int n, int p) {
	bool *b;
	b = (bool *)malloc(sizeof(bool)*(n + 1));
	if (b == NULL) return;
	int q = 0;
	for (int m = 0; m < n; m++) {
		if (p < *(s + m)) {
			//閾値より小さいtrue
			*(b + m) = true;
			//中央値
			q++;
		}
		else {
			*(b + m) = false;
		}
	}
	exchange(s, b, 0, q);
	for (int m = 0; m < q; m++) {
		if (*(b + m) == false) {
			for (int z = 0 + q; z < n; z++) {
				if (*(b + z) == true) {
					exchange(s, b, m, z);
				}
			}
		}
	}
	free(b);
	if (n <= 1) {
	}
	else {
		sortx(s, q, *s);
		sortx(s + q + 1, n - q - 1, *(s + q + 1));
	}

}


int main() {
	
	int a;
	scanf("%d", &a);
	int *s;
	s = (int*)malloc(sizeof(int)*(a + 1));
	if (s == NULL) return -1;

	for (int x = 0; x < a; x++) {
		scanf("%d", s+x);
		
	}
	sortx(s,a,*s);
	double value = *(s+a-1)*1.0;
	for (int x = a - 2; 0 <= x; x--) {
		value = (value + *(s + x)) / 2;
	}
	/*
	for (int x = 0; x < a; x++) {
		printf("%d\n",*(s+x));
	}
	*/
	printf("%f", value);
	free(s);
	scanf("\n%d", &a);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  long long count1=0,count2=0;
  vector<long long>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
    count1+=A[i];
    if(i%2==1)count2+=A[i];
  }
  vector<long long>B(N);
  B[0]=count1-2*count2;
  cout<<B[0]<<" ";
  for(int i=1;i<N;i++){B[i]=(A[i-1]-B[i]/2)*2-B[i-1];cout<<B[i]<<(i!=N-1? " ":"");}
  cout<<"\n";
}

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

int main() {
  string S;
  cin >> S;
  int ans = 0;
  for(int i = 0; i < S.size() / 2; ++i) {
    int j = i;
    int k = S.size() - 1 - i;
    if(S[j] != S[k]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main()
{
   
    long long int h;
    double a = 0;
    cin >> h;
    long long int t = 0;
    while (h) {
        t += pow(2, a);
        a++;
        h /= 2;
    }
    cout << t << endl;


    return 0;

}


Measured memory_bytes: 512
from collections import defaultdict
import sys
def read():
    return sys.stdin.readline().rstrip()
def main():
    N, Q = map(int, read().split())
    C = list(map(int, read().split()))
    E = defaultdict(list)

    D = [-1] * (N + 1)
    for i in range(N):
        D_i = D[C[i]]
        if D_i != -1:
            E[D_i].append((D_i, i))
        D[C[i]] = i

    F = defaultdict(list)
    for i in range(Q):
        l, r = map(int, input().split())
        F[l-1].append((r - 1, i))



    # Binary Indexed Tree (Fenwick Tree)
    class BIT:
        def __init__(self, n):
            self.n = n
            self.data = [0] * (n + 1)
            self.el = [0] * (n + 1)

        def sum(self, i):
            s = 0
            while i > 0:
                s += self.data[i]
                i -= i & -i
            return s

        def add(self, i, x):
            # assert i > 0
            self.el[i] += x
            while i <= self.n:
                self.data[i] += x
                i += i & -i

        def get(self, i, j=None):
            if j is None:
                return self.el[i]
            return self.sum(j) - self.sum(i)

    ANS = [0] * Q
    d = BIT(N)
    for x in range(N - 1, -1, -1):
        for e in E[x]:
            d.add(e[1], 1)
        for f in F[x]:
            ANS[f[1]] = f[0] - x + 1 - d.sum(f[0])

    for i in range(Q):
        print(ANS[i])

if __name__ == '__main__':
    main()


Measured memory_bytes: 287856
a, b = gets.split.map(&:to_s)

if a == 'H' && b == 'H'
  puts 'H'
elsif a == 'H' && b == 'D'
  puts 'D'
elsif a == 'D' && b == 'H'
  puts 'D'
else
  puts 'H'
end


Measured memory_bytes: 1788
nm = input().split()
n, m = map(int, nm)

A = [[int(i) for i in input().split()] for j in range(n)]

b = [int(input()) for i in range(m)]

for row in A:
    s = 0
    for i, elm in enumerate(row):
        s += (elm*b[i])
    print(s)

Measured memory_bytes: 7996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
    int n,m;cin>>n>>m;
    vector<int> g[n];
    for (int i=0;i<m;i++) {
        int a,b;cin>>a>>b;a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    queue<int> q;
    q.push(0);
    int vis[n]{1};
    int ans[n];
    while (q.size()) {
        int v=q.front();q.pop();
        for (int u:g[v])
            if (!vis[u]) {
                ans[u]=v+1;
                vis[u]=1;
                q.push(u);
            }
    }
    cout<<"Yes"<<endl;
    for (int i=1;i<n;i++)
        cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 10848
H = int(input())
W = int(input())
N = int(input())

p = -1
if H > W:
    p = H
else:
    p = W

count = 1
result = 1
while True:
    result = count * p
    if result >= N:
        print(count)
        break
    else:
        count += 1


Measured memory_bytes: 3060
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	string s;
	cin >> s;
	REP1(i, s.size()/2 - 1){
		if(s.substr(0, i) == s.substr(i, i)) ans = i*2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, c, k;
  cin >> n >> c >> k;
  int ans = 0;
  vector<int> tt(n);
  rep(snip_i, n) cin >> tt.at(snip_i);
  sort(tt.begin(), tt.end());
  deque<int> td;
  rep(i, n){
    int t = tt.at(i);
    if(td.size() > 0 &&  t - td.front() > k){
      ans++;
      td.clear();
    }
    td.push_back(t);
    if(td.size() == c){
      ans++;
      td.clear();
    }
    // cerr << ans << endl;
  }
  if(td.size() > 0)ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include "stdio.h"

int main(int argc, char const *argv[])
{
	int i;
	int a,b,c;
	while(scanf("%d %d",&a,&b) != EOF){
		c = a+b;
		for(i=1;c>=10;i++){
			c = c/10;
		}
		printf("%d\n",i);
	}

	return 0;
}

Measured memory_bytes: 600
import std;

long calc(long[] a) {
    if (a.any!(e => e == 0)) return 0;

    long x = 1;
    long m = 10L ^^ 18;
    foreach (e; a) {
        long y = x * e;
        if (y < x) return -1;
        if (y > m) return -1;
        x = y;
    }
    return x;
}

void main() {
    int n; scan(n);
    auto a = reads!long;
    writeln(calc(a));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;


Measured memory_bytes: 7988
#include <bits/stdc++.h>
#include <cmath>
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    rep(i,0,(int)s.length()){
        if(s[i]+n>'Z'){
            int buf=n-('Z'-s[i])-1;
            s[i]='A';
            s[i]+=buf;
        }
        else s[i]+=n;
    }
    cout<<s<<endl;
}

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

struct node{
  int key;
  node *parent,*left,*right;
};
node *root,*nil;

void insert(int k){
  node *p;
  p = (node *)malloc(sizeof(node));
  p->key = k;
  p->left = nil;
  p->right = nil;

  node *v = root,*u = nil;
  //if(v == nil) return;
  while(v != nil){
    u = v;
    if(p->key < v->key) v = v->left;
    else v = v->right;
  }
  p->parent = u;
  if(u == nil) root = p;
  else {
    if(p->key < u->key) u->left = p;
    else u->right = p;
  }
}

bool find(int k){
  node *p;
  p = root;
  while(p != nil){
    if(p->key == k) return 1;
    if(p->key < k) p = p->right;
    else p = p->left;
  }
  return 0;
}

void preorder(node *u){
  if(u == nil) return;
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}

void inorder(node *u){
  if(u == nil) return;
  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);
}

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

  int m; cin >> m;
  for(int i = 0; i < m; i++){
    string s; cin >> s;
    if(s[0] == 'p'){
      inorder(root);
      cout << '\n';
      preorder(root);
      cout << '\n';
      continue;
    }
    else if(s[0] == 'f'){
      int k; cin >> k;
      if(find(k)) cout << "yes" << endl;
      else cout << "no" << endl;
      continue;
    }
    int k; cin >> k;
    insert(k);
  }

  return 0;
}



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

int main(int argc, char** argv){
  string S;
  cin >> S;
  
  if(S[5] == '0' && (S[6] == '1' || S[6] == '2' || S[6] == '3' || S[6] == '4' )) cout << "Heisei" << endl;
  else cout << "TBD" << endl;
  
  
}

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

int main()
{
    int k;
    string s;
    cin >> k >> s;
    if (s.length() <= k)
        cout << s << endl;
    else
    {
        rep(i, k) cout << s[i];
        cout << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
import java.util.*;
import java.io.*;
import static java.lang.System.*;
import static java.lang.Math.*;

class Item {
  int value;
  int weight;
}

public class Main {
	static int[][] dp;
	static int[] p;

	public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int w = sc.nextInt();

    Item[] item = new Item[n+1];
    int[][] dp = new int[n+1][w+1];

    for (int i = 1; i <= n; i++) {
      item[i] = new Item();
      item[i].value = sc.nextInt();
      item[i].weight = sc.nextInt();
    }
    sc.close();

    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= w; j++) {
        dp[i][j] = dp[i-1][j];
        if(j-item[i].weight >= 0){
          dp[i][j] = max(dp[i][j], dp[i-1][j-item[i].weight] + item[i].value);
        }
      }
    }

    out.println(dp[n][w]);
	}

}


Measured memory_bytes: 30824
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}
func bOut(f bool, x string, y string) {
	if f {
		fmt.Println(x)
	} else {
		fmt.Println(y)
	}
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b := iScan()-1, iScan()-1
	g := make([][]string, 100)
	for i := 0; i < 100; i++ {
		g[i] = make([]string, 100)
		for j := 0; j < 50; j++ {
			g[i][j] = "#"
		}
		for j := 50; j < 100; j++ {
			g[i][j] = "."
		}
	}
	for i := 0; i < a; i++ {
		x := i * 2 % 100
		y := i * 2 / 100 * 2
		g[x][y] = "."
	}
	for i := 0; i < b; i++ {
		x := i * 2 % 100
		y := i * 2 / 100 * 2
		g[x][99-y] = "#"
	}
	fmt.Println(100, 100)
	for i := 0; i < 100; i++ {
		fmt.Println(strings.Join(g[i], ""))
	}
}


Measured memory_bytes: 1996
/*
  Contest 072
  A - Sandglass2
  Rakesh Kumar --> 10/09/2020
 */

#include <bits/stdc++.h>

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

    std::string s;
    std::getline(std::cin, s);
    for (std::size_t i = 0; i < s.size(); ++i)
        if ((i & 1) == 0)
            std::cout << s[i];
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 3712
from fractions import gcd
import math
n = int(input())
a = list(map(int, input().split()))
MOD=10**9+7
lcm=1
for i in range(n):
    lcm*=a[i]//gcd(lcm,a[i])
res=0
for i in range(n):
    res+=lcm//a[i]
print(res%MOD)

Measured memory_bytes: 6112
# include <bits/stdc++.h>
 
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
# define forn(i, n) for (ll i = 0; i < int(n); i++)
# define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
# define all(V) V.begin(), V.end()
# define rall(V) V.rbegin(), V.rend()
# define len(V) (int)V.size()
# define ll long long
# define ld long double
# define ff first
# define ss second
# define pb push_back
# define mp make_pair
# define endl '\n'
# define M_PI 3.14159265358979323846
 
void solve()
{
        int arr[3][3];
        forn(i, 3) { forn(j, 3) cin >> arr[i][j]; }
        map<pair<int, int>, int> mp;
        int n; cin >> n;
        vector<int> a(n);
        forn(i, n) cin >> a[i];
        for(int i = 0; i < n; ++i)
        {
                int c = a[i];
                for(int j = 0; j < 3; ++j)
                {
                        for(int k = 0; k < 3; ++k)
                        {
                                if(arr[j][k] == c) arr[j][k] = 0;
                        }
                }
        }
        bool ok = false;
        for(int i = 0; i < 3; ++i)
        {
                int cnt = 0;
                for(int j = 0; j < 3; ++j)
                {
                        if(arr[i][j] == 0) cnt++;
                }
                if(cnt == 3) ok = true;
        }
        for(int i = 0; i < 3; ++i)
        {
                int cnt = 0;
                for(int j = 0; j < 3; ++j)
                {
                        if(arr[j][i] == 0) cnt++;
                }
                if(cnt == 3) ok = true;
        }
        if(arr[0][0] == 0 && arr[1][1] == 0 && arr[2][2] == 0) ok = true;
        if(arr[2][0] == 0 && arr[1][1] == 0 && arr[0][2] == 0) ok = true;
        cout << (ok ? "Yes" : "No");
}
 
int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long k;
int main(){
  string N;
  cin >> N;
  int count =0;
  for(int i =0; i<N.size(); i++){
    if(N[i]=='7'){
      cout << "Yes" << endl;
      break;
    }
      count++;
  }
  if(count==3)cout << "No" << endl;
  
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using  namespace std;
#define pb push_back
#define M 1000000007
#define f first
#define s second
typedef long long int ll;

void solve(){
	
	string s;
	int cnt, maxx = 0;
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'R')
			cnt++;
		else{
			maxx = max(maxx, cnt);
			cnt = 0;
		}
	}
	maxx = max(maxx, cnt);
	cout << maxx << endl;

}		

int main(){

	int t;
	// cin >> t;
	t = 1;
	for(int q = 0; q < t; q++){
		solve();
	}

	return 0;
}

Measured memory_bytes: 3596
function main()
  
  n = parse(Int, readline())
  
  checks = [Dict() for i in 1:n]
  
  for i in 1:n
    S = collect(chomp(readline()))
    for j in S
      checks[i][j] = get(checks[i], j, 0) + 1
    end
  end
  
  key = []
  
  for i in keys(checks[1])
    push!(key, i)
  end
  
  sort!(key)
  cnt = checks[1]

  for i in key
    for j in 1:n

      cnt[i] = min(cnt[i], get(checks[j], i, 0))
      
    end
  end
  
  for i in key
    for j in 1:cnt[i]
      print(i)
    end
  end
  
  print("\n")
 
end

main()

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

using namespace std;
typedef long long ll;

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<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;

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

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

const int N = 100000;
int cnt[N + 1];
mint fc[N + 1];
int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	ll k; cin >> k; ll n = 3;
	for (int i = 1; i <= k; i++) cnt[i] += 1;
	for (int i = 1; i <= k; i++) {
		for (int j = i + i; j <= k; j += i) {
			cnt[i] += cnt[j];
		}
	}
	for (int i = k; i >= 1; i--) {
		for (int j = i + i; j <= k; j += i) {
			fc[i] -= fc[j];
		}
		fc[i] += mint(cnt[i]).pow(n);
	}
	mint res = 0;
	for (int i = 1; i <= k; i++) {
		res += fc[i] * i;
	}
	cout << res.x << "\n";
	return 0;
}

Measured memory_bytes: 4408
#include <bits/stdc++.h>
    
#define int long long
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x)
#define all(x) ((x).begin(), (x).end())
#define mp(x, y) make_pair(x, y) 
#define SORT(x) sort((x).begin(), (x).end())
#define INF 99999999999
#define MOD (int)(1e9)+7
    
using namespace std;
    
int dy[4]={1, 0, -1, 0};
int dx[4]={0, 1, 0, -1};

int32_t main(){
    int n, m;
    cin >> n >> m;
    int k = m - n;
    int s = 0;
    REP(i, k){
        s += i;
    }

    cout << s - n << endl;
}

Measured memory_bytes: 256
/****************************
*  Developer : joshi08
*  Date  :  16-06-2020
*  Year  :  2020
****************************/

#include <bits/stdc++.h>

#define lli long long int
#define mod 1000000007
#define fi first
#define se second
#define ii pair<lli, lli>
#define mp make_pair
#define endl '\n'
const double PI = 3.141592653589793238460;
lli gcd(lli a, lli b) { if (a == 0) return b; return gcd(b % a, a);}
lli max(lli a, lli b) {if (a > b) return a; else return b;}
lli min(lli a, lli b) {if (a < b) return a; else return b;}
lli power(lli a,lli b) {lli i,p=1; for(i=0;i<b;i++){p*=a;} return p;}

using namespace std;

int main()
{
    ios::sync_with_stdio(false);

	lli a,b;
	cin>>a>>b;
	cout<<a*b;

    return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans = MOD;
  rep(i,n-k+1){
    int l = a[i];
    int r = a[i+k-1];
    ans = min(abs(r) + abs(r-l),ans);
    ans = min(abs(l) + abs(r-l),ans);
  }
  cout << ans << endl;
}



Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

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

		int x = sc.nextInt();
		if(x == 0) {
			System.out.println(1);
		}else {System.out.println(0);}

	}

}

Measured memory_bytes: 35596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    vector<pair<int,pair<int,int>>> v;
    for (int i=1; i<=150; ++i) {
        for (int j=i+1; j<=150; ++j) {
            v.push_back(make_pair(i*i+j*j, make_pair(i, j)));
        }
    }
    sort(v.begin(), v.end());

    int h, w;
    while (cin >> h >> w, (h || w)) {
        for (int i=1; i<(int)v.size(); ++i) {
            if (v[i-1].second.first == h && v[i-1].second.second == w) {
                cout << v[i].second.first << " " << v[i].second.second << endl;
                break;
            }
        }
    }
    return 0;
}

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

int main() {
    ll N;
    cin >> N;
    ll ans[90];
    ans[0] = 2; ans[1] = 1;
    for(int i = 2; i <= N; i++) {
        ans[i] = ans[i - 2] + ans[i - 1];
    }
    cout << ans[N] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int X, Y, Z;
  cin >> X >> Y >> Z;
  int a = Z;
  Z = Y; Y = X; X = a;
  cout << X << ' ' << Y << ' ' << Z << '\n';
  return 0;
}

Measured memory_bytes: 3424
N,K = [int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
####まず一周の場合を求める
low=0
high=0
eq=0
for i in range(N):
  for j in range(i+1,N):
    if(ls[i]>ls[j]):
      low+=1
    elif(ls[i]<ls[j]):
      high+=1
    else:
      eq+=1
####K周の場合
ans=0
ans+=low*K*(K+1)//2
ans+=high*K*(K-1)//2
ans=ans%(1000000007)
print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll A,B,C,D;
	cin>>A>>B>>C>>D;
	ll c1=(C+B-1)/B;
	ll c2=(A+D-1)/D;
	if(c1>c2){
		cout<<"No\n";
	}
	else{
		cout<<"Yes\n";
	}
}

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

int main(){
    int n,k;
    cin>>n>>k;
    int h[n],i;
    for(i=0;i<n;i++)cin>>h[i];
    int ans=0;
    for(i=0;i<n;i++){
        if(h[i]>=k)ans++;	
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n)  for (int i = 0; i < n; i++)
#define loop(i,a,n)  for (int i = a; i <= n; i++)
#define deb(x) cout << #x << " = " << x <<'\n'
typedef long long ll;

int main(){
    int n,m;
    cin >> n >> m;
    int sum = 0;
    for(int i = 0; i < m;i++){
        int x;
        cin >> x;
        sum += x;
    }
    n-sum < 0 ? cout << -1 : cout << n-sum;
    cout << endl;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	ll a, b;
	scanf("%lld%lld", &a, &b);
	if (a > b)swap(a, b);
	if (a == 1)
	{
		if (b == 1)printf("1\n");
		else printf("%lld\n", b - 2);
	}
	else printf("%lld\n", (a - 2)*(b - 2));
}


Measured memory_bytes: 128
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <iterator>      // std::next prev


using namespace std;


int main() {   
    std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int left,middle,right;
	if(n>2)
	{
		int ans = 1;
		cin>>left>>middle;
		while(cin>>right)
		{
			if(left<middle)
			{
				if(middle<right)
				{
					left = middle;
					middle = right;
				}
				else if(middle>right)
				{
					left = right;
					cin>>middle;
					ans++;
				}
			}
			else if(left>middle)
			{
				if(middle>right)
				{
					left = middle;
					middle = right;
				}
				else if(middle<right)
				{
					left = right;
					cin>>middle;
					ans++;
				}
			}
			else
			{
				middle = right;
			}
		}
		cout<<ans;
	}
	else
	{
		cout<<1;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int sumt,sums,sum;
int main()
{
    std::ios::sync_with_stdio(false);
    cin>>s;
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        if(s[i]=='S') sums++;
        else if(sums) sumt++;
        if(sums>=sumt)
        {
            sum+=min(sums,sumt)*2;
            sums-=min(sums,sumt);
            sumt=0;
        }
    }
    cout<<n-sum<<endl;
    return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    for(int i = 0; i < N; ++i) {
        cin >> H[i];
    }
    vector<bool> Res(N, true);
    for(int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;
        if(H[A-1] > H[B-1]) Res[B-1] = false;
        else if(H[A-1] == H[B-1]) Res[A-1] = false, Res[B-1] = false;
        else Res[A-1] = false;
    }
    int ans = 0;
    for(auto p : Res)
    {
        if(p) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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

	
	int N, L;
	cin >> N >> L;
	string S[100];
	rep(i, N) cin >> S[i];
	sort(S, S + N);

	string kotae;
	rep(i, N) {
		kotae += S[i];
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256