akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    vector<int> nums(3);
    rep(i, 3) cin >> nums.at(i);
    sort(nums.begin(), nums.end());

    int k;
    cin >> k;
    rep(i, k) nums.at(2) *= 2;
    cout << nums.at(0) + nums.at(1) + nums.at(2) << endl;
}


Measured memory_bytes: 3612
#include<iostream>
    #include<cmath>
    using namespace std;
    int main()
    {
    	int a,b,c;
    	cin>>a>>b>>c;
    	int max1=max(a,max(b,c));
    	int sum=a+b+c-max1;
    	int k;
    	cin>>k;
    	cout<<max1*pow(2,k)+sum<<endl;
    	return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <string.h>
int main() 
{ 
    int n,x,t;cin>>n>>x>>t;
    int q=n/x;
    int r=n%x;
    int point=0;
    point+=q*t;//cout<<point<<endl;
    if(r>0)
    point+=t;
    cout<<point;
        
}         

Measured memory_bytes: 3632
#include <climits>
#include <iostream>

using namespace std;

#define r(i, start, end) for (int(i) = (start); (i) < (end); (i)++)
#define rr(i, end, start) for (int(i) = (end); (i) >= (start); i--)
#define times(n) for (int i = 0; i < n; i++)
#define len(ar) (sizeof(ar) / sizeof(ar[0]))

// N = A + B && A>0 B>0

int getDigitSum(int n) {
  int sum = 0;
  while (n != 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  int min = INT_MAX, a, b, tmp;
  r(a, 1, N) {
    b = N - a;
    tmp = getDigitSum(a) + getDigitSum(b);
    if (min > tmp) min = tmp;
  }
  cout << min;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
long long H, W, K;
 
long long A[805][805];
long long WORK[805][805];
 
#define OPEN INT_MAX
#define CLOSED LONG_MAX/3
 
 
bool valid(long long h, long long w){
	return (h >= 0) && (h < H) && (w >= 0) && (w < W);
}
 
void move(long long h, long long w){
	queue<pair<long long, pair<long long, long long> > >Q;
	Q.push(make_pair(0, make_pair(h, w)));
	while(!Q.empty()){
		long long cost = Q.front().first;
		long long curh = Q.front().second.first;
		long long curw = Q.front().second.second;
		Q.pop();
		if(cost > K){
			break;
		}
		if(valid(curh, curw) == false || A[curh][curw] == CLOSED ||  A[curh][curw] <= cost){
			continue;
		}
		A[curh][curw] = cost;
		Q.push(make_pair(cost + 1, make_pair(curh-1, curw)));
		Q.push(make_pair(cost + 1, make_pair(curh+1, curw)));
		Q.push(make_pair(cost + 1, make_pair(curh, curw-1)));
		Q.push(make_pair(cost + 1, make_pair(curh, curw+1)));
	}
}
 
int main(){
	cin >> H >> W >> K;
 
	long long sh, sw;
	for(long long h = 0; h < H; h++){
		string S;
		cin >> S;
		for(long long w = 0; w < W; w++){
			if(S[w] == '.'){
				A[h][w] = OPEN;
			}else if(S[w] == 'S'){
				sh = h;
				sw = w;
				A[h][w] = 1;
			}else{
				A[h][w] = CLOSED;
			}
		}
	}
 
	move(sh, sw);
 
	long long ans = INT_MAX;
	for(long long h = 0; h < H; h++){
		for(long long w = 0; w < W; w++){
			if(A[h][w] != OPEN && A[h][w] != CLOSED){
				long long tmp;
				tmp = h;
				tmp = min(tmp, w);
				tmp = min(tmp, H - h - 1);
				tmp = min(tmp, W - w - 1);
				if(tmp % K == 0){
					ans = min(ans, tmp/K);
				}else{
					ans = min(ans, tmp/K + 1);
				}
			}
		}
	}
	cout << ans + 1 << endl;
}


Measured memory_bytes: 6400
#include<stdio.h>
#include<algorithm>
using namespace std;
int x[100000];
int y[100000];
int sx[100000];
int sy[100000];
long long abs(long long a){return a>=0?a:-a;}
long long max(long long a,long long b){return a>b?a:b;}
int main(){
	int w,h,n,i,j,k;
	scanf("%d %d %d",&w,&h,&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&sx[i],&sy[i]);
		x[i]=sx[i];
		y[i]=sy[i];
	}
	if(n==1){
		printf("0\n");
		printf("%d %d\n",x[0],y[0]);
		return 0;
	}
	sort(x,x+n);
	sort(y,y+n);
	int m=(n-1)/2;
	long long ans=1000000000000000LL;
	int ax,ay;
	for(i=m;i<=m+1;i++){
		for(j=m;j<=m+1;j++){
			long long res=0;
			long long mx=0;
			for(k=0;k<n;k++){
				long long dis=abs(sx[k]-x[i])+abs(sy[k]-y[j]);
				res+=dis*2;
				mx=max(mx,dis);
			}
			res-=mx;
			if(res<ans){
				ans=res;
				ax=x[i];
				ay=y[j];
			}
		}
	}
	printf("%lld\n%d %d\n",ans,ax,ay);
	return 0;
}

Measured memory_bytes: 2600
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a[] = new int[]{105,135,165,189,195};
        int n = scanner.nextInt();
        int k = 0;
        for (int b:a){
            if(b <= n)++k;
        }
        System.out.println(k);
    }

}


Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String s1 = scan.next();
		String s2 = scan.next();
		String s3 = scan.next();
		String s = String.valueOf(s1.charAt(0))+String.valueOf(s2.charAt(0))+String.valueOf(s3.charAt(0));
		System.out.println(s.toUpperCase());
	}

}


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

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vi;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nl cout<<'\n'
#define pb push_back
#define all(s) s.begin(),s.end()
#define bs binary_search

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a)*(b)/(__gcd((a),(b)))

const int Mod=1e9+7;
#define sum(a,b) (((a)%Mod)+((b)%Mod))%Mod
#define sub(a,b) (((a)%Mod)-((b)%Mod))%Mod
#define mul(a,b) (((a)%Mod)*((b)%Mod))%Mod
#define digit(x) floor((log10(x))+1)


#define count1(x) __builtin_popcount(x)

#define dbg(x) cout << #x <<":"<<x<<endl;

bool isPowerOfTwo (int x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
} 

ll pow(ll x, ll y, ll mod)
{
	int ans=1;
	while(y)
	{
		if(y&1)
			ans=(ans*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}
	return ans;
}

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

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
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==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}


signed main(){
    int k;cin>>k;
    rep(i,k) cout<<"ACL";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <math.h>

double L(double x1, double y1, double x2, double y2){
	return sqrt(pow(x1-x2,2)+pow(y1-y2,2));
}

double S(double a, double b, double c){
	double s = (a+b+c)/2;
	return sqrt(s*(s-a)*(s-b)*(s-c));
}
	
int main(void){
	double x1,y1,x2,y2,x3,y3,xp,yp,a,b,c,pa,pb,pc;
	while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
				  &x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
		a = L(x1,y1,x2,y2);
		b = L(x1,y1,x3,y3);
		c = L(x2,y2,x3,y3);
		pa = L(x3,y3,xp,yp);
		pb = L(x2,y2,xp,yp);
		pc = L(x1,y1,xp,yp);
		if (S(a,pb,pc)+S(b,pc,pa)+S(c,pa,pb)-S(a,b,c) > 0.0000001){
			puts ("NO");
		}else{
			puts ("YES");
		}
	}
	return 0;
}

Measured memory_bytes: 612
#include <stdio.h>
#define SIZE 1200

int main(void)
{
	int i, c;

	for (i = 0; i < SIZE; i++)
	{
		c = getchar();		
		if (c == '\n')
			break;
		else if (c >= 'A' && c <= 'Z')
			c = c + 'a' - 'A';
		else if (c >= 'a' && c <= 'z')
			c = c + 'A' - 'a';
		putchar(c);
	}
	putchar('\n');
	return 0;
}

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

int main()
{
    double a, b, x; cin >> a >> b >> x;
    double s = x/a;
    double rad;
    if(s >= a*b/2){
        double h = (a*b-s)*2/a;
        rad = atan2(h, a);
    }else{
        double w = s*2/b;
        rad = atan2(b, w);
    }
    double Pi = acos(-1);
    double ans = rad/(2*Pi)*360;
    printf("%.10f\n", ans);
    system("pause");
}

Measured memory_bytes: 632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		//?????£?????????
		String strInput = null;

		int intTime = 0;
		int h = 0;
		int m = 0;
		int s = 0;

		try {
			BufferedReader strLine = new BufferedReader(new InputStreamReader(System.in));
			strInput = strLine.readLine();

			intTime = Integer.parseInt(strInput);

			//??\?????°???????????§??????

			if (intTime >= 0 && intTime < 86400) {

				h = intTime / 3600;

				m = (intTime % 3600) / 60;

				s = (intTime % 3600) % 60;

				//???????????????
				System.out.println(h + ":" + m + ":" + s);
			}
			/*else {
				System.out.println("intTime is Error");
			}*/
			//??¨????????????
		} catch (IOException e1) {
			System.out.println(e1);
		}catch (NumberFormatException e2) {
			System.out.println(e2);
		}
	}

}

Measured memory_bytes: 24320
import copy


n = int(input())
M = []
for _ in range(n):
    m = input().split()
    M.append([m[0], int(m[1])])

_M = copy.deepcopy(M)


def group(arr):
    r = {}
    for a in arr:
        if r.get(a[1]):
            r[a[1]] += a[0]
        else:
            r[a[1]] = a[0]

    return r


def partition(p, r):
    x = M[r][1]
    i = p - 1
    for k in range(p, r):
        if M[k][1] <= x:
            i += 1
            M[i], M[k] = M[k], M[i]
    M[i + 1], M[r] = M[r], M[i + 1]
    return i + 1


def quick_sort(p, r):
    if p < r:
        q = partition(p, r)
        quick_sort(p, q - 1)
        quick_sort(q + 1, r)


quick_sort(0, n - 1)

if group(_M) == group(M):
    print('Stable')
else:
    print('Not stable')

for m in M:
    print(m[0], m[1])



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

int main() {
	// your code goes here
	int x,a,b;
	cin>>x>>a>>b;
	if(abs(x-a)>abs(x-b))
	{
		cout<<"B"<<endl;
	}
	else
	{
		cout<<"A"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
s = int(input())


def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return n * 3 + 1


sset = {s}
ss = s
for i in range(2, 2**32):
    prev_len = len(sset)
    ss = f(ss)
    sset.add(ss)
    next_len = len(sset)
    if prev_len == next_len:
        print(i)
        break


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

int main(void){
		map<int,int> m;
		int n;
		cin>>n;
		int a[n];
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		m[a[0]]=1;
		m[a[1]]=1;
		m[a[0]*10+a[1]]=1;
		for(int i=2;i<n;i++){
			m[a[i-2]*100+a[i-1]*10+a[i]]=1;
			m[a[i-1]*10+a[i]]=1;
			m[a[i]]=1;
		}
		for(int i=0;i<1000;i++){
			if(!m[i]) return cout<<i<<endl,0;
		}
		return cout<<1000<<endl,0;
    return 0;
}



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

int main() {
    int n, d;
    int x[10][10];
    int i, j, k;
    int ret = 0;

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

    for(i = 0; i < n; i++) {
        for(j = i + 1; j < n; j++) {
            double distance_sum = 0;
            for(k = 0; k < d; k++) {
                distance_sum += pow(abs(x[i][k] - x[j][k]),2);
            }
            double distance = sqrt(distance_sum);
            if((distance - floor(distance)) == (double)0 ) {
                ret += 1;
            }
        }
    }

    cout << ret << endl;
}

Measured memory_bytes: 256
import math


def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())
    s = int(input().rstrip())
    opened = set()
    opened.add(s)
    prev = s
    m = 1
    while True:
        m += 1
        y = int(prev / 2) if prev % 2 == 0 else (3 * prev + 1)
        if y in opened:
            print(m)
            break
        prev = y
        opened.add(y)









if __name__ == "__main__":
    resolve()


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

string str[2][10],s,e;
int n,ans;

void bfs(string S,int cnt){
	if(S==e) ans=min(ans,cnt);
	else if(S.size()>=e.size())return;
	cnt++;
	rep(i,n){
		string tmp;
		rep(j,S.size()){
			int x=str[0][i].size();
			if(j+x-1<S.size()&&S.substr(j,x)==str[0][i]){
				tmp+=str[1][i];
				j+=x-1;
			} else tmp.push_back(S[j]);
		}
		if(tmp!=S)bfs(tmp,cnt);
	}
}

int main(){
	while(cin>>n,n){
		rep(i,n)cin>>str[0][i]>>str[1][i];
		cin>>s>>e;
		ans=1000;
		bfs(s,0);
		if(ans==1000)ans=-1;
		cout<<ans<<endl;
	}
}

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

#define vint vector<int>
#define vvint vector<vint>
#define rep(i, n) for(int i=0;i<(int)(n);i++) // 繰り返し処理
#define all(x) (x).begin(),(x).end() // 全体 こんな感じで使う→sort(all(a));
#define ct(a) cout << a << endl
#define iceil(a,b) (a+(b-1))/b //int ceil : 繰り上げの割り算 通常のceilではceil((7.0/2.0))のようにしなければならなかった。
vint CinLine(int N){vint v(N);for(int i=0;i<N;i++){cin >> v.at(i);}return v;}//cin line 連続でvectorに格納
void CoutLine(vint v){for(int i=0;i<v.size()-1;i++){cout<<v.at(i)<<" ";}cout << v.at(v.size()-1)<<endl;}

void Main(){
    string s;
    cin >> s;
    if(s == "ABC"){
        ct("ARC");
    }else {
        ct("ABC");
    }
}

int main() {
    Main();
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
#define mod 200003
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
using vvb=vector<vector<bool>>;
using vb= vector<bool>;
ll f(ll a,ll b,ll p){
	if(b==0) return 1;
	if(b%2==0){
		ll t=f(a,b/2,p);
		return t*t%p;
	}
	return a*(f(a,b-1,p))%p;
} 

//__builtin_popcount()
signed main(){
	ll n; cin>>n;
	map<ll,ll> mp;
	rep(i,0,n){
		ll a; cin>>a;
		mp[a]++;
	}
	ll ans=0;
	for(auto c:mp){
		if(c.second>c.first)ans+=(c.second-c.first);
		if(c.first>c.second)ans+=c.second;
	}
	cout<<ans<<endl;



	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<int> D(N);
    rep(i, N) cin >> D[i];
    int ans = 0;
    rep(i, N) {
        rep2(j, i + 1, N) {
            ans += D[i] * D[j];
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
int main(){
    int n;
    cin>>n;
    bool ok=false;
    for (int i = 1; i < 10; i++)
    {
        /* code */
        for (int j = 1; j <10 ; j++)
        {
            /* code */
            if (i*j==n)
            {
                /* code */
                ok=true;
                break;
            }
            
        }
        
    }
    if (ok)
    {
        /* code */
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    
    
        
   }

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
use std::collections::HashSet;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let a: u64 = input();
    let b: u64 = input();
    let mut nums: HashSet<u64> = HashSet::new();
    nums.insert(1);
    nums.insert(2);
    nums.insert(3);
    nums.remove(&a);
    nums.remove(&b);
    for n in nums {
        println!("{}", n);
    }
}


Measured memory_bytes: 4352
a,b,k=map(int,input().split())
ans=[]
for i in range(a,min(a+k,b+1)):
    ans.append(i)
for j in range(b,max(b-k,a-1),-1):
    if j not in ans:
        ans.append(j)
ans.sort()
for k in range(len(ans)):
  print(ans[k])



Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
const db pi = acos(-1.0);
inline LL gcd(LL a, LL b) {return a % b == 0 ? b : gcd(b, a % b);}
inline LL read() {
    LL 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;
}
LL a, b, c, d;
int main() {
    a = read(); b = read();
    c = read(); d = read();
    printf("%lld\n", a * b - a * d - b * c + c * d);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    int K; cin >> K;
    mat c;
    int n;
    if(K <= 2){
        n = K;
        c = mat(n, vec(n));
        REP(i, n) REP(j, n) c[i][j] = i;
    }else{
        n = 2;
        while(2 * n < K) n += 2;
        c = mat(n, vec(n));
        REP(i, n) REP(j, n){
            c[i][j] = n * (i % 2) + (i + j) % n;
            if(c[i][j] >= K) c[i][j] -= n;
        }
    }

    cout << n << endl;
    REP(i, n){
        REP(j, n) cout << c[i][j] + 1 << " ";
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

signed main()
{
    int t;
    cin >> t;
    cout << ((t/1000+1)*1000 - t)%1000;    
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int M=1e5+5;
int A[M];
int main(){
	int n;
	scanf("%d",&n);
	if(n&1) puts("1");
	for(int i=1; i<=n; i++) scanf("%d",&A[i]);
	sort(A+1,A+n+1);
	int r=(n>>1)+1,l=n>>1;
	while(A[l]==A[l-1]) l--;
	while(A[r]==A[r+1]) r++;
	printf("%d\n",A[r]-A[l]);
	return 0;
}

Measured memory_bytes: 640
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>

using namespace std;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	map<int,int> tmp;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		tmp[A]++;
		tmp[A - 1]++;
		tmp[A + 1]++;
	}
	vector<pair<int, int>> p;
	for (const auto& i : tmp) {
		p.emplace_back(i.second, i.first);
	}
	sort(p.begin(), p.end());
	cout << p.crbegin()->first << endl;
	return 0;
}


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

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}


bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}

bool palin(string S){//回文判定
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
/*vector<int> d(N+1,-1);

//頂点xとの各点との最短距離を求める
void bfs(int x,Graph &G){
  d[x] = 0;
  queue<<int> que;
  que.push(x);

  // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
}*/

int main(){
  int N;
  cin >> N;
  double M;
  cin >> M;
  vector<double> A(N);
  rep(i,N){
    cin >> A[i];
  }
  double c = 0;
  double sum = 0;
  rep(i,N){
    sum += A[i];
  }
  // cout << sum << " " << sum/(4*M) << endl;
  rep(i,N){
    if(A[i] >= sum/(4*M)) c++;
  }
  if(c >= M) cout << "Yes" << endl;
  else cout << "No" << endl;
 }


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



int main()
{
	int N;
	while(cin>>N)
	{
		int temp=N;
		int count=0;
		while(temp)
		{
			int p=temp%10;
			temp/=10;
			if(p==2) count++;
		}
		cout<<count<<endl;
	}



	return 0;
}


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

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll N,A,B;

void solve(){
    cout << min(N*A,B) << endl;
}

int main(){
    cin >> N >> A >> B;

    solve();
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
static const int MAXN = 104;
static const int ALPHA = 26;

int h, w;
int ct[ALPHA] = { 0 };
int groups[5] = { 0 };

int main()
{
    scanf("%d%d", &h, &w); getchar();
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j)
            ++ct[getchar() - 'a'];
        getchar();
    }

    for (int i = 0; i < (h + 1) / 2; ++i)
        for (int j = 0; j < (w + 1) / 2; ++j) {
            int u = 1;
            if (i * 2 != h - 1) {
                u += 1;
                if (j * 2 != w - 1) u += 2;
            } else {
                if (j * 2 != w - 1) u += 1;
            }
            groups[u] += 1;
        }

    for (int i = 0; i < ALPHA; ++i) {
        for (int j = 4; j >= 1; --j) {
            int dec = std::min(groups[j], ct[i] / j);
            ct[i] -= j * dec;
            groups[j] -= dec;
        }
    }

    bool valid = true;
    for (int i = 1; i <= 4; ++i) if (groups[i] > 0) valid = false;
    puts(valid ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var NAB = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, A, B) = (NAB[0], NAB[1], NAB[2]);

        var ans = Math.Min(A * N, B);

        WriteLine(ans);
    }
}


Measured memory_bytes: 28128
import numpy as np
n,m,x = map(int,input().split())
c = []
A = np.array([[0]*m for _ in range(n)])
for i in range(n):
  a = list(map(int,input().split()))
  c.append(a[0])
  A[i] = np.array(a[1:])
ans = 10**18
for i in range(2**n):
  cost = 0
  u = np.array([0]*m)
  for j in range(n):
    if i >> j & 1:
      cost += c[j]
      u += A[j]
  flag = 1
  for j in range(m):
    if u[j] < x:
      flag = 0
  if flag == 1:
    ans = min(cost,ans)
if ans == 10**18:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 27220
#include <stdio.h>
#include <string.h>
 
int N;
char a[10000];
char b[10000];
 
int main() {
    scanf("%d", &N);
    
    char a[10000], b[10000];
    int i;
    for(i = 0; i < N; ++i) {
        scanf("%s", a);
        scanf("%s", b);	
        
        int alen = (int)strlen(a),
            blen = (int)strlen(b);
        if(alen > 80 || blen > 80) {
            printf("overflow\n");
            continue;
        }
        
        int j = 0, carry = 0;
        int out[82];
        while(alen || blen) {
        	out[j] = carry;
            if(alen) {
                --alen;
                out[j] += a[alen] - '0';
            }
            if(blen) {
                --blen;
                out[j] += b[blen] - '0';
            }
            carry = out[j] / 10;
            out[j] %= 10;
            ++j;
        }
        
        if(carry) {
        	out[j] = 1;
        }else {
        	--j;
        }
        if (j >= 80) {
            printf("overflow\n");
            continue;
        }
        for(; j >= 0; --j){
        	printf("%d", out[j]);
        }
           
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 2048
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from heapq import heappop,heappush

n,m = map(int,readline().split())
a = list(map(int,readline().split()))
xy = list(map(int,read().split()))

if(n-m==1):
    print(0)
    exit()

p = ((n-1)-m)*2
if( p > n):
    print('Impossible')
    exit()

sys.setrecursionlimit(10**9)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self,x):
        if(self.parents[x] < 0):
            return x
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def size(self, x):
        return self.parents[ self.find(x) ] * -1

    def same(self, x, y):
        x_root = self.find(x)
        y_root = self.find(y)
        return (x_root == y_root)

    def union(self,x,y):
        x_root = self.find(x)
        y_root = self.find(y)
        if(x_root == y_root):
            return

        if( self.parents[x_root] <= self.parents[y_root] ):
            self.parents[x_root] += self.parents[y_root]
            self.parents[y_root] = x_root
        else:
            self.parents[y_root] += self.parents[x_root]
            self.parents[x_root] = y_root

    def members(self,x):
        root = self.find(x)
        ret = [ i for i in range(self.n) if self.find(i) == root ]
        return ret

    def roots(self):
        ret = [ i for i in range(self.n) if self.parents[i] < 0]
        return ret

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

uf = UnionFind(n)
hqs = [[] for _ in range(n)]

it = iter(xy)
for x,y in zip(it,it):
    uf.union(x,y)

for i in range(n):
    root = uf.find(i)
    heappush(hqs[root], a[i])

ans = []
others = []
for i in range(n):
    if(hqs[i]):
        ans.append(heappop(hqs[i]))
        for j in hqs[i]:
            others.append(j)

others.sort()
rem = p - len(ans)
ans = ans + others[:rem]

print(sum(ans))

Measured memory_bytes: 112200
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef string::const_iterator SC;
const int MOD = 1000000007;
const ll INF=2e18;

string s;
string p;
map<char,ll> mp;
ll Letter(SC &it){
    ll ret= mp[*it];
    it++;
    return ret;
}
ll Hash(SC &it){
    if(isalpha(*it)){
        return Letter(it);
    }
    else{
        it++;//[
        char op=*it;
        it++;//op
        ll l=Hash(it);
        ll r=Hash(it);
        it++;//]
        if(op=='+'){
            return l | r;
        }else if(op=='*'){
            return l & r;
        }else{
            return l^r;
        }
    }
}
int main(){
    while(cin>>s,s[0]!='.'){
        cin>>p;
        mp['a']=p[0]-'0';
        mp['b']=p[1]-'0';
        mp['c']=p[2]-'0';
        mp['d']=p[3]-'0';
        SC it=s.begin();
        ll hashNum=Hash(it);
        cout<<hashNum<<" ";
        ll ans=0;
        for(ll i=0;i<10000;i++){
            ll tmp=i;
            ll t[4];
            for(ll j=0;j<4;j++){
                ll mod=pow(10,3-j);
                t[j]=tmp/mod;
                tmp%=mod;
            }
            mp['a']=t[0];
            mp['b']=t[1];
            mp['c']=t[2];
            mp['d']=t[3];
            it=s.begin();
            if(Hash(it)==hashNum){
                ans++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 3380
n = int(input())
S1 = input()
S2 = input()
m = 1000000007

if S1[0] == S2[0]:
    p = 3
    v = True
    i = 1
else:
    p = 6
    v = False
    i = 2
while(i < n):
    if S1[i] == S2[i]:
        p = (p*2 if v else p) % m
        v = True
        i += 1
    else:
        p = (p*2 if v else p*3) % m
        v = False
        i += 2
print(p)


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	// 蟻本のDP

	// input
	int d, g;
	cin >> d >> g;

	vector<int> p(d), c(d);
	for (int i = 0; i < d; i++) {
		cin >> p[i] >> c[i];
	}

	// pSum
	int pSum = accumulate(begin(p), end(p), 0);

	// dp[i番目][スコア]
	vector<vector<int>> dp(d + 1, vector<int>(pSum + 1));
	// for 1 in d
	for (int i = 1; i <= d; i++) {
		// for j in pSum
		for (int j = 1; j <= pSum; j++) {
			// 最大値 = 前のスコア
			int ma = dp[i - 1][j];

			// 前の手順
			for (int k = j - 1; k >= 0; k--) {
				if (k < (j - p[i - 1])) {
					break;
				}
				// 基本得点
				ma = max(ma, dp[i - 1][k] + (j - k) * 100 * i);

				if (k == j - p[i - 1]) {
					// コンプリート
					ma = max(ma, dp[i - 1][k] + (j - k) * 100 * i + c[i - 1]);
				}

				// 前の手が0
				//if (k == 0) {
				//	break;
				//}
			}

			// dp 更新
			dp[i][j] = ma;
		}
	}

	// output
	for (int i = 0; i <= pSum; i++) {
		if (dp[d][i] >= g) {
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


//int main(){
//    cin.tie(0);
//    ios_base::sync_with_stdio(false);
//
//    int N, M;
//    cin >> N >> M;
//
//    int m[N];
//    REP(i, N) m[i] = N;
//    REP(i, M) {
//        int a, b;
//        cin >> a >> b;
//        --a; --b;
//        m[a] = min(m[a], b);
//    }
//
//    int ans = 1;
//    int r = N;
//    REP(i, N) {
//        if (m[i] == N) continue;
//
//        if (i < r) {
//             r = min(r, m[i]);
//            continue;
//        }
//
//        r = m[i];
//        ++ans;
//    }
//
//    cout << ans << endl;
//
//}

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

    int N, M;
    cin >> N >> M;

    vector<pair<int, int>> m(N);
    REP(i, N) {
        m[i].fi = N;
        m[i].se = i;
    }
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        m[a].fi = min(m[a].fi, b);
    }

    sort(m.begin(), m.end());

    int ans = 0;
    int l = -1;
    REP(i, N) {

        if (l <= m[i].se) {
            l = m[i].fi;
            if (l >= N) break;
            ++ans;
        }
    }

    cout << ans << endl;

}


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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	int cost;
} edge;
vector <ll> calc( int N ){
	vector <ll> hoge( N + 1 );
	hoge[ 0 ] = 0;
	ll b = 1;
	rep( i, 0, N ){
		b *= 26;
		hoge[ i + 1 ] = b + hoge[ i ];
	}
	return hoge;
}

int main( void ){
	// initialize();
	vector <ll> hoge = calc( 11 );
	ll N; cin >> N;
	int index = 0;
	rep( i, 1, 12 ){
		if (N <= hoge[ i ]){
			index = i;
			N -= hoge[ i - 1 ] + 1;
			break;
		}
	}
	vector <char> output;
	ll base = 1;
	rep( i, 0, index ){
		int d = ( N / base ) % 26;
		output.push_back(( char )( 'a' + d ));
		base *= 26;
	}
	rep_d(i, index, 0){
		cout << output[i];
	}
	cout << endl;
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;

int main(){
  int k, n;
  cin >> k >> n;
  int kmax = n + k - 1;
  int kmin = n - k + 1;
  for(int i = kmin; i <= kmax; i++){
    if(i != kmax){
      cout << i << " ";
    }else{
      cout << i << "\n";
    }
    
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        string s,t;
        int n;
        cin >> n;
        cin >> s >> t;
        for(int i = 0; i < n; i++){
            cout << s[i] << t[i];
        }
        cout << '\n';
    }
}

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

int main(){
	// sengen
	double a,b,h,m;
	// nyuryoku
	cin >> a >> b >> h >> m;
	// keisan
	double kakudo = M_PI/6*(h+m/60) - M_PI/30*m;
	cout << setprecision(15) << sqrt(a*a + b*b -2*a*b*cos(kakudo));
	// syutsuryoku
}

Measured memory_bytes: 4212
#pragma comment(linker, "/STACK:102c000000,102c000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <list>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
// #include <conio.h>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
const int N = 3*1e6+10;
const int MOD = 1e9+7;
#define LL long long
#define mi() (l+r)>>1
double const pi = acos(-1);

void fre() {
    freopen("in.txt","r",stdin);
}

// inline int r() {
//     int x=0,f=1;char ch=getchar();
//     while(ch>'9'||ch<'0') {if(ch=='-') f=-1;ch=getchar();}
//     while(ch>='0'&&ch<='9') { x=x*10+ch-'0';ch=getchar();}return x*f;
// }

LL Gcd(LL a,LL b){ return b? Gcd(b, a % b) : a; }
int main()
{
    LL n,x; cin >> n >> x;
    LL d = Gcd(n,x);
    cout << d * (n/d*3-3) << endl;
}

Measured memory_bytes: 256
DBG = true
#n,a,b = gets.split.map{|z| z.to_i}
n,a,b = gets.split
n = n.to_i
a = a.to_i
b = b.to_i
mx = [a,b].min
mn = [a+b-n, 0].max
puts "#{mx} #{mn}"


Measured memory_bytes: 1788
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

using namespace std;

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}
template <class Con>
string concat(const Con &c, const string &spr){
	stringstream ss;
	typename Con::const_iterator it = c.begin(), en = c.end();
	bool fst = true;
	for(; it != en; ++it){
		if(!fst){ ss << spr; }
		fst = false;
		ss << *it;
	}
	return ss.str();
}

template <class Con, class Fun>
vector<typename Con::value_type> cfilter(const Con &c, Fun f) {
	vector<typename Con::value_type> ret;
	typename Con::const_iterator it = c.begin(), en = c.end();
	for(; it != en; ++it){
		if(f(*it)){
			ret.emplace_back(*it);
		}
	}
	return ret;
}
#if __cplusplus >= 201103L
template <class Con, class Fun>
auto cmap(const Con &c, Fun f) -> vector<decltype(f(*c.begin()))> {
	vector<decltype(f(*c.begin()))> ret;
	ret.reserve(c.size());
	for(const auto &x: c){
		ret.emplace_back(f(x));
	}
	return ret;
}
#endif


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()
#define tget(t,i) get<i>(t)

#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n;
	scanf("%d", &n);
	LL mina = LLONG_MAX, maxa = LLONG_MIN;
	LL minb = LLONG_MAX, maxb = LLONG_MIN;
	for(int i = 0; i < n; ++i){
		LL x, y;
		scanf("%lld%lld", &x, &y);
		LL a = x + y;
		LL b = x - y;
		chmin(mina, a);
		chmax(maxa, a);
		chmin(minb, b);
		chmax(maxb, b);
	}
	LL ans = max(maxa - mina, maxb - minb);
	printf("%lld\n", ans);
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(const exception &e){
	cerr << "exception: " << e.what() << endl;
	abort();
}
catch(...){
	cerr << "exception" << endl;
	abort();
}


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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) if((x)>(y))(x)=(y)
#define chmax(x,y) if((x)<(y))(x)=(y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// dp[i]: [0,i)のステージをクリアする順序の個数
int n, t, d[100100];
ll dp[100100];

signed main() {
	cin >> n >> t;
	rep(i,n) cin >> d[i];
	sort(d,d+n);
	
	dp[0] = 1;
	rep(i,n) dp[i+1] = dp[i] * (i - (lower_bound(d,d+i,d[i]-t)-d) + 1) %mod;
	cout << dp[n] << ln;
}


Measured memory_bytes: 4328
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<limits.h>

int main(){
	int d, n, tmp;
	scanf("%d %d\n", &d, &n);
	if(d==0) tmp = 1;
	else if(d==1) tmp = 100;
	else tmp = 10000;
	if(n!=100)
		printf("%d\n", n*tmp);
	else
		printf("%d\n", 101*tmp);
	return 0;
}




Measured memory_bytes: 128
//I_F_A
#include "bits/stdc++.h"
using namespace std;

int main(){

	long long n,m;
	cin >> n >> m;

	char arr[n+1][n+1],brr[m+1][m+1];
	
	for(long long i=1;i<=n;i++)
		for(long long j=1;j<=n;j++)
			cin >> arr[i][j];

	for(long long i=1;i<=m;i++)
		for(long long j=1;j<=m;j++)
			cin >> brr[i][j];

	bool found = 0;

	for(long long i=1;i+m-1<=n;i++){

		for(long long j=1;j+m-1<=n;j++){

			bool wrong = 0;
			for(long long k=i;k<=i+m-1;k++){

				for(long long t=j;t<=j+m-1;t++){

					if(brr[k-i+1][t-j+1] != arr[k][t]){

						wrong = 1;
					}
				}
			}
			if(wrong == 0)
				found = 1;
		}
	}
	if(found == 1)
		cout << "Yes\n";
	else
		cout << "No\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <limits.h>

struct PatternA {
	int a, b, c;
	PatternA(int a0, int b0, int c0) : a(a0), b(b0), c(c0) {}
	PatternA() : a(0), b(0), c(0) {}
	bool operator<(const PatternA& o) const {
		if (a - b == o.a - o.b) {
			return c < o.c;
		}
		else {
			return a - b < o.a*b;
		}
	}
};
struct PatternB {
	int a, b, c;
	PatternB(int a0, int b0, int c0) : a(a0), b(b0), c(c0) {}
	PatternB() : a(0), b(0), c(0) {}
	bool operator<(const PatternB& o) const {
		if (a * o.b == o.a * b) {
			return c < o.c;
		}
		else {
			return a*o.b > o.a*b;
		}
	}
};

int buf[401][401];

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

	memset(buf, 0, sizeof(int)*40*40);

	for (int i = 0; i < n; i++) {
		for (int j = 400; j >= 0; j--) {
			for (int k = 400; k >= 0; k--) {
				if (buf[j][k] > 0 || j==0 && k==0) {
					if (buf[j + a[i]][k + b[i]] == 0) {
						buf[j + a[i]][k + b[i]] = buf[j][k] + c[i];
					}
					else {
						buf[j + a[i]][k + b[i]] = std::min(buf[j + a[i]][k + b[i]], buf[j][k] + c[i]);
					}
				}
			}
		} 
	}

	int ret = INT_MAX;
	for (int i = 0; i <= 400; i++) {
		for (int j = 0; j <= 400; j++) {
			if (buf[i][j] > 0 && i * mb == ma * j) {
				ret = std::min(ret, buf[i][j]);
			}
		}
	}
	if (ret == INT_MAX) {
		ret = -1;
	}
	printf("%d\n", ret);
	return 0;
}


Measured memory_bytes: 512
n = int(input())

def yak(n):
  lis = []
  for i in range(1,n+1):
    if n%i==0: lis.append(i)
  return lis

cnt = 0
for i in range(1, n+1):
  if i%2==1:
    l = len(yak(i))
    if l == 8:
      cnt += 1
      
print(cnt)

Measured memory_bytes: 38768
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define LL long long

using namespace std;

double a,b;

int main()
{
    cin >>a>>b;
    for (int i=1;i<=10000;i++) if ( (int)floor(0.08*i)==a && (int)floor(0.1*i)==b  )
    {
        printf("%d\n",i);
        return 0;
    }


    printf("-1");
    return 0;
}


Measured memory_bytes: 256