akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] abc = br.readLine().split(" ");
        int a = Integer.parseInt(abc[0]);
        int b = Integer.parseInt(abc[1]);
        int c = Integer.parseInt(abc[2]);
        String ans = "NO";
        int sum = 0;
        int num;
        for (int i = 1; i <= b ;i++) {
            num = a * i;
            if (num % b == c) ans = "YES";
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 21332
s = input()
n = len(s)
if s[0] == '0':
    print(-1)
    exit(0)
if s[-1] == '1':
    print(-1)
    exit(0)
for i in range((n - 1) // 2):
    if s[i] != s[n - i - 2]:
        print(-1)
        exit(0)
p = 1
t = 2
i = n - 2
while i >= 0:
    print(p, t)
    if s[i] == '1':
        p = t
    t += 1
    i -= 1

Measured memory_bytes: 4648
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
double pi=3.141592653589793;

const int MOD = 1000000007;

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

ll N,M;
vector<ll>A(106);

void batten(ll i,ll k){
	if(i==N)return;
	if((A[i]%k)>(A[i+1]%k)){
		swap(A[i],A[i+1]);
		batten(i+1,k);
		return;
	}else{
		batten(i+1,k);
		return;
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll N;
	cin>>N;
	vector<ll>A(N+1,0);
	for(int i=1;i<=N;i++)cin>>A[i];
	
	ll ans=0;
	for(int i=1;i<=N;i++){
		ll j=A[i];
		if(A[j]==i)ans++;
	}
	cout<<ans/2<<endl;
}



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

int main()
{
  char s[100001];
  cin >> s;
  
  int rlen[100001] = {0};

  int N = strlen(s);
  int m = 0;
  char LR = 'R';

  rep(i,N){
    if (s[i] == LR) {
      rlen[m]++;
    }
    else {
      rlen[++m]=1;
      if (LR=='L') LR = 'R';
      else LR = 'L';
    }
  }

  LR = 'R';
  int j=0;
  while(rlen[j]>0){
    int e1 = rlen[j]/2 + rlen[j]%2;
    int o1 = rlen[j]/2;
    int e2 = rlen[j+1]/2 + rlen[j+1]%2;
    int o2 = rlen[j+1]/2;

    rep(i, rlen[j]-1) cout << "0 ";
    cout << e1+o2 << " ";
    cout << o1+e2 << " ";
    rep(i, rlen[j+1]-1) cout << "0 ";
    j+=2;
  }
  cout << endl;
}

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

int main() {
    string t, h;
    int n; cin >> n;
    int pt = 0, ph = 0;
    while (cin >> t >> h) {
        pt += 3 * (t > h) + (t == h);
        ph += 3 * (t < h) + (t == h);
    }
    cout << pt << " " << ph << endl;
}


Measured memory_bytes: 3144
fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut sc: Vec<(usize, u8)> = vec![];
    for _ in 0..m {
        sc.push((read(), read()));
    }

    for i in 0..10_i32.pow(n as u32) {
        // 100
        let ss = format!("{}", i);
        if ss.len() != n {
            continue;
        }
        let ss: Vec<u8> = ss.as_bytes().to_vec().iter().map(|x| x - b'0').collect();
        if sc.iter().all(|&(s, c)| ss[s - 1] == c) {
            println!("{}", i);
            return;
        }
    }
    println!("-1");
}

use std::io::stdin;
use std::io::Read;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let token: String = cin
        .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")
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define endl '\n'
#define fastio ios::sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

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

int main() {
	fastio;
	int N;
	cin >> N;

	vector<int> vec(N);
	for (int &i : vec) cin >> i;

	sort(all(vec));

	ll pre[100000]{ vec[0] };
	for (int i = 1; i < N; ++i) pre[i] = pre[i - 1] + vec[i];
	
	int ans = 1;
	for (int i = N - 2; i >= 0; --i) {
		if (pre[i] * 2 < vec[i + 1]) break;
		++ans;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 1408
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# from numpy import array, sum

MAX_DIVIDER = 32 # 32 ** 2 = 1024 > 1000

X =int(input())

li = set()

li.add(1)

b = 2
while b < MAX_DIVIDER:
	c = b * b
	while c <= 1000:
		li.add(c)
		c *= b
	b += 1

while X > 0:
	if X in li:
		print(X)
		break
	else:
		X -= 1

Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, x, y;

  for ( ; ; )
  {
    int map[ 2 ][ 3 ][ 3 ] = { { { 0 } } };
    int mother = 1;
    int sw = 0;
    int n;
    int sx, sy, tx, ty, bx, by;
    char s, t, b;

    scanf ( " %d", &n );
    if ( !n ) break ;

    scanf ( " %c %c %c", &s, &t, &b );
    sx = ( s - 'A' ) % 3; sy = ( s - 'A' ) / 3;
    tx = ( t - 'A' ) % 3; ty = ( t - 'A' ) / 3;
    bx = ( b - 'A' ) % 3; by = ( b - 'A' ) / 3;

    map[ sw ][ sx ][ sy ] = 1;
    for ( i = 0; i < n; ++i )
    {
      mother *= 4;
      sw = !sw;

      memset ( map[ sw ], 0, sizeof ( map[ sw ] ) );

      for ( y = 0; y < 3; ++y )
      for ( x = 0; x < 3; ++x )
      {
        map[ sw ][ ( x < 1 || ( y == by && x - 1 == bx ) ? x : x - 1 ) ][ y ]
          += map[ !sw ][ x ][ y ];
        map[ sw ][ ( x > 1 || ( y == by && x + 1 == bx ) ? x : x + 1 ) ][ y ]
          += map[ !sw ][ x ][ y ];
        map[ sw ][ x ][ ( y < 1 || ( x == bx && y - 1 == by ) ? y : y - 1 ) ]
          += map[ !sw ][ x ][ y ];
        map[ sw ][ x ][ ( y > 1 || ( x == bx && y + 1 == by ) ? y : y + 1 ) ]
          += map[ !sw ][ x ][ y ];
      }
    }

    printf ( "%.6lf\n", (double)map[ sw ][ tx ][ ty ] / (double)mother );
  }

  return ( 0 );
}

Measured memory_bytes: 0
N = int(input())
input_v_list = list(map(int, input().split()))

cnt = 0             # 出力の個数
min_var = 2 * 10**6 # 最小値(初期値2*10^5以上)

# 比較用リストに一つずつ値をセット
for i in input_v_list:
    
    # 最小値更新
    if(min_var > i):
        min_var = i

    # i <= min のとき個数をカウント
    if(i <= min_var):
        cnt += 1

# 出力
print(cnt)

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

int sum_digit(string str)
{
    int sum=0;
    for(int i=0 ; i<str.length() ; ++i)
    sum+=(str[i]-'0');
    return sum;
}

int main()
{
  	int a,b,c;
  	cin>>a>>b>>c;
  	int total=0;
  	for(int i=1 ; i<=a ; ++i)
  	{
  	    int digit=sum_digit(to_string(i));
  	    if(digit>=b && digit<=c)
  	    total+=i;
  	}
  	cout<<total<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

char s[10];
int cnt[26];
int main() {
	scanf("%s", s);
	for (int i = 0; i < 4; i++)
		cnt[s[i] - 'A']++;
	int count = 0;
	for (int i = 0; i < 26; i++)
		count += cnt[i] == 2;
	printf(count == 2 ? "Yes\n" : "No\n");
}

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

void solve(long long K, long long A, long long B) {
  for (int i = A; i <= B; ++i) {
    if (i % K == 0) {
      cout << "OK" << endl;
      return;
    }
  }
  cout << "NG" << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long K;
  scanf("%lld", &K);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  solve(K, A, B);
}


Measured memory_bytes: 3784
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean ans = true;
        String[] s = new String[n];
        s[0] = sc.next();
        for(int i =1;i<n;i++){
            String tmp = sc.next();
            if(Arrays.asList(s).contains(tmp)){
                ans = false;
                break;
            }
            s[i] = tmp;
            if(s[i].charAt(0)!=s[i-1].charAt(s[i-1].length()-1)){
                ans = false;
                break;
            }
        }
        if(ans){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

#[allow(unused_macros)]
macro_rules! vec_md {
    ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) };
    ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] };
    ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] };
}

#[allow(dead_code)]
pub const M: u64 = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        a: [[u32;n];n]
    }

    let mut dp = vec_md![0u64;n+1;1 << n];
    dp[0][0] = 1;
    for i in 0..n {
        let mut bit = (1 << i) - 1;
        while bit < 1 << n {
            
            for j in 0..n {
                if bit >> j & 1 == 0 && a[i][j] == 1 {
                    dp[i+1][bit | (1 << j)] += dp[i][bit];
                    dp[i+1][bit | (1 << j)] %= M;
                }
            }
            if bit == 0 {break;}
            let x = (bit as i64 & -(bit as i64)) as usize;
            let y = bit + x;
            bit = ((bit & !y) / x >> 1) | y;
        }
    }
    println!("{}", dp[n][(1<<n)-1]);
}


Measured memory_bytes: 364924
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: i64 = iter.next().unwrap().parse().unwrap();
    let mut ans = 1000000000000000000i64;
    for i in 1..n {
        if i * i > n {
            break;
        }
        if n % i == 0 {
            ans = std::cmp::min(ans, i + n / i - 2);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(10**6)

#a = int(input())
#b = list(map(int, input().split()))
x, a = map(int, input().split())
#s = input()
#s,t = input().split()
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

if x < a:
    print(0)
else:
    print(10)

Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    vector<pair<string, int> > vec[N+1];
    vec[1].pb(make_pair("a", 0));
    rep2(i, 2, N){
        for(auto &e: vec[i-1]){
            string c = e.first;
            rep(j, e.second+1){
                vec[i].pb(make_pair(c+alpha[j], e.second));
            }
            vec[i].pb(make_pair(c+alpha[e.second+1], e.second+1));
        }
    }
    //cout << vec[N].size() << endl;
    for(auto &e: vec[N]){
        cout << e.first << endl;
    }
}

Measured memory_bytes: 10736
w, a, b = map(int, input().split())
x = [0]*(max(a+w, b+w)+1)

for i in range(a, a+w):
    x[i] += 1

for i in range(b, b+w):
    x[i] += 1

ans = 0
for i in range(min(a,b), max(a+w, b+w)):
    if x[i] == 0:
        ans += 1

print(ans)


Measured memory_bytes: 4596
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;  
    using ll = long long;
    using P = pair<int,int>; 
     
    int main() {
     int n,m;
     cin >> n >> m;
     vector<int> a(n);
     rep(i,n)    cin >> a[i];
     
     int s=0;
     
     rep(i,n)  s+=a[i];
     
     int cnt=0;
     
     
     rep(i,n){
         if(a[i]*(4*m)>=s)  cnt++;
     }
        if(cnt>=m) cout <<"Yes"<< '\n';
        else cout <<"No"<< '\n';
      
    }

Measured memory_bytes: 256
#pragma region
#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
#define rep(i, a, n) for (long long i = a; i <= n; i++)
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
#pragma endregion
int main() {
    IO;
    ll ans = 1;
    ll n;
    cin >> n;
    int flag = 0;
    while (n--) {
        ll x;
        cin >> x;
        if (!x) {
            cout << "0\n";
            return 0;
        }
        if (ll(1e18) / ans >= x)
            ans *= x;
        else
            flag = 1;
    }
    if (flag)
        cout << "-1\n";
    else
        cout << ans << endl;
}

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


def main():
    k, t = map(int, input().split())
    a = list(map(int, input().split()))
    max_value = 0
    max_value_index = -1
    ans = 0

    for index, ai in enumerate(a):
        if ai > max_value:
            max_value = ai
            max_value_index = index

    prev = max_value_index
    a[prev] -= 1

    # KeyInsight
    # できる限り前と同じケーキを選ばないようにしながら，残りが最も多いケーキを選択
    # See:
    # http://competitive-kivantium.hateblo.jp/entry/2016/10/24/135521
    for i in range(k - 1):
        max_value = 0
        max_value_index = -1

        # 残りのケーキが最大となるものを求める
        for j in range(t):
            if a[j] > max_value and j != prev:
                max_value = a[j]
                max_value_index = j

        if max_value_index != -1:
            prev = max_value_index
            a[max_value_index] -= 1
        else:
            a[prev] -= 1
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  int s;
  cin >> s;
  
  int cnt = 0;
  int bit0;
  for(int i = 0; i < 3; ++i){
    bit0 = s & 0x1;
    if(1 == bit0){
      ++cnt;
    }
    s >>= 1;
  }
    
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define rep(i, n) for (int i =  0; i < (int)(n); i++)

int n, m, f[64][64];

void rec(int x, int y) {
    if (f[x][y] == 0) return ;
    f[x][y] = 0;
    rep (i, 3) rep (j, 3) rec(x+i-1, y+j-1);
}

int main() {
    for (;;) {
        scanf("%d%d", &m, &n);
        if (n == 0) return 0;
        memset(f, 0, sizeof(f));
        rep (i, n) rep (j, m) scanf("%d", f[i+1]+j+1);
        int c = 0;
        rep (i, n) rep (j, m) if (f[i+1][j+1]) c++, rec(i+1, j+1);
        printf("%d\n", c);
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;
const int MAX = 1000010;

/*

あるp,qを用いて、
x=p+2*q
y=2*p+q
となるp,qを求める
*/

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



void solve(){
    int x,y;
    cin >> x;
    cin >> y;

    if((2*y-x)%3==0){

    
    ll p,q;
    p = (2*y-x)/3;
    q = y - 2*p;

    COMinit();
    cout << (COM(p+q,q)) << endl;

    }
    else{
        cout << 0 << endl;
    }

}

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


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

using namespace std;

int main() 
{ 
   string s1; 
    string s2;
     int n1;
cin>>n1;
 
    cin>>s1;

      cin>>s2;

     int x= 2*n1;
     char char_array1[n1];
     char char_array2[n1];
     char char_array[x];

     strcpy(char_array1, s1.c_str());
     strcpy(char_array2, s2.c_str());
     
       
int j=0,k=0;
     for(int i=0;i<x;i++)
     {
       if(i%2==0)
       char_array[i]= char_array1[j++];
       else
       char_array[i]= char_array2[k++];     
     }

  for(int i=0;i<x;i++)
   cout<<char_array[i];     
     
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
// using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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 ll INF = 1e16;

ll f(pll p, pll q) {
  ll dx = abs(p.first-q.first);
  ll dy = abs(p.second-q.second);
  return dx+dy;
}

int main() {
  int n;
  cin>>n;
  vc(pll) p(n);
  REP(i, n) cin>>p[i].first>>p[i].second;
  ll ma = INF;
  ll mb = INF;
  ll Ma = -INF;
  ll Mb = -INF;

  REP(i, n) {
    ll x = p[i].first;
    ll y = p[i].second;
    ll a = x+y;
    ll b = x-y;
    chmin(ma, a);
    chmin(mb, b);
    chmax(Ma, a);
    chmax(Mb, b);
  }
  ll ans = max((Ma-ma), (Mb-mb));
  

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6424
fun main() {
    val (n,m) = readLine()!!.split(" ").map(String::toInt)

    val h = readLine()!!.split(" ").map(String::toLong)

    val ab = Array(m){ //ab[1][0]
        readLine()!!.split(" ").map(String::toInt)
    }.sortedBy { it[0] }

    val flgs = Array(n){
        true
    }

    ab.forEach {
        if (h[it[0]-1] > h[it[1]-1]){
            flgs[it[1]-1] = false
        }else if(h[it[0]-1] < h[it[1]-1]){
            flgs[it[0]-1] = false
        }else{
            flgs[it[0]-1] = false
            flgs[it[1]-1] = false
        }
    }

    println("${flgs.count { it }}")

}

Measured memory_bytes: 75180
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  if(0<(c-a-b)*(c-a-b)-4*a*b && c-a-b>=0){
    cout << "Yes";
  }else{
    cout <<"No";
  }
}
  

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

using namespace std;

typedef complex<double> Point;
const double eps = 1e-9;
const int N = 1e5+10;
const double inf = 1e6;

bool eq(const double &a,const double &b)
{
    return abs(a-b)<eps;
}

bool cmp(const Point &a,const Point &b)
{
    if(eq(a.real(),b.real()))
    {
        return a.imag()<b.imag();
    }else
    {
        return a.real()<b.real();
    }
}

bool cmp1(const Point &a,const Point &b)
{
    if(eq(a.imag(),b.imag()))
    {
        return a.real()<b.real();
    }else
    {
        return a.imag()<b.imag();
    }
}

int get_low(const vector<Point> &arr,double x)
{
    int sz = arr.size();
    int l=0,r=sz-1;
    while(l<r)
    {
        int mid = (l+r)/2;
        if(arr[mid].imag()<x)
        {
            l = mid+1;
        }else
        {
            r = mid;
        }
    }
    if(arr[l].imag()<x) return sz;
    return l;
}

double closest_pair(Point *points,int sz)
{
    if(sz<4)
    {
        double ans = inf;
        for(int i=0;i<sz;i++)
        {
            for(int j=0;j<i;j++)
            {
                double tmp = abs(points[i]-points[j]);
                if(tmp < ans)
                {
                    ans = tmp;
                }
            }
        }
        return ans;
    }
    int mid =  sz/2;
    double x = points[mid].real();
    double d = min(closest_pair(points,mid),closest_pair(points+mid,sz-mid));
    vector<Point> arr;
    for(int i = mid;i<sz;i++)
    {
        if(points[i].real()-x < d+eps) arr.push_back(points[i]);
    }
    sort(arr.begin(),arr.end(),cmp1);
    double ans = d;
    for(int i=0;i<mid;i++)
    {
        if(x-points[i].real()<d+eps)
        {
            int low = get_low(arr,points[i].imag()-d-eps);
            int high = get_low(arr,points[i].imag()+d+eps);
            for(int j=low;j<high;j++)
            {
                double dist = abs(points[i]-arr[j]);
                if(dist<ans)
                {
                    ans = dist;
                }
            }
        }
    }
    return ans;
}

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

    Point points[N];

    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        double x,y;
        cin>>x>>y;
        points[i] = Point(x,y);
    }
    sort(points,points+n,cmp);

    cout<<fixed<<setprecision(10)<<closest_pair(points,n)<<endl;

    return 0;
}



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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
// end of Template

int op[4],dig[5];
str s;
bool valid = false;
bool validity(){
    int sum = 0;
    int a,b,c,d;
    a = dig[1];
    b = dig[2];
    c = dig[3];
    d = dig[4];

    if(op[1]==1){b*=-1;}
    if(op[2]==1){c*=-1;}
    if(op[3]==1){d*=-1;}

    sum = a+b+c+d;

    if(sum==7){return true;}
    else return false;
}
str sym(int x){
    if(x==0)return "+";
    else return "-";
}
void comb(){
    for(int i=0;i<=1;i++){
        for(int j=0;j<=1;j++){
            for(int k=0;k<=1;k++){
                op[1] = i;
                op[2] = j;
                op[3] = k;
                valid = validity();
                if(valid){
                    cout<<dig[1]<<sym(op[1])<<dig[2]<<sym(op[2])<<dig[3]<<sym(op[3])<<dig[4]<<"=7\n";
                    break;
                }
            }
            if(valid)break;
        }
        if(valid)break;
    }
}
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s;
    for(int i=0;i<s.size();i++){
        dig[i+1] = numerize(s[i]);
    }
    comb();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;

int main(int argc, char* argv[]) {

	int N;
	double T, A;
	double min = 999;
	int ans = 1;

	cin >> N;
	cin >> T >> A;

	vector<double>H(N, 0);

	for (int i = 0; i < N; i++) {
		cin >> H[i];
		if (min > fabs(A - (T - H[i] * 0.006))) {
			min = fabs(A - (T - H[i] * 0.006));
			ans = i + 1;
		}
	}

	cout << ans << endl;

	return 0;

}


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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

int cmp(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int *h=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",h+i);
  qsort(h,n,sizeof(int),cmp);
  int min=1000000000;
  for(i=0;i+k-1<n;i++){
    int d=h[i+k-1]-h[i];
    if(d<min) min=d;
  }
  printf("%d\n",min);
}

int main(void){
  run();
  return 0;
}


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

ll dp[105][5][2];

int main() {
    string N; cin >> N;
    int K; cin >> K;
    int n = N.size();
    dp[0][0][0] = 1;
    rep(i, n){
        int x = N[i] - '0';
        rep(j, 10){
            if(j == 0){
                if(N[i] == '0'){
                    rep(k, K+1){
                        dp[i+1][k][0] += dp[i][k][0];
                        dp[i+1][k][1] += dp[i][k][1];
                    }
                } else {
                    rep(k, K+1){
                        dp[i+1][k][1] += dp[i][k][0] + dp[i][k][1];
                    }
                }
            } else if (j < x){
                rep(k, K+1){
                    dp[i+1][k+1][1] += dp[i][k][0] + dp[i][k][1];
                }
            } else if (j == x){
                rep(k, K+1){
                    dp[i+1][k+1][0] += dp[i][k][0];
                    dp[i+1][k+1][1] += dp[i][k][1];
                }
            } else {
                rep(k, K+1){
                    dp[i+1][k+1][1] += dp[i][k][1];
                }
            }
        }    
    }

    cout << dp[n][K][0] + dp[n][K][1] << endl;

    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;

static const int  MAX_INT = std::numeric_limits<int>::max();
static const long MAX_LONG = std::numeric_limits<long>::max();
static const ll   MAX_LL = std::numeric_limits<long long>::max();

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


///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
    int x; cin >> x;
    cout << (x == 0 ? 1 : 0) << endl;
}

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

    double tmp;
    cin >> tmp;

    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,x;
    while(cin>>a>>b){
        x=a+b;
        if(x>=10){
            cout<<"error"<<endl;
        }
        else {
            cout<<x<<endl;
        }
    }
    return 0;
}


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

int main() {
  int N, sum;
  cin >> N;
  sum = 0;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    sum += b-a+1;
  }
  cout << sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll dp[2][4010][2];
int N, M, K, T;

void solve() {
	cin >> N >> M >> K;
	int T = (N + M - 1) / (K - 1);

	int now = 0, nex = 1;
	dp[now][0][0] = 1;

	rep(i, 0, T) {
		memset(dp[nex], 0, sizeof(dp[nex]));
		rep(j, 0, M + 1) {
			rep(k, 0, 2) {
				if(!dp[now][j][k]) continue;
				// debug(i, j, k, dp[now][j][k]);
				if(j == 0) {
					assert(k == 0);
					rep(cnt, 0, K) {
						ADD(dp[nex][j + cnt][0], dp[now][j][k]);
					}
					ADD(dp[nex][j + K][1], dp[now][j][k]);
				}
				else {
					if(k == 0) {
						rep(cnt, 0, K) {
							ADD(dp[nex][j + cnt][0], dp[now][j][k]);
						}
					}
					else {
						rep(cnt, 0, K - 1) {
							ADD(dp[nex][j + cnt][0], dp[now][j][k]);
						}
						ADD(dp[nex][j + K - 1][1], dp[now][j][k]);
					}
				}
			}
		}

		swap(now, nex);
	}
	cout << dp[now][M][0] << "\n";

}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S moddw_L(S a, const T b){
  a %= b;
  if(a < 0){
    a += b;
  }
  return a;
}
int K;
int X;
int Y;
int cx;
int cy;
int ress;
int resx[200000];
int resy[200000];
int main(){
  int dx, dy, fx, fy, i, j, r, res;
  rd(K);
  rd(X);
  rd(Y);
  if(K%2 == 0 &&moddw_L((X+Y),2)== 1){
    wt_L(-1);
    wt_L('\n');
    return 0;
  }
  while(X != cx || Y != cy){
    dx = abs(cx - X);
    dy = abs(cy - Y);
    if(cx < X){
      fx = 1;
    }
    else{
      fx = -1;
    }
    if(cy < Y){
      fy = 1;
    }
    else{
      fy = -1;
    }
    if( dx+dy == K){
      cx = X;
      cy = Y;
    }
    else if( dx+dy >= 2*K || (K%2==1 && (dx+dy)%2==1) ){
      i =min_L(K, dx);
      cx += fx * i;
      cy += fy * (K- i);
    }
    else{
      r = (2*K - dx - dy) / 2;
      if(dx <= K - r){
        i = dx + r;
        j = K - i;
      }
      else{
        j = dy + r;
        i = K - j;
      }
      cx += fx * i;
      cy += fy * j;
    }
    resx[ress] = cx;
    resy[ress] = cy;
    ress++;
  }
  wt_L(ress);
  wt_L('\n');
  for(i=0;i<ress;i++){
    wt_L(resx[i]);
    wt_L(' ');
    wt_L(resy[i]);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int K, X, Y;
// 
// int cx, cy;
// int ress, resx[200000], resy[200000];
// 
// {
//   int i, j, r, res;
//   int dx, dy, fx, fy;
//   rd(K,X,Y);
// 
//   if(K%2 == 0 && (X+Y)%%2 == 1){
//     wt(-1);
//     return 0;
//   }
// 
//   while(X != cx || Y != cy){
//     dx = abs(cx - X);
//     dy = abs(cy - Y);
//     if(cx < X) fx = 1; else fx = -1;
//     if(cy < Y) fy = 1; else fy = -1;
// 
//     if( dx+dy == K){
//       cx = X;
//       cy = Y;
//     } else if( dx+dy >= 2K || (K%2==1 && (dx+dy)%2==1) ){
//       i = min(K, dx);
//       cx += fx * i;
//       cy += fy * (K- i);
//     } else {
//       r = (2K - dx - dy) / 2;
// 
//       if(dx <= K - r){
//         i = dx + r;
//         j = K - i;
//       } else {
//         j = dy + r;
//         i = K - j;
//       }
// 
//       cx += fx * i;
//       cy += fy * j;
//     }
// 
//     resx[ress] = cx;
//     resy[ress] = cy;
//     ress++;
//   }
// 
//   wt(ress);
//   rep(i,ress) wt(resx[i], resy[i]);
// }


Measured memory_bytes: 3840
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int K, N; cin >> K >> N;
    vector<int> As(N); for (auto &Ai : As) cin >> Ai;
    int ans = K - (As.front() + K - As.back());
    for (int i = 0; i < N - 1; ++i)
    {
        int dist = As[i + 1] - As[i];
        ans = min(ans, K - dist);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> P;

int main() {
	int n;
	cin >> n;
	vi a(n);
	Loop(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int m = a[0];
	int M = a[n - 1];
	bool ans = true;
	if (a[0] == a[1] && a[1] == a[2]) {
		//minimumが3個以上はimpossible
		ans = false;
	}
	else if (a[0] == a[1]) {
		//minimumが2個
		if (M > m * 2 - 1) ans = false; //範囲外
		else {
			int x = m;
			Loop(i, n) {
				if (a[i] - x <= 1) x = a[i];
				else {
					ans = false;
					break;
				}
			}
		}
	}
	else {
		//minimumが1個
		if (M > m * 2) ans = false;
		else {
			int x = m;
			Loop(i, n) {
				if (a[i] - x <= 1) x = a[i];
				else {
					ans = false;
					break;
				}
			}
		}
	}
	if (ans) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void){
  int a,b,c,i;
  int k = 0;
  for(;;){
  	scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    if (a >= 0 && a <= 100 && b >= 0 && b <= 100 && c >= 0 && c <= 100){
      break;
    }
  }
  	if (a > b){
      k = 0;
    }else{ 
      for(i = 1; i <= c; i++){
        b = b - a;
        k = i;
        if (a > b){
          break;
        }  
        
      }
    }
   printf("%d",k);
  }

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    
    int ans = 0;
    int num = 1;
    while(num < b) {
        ans++;
        num += a - 1;
    }
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
N = I()
ans = int(0)
d = LI()

for i in range(N):
    for j in range(i+1,N):
        ans += d[i]*d[j]

print(ans)


Measured memory_bytes: 3060
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

S = input()
make = 0
for s in S:
    if s == 'x':
        make += 1

if make >= 8:
    print('NO')
else:
    print('YES')


Measured memory_bytes: 4460
function main()
  
  N = parse(Int,readline())
  a = map(x -> parse(Int,x), split(readline()))
  
  dict = Dict()
  
  for i in 0:10^5
    dict[i] = get(dict,i,0)
    if 1 <= i <= N
      dict[a[i]] = get(dict,a[i],0)+1
    end
  end
  
  ans = 0
  
  for i in 0:10^5-2
    save = dict[i]+dict[i+1]+dict[i+2]
    ans = max(ans,save)
  end
  
  println(ans)
  
end

main()

Measured memory_bytes: 153232
N = int(input())
A = [[0 for i in range(2)] for j in range(N)]

for i in range(N):
    A[i] = [int(x) for x in input().split()]


sum = [[0 for i in range(2)]for j in range(N)]
for i in range(N):
    sum[i][0]=A[i][0]+A[i][1]
    sum[i][1] = i

##最大値を取るiの番号を特定                                                                                                                                                                                 
sum = sorted(sum)
sum.reverse()
max = 0
for i in range(N):
    if(i%2==0):
        max = max + A[sum[i][1]][0]
    else:
        max = max - A[sum[i][1]][1]

print(max)

Measured memory_bytes: 40592
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if((a==1 and b==2) or (a==2 and b==1))
    cout<<3<<endl;
  else if((a==1 and b==3) or (a==3 and b==1))
    cout<<2<<endl;
  else if((a==2 and b==3) or (a==3 and b==2))
    cout<<1<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()

ll sum(ll n) {
if(n==0) {
return 0;
}
  ll s=n+sum(n-1);
  return s;
}
 
int main() {
 ll a,b;
  cin>>a>>b;
  ll x=sum(b-a-1);
  
  cout<<x-a<<endl;
}
  
  
  


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int INF=(2e9);
const int maxn=2010;
int n,k,q,a[maxn],ans,b[maxn],res[maxn];
int solve(int x) {
	int s=-1,sz=0;
	for (int i=1;i<=n+1;i++)
		if (a[i]>=a[x]) {
			if (s==-1) s=i;
		}
		else if (s!=-1) {
			if (i-s>=k) {
				for (int j=s;j<i;j++) b[j-s+1]=a[j];
				sort(b+1,b+i-s+1);
				for (int j=1;j+k-1<=i-s;j++) res[++sz]=b[j];
			}
			s=-1;
		}
	if (sz<q) return INF;
	sort(res+1,res+sz+1);
	return res[q]-a[x];
}
int main() {
	
	read(n),read(k),read(q);
	for (int i=1;i<=n;i++) read(a[i]);
	ans=INF;
	for (int i=1;i<=n;i++) ans=min(ans,solve(i));
	printf("%d\n",ans);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

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

#define pb push_back
#define mp make_pair

typedef long long ll;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
  int c[3][3];
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> c[i][j];
    }
  }

  for(int i = 0; i < 2; i++){
    for(int j = 0; j < 2; j++){
      if(c[i][j]-c[i+1][j] != c[i][j+1]-c[i+1][j+1] or
          c[i][j]-c[i][j+1] != c[i+1][j]-c[i+1][j+1]){
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int d[100010],n;
int swap(int a,int b)
{
	int cache=d[a];
	d[a]=d[b];
	d[b]=cache;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&d[i]);
	int pd=0,jis=0;
	mark:for(int i=1;i<=n;i++) if(d[i]==i)
	{
		jis++;
		pd=1;
		if(i>1)
		{
			if(d[i-1]==i-1)
			{
				swap(i,i-1);
				break;
			}
		}
		
		if(i<n)
		{
			if(d[i+1]==i+1)
			{
				swap(i,i+1);
				break;
			}
		}
		if(i>1)
		{
			if(d[i]!=i-1) {swap(i,i-1);
			break;}
		}
		if(i<n)
		{
			if(d[i]!=i+1)
			{
				swap(i,i+1);
				break;
			}
		}
	}
	if(pd)
	{
		pd=0;
		goto mark;
	}
	printf("%d",jis);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int a[100000];
signed main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d", &a[i]);
	int back = a[0], ty = -1;
	int cnt = 1;
	for (int i = 1; i < n; i++) {
		if (a[i] == back) {
			back = a[i];
			continue;
		}
		if (a[i] > back) {
			if (ty == -1)ty = 0;
			if (ty == 1) {
				cnt++; back = a[i]; ty = -1;
			}
			back = a[i];
			continue;
		}
		if (ty == -1)ty = 1;
		if (ty == 0) {
			cnt++; back = a[i]; ty = -1;
		}
		back = a[i];
	}
	cout << cnt << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;
// 11
int main() {
    string s;
    cin >> s;
    int zero = 0;
    int ichi = 0;
    rep(i,s.size()){
        if(s[i]=='1') ichi++;
        else zero++;
    }
    int ans = min(ichi, zero);
    cout << ans*2 << endl;
    return 0;
}

Measured memory_bytes: 3696
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    char[][] m = new char[H][W];
    for (int i = 0; i < H; i++) {
      String s = sc.next();
      for (int j = 0; j < W; j++) {
        m[i][j] = s.charAt(j);
      }
    }
    
    int[][] color = new int[H][W];
    int nowColor = 0;
    for (int s = 0; s < H*W; s++) {
      int si = s/W;
      int sj = s%W;
      if (color[si][sj] > 0) continue;
      nowColor++;
      LinkedList<Point> q = new LinkedList<>();
      q.offer(new Point(si,sj));
      color[si][sj] = nowColor;
      while (!q.isEmpty()) {
        Point p = q.poll();
        for (int d = 0; d < 4; d++) {
          int i = p.i+di[d];
          int j = p.j+dj[d];
          if (0 <= i && i < H
             && 0 <= j && j < W
             && color[i][j] == 0) {
            if (m[p.i][p.j] != m[i][j]) {
              color[i][j] = nowColor;
              //System.out.println(si+","+sj+" "+i+","+j);
              q.add(new Point(i,j));
            }
          }
        }
      }
    }
 
    int[] black = new int[H*W+1];
    int[] white = new int[H*W+1];
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (m[i][j] == '#') {
          black[color[i][j]]++;
        } else {
          white[color[i][j]]++;
        }
      }
    }
      
    long ans = 0;
    for (int i = 0; i < H*W+1; i++) {
      ans += (long)white[i]*black[i];
    }
    System.out.println(ans);
  }
  private static int[] di = {0,0,1,-1};
  private static int[] dj = {1,-1,0,0};
  private static class Point {
    private final int i;
    private final int j;
    Point(int i, int j) {
      this.i = i;
      this.j = j;
    }
  }
}

Measured memory_bytes: 39740
val PLUS = 0
val MINUS = 1

fun main(args: Array<String>) {
    val (A, B, C, D) = readLine()!!.map { it.toInt() - 48 }
    (0..1).forEach { op1 ->
        (0..1).forEach { op2 ->
            (0..1).forEach { op3 ->
                // A, B
                if (operate(operate(operate(A, B, op1), C, op2), D, op3) == 7) {
                    println(A.toString() + stringifyOperator(op1) + B.toString() + stringifyOperator(op2) + C.toString() + stringifyOperator(op3) + D.toString() + "=7")
                    return
                }
            }
        }
    }
}


fun operate(x: Int, y: Int, operator: Int) : Int {
    if (operator == PLUS) {
        return x + y
    } else {
        return x - y
    }
}

fun stringifyOperator(num: Int) : String {
    if (num == PLUS) {
        return "+"
    } else {
        return "-"
    }
}

Measured memory_bytes: 33764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    char c;
    cin >> c;
    
    string vowel = "aiueo";
    
    int i;
    for(i = 0; i < vowel.size() ; i++){
        if(vowel.at(i) == c){
            cout << "vowel" << endl;
            break;
        }
        else{
            if(i == vowel.size() -1)   cout << "consonant" << endl;
            continue;
        }
    }
    
}

Measured memory_bytes: 256
#include <map>
#include <string>
#include <iostream>
using namespace std;
int main() {
    map<string,int>t;
    int n;
    cin>>n;
    string a,b;
    while(n--){
        cin>>a>>b;
        if(a=="insert"){
            t[b]=1;
        }else{
            if(t[b]==0){
                cout<<"no"<<endl;
            }else{
                cout<<"yes"<<endl;
            }
        }
    }
}



Measured memory_bytes: 52568