akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;
class Main{


	static final int MOD = 1000000007;


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int m = sc.nextInt();

		int ans = n-m*2;
		if(ans < 0){
			ans = 0;
		}
		System.out.println(ans);

		
	}


	static long dijkstra(Edge[] edge,int n){

		long[] d = new long[n];		//始点からの最短距離
		Arrays.fill(d, 1l << 60);
		d[0] = 0;
		PriorityQueue<P> q = new PriorityQueue<>(Comparator.comparingLong(p-> p.cost));			//costをソート
		q.add(new P(0,0));

		while(!q.isEmpty()){
			P current = q.remove();
			if(current.to == n-1){
				return current.cost;
			}
			if(current.cost != d[current.to]){
				continue;
			}
			for(P next: edge[current.to]){
				if(d[next.to] > current.cost + next.cost){
					d[next.to] = current.cost + next.cost;
					q.add(new P(next.to, current.cost+next.cost));
				}
			}


		}
		return -1;



	}



	static int upperbond(int k,int currentindex, ArrayList<Pair> a,ArrayList<Pair> b,int[] aa,int[] bb){		//kより小さい最大の値をdataの中から探し、返す二分探索
		int min = -1;
		int max = a.size();

		while(max-min > 1){
			int mid = (max+min)/2;
			if(a.get(mid).from > k){
				max = mid;
			}else{
				min = mid;
			}
		}

		if(max == a.size()){
			max--;
		}
		for(int i = max; i>=0;i--){
			if(a.get(i).from <= bb[currentindex] && aa[currentindex] <= bb[a.get(i).end]){
				int tmp = a.get(i).end;
				a.get(i).end = a.get(currentindex).end;
				a.get(currentindex).end = tmp;

				return tmp;
			}
		}

		return -1;
	}

	static int lowerbond(int k, ArrayList<Integer> data){		//kより小さい最小の値をdataの中から探し、返す二分探索
		int min = -1;
		int max = data.size();

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data.get(mid) >= k){
				max = mid;
			}else{
				min = mid;
			}
		}
		return data.get(min);
	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}


class Edge extends ArrayList<P>{

}

class P{
	int to;
	long cost;
	P(int to,long cost){
		this.to = to;
		this.cost = cost;
	}
}


class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   from- otherpair.from;
	}








}






Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int N=105;
const int mod=1e9+7;
const double eps=1e-8;
const double PI = acos(-1.0);
#define lowbit(x) (x&(-x))
int a[N][N];
int main()
{
    std::ios::sync_with_stdio(false);
    int w,h,n;
    cin>>w>>h>>n;
    int ss=h,xx=0,zz=0,yy=w;
    for(int i=1; i<=n; i++)
    {
        int x,y,a;
        cin>>x>>y>>a;
        if(a==1)
        {
            zz=max(zz,x);
        }
        if(a==2)
        {
            yy=min(yy,x);
        }
        if(a==3)
        {
            xx=max(xx,y);
        }
        if(a==4)
        {
            ss=min(ss,y);
        }
    }
    if(ss<=xx||yy<=zz)
        cout<<0<<endl;
    else
        cout<<(ss-xx)*(yy-zz)<<endl;
    return 0;
}


Measured memory_bytes: 256
n,m= map(int, input().split())
a =[input() for _ in range(n)]
b =[input() for _ in range(m)]
ans =0
for i in range(n-m+1):
  for j in range(n-m+1):
    if [a[j:j+m] for a in a[i:i+m]]==b:
      ans =1
print('Yes' if ans ==1 else 'No')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

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

  int n; cin >> n;
  vector<ll> a(n), b(n);
  ll tmp = 0;
  rep(i, n) {
    cin >> a[i];
    tmp -= a[i];
  }
  rep(i, n) {
    cin >> b[i];
    tmp += b[i];
  }

  ll sumA = 0, sumB = 0;
  rep(i, n) {
    ll dif = b[i]-a[i];

    if(dif > 0) sumB += (dif+1)/2;
    else sumA += -dif;
  }

  string ans = "Yes";
  if(sumA > tmp || sumB > tmp) ans = "No";
  cout << ans << '\n';
  return 0;
}


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

int main(void) {
	int a, b, c,flag=0;
	cin >> a >> b >> c;
	for (int n = 0; n < b; n++) {
		if (((a*n)%b) == c) {
			flag = 1;
			break;
		}
	}
	if (flag == 1)
		cout << "YES" << endl;
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll h, w;
	cin >> h >> w;
	vector<string> grid(h);
	for (ll i = 0; i < h; i++) cin >> grid[i];

	bool flag = true;
	for (ll i = 0; i < h - 1; i++) {
		for (ll j = 0; j < w - 1; j++) {
			if (grid[i][j] == '.') continue;
			if ((grid[i + 1][j] ^ grid[i][j + 1]) == 0) flag = false;
		}
	}
	for (ll i = 0; i < h - 1; i++) {
		ll j = w - 1;
		if (grid[i][j] == '#' && grid[i + 1][j] == '.') flag = false;
	}
	for (ll j = 0; j < w - 1; j++) {
		ll i = h - 1;
		if (grid[i][j] == '#' && grid[i][j + 1] == '.') flag = false;
	}

	for (ll i = 1; i < h; i++) {
		for (ll j = 1; j < w; j++) {
			if (grid[i][j] == '.') continue;
			if ((grid[i - 1][j] ^ grid[i][j - 1]) == 0) flag = false;
		}
	}
	for (ll i = 1; i < h; i++) {
		ll j = 0;
		if (grid[i][j] == '#' && grid[i - 1][j] == '.') flag = false;
	}
	for (ll j = 1; j < w; j++) {
		ll i = 0;
		if (grid[i][j] == '#' && grid[i][j - 1] == '.') flag = false;
	}

	if (flag) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
import math
import fractions
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))




def lcm(x, y):
    return (x * y)//fractions.gcd(x, y)


a,b=input2()

print(lcm(a,b))


Measured memory_bytes: 5076
package main

import "fmt"

const size = 100001

func main() {
    var n, t int
    var l, r int
    var mem [size]int
    fmt.Scan(&n)
    fmt.Scan(&t)
    for i := 0; i < n; i++ {
        fmt.Scan(&l)
        fmt.Scan(&r)
        mem[l] += 1
        mem[r] -= 1
    }
    ans := mem[0]
    for i := 1; i < t + 1; i++ {
        mem[i] += mem[i - 1]
        if ans < mem[i] {
            ans = mem[i]
        }
    }
    fmt.Println(ans)
}



Measured memory_bytes: 6760
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  cout << max({a,b,c})-min({a,b,c}) << endl;
}

Measured memory_bytes: 3564
n, c, k = list(map(int, input().split()))
t = []

for i in range(n):
    t.append(int(input()))

t = sorted(t)

cnt = 1
cap = 1
first = t[0]

for i in range(1, n):
    if t[i] > first + k:
        cnt += 1
        cap = 1
        first = t[i]
    elif cap == c:
        cnt += 1
        cap = 1
        first = t[i]
    else:
        cap += 1

print(cnt)

Measured memory_bytes: 14024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

bool debug=false;
/*---------------------------------------------------*/

int main(){
    int a,b,sum,keta;
    while(cin>>a>>b){
        sum=a+b;
        for(keta=1;;keta++){
            sum=sum/10;
            if(sum==0)break;
        }
        cout<<keta<<endl;
    }
    return 0;
}

Measured memory_bytes: 3076
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static int N;

        static void Main(string[] args)
        {
            //[summary]C - Average Length
            N = int.Parse(Console.ReadLine());

            var towns = GetTowns().ToList();

            var lib = new Library.Combination();
            var combis = lib.AllCombinations<Coordinate>(towns, N, true).ToList();

            double total = 0;

            foreach (var c in combis)
            {
                total += CalcDistance(c);
            }

            var ave = total / combis.Count();
            Console.WriteLine(ave);
        }

        static double CalcDistance(List<Coordinate> c)
        {
            double sum = 0;

            for (int i = 1; i < N; i++)
            {
                int xi = c[i].x;
                int xj = c[i - 1].x;
                int yi = c[i].y;
                int yj = c[i - 1].y;

                var d = Math.Pow(xi - xj, 2) + Math.Pow(yi - yj, 2);
                sum += Math.Sqrt(d);
            }

            return sum;
        }

        static IEnumerable<Coordinate> GetTowns()
        {
            for (int i = 0; i < N; i++)
            {
                var arr = Console.ReadLine().Split(' ');
                int x = int.Parse(arr[0]);
                int y = int.Parse(arr[1]);

                yield return new Coordinate(x, y);
            }
        }
    }

    struct Coordinate
    {
        public int x;
        public int y;

        public Coordinate(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
    }
}

namespace Library
{
    class Combination
    {
        public IEnumerable<List<T>> AllCombinations<T>(List<T> source, int n,
                                                       bool isAllowDupication = false)
        {
            //[summary]異なる要素から、n個を選ぶ組み合わせを列挙する
            //"isAllowDupication"を"true"にすると、重複を許可する
            //(重複を許可して、nを要素数と同じにすると、順列を列挙する)

            if (n == 1)
            {
                foreach (var s in source)
                {
                    yield return new List<T> { s };
                }

                yield break;
            }
            else
            {
                for (int i = 0; i < source.Count; i++)
                {
                    List<T> clone;

                    if (isAllowDupication)
                    {
                        //重複を許可する場合は、その要素のみを削除
                        clone = new List<T>(source);
                        clone.RemoveAt(i);
                    }
                    else
                    {
                        //重複を許可しない場合は、自分よりも前の要素はすべて削除
                        clone = new List<T>(source.Skip(i + 1));
                    }

                    //再帰処理
                    var items = AllCombinations(clone, n - 1, isAllowDupication);

                    foreach (var item in items)
                    {
                        item.Insert(0, source[i]);
                        yield return item;
                    }
                }
            }
        }
    }
}


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

using ll = long long;

using namespace std;

//0 -> a-1
#define rep(i, a) for (int i = 0; (i) < (int)(a); (i)++)
//a -> b-1
#define reps(i, a, b) for (int i = (int)(a); (i) < (int)(b); (i)++)
//a-1 -> 0
#define rrep(i, a) for (int i = (int)a - 1; (i) >= 0; (i)--)
//a-1 -> b
#define rreps(i, a, b) for (int i = (int)(a)-1; (i) >= (int)(b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
//next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
(v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v) \
	sort(all(v)); \
	(v).erase(unique(all(v)), v.end())
#define CIN(type, x) \
	type x;          \
	cin >> x
#define YES(f) if ((f)) {cout << "YES" << endl;} else {cout << "NO" << endl;}
#define Yes(f) if ((f)) {cout << "Yes" << endl;} else {cout << "No" << endl;}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
//b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
//c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(12)
#define RS resize
#define CINV(v, N)             \
	do                         \
	{                          \
		v.RS(N);               \
		rep(i, N) cin >> v[i]; \
	} while (0);

#define RCINV(v, N)             \
	do                          \
	{                           \
		v.RS(N);                \
		rrep(i, N) cin >> v[i]; \
	} while (0);
#define MOD 1000000007

template <class T>
inline T GET()
{
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

ll dp[500][500];
vector<int> a;

ll dfs(int l, int r)
{
	ll& res = dp[l][r];
	if (res != -1) return res;
	res = 0;
	reps(i, l, r) res += a[i];
	ll mi = LLONG_MAX;
	reps(i, l+1, r) {
		chmin(mi, dfs(l, i) + dfs(i, r));
	}
	res += mi;
	return res;
}

void init()
{
	int N;
	cin >> N;
	a.RS(N);
	rep(i, N) cin >> a[i];
	rep(i, 500) rep(j, 500) {
		dp[i][j] = -1;
		if (j - i == 1) dp[i][j] = 0;
	}
	cout << dfs(0, N) << endl;
}

void solve()
{
}


Measured memory_bytes: 2304
from collections import defaultdict
from heapq import heappush, heappop

N, M = map(int, input().split())
d = defaultdict(list)
q = []

for _ in range(N):
    a, b = map(int, input().split())
    d[a].append(b)

ans = 0
for i in range(1, M+1):
    for j in d[i]:
        heappush(q, -j)
    if q:
        ans += heappop(q)*-1

print(ans)


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

int main(){
  int count=0;
  long N,K,Q;
  cin>>N>>K>>Q;
  vector<long>a(N,Q*-1);
  rep(i,Q){
    int b;
    cin>>b;
    a[b-1]++;
  }
  rep(i,N){
    if(a[i]+K>0){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
}


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

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back

using namespace std;

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

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }
inline int read ()
{
	int sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

const int Maxn = 400 + 10, Maxm = 1e5 + 100;

int N, M;
pii A[Maxm];

inline void Input ()
{
	N = read(), M = read();
	for (int i = 1; i <= M; ++i) A[i].x = read(), A[i].y = read();
}

bitset <Maxn> Vis[Maxn];
int Die[Maxn];

inline void Solve ()
{
	for (int i = 1; i <= N; ++i)
	{
		Vis[i][i] = 1;
		for (int j = M; j >= 1; --j)
		{
			int x = A[j].x, y = A[j].y;
			if (Vis[i][x] && Vis[i][y])
			{
				Die[i] = 1;
				break;
			}
			if (Vis[i][x] || Vis[i][y]) Vis[i][x] = Vis[i][y] = 1;
		}
	}
	int ans = 0;
	for (int i = 1; i <= N; ++i)
		if (!Die[i])
			for (int j = i + 1; j <= N; ++j)
				if (!Die[j])
				{
					if (!(Vis[i] & Vis[j]).count())
						++ans;
				}
	cout<<ans<<endl;
}

int main()
{
	Input();
	Solve();
	return 0;
}


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

int main()
{
    long long int a, b;
    cin >> a >> b;
    long long int begin = a % 2 ? a + 1 : a, end = b % 2 ? b : b - 1;
    long long int ans = (a % 2 ? a : 0) ^ ((end - begin + 1) / 2 % 2) ^ (b % 2 ? 0 : b);
    cout << ans << endl;
    return 0;
}


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

using namespace std;


int main()
{
    unsigned long long n;
    cin >> n;
    int a, b;
    a = (n-1) % 26;
    b = n / 26;
    string tmp = "";
    while(n > 0) {
        n--;
        tmp += 'a' + n % 26;
        n /= 26;
    }
    string ans = "";
    for (int i = tmp.size() - 1; i >= 0 ; i--) {
        ans += tmp[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
import java.util.*;
import java.io.*;
import java.math.BigDecimal; 
import java.math.BigInteger; 
class Main
{
	static boolean visited[];
	static long dp[][][];
	static long MOD=1000000007L;
	static Hashtable<String , Long>hash=new Hashtable<>();
	public static void main(String args[]) throws java.lang.Exception
	{
		BufferedReader inp = new BufferedReader (new InputStreamReader(System.in));
			// String h[]=inp.readLine().split(" ");
			// String h[]=inp.readLine().split(" ");
		// int n=Integer.parseInt(inp.readLine());

int flag=0;
			String h[]=inp.readLine().split(" ");
			BigDecimal a=new BigDecimal(h[0]);
			// BigInteger max=new BigInteger("1000000000000000000");
			BigDecimal b=new BigDecimal(h[1]);
			a=a.multiply(b);
			System.out.println(a.toBigInteger());
	}
	static int[] gg(String aa)
	{
		int a[]=new int[aa.length()];
		for(int i=0;i<aa.length();i++)
		{
			a[i]=(int)aa.charAt(i)-(int)'0';
		}
		return a;
	}
	static long get(int a[], int d, int sum, int tight, int i)
	{
		if(i==a.length){if(sum%d==0 && sum!=0){return 1;}return 0;}
		// if(dp[i][sum][tight]!=-1){return dp[i][sum][tight];}
		String s=i+" "+sum+" "+tight;
		if(hash.containsKey(i+" "+sum+" "+tight) && tight!=1){return hash.get(i+" "+sum+" "+tight);}
		long ans=0;
		
		int limit=(tight==0?9:a[i]);
			for(int j=0;j<=limit;j++)
			{
				int newt=(a[i]==j?tight:0);

				ans=(ans%MOD+get(a,d,sum+j,newt,i+1)%MOD)%MOD;
			}
			// dp[i][sum%d][tight]=ans;
			hash.put(s,ans);
			return ans;	
	}


	
	static long bfs(int src, ArrayList<ArrayList<Integer>>arr)
	{
		Queue<Pair>q=new LinkedList<>();
		q.add(new Pair(src,1,1));
		visited[src]=true;
		long ans=0;
		while(q.size()!=0)
		{
			ans=0;
			int size=q.size();
			for(int j=0;j<size;j++)
			{
				Pair t=q.poll();
				ans=(ans%MOD+(t.b%MOD+t.c%MOD)%MOD)%MOD;
				for(Integer node:arr.get(t.a))
				{
					if(!visited[node])
					{
						visited[node]=true;
						q.add(new Pair(node,t.b+t.c,t.b));
					}
				}
			}
		}
		return ans%MOD;
	}
}
class Pair
{
	int a;
	long b;
	long c;
	Pair(int e, long f, long h)
	{
		a=e;
		b=f;
		c=h;
	}
}

Measured memory_bytes: 33200
Scanf.scanf "%d" (fun n ->
    let a = Array.make n 0 in
    let b = Array.make n 0 in
    for i = 0 to n - 1 do
        Scanf.scanf " %d %d" (fun aa bb -> a.(i) <- aa; b.(i) <- -bb)
    done;
    Array.sort compare a;
    Array.sort compare b;

    let mi = a.((n - 1) / 2) + a.(n / 2) in
    let mx = b.((n - 1) / 2) + b.(n / 2) in

    Printf.printf "%d\n" @@ if n mod 2 = 0 then -mx - mi + 1 else (-mx - mi) / 2 + 1
)

Measured memory_bytes: 9192
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 8;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int x; cin >> x;
    for(int i = 0; i < 8; ++i) {
        if(x < 600 + 200 * i) {
            cout << 8 - i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3592
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

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

int64 min(int64 lhs, int64 rhs){ return rhs<lhs ? rhs:lhs; }

int main(){
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    
    int N, X; cin >> N >> X;
    
    vector<int> vX(N);
    for(int i=0; i<N; ++i){ cin >> vX[i]; }
    
    if(N==1){ cout << abs(vX[0]-X) << endl; return 0; }

    vX.push_back(X);
    sort(vX.begin(), vX.end());
    
    int64 gcd_val=gcd(vX[1]-vX[0], vX[2]-vX[1]);
    for(int i=3; i<N; ++i){
        gcd_val = gcd(vX[i]-vX[i-1], gcd_val);
    }
    cout << gcd_val << endl;
    
    return 0;
}

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

#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<30)
#define INFLL (1<<62LL)

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int N;
  vector<int> A;
  cin >> N;

  A.resize(N);
  rep(i, N) cin >> A[i];

  ll ans = 0;
  rep(i, N) {
    ll pat = 1;
    rep(j, N) {
      if (j < i && A[j] % 2 == 0) pat *= 2;
      if (i == j && A[j] % 2 != 0) pat *= 2;
      if (j > i) pat *= 3;
    }
    ans += pat;
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
  int a, cnt5, cnt7;
  cnt5 = cnt7 = 0;
  for(int i = 0; i < 3; i++){
    cin >> a;
    if(a == 5) cnt5++;
    else if(a == 7) cnt7++;
  }
  if(cnt5 == 2 && cnt7 == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
from bisect import insort, bisect_left
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

ans = 10**12
flg = False


def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = []
    ca, cb = [], []
    for i in range(n):
        c.append(b[i] - a[i])
        if b[i] - a[i] > 0:
            ca.append(b[i] - a[i])
        elif b[i] - a[i] < 0:
            cb.append(-b[i] + a[i])
    if len(ca) == n:
        print(0)
        exit()

    cb = sorted(cb, reverse=True)
    ans = 0
    casum = sum(ca)
    #print(c, ca, cb)
    for i in range(1, len(cb)+1):
        if casum <= 0:
            break
        casum -= cb[i - 1]
        ans += 1
    if casum > 0:
        print(-1)
        exit()
    print(ans + len(ca))


if __name__ == '__main__':
    main()


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

int main(){
	int i;
	int result=0;
	string S;
	
	cin>>S;
	
	for(i=0;i<4;i++){
		if(S[i]=='+')result+=1;
		if(S[i]=='-')result-=1;
	}
	cout<<result<<endl;
}


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

#define Int long long int
#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()

int main(){
    Int n;
    cin >> n;
    cout << n/3 << endl;
}


Measured memory_bytes: 768
#include<stdio.h>

long long fibo(int n){
	long long fibodp[200]={1,1};

	for(int i=2; i<=n; i++){
		fibodp[i]=fibodp[i-1]+fibodp[i-2];
	}
	return fibodp[n];
}

int main(void){
	int n;
	scanf("%d",&n);
	printf("%lld\n",fibo(n));

return(0);
}




Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define N 100005
using namespace std;
long long n, i, j, k, a[N], l, t, r, m, p, b[N];
main(){
    cin>>n;
    for(i=0;i<n;i++)cin>>a[i]>>b[i];
    for(i=n-1;i>=0;i--){
        a[i]+=t;
        if(a[i]%b[i]==0)continue;
        t+=(b[i]-a[i]%b[i]);
    }
    cout<<t<<endl;
}

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

int main()
{
    int A,B,K;
    cin >> A >> B >> K;

    int c = 0;
    for(int i=min(A,B);i>=0;i--){
        if(A%i==0 && B%i==0) c++;
        if(c==K){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

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

ll ans=0;

ll mypow(ll a,ll b){
	ll num=1;
	while(b!=0){
		b--;
		num*=a;
	}
	return num;
}

ll keta(ll a){
	ll num=0;
	while(a!=0){
		a/=10;
		num++;
	}
	return num;
}

void dfs(ll s,ll num,vector<bool> &BO){
	if(num==keta(s)){
		ll prt=0,prtsum=0;
		BO[keta(s)-1]=true;//sentinel
		
		rep(i,keta(s)){
			if(BO[i]){
				prt=prt*10+(s/mypow(10,keta(s)-i-1))%10;
				prtsum+=prt;
				prt=0;
			}else{
				prt=prt*10+(s/mypow(10,keta(s)-i-1))%10;
			}
		}

		ans+=prtsum;
		return;
	}

	BO[num]=true;
	dfs(s,num+1,BO);

	BO[num]=false;
	dfs(s,num+1,BO);

	return;
} 

int main(){
	ll s;cin>>s;
	vector<bool> BO(keta(s),false);

	dfs(s,0,BO);

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int N;
ll K;
vector<ll>A, F;

ll calc(ll A,ll F,ll mid){
	ll mi = mid / F;
	return max(0LL,A-mi);
}

int check(ll mid){
	ll sum = 0;
	for (int i = 0; i < N; i++)sum += calc(A[i],F[i],mid);
	return sum <= K;
}

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

	cin >> N >> K;
	A.resize(N);
	F.resize(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	for (int i = 0; i < N; i++)cin >> F[i];
	sort(all(A));
	reverse(all(A));
	sort(all(F));


	ll ng = -1, ok = inf;
	while (ok - ng > 1) {
		ll mid = (ok + ng)/2;
		if (check(mid))ok = mid;
		else ng = mid;
	}
	puts(ok);
	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define LL long long 
#define MAXN 100005
#define INF 0x3f3f3f3f
using namespace std;

int n, ans, f[MAXN];
bool flag;
int n6[100], n9[100];


int main()
{
	memset(f, 0x3f, sizeof(f));
	scanf("%d", &n);
	for(int i=0; i<=7; i++) n6[i]=n9[i]=1;
	for(int i=0; i<=7; i++)
	{
		for(int j=1; j<=i; j++) n6[i]*=6;
		for(int j=1; j<=i; j++) n9[i]*=9;
	}
	f[0]=0;
	for(int i=0; i<=n; i++)
	{
		for(int j=0; j<=7; j++)
		{
			if(i+n6[j]<=n) f[i+n6[j]]=min(f[i+n6[j]], f[i]+1);
			if(i+n9[j]<=n) f[i+n9[j]]=min(f[i+n9[j]], f[i]+1);
		}
	}
	printf("%d\n", f[n]);
}
 

Measured memory_bytes: 640
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	#b , c = tin()
	s = input()
	key = 'keyence'
	for i in range(len(key)+1):
		if -len(key)+i < 0:
			ts=s[:i]+s[-len(key)+i:]
		else:
			ts = s[:i]
		pa(ts)
		if ts == key:
			return 'YES'
	return 'NO'
			
	
	
#+++++
isTest=False
def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
var input = ""
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
 
process.stdin.on('end', function() {
  input = input.split("\n");
  i = 0;
  var r = input[i].split(" ")[0];
  var c = input[i].split(" ")[1];

  var sum = new Array(c);
  for (j = 0; j < c; j++) {
    sum[j]  = 0;
  }
  var total_all = 0;

  for (i = 1; i <= r; i++) {
    var arr = input[i].split(" ");
    var total = 0;
    for (j = 0; j < c; j++) {
      n = parseInt(arr[j], 10);
      total += n;
      sum[j] += n;
      total_all += n;
    }
    arr.push(total);
    console.log(arr.join(" "));
  }
  sum.push(total_all);
  console.log(sum.join(" "));
});

Measured memory_bytes: 9328
#include<stdio.h>
    #include<iostream>
    #include<vector>
    #include<algorithm>
    #include<math.h>
    #define rep(i,a) for(int i=0;i<a;i++)
    #define nrep(i,a,b) for(int i=a;i<b;i++)
    #define INF 1145141919810
    #define ll long long
    using namespace std;
     
    int main(){
        ll n; cin>>n;
        vector<ll> a(n);
        rep(i,n) cin>>a[i];
        ll sum=0;
        ll ans_1=0;
        ll ans_2=0;
        bool plus=true;
        rep(i,n){
            sum+=a[i];
            if(plus){
                if(sum>=0){
                    ans_1+=abs(sum)+1;
                    sum=-1;
                }
            }else{
                if(sum<=0){
                    ans_1+=abs(sum)+1;
                    sum=1;
                }
            }plus=!plus;
        }plus=false;
        sum=0;
        rep(i,n){
            sum+=a[i];
            if(plus){
                if(sum>=0){
                    ans_2+=abs(sum)+1;
                    sum=-1;
                }
            }else{
                if(sum<=0){
                    ans_2+=abs(sum)+1;
                    sum=1;
                }
            }plus=!plus;
        }
        cout<<min(ans_1,ans_2)<<endl;
        return 0;
    }

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

public class Main {
	static public void main(String[] argv) {
		try{
//			FileReader file_in = new FileReader("test.txt");
//			BufferedReader d = new BufferedReader( file_in );
			BufferedReader d = new BufferedReader(new InputStreamReader(System.in));
	
			while(true) {
				String buf = d.readLine();
				
				int num = Integer.valueOf(buf);
				if( num == 0 ) break;
				
				int res_a = 0;
				int res_b = 0;
				
				for(int i = 0; i < num; i++) {
					buf = d.readLine();
					StringTokenizer st = new StringTokenizer(buf);
					
					int cur_a = Integer.valueOf(st.nextToken());
					int cur_b = Integer.valueOf(st.nextToken());
					
					if( cur_a > cur_b ) {
						res_a += cur_a;
						res_a += cur_b;
					} else if( cur_a == cur_b ) {
						res_a += cur_a;
						res_b += cur_b;
					} else {
						res_b += cur_a;
						res_b += cur_b;
					}
				}
				
				System.out.println(res_a + " " + res_b);
			}
			
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
}

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

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

int main(){
    long long int a,b;
    cin >> a >> b;
    long long int g = gcd(a,b);
    cout << a * b / g << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
   public static void main(String[] args) {
	  Scanner sc =new Scanner(System.in);
while(sc.hasNext()){
int n=sc.nextInt();
int count =0;
for(int i=0; i<10; i++){
	for(int j=0; j<10; j++){
		for(int k=0; k<10; k++){
			for(int l=0; l<10; l++){
				if(i+j+l+k==n) count++;
			}
			}
        	}
            }
System.out.println(count);
	
}
   }
   }

Measured memory_bytes: 18848
/*---> 04 April 2020 <--- > 01:37:04 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#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__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=2e3+5;
vi adj[N];
int n,x,y,cnt[N];
void bfs(int sr){
	queue<int> q;
	q.push(sr);
	vector<int> dist(n+1,10000);
	dist[sr]=0;
	while(!q.empty()){
		int cur=q.front();
		q.pop();
		cnt[dist[cur]]++;
		for(int v:adj[cur]){
			if(dist[v]==10000){
				dist[v]=dist[cur]+1;
				q.push(v);
			}
		}
	}
}	
int32_t main(){__
	// int n,x,y;
	cin>>n>>x>>y;
	for(int i=1;i<=n-1;i++){
		adj[i].push_back(i+1);
		adj[i+1].push_back(i);
	}
	if(x>y)
		swap(x,y);
	if(x+1!=y){
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	for(int i=1;i<=n;i++){
		bfs(i);
	}
	for(int i=1;i<=n-1;i++)
		cout<<cnt[i]/2<<"\n";
	// cout<<"\n";
return 0;
}

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

#define ll long long

int dp[3003][3003];
string s, t;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/

	cin >> s >> t;
	//memset (dp, -1, sizeof dp);
	int n = s.length(), m = t.length();
	dp[0][0] = dp[0][1] = dp[1][0] = 0;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (s[i - 1] == t[j - 1]) {
				dp[i][j] = 1 + dp[i - 1][j - 1];
			}
			else {
				dp[i][j] = max (dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}

	int len = dp[n][m], len_ptr = len - 1, i = n, j = m;
	//cout << len_ptr << "\n";

	/*if (len == 0) {
		cout << "" ;
		return 0;
	}*/
	//string ans = "";
	char ans[len + 1];
	ans[len] = '\0';

	while (i != 0 && j != 0) {
		if (s[i - 1] == t[j - 1]) {
			ans[len_ptr] = s[i - 1];
			//cout << s[i - 1];
			//ans.push_back(s[i]);
			i--; j--; len_ptr--;
		}
		else {
			/*if (i == 0) {
				j--;
				continue;
			}
			if (j == 0) {
				i--;
				continue;
			}*/
			if (dp[i - 1][j] >= dp[i][j - 1]) {
				i--;
			}
			else {
				j--;
			}
		}
	}

	//reverse (ans.begin(), ans.end());
	cout << ans;

	return 0;
}

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

int main(){
    long long A,B,N,wa,ans,j;
    cin >> N >> A >> B;

    wa = A + B;
    
    j = N /wa;


    wa = wa * j;
    ans = A * j;

    if(wa + A <= N){
        ans += A;
    }else if(wa + A > N){
        ans += N - wa; 
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
from collections import defaultdict
from bisect import bisect_left, bisect_right, insort_left, insort_right
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    S = list(input())
    q = int(input())
    Q = [input() for _ in range(q)]

    dd = defaultdict(list)  # 各アルファベットが出現するインデックスをddに登録
    for i in range(ord('a'), ord('z') + 1):
        dd[chr(i)] = []
    for i, st in enumerate(S):
        dd[st].append(i)

    ans = []
    for q in Q:
        t, a, b = q.split()
        a = int(a) - 1
        if int(t) == 1:
            if S[a] == b: continue
            # 二分探索で該当するインデックスを取得
            id = bisect_left(dd[S[a]], a)
            dd[S[a]].pop(id)  # 取ってくる
            insort_left(dd[b], a)  # 新規に挿入する
            S[a] = b
        else:
            b = int(b) - 1
            cnt = 0
            for l in dd.values():
                # liの中身が存在し，
                # そのアルファベットの最後のインデックスが指定されている最初のindexよりも大きく．
                # a以上の最初のindexがb以下の時は，そのアルファベットの存在は保証される
                if l and a <= l[-1] and l[bisect_left(l, a)] <= b:
                    cnt += 1
            ans.append(cnt)
    print(*ans, sep='\n')

if __name__ == '__main__':
    main()

Measured memory_bytes: 31004
#include <iostream>

using namespace std;

int nC2(int n)
{
	return (n*(n-1)/2);
}

int main()
{
	int n, m, even = 0, odd = 0, total;
	cin>>n>>m;
	if(n > 1)
		even = nC2(n);
	if(m>1)
		odd = nC2(m);
	total = even + odd;
	cout<<total<<endl;
}

Measured memory_bytes: 256
n=int(input())
r=[list(map(int,input().split())) for _ in range(n)]
a,c,b,d=0,10**10,0,10**10
for i in range(n):
    y,x=r[i]
    a=max(a,x+y)
    c=min(c,x+y)
    b=max(b,x-y)
    d=min(d,x-y)
print(max(abs(a-c),abs(b-d)))

Measured memory_bytes: 45316
#include <stdio.h>

int main(){

  int h,i,j,k,minj,N,cnt=0;

  scanf("%d",&N);
  int A[N];

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

  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[j]<A[minj]){
	minj=j;
      } 
    }
    if(minj!=i){
      h=A[i];
      A[i]=A[minj];
      A[minj]=h;
      cnt++;
    }
  }

  printf("%d",A[0]);
  for(k=1;k<N;k++){
    printf(" %d",A[k]);
  }
  printf("\n%d\n",cnt);

  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,A,B; cin>>N;
    if(N==1){
        cout<<"Hello World"<<endl;
    }else{
        cin>>A>>B;
        cout<<A+B<<endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
int main() {
	int x,y;

	cin >> x >> y;

	if ((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12)&& (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)) {
		cout << "Yes";

	}
	else if((x==4||x==6||x==9||x==11)&&( y == 4 || y == 6 || y == 9 || y == 11)) {
		cout << "Yes";


	}
	else if (x == 2 && y == 2) {

		cout << "Yes";
	}
	else {

		cout << "No";
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int main(){
    string s, t;
    cin >> s >> t;
    cout << t + s << endl;

    return 0;
}


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

#define int long long
const int N = 2e5+5, INF = 1e18;
int n, a[N], pref[N], ans = INF;

int sum(int l, int r)
{
    return pref[r] - pref[l-1];
}
signed main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        pref[i] = pref[i-1] + a[i];
    }
    for (int i = 3; i <= n-1; i++)
    {
        //if (i != 5) continue;
        int pos1, pos2, ans1 = INF, ans2 = INF;

        int l = 1, r = i-1;
        while(l < r)
        {
            int mid = (l+r)/2;
            int tmp = 2*sum(1,mid) - sum(1,i-1);
            if (abs(tmp) < ans1)
            {
                ans1 = abs(tmp);
                pos1 = mid;
            }
            if (tmp < 0)
                l = mid+1;
            else
                r = mid;
        }
        l = i, r = n;
        while(l < r)
        {
            int mid = (l+r)/2;
            int tmp = 2*sum(i,mid) - sum(i,n);
            //cout << mid << ' ' << tmp << endl;
            if (abs(tmp) < ans2)
            {
                ans2 = abs(tmp);
                pos2 = mid;
            }
            if (tmp < 0)
                l = mid+1;
            else
                r = mid;
        }
        int sum1 = sum(1,pos1), sum2 = sum(pos1+1,i-1), sum3 = sum(i,pos2), sum4 = sum(pos2+1,n);
        //cout << pos1 << ' ' << i << ' ' << pos2 << endl;
        //cout << sum1 << ' ' << sum2 << ' ' << sum3 << ' ' << sum4 << endl;
        ans = min(ans,max(sum1,max(sum2,max(sum3,sum4))) - min(sum1,min(sum2,min(sum3,sum4))) );
    }
    cout << ans;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n;
    cin >> n;
    int a[100], v[10] = {0}, count = 0;
    rep(i, n){
        cin >> a[i];
        if(a[i] < 3200){
            v[(a[i])/400]++;
        }
        else{
            count++;
        }
    }
    int min = 0, max;
    rep(i, 8){
        if(v[i] > 0){
            min++;
        }
    }
    max = min + count;
    if(min == 0){
        min = 1;
    }
    cout << min << " " << max;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-12;

struct Anchor{
  int x,y,l;
  Anchor(int _x,int _y,int _l)
    : x(_x), y(_y), l(_l) {}
};

double check(const vector<Anchor>& anchors,
	     double x,double y){

  double res = 100000000.0;
  for(int anchor_idx=0;anchor_idx<anchors.size();anchor_idx++){
    double bottom_line
      = (double)(anchors[anchor_idx].x - x) * (double)(anchors[anchor_idx].x - x)
      + (double)(anchors[anchor_idx].y - y) * (double)(anchors[anchor_idx].y - y);
    double capacity = anchors[anchor_idx].l * anchors[anchor_idx].l;
    res = min(res,capacity - bottom_line);
  }
  return res;
}

double search(const vector<Anchor>& anchors,
	      const double x,double left, double right)
{
  for (int round = 0; round < 100; round++){
    if (check(anchors,x,(left * 2 + right) / 3)
	> check(anchors,x,(left + right * 2) / 3)){
      right = (left + right * 2) / 3;
    } else {
      left = (left * 2 + right) / 3;
    }
  }
  return check(anchors,x,(right + left) * 0.5);
}

int main(){
  int total_anchors;
  while(~scanf("%d",&total_anchors)){
    if(total_anchors == 0) break;

    vector<Anchor> anchors;
    for(int anchor_idx=0;anchor_idx<total_anchors;anchor_idx++){
      int x,y,l;
      scanf("%d %d %d",&x,&y,&l);
      anchors.push_back(Anchor(x,y,l));
    }

    double left = -100.0;
    double right = 100.0;
    for(int round = 0;round < 100; round++){
      if (search(anchors,(left * 2 + right) / 3,-100.0,100.0)
	  > search(anchors,(left + right * 2) / 3,-100.0,100.0)){
	right = (left + right * 2) / 3;
      } else {
	left = (left * 2 + right) / 3;
      }
    }
    double res = search(anchors,right,-100,100.0);
    printf("%.7lf\n",sqrt(res));
  }
}

Measured memory_bytes: 1228
#define _GLIBCXX_DEBUG // 配列エラー
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
// typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;

int64_t H, W, N; // N = min((unsigned int)100000, H*W);
map<unsigned int, map<unsigned int, int>>box;
vector<int64_t>cnt(10, 0);

void printAnswer(vector<int64_t> &v);

void incDec(int decNum);
void changeCnt(unsigned int hPos, unsigned int wPos);
void check(unsigned int hPos, unsigned int wPos);

int main() {
  cin >> H >> W >> N;

  cnt.at(0) = (H - 2)*(W - 2);

  for(unsigned int i = 0; i < N; i++) {
    unsigned int hPos, wPos;
    cin >> hPos >> wPos;

    check(hPos, wPos);
  }
  printAnswer(cnt);
}


void printAnswer(vector<int64_t> &v) {
  for(int i = 0; i < (int)v.size(); i++) {
    cout << v.at(i) << endl;
  }
}

void incDec(int decNum) {
  cnt.at(decNum) -= 1;
  cnt.at(decNum+1) += 1;
}

void changeCnt(unsigned int hP, unsigned int wP) {
  if(!(box.count(hP) > 0)) {
    box[hP][wP] = 1;
    incDec(0);
  } else {
    if(box.at(hP).count(wP) > 0) {
      incDec( box.at(hP).at(wP)); // 現在のやつのカウント変更
      box.at(hP).at(wP)++;
    } else {
      box.at(hP).emplace(wP, 1);
      incDec(0);
    }
  }
}

void check(unsigned int hPos, unsigned int wPos) {
  for(int i = -1; i <= 1; i++) { // 上下左右
    for(int j = -1; j <= 1; j++) {
      if(hPos+i < 2 || hPos+i > H-1) {break;}
      if(wPos+j < 2 || wPos+j > W-1) {continue;}
      changeCnt(hPos+i, wPos+j);
    }
  }
}


Measured memory_bytes: 79872
#include <bits/stdc++.h>
using namespace std;
string s;
int ans;
int main()
{
	cin >>s;
	ans=s.size();
	for(int i=0;i<s.size()-1;i++)
	if(s[i]!=s[i+1])
	ans=min(ans,max(i+1,(int)s.size()-i-1));
	cout <<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
N,A,B = map(int,input().split())
S = input()

ans = ['No'] * N
p = b = 0
for i,c in enumerate(S):
    if c == 'a':
        if p < A+B:
            ans[i] = 'Yes'
            p += 1
    elif c == 'b':
        if p < A+B and b < B:
            ans[i] = 'Yes'
            p += 1
            b += 1
print(*ans,sep='\n')

Measured memory_bytes: 6344