akhauriyash/Code-Regression huggingface dataset:
/* 
 *     author-->@harshrajani460
 *     codeforces round-567
 *
 */
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define sz size()
#define mp make_pair
#define p(x) cout<< x << " ";
#define pe(x) cout<< x << endl ;
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define el endl
#define M 998244353 
#define int long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROR(i,a,b) for(int i=a;i>=b;i--)
const int N = 1e5 + 5;
int dp[N],a[105];
void solve()
{
    int n,k;
    cin>>n>>k;
    FOR(i,1,n+1)
    cin>>a[i];
    FOR(i,1,k+1)
    {
        FOR(j,1,n+1)
        {
            if(i>=a[j] && dp[i-a[j]]==0)
            { dp[i]=1;  break;}
        }
    }
    if(dp[k])
    cout<<"First";
    else
    cout<<"Second";
    
}
int32_t main() 
{ 
    solve();
   
} 

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();		
		int a[] = new int[N];
		Set<Integer> set = new HashSet<Integer>();
		for(int  i=0; i<N; i++) {
			a[i]= sc.nextInt();
			set.add(Integer.valueOf(a[i]));
		}
		if(set.size()!=N){
			System.out.println("NO");
		}else {
			System.out.println("YES");
		}
	}
		
}

Measured memory_bytes: 104728
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
ll t, a, b, c, i, j, k, x, y, n, m;
ll arr[200005];
string s;
char str[105][105];
int main() {
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> arr[i];
	}
	ll ans = 0;
	for (i = 1; i < n; i++) {
		if (arr[i] < arr[i - 1])
		{
			ans += (-arr[i] + arr[i - 1]);
			arr[i] = arr[i - 1];
		}
	}
	cout << ans;
	return 0;
}
/*
4 6 8
4 6 8 6 8 6 8
24+18+4
46
4 6 8 2 9 9 9 9
36+20
56
*/

Measured memory_bytes: 5212
MOD = 998244353

n,m,k = map(int,input().split())

fac = [1]*(n+1)
fac_inv =  [0]*(n+1)

for i in range(n):
    fac[i+1] = (fac[i] * (i+1)) %MOD
fac_inv[-1] = pow(fac[-1],MOD-2,MOD)
for i in range(n,0,-1):
    fac_inv[i-1] = (fac_inv[i] * i) % MOD
    
def comb(n,k):
    if k<0 or k>n:
        return 0
    x = (fac[n] * (fac_inv[k] * fac_inv[n-k])%MOD)%MOD
    return x

ans = 0
for i in range(k+1):
    ans += comb(n-1, i) * m %MOD * pow(m-1,n-i-1,MOD) %MOD
    ans %= MOD

print(ans)

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

int main()
{
    ll n,m,k,y,x,z;
    cin>>n>>x>>y;
    m=abs(n-x);
    k=abs(n-y);
    if(m>k)
        cout<<"B"<<endl;
    else
        cout<<"A"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,i,i1,j,j1,x;
	while((scanf("%d",&a))!=EOF){
		x=0;
		for(i=0;i<10;i++){
			for(j=0;j<10;j++){
				for(i1=0;i1<10;i1++){
					for(j1=0;j1<10;j1++){
						if(i+j+i1+j1==a){
							x++;
						}
					}
				}
			}
		}
		printf("%d\n",x);
	}
	return 0;
}

Measured memory_bytes: 596
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;

fn main() {
    let mut v = input_vector::<usize>();
    v.sort();
    if v[0] + v[1] == v[2] {
        p("Yes");
    } else {
        p("No");
    }
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
	int x, y;
	
	while (1){
		scanf("%d%d", &x, &y);
		
 		if (x == 0 && y == 0){
			break;
 		}
		
		if (x < y){
			printf("%d %d\n", x, y);
		}
		else {
			printf("%d %d\n", y, x);
		}
	}
	return (0);
}






Measured memory_bytes: 2052
X = input()
l = [''] * 2*10**5

last = X[0]
l[0] = X[0]
lastSindex = []
if last == 'S':
    lastSindex.append(0)

for i, a in enumerate(X):
    if i == 0:
        continue
    
    if a == 'T':
        if len(lastSindex) != 0:
            li = lastSindex.pop()
            l[li] = ''
        else:
            l[i] = a
    if a == 'S':
        lastSindex.append(i)
        l[i] = a

print(len(''.join(l)))

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A,B,C=MAP()

print(max(0, C-(A-B)))


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
    int n; cin >> n;
    double A[n]; for(int i = 0; i < n; i++) cin >> A[i];
    sort(A, A+n);
    //cout << A[0] << endl;
    double sum = A[0] * pow(2, -n+1);
    for(int i = 1; i < n; i++) sum += A[i] * pow(2, -n+i);
    cout << sum << endl;
}

Measured memory_bytes: 256
N = int(input())
colors = []
n_wild = 0
for ai in map(int, input().split()):
    bi = ai // 400
    if bi >= 8:
        n_wild += 1
    else:
        colors.append(bi)
n_colors = len(set(colors))
if n_colors == 0:
    print(1, n_wild)
else:
    print(n_colors, n_colors + n_wild)


Measured memory_bytes: 2940
import java.util.*;
  
class Main{
  public static void main(String[] args){
    Scanner stdId = new Scanner(System.in);
    int x = stdId.nextInt(); 
    int y = stdId.nextInt(); 
    while(x!=0 || y!=0){
      System.out.println(Math.min(x,y) + " " + Math.max(x,y));
      x = stdId.nextInt();
      y = stdId.nextInt();
    }
  }
}

Measured memory_bytes: 25368
program ABC149E
    implicit none
    integer(16)::N,M
    integer(16),allocatable,dimension(:)::A,R
    integer(16)::ans,OK,NG,MD,tmp
    integer(16)::i,j
    read*,N,M
    allocate(A(N))
    read*,A
    call heapsort(N,A)
    allocate(R(200000+1))
    R=0
    do i=1,N
        R(A(i))=R(A(i))+1
    end do
    do i=2*10**5,1,-1
        R(i)=R(i)+R(i+1)
    end do
    
    OK=0;NG=A(N)*2+1
    MD=(OK+NG)/2
    do while(NG-OK>1)
        if(CNT(MD)>=M)then
            OK=MD
        else
            NG=MD
        endif
        MD=(OK+NG)/2
    end do

    ans=0
    do i=1,N
        if(A(i)>=OK)then
            tmp=N
        else
            tmp=R(MD-A(i))
        endif
        ans=ans+tmp*A(i)*2
    end do
    print"(i0)",ans-MD*(cnt(OK)-M)
contains
integer(16) function cnt(MID)
    integer(16),intent(in)::MID
    integer(16)::ii
    cnt=0
    do ii=1,N
        if(MID>A(ii))then
            cnt=cnt+R(MID-A(ii))
        else
            cnt=cnt+N
        endif
    end do
end function
subroutine heapsort(n,array)
  implicit none
!ここの入力は状況に応じて変更すること
  integer(16),intent(in) :: n
  integer(16),intent(inout) :: array(1:n)
  integer(16)::i,k,j,l
  integer(16):: t
  l=n/2+1
  k=n
  do while(k /= 1)
     if(l > 1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k == 1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j<=k)
        if(j < k)then
           if(array(j) < array(j+1))j=j+1
        endif
        if (t < array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo
  return
end subroutine heapsort
end program ABC149E

Measured memory_bytes: 5504
import math

def combi(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n, p = map(int, input().split())
L = list(map(int, input().split()))
odd = 0
even = 0
for a in L:
    if a % 2:
        odd += 1
    else:
        even += 1
c = 0
if p == 0:
    for i in range(0, odd + 1, 2):
        c += combi(odd, i)
else:
    for i in range(1, odd + 1, 2):
        c += combi(odd, i)
ans = 2 ** even * c
print(ans)


Measured memory_bytes: 3064
def pri(l):
    for i in l:
        print(i)
h, w = map(int, input().split())
a, ans = [], []
for _ in range(h):
    temp = ''.join(input())
    if not all([x == '.' for x in temp]):
        a.append(temp)
for temp in [''.join(s) for s in zip(*a)]:
    if not all([x == '.' for x in temp]):
        ans.append(temp)
pri([''.join(s) for s in zip(*ans)])

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

using namespace std;

typedef tuple<int, int, int> tp;

#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i=(a); i<(n); i++)

bool obstacle[120][120];
bool visited[120][120];

int main() {
    int t, n;
    while(cin>>t>>n, t+n) {
        rep(i, 120) rep(j, 120) obstacle[i][j] = false;
        rep(i, 120) rep(j, 120) visited[i][j] = false;

        rep(_, n) {
            int x, y;
            cin >> x >> y;
            obstacle[x+60][y+60] = true;
        }

        int cx, cy, cnt;
        cin >> cx >> cy;
        cx += 60;
        cy += 60;

        queue< tp > que;
        que.push(make_tuple(cx, cy, 0));
        visited[cx][cy] = true;
        while(!que.empty()) {
            tie(cx, cy, cnt) = que.front(); que.pop();
            if(cnt == t) break;
            REP(i, -1, 2) REP(j, -1, 2) {
                if(i*j < 0) continue;
                if(visited[cx+i][cy+j]) continue;
                if(obstacle[cx+i][cy+j]) continue;
                que.push(make_tuple(cx+i, cy+j, cnt+1));
                visited[cx+i][cy+j] = true;
            }
        }
        int ans = 0;
        rep(i, 120) rep(j, 120) ans += visited[i][j];
        cout << ans << endl;
    }
}



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

class Node:
  def __init__(self, key, priority, left=None, right=None):
    self.key = key
    self.priority = priority
    self.left = left
    self.right = right
  
def rightRotate(t):
  s = t.left
  t.left = s.right
  s.right = t
  return s

def leftRotate(t):
  s = t.right
  t.right = s.left
  s.left = t
  return s

def insert(t, key, priority):
  
  if not t: return Node(key, priority)
  if key == t.key: return t
  
  if key < t.key: 
    t.left = insert(t.left, key, priority)
    if t.priority < t.left.priority:
      t = rightRotate(t)
  else:
    t.right = insert(t.right, key, priority)
    if t.priority < t.right.priority:
      t = leftRotate(t)
  
  return t

def erase(t, key):
  
  if not t: return None
  
  if key == t.key:
    if (not t.left) and (not t.right): return None
    elif not t.left: 
      t = leftRotate(t)
    elif not t.right:
      t = rightRotate(t)
    else:
      if t.left.priority > t.right.priority:
        t = rightRotate(t)
      else:
        t = leftRotate(t)
    return erase(t, key)
  elif key > t.key:
    t.right = erase(t.right, key)
  else:
    t.left = erase(t.left, key)
  return t


def find(t, key):
  if t.key == key:
    print("yes")
  elif t.key < key and t.right != None:
    find(t.right, key)
  elif t.key > key and t.left != None:
    find(t.left, key)
  else:
    print("no")
  return 0

def in_print(t):
  if t.left != None:
    in_print(t.left)
  print(" " + str(t.key), end='')
  if t.right != None:
    in_print(t.right)

def pre_print(t):
  print(" " + str(t.key), end='')
  if t.left != None:
    pre_print(t.left)
  if t.right != None:
    pre_print(t.right)
  
Treap = None
num = int(input())
for i in range(num):
  string = list(input().split())
  if string[0] == "insert":
    key = int(string[1])
    priority = int(string[2])
    Treap = insert(Treap, key, priority)
  elif string[0] == "find":
    key = int(string[1])
    find(Treap, key)
  elif string[0] == "delete":
    key = int(string[1])
    Treap = erase(Treap, key)
  else:
    in_print(Treap)
    print()
    pre_print(Treap)
    print()
    

  


Measured memory_bytes: 52024
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << # x << "; "<< x << endl


int main() {
	long long X, Y;
	cin >> X;
	Y = X;
	long long happy = 0;
	X = X / 500;
	happy += 1000 * X;
	Y -= X * 500;
	Y = Y / 5;
	happy += Y * 5;
	cout << happy << endl;
}


Measured memory_bytes: 3632
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

int i,j,d,n;string s;
cin>>s;n=s.length();
vector<int> dp(13,0);
if(s[0]!='?') dp[s[0]-'0']+=1;
else
{
	for(i=0;i<10;i++) dp[i]+=1;
}
for(i=1;i<n;i++)
{
	vector<int> tdp(13,0);
	if(s[i]!='?') {
	d=s[i]-'0';
	for(j=0;j<13;j++)
	{
		int r=(10*j+d)%13;
		tdp[r]=(tdp[r]+dp[j])%mod;
	}
	}
	else
	{
		for(d=0;d<10;d++)
		{
			for(j=0;j<13;j++)
			{
				int r=(10*j+d)%13;
				tdp[r]=(tdp[r]+dp[j])%mod;
			}
		}
	}
	dp=tdp;
}
cout<<dp[5];


return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H,W;
    char a[110][110];
    cin >> H >> W;
    rep(i,0,H) rep(j,0,W) cin >> a[i][j];
    map<char, ll> mp;
    rep(i,0,H) rep(j,0,W) mp[a[i][j]]++;
    bool flg = true;
    if(H % 2 == 0 && W % 2 == 0){
        for(auto &e: mp){
            if(e.second % 4 != 0) flg = false;
        }   
    }else if(H % 2 == 0 && W % 2 != 0){
        ll cnt2 = 0;
        for(auto &e: mp){
            if(e.second % 2 != 0){
                flg = false;
            }else if(e.second % 4 != 0){
                cnt2++;
            }
        }
        if(cnt2 > H/2) flg = false;
    }else if(H % 2 != 0 && W % 2 == 0){
        ll cnt2 = 0;
        for(auto &e: mp){
            if(e.second % 2 != 0){
                flg = false;
            }else if(e.second % 4 != 0){
                cnt2++;
            }
        }
        if(cnt2 > W/2) flg = false;
    }else{
        ll cnt2 = 0, cnt1 = 0;
        for(auto &e: mp){
            if(e.second % 2 != 0){
                cnt1++;
            }else if(e.second % 4 != 0){
                cnt2++;
            }
        }
        if(cnt1 > 1) flg = false;
        if(cnt2 > W/2 + H/2) flg = false;
    }
    if(flg){
        print("Yes");
    }else{
        print("No");
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    int ctr = 0;
    cin >> s;
    int l = s.length();
    char ch1, ch2;
    for (int i = 0; i < l/2; i++){
        ch1 = s[i];
        ch2 = s[l-i-1];
        if (ch1 == ch2)
            continue;
        else
            ctr++;
    }
    cout << ctr;
    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;
int main(void){
    ll X;
    cin>>X;
    bool Pnum=false;
    bool mod0;
    ll ans;
    while(Pnum==false){
        mod0=false;
        if(X==2){
            ans=X;
            Pnum=true;
        }
        else {
        for(int i=2;i<X;i++){
            if(X%i==0){
                mod0=true;
                X++;
                break;
            }
        }
        }
        if(mod0==false){
            Pnum=true;
            ans=X;
        }
    }
    cout<<ans<<endl;
    }
    
    



Measured memory_bytes: 3620
n,k=map(int,input().split())

#k ... n の値を取りうる. mとする。
# 和としてあり得るものは、
# m*(2*0+(m-1))/2 ~ m*(2*n+(m-1)*-1)/2 までの値を取りうる
# よって
# m*(2*n+(m-1)*-1)/2 - m*(2*0+(m-1))/2 + 1 通りがありうる。
# 
# mはk~nまでとりうるので
ans=0
for m in range(k,n+1):
    ans+= (m*(2*n+(m-1)*-1)/2 - m*(2*0+(m-1))/2 + 1 )
print(int((ans+1)%(10**9+7)))


Measured memory_bytes: 9084
{ Free PascalのHello, world.(日本語版) }
 
program Hello;
 
{$MODE OBJFPC}
{$CODEPAGE UTF8}
{$LONGSTRINGS ON}
 
uses
  SysUtils,
  Classes;

procedure MainFunc;
	procedure GetInput(var Length : Integer; var Num : Integer);
		var
			str : string;
			strlist : TStringList;
		begin
			Readln(str);
			strlist := TStringList.Create;
			try
				strlist.Delimiter := ' ';
				strlist.DelimitedText := str;
				Length := StrToInt(strlist.Strings[0]);
				Num := StrToInt(strlist.Strings[1]);
			finally
				FreeAndNil(strlist);
				end;
		end;
	var
		trainLength : Integer;
		trainNum : Integer; 
	begin
		GetInput(trainLength, trainNum);
		WriteLn(trainLength - trainNum + 1);
	end;
	
begin
	MainFunc;
end.


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
#define pb push_back
using namespace std;
const int N=2e5+10;
vector<int> G[N];int n,f[N],u,v,fa[N][20],c[N],d[N];
int get(int v,int t){
    int u=v;
    per(i,18,0) if(c[fa[fa[u][i]][0]]>v&&d[fa[u][i]]>=t) u=fa[u][i];
    return u;
}
void dfs(int u,int t){
    ++f[t];
    for(int &v:G[u]) if(v^fa[u][0]){
        d[v]=d[u]+1,c[v]=max(c[u],v),fa[v][0]=u;
        rep(i,1,18) fa[v][i]=fa[fa[v][i-1]][i-1];
        dfs(v,get(v,d[t]));
    }
}
void DFS(int u){for(int &v:G[u]) if(v^fa[u][0]) f[v]+=f[u],DFS(v);}
int main(){
    scanf("%d",&n);
    rep(i,1,n-1) scanf("%d%d",&u,&v),G[u].pb(v),G[v].pb(u);
    d[1]=1;c[1]=1;dfs(1,1);DFS(1);
    rep(i,2,n) printf("%d ",f[i]-1);
    return 0;
}

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

int main() {
	long long x;
	cin >> x;
	long long ans = x / 11 * 2;
	if (x % 11 > 6)
		ans += 2;
	else if (x % 11 > 0)
		ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

struct ModInt {
    ll v;
    static unsigned M;
    ModInt() : v(0) {}
    ModInt(ll x) : v((x % M + M) % M) {}

    ModInt& operator+=(const ModInt& r) {
        v = (v + r.v) % M;
        return *this;
    }
    ModInt& operator-=(const ModInt& r) {
        v = (v - r.v + M) % M;
        return *this;
    }
    ModInt& operator*=(const ModInt& r) {
        v = (v * r.v) % M;
        return *this;
    }
    ModInt& operator/=(const ModInt& r) {
        v = (v * r.pow(M - 2).v) % M;
        return *this;
    }
    ModInt operator-() const { return (M - v % M); }

    friend ModInt operator+(ModInt l, const ModInt& r) { return l += r; }
    friend ModInt operator-(ModInt l, const ModInt& r) { return l -= r; }
    friend ModInt operator*(ModInt l, const ModInt& r) { return l *= r; }
    friend ModInt operator/(ModInt l, const ModInt& r) { return l /= r; }
    friend bool operator==(ModInt l, const ModInt& r) { return l.v == r.v; }
    friend bool operator!=(ModInt l, const ModInt& r) { return !(l == r); }

    ModInt pow(ll n) const {
        ModInt base = *this, ans = 1;
        while (n) {
            if (n & 1) ans *= base;
            base *= base;
            n /= 2;
        }
        return ans;
    }
};
unsigned ModInt::M;
ostream& operator<<(ostream& o, const ModInt& r) {
    o << r.v;
    return o;
}

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

ModInt fact(ll n) {
    if (n == 0) return 1;
    return ModInt(n) * fact(n - 1);
}

ModInt comb(ll n, ll a) {
    return fact(n) * (fact(a) * fact(n - a)).pow(ModInt::M - 2);
}

ModInt prod(ll a, ll b) {
    ModInt ans = 1;
    loop (b, i) ans *= (a - i);
    return ans;
}

V<int> G[100010];
int k;
int vis[100010] = {};

ModInt dfs(int par, int node, int ancs, int sibs) {
    ModInt ans = 1;
    if (!vis[par]) {
        if (k - ancs < sibs) return 0;
        ans = prod(k - ancs, sibs);
        vis[par] = 1;
    }

    int n_sibs = 0;
    for (int c : G[node]) if (c != par) n_sibs++;
    for (int c : G[node]) {
        if (c == par) continue;
        ans *= dfs(node, c, min(ancs + 1, 2), n_sibs);
    }
    return ans;
}

int main() {
    ModInt::M = 1000000007;
    int n; cin >> n >> k;
    loop (n - 1, i) {
        int a, b; cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    cout << dfs(0, 1, 0, 1) << endl;
    return 0;
}




Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    string a, b; cin >> a >> b;
    ll syn = atoll((a+b).c_str());
    double sq = sqrt(syn);
    if(sq == ceil(sq)) Yes(); else No();
}

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

using namespace std;

int main(){
  	int N=0;
    cin >> N;
  
	int V[N], C[N];
    for (int i=0; i < N; i++){
    	cin >> V[i];	
    }
  
     for (int i=0; i < N; i++){
    	cin >> C[i];	
    }
  
  	int obj_vals[N];
    int obj_val=0;
  	for (int i=0; i < N; i++){
      obj_val = V[i] - C[i];
      
      if (obj_val <= 0){
      	obj_vals[i] = 0;
      }
      else{
      obj_vals[i] = obj_val;
      }
    }
  	
  	int sum_obj_vals=0;
    for (int i=0; i < N; i++){
    	sum_obj_vals += obj_vals[i];
    }
  	  
    cout << sum_obj_vals << endl;

	return 0;
}

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

typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int N, M;
  cin >> N >> M;
  vector<bool> l(N, false);
  for (int i = 0; i < M; i++) {
    int a;
    cin >> a;
    l[a] = true;
  }

  vector<ll> dp(N + 1, 0);
  dp[0] = 1;
  if (!l[1]) dp[1] = 1;
  for (int i = 2; i <= N; i++) {
    if (l[i]) {
      continue;
    }
    dp[i] = dp[i - 1] + dp[i -2];
    dp[i] %= MOD;
  }

  cout << dp[N] << endl;
  return 0;
}

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

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

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

    ll output = 0;
    ll div = 1000000007;
    ll init = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            if (A[i] > A[j]) {
                init++;
            }
        }
    }

    ll next = 0;
    for (int i = 0; i < 2 * N - 1; i++) {
        for (int j = i + 1; j < 2 * N; j++) {
            if (A[i % N] > A[j % N]) {
                next++;
            }
        }
    }

    next -= init * 2;

    output = K * init % div;
    ll tmp = K * (K - 1) / 2;
    tmp %= div;
    tmp *= next;
    tmp %= div;
    output += tmp;
    output %= div;

    cout << output << endl;

    return 0;
}


Measured memory_bytes: 3628
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.Writer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Niyaz Nigmatullin
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        FastPrinter out = new FastPrinter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, FastPrinter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            out.println(Math.min(solve(a, b, c), Math.min(solve(b, a, c), solve(c, a, b))));
        }

        static long solve(int a, int b, int c) {
            if ((a & 1) == 0) {
                return 0;
            }
            return (long) b * c;
        }

    }

    static class FastScanner extends BufferedReader {
        public FastScanner(InputStream is) {
            super(new InputStreamReader(is));
        }


        public int read() {
            try {
                int ret = super.read();
//            if (isEOF && ret < 0) {
//                throw new InputMismatchException();
//            }
//            isEOF = ret == -1;
                return ret;
            } catch (IOException e) {
                throw new InputMismatchException();
            }
        }

        static boolean isWhiteSpace(int c) {
            return c >= 0 && c <= 32;
        }

        public int nextInt() {
            int c = read();
            while (isWhiteSpace(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int ret = 0;
            while (c >= 0 && !isWhiteSpace(c)) {
                if (c < '0' || c > '9') {
                    throw new NumberFormatException("digit expected " + (char) c
                            + " found");
                }
                ret = ret * 10 + c - '0';
                c = read();
            }
            return ret * sgn;
        }

        public String readLine() {
            try {
                return super.readLine();
            } catch (IOException e) {
                return null;
            }
        }

    }

    static class FastPrinter extends PrintWriter {
        public FastPrinter(OutputStream out) {
            super(out);
        }

        public FastPrinter(Writer out) {
            super(out);
        }

    }
}



Measured memory_bytes: 8276
import copy
n,m,q=[int(_) for _ in input().split()]
lista=[[int(i) for i in input().split()] for j in range(q)]
v=list()  #0,0,0,0,0....,0
def make(a,b,c): #a=list b=maxlen c=max
    global v
    if len(a)==b:
        v.append(a)
    else:
        for i in range(a[-1],c+1):
            make(a+[i],b,c)
for t in range(1,m+1):
    make([t],n,m)
max=0
for j in v:
    point=0
    for l in lista:
        if j[l[1]-1]-j[l[0]-1]==l[2]:
            point+=l[3]
    if max<point:
        max=point
print(max)

Measured memory_bytes: 23204
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long N, K;
	cin >> N >> K;
	long long H[N];
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	sort(H, H + N);
	//H[N - 1] - H[N  - K]
	long long D[N];
	for (int i =K-1; i < N; i++) {
		D[i] = H[i] - H[i - K + 1];
	}
	for (int i = 0; i <= K - 2; i++) {
		D[i] = 1000000000;
	}
	sort(D, D + N );
	cout << D[0] << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int i,j;
    string s,t;
    cin>>s;
    cin>>t;
    int map_chars[26][26];
    memset(map_chars,0,sizeof(map_chars));
    for (i=0;i<s.size();i++)
        map_chars[s[i]-'a'][t[i]-'a']=1;
    int cnt,f=0;
    for (i=0;i<26;i++)
    {
        cnt=0;
        for (j=0;j<26;j++)
        {
            if (map_chars[i][j])
                cnt++;
        }
        if (cnt>1)
        {
            f=1;
            break;
        }
    }
    for (i=0;i<26;i++)
    {
        cnt=0;
        for (j=0;j<26;j++)
        {
            if (map_chars[j][i])
                cnt++;
        }
        if (cnt>1)
        {
            f=1;
            break;
        }
    }
    if (f)
        cout<<"No\n";
    else
        cout<<"Yes\n";
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int solve(){
    int a,b,n; cin>>a>>b>>n;
    int t=min(b-1,n);
    cout<<(a*t)/b;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cctype>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<string>

using namespace std;

int main()
{
    int n,i,j,k,l,c,m,d=0;
    char s[110],a[110]= {'\0'};
    scanf("%d %s",&n,s);
    for(i=1; i<n-1; i++)
    {
        int b[110]= {0};
        sort(s,s+i);
        a[0]=s[0];
        for(k=0,l=1; k<i; k++)
        {
            if(s[k]!=a[l-1])
            {
                a[l++]=s[k];
            }
        }
        for(j=i,c=0; j<n; j++)
        {
            for(m=0; m<l; m++)
            {
                if(s[j]==a[m]&&b[m]==0)
                {
                    c++;
                    b[m]=1;
                }
            }
        }
        d=max(c,d);
    }
    cout<<d<<endl;
    return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int K, X;

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

  std::cin >> K >> X;

  if(K * 500 >= X){
      std::cout << "Yes" << std::endl;
  }else{
      std::cout << "No" << std::endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1000000000000000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

struct edge { int to, cost; };
vector<edge> g[110000];
int d[110000];
int v,e,s,t;

void dijkstra(int s, int d[], vector<edge> g[]){
  priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> que;
  fill(d,d+v+1, INF);d[s] = 0;que.push(pair<int,int>(0,s));
  while(!que.empty()){
    pair<int,int> p = que.top();que.pop();
    int v = p.second;
    if(d[v]<p.first)continue;
    rep(i,g[v].size()){
      edge e = g[v][i];
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(pair<int,int>(d[e.to], e.to));
      }
    }
  }
}

signed main(){
  int x,y,z,k;cin>>x>>y>>z>>k;
  int a[1100], b[1100], c[1100];rep(i,x)cin>>a[i];rep(i,y)cin>>b[i];rep(i,z)cin>>c[i];
  vector<int> d(x*y);int ind = 0;
  rep(i,x){
    rep(j,y){
      d[ind] = a[i]+b[j];
      ind++;
    }
  }
  sort(d.begin(), d.end(),greater<int>());sort(c,c+z,greater<int>());
  deque<int> q;
  rep(i,z){
    rep(j,min(k,x*y)){
      q.push_back(c[i]+d[j]);
    }
  }
  sort(q.begin(), q.end(), greater<int>());
  rep(i,k){
    cout << q[i] << endl;
  }
}


Measured memory_bytes: 35252
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n, q; cin >> n >> q;
    string s; cin >> s;

    vector<int> cnt(n, 0);
    for(int i = 0; i < s.size(); i++)
    {
        if(s.substr(i, 2) == "AC")
        {
            cnt[i]++;
        }
    }

    vector<int> sum(n + 1, 0);
    for(int i = 0; i < s.size(); i++)
    {
        sum[i + 1] = sum[i] + cnt[i];
    }

    for(int i = 0; i < q; i++)
    {
        int l, r; cin >> l >> r;
        l--, r--;
        int ans = sum[r] - sum[l - 1];
        if(s[l] == 'C' && s[l - 1] == 'A') ans--;
        cout << ans << "\n";
    }
}

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

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

using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define debug(a) cout << #a << ": " << a << endl;

int main() {
  int N, D;
  cin >> N >> D;
  int ans = 0;
  ans = N / (D * 2 + 1);
  if (N % (D * 2 + 1) != 0)
    ans += 1;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

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

    ll n;
    cin >> n;
    ll ans =n-1;
    ll j;
    for(ll i=1;i*i<=n;i++){
        if (n%i ==0){
            j = n / i;
            ans = min(ans,i+j-2);
        }
    }
    cout << ans << endl;

        
}

Measured memory_bytes: 256
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break

    for i in range(H):
        if i == 0 or i == H - 1:
            print('#' * W)
        else:
            print('#' + '.' * (W - 2) + '#')
    print()


Measured memory_bytes: 5616
n, m = map(int, input().split())
shi = []
for i in range(m):
  pi, yi = map(int, input().split())
  shi.append([i, pi, yi])
  
shi.sort(key=lambda x:x[1:])
# print(shi)
x = 0
for i in range(m):
  x += 1
  shi[i].append("{:06d}{:06d}".format(shi[i][1], x))
  if i != m-1 and shi[i][1] != shi[i + 1][1]:
    x = 0
shi.sort(key=lambda x:x[0])
for i in range(m):
  print(shi[i][3])

Measured memory_bytes: 34232
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint s(n);
    rep(i, n) cin >> s[i];
    
    int sum = accumulate(all(s), 0);
    if (sum%10 != 0) {
        cout << sum << endl;
        return 0;
    }

    int ans = 0;
    sort(all(s));
    rep(i, n) {
        if (s[i]%10 != 0) {
            ans = sum - s[i];
            break;
        }
    }

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

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

int main()
{
    long long k=0;
    long long n,i,j,sum;
    cin>>n;
    long long a[n],b[210000]={0};
    for( i=0;i<n;i++)
    {
        cin>>a[i];
        b[a[i]]++;
    }
            sum=0;
    for(j=0;j<=n;j++)
    {
        sum+=(b[j]*(b[j]-1))/2;
    }
    while(k<n){
    cout<<sum-b[a[k]]+1<<endl;
    k++;
    }
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int vc[1000005];
int v2[1000005], a[1000005], b[1000005];
int main(){
	int n;
	string s;
	cin>>n>>s;
	memset(v2, 0, sizeof v2);
	for(int i=1;i<=1000000;i++){
		int x=i;
		while(x%2==0){
			x/=2;
			v2[i]++;
		}
	}
	vc[0]=0;
	for(int i=1;i<n;i++){
		vc[i]=vc[i-1]+v2[n-i]-v2[i];
	}
	bool bb=false;
	for(int i=0;i<n;i++){
		a[i]=(int)(s[i]-'1');
		b[i]=a[i]/2;
		if(a[i]==1) bb=true;
	}
	int m2=0;
	for(int i=0;i<n;i++){
		if(a[i]==1 && vc[i]==0){
			m2^=1;
		}
	}
	if(m2==1){
		cout<<1;
		return 0;
	}
	if(bb){
		cout<<0;
		return 0;
	}
	for(int i=0;i<n;i++){
		if(b[i]==1 && vc[i]==0) m2^=1;
	}
	cout<<2*m2;

}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
#define vi vector
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define FORR(i,a,b) for(int i=a;i>=b;i--)
#define mod 1000000007
#define pb push_back
#define ll long long int
#define db double
#define all(v) v.begin(),v.end()
#define inf 10000000000


using namespace std;

/*

ll expo(ll n){
    ll t;
    if(n==0)return 1;
    else if(n==1) return 2;
    t=expo(n/2);
    if(n%2){
        return t*t*2;
    }
    else return t*t;
}

//ffrom geek for geek
ll exponentMod(ll A, ll B, ll C)  
{  
    if (A == 0)  
        return 0;  
    if (B == 0)  
        return 1;  
    ll y;  
    if (B % 2 == 0) {  
        y = exponentMod(A, B / 2, C);  
        y = (y * y) % C;  
    }  
    else {  
        y = A % C;  
        y = (y * exponentMod(A, B - 1, C) % C) % C;  
    }  
  
    return (ll)((y + C) % C);  
}

*/
/*
class dsu{
public:    
vi<ll> v;


void init(ll n){
    v.assign(n+1,-1);
}

 
ll dsufind(ll x){
    if(v[x]<0){
        return x;
    }
    v[x]=dsufind(v[x]);
    return v[x];
}
 
void dsujoin(ll x,ll y){
    x=dsufind(x);
    y=dsufind(y);
    
    if(x==y)
    return;
    if(v[x]>v[y])swap(x,y);
    v[y]+=v[x];
    v[x]=y;
}

};
*/



int main(){
    IOS;
    ll t;
    t=1;
   //cin>>t;
    while(t--){
      ll n,x,y;
      cin>>n;
      vi<ll> v,v1,v2;

      FOR(i,n){
          cin>>x>>y;
          v.pb(x+y);
          v1.pb(y-x);
          v2.pb(x-y);
      }
      sort(v.begin(),v.end());
      sort(v1.begin(),v1.end());
      sort(all(v2));
      cout<<max((v[v.size()-1]-v[0]),(v1[v1.size()-1]+v2[v2.size()-1]))<<"\n";
    }    
    return 0;
} 

Measured memory_bytes: 8164
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        for(int i = 1;i < n;i++){
            for(int j = 1;j < n && j * i < n;j++){
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 36344
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allg(v) v.begin(), v.end(), greater<int>()
 
 
 
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(m);
  vector<int> d(m);
  rep(i, 0, n) cin >> a[i] >> b[i];
  rep(i, 0, m) cin >> c[i] >> d[i];
 
  rep(i, 0, n) {
    int mini = abs(a[i]-c[0]) + abs(b[i]-d[0]);
    int checkpoint = 1;
    rep(j, 1, m) {
      int dist = abs(a[i]-c[j]) + abs(b[i]-d[j]);
      if(mini > dist) {
        mini = dist;
        checkpoint = j+1;
      }
    }
    cout << checkpoint << "\n";
  }
  
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<iomanip>
using lint=int64_t;
using namespace std;

int main()
{
	int N;
	int A[110]={};

	cin >> N;
	for(int i=0;i<N;i++)
		cin >> A[i];
	
	double ans=0;
	for(int i=0;i<N;i++)
	{
		ans+=1.0/A[i];
	}
	cout << fixed << setprecision(7);
	cout << 1.0/ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

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

int pow(int x, int y) {
	int a = 1;
	rep(i, y) {
		a *= x;
	}
	return a;
}
int main() {
	int N;cin >> N;
	vector<int>dp(N + 1, INF);
	int m[] = { 1,6,9 };
	dp[0] = 0;
	dp[1] = 1;
	rep(i, N + 1) {
		rep(j, 3) {
			int a = m[j], b = a;
			if (i < m[j])continue;
			if (j > 0) {
				while (i >= b) {
					chmin(dp[i], dp[i - b] + 1);
					b *= a;
				}
			}
			else chmin(dp[i], dp[i - a] + 1);
		}
	}
	cout << dp[N] << "\n";

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;



int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n;i++) {
		cin >> a[i];
	}

	int min_i = 0;
	int max_i = 0;

	for (int i = 1; i < n;i++) {
		if (a[i] < a[min_i]) {
			min_i = i;
		}
		if (a[i] >a[max_i]) {
			max_i = i;
		}
	}
	
	cout << 2 * n -1<< endl;
	if ((-1*a[min_i]) <= (a[max_i])) {
		max_i++;
		for (int i = 1; i <=n;i++) {
			cout << max_i << " " << i << endl;
		}
		for (int i = 1; i < n;i++) {
			cout << i << " " << i+1 << endl;
		}
	}
	else {
		min_i++;
		for (int i = 1; i <= n;i++) {
			cout << min_i << " " << i << endl;
		}
		for (int i = n; i >1;i--) {
			cout << i << " " << i - 1 << endl;
		}
	}
}
	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
#define fst first
#define snd second
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> inline int Log2(T& x) {int k; for(k=0; (T(1)<<k)<=x; ++k); return k;} // number of binary digits


template<typename T>
vector<int> compress(vector<T> &v) {
  vector<T> t = v;
  sort(t.begin(), t.end());
  t.erase(unique(t.begin(), t.end()), t.end());
	vector<int> r(v.size());
  for (int i = 0; i < v.size(); i++) {
    r[i] = lower_bound(t.begin(), t.end(), v[i]) - t.begin();
  }
	return r;
}

template<typename T>
struct BIT {
  int n; vector<T> d;
  BIT(int n=0) : n(n), d(n+1) {}
  void add(int i, T a=1) {
    for (i++; i <= n; i += i & -i) d[i] += a;
  }
  // sum [0, i)
  T sum(int i) {
    if (i == 0) return 0;
    T x = 0;
    for (; i > 0; i -= i & -i) x += d[i];
    return x;
  }
};


int main() {
  ll N, K; cin >> N >> K;
  Vll a(N);
  rep(i, N) cin >> a[i];

  Vll S(N+1);
  rep(i, N) S[i+1] = S[i] + a[i] - K;
  V Sc = compress(S);

  int M = *max_element(all(Sc)) + 1;
  BIT<int> bit(M);

  ll ans = 0;
  rep(i, N+1) {
    int x = Sc[i];
    ans += bit.sum(x+1);
    bit.add(x);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5760