akhauriyash/Code-Regression huggingface dataset:
a,b,c,x,y=map(int,input().split())
buy_x=x
buy_y=y
buy_z=0
ans=a*buy_x+b*buy_y

for i in range(max(x,y)*2):
    if (a+b>c*2):
        if (buy_x>0 and buy_y>0):
            buy_x-=1
            buy_y-=1
            buy_z+=2
        elif (buy_x==0 and buy_y>0 and b>c*2):
            buy_y-=1
            buy_z+=2
        elif (buy_x>0 and buy_y==0 and a>c*2):
            buy_x-=1
            buy_z+=2
    else:
        break
        
print(buy_x*a+buy_y*b+buy_z*c)



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

using namespace std;
typedef long long ll;
#define pb push_back

const int N = 16;

int a[N + 1][N + 1];
ll value[1 << N];
ll f[1 << N];

int main() {
    int n; cin >> n;

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

    for(int i = 1; i < (1 << n); ++i) {
        vector<int> vec;
        for(int j = 0; j < n; ++j) {
            if((i >> j)&1) vec.pb(j);
        }

        value[i] = 0;
        for(int x : vec) {
            for(int y : vec) {
                value[i] += a[x][y];
            }
        }
        value[i] /= 2;
    }

    for(int i = 0; i < (1 << n); ++i) {
        f[i] = 0;
        for(int j = i; j > 0; j = (j - 1)&i) {
            f[i] = max(f[i], value[j] + f[i^j]);
        }
    }

    cout << f[(1 << n) - 1] << endl;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  int cn[4];
  cn[a]=10;
  cn[b]=10;
  for(int i=1;i<=3;++i)
    if(cn[i]!=10)
    {
      cout<<i;
      return 0;
    }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 101
 
int A[N][N],color[N],f[N],d[N];
int n,time,k,a;
 
void visit(int );
void dSearch(void);
 
 
int main()
{
  int i, j, u, k;

  scanf("%d",&n);

  for(i = 0;i <= n;i ++ )
    {
    for(j = 0 ;j <= n;j ++ )
      {
      A[i][j] = 0;
      }
    }
  
  for(i = 1 ;i <= n;i ++ )
    {
    scanf("%d",&u);
    scanf("%d",&k);
    for(j = 1;j <= k;j ++ )
      {
      scanf("%d",&a);
      A[u][a] = 1;
    }
  }
  dSearch();
 
  for(i = 1;i <= n;i ++)
    {
    printf("%d %d %d\n",i,d[i],f[i]);
    }
  
  return 0;
}

void visit(int u)
{
  int i;

  color[u] = 2;

  d[u] = ++time;

  for(i = 1;i <= n; i ++)
    {
    if(A[u][i] != 0)
      {
      if(color[i] == 0) visit(i);
    }
  }
  color[u] = 3;
  f[u] = ++time;
}
 
void dSearch(void)
{
  int i;
  for(i = 1;i <= n ; i++)
    {
    color[i] = 0;
    }
  
  time = 0;
  
  for(i = 1;i <= n ;i ++ )
    {
    if(color[i] == 0)visit(i);
    }
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

typedef pair<ll, ll> LP;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, k;
	cin >> n >> k;
	vector<LP> edge;
	if (k > (n-1)*(n-2)/2){ cout << -1 << endl; return 0;}
	else {
		FOR(i, 2, n+1){
			edge.push_back({1, i});
		}
		ll cnt = (n-1)*(n-2)/2;
		FOR(i, 2, n+1){
			FOR(j, i+1, n+1){
				if (cnt == k){ break; }
				edge.push_back({i, j});
				cnt--;
			}
		if (cnt == k){ break; }
		}
	}
	cout << edge.size() << endl;
	REP(i, edge.size()){
		cout << edge[i].first << " " << edge[i].second << endl;
	}
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define _GLIBCXX_DEBUG
const int INF=1e15;

signed main(){
    int N;cin>>N;
    map<int,int>memo;
    REP(i,N){
        int a;cin>>a;
        memo[a*(-1)]++;
    }
    int ans=0;
    int count=0;
    for(auto it=memo.begin();it!=memo.end()&&count<=1;it++){
      	if((it->second)>=4&&count==0){
          ans=it->first*it->first;
          break;
        }
      	if((it->second)<2)continue;
		int d=it->first;
      	if(count==0)ans=d;
        else ans*=d;
        count++;
    }
  	if(ans<0)ans=0;
    cout<<ans<<endl;
}


Measured memory_bytes: 6528
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;
    std::cin >> S;
    ll w;
    std::cin >> w;
    for (int i = 0; i <= (S.length()-1)/w; i++) {
        std::cout << S[w*i];
    }
    std::cout << std::endl;
}


Measured memory_bytes: 256
n = []

N, M = list(map(int, input().split()))
for i in range(N):
    n.append('W')

for i in range(M):
    s, c = list(map(int, input().split()))
    s -= 1
    if n[s] == "W":
        n[s] = c
    elif n[s] == c:
        pass
    else:
        print(-1)
        exit()
        
if N != 1:
    if n[0] == 0:
        print(-1)
        exit()
    
    if n[0] == "W":
        n[0] = 1
        
    for i in range(N):
        if n[i] =="W":
            n[i] = 0

else:
    if n[0] == "W":
        n[0] = 0
        
print(''.join(map(str,n)))

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

int main()
{
int A;
int B;
int C;
cin >> A;
cin >> B;
cin >> C;
if (A == 7 && B == 5 && C == 5)
{
cout << "YES" << endl;
}
else if (A == 5 && B == 7 && C == 5)
{
cout << "YES" << endl;
}
else if (A == 5 && B == 5 && C == 7)
{
cout << "YES" << endl; 
}
else
{
cout << "NO" << endl;
}


}

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

int main() {
    ll n;
    cin >> n;
    if(floor(sqrt(n)) * float(sqrt(n)) == n) { //nが平方数の場合
        cout << (ll)(sqrt(n) * 2 - 2) << endl;
        return 0;
    }
    for(int i = floor(sqrt(n)); i >= 1; i--) { //nが平方数でないときはしらみつぶし(10^6程度で終わるはず)
        if(i * (n / i) == n) {
            cout << (i - 1) + ((n / i) - 1) << endl;
            return 0;
        }
        continue;
    }
}


Measured memory_bytes: 3720
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, P = map(int, input().split())
    A = [0] + list(map(int, input().split()))
    dp_odd = [0 for _ in range(N + 1)]
    dp_even = [0 for _ in range(N + 1)]
    dp_even[0] = 1

    for i in range(1, N + 1):
        if A[i] % 2 == 0:
            dp_odd[i] = dp_odd[i - 1] * 2
            dp_even[i] = dp_even[i - 1] * 2
        else:
            dp_odd[i] = dp_even[i - 1] + dp_odd[i - 1]
            dp_even[i] = dp_odd[i - 1] + dp_even[i - 1]

    if P == 0:
        print(dp_even[-1])
    else:
        print(dp_odd[-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
l =  "qwertasdfgzxcvb"
while line = gets.chomp do
    break if line == "\#"
    count = 0
    f = l.include?(line[0])
    line.each_char do |c|
        if l.include?(c)
            count += 1 if !f
            f = true
        else
            count += 1 if f
            f = false
        end
    end
    puts count
end

Measured memory_bytes: 6092
#include <bits/stdc++.h>
using namespace std;
int i,j,k,count1=0,count2=0;
int gcd(int,int);
void ABC157();
void ABC158();
void ABC161();
void ABC162();
void ABC163();
void ABC164();

int main(){
    ABC157();
}

void ABC157(){
    int s,c,ans=1;
    int n,m;
    cin>>n>>m;
    vector<int> vec(n,-1);
    //同じ数の場合，何も入ってなかった場合
    for(i=0;i<m;i++){
        cin>>s>>c;
        if(vec[s-1]==-1){
            vec[s-1]=c;
        }
        else if(vec[s-1]!=c){
            ans=0;
            break;
        }
    }
    if(n==1&&m==0)cout<<0<<endl;
    else if(n==1&&ans==1)cout<<vec[0]<<endl;
    else if(ans==1&&n>=2&&vec[0]!=0){
        for(i=0;i<n;i++){
            if(vec[i]==-1&&i==0)cout<<1;
            else if(vec[i]==-1)cout<<0;
            else cout<<vec[i];
        }
        cout<<endl;
    }else{
        cout<<-1<<endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX                             (100000)

#define ABS(NUM)                ((NUM>0)?(NUM):((-1)*(NUM)))
#define MIN(NUM1, NUM2) ((NUM1>NUM2)?(NUM2):(NUM1))

int main(void)
{
        int n, h[MAX]={};
        int i;
        int step[MAX]={};

        scanf("%d", &n);
        for(i=0; i<n; i++)
                scanf("%d", &h[i]);

        step[1] = ABS(h[1]-h[0]);
        for(i=2; i<n; i++)
                step[i] = MIN( (ABS(h[i]-h[i-1])+step[i-1]), (ABS(h[i]-h[i-2])+step[i-2]) );

        printf("%d\n", step[--i]);

        return (0);
}


Measured memory_bytes: 896
n = int(input())
a = list(map(int, input().split()))

arr = []
for i in range(n):
    arr.append(a[i] - (i+1))

arr.sort()

ans = []

s = 0
b = arr[n//2]
for i in range(n):
    s += abs(a[i] - (b + (i+1)))
ans.append(s)

if n == 1:
    print(ans[0])
    exit()
    
s = 0
b = arr[n//2 + 1]
for i in range(n):
    s += abs(a[i] - (b + (i+1)))
ans.append(s)

print(min(ans))

Measured memory_bytes: 30940
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    
    int N, M;
    cin >> N >> M;

    cout << (N * (N - 1) / 2 + M * (M - 1) / 2) << endl;

    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<cmath>
using namespace std;

int main() {
  int x;
  scanf("%d", &x);
  int max=1;
  for (int i=2 ; i*i<=x ; i++) {
    int j = 2;
    while (pow(i, j) <= x) {
      j++;
    }
    if (pow(i, j-1)>max) max = pow(i, j-1);
  }
  printf("%d\n", max);
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int ans = 0;
    string str;
    cin >> str;
    for(int i = 0;i < 4;i++){
        if(str[i] == '+'){
            ans += 1;
        }else{
            ans -= 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

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

    int a, b;
    cin >> a >> b;
    int price;
    if (a >= 13) {
      price = b;
    } else if (a >= 6 && a <= 12) {
      price = b / 2;
    } else {
      price = 0;
    }

    cout << price << '\n';

    return 0;
}


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

using namespace std;

const int MODULUS = 1000000007;


void make_modular_inverse_table(int, vector<int>&);
int modular_factorial(int);
int modular_factorial_inverse(int, vector<int>& );
int modular_combination(int, int, vector<int>& );

int main(){
    int X, Y;
    int s, t, n, d;
        
    cin >> X >> Y;
    if( (X + Y) % 3 != 0 ){
        cout << 0 << endl;
        return 0;
    }
    n = (X + Y)/3;
    d = X - Y;

    s = (n + d) / 2;
    t = (n - d) / 2;
    if(s < 0 or t < 0){
        cout << 0 << endl;
        return 0;
    }  

    int u = max(s,t);
    vector<int> table(u+1);  
    make_modular_inverse_table( u, table );

    cout << modular_combination( n, s, table) << endl;
    return 0;
}

void make_modular_inverse_table( int n, vector<int>& table){
    table[0] = 0;
    table[1] = 1;
    long long temp;
    for(int i=2;i<=n;i++){
        temp = ( MODULUS - ( static_cast<long long>(MODULUS) / i * table[MODULUS % i] ) % MODULUS ) % MODULUS;
        table[i] = temp; 
        // cout << "table[" << i << "] = " << table[i] << endl;
    }
}

int modular_factorial(int n){
    if(n==0){
        return 1;
    }
    long temp = 1;
    for(int i=1;i<=n;i++){
        temp = (temp * i) % MODULUS;
    }
    return temp;
}

int modular_factorial_inverse(int n, vector<int>& table){
    if(n==0){
        return 1;
    }
    long long temp = 1;
    for(int i=1;i<=n;i++){
        temp = (temp * table[i] ) % MODULUS;
    }
    return temp;
}

int modular_combination( int n, int s, vector<int>& table ){
    long temp = modular_factorial(n);
    temp = (temp * modular_factorial_inverse(s, table) ) % MODULUS;
    temp = (temp * modular_factorial_inverse(n-s, table) ) % MODULUS;    
    return temp;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1LL<<59

ll n;
vector<ll> E[101010];
//---------------------------------------------------------------------------------------------------
ll dp[101010][2];
void dfs(ll cu, ll pa = -1) {
    dp[cu][0] = dp[cu][1] = 1;
    for(ll to:E[cu]) {
        if (to != pa) {
        dfs(to, cu);
        dp[cu][0] *= (dp[to][0] + dp[to][1]);
        dp[cu][0]%=Mod;
        dp[cu][1] *= dp[to][0];
        dp[cu][1]%=Mod;
        }
    }
}

int main(){
    ll i,j;
    cin>>n;
    for(i=0;i<n-1;i++){
        ll a,b;
        cin>>a>>b;
        a--;
        b--;
        E[a].pb(b);
        E[b].pb(a);
    }
    dfs(0);
    ll ans=dp[0][0]+dp[0][1];
    cout<<ans%Mod<<endl;
}

Measured memory_bytes: 14208
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
vector<int> f(vector<int> a){
    vector<int>res(a.size()/2);
    rep(i,res.size()){
        if(a[2*i] == a[2*i+1])res[i] = a[2*i];
        else res[i] = abs(a[2*i]-a[2*i+1]);
    }
    return res;
}
int main(){
    int n;
    cin >> n;
    vector<int>a(1<<n);
    rep(i,1<<n){
        cin >> a[i];
    }
    while(a.size()!=1){
        a = f(a);
    }
    cout << a[0] << endl;
}

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

using namespace std;

int main()
{
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        vector<vector<bool>> info(n, vector<bool>(n, false));
        for (int i = 0; i < n; i++) {
            int m;
            cin >> m;
            info[i].resize(m);
            for (int j = 0; j < m; j++) {
                int in;
                cin >> in;
                in--;
                info[i][in] = true;
            }
        }
        int k;
        cin >> k;
        vector<int> leak(k);
        for (int i = 0; i < k; i++) {
            int l;
            cin >> l;
            l--;
            leak[i] = l;
        }

        int suspect = -1;
        for (int i = 0; i < n; i++) {
            int rest = k;
            for (int j = 0; j < k; j++) {
                if (info[i][leak[j]]) {
                    rest--;
                }
            }
            if (rest == 0) {
                if (suspect == -1) {
                    suspect = i + 1;
                } else {
                    suspect = -2;
                }
            }
        }
        if (suspect < 0) {
            cout << -1 << endl;
        } else {
            cout << suspect << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3108
inp = str(input())

A = int(inp[0])
B = int(inp[1])
C = int(inp[2])
D = int(inp[3])

a = "%d+%d+%d+%d=7" % (A, B, C, D)
b = "%d+%d+%d-%d=7" % (A, B, C, D)
c = "%d+%d-%d+%d=7" % (A, B, C, D)
d = "%d-%d+%d+%d=7" % (A, B, C, D)
e = "%d+%d-%d-%d=7" % (A, B, C, D)
f = "%d-%d+%d-%d=7" % (A, B, C, D)
g = "%d-%d-%d+%d=7" % (A, B, C, D)
h = "%d-%d-%d-%d=7" % (A, B, C, D)

if A + B + C + D == 7:
    print(a)
elif A + B + C - D == 7:
    print(b)
elif A + B - C + D == 7:
    print(c)
elif A - B + C + D == 7:
    print(d)
elif A + B - C - D == 7:
    print(e)
elif A - B + C - D == 7:
    print(f)
elif A - B - C + D == 7:
    print(g)
elif A - B - C - D == 7:
    print(h)


Measured memory_bytes: 3064
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    char[] c=sc.next().toCharArray();
    int sum=700;
    for(int i=0;i<3;i++){
      if(c[i]=='o'){
        sum+=100;
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 22868
#[macro_use]
mod input {

use std;
use std::io;

#[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);
}

const SPLIT_DELIMITER: char = ' ';
#[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 s = str2vec(&input_line_str());
    let mut count = 1;
    let mut ans = 1;
    for z in 1..4 {
        if s[z] == s[z - 1] {
            count += 1;
        } else {
            ans = std::cmp::max(ans, count);
            count = 1;
        }
    }
    ans = std::cmp::max(ans, count);
    if ans >= 3 {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int search(int A[], int n, int key) {
  int i = 0;
  A[n] = key;
  while (A[i] != key) i++;
  return i != n;
}

int main() {
  int i, n, A[10000+1], q, key, sum = 0;

  cin >> n;
  for (i = 0; i < n; i++) cin >> A[i];

  cin >> q;
  for (i = 0; i < q; i++) {
    cin >> key;
    if (search(A, n, key)) sum++;
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(void) {
  int h, w;
  char x[102][102], ans[102][102], flag;

  if(scanf("%d %d", &h, &w) == 1);

  for(int i = 0; i < h; i++) {
    flag = 1;
    if(scanf("%s", x[i]) == 1);
    for(int j = 0; j < w; j++) {
      if(x[i][j] == '#') {
        flag = 0;
        break;
      }
    }
    if(flag) {
      i--;
      h--;
    }
  }

  //for(int i = 0; i < h; i++) {
  //  printf("%s\n", x[i]);
  //}

  //printf("\n\n\n\n");

  for(int i = 0; i < w; i++) {
    flag = 1;
    for(int j = 0; j < h; j++) {
      if(x[j][i] == '#') {
        flag = 0;
        break;
      }
    }
    if(flag) {
      for(int l = i; l < w; l++) {
        for(int k = 0; k < h; k++) {
          if(l == w - 1) {
            x[k][l] = '\0';
          } else {
            x[k][l] = x[k][l + 1];
          }
        }
      }
      i--;
      w--;
    }
  }

  for(int i = 0; i < h; i++) {
    printf("%s\n", x[i]);
  }

  return 0;
}


Measured memory_bytes: 128
S = gets.chomp.split("")
if (S.include?("N") && !S.include?("S")) || (!S.include?("N") && S.include?("S")) || (S.include?("W") && !S.include?("E")) || (!S.include?("W") && S.include?("E"))
  puts "No"
else
  puts "Yes"
end


Measured memory_bytes: 1788
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
k = n-1
for i in range(m):
    if a[i] > x:
        k = i
        break
if k==0 or k==n-1:
    print('0')
    exit()
else:
    print(min(k,m-k))
    

Measured memory_bytes: 9112
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <unordered_map>
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned int uint;

ll gcd(ll a,ll b)
{
    if ( b > a)
    {
        return gcd(b,a);
    }

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


int main(int argc, char const *argv[])
{
    ll a,b;
    cin >> a >> b;
    
    cout << a * b / gcd(a,b) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int a, b, c, d;
    d = 0;
    scanf("%d %d %d",&a,&b,&c);
    while (a > b || b >
     c) {
        if (a > b){
            d = a;
            a = b;
            b = d;
       } else if (b > c){
            d = b;
            b = c;
            c = d;
       }  
    }
    printf("%d %d %d\n",a,b,c);
}


Measured memory_bytes: 2684
/*
 *  AUTHOR : MANAV PATEl
*/
#include<bits/stdc++.h>
#include<functional>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

namespace fastio {

	template <class T> istream &operator>>(istream &os, vector<T> & vec) {
		for (auto &u : vec)os >> u;
		return os;
	}
	template <class T> ostream &operator<<(ostream &os, const vector<T> & vec) {
		for (auto &u : vec)os << u << " ";
		return os;
	}
	template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p) {
		return os >> p.first >> p.second;
	}
	template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
		return os << p.first << " " << p.second;
	}
	template <class T> ostream &operator<<(ostream &os, set<T> & con) {
		for (auto &u : con) os << u << " ";
		return os;
	}
	void re() {}
	template <typename T, typename... args> void re(T& x, args&... tail) {
		cin >> x;
		re(tail...);
	}
	void pr() {}
	template <typename T> void pr(const T& x) {
		cout << x;
	}
	template <typename T, typename... args> void pr(const T& x, const args&... tail) {
		cout << x << " ";
		pr(tail...);
	}
	template <typename... args> void prln(const args&... tail) {
		pr(tail...);
		cout << "\n";
	}
}
using namespace fastio;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(a)  memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back

int main()
{
	cin.sync_with_stdio(false);
	cin.exceptions(cin.failbit);
	cin.tie(0);
	ll n, cnt = 0;
	re(n);
	if(n&1) return !printf("0\n");
	n/=2;
	for(ll i = 5; n / i >= 1; i*=5)
		cnt += n / i;
	cout << cnt;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		  Scanner  scan = new   Scanner (System.in);
		int[]array=new int[3];
		array[0]=scan.nextInt();
		array[1]=scan.nextInt();
		array[2]=scan.nextInt();
		Arrays.sort(array);
		System.out.println(array[0]+array[1]);
	}

}

Measured memory_bytes: 23632
#include<stdio.h>
#include<algorithm>
using namespace std;
int p[3100];
int q[3100];
double A[510][3100];
double ABS(double a){return max(a,-a);}
double EPS=1e-9;
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		scanf("%d%d",p+i,q+i);
		p[i]--;q[i]--;
		A[p[i]][i]+=1.0;
		A[q[i]][i]-=1.0;
	}
	int rank=b;
	int col=0;
	/*for(int i=0;i<a;i++){
		for(int j=0;j<b;j++)printf("%.0f ",A[i][j]);
		printf("\n");
	}*/
	for(int i=0;i<a;i++){
		int at=-1;
		while(col<b){
			for(int j=i;j<a;j++){
				if(ABS(A[j][col])>EPS){
					at=j;break;
				}
			}
			if(~at)break;
			col++;
		}
		if(col>=b)break;
		rank--;
		for(int j=0;j<b;j++)swap(A[i][j],A[at][j]);
		double ks=A[i][col];
		for(int j=0;j<b;j++)A[i][j]/=ks;
		for(int j=i+1;j<a;j++){
			double t=A[j][col];
			for(int k=0;k<b;k++)A[j][k]-=t*A[i][k];
		}
		col++;
		/*for(int k=0;k<a;k++){
			for(int j=0;j<b;j++)printf("%.0f ",A[k][j]);
			printf("\n");
		}*/
	}
	printf("%d\n",rank);
}

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

int main() {
    int n, c; cin >> n >> c;
    int sum = 0;
    for (int i = 0; i < c; i++) {
        int tmp; cin >> tmp;
        sum += tmp;
    }
    const int common = sum / (n + 1);
    int me = common;
    if (sum - common * (n + 1) != 0) me++;
    cout << me << endl;
}


Measured memory_bytes: 3112
//01
#include<iostream>
#include<queue>
#include<vector>

using namespace std;

struct E{
  int d,c;
};

struct S{
  int v,f,t;
  bool operator<(S a)const{
    return f>a.f;
  }
};

int main(){
  for(int n,m;cin>>n>>m,n|m;){
    vector<E> e[101];
    while(m--){
      int a,b,c;
      cin>>a>>b>>c;
      E ce={b,c};
      e[a].push_back(ce);
      ce.d=a;
      e[b].push_back(ce);
    }
    priority_queue<S> que;
    S is={1,0,2};
    que.push(is);
    bool p[101][3]={{}};
    for(;;){
      S c=que.top();
      if(c.v==n&&c.t!=1)break;
      que.pop();
      if(p[c.v][c.t]++)continue;
      for(int i=0;i<e[c.v].size();i++){
	if(c.t>0){
	  S n={e[c.v][i].d,c.f,c.t-1};
	  que.push(n);
	}
	if(c.t!=1){
	  S n={e[c.v][i].d,c.f+e[c.v][i].c,c.t};
	  que.push(n);
	}
      }
    }
    cout<<que.top().f<<endl;
  }
  return 0;
}

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


#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int,int>
#define tiii tuple<int,int,int> >
#define tiiii tuple<int,int,int,int>
#define pl pair<ll> pl
#define vpi vector< pair<int,int> >

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast_io std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)


#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;
#define trace3(x,y,z) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y <<" | " << #z << ':' << z << endl;
#define trace4(x,y,z,w) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y <<" | " << #z << ':' << z << " | " << #w << ':' << w << endl;

#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(),(v).end()
#define print(x) cout<<(x)<<endl;

int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};
int toInt(string s){int r=0;istringstream sin(s);sin>>r; return r;}
///////////////////////////////////////////////////////

string s;
int n;

int main()
{
	fast_io;
	cout<<fixed;

	cin>>s;
	n = s.size();
	bool isPresent[30];

	REP(i,26) isPresent[i] = false;

	REP(i,n){
		isPresent[s[i]-'a'] = true;
	}

	// trace(n)
	int flag = 0;

	if(n==26){
		if(s == "zyxwvutsrqponmlkjihgfedcba"){
			cout<<-1<<endl;
			return 0;
		}

		FORD(i,24,0){

			// trace(i)

			int x = s[i];

			// trace(char(x))

			int mini = 'z';

			FOR(j,i+1,25){

				// trace2()
				if(s[j]>x){
					mini = min(mini,(int)s[j]);
					flag = 1;
				}
			}

			// trace2(s[i],(char)mini)

			if(flag){
				FOR(k,0,i-1){
					cout<<s[k];
				}
				cout<<(char)mini<<endl;
				return 0;
			}
		}
	}
	else{
		cout<<s;
		FOR(i,0,25){
			if(!isPresent[i]){
				cout<<(char)(((int)'a')+i)<<endl;
				return 0;
			}
		}
	}
}


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

int main() {
  ll n, k;
  cin >> n >> k;
  vll h(n);
  for (ll i = 0; i < n; i++) cin >> h[i];

  vll dp(n, inf);
  dp[0] = 0;
  for (ll i = 1; i < n; i++) {
    for (ll j = 1; j <= k; j++) {
      dp[i] = min(dp[i], dp[max(0ll, i - j)] + abs(h[max(0ll, i - j)] - h[i]));
    }
  }
  cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1792
/* #                          */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <deque>
#include <map>
//#pragma warning(disable:4996)
using namespace std;


/** Type Define **/

typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;


constexpr int               inf = 0x3f3f3f3f;
constexpr long long 		INF = 9123456789123456789;
constexpr long long         MOD = 1000000007LL;
/*************************************************/
int H, N;
vi dp;

void Min(int& x, int y) {
    if (x > y)
        x = y;
}

void sol() {
    for (int i = 0; i < N; i++) {
        int a, b; // a: damage, b: cost.
        cin >> a >> b;
        for (int i = 0; i < a; i++)
            Min(dp[i], b);
        for (int i = a; i <= H; i++)
            Min(dp[i], dp[i - a] + b);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    //cout << fixed << setprecision(10);
    cin.tie(nullptr);
    cin >> H >> N;
    dp.assign(10001, INT32_MAX);
    dp[0] = 0;

    sol();
    cout << dp[H] << '\n';

    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++)
#define all(x) (x).begin(),(x).end()

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


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

tscore, hscore = 0, 0
for i in range(num):
    ts, hs = input().split()
    if ts > hs:
        tscore += 3
    elif ts < hs:
        hscore += 3
    else:
        tscore += 1
        hscore += 1
print(tscore, hscore)



Measured memory_bytes: 5604
#include <stdio.h>
#include <math.h>
int main(){
    int a,b,r=100,a2,b2,i,cnt=0,s=1;
    long int yaku[1000]={0},bai[1000];
    while(scanf("%d %d",&a,&b)!=EOF){
        a2=a;
        b2=b;
        if(a>b){
            r=a-b;
        }else{
            r=b-a;
        }
        while(r!=0){//テ」ツδヲテ」ツδシテ」ツつーテ」ツδェテ」ツδε」ツδ嘉」ツ?ョテ・ツ?ャテァツエツ?ヲツ閉ー
            if(a2>b2){
                r=a2-b2;
                a2=b2;
                b2=r;
                s=1;
            }else{
                r=b2-a2;
                b2=a2;
                a2=r;
                s=2;
            }
        }
        if(s==1){
            yaku[cnt]=a2;
        }else{
            yaku[cnt]=b2;
        }
        bai[cnt]=1;
        for(i=100;i>1;i--){
            if(a%i==0&&b%i==0){
                while(1){
                    a=a/i;
                    b=b/i;
                    bai[cnt]*=i;
                    if(a%i!=0||b%i!=0) break;
                }
            }
        }
         
        bai[cnt]*=a*b;
        cnt++;
        r=100;
    }
    for(i=0;i<cnt;i++){
        printf("%ld %ld\n",yaku[i],bai[i]);
    }
    return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

class Node {
public:
	int type;
	vector<int> childs;
	Node() {
		type = -1;
	}
};

vector<Node> nodes;

bool dfs(int now, int prev, int val) {
	if (nodes[now].type == -1) {
		nodes[now].type = val;
	} else {
		return nodes[now].type == val;
	}

	for (int next : nodes[now].childs) {
		if (next == prev) continue;
		bool flag = dfs(next, now, 1 - val);
		if (!flag) return false;
	}

	return true;
}

signed main() {
	int N, M;
	cin >> N >> M;

	nodes.resize(N);

	rep(i, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		nodes[a].childs.push_back(b);
		nodes[b].childs.push_back(a);
	}

	bool flag = dfs(0, -1, 0);

	int num = 0;
	if (flag) {
		int even = 0;
		int odd = 0;
		rep(i, N) {
			if (nodes[i].type == 0) even++;
			else odd++;
		}
		cerr << "even:" << even << " odd:" << odd << endl;

		rep(i, N) {
			if (nodes[i].type == 0) num += odd;
			else num += even;
		}

		num /= 2;
	} else {
		rep(i, N) {
			num += i;
		}
	}

	cerr << "flag:" << flag << endl;
	cerr << "num:" << num << endl;

	cout << num - M << endl;

    return 0;
}


Measured memory_bytes: 7424
import sys

for s in sys.stdin:
    #?????????????????????
    s=s[:-1]
    #????????¨??????????????????
    p=s.split("=")

    ans="NA"
    st=0

    #X??¨??????0????¨±?????????????????????
    #2?????\?????§?????????X???????????¨????????????
    tmp=p[0].split("+")
    if tmp[0][0]=="X" and len(tmp[0])>1:
        st=1
    if tmp[1][0]=="X" and len(tmp[1])>1:
        st=1
    if p[1][0]=="X" and len(p[1])>1:
        st=1

    #print(p)
    for i in range(st,10):
        a=eval(p[0].replace("X",str(i)))
        b=eval(p[1].replace("X",str(i)))
        if a==b:
            ans=i
            break

    print(ans)

Measured memory_bytes: 7704
n = int(input())
h = list(map(int, input().split()))

h = [0] + h
dp = [0]*(n+1)
dp[2] = abs(h[1] - h[2])

for i in range(3, n+1):
    dp[i] = min((dp[i-2] + abs(h[i-2]-h[i])), (dp[i-1] + abs(h[i-1]-h[i])))
print(dp[-1])

Measured memory_bytes: 13980
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, x, a[100000], ta = 0;

signed main() {
	cin >> n >> x;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ta = max(x, a[0]) - min(x, a[0]);
	for (int i = 1; i < n; i++) {
		ta = gcd(ta, max(x, a[i]) - min(x, a[i]));
	}
	cout << ta << endl;
	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>

int n;
long long int m;
int A[100001];
long long int S[100001];

/*
max \sum_{(i,j)} A_i + A_j
((x^{A1} + x^{A2} + ... + x^{AN})^2 - (x^{2A1} + x^{2A2} + ... + x^{2AN}))/2
s
*/

int check(int t){
  long long int c = 0;
  for(int i = n-1; i>=0 && 2*A[i] >= t; i--){
    int lb, ub;
    lb = -1;
    ub = i;
    while(ub - lb > 1){
      int mid = (lb + ub) / 2;
      if(A[i] + A[mid] >= t) ub = mid;
      else lb = mid;
    }

    c += 1 + 2 * (i - ub);
  }
  return c >= m;
}

int main(){
  scanf("%d%lld", &n, &m);
  for(int i = 0; i < n; i++) scanf("%d",A+i);
  std::sort(A, A+n);
  S[0] = A[0];
  for(int i = 1; i < n; i++) S[i] = S[i-1] + A[i];

  int lb, ub;
  lb = 0;
  ub = 200001;

  while(ub - lb > 1){
    int mid = (lb + ub) / 2;
    if(check(mid)) lb = mid;
    else ub = mid;
  }
  const int t = lb;

//printf("TEST %d\n", t);

  long long int ans = 0;
  long long int c = 0;
  for(int i = n-1; i >= 0 && 2*A[i] >= t; i--){
    int lb, ub;
    lb = -1;
    ub = i;
    while(ub - lb > 1){
      int mid = (lb + ub) / 2;
      if(A[i] + A[mid] >= t) ub = mid;
      else lb = mid;
    }

    c += 1 + 2 * (i - ub);
    ans += (long long) (1 + 2 * (i - ub)) * A[i] + A[i];
    ans += 2 * (S[i-1] - S[lb]);
//printf("AAA %d %d\n", A[i], A[ub]);
  }

  ans -= (long long) (c-m)*t;


  printf("%lld\n", ans);

  
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>

using namespace std;

typedef pair<double,double> pos;
const double r = 1;
const double eps = 0.0000000001;
int count(vector<pos> ps,double x,double y,int ban1,int ban2){
	int c=0;//2;
	for(int i=0;i<ps.size();i++){
		if(//i!=ban1&&i!=ban2&&
				pow(ps[i].first-x,2)+pow(ps[i].second-y,2)<=pow(1.0+eps,2)){
			c++;
		}
	}
	return c;
}

bool range(pos p1,pos p2,double r){
	return pow(p1.first-p2.first,2)+pow(p1.second-p2.second,2) <= r*r;
}

double len(pos p){
	return sqrt(pow(p.first,2)+pow(p.second,2));
}

double len2(pos p){
	return (pow(p.first,2)+pow(p.second,2));
}

vector<pos> point2(pos p1,pos p2){
	pos m = make_pair((p1.first+p2.first)/2,(p1.second+p2.second)/2);
	pos vec = make_pair(p1.first-p2.first,p1.second-p2.second);
	pos q = m;//make_pair(p2.first+vec.first/2,p2.second+vec.second/2);
	double l = sqrt(1-pow(len(vec)/2.0,2));
	double ll = len(vec);
	pos vec2 = make_pair(-vec.second,vec.first);
	vec2.first=vec2.first/ll*l;
	vec2.second = vec2.second/ll*l;
	vector<pos> ret;
	ret.push_back(make_pair(q.first+vec2.first,q.second+vec2.second));
	ret.push_back(make_pair(q.first-vec2.first,q.second-vec2.second));
	return ret;
}

int solve(vector<pos> ps){
	int mx=1;
	for(int i=0;i<ps.size()-1;i++)
		for(int k=i+1;k<ps.size();k++){
			if(range(ps[i],ps[k],2)){
				//cerr << "*****" << i << " " << k << endl;
				vector<pos> vp = point2(ps[i],ps[k]);
				mx = max(mx,count(ps,vp[0].first,vp[0].second,i,k));
				mx = max(mx,count(ps,vp[1].first,vp[1].second,i,k));
			}
		}
	return mx;
}

int main(){
	//cerr << point2(make_pair(0,0),make_pair(1,1))[1].first << endl;
	while(true){
		int n;
		vector<pos> v;
		cin >> n;
		if(n==0)return 0;
		for(int i=0;i<n;i++){
			double x,y;
			cin >> x >> y;
			v.push_back(make_pair(x,y));
		}
		cout << solve(v) << endl;
	}
}

Measured memory_bytes: 988
/******

AUTHOR : RUDRANSH TRIPATHI, IIIT NAGPUR, CCID(rt24) & CFID(rsgt24)

MOTTO : Use criticism as fuel and you will never run out of energy.
        AIM : TO BECOME A BETTER CODER
        INTROSPECT + COURSE CORRECTIONS = CATALYST FOR SUCCESS
        Every moment is an opportunity to better yourself

*******/

#include<bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
const int MAX = 1e5 + 5;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define pb push_back
#define d(x) cout<<x<<"\n"
#define time_passed	1.0 * clock() / CLOCKS_PER_SEC

//basic mathematics
int gcd(int a, int b)
{
	if (a == 0)
		return b;
	return gcd(b % a, a);
}
int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}

//modular arithmetic
int powermod(int x, int y, int p)
{
	int res = 1;

	x = x % p;

	if (x == 0) return 0;

	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

//Prime numbers till n precomputation - range query
int prefix[MAX + 1];

void buildPrefix()
{
	bool prime[MAX + 1];
	memset(prime, true, sizeof(prime));

	for (int p = 2; p * p <= MAX; p++) {
		if (prime[p] == true) {
			for (int i = p * 2; i <= MAX; i += p)
				prime[i] = false;
		}
	}
	prefix[0] = prefix[1] = 0;
	for (int p = 2; p <= MAX; p++) {
		prefix[p] = prefix[p - 1];
		if (prime[p])
			prefix[p]++;
	}
}

int query(int L, int R)
{
	return prefix[R] - prefix[L - 1];
}


//Find all paths from a to b in an undirected graph
vector<int> g[MAX];
int visited[MAX];
//count of all the paths from 1 to n;

void dfs(int visited[MAX], int u, int v, vector<int> path)
{
	visited[u] = 1;
	if (u == v)
	{
		for (int i = 0; i < path.size(); i++)
		{
			cout << path[i] << " ";
		}
		cout << "\n";
	}
	else
	{
		for (int i = 0; i < g[u].size(); i++)
		{
			int y = g[u][i];

			if (visited[y] == 0)
			{
				visited[y] = 1;
				path.pb(y);
				dfs(visited, y, v, path);
				path.pop_back();
			}

		}
	}

	visited[u] = 0;

}

vector<int> graph[MAX];
int vis[MAX];

void dfs(int v)
{
	vis[v] = 1;
	
	for(auto x: graph[v]){
	    
		if(vis[x] == 0)
		{
		    dfs(x);
		}
		
	}
}

int dp[20001];

void pre()
{
    dp[1] = 0;
    dp[2] = 0;
    dp[3] = 1;
    
    for(int i = 4; i <= 2000; i++)
    {
        dp[i] = (dp[i - 1] % M + dp[i - 3] % M) % M;
    }
}

void solve()
{
	int n;
	cin >> n;
	int k = n;
	int xx[n];
	int yy[n];
	int i = 0;
	while(n--)
	{
	    int x,y;
	    cin >> x >> y;
	    xx[i] = x + y;
	    yy[i] = x - y;
	    i++;
	}
	
	int max_1x = *max_element(xx,xx+i);
	int min_1x = *min_element(xx,xx+i);
	int max_1y = *max_element(yy,yy+i);
	int min_1y = *min_element(yy,yy+i);
	
	cout << max(max_1x - min_1x, max_1y - min_1y) << "\n";
	
		
		
	//for (int i = 0; i < n; i++)
	//	cout << ar[i];
}

int32_t main(void)
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
    pre();
	fastio
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	//cerr << "\n" << "Time elapsed : " << time_passed << "\n";
	return 0;
}

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

int main() {
  //
  int N, x;
  int64_t ans = 0;
  cin >> N >> x;
  for (int i = 2; i <= N; i++) {
    int y;
    cin >> y;
    if (x >= y)
      ans += x - y;
    else
      x = y;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3196
# coding: utf-8
import sys
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# vertexごとに3つの状態数を持つ
N, M = lr()
graph = [[] for _ in range((N+1)*3)]  # 1-indexed
for _ in range(M):
    a, b = lr()
    a *= 3; b *= 3
    for i in range(3):
        j = i+1 if i < 2 else 0
        graph[a+i].append(b+j)

INF = 10 ** 15

def dijkstra(start):
    dist = [INF] * (N+1) * 3
    dist[start] = 0
    que = [(0, start)]
    while que:
        d, prev = heappop(que)
        if dist[prev] < d:
            continue
        for next in graph[prev]:
            d1 = d + 1
            if dist[next] > d1:
                dist[next] = d1
                heappush(que, (d1, next))
    return dist

S, T = lr()
dist = dijkstra(S*3)
answer = dist[T*3]
if answer == INF:
    answer = -1
else:
    answer //= 3
print(answer)


Measured memory_bytes: 91300
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define poi 1000
using namespace std;
int b[poi];
inline int re()
{
	char c=getchar();
	int x=0,k=1;
	while(c<'0'||c>'9')
	{if(c=='-') k=-1;c=getchar();}
	while(c>='0'&&c<='9')
	{x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return x*k;
}
void wr(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) wr(x/10);
	putchar(x%10+'0');
}
signed main()
{
	int n=re(),m=re(),c=re(),ans=0;
	for(int i=1;i<=m;i++) b[i]=re();
	for(int i=1;i<=n;i++)
	{
		int sum=c;
		for(int j=1;j<=m;j++)
		sum+=b[j]*re();
		ans+=sum>0;
	}
	wr(ans);
	return 0;
}
/*

*/

Measured memory_bytes: 384
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
ans1 = 10**7
ans2 = 0
for i in range(n):
    tmp = t - h[i]*0.006
    if abs(tmp-a) < abs(ans1-a):
        ans1 = tmp
        ans2 = i+1
print(ans2)

Measured memory_bytes: 3444
#include <iostream>

using namespace std;

int main (){
	
	int a1;
	int a2;
	int a3;
	int zbroj;
	
	cin >> a1;
	cin >> a2;
	cin >> a3;
	
	zbroj = a1 + a2 + a3;
	
	if (zbroj < 22){
		cout << "win";
	}
	
	if (zbroj >= 22){
		cout << "bust";
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int A = sc.nextInt();
        int B = sc.nextInt();

        System.out.println(solve(A, B));

        sc.close();
    }

    static int solve(int A, int B) {
        return (A + B) % 24;
    }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define Mo 998244353
#define N 500
typedef long long LL;
using namespace std;
int x[N], y[N], b[N], num[N], n;

void prepare() {
    b[0] = 1;
    for(int i = 1; i <= n; i++) b[i] = ((LL)b[i - 1] * 2) % Mo;
    for(int i = 1; i <= n; i++) b[i] = (b[i] - 1 - i - i * (i - 1) / 2) % Mo;
}

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> x[i] >> y[i];
    prepare();
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++) {
            if (i == j) continue;
            int cnt = 2;
            for(int k = 1; k <= n; k++) {
                if (k == i || k == j) continue;
                if ((LL)(x[k] - x[i]) * (y[k] - y[j]) == (LL)(x[k] - x[j]) * (y[k] - y[i])) cnt++;
            }
            num[cnt]++;
        }
    for(int i = 3; i <= n; i++) num[i] = num[i] / i / (i - 1);
    LL ans = b[n];
    for(int i = 3; i <= n; i++) ans = (ans - (LL)num[i] * b[i] % Mo) % Mo;
    cout << (ans % Mo + Mo) % Mo << endl;
}


Measured memory_bytes: 256
board = [[False]*1000001]*1000001
while True:
    m = int(input())
    if m == 0: break
    sx, sy = map(int, input().split())
    star = []
    for i in range(m-1):
        x, y = map(int, input().split())
        star.append((x-sx, y-sy))
    
    
    n = int(input())
    starlist = [tuple(map(int, input().split())) for i in range(n)]
    for i in range(n):
        board[starlist[i][0]][starlist[i][1]] = True
    for i in range(n):
        flag = True
        for j in range(len(star)):
            dx = starlist[i][0] + star[j][0]
            dy = starlist[i][1] + star[j][1]
            if 0 <= dx <= 1000000 and 0 <= dy <= 1000000 and board[dx][dy] == False:
                flag = False
                break
        if flag == True:
            print("{} {}".format(str(starlist[i][0] - sx), str(starlist[i][1] -sy)))
            break
    

Measured memory_bytes: 22504
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> s;
    int ans = 0;
    string codfes = "CODEFESTIVAL2016";
    rep(i, 0, s.size()) {
        if (s[i] != codfes[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256