akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::cmp::max;
use std::cmp::min;


fn main() {
    input! {
        N: usize,
        mut Vs: [i64; N],
    }

    Vs.sort();

    let mut ans : f64 = (Vs[0] + Vs[1]) as f64 / 2.0;
    for i in 2..N {
        ans = (ans + Vs[i] as f64) / 2.0;
    }

    println!("{}", ans);
}


Measured memory_bytes: 2176
#!usr/bin/env python3

import sys


class Die:
    def __init__(self, pips):
        self.pips = pips

    def move_die(self, direction):
        if direction == 'N':
            tmp = self.pips[0]
            self.pips[0] = self.pips[1]
            self.pips[1] = self.pips[5]
            self.pips[5] = self.pips[4]
            self.pips[4] = tmp
            del tmp
        elif direction == 'S':
            tmp = self.pips[0]
            self.pips[0] = self.pips[4]
            self.pips[4] = self.pips[5]
            self.pips[5] = self.pips[1]
            self.pips[1] = tmp
            del tmp
        elif direction == 'E':
            tmp = self.pips[0]
            self.pips[0] = self.pips[3]
            self.pips[3] = self.pips[5]
            self.pips[5] = self.pips[2]
            self.pips[2] = tmp
            del tmp
        elif direction == 'W':
            tmp = self.pips[0]
            self.pips[0] = self.pips[2]
            self.pips[2] = self.pips[5]
            self.pips[5] = self.pips[3]
            self.pips[3] = tmp
            del tmp

    def spin_die_clockwise(self):
        tmp = self.pips[1]
        self.pips[1] = self.pips[2]
        self.pips[2] = self.pips[4]
        self.pips[4] = self.pips[3]
        self.pips[3] = tmp
        del tmp

    def get_upside(self):
        return self.pips[0]

    def get_frontside(self):
        return self.pips[1]

    def get_rightside(self):
        return self.pips[2]


def init_die():
    pips = [int(pip) for pip in sys.stdin.readline().strip('\n').split()]
    die = Die(pips)

    return die


def roll_die(die):
    directions = list(sys.stdin.readline().strip('\n'))

    for direction in directions:
        die.move_die(direction)

    return die


def main():
    die = init_die()
    q = int(sys.stdin.readline().strip('\n'))

    for question in range(q):
        q_pips = [int(pip) for pip in sys.stdin.readline().strip('\n').split()]

        if q_pips[0] == die.pips[0]:
            pass
        elif q_pips[0] == die.pips[1]:
            die.move_die('N')
        elif q_pips[0] == die.pips[2]:
            die.move_die('W')
        elif q_pips[0] == die.pips[3]:
            die.move_die('E')
        elif q_pips[0] == die.pips[4]:
            die.move_die('S')
        elif q_pips[0] == die.pips[5]:
            die.move_die('N')
            die.move_die('N')

        while die.get_frontside() != q_pips[1]:
            die.spin_die_clockwise()

        print(die.get_rightside())


if __name__ == '__main__':
    main()

Measured memory_bytes: 7816
/*** keep hungry and calm CoolGuang!***/
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#include<stdio.h>
#include<algorithm>
#define debug(x) cout<<#x<<":"<<x<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const ll INF=1e18;
const int maxn=1e6+18;
const int mod=998244353;
inline bool read(ll &num)
{char in;bool IsN=false;in=getchar();if(in==EOF) return false;while(in!='-'&&(in<'0'||in>'9')) in=getchar();if(in=='-'){ IsN=true;num=0;}else num=in-'0';while(in=getchar(),in>='0'&&in<='9'){num*=10,num+=in-'0';}if(IsN) num=-num;return true;}
ll n,m,p;
ll st[100];
ll dp[100][2];///被限制 不被限制
int main()
{
    scanf("%lld%lld",&n,&m);
    ll sum=0;
    for(int i=1;i<=n;i++){
        ll x;read(x);
        for(ll k=0;k<=45;k++)
            if(x>>k&1ll) st[k]++;
        sum+=x;
    }
    if(m==0){
        printf("%lld\n",sum);
        return 0;
    }
    int f=0;
    int mx=log2(m);
    dp[mx][0]=st[mx]*(1ll<<mx);
    dp[mx][1]=(ll)(n-st[mx])*(1ll<<mx);
    ll ans=0;
    for(int k=mx+1;k<=45;k++)
        ans+=(1ll<<k)*st[k];
    for(ll k=mx-1;k>=0;k--){
        if(m>>k&1ll){
            dp[k][1]=dp[k+1][1]+(1ll<<k)*(n-st[k]);
            dp[k][0]=max(dp[k+1][1]+(1ll<<k)*st[k],dp[k][0]);///取0
            dp[k][0]=max(dp[k+1][0]+(1ll<<k)*st[k],dp[k][0]);
            dp[k][0]=max(dp[k+1][0]+(1ll<<k)*(n-st[k]),dp[k][0]);
        }
        else{
            dp[k][1]=dp[k+1][1]+(1ll<<k)*st[k];
            dp[k][0]=max(dp[k+1][0]+(1ll<<k)*st[k],dp[k][0]);
            dp[k][0]=max(dp[k+1][0]+(1ll<<k)*(n-st[k]),dp[k][0]);
        }
    }
    printf("%lld\n",max(dp[0][0],dp[0][1])+ans);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
	while(1){
		int h, w;
		scanf(" %d %d", &h, &w);
		if(h==0 && w==0) break;
		
		for(int i=0; i<h; ++i){
			for(int j=0; j<w; ++j){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");

	}
	return 0;
}



Measured memory_bytes: 2584
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int main() {
	cin>>n>>s;
	if(n&1) {
		cout<<"No";exit(0); 
	}
	for(int i=0;i+i<s.size();i++) {
		if(s[i]!=s[n/2+i]) {
			cout<<"No";exit(0); 
		}
	}
	cout<<"Yes";
	return 0;
}

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

deque<int> d[2];
deque<int> *p1, *p2;
vector<int> e[200000];
int ans[200000];

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

	int H, W, N;
	cin >> H >> W >> N;
	for(int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		e[a].push_back(b);
	}

	for(int i = 1; i <= W; i++) {
		d[(i + 1) % 2].push_back(i);
	}
	p1 = &d[0], p2 = &d[1];

	for(int i = 0; i < H; i++) {
		for(int b : e[i]) {
			if(i % 2 == 0) {
				swap(p1->at(b / 2), p2->at(b / 2));
			}
			else {
				swap(p1->at(b / 2 + 1), p2->at(b / 2));
			}
		}

		swap(p1, p2);
		if(i % 2) {
			p1->push_front(p2->front());
			p2->pop_front();
			p2->push_back(p1->back());
			p1->pop_back();
		}
	}


	for(int i = 0; i < W; i++) {
		if(i % 2 == 0) ans[p1->at(i / 2) - 1] = i;
		else ans[p2->at(i / 2) - 1] = i;
	}

	for(int i = 0; i < W; i++) {
		cout << ans[i] + 1 << endl;
	}
}

Measured memory_bytes: 12984
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::collections::HashMap;

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    let t = read::<String>().chars().collect::<Vec<char>>();

    let mut h1 = HashMap::new();
    let mut h2 = HashMap::new();
    for i in 0..s.len() {
        let aa = h1.entry(s[i]).or_insert(t[i]);
        let bb = h2.entry(t[i]).or_insert(s[i]);
        if *aa != t[i] || *bb != s[i] {
            println!("No");
            return;
        }
    }
    println!("Yes");
}

Measured memory_bytes: 6396
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>

using namespace std;
typedef long long ll;


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

    vector<ll> A(N);
    ll num0 = 0;
    ll num1 = 0;
    for(int i=0;i<N;i++){
        ll a;
        cin >> a;
        if(a%2==0) num0++;
        else num1 ++;
    } 

    ll ans = 1;
    if(P%2 == 0){
        ans <<= (num0);
        if(num1 > 0) ans <<= (num1-1);
    }else{
        if(num1 == 0){
            ans = 0;
        }else{
            ans <<= (num0 + num1-1);
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def examA():
    A, B, C = LI()
    ans = B + C - max(0,C-B-A-1)
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examA()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

int main(){
    int K;
    std::cin >> K;
    
    int a = 0;
    int b = 7;
    int cnt = 0;
    while(cnt < 10000000){
        b = b % K;
        a = (a + b) % K;
        cnt++;
        if(a == 0){
            std::cout << cnt << std::endl;
            return 0;
        }
        b *= 10;
    }
    
    std::cout << -1 << std::endl;
    
    return 0;
}



Measured memory_bytes: 3632
def BinarySearch(data, key):
    left = 0
    right = len(data)
    while left < right:
        mid = (left + right) // 2
        if data[mid] == key:
            return True
        elif key < data[mid]:
            right = mid
        else:
            left = mid + 1
    return False
n = int(input())
s = list(map(int,input().split()))
q = int(input())
t = list(map(int,input().split()))
ans = 0
for i in t:
    if BinarySearch(s,i):
        ans += 1
print(ans)


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll mod_pow(ll x,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*x%mod;
    x=x*x%mod;
    n>>=1;
  }
  return res;
}

ll fac[2000010],finv[2000010];

ll comb(ll n,ll r){
  if(n<0||r<0||n<r)return 0;
  else return (fac[n]*finv[r]%mod)*finv[n-r]%mod;
}

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

  fac[0]=1;
  rep(i,2000000)fac[i+1]=fac[i]*(i+1)%mod;
  rep(i,2000001)finv[i]=mod_pow(fac[i],mod-2);

  ll X,Y;
  cin>>X>>Y;
  if((X+Y)%3!=0){
    cout<<0<<endl;
  }else{
    ll x=Y-(X+Y)/3;
    ll y=X-(X+Y)/3;
    cout<<comb(x+y,x)<<endl;
  }

  return 0;
}


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


void solve(std::string O, std::string E){
  for(int i = 0; i < E.size(); i++) {
    cout << O[i] << E[i];
  }

  if(O.size() > E.size()) {
    cout << O[O.size()-1] << endl;
  }
  else{
    cout << endl;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string O;
  std::cin >> O;
  std::string E;
  std::cin >> E;
    solve(O, E);
    return 0;
}


Measured memory_bytes: 256
import Data.List

hoge :: [Int] -> Int
hoge [] = 0
hoge ints = bar $ sort ints
  where
    bar ls
      | length ls `mod` 2 == 0 = ls!!(length ls `div` 2) - ls!!(length ls `div` 2 - 1)
      | otherwise = 0

main = do
  _ <- getLine
  ints <- map read . words <$> getLine :: IO [Int]
  print $ hoge ints



Measured memory_bytes: 29052
def drawline(odd, columns):
    if odd == 0:
        f = '#'
        s = '.'
    else:
        f = '.'
        s = '#'
    for c in range(columns):
        if c%2 == 0:
            print(f, end='')
        else:
            print(s, end='')
    print('')

while(True):
    H, W = map(int, input().split())
    if W == 0 and H ==0:
        break
    for h in range(H):
        drawline(h%2, W)
    print('')

Measured memory_bytes: 9040
import java.util.Scanner;

public class Main {

    public Main() {
    }

    public static void main(String[] args) {
        new Main().solve();
    }

    private void solve() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        System.out.println("2018" + s.substring(4));
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

int main()
{
    string s;
    cin >> s;
    int placeA = 2000000;
    int placeZ = 0;
    rep(i,s.length()) {
        if (s[i] == 'A' && placeA > i) {
            placeA = i;
        }
        if (s[i] == 'Z' && placeZ < i) {
            placeZ = i;
        }
    }

    cout <<  placeZ - placeA + 1<< endl;
    return 0;
}


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

int main() {
  int N, counter, tmp, A;
  counter = 0;
  cin >> N;
  for (int i = 0; i < N; i++){
    tmp = 0;
    cin >> A;
    while (A % 2 == 0){
      tmp++;
      A /= 2;
    }
    if (i == 0)
    counter = tmp;
    else if (counter > tmp)
    counter = tmp;
  }
  cout << counter << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
inline string smax(string &s, string &t){
  return (s.size() < t.size()) ? t : s;
}
int main(){
  string s;
  while(cin>>s && s != "#END"){
    string ans = "";
    for(int dif = 0; dif < s.size()/2 + 1; dif++){
      {
        int i = s.size() / 2 + dif;
        if(i < s.size() && i > 0 && min(i, (int)s.size() - i) > ans.size()){
          int numdp[301][301] = {};
          string dp[301][301] = {};
          for(int j = 0; j < i; j++){
            for(int k = i; k < s.size(); k++){
              if(s[j] == s[k]) numdp[j+1][k+1] = numdp[j][k] + 1;
              else numdp[j+1][k+1] = max(numdp[j][k+1], numdp[j+1][k]);
            }
          }
          if(ans.size() < numdp[i][s.size()]){
            for(int j = 0; j < i; j++){
              for(int k = i; k < s.size(); k++){
                if(s[j] == s[k]) dp[j+1][k+1] = dp[j][k] + s[j];
                else dp[j+1][k+1] = smax(dp[j][k+1], dp[j+1][k]);
              }
            }
            ans = dp[i][s.size()];
          }
        }
      }
      {
        int i = s.size() / 2 - dif;
        if(i < s.size() && i > 0 && min(i, (int)s.size() - i) > ans.size()){
          int numdp[301][301] = {};
          string dp[301][301] = {};
          for(int j = 0; j < i; j++){
            for(int k = i; k < s.size(); k++){
              if(s[j] == s[k]) numdp[j+1][k+1] = numdp[j][k] + 1;
              else numdp[j+1][k+1] = max(numdp[j][k+1], numdp[j+1][k]);
            }
          }
          if(ans.size() < numdp[i][s.size()]){
            for(int j = 0; j < i; j++){
              for(int k = i; k < s.size(); k++){
                if(s[j] == s[k]) dp[j+1][k+1] = dp[j][k] + s[j];
                else dp[j+1][k+1] = smax(dp[j][k+1], dp[j+1][k]);
              }
            }
            ans = dp[i][s.size()];
          }
        }
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 4796
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main() {
    unsigned short *A, *B;
    
    int C[VMAX + 1];
    int n, i, j;
    scanf("%d", &n);
    
    A = malloc(sizeof(short) * n + 1);
    B = malloc(sizeof(short) * n + 1);
    
    for (i = 0; i <= VMAX; i++) C[i] = 0;
    
    for (i = 0; i < n; i++) {
        scanf("%hu", &A[i + 1]);
        C[A[i + 1]]++;
    }
    
    for (i = 1; i <= VMAX; i++) C[i] = C[i] + C[i - 1];
    
    for (j = 1; j <= n; j++) {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
    
    for (i = 1; i <= n; i++) {
        if (i > 1) printf(" ");
        printf("%d", B[i]);
    }
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 9600
def main():
    K = int(input())
 
    work = 7
 
    answer = -1
    for i in range(1, K+1):
        i_mod = work % K
        if i_mod == 0 :
            answer = i
            break
        work = i_mod * 10 + 7
    print(answer)
main()

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int n,sz;
string s[1000001],ans;
vector<pint> r,l;
int main(){
    cin>>n;
    rep(i,n){
        cin>>s[i];
        sz=s[i].size();
        int mx=0,mx2=0,c=0;
        rep(j,sz){
            if(s[i][j]=='(') --c;
            else ++c;
            mx=max(mx,c);
        }
        c=0;
        for(int j=sz-1;j>=0;--j){
            if(s[i][j]=='(') ++c;
            else --c;
            mx2=max(mx2,c);
        }
        if(mx2-mx>=0){
            l.pb(mx,i);
        }
        else{
            r.pb(-mx2,i);
        }
    }
    ans="";
    sort(l.begin(),l.end());
    sort(r.begin(),r.end());
    for(auto it:l) ans+=s[it.second];
    for(auto it:r) ans+=s[it.second];
    int cur=0;
    bool ok=true;
    for(auto it:ans){
        if(it=='(')++cur;
        else --cur;
        if(cur<0) ok=false;
    }
    if(cur==0&&ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 45104
N,M = list(map(int, input().split()))

combination = [1,1,2]
for i in range(3,N+1):
    combination.append(combination[i-1]+combination[i-2])

a = 0
ans = 1
lst = []

if M > 0:
    next_a = int(input())
    lst.append(combination[next_a-a-1])
    a = next_a
    for i in range(M-1):
        next_a = int(input())
        if next_a-a == 1:
            ans = 0
            break
        elif next_a-a == 0:
            continue
        lst.append(combination[next_a-a-2])
        a = next_a

    next_a = N
    lst.append(combination[next_a-a-1])
else:
    lst.append(combination[N])
    
for tmp in lst:
    ans *= tmp
print(ans%1000000007)

Measured memory_bytes: 462640
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n, a[100009], dp[100009];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	int p1 = 0, p2 = 0;
	for (int i = 0; i < n; i++) {
		dp[i + 1] = 999999999;
		if (i >= 1 && a[i - 1] > a[i]) p1 = i;
		else dp[i + 1] = dp[p1] + 1;
		if (i >= 1 && a[i - 1] < a[i]) p2 = i;
		else dp[i + 1] = min(dp[i + 1], dp[p2] + 1);
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
 
int main(){
  //入力
  int a,b,c,d,e;
  int N = 5;
  cin >> a >> b >> c >> d >> e;
  vector<int> Time = { a,b,c,d,e };
  //注文してから次に届くまでの時間
  vector<int> index = { 0,1,2,3,4 };
  
  //index の中身が 0,1,2,3,4
  //0,1,2,4,3
  //...
  //の全探索ができる
  
  int BestTime = 99999999;
  // int BestTime = (int)1e9; ←10の9乗
  
  do{
    int NowTime = 0;
    for (int i = 0; i < N; i++)
    {
    //10で割り切れるようになるまで1を足し続ける
      while (NowTime % 10 != 0) NowTime++;
      NowTime += Time[index[i]];
    }
    BestTime = min(BestTime, NowTime);
    
  }while (next_permutation(index.begin(), index.end()));
  
  cout << BestTime << endl;
  return 0;
}

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


#define ll long long
#define MOD 1000000007



int main(){
    string a = "abcdefghijkrlmnopqrstuvwxyz";
    string k;
    cin>>k;
    
    int j=0;
    for(int i=0;i<a.size();i++){
        if(k.at(0)==a.at(i)){
            j=1;
            break;
        }
    }
    
    if(j==1){
        cout<<"a"<<endl;
    }else{
        cout<<"A"<<endl;
    }

}

Measured memory_bytes: 3624
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let _n: usize = iter.next().unwrap().parse().unwrap();
    let x: usize = iter.next().unwrap().parse().unwrap();

    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let ls = buf.split_whitespace()
        .map(|x| x.parse::<usize>().unwrap())
        .collect::<Vec<_>>();

    let mut ans = 1usize;
    let mut d = 0usize;
    for l in ls.iter() {
        d = d + l;
        if d <= x {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  double a, b, x;
  cin >> a >> b >> x;

  cout << setprecision(8);
  if (x <= a * a * b / 2.0){
    double l = 2*x/(a*b);
    cout << atan(b/l) * 180. / 3.1415926535 << endl;
  } else {
    double l = 2*x/(a*a)-b;
    cout << atan((b-l)/a) * 180. / 3.1415926535 << endl;
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define pb(x) push_back((x))
#define line() cerr << "DEBUG @" << __LINE__ << endl;
#define debug(x) \
  cerr << "DEBUG @" << __LINE__ << " -> " << #x << " = " << x << endl;
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  vector<int> Root(n), Size(n, 1);
  function<int(int)> root = [&](int r) {
    if (Root[r] == r) return r;
    return Root[r] = root(Root[r]);
  };
  for (int i = 0; i < n; i++) Root[i] = i;
  auto merge = [&](int a, int b) {
    a = root(a), b = root(b);
    if (a != b) {
      Root[b] = a;
      Size[a] += Size[b];
      Size[b] = 0;
    }
  };
  while (m--) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    merge(u, v);
  }
  int ans = -1;
  for (int i = 0; i < n; i++) {
    ans = max(ans, Size[root(i)]);
  }
  cout << ans << '\n';
}


Measured memory_bytes: 9772
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{
    public static void Main()
    {
        long X = long.Parse(Console.ReadLine());
        int first = 1, second = 1;
        for (int b = 0; b < X; b++)
        {
            for (int a = b-100; a < b+100 ; a++)
            {
                if (Math.Pow(a, 5) - Math.Pow(b, 5) == X) { first = a;second = b; goto loop; }
                if (Math.Pow(-a, 5) - Math.Pow(b, 5) == X) { first = -a; second = b;  goto loop; }
                if (Math.Pow(a, 5) - Math.Pow(-b, 5) == X) { first = a; second = -b; goto loop; }
            }
        }
        loop:
        Console.WriteLine(first + " " + second); 
    }
}

Measured memory_bytes: 27884
#include <iostream>
#include <vector>
#include <cmath>
//https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
 
using namespace std;
typedef long long ll;
 
const ll M = 998244353;

int main()
{
    ll A, B;
    cin >> A >> B;
    if(A % 2 == 1 && B % 2 == 1){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define sci(x) int x; scanf("%d", &x);
#define TC(x) sci(x); while(x--)
typedef long long ll;
using namespace std;

bool pelindrome(string s)
{
    int len=s.length();
    string s1=s;
    reverse(all(s1));
    if(s==s1) return true;
    else return false;
}

string strmaker(string s, int a, int b)
{
    string s1;
    for(int i=a-1;i<=b-1;i++){
        s1.pb(s[i]);
    }
    return s1;
}

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

    string s,s1,s2;
    cin>>s;
    int n=s.length();
    s1=strmaker(s, 1, (n-1)/2);
    s2=strmaker(s, (n+3)/2, n);
    if(pelindrome(s)==true && pelindrome(s1)==true && pelindrome(s2)==true) cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int H,h,m,s;

struct data{
  int h,m,n,d;
  bool operator < (const data &p)const{
    if(h!=p.h)return h<p.h;
    if(m!=p.m)return m<p.m;
    return (double)n/(double)d < (double)p.n/(double)p.d;
  }
};

int main(){
  while(1){
    cin>>H>>h>>m>>s;
    if(H==0&&h==0&&m==0&&s==0)break;

    vector<data> t;
    
    int I=h,J=m,cnt=0;
    while(1){
      cnt++;
      int i=I,j=J;
      int a=(60*i+j+H*j+60*H)*60;
      int b=120*H-1-H;
      int ab=__gcd(a,b);
      a/=ab,b/=ab;
      if(a==0)b=1;
      
      int c=(60*i+j+H*j)*60;
      int d=120*H-1-H;
      int cd=__gcd(c,d);
      c/=cd,d/=cd;
      if(c==0)d=1;


      if(a>=b*60){
        j++;
        if(j==60)j=0,i++;
        if(i==H)i=0;
        a%=(b*60);
      }
      if(a<60*b &&a*(H-1)!=(3600*i+60*j-60*j*H)*b ){
        t.push_back( (data){i,j,a,b});
      }
      i=I,j=J;
      if(c<60*d && c*(H-1)!=(3600*i+60*j-60*j*H)*d ){
        t.push_back( (data){i,j,c,d});
      }

      J++;
      if(J==60)J=0,I++;
      if(I==H)I=0;
      if(I==h&&J==m)break;
    }
    sort(t.begin(),t.end());
    int k=lower_bound(t.begin(),t.end(),(data){h,m,s,1})-t.begin();
    data ans;
    if(k<(int)t.size())ans=t[k];
    else ans=t[0];
    cout<<ans.h<<' '<<ans.m<<' '<<ans.n<<' '<<ans.d<<endl;
  }
  return 0;
}

Measured memory_bytes: 1600
//-----------------------
// author : xyqkoala
// time : 2020-09-20
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 998244353;

void solve();


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


void solve(){
	int n,k;
	cin>>n>>k;
	vector<vector<int>> nums(k,vector<int>(2,0));
	for(int i=0;i<k;i++){
		cin>>nums[i][0]>>nums[i][1];
	}
	vector<LL> dp(n+2,0);
	dp[1] = 1;
	for(int i=2;i<=n;i++){
		for(int j=0;j<k;j++){
			int l = max(i-nums[j][1],1);
			int r = max(i-nums[j][0],0);
			dp[i] = ((dp[r]-dp[l-1])+dp[i])%MOD;
		}
		dp[i] = (dp[i]+dp[i-1])%MOD;
	}
	cout<<(dp[n]-dp[n-1]+MOD)%MOD<<endl;
}


Measured memory_bytes: 4672
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

ll x;
cin>>x;
for(int i=0;i<=120;i++)
{
    for(int j=-100;j<=119;j++)
    {
        if(po(i,5)-po(j,5)==x)
        {
            cout<<i<<" "<<j<<endl;
            return 0;
        }
    }
}

return 0;
}



Measured memory_bytes: 3660
#include <stdio.h>
int a[100005];
int main(void) {
    int n,i,x,k;
    int pos ;
    scanf("%d%d",&n,&k);
    for(i=1; i<=n; i++){
    scanf("%d",&a[i]);
    if(a[i]==1)pos = i;
    }
    int fir = pos - 1;
    int sec = n - pos;
    int f = k - 1;
    fir = (fir + f-1)/f;
    sec = (sec + f-1)/f;
 //   if(fir < sec)fir = sec;
 int ans = (n + f-2)/f ;
 if(fir + sec < ans)ans = fir + sec;
    printf("%d\n",ans);
	return 0;
}



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



int main(){
   cin.tie(0);
   ios::sync_with_stdio(false);
   cout << fixed << setprecision(20);
   
   string s; cin >> s;
   int ans=0,n=s.length();
   rep(i,0,n) if(i%2==s[i]%2)ans++;
   ans=min(ans,n-ans);
   cout << ans << endl;
   
}



Measured memory_bytes: 512
#!/usr/bin/env python3
h, w, d = map(int, input().split())
x = [None] * h * w
y = [[0] for _ in range(d)]
for i in range(h):
    r = [int(x) for x in input().split()]
    for j in range(w):
        x[r[j] - 1] = (i, j)
for i in range(d):
    for j in range(i + d, h * w, d):
        y[i].append(abs(x[j][0] - x[j - d][0]) + abs(x[j][1] - x[j - d][1]))
        y[i][-1] += y[i][-2]
for _ in range(int(input())):
    l, r = [int(x) - 1 for x in input().split()]
    m = l % d
    print(y[m][r // d] - y[m][l // d])


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

using namespace std;

void insertionSort(vector<double> &a, int g, long &cnt)
{
	int j;
	double v;
	for (int i = g; i < a.size(); i++)
	{
		v = a[i];
		j = i - g;
		while (j >= 0 && a[j] > v)
		{
			a[j + g] = a[j];
			j = j - g;
			cnt++;
			if (cnt > (int)pow(a.size(), 1.5))
			{
				return;
			}
		}
		a[j + g] = v;
	}
}

int shellSort(vector<double> &a, vector<int> &g)
{
	long cnt = 0;
	for (int i = 0; i < g.size(); i++)
	{
		insertionSort(a, g[i], cnt);
		if (cnt > (int)pow(a.size(), 1.5))
		{
			break;
		}
	}
	return cnt;
}

int main()
{
	int n;
	long cnt;
	cin >> n;
	vector<double> a(n, 0);
	vector<double> org(a);
	vector<int> g;
	for (int i = 0; i < n; i++)
	{
		cin >> org[i];
	}
	for (int m = 100; m >= 1; m--)
	{
		a = org;
		g.resize(m, 1);
		for (int i = 0; i < m; i++)
		{
			g[i] = (int)exp(m - i - 1);
		}
		if (g[0] < 0 || n < g[0])
		{
			continue;
		}
		else
		{
			cnt = shellSort(a, g);
			if (cnt <= pow(n, 1.5))
			{
				break;
			}
		}
	}
	cout << setprecision(10) << g.size() << endl;
	for (int i = 0; i < g.size(); i++)
	{
		cout << g[i];
		if (i == g.size() - 1)
		{
			cout << endl;
		}
		else
		{
			cout << " ";
		}
	}
	cout << cnt << endl;
	for (int i = 0; i < n; i++)
	{
		cout << a[i] << endl;
	}
}


Measured memory_bytes: 18292
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
#include <cstdint>

uintmax_t comb(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

double r,PI = 3.1415926535897932;
cin >> r;
cout << 2*r*PI << endl;


//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 3776
import sys
import math
from collections import deque
from collections import defaultdict

def main():
    h, n = list(map(int,sys.stdin.readline().split()))
    A = list(map(int,sys.stdin.readline().split()))
    print("Yes") if sum(A) >= h else print("No")
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 13836
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
 
int main() {
    int N;
    vector<int> root;
    cin >> N;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        root.push_back(a);
    }
    sort(root.begin(), root.end());
    reverse(root.begin(), root.end());

    long long p,q;
    p = 0;
    q = 0;
    long long re;
    while(!root.empty()){
        int x = root[0];
        root.erase(root.begin());
        if(root.empty()){
            break;
        }
        if(x == root[0]){
            root.erase(root.begin());
            p = (long long)x;
            break;
        }
    }

    while(!root.empty()){
        int x = root[0];
        root.erase(root.begin());
        if(root.empty()){
            break;
        }
        if(x == root[0]){
            root.erase(root.begin());
            q = (long long)x;
            break;
        }
    }

    re = p*q;
    cout << re << endl;
    
    return 0;
}



Measured memory_bytes: 892
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	var b = tmp[0];
	var c = tmp[1];
	console.log(c+b)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
MOD = 10 ** 9 + 7
table_len = 10 ** 5 + 10

fac = [1, 1]
for i in range(2, table_len):
    fac.append(fac[-1] * i % MOD)

finv = [0] * table_len
finv[-1] = pow(fac[-1], MOD - 2, MOD)
for i in range(table_len-1, 0, -1):
    finv[i-1] = finv[i] * i % MOD


def sum_of_maxS(N, K, As):
    ret = 0
    for i in range(N - K + 1):
        ret += ((As[i] * fac[N - i - 1]) % MOD) * \
            ((finv[K-1] * finv[N - K - i]) % MOD) % MOD
        ret %= MOD
    return ret


N, K = map(int, input().split())
As = sorted(map(int, input().split()), reverse=True)

minus_As = [-A for A in reversed(As)]

print((sum_of_maxS(N, K, As) + sum_of_maxS(N, K, minus_As)) % MOD)


Measured memory_bytes: 97928
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define sz size()
#define pb push_back
#define bg begin()
#define ed end()
#define fi first()
#define se second()
using namespace std;
using ll = long long;
using vint = vector<int>;
using pint = pair<int,int>;
using vpint = vector<pint>;
template <typename T>
T sq(T x){
  return x * x;
}
ll mod = 1e9 + 7;

signed main (){
  int N;
  cin >> N;
  ll count = 0;
  vector<bool> dp(mod,false);
  ll A;
  rep(i,N){
    cin >> A;
    if(dp.at(A)){
dp.at(A) = false;
count--;
    }else{
dp.at(A) = true;
count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 125192
#include <stdio.h>
#define LL long long
#define maxn 3010
#define mod 998244353
LL dp[maxn];
int main(){
	int n,s,x,i,j,inv2;
	scanf("%d%d",&n,&s);
	inv2=mod-mod/2,dp[0]=1;
	for(i=1;i<=n;i++)dp[0]=dp[0]*2%mod;
	for(i=1;i<=n;i++){
		scanf("%d",&x);
		for(j=s;j>=x;j--)
			dp[j]=(dp[j]+dp[j-x]*inv2)%mod;
	}
	printf("%lld\n",dp[s]);
	return 0;
}

Measured memory_bytes: 1720
#include <iostream>


#define ll long long
#define US unsigned
#define UINT unsigned int

using namespace std;



int main() {
	int X, Y;
	cin >> X >> Y;
	int two, four,ans;
	int c;
	for (c = 0; c <= X; c++) {
		two = c;
		four = X - c;
		ans = two * 2 + four * 4;
		if (ans == Y) {
			cout << "Yes"<<endl;
			return 0;
		}		
	}

	cout << "No"<<endl;
		
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
#define FIO \
    freopen("input.txt","r",stdin); \
    freopen("output.txt","w",stdout);
int main()
{
    //FIO;
    int n,k; cin>>n>>k;
   long long int a[n]; for(int i = 0 ; i < n; i++) cin>>a[i];
    long long int temp=1;
    for(int i = k; i < n; i++)
    {
        if(a[i-k]<a[i])
          cout<<"Yes\n";
        else
          cout<<"No\n";
        
    }
    return 0;
}

Measured memory_bytes: 4700
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

ll f(vp p) {
  int n = sz(p);
  vi l, r;
  rep(i,n) l.pb(p[i].fi);
  rep(i,n) r.pb(p[i].se);
  sort(rng(l)); reverse(rng(l));
  sort(rng(r));
  ll res = 0;
  int li = 0, ri = 0;
  ll x = 0;
  while (ri<n) {
    if (li == ri) {
      if (l[li] < x) break;
      res += l[li]-x;
      x = l[li];
      ++li;
    } else {
      if (r[ri] > x) break;
      res += x-r[ri];
      x = r[ri];
      ++ri;
    }
  }
  res += abs(x);
  return res;
}

int main() {
  int n;
  scanf("%d",&n);
  vp p(n);
  cin>>p;
  ll ans = 0;
  rep(i,2) {
    ll now = f(p);
    maxs(ans,now);
    rep(i,n) {
      swap(p[i].fi,p[i].se);
      p[i].fi = -p[i].fi;
      p[i].se = -p[i].se;
    }
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll a,b;


signed main(){
	int k; cin>>a>>b>>k;
	rep(i,k){
		if(i%2){
			if(b%2) b--;
			b/=2; a+=b;
		}else{
			if(a%2) a--;
			a/=2; b+=a;
		}
		// cerr << i SP a SP b << endl;
	}
	cout<<a SP b<<endl;
	return 0;
}


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

int main(void){
    int i;
    int n;
    //printf(">");
    scanf("%d",&n);
    if(n<1||n>20){
        exit(0);
    }
    printf("\n");

    int v[n];
    for(i=0;i<n;i++){
        //printf(">");
        scanf("%d",&v[i]);
        if(v[i]<1||v[i]>50){
            exit(0);
        }
    }
    printf("\n");

    int c[n];
    for(i=0;i<n;i++){
        //printf(">");
        scanf("%d",&c[i]);
        if(c[i]<1||c[i]>50){
            exit(0);
        }
    }
    printf("\n");

    int ans=0;
    for(i=0;i<n;i++){
        if(v[i]>c[i]){
            ans+=(v[i]-c[i]);
        }
    }
    printf("%d",ans);

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <cmath>
#include <algorithm>

#define NUM 300500

int main(){
	int table[NUM],limit,pre_div,tmp;

	for(int i=0; i < NUM;i++)table[i] = 1;

	limit = sqrt(NUM);

	pre_div = -1;

	for(int i=1;7*i+pre_div<=limit;){
		if(table[(tmp=7*i+pre_div)] == 1){
			for(int k=2*tmp;k < NUM; k += tmp){
				table[k] = 0;
			}
		}
		if(pre_div == -1){
			i++;
			pre_div = -6;
		}else{
			pre_div = -1;
		}
	}

	int n;

	while(true){
		scanf("%d",&n);
		if(n == 1)break;

		pre_div = -1;
		printf("%d:",n);
		for(int i=1;7*i+pre_div<=n;){
			tmp = 7*i+pre_div;
			if(table[tmp] == 1 && n%(tmp) == 0){
				printf(" %d",tmp);
			}

			if(pre_div == -1){
				i++;
				pre_div = -6;
			}else{
				pre_div = -1;
			}
		}
		printf("\n");
	}
	return 0;
}

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

class aizu_judge
{
    static void Main(string[] args)
    {
        while(true)
        {
            int[] num = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (num[0] + num[1] == 0)
                break;

            string width = new string('#', num[1]);

            for (int i = 0; i < num[0]; i++)
            {
                Console.WriteLine(width);
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 9376
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <climits>
#include <queue>

using namespace std;

const int kSize = 50001;
const int kCoins = 20;
int main() {
    int n, m;
    int coins[kCoins];
    cin >> n >> m;

    for (int i = 0; i < m; ++i) {
        cin >> coins[i];
    }

    int dp[kSize];

    for (int i = 0; i <= n; ++i) {
        dp[i] = INT_MAX;
    }

    dp[0] = 0;

    for (int i = 0; i < m; ++i) {
        for (int j = 0; j + coins[i] <= n; ++j) {
            dp[j + coins[i]] = min(dp[j + coins[i]], dp[j] + 1);
        }
    }

    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 3284
#include<stdio.h>
int main(void)
{
	int a1,a2,a3,b1,b2,b3,i;
	int x,xx,z,h,hh,m,mm,s;
	for(i=0;i<3;i++){
		scanf("%d %d %d %d %d %d",&a1,&a2,&a3,&b1,&b2,&b3);
		x=a1*3600+a2*60+a3;
		xx=b1*3600+b2*60+b3;
		z=xx-x;
		h=z/3600;
		m=z%3600/60;
		s=z%3600%60;
		printf("%d %d %d\n",h,m,s);
	}
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str[] = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
            String masu[] = new String[h];
            for (int i = 0; i < h; i++) {
                masu[i] = br.readLine();
            }
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    int num = 0;
                    char ch = masu[i].charAt(j);
                    if (ch == '#') {
                        System.out.print(ch);
                    } else {
                        if (j > 0) {
                            if (masu[i].charAt(j - 1) == '#') {
                              num++;
                            }
                            if (i > 0 && masu[i - 1].charAt(j - 1) == '#') {
                                num++;
                            }
                            if (h - 1 > i && masu[i + 1].charAt(j - 1) == '#') {
                                num++;
                            }
                        }
                        if (i > 0 && masu[i - 1].charAt(j) == '#') {
                            num++;
                        }
                        if (h - 1 > i && masu[i + 1].charAt(j) == '#') {
                            num++;
                        }
                        if (w - 1 > j) {
                            if (masu[i].charAt(j + 1) == '#') {
                                num++;
                            }
                            if (i > 0 && masu[i - 1].charAt(j + 1) == '#') {
                                num++;
                            }
                            if (h - 1 > i && masu[i + 1].charAt(j + 1) == '#') {
                                num++;
                            }
                        }
                        System.out.print(num);
                    }
                }
                System.out.println();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 23124