akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define fi(i,start,end) for(int i=start; i<end; ++i)
#define fd(i,end,start) for(int i=end-1; i>=start; --i)
#define pb push_back
#define mz(a) memset(a,0,sizeof(a))
#define nl cout<<endl;
#define ip(n) cin>>n;
#define op(n) cout<<n;
#define FT() int t; cin>>t; while(t--)
#define inparr fi(i,0,n) ip(a[i]);
#define dispar fi(i,0,n) op(a[i]); nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
const int MAX = 1000001; 
  
// array to store prime factors 
int factor[MAX] = { 0 }; 
  
// function to generate all prime factors 
// of numbers from 1 to 10^6 
void generatePrimeFactors() 
{ 
    factor[1] = 1; 
  
    // Initializes all the positions with their value. 
    for (int i = 2; i < MAX; i++) 
        factor[i] = i; 
  
    // Initializes all multiples of 2 with 2 
    for (int i = 4; i < MAX; i += 2) 
        factor[i] = 2; 
  
    // A modified version of Sieve of Eratosthenes to 
    // store the smallest prime factor that divides 
    // every number. 
    for (int i = 3; i * i < MAX; i++) { 
        // check if it has no prime factor. 
        if (factor[i] == i) { 
            // Initializes of j starting from i*i 
            for (int j = i * i; j < MAX; j += i) { 
                // if it has no prime factor before, then 
                // stores the smallest prime divisor 
                if (factor[j] == j) 
                    factor[j] = i; 
            } 
        } 
    } 
} 
  
// function to calculate number of factors 
int calculateNoOFactors(int n) 
{ 
    if (n == 1) 
        return 1; 
  
    int ans = 1; 
  
    // stores the smallest prime number 
    // that divides n 
    int dup = factor[n]; 
  
    // stores the count of number of times 
    // a prime number divides n. 
    int c = 1; 
  
    // reduces to the next number after prime 
    // factorization of n 
    int j = n / factor[n]; 
  
    // false when prime factorization is done 
    while (j != 1) { 
        // if the same prime number is dividing n, 
        // then we increase the count 
        if (factor[j] == dup) 
            c += 1; 
  
        /* if its a new prime factor that is factorizing n,  
           then we again set c=1 and change dup to the new  
           prime factor, and apply the formula explained  
           above. */
        else { 
            dup = factor[j]; 
            ans = ans * (c + 1); 
            c = 1; 
        } 
  
        // prime factorizes a number 
        j = j / factor[j]; 
    } 
  
    // for the last prime factor 
    ans = ans * (c + 1); 
  
    return ans; 
} 

void solve()
{
  	int n;
	cin>>n;
	ll ans = 0;
	generatePrimeFactors(); 
	for(ll i=1; i<n; i++)
	{
		ll no = n-i;
		ans += calculateNoOFactors(no);
	}

	cout<<ans;
}
int main()
{
	/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif*/
	//FT()
		solve();

	/*#ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
    #endif*/
	return 0;
}


Measured memory_bytes: 7536
def decSum(n, sm, mn):
    #print(n,sm,mn)
    if mn + n > 10 :
        return 0
    elif sum(range(mn, mn + n)) > sm or sum(range(10 - n, 10)) < sm:
        return 0
    elif n == 1:
        return 1
    else:
        a = 0
        for i in range(mn, 10 if sm >= 10 else sm):
            a += decSum(n - 1, sm - i, i + 1)
        return a
while True:
    n, sm = map(int, input().split())
    if n == 0:
        break
    print(decSum(n, sm, 0))

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

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

  sort(s.begin(), s.end());
  for (int i = 0; i < n; i++) {
    cout<<s[i];
  }
}


Measured memory_bytes: 256
S = list(input())
S.append("?")
for i in range(len(S) - 2):
    if S[i] == S[i + 1]:
        print(i + 1, i + 2)
        exit()
    elif S[i] == S[i + 2]:
        print(i + 1, i + 3)
        exit()

print("-1 -1")

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

int main() {
  int k, n;
  cin >> k >> n;
  
  vector<int> vec(n);
  REP(i, n) {
    cin >> vec.at(i);
  }
  
  int dist = 0;
  for (int i = 1; i < n; ++i) {
    dist = max(dist, vec.at(i) - vec.at(i-1));
  }
  
  cout << min(vec.at(n-1) - vec.at(0), k - dist) << endl;
  
  return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var n = long.Parse(Console.ReadLine());

        Dictionary<string, long> dic = new Dictionary<string, long>();

        dic["AC"] = 0;
        dic["WA"] = 0;
        dic["TLE"] = 0;
        dic["RE"] = 0;

        for (long i = 0; i < n; i++)
        {
            var str = Console.ReadLine();
            dic[str]++;
        }

        Console.WriteLine();
        foreach(var item in dic)
        {
            Console.WriteLine($"{item.Key} x {item.Value}");
        }
    }
}

Measured memory_bytes: 31176
#-*-coding:utf-8-*-

def main():
    a, b = map(int, input().split())

    merged = int(str(a) + str(b))
    merged_root = int(merged ** 0.5)
    if merged == merged_root ** 2:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto as = readln.split.to!(double[]);
    auto m = 0.0.reduce!"a + b"(as) / N;
    double max_d = 100;
    size_t s;
    foreach (i, a; as) {
        auto d = (m - a).abs;
        if (d < max_d) {
            max_d = d;
            s = i;
        }
    }
    writeln(s);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] points = new int[n][2];
        for(int i = 0; i < n; ++i) {
            points[i][0] = sc.nextInt();
            points[i][1] = sc.nextInt();
            sc.nextLine();
        }
        System.out.println(solve(n,points));
    }
    private static double solve(int N, int[][] points) {
        double sum = 0.0;
        for(int i = 0; i < N; i++) {
            for (int j = i+1; j < N; j++) {
                sum+=dist(i, j, points);
            }
        }
        return 2*sum/(double)N;
    }

    private static double dist(int i, int j, int[][] points) {
        return Math.sqrt(Math.pow(points[i][0]-points[j][0],2)+ Math.pow(points[i][1]-points[j][1],2));
    }
}


Measured memory_bytes: 23892
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;
int main(void){
   char s[200005],t[200005];
   cin>>s>>t;
   int scheck[26],tcheck[26];
   int N=strlen(s);
   for(int i=0;i<N;i++){
      scheck[s[i]-'a']++;
      tcheck[t[i]-'a']++;
   }
   sort(scheck,scheck+26);
   sort(tcheck,tcheck+26);
   int count=0;
   for(int i=0;i<26;i++){
      if(scheck[i]==tcheck[i]) {count++;}
   }
   if(count==26){cout<<"Yes";}
   else {cout<<"No";}
   return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <tuple>
#include <stdlib.h>
using namespace std;
typedef long long int ll;

int main()
{
	int A, B, C;
	string S;
	cin >> A >> B;
	cout << max(A-2*B,0);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,m,a[1005],p[1005];
int main(){
	cin>>n>>m;for(int i=0;i<n;i++){cin>>a[i];}
	for(int i=0;i<m;i++){
		int b;cin>>b;
		for(int j=0;j<n;j++){
			if(a[j]<=b){p[j]++;break;}
		}
	}
	int maxn=0,maxid=0;
	for(int i=0;i<n;i++){
		if(maxn<p[i]){maxn=p[i];maxid=i;}
	}
	cout<<maxid+1<<endl;
	return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main(int argc, char const *argv[]) {
	int N;
	std::cin >> N;
	unsigned int ans = pow((int)sqrt(N),2);
	std::cout << ans << '\n';
	return 0;
}


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

#define int long long 

const int INF = 1e18;

void max_self(int &a, int b)
{
	a = max(a,b);
}

void min_self(int &a, int b)
{
	a = min(a,b);
}

signed main()
{
	int n,w;
	cin >> n >> w;
	vector<int> weight(n),value(n);
	for(int i=0;i<n;++i)
	{
		cin >> weight[i] >> value[i];
	}
	
	int sum_val = accumulate(value.begin(),value.end(),0LL);
	
	vector<int> dp(sum_val+1,INF); // 0...W
	// dp[i] - min total weights that can be obtained with total value exactly i
	dp[0] = 0;
	for(int item = 0;item < n; ++item)
	{
			for(int value_added = sum_val-value[item]; value_added >= 0; --value_added)
			min_self(dp[value_added + value[item]],dp[value_added] + weight[item]);	
	}
	
	int ans = 0;
	
	for(int i=0;i<sum_val+1;++i)
	{
		if(dp[i]<=w)
		max_self(ans,i);
	}
	cout << ans;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
void findNum(string &s,int a,int b,int &A,int &B){
  int cnt=0;
  for(int i=a;i<b;i++){
    if(s[i]=='(')cnt++;
    if(s[i]==')')cnt--;
    if(cnt==0&&s[i]=='[')A=i;
    if(cnt==0&&s[i]==']')B=i+1;
  }
}
 
int getNum(string &s,int a,int b){
  int num=0;
  for(int i=a+1;i<b-1;i++)
    num=num*10+(s[i]-'0');
  return num;
}
 
void solve(string &s,string &t,int a,int b,int l,int r){
  if(a==b||l==r)return;
  int A,B,L,R;
  findNum(s,a,b,A,B);
  findNum(t,l,r,L,R);
  int snum=getNum(s,A,B);
  int tnum=getNum(t,L,R);
   
  cout<<'(';
  solve(s,t,a+1,A-1,l+1,L-1);
  cout<<')';
     
  cout<<'['<<snum+tnum<<']';
 
  cout<<'(';
  solve(s,t,B+1,b-1,R+1,r-1);
  cout<<')';
}
 
int main(){
  string s,t;
  cin>>s>>t;
  solve(s,t,0,s.size(),0,t.size());
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3224
#include <stdio.h>
#include <stdlib.h>

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

int lcm(int a, int b) {
  return b / gcd(a, b) * a;
}

int main(void) {
  int a, b;

  while (scanf("%d %d", &a, &b) != EOF) {
    printf("%d %d\n", gcd(a, b), lcm(a, b));
  }

  return EXIT_SUCCESS;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    int xmax = *max_element(x.begin(),x.end());
    int xmin = *min_element(x.begin(),x.end());
    int ans = INT_MAX;
    for(int i = xmin;i <= xmax;i++){
        int cost = 0;
        rep(j,n) cost += (x[j]-i)*(x[j]-i);
        if(cost < ans) ans = cost;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
h, w = map(int, input().split())
matrix = [list(input()) for _ in range(h)]


def get_or_period(l, passed_x, passed_y):
    if passed_x in [-1, w]:
        return '.'
    if passed_y in [-1, h]:
        return '.'
    return l[passed_y][passed_x]


convertedMatrix = []

for y, row in enumerate(matrix):
    convertedMatrix.append([])
    for x, cell in enumerate(row):
        convertedCell = 0
        if matrix[y][x] == "#":
            convertedCell = "#"
            convertedMatrix[y].append(convertedCell)
            continue
        for exam_x in [-1, 0, 1]:
            for exam_y in [-1, 0, 1]:
                if get_or_period(matrix, x + exam_x, y + exam_y) == "#":
                    convertedCell += 1
        convertedMatrix[y].append(convertedCell)

for row in convertedMatrix:
    print("".join(map(str, row)))


Measured memory_bytes: 3064
function main(input) {
  input=input.trim();
  const n = parseInt(input.split("\n")[0], 10);
  const a = parseInt(input.split("\n")[1], 10);
  var wari = n%500;
  if(wari<=a){
    console.log("Yes");
  }else{
    console.log("No");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 7372
n = int(input())
happymat = []
dp = []
for _ in range(n):
    happymat.append(list(map(int, input().split())))
    dp.append([0]*3)

# dp[i][j] stores the max happiness after day i ... doing activity j on that day
dp[0][0] = happymat[0][0]
dp[0][1] = happymat[0][1]
dp[0][2] = happymat[0][2]

for i in range(1, n):
    for j in range(3):
        dp[i][j] = happymat[i][j] + max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3])

print(max(dp[n-1]))

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

int main(){
	int a,b;
	cin >> a >> b;
	cout << (a+b+1)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <sstream> // std::stringstream
#include <bitset>  // std::bitset<N>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

ll min(ll a, ll b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}

void solve(){
	ll n;
	cin >> n;

	vector<ll> a(3*n, 0);
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (ll i = 0; i < n;i++)
	{
		a[i + n] = a[i] + 1;
		a[i + n + n] = a[i] - 1;

	}
	
	sort(a.begin(), a.end());
	
	ll max = 1;
	ll count = 1;
	for (ll i = 0; i < 3 * n - 1; i++)
	{
		if(a[i]==a[i+1]){
			count++;
		}
		else{
			if(count>max){
				max = count;
			}
			count = 1;
		}
	}

	cout << max << endl;
}

int main(){
	
	solve();
	
    return 0;
}



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

int main(){

    int a,b,c;
    cin >> a >> b >> c;
    int x,y;
    cin >> x >> y;
    int cost=a*x+b*y;

    if(x<y){
        swap(x,y);
        swap(a,b);
    }

    cost=min(cost,a*(x-y)+2*y*c);
    cost=min(cost,2*x*c);

    cout << cost << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<bitset>
#include<utility>

typedef long long ll;
#define INF 1000000000
#define MOD 1000000007

using namespace std;


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

int main() {
	ll n;
	cin >> n;
	vector<double> x(n);
	vector<string> u(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		cin >> u[i];
	}
	double ans = 0;
	for (int i = 0; i < n; i++) {
		if (u[i] == "JPY") {
			ans += x[i];
		} else {
			ans += x[i] * 380000.0;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;
int a,b;
char m[55];
bool n[55][55],c=1;
int main(){
scanf("%d%d",&a,&b);
memset(n,0,sizeof(n));
for(int i=1;i<=a;i++){
scanf("%s",m+1);
for(int j=1;j<=b;j++)if(m[j]=='#')n[i][j]=1;
}
for(int i=1;i<=a;i++)for(int j=1;j<=b;j++)if(n[i][j])
c&=n[i-1][j]||n[i+1][j]||n[i][j-1]||n[i][j+1];
printf(c?"Yes\n":"No\n");
}

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

int main(){
    int k;
    scanf("%d",&k);
    if(k%2==0||k%5==0){
        printf("-1");
    }else{
        ll cnt=0,sum=0;
        while(true){
            cnt++;
            sum=sum*10+7;
            if(sum%k==0){break;}
            else sum%=k;
        }
        printf("%lld",cnt);
    }
    return 0;
}


Measured memory_bytes: 3788
my $N = <STDIN>;
my @alfabet = ('a' .. 'z');

for($n=0;$n<$N;$n++){
  for($i=0;$i<=$#alfabet;$i++){
    $data{$alfabet[$i]} =0;
  }
}

%hash;
%data;
for($n=0;$n<$N;$n++){
 $str = <STDIN>;
 chomp $str;
 #print "$str\n";
 @s = split(//,$str);
 @s = sort @s;
 $str2 = "";
 for($i=0;$i<=$#s;$i++){
   $str2 .= "$s[$i]";
 }
 chomp $str2;
 #print "$str2\n";
 $hash{$str2} =  $hash{$str2} + 1;
}
$count = 0;

foreach $key ( keys%hash){
  #print "$hash{$key}\n";
  $n = $hash{$key} - 1;
  for($n;$n>0;$n--){
    $count = $count + $n;
  }
}

print "$count\n";

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

public class Main{


	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner();
		PrintWriter out=new PrintWriter(System.out);
		long k=sc.nextLong();
		int n=50;
		long x=k/n;
		long []a=new long [n];
		for(int i=0;i<n;i++)
			a[i]=i+x;
		int rem=(int) (k%n);
		for(int i=0;i<rem;i++) {
			a[i]+=n;
			for(int j=0;j<n;j++)
				if(j!=i)
					a[j]--;
			
		}
		out.println(n);
		for(long z:a)
			out.print(z+" ");

		out.close();
	}
	
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		Scanner(String fileName) throws FileNotFoundException{
			br=new BufferedReader(new FileReader(fileName));
		}
		String next() throws IOException {
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		String nextLine() throws IOException {
			return br.readLine();
		}
		int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		long nextLong()  throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
	
}



Measured memory_bytes: 21716
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int N = sc.nextInt();
                        long[] S = new long[N];
                        for (int i = 0; i < N; i++) {
                                S[i] = sc.nextLong();
                        }
                        int Q = sc.nextInt();
                        long[] T = new long[Q];
                        for (int i = 0; i < Q; i++) {
                                T[i] = sc.nextLong();
                        }
                        Arrays.sort(S);
                        Arrays.sort(T);
                        int ans = 0;
                        for (int i = 0, j = 0; i < N && j < Q; i++) {
                                if (S[i] == T[j]) {
                                        ans++;
                                        j++;
                                } else if(S[i] > T[j]) {
                                        i--;
                                        j++;
                                }
                        }
                        System.out.println(ans);
                }
        }
}

Measured memory_bytes: 79212
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
using namespace std;

int main() {
	int n;
	cin >> n; 
	int d[100];
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	sort(d, d + n);
	int ans = 0;
	for (int i = 0; i < n - 1; i++) {
		if (d[i] == d[i + 1]) {
			ans++;
		}
	}
	cout << n - ans << endl;
	
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  vector<P> q, r;
  rep(i,n) {
    int x, y;
    cin >> x >> y;
    q.emplace_back(1e9-x, 1e9-y);
    r.emplace_back(x-1e9, 1e9-y);
  }
  sort(q.begin(), q.end(), [] (P x, P y) {
    return (x.first+x.second) < (y.first+y.second);
  });
  sort(r.begin(), r.end(), [] (P x, P y) {
    return (x.first+x.second) < (y.first+y.second);
  });
  P a = q.back(), b = q.front();
  P c = r.back(), d = r.front();
  cout << max(a.first+a.second-b.first-b.second, c.first+c.second-d.first-d.second) << endl;
}

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

using namespace std;


int main(){
    int num;
    vector<int> As;

    while(cin >> num){
        As.push_back(num);
    }
    sort(As.begin(), As.end());

    cout << (As[1]-As[0])+(As[2]-As[1]) << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007

ll N;
ll K;
ll ruiseki[11];
vector<ll> all;
ll ans = 0;

ll keta(ll n){
    ll res = 0;
    while(n / 10 != 0){
        res++;
        n /= 10;
    }
    return res;
}

ll ketame(ll n,ll k){
    ll temp = n;
    rep(i,k){
        temp /= 10;
    }
    return temp%10;
}

void solve(){
    all.push_back(3);
    all.push_back(5);
    all.push_back(7);
    repi(i,1,10){
        ll s = ruiseki[i-1];
        ll e = ruiseki[i];
        repi(j,s,e){
            all.push_back(all[j]*10+3);
            all.push_back(all[j]*10+5);
            all.push_back(all[j]*10+7);
        }
    }
    return;
}

int main() {
    cin >> N;
    ruiseki[0] = 0;
    repi(i,1,11){
        ruiseki[i] = ruiseki[i-1]+pow(3,i);
    }
    solve();
    rep(i,all.size()){
        set<ll> ele;
        if (all[i] <= N){
            ll k = keta(all[i]);
            rep(j,k+1){
                ele.insert(ketame(all[i],j));
            }
        }
        if (ele.size() == 3) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//   for(auto x : v) cout << x << " "; cout << "\n";    // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }

int main()
{
  int n, m, a, b = 0, index = 0, times = 1;
  int64_t r = 1000000007, fib = 1, fib_b = 1, temp, ans = 1;

  cin >> n >> m;
  vector<int> vec;
  if (m >= 1)
  {
    cin >> b;
    vec.push_back(max(1, b - 1));
  }
  for (int i = 1; i < m; i++)
  {
    cin >> a;
    vec.push_back(max(1, a - b - 2));
    if (a - b == 1)
    {
      cout << 0 << endl;
      return (0);
    }
    b = a;
  }
  if (m == 0)
    vec.push_back(n);
  else
    vec.push_back(max(1, n - b - 1));
  sort(vec.begin(), vec.end());
  while (index <= m)
  {
    if (times == vec[index])
    {
      ans = ans * fib % r;
      index++;
    }
    else
    {
      temp = fib;
      fib = (fib + fib_b) % r;
      fib_b = temp;
      times++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3852
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#include<stack>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
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;}
const long long INF=1LL<<60;
//set<int>::iterator it;

void disp(vector<int>& v) {
    cout<<"[ ";
    for(int i=0;i<v.size();i++) {
        cout<<v[i]<<" ";
    }
    cout<<"]"<<endl;
}

int main(void){
    int n;
    cin>>n;
    vector<int> v;
    vector<int> a;
    a.resize(n);
    for(int i=0;i<n;i++) {
        int s;
        cin>>s;
        a[i] = s;
        // if(!binary_search(v.begin(),v.end(),s)) {
        //     v.push_back(s);
        // }
    }
    // sort(v.begin(),v.end(),greater<int>());
    // cout<<"size:"<<v.size()<<endl;
    // disp(v);
    vector<int> c;
    c = a;
    sort(c.begin(),c.end(),greater<int>());
    if (c[0] == c[1]) {
        for(int i = 0;i<n;i++) {
            cout<<c[0]<<endl;
        }   
        return 0;
    }
    int max,semimax;
    max = c[0];
    semimax = c[1];
    for(int i=0;i<n;i++) {
        if(a[i] != max) {
            cout<<max<<endl;
        }
        else
            cout<<semimax<<endl;
        
    }

    return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
using namespace std;

//階乗先に計算
long long int kaizyou[200005] = { 1 };
long long int kai(long long int a, long long int b, long long int mod) {
	long long int tmp = 1;
	for (long long int i = a; i <= b; i++) {
		tmp *= i;
		tmp %= mod;

		kaizyou[i] = tmp;
	}
	return tmp;
}


//累乗(繰り返し2乗法)　aのb乗(mod)を求める。
long long int rui(long long int a, long long int b, long long mod) {
	int memo[65] = {};
	long long int A[65] = {};
	long long int tmp = 1;
	for (int i = 0; i < 65; i++) {
		memo[i] = b % 2;
		b /= 2;
	}

	A[0] = a;
	A[0] %= mod;

	for (int i = 1; i < 65; i++) {
		A[i] = A[i - 1] * A[i - 1];
		A[i] %= mod;
	}
	for (int i = 0; i < 65; i++) {
		if (memo[i] == 1) {
			tmp *= A[i];
			tmp %= mod;
		}
	}
	tmp %= mod;
	return tmp;
}

//コンビネーション計算
long long int comb(long long int n, long long int r, long long int mod) {
	long long int tmp;

	tmp = (kaizyou[n] * rui(kaizyou[r], mod - 2, mod)) % mod;
	tmp *= rui(kaizyou[n - r], mod - 2, mod);
	tmp %= mod;
	if (tmp < 0) { tmp = (mod - tmp) % mod; }
	return tmp;
}

int main() {
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int n, m, k,a[200005],L[200001], R[200001],res=0,now=0;
	long long int sum=0;
	cin >> n >> m>>k;
	kai(1, 200002, mod);
	for (long long int i = 1; i <= m; i++) {
		long long int tmp = n;
		tmp *= ((m - i) * (m - i + 1) / 2 + (i - 1) * i / 2)%mod;
		tmp %= mod;
		tmp *= comb(n * m - 1, k - 1, mod);
		tmp %= mod;
		tmp *= n;
		tmp %= mod;
		tmp *= rui(n * m - 1, mod - 2, mod);
		tmp %= mod;
		res += tmp;
		res %= mod;
	}
	for (long long int i = 1; i <= n; i++) {
		long long int tmp = m;
		tmp *= ((n- i) * (n - i + 1) / 2 + (i - 1) * i / 2)%mod;
		tmp %= mod;
		tmp *= comb(n * m - 1, k - 1, mod);
		tmp %= mod;
		tmp *= m;
		tmp %= mod;
		tmp *= rui(n * m - 1, mod - 2, mod);
		tmp %= mod;
		res += tmp;
		res %= mod;

	}
	res *= rui(2, mod - 2, mod);
	res %= mod;
	res *= k - 1;
	
	cout << res%mod;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(void)
{
	int yyyy,mm,dd;

	scanf("%d/%d/%d",&yyyy,&mm,&dd);
	if(yyyy<=2018){
		printf("Heisei\n");
	}else if((yyyy<=2019) && (mm>=5)){
		printf("TBD\n");
	}else if((yyyy==2019) && (mm>=1) && (mm<=4)){
		printf("Heisei\n");
	}
return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = calc();
            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static int calc()
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);

            string[] A = Console.ReadLine().Split(' ');

            if (K == N)
            {
                return 1;
            }


            int pointer1 = 0;
            for (int i = 0; i < A.Length; i++)
            {
                if (A[i] == "1")
                {
                    pointer1 = i;
                    break;
                }
            }

            int dK = K-1;

            int left = 0;
            for (int i = 1; i < N; i++)
            {
                if (pointer1 == 0)
                {
                    left = 0;
                    break;
                }
                if (pointer1 - i * dK <= 0 )
                {
                    left = i;
                    break;
                }
            }

            int right = 0;
            for (int i = 1; i < N; i++)
            {
                if (pointer1 == N -1)
                {
                    right = 0;
                    break;
                }

                if (pointer1 + i* dK >= N-1  )
                {
                    right = i;
                    break;
                }

            }

            int ans = left + right;
            int ans2 = (int)( Math.Ceiling( (N - 1.0d) / (K - 1.0d)));
            if (ans > ans2 )
            {
                return ans2;
            }

            return ans;

        }

    }
}


Measured memory_bytes: 18016
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1000000007, INF = 1e9;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    int top = v[0], ans = 1;
    for(int i = 1; i < n; i++){
        if(top >= v[i]){
            top = v[i];
            ans++;
        }
    }
    cout << ans << endl;
}

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

void solve(){
	ll n;
	cin >> n;
	ll arr[n];
	for( ll i = 0; i < n; i++){
		cin >> arr[i];
	}
	ll ans = 0;
	sort(arr, arr + n,greater<int>());
	vector< ll > qwe;
	for( int i = 0; i < n; i++){
		qwe.push_back(arr[i]);
		if(i) qwe.push_back(arr[i]);
	}
	for( int i = 0; i < n -1; i++){
		ans += qwe[i];
	}
	cout << ans <<"\n";
	return ;
}

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

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		
	int t = 1;

	while(t--){
		solve();
	}

	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;

ll table[100001][21];

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<ll> v;
    ll l;  // max travel distance per day
    for(long long i=0;i<n;i++){
        long long k;
        cin>>k;
        v.pb(k);
    }
    v.pb(1e17);
    cin>>l;
    int k=20;
    ll pointer=0;
    for(ll i=0;i<n;i++){
        for(ll j=pointer;j<=n;j++){
            if(v[j]-v[i]>l){
                pointer=j;
                table[i][0]=j-1;
                break;
            }
        }
    }
    for(ll j = 1; j <= k; j++) {
        for(ll i = 0; i <= n ; i++)
            table[i][j] = table[table[i][j - 1]][j-1];
    }
    ll q;
    cin>>q;
    for(ll i=0;i<q;i++){
        ll a,b;
        cin>>a>>b;
        if(a>b)
            swap(a,b);
        a--;
        b--;
        long long answer = 0;
        while(a<b){
            for(ll j = k; j >= 0; j--) {
                if(table[a][j] < b || j==0) {
                    answer = answer +(1<<j);
                    a=table[a][j];
                    break;
                }
            }
        }
        cout << answer << endl;
    }
    return 0;
}

Measured memory_bytes: 18164
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;

int main() {

    int A, B, C, D, E, F;

    cin >> A >> B >> C >> D >> E >> F;

    vector<int> waters;
    vector<int> sugars;

    for (int a = 0; a * A * 100 <= F; a++) {
        for (int b = 0; a * A * 100 + b * B * 100 <= F; b++) {
            waters.push_back(a * A * 100 + b * B * 100);
        }
    }

    for (int c = 0; c * C <= F; c++) {
        for (int d = 0; c * C + d * D <= F; d++) {
            sugars.push_back(c * C + d * D);
        }
    }

    double maxC = 0;
    int sugarWater = 0;
    int sugar = 0;

    for (auto w : waters) {
        for (auto s :sugars) {

            double c = (((double) s) * 100) / ((double) (w + s));

            if ((maxC <= c) and (w + s <= F) and (s * 100 <= w * E)) {

                sugarWater = w + s;
                sugar = s;
                maxC = c;
            }

        }
    }

    cout << sugarWater << " " << sugar;


    return 0;

}

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

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b;
  cin >> a >> b;

  if (a < 10 && b < 10) {
    cout << a * b << endl;
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define v(T) vector<T>
#define yn {puts("Yes");}else{puts("No");}
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double eps = 1e-10;

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if (d <= t * s)
    yn
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, k, s;
  	cin>>n>>k>>s;
  	rep(i, n) {
  	if(i < k) cout<<s<<' ';
    else cout<<(s+1) % 1000000000<<' ';
  }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
constexpr ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N,M;
    cin >> N >> M;
    priority_queue<ll> pq;
    REP(i,N){
        ll tmp;
        cin >> tmp;
        pq.push(tmp);
    }
    REP(i,M){
        ll disc = pq.top();
        pq.pop();
        pq.push(disc/2);
    }
    ll ans = 0;
    while(!pq.empty()){
        ans += pq.top();
        pq.pop();
    }
    cout << ans << "\n";
}

Measured memory_bytes: 4244
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;
    
    vvpll G(n);
    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(make_pair(b, 1));
        G[b].pb(make_pair(a, 1));
    }
    
    vl dist1(n, -1);  // dist1[i] : 頂点iの頂点0からの距離
    queue<ll> Q1;
    dist1[0] = 0;
    Q1.push(0);
    while(!Q1.empty()) {
        ll v = Q1.front();
        Q1.pop();
        for(auto p : G[v]) {
            ll u = p.first;
            ll cost = p.second; 
            if(dist1[u] != -1) {
                continue;
            }
            dist1[u] = dist1[v] + cost;
            Q1.push(u);
        }
    }
    
    ll vertex1 = 0;  // 頂点0からの距離が最大の頂点
    rep(v, n) {
        if(dist1[vertex1] < dist1[v]) {
            vertex1 = v;
        }
    }

    vl dist2(n, -1);  // dist2[i] : 頂点iの頂点vertex1からの距離
    queue<ll> Q2;
    dist2[vertex1] = 0;
    Q2.push(vertex1);
    while(!Q2.empty()) {
        ll v = Q2.front();
        Q2.pop();
        for(auto p : G[v]) {
            ll u = p.first;
            ll cost = p.second; 
            if(dist2[u] != -1) {
                continue;
            }
            dist2[u] = dist2[v] + cost;
            Q2.push(u);
        }
    }

    ll vertex2 = vertex1;  // 頂点vertex1からの距離が最大の頂点
    ll TreeDiameter = 0;  // 木の直径
    rep(v, n) {
        if(dist2[vertex2] < dist2[v]) {
            vertex2 = v;
            TreeDiameter = dist2[v];
        }
    }

    if(TreeDiameter%3 == 1) {
        out("Second");
    }
    else {
        out("First");
    }

    re0;
}

Measured memory_bytes: 19180
#include <stdio.h>

int main(void){
	int i , m , d , sum;
	int mon[13] = {0 , 31 , 29 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31};
	char *m_name[] = {"Wednesday" , "Thursday" , "Friday" , "Saturday" , "Sunday" , "Monday" , "Tuesday"};
	while(1){
		sum = 0;
		scanf("%d %d" , &m , &d);
		if(m==0) break;
		for(i=1;i<m;i++){
			sum += mon[i];
		}
		sum += d;
		printf("%s\n" , m_name[sum%7]);
	}
	return 0;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> p;
  for(int i=0; i<n; i++){
    int tmp;
    cin >> tmp;
    p.emplace_back(tmp);
  }
  sort(p.begin(), p.end());
  int res = 0;
  for(int i=0;i<k;i++){
    res += p[i];
  }
  cout << res << endl;
  return 0;
}

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

using namespace std;

vector<int> A,B,C;

long long n;
long long ans; 

int main()
{
	int temp;
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&temp);
		A.push_back(temp);
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&temp);
		B.push_back(temp);
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&temp);
		C.push_back(temp);
	}
	sort(A.begin(),A.end());
	sort(C.begin(),C.end());
	sort(B.begin(),B.end());
	for(int i=0;i<n;i++)
	{
		int acnt = lower_bound(A.begin(),A.end(),B[i]) - A.begin();
		int ccnt = upper_bound(C.begin(),C.end(),B[i]) - C.begin();
		if(acnt >= 1&&ccnt!=n)
		ans += acnt * (n-ccnt); 
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1784
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

const int maxn = 1e5 + 10;
int a[maxn], b[maxn], c[maxn], n;

int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    for(int i = 0; i < n; i++)
        scanf("%d", &b[i]);
    for(int i = 0; i < n; i++)
        scanf("%d", &c[i]);
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);

    LL ans = 0;
    for(int i = 0; i < n; i++) {
        int x = b[i];
        int pos1 = lower_bound(a, a + n, x) - a - 1;
        int pos2 = upper_bound(c, c + n, x) - c ;
        if(pos1 >= 0 && pos1 < n && pos2 >= 0 && pos2 < n) {
            ans += (LL) (pos1 + 1) * (LL)(n - pos2);
        }
    }
    printf("%lld\n", ans);
    return 0;
}


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

ll tc, bil, r;


int main(){
	scanf("%lld %lld",&bil, &tc);
	map<ll,ll> ar;
	for(int k = 1; k<= tc; k++){
		scanf("%lld", &r);
		ar[r]++;
	}
	ll tmp = 0;
	ll jaw = 0;
	if(tc == 0){
		printf("%lld\n", bil);
		return 0;
	}
	while(true){
		if(ar[bil - tmp] == 0){
			jaw = bil - tmp;
			break;
		}
		if(ar[bil + tmp] == 0){
			jaw = bil + tmp;
			break; 
		}
		tmp++;
	}
	printf("%lld\n",jaw);
}

Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;
const int CENTER = 30;
int n, r;
int h[60];

bool check(double m) {
	for(int i = 0; i <= r - 1; i++) {
		double sh = -r + m + sqrt(r * r - i * i);
		if(sh < 0) continue;
		if(h[CENTER + i] < sh) return false;
	}
	for(int i = -r; i <= -1; i++) {
		double sh = -r + m + sqrt(r * r - (i + 1) * (i + 1));
		if(sh < 0) continue;
		if(h[CENTER + i] < sh) return false;
	}
	return true;
}

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

	while(cin >> r >> n, n | r) {
		for(int i = 0; i < 60; i++) {
			h[i] = 0.0;
		}

		for(int i = 0; i < n; i++) {
			int xl, xr, hh;
			cin >> xl >> xr >> hh;
			for(int j = xl; j < xr; j++) {
				h[CENTER + j] = max(h[CENTER + j], hh);
			}
		}
		double ok = 0, ng = 100;
		for(int loop = 0; loop < 100; loop++) {
			double m = (ok + ng) / 2.0;
			if(check(m)) ok = m;
			else ng = m;
		}

		cout << fixed << setprecision(4) << ok << endl;
	}
}

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

void solve() {
    int N; cin >> N;
    for(int X = 1; X <= N; ++X) {
        double t = X * 1.08;
        if((int)t == N) {
            cout << X << '\n';
            return;
        }
    }
    cout << ":(" << '\n';
}

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


Measured memory_bytes: 256
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());

	// skip the first zero
	if (int.Parse(ReadLine()) != 0)
	{
	    WriteLine(-1);
	    return;
	}

	long ans = 0;
	int curr = 0;
	for (int i = 2; i <= n; i++)
	{
	    int a = int.Parse(ReadLine());
	    if (curr == 0 && a == 0) continue;

	    if (a == curr + 1)
	    {
		ans++;
	    }
	    else if (a == curr)
	    {
		ans += a;
	    }
	    else if (a < curr)
	    {
		ans += a;
	    }
	    else
	    {
		WriteLine(-1);
		return;
	    }
	    curr = a;
	}
	    
	WriteLine(ans);
    }
}


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

int a[85][85], b[85][85];
bitset<12805> dp[85][85];

const int INF = 1e9;

void update(bitset<12805> &x, bitset<12805> y, int val) {
    if (val >= 0) x |= y << val;
    else x |= (y >> (-val));
}

int main() {
    int h, w;
    scanf("%d%d", &h, &w);
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) scanf("%d", &a[i][j]);
    }
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) scanf("%d", &b[i][j]);
    }
    
    dp[0][0][6400 - (a[0][0] - b[0][0])] = 1;
    dp[0][0][6400 - (b[0][0] - a[0][0])] = 1;
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (i - 1 >= 0) {
                update(dp[i][j], dp[i - 1][j], a[i][j] - b[i][j]);
                update(dp[i][j], dp[i - 1][j], b[i][j] - a[i][j]);
            }
                
            if (j - 1 >= 0) {
                update(dp[i][j], dp[i][j - 1], a[i][j] - b[i][j]);
                update(dp[i][j], dp[i][j - 1], b[i][j] - a[i][j]);
            }
        }
    }
    
    int res = INF;
    
    for (int i = 0; i <= 12800; i++) {
        if (dp[h - 1][w - 1][i] == 1) res = min(res, abs(i - 6400));
    }
    
    printf("%d\n", res);
}


Measured memory_bytes: 10880
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	p := make(map[int]int)
	for i := 1; i <= n; i++ {
		prime := PrimeFactors(i)
		for _, j := range prime {
			p[j]++
		}
	}
	q := make([]int, 0)
	for _, v := range p {
		q = append(q, v)
	}
	lq := len(q)
	ans := 0
	for i := 0; i < lq; i++ {
		for j := i + 1; j < lq; j++ {
			for k := j + 1; k < lq; k++ {
				if q[i] >= 4 && q[j] >= 4 && q[k] >= 4 {
					ans += 3
				} else if q[i] >= 4 && q[j] >= 4 && q[k] >= 2 {
					ans += 1
				} else if q[i] >= 4 && q[j] >= 2 && q[k] >= 4 {
					ans += 1
				} else if q[i] >= 2 && q[j] >= 4 && q[k] >= 4 {
					ans += 1
				}
			}
		}
	}
	for i := 0; i < lq; i++ {
		for j := i + 1; j < lq; j++ {
			if q[i] >= 24 && q[j] >= 24 {
				ans += 2
			} else if q[i] >= 24 && q[j] >= 2 {
				ans += 1
			} else if q[i] >= 2 && q[j] >= 24 {
				ans += 1
			}
		}
	}
	for i := 0; i < lq; i++ {
		for j := i + 1; j < lq; j++ {
			if q[i] >= 14 && q[j] >= 14 {
				ans += 2
			} else if q[i] >= 14 && q[j] >= 4 {
				ans += 1
			} else if q[i] >= 4 && q[j] >= 14 {
				ans += 1
			}
		}
	}
	for i := 0; i < lq; i++ {
		if q[i] >= 74 {
			ans++
		}
	}
	fmt.Println(ans)
}
func PrimeFactors(n int) (pfs []int) {
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}
	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}
	if n > 2 {
		pfs = append(pfs, n)
	}
	return
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
const int mxn=100010;
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,a[mxn];
int main(){
	int i,j;
	n=read();
	for(i=1;i<=n;i++)a[i]=read();
	int mx=-1e9,mn=1e9;
	for(i=1;i<=n;i++){
		mx=max(a[i],mx);
		mn=min(a[i],mn);
	}
	printf("%d\n",mx-mn);
	return 0;
}

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

int main(){
    int L, R, d;
    cin >> L >> R >> d;
    int ans = 0;
    for(int i = L; i <= R; i++){
        if(i%d == 0) ans++;
    }

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

Measured memory_bytes: 3500